| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | //  Boost string_algo library compare.hpp header file  -------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-27 10:27:37 +00:00
										 |  |  | //  Copyright Pavol Droba 2002-2006.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Distributed under the Boost Software License, Version 1.0.
 | 
					
						
							|  |  |  | //    (See accompanying file LICENSE_1_0.txt or copy at
 | 
					
						
							|  |  |  | //          http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-27 10:27:37 +00:00
										 |  |  | //  See http://www.boost.org/ for updates, documentation, and revision history.
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef BOOST_STRING_COMPARE_HPP
 | 
					
						
							|  |  |  | #define BOOST_STRING_COMPARE_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/algorithm/string/config.hpp>
 | 
					
						
							|  |  |  | #include <locale>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*! \file
 | 
					
						
							| 
									
										
										
										
											2005-05-11 09:17:14 +00:00
										 |  |  |     Defines element comparison predicates. Many algorithms in this library can | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |     take an additional argument with a predicate used to compare elements. | 
					
						
							|  |  |  |     This makes it possible, for instance, to have case insensitive versions | 
					
						
							|  |  |  |     of the algorithms. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace boost { | 
					
						
							|  |  |  |     namespace algorithm { | 
					
						
							| 
									
										
										
										
											2005-05-11 09:17:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         //  is_equal functor  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! is_equal functor
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							| 
									
										
										
										
											2004-07-15 21:48:25 +00:00
										 |  |  |             Standard STL equal_to only handle comparison between arguments | 
					
						
							|  |  |  |             of the same type. This is a less restrictive version which wraps operator ==. | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |         */ | 
					
						
							|  |  |  |         struct is_equal | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             //! Function operator
 | 
					
						
							|  |  |  |             /*!
 | 
					
						
							|  |  |  |                 Compare two operands for equality | 
					
						
							|  |  |  |             */ | 
					
						
							|  |  |  |             template< typename T1, typename T2 > | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  |                 bool operator()( const T1& Arg1, const T2& Arg2 ) const | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             { | 
					
						
							|  |  |  |                 return Arg1==Arg2; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! case insensitive version of is_equal
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             Case insensitive comparison predicate. Comparison is done using | 
					
						
							|  |  |  |             specified locales. | 
					
						
							|  |  |  |         */ | 
					
						
							|  |  |  |         struct is_iequal | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             //! Constructor
 | 
					
						
							|  |  |  |             /*!
 | 
					
						
							|  |  |  |                 \param Loc locales used for comparison | 
					
						
							|  |  |  |             */ | 
					
						
							| 
									
										
										
										
											2005-05-11 09:17:14 +00:00
										 |  |  |             is_iequal( const std::locale& Loc=std::locale() ) : | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |                 m_Loc( Loc ) {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-11 09:17:14 +00:00
										 |  |  |             //! Function operator
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             /*!
 | 
					
						
							|  |  |  |                 Compare two operands. Case is ignored. | 
					
						
							|  |  |  |             */ | 
					
						
							|  |  |  |             template< typename T1, typename T2 > | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  |                 bool operator()( const T1& Arg1, const T2& Arg2 ) const | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2005-05-11 09:17:14 +00:00
										 |  |  |                 #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
 | 
					
						
							|  |  |  |                     return std::toupper(Arg1)==std::toupper(Arg2); | 
					
						
							|  |  |  |                 #else
 | 
					
						
							| 
									
										
										
										
											2006-04-16 09:46:34 +00:00
										 |  |  |                     return std::toupper<T1>(Arg1,m_Loc)==std::toupper<T2>(Arg2,m_Loc); | 
					
						
							| 
									
										
										
										
											2005-05-11 09:17:14 +00:00
										 |  |  |                 #endif
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private: | 
					
						
							|  |  |  |             std::locale m_Loc; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |         //  is_less functor  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! is_less functor
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             Convenient version of standard std::less. Operation is templated, therefore it is  | 
					
						
							|  |  |  |             not required to specify the exact types upon the construction | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         struct is_less | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             //! Functor operation
 | 
					
						
							|  |  |  |             /*!
 | 
					
						
							|  |  |  |                 Compare two operands using > operator | 
					
						
							|  |  |  |              */ | 
					
						
							|  |  |  |             template< typename T1, typename T2 > | 
					
						
							|  |  |  |                 bool operator()( const T1& Arg1, const T2& Arg2 ) const | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 return Arg1<Arg2; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }; | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! case insensitive version of is_less
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             Case insensitive comparison predicate. Comparison is done using | 
					
						
							|  |  |  |             specified locales. | 
					
						
							|  |  |  |         */ | 
					
						
							|  |  |  |         struct is_iless | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             //! Constructor
 | 
					
						
							|  |  |  |             /*!
 | 
					
						
							|  |  |  |                 \param Loc locales used for comparison | 
					
						
							|  |  |  |             */ | 
					
						
							|  |  |  |             is_iless( const std::locale& Loc=std::locale() ) : | 
					
						
							|  |  |  |                 m_Loc( Loc ) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //! Function operator
 | 
					
						
							|  |  |  |             /*!
 | 
					
						
							|  |  |  |                 Compare two operands. Case is ignored. | 
					
						
							|  |  |  |             */ | 
					
						
							|  |  |  |             template< typename T1, typename T2 > | 
					
						
							|  |  |  |                 bool operator()( const T1& Arg1, const T2& Arg2 ) const | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
 | 
					
						
							|  |  |  |                     return std::toupper(Arg1)<std::toupper(Arg2); | 
					
						
							|  |  |  |                 #else
 | 
					
						
							| 
									
										
										
										
											2006-04-16 09:46:34 +00:00
										 |  |  |                     return std::toupper<T1>(Arg1,m_Loc)<std::toupper<T2>(Arg2,m_Loc); | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  |                 #endif
 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private: | 
					
						
							|  |  |  |             std::locale m_Loc; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |         //  is_not_greater functor  -----------------------------------------------//
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! is_not_greater functor
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             Convenient version of standard std::not_greater_to. Operation is templated, therefore it is  | 
					
						
							|  |  |  |             not required to specify the exact types upon the construction | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         struct is_not_greater | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             //! Functor operation
 | 
					
						
							|  |  |  |             /*!
 | 
					
						
							|  |  |  |                 Compare two operands using > operator | 
					
						
							|  |  |  |              */ | 
					
						
							|  |  |  |             template< typename T1, typename T2 > | 
					
						
							|  |  |  |                 bool operator()( const T1& Arg1, const T2& Arg2 ) const | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2006-03-06 18:05:10 +00:00
										 |  |  |                 return Arg1<=Arg2; | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         }; | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //! case insensitive version of is_not_greater
 | 
					
						
							|  |  |  |         /*!
 | 
					
						
							|  |  |  |             Case insensitive comparison predicate. Comparison is done using | 
					
						
							|  |  |  |             specified locales. | 
					
						
							|  |  |  |         */ | 
					
						
							|  |  |  |         struct is_not_igreater | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             //! Constructor
 | 
					
						
							|  |  |  |             /*!
 | 
					
						
							|  |  |  |                 \param Loc locales used for comparison | 
					
						
							|  |  |  |             */ | 
					
						
							|  |  |  |             is_not_igreater( const std::locale& Loc=std::locale() ) : | 
					
						
							|  |  |  |                 m_Loc( Loc ) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //! Function operator
 | 
					
						
							|  |  |  |             /*!
 | 
					
						
							|  |  |  |                 Compare two operands. Case is ignored. | 
					
						
							|  |  |  |             */ | 
					
						
							|  |  |  |             template< typename T1, typename T2 > | 
					
						
							|  |  |  |                 bool operator()( const T1& Arg1, const T2& Arg2 ) const | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
 | 
					
						
							| 
									
										
										
										
											2006-03-06 18:05:10 +00:00
										 |  |  |                     return std::toupper(Arg1)<=std::toupper(Arg2); | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  |                 #else
 | 
					
						
							| 
									
										
										
										
											2006-04-16 09:46:34 +00:00
										 |  |  |                     return std::toupper<T1>(Arg1,m_Loc)<=std::toupper<T2>(Arg2,m_Loc); | 
					
						
							| 
									
										
										
										
											2006-01-31 14:57:15 +00:00
										 |  |  |                 #endif
 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private: | 
					
						
							|  |  |  |             std::locale m_Loc; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-11 09:17:14 +00:00
										 |  |  |     } // namespace algorithm
 | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // pull names to the boost namespace
 | 
					
						
							|  |  |  |     using algorithm::is_equal; | 
					
						
							|  |  |  |     using algorithm::is_iequal; | 
					
						
							| 
									
										
										
										
											2006-02-06 18:10:18 +00:00
										 |  |  |     using algorithm::is_less; | 
					
						
							|  |  |  |     using algorithm::is_iless; | 
					
						
							|  |  |  |     using algorithm::is_not_greater; | 
					
						
							|  |  |  |     using algorithm::is_not_igreater; | 
					
						
							| 
									
										
										
										
											2004-03-04 22:12:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace boost
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif  // BOOST_STRING_COMPARE_HPP
 |