Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Examples  

ci_char_traits.h

Go to the documentation of this file.
00001 
00002 #ifndef _CI_CHAR_TRAITS_H
00003 #define _CI_CHAR_TRAITS_H 1
00004 
00005 #include <string>
00006 #include <ctype.h>
00007 //#include "/usr/include/linux/string.h"
00008 namespace bioinfo 
00009 {
00010 
00019   struct ci_char_traits : public std::char_traits<char>
00020                 // just inherit all the other functions
00021                 //  that we don't need to override
00022   {
00028     static bool eq( char c1, char c2 ) {
00029       return tolower(c1) == tolower(c2);
00030     }
00031 
00037     static bool ne( char c1, char c2 ) {
00038       return tolower(c1) != tolower(c2);
00039     }
00040 
00046     static bool lt( char c1, char c2 ) {
00047       return tolower(c1) < tolower(c2);
00048     }
00049 
00050     static int compare( const char* s1,
00051                         const char* s2,
00052                         size_t n ) {
00053       return 0;
00054       //return strnicmp( s1, s2, n );
00055              // if available on your compiler,
00056              //  otherwise you can roll your own
00057     }
00058 
00059     static const char*
00060     find( const char* s, int n, char a ) {
00061       while( n-- > 0 && tolower(*s) != tolower(a) ) {
00062           ++s;
00063       }
00064       return s;
00065     }
00066   };
00067 
00068 };
00069 
00070 #endif // _CI_CHAR_TRAITS_H