00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef __CCXX_STRCHAR_H__
00042 #define __CCXX_STRCHAR_H__
00043
00044 #ifndef __CCXX_CONFIG_H__
00045 #include <cc++/config.h>
00046 #endif
00047
00048 #include <cctype>
00049 #include <string>
00050 #include <cstring>
00051
00052 #ifdef HAVE_STRINGS_H
00053 extern "C" {
00054 #include <strings.h>
00055 };
00056 #endif
00057
00058 #ifdef HAVE_STRCASECMP
00059 #ifndef stricmp
00060 #define stricmp(x, y) strcasecmp(x, y)
00061 #endif
00062 #ifndef strnicmp
00063 #define strnicmp(x, y, n) strncasecmp(x, y, n)
00064 #endif
00065 #endif
00066
00067 #ifdef __NAMESPACES__
00068 namespace ost {
00069 #endif
00070
00071 class keystring
00072 {
00073 private:
00074 const char *c_str;
00075
00076 public:
00077 inline keystring(const char *s)
00078 {c_str = s;}
00079
00080 inline keystring()
00081 {c_str = NULL;};
00082
00083 virtual int compare(const char *s2)
00084 {return stricmp(c_str, s2);};
00085
00086 inline const char *operator =(const char *s)
00087 {return c_str = s;};
00088
00089 friend inline int operator==(keystring k1, keystring k2)
00090 {return (k1.compare(k2) == 0);};
00091
00092 friend inline int operator==(keystring k1, const char *c)
00093 {return (k1.compare(c) == 0);};
00094
00095 friend inline int operator!=(keystring k1, const char *c)
00096 {return (k1.compare(c) != 0);};
00097
00098 friend inline int operator==(const char *c, keystring k1)
00099 {return (k1.compare(c) == 0);};
00100
00101 friend inline int operator!=(const char *c, keystring k1)
00102 {return (k1.compare(c) != 0);};
00103
00104 friend inline int operator!=(keystring k1, keystring k2)
00105 {return (k1.compare(k2) != 0);};
00106
00107 friend inline int operator<(keystring k1, keystring k2)
00108 {return (k1.compare(k2) < 0);};
00109
00110 friend inline int operator>(keystring k1, keystring k2)
00111 {return (k1.compare(k2) > 0);};
00112
00113 friend inline int operator<=(keystring k1, keystring k2)
00114 {return (k1.compare(k2) <= 0);};
00115
00116 friend inline int operator>=(keystring k1, keystring k2)
00117 {return (k1.compare(k2) >= 0);};
00118
00119 friend inline int operator!(keystring k1)
00120 {return k1.c_str == NULL;};
00121
00122 friend inline int length(keystring k1)
00123 {return strlen(k1.c_str);};
00124
00125 friend inline const char *text(keystring k1)
00126 {return k1.c_str;};
00127
00128 inline const char *operator ()()
00129 {return c_str;};
00130
00131 inline operator const char *()
00132 {return c_str;};
00133 };
00134
00135 #ifdef __NAMESPACES__
00136 };
00137 #endif
00138
00139 #endif