00001 // Copyright (C) 1999-2005 Open Source Telecom Corporation. 00002 // 00003 // This program is free software; you can redistribute it and/or modify 00004 // it under the terms of the GNU General Public License as published by 00005 // the Free Software Foundation; either version 2 of the License, or 00006 // (at your option) any later version. 00007 // 00008 // This program is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with this program; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 // 00017 // As a special exception, you may use this file as part of a free software 00018 // library without restriction. Specifically, if other files instantiate 00019 // templates or use macros or inline functions from this file, or you compile 00020 // this file and link it with other files to produce an executable, this 00021 // file does not by itself cause the resulting executable to be covered by 00022 // the GNU General Public License. This exception does not however 00023 // invalidate any other reasons why the executable file might be covered by 00024 // the GNU General Public License. 00025 // 00026 // This exception applies only to the code released under the name GNU 00027 // Common C++. If you copy code from other releases into a copy of GNU 00028 // Common C++, as the General Public License permits, the exception does 00029 // not apply to the code that you add in this way. To avoid misleading 00030 // anyone as to the status of such modified files, you must delete 00031 // this exception notice from them. 00032 // 00033 // If you write modifications of your own for GNU Common C++, it is your choice 00034 // whether to permit this exception to apply to your modifications. 00035 // If you do not wish that, delete this exception notice. 00036 // 00037 00038 #ifndef CCXX_STRCHAR_H_ 00039 #define CCXX_STRCHAR_H_ 00040 00041 #ifndef CCXX_CONFIG_H_ 00042 #include <cc++/config.h> 00043 #endif 00044 00045 #ifndef CCXX_MISSING_H_ 00046 #include <cc++/missing.h> 00047 #endif 00048 00049 #include <cctype> 00050 #include <string> 00051 #include <cstring> 00052 00053 #ifdef HAVE_STRINGS_H 00054 extern "C" { 00055 #include <strings.h> 00056 } 00057 #endif 00058 00059 #ifdef HAVE_STRCASECMP 00060 #ifndef stricmp 00061 #define stricmp(x, y) strcasecmp(x, y) 00062 #endif 00063 #ifndef strnicmp 00064 #define strnicmp(x, y, n) strncasecmp(x, y, n) 00065 #endif 00066 #endif 00067 00068 #ifdef CCXX_NAMESPACES 00069 namespace ost { 00070 #endif 00071 00072 __EXPORT char *lsetField(char *target, size_t size, const char *src, const char fill = 0); 00073 __EXPORT char *rsetField(char *target, size_t size, const char *src, const char fill = 0); 00074 __EXPORT char *setString(char *target, size_t size, const char *src); 00075 __EXPORT char *addString(char *target, size_t size, const char *src); 00076 __EXPORT char *newString(const char *src, size_t size = 0); 00077 __EXPORT void delString(char *str); 00078 __EXPORT char *find(const char *cs, char *str, size_t len = 0); 00079 __EXPORT char *rfind(const char *cs, char *str, size_t len = 0); 00080 __EXPORT char *ifind(const char *cs, char *str, size_t len = 0); 00081 __EXPORT char *strip(const char *cs, char *str, size_t len = 0); 00082 __EXPORT size_t strchop(const char *cs, char *str, size_t len = 0); 00083 __EXPORT size_t strtrim(const char *cs, char *str, size_t len = 0); 00084 00085 /* 00086 class keystring 00087 { 00088 private: 00089 const char *c_str; 00090 00091 public: 00092 inline keystring(const char *s) 00093 {c_str = s;} 00094 00095 inline keystring() 00096 {c_str = NULL;}; 00097 00098 virtual int compare(const char *s2) 00099 {return stricmp(c_str, s2);}; 00100 00101 inline const char *operator =(const char *s) 00102 {return c_str = s;}; 00103 00104 friend inline int operator==(keystring k1, keystring k2) 00105 {return (k1.compare(k2) == 0);}; 00106 00107 friend inline int operator==(keystring k1, const char *c) 00108 {return (k1.compare(c) == 0);}; 00109 00110 friend inline int operator!=(keystring k1, const char *c) 00111 {return (k1.compare(c) != 0);}; 00112 00113 friend inline int operator==(const char *c, keystring k1) 00114 {return (k1.compare(c) == 0);}; 00115 00116 friend inline int operator!=(const char *c, keystring k1) 00117 {return (k1.compare(c) != 0);}; 00118 00119 friend inline int operator!=(keystring k1, keystring k2) 00120 {return (k1.compare(k2) != 0);}; 00121 00122 friend inline int operator<(keystring k1, keystring k2) 00123 {return (k1.compare(k2) < 0);}; 00124 00125 friend inline int operator>(keystring k1, keystring k2) 00126 {return (k1.compare(k2) > 0);}; 00127 00128 friend inline int operator<=(keystring k1, keystring k2) 00129 {return (k1.compare(k2) <= 0);}; 00130 00131 friend inline int operator>=(keystring k1, keystring k2) 00132 {return (k1.compare(k2) >= 0);}; 00133 00134 friend inline int operator!(keystring k1) 00135 {return k1.c_str == NULL;}; 00136 00137 friend inline int length(keystring k1) 00138 {return static_cast<int>(strlen(k1.c_str));}; 00139 00140 friend inline const char *text(keystring k1) 00141 {return k1.c_str;}; 00142 00143 inline const char *operator ()() 00144 {return c_str;}; 00145 00146 inline operator const char *() 00147 {return c_str;}; 00148 }; 00149 00150 */ 00151 00152 #ifdef CCXX_NAMESPACES 00153 } 00154 #endif 00155 00156 #endif
1.4.4