openModeller  Version 1.5.0
ignorecase_traits.hh
Go to the documentation of this file.
1 #ifndef _ICSTRING_HH
2 #define _ICSTRING_HH
3 
4 #include <string>
5 #include <cctype> // for std::toupper in this file and std::size_t in the .cpp
6 
9 
10 // Define a char_traits struct to make strings case insensitive.
11 // Taken from Josuttis.
12 struct dllexp ignorecase_traits : std::char_traits<char>
13 {
14  static inline bool eq( const char& c1, const char& c2 ) {
15  return std::toupper(c1)==std::toupper(c2);
16  }
17  static inline bool lt( const char& c1, const char& c2 ) {
18  return std::toupper(c1)<std::toupper(c2);
19  }
20  static int compare(const char* s1, const char* s2, std::size_t n);
21  static const char* find( const char* s,std::size_t n, const char& c );
22 };
23 
24 class icstring : public std::basic_string< char, ignorecase_traits > {
25 public:
26 
27  inline
29  std::basic_string<char,ignorecase_traits>()
30  {}
31 
32  inline
33  icstring( const std::string & rhs ) :
34  std::basic_string<char,ignorecase_traits>( rhs.c_str() )
35  {}
36 
37  inline
38  icstring( const char* chrs ) :
39  std::basic_string<char,ignorecase_traits>( chrs )
40  {}
41 
42  inline operator std::string() const {
43  return std::string( this->c_str() );
44  }
45 };
46 
47 
48 
49 #endif
static bool lt(const char &c1, const char &c2)
icstring(const std::string &rhs)
static bool eq(const char &c1, const char &c2)
icstring(const char *chrs)