Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

strchar.h

Go to the documentation of this file.
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 
00044 #ifndef CCXX_STRCHAR_H_
00045 #define CCXX_STRCHAR_H_
00046 
00047 #ifndef CCXX_CONFIG_H_
00048 #include <cc++/config.h>
00049 #endif
00050 
00051 #ifndef CCXX_MISSING_H_
00052 #include <cc++/missing.h>
00053 #endif
00054 
00055 #include <cctype>
00056 #include <string>
00057 #include <cstring>
00058 
00059 #ifdef  HAVE_STRINGS_H
00060 extern "C" {
00061 #include <strings.h>
00062 }
00063 #endif
00064 
00065 #ifdef  HAVE_STRCASECMP
00066 #ifndef stricmp
00067 #define stricmp(x, y) strcasecmp(x, y)
00068 #endif
00069 #ifndef strnicmp
00070 #define strnicmp(x, y, n) strncasecmp(x, y, n)
00071 #endif
00072 #endif
00073 
00074 #ifdef  CCXX_NAMESPACES
00075 namespace ost {
00076 #endif
00077 
00078 __EXPORT char *lsetField(char *target, size_t size, const char *src, const char fill = 0);
00079 __EXPORT char *rsetField(char *target, size_t size, const char *src, const char fill = 0);
00080 __EXPORT char *setString(char *target, size_t size, const char *src);
00081 __EXPORT char *addString(char *target, size_t size, const char *src);
00082 __EXPORT char *newString(const char *src, size_t size = 0);
00083 __EXPORT void delString(char *str);
00084 __EXPORT char *setUpper(char *string, size_t size);
00085 __EXPORT char *setLower(char *string, size_t size);
00086 __EXPORT char *find(const char *cs, char *str, size_t len = 0);
00087 __EXPORT char *rfind(const char *cs, char *str, size_t len = 0);
00088 __EXPORT char *ifind(const char *cs, char *str, size_t len = 0);
00089 __EXPORT char *strip(const char *cs, char *str, size_t len = 0);
00090 __EXPORT size_t strchop(const char *cs, char *str, size_t len = 0);
00091 __EXPORT size_t strtrim(const char *cs, char *str, size_t len = 0);
00092 
00093 inline char *dupString(const char *src, size_t size = 0)
00094         {return newString(src, size);}
00095 
00096 /*
00097 class keystring
00098 {
00099 private:
00100         const char *c_str;
00101 
00102 public:
00103         inline keystring(const char *s)
00104                 {c_str = s;}
00105 
00106         inline keystring()
00107                 {c_str = NULL;};
00108 
00109         virtual int compare(const char *s2)
00110                 {return stricmp(c_str, s2);};
00111 
00112         inline const char *operator =(const char *s)
00113                 {return c_str = s;};
00114 
00115         friend inline int operator==(keystring k1, keystring k2)
00116                 {return (k1.compare(k2) == 0);};
00117 
00118         friend inline int operator==(keystring k1, const char *c)
00119                 {return (k1.compare(c) == 0);};
00120 
00121         friend inline int operator!=(keystring k1, const char *c)
00122                 {return (k1.compare(c) != 0);};
00123 
00124         friend inline int operator==(const char *c, keystring k1)
00125                 {return (k1.compare(c) == 0);};
00126 
00127         friend inline int operator!=(const char *c, keystring k1)
00128                 {return (k1.compare(c) != 0);};
00129 
00130         friend inline int operator!=(keystring k1, keystring k2)
00131                 {return (k1.compare(k2) != 0);};
00132 
00133         friend inline int operator<(keystring k1, keystring k2)
00134                 {return (k1.compare(k2) < 0);};
00135 
00136         friend inline int operator>(keystring k1, keystring k2)
00137                 {return (k1.compare(k2) > 0);};
00138 
00139         friend inline int operator<=(keystring k1, keystring k2)
00140                 {return (k1.compare(k2) <= 0);};
00141 
00142         friend inline int operator>=(keystring k1, keystring k2)
00143                 {return (k1.compare(k2) >= 0);};
00144 
00145         friend inline int operator!(keystring k1)
00146                 {return k1.c_str == NULL;};
00147 
00148         friend inline int length(keystring k1)
00149                 {return static_cast<int>(strlen(k1.c_str));};
00150 
00151         friend inline const char *text(keystring k1)
00152                 {return k1.c_str;};
00153 
00154         inline const char *operator ()()
00155                 {return c_str;};
00156 
00157         inline operator const char *()
00158                 {return c_str;};
00159 };
00160 
00161 */
00162 
00163 #ifdef  CCXX_NAMESPACES
00164 }
00165 #endif
00166 
00167 #endif

Generated on Sat May 12 17:47:52 2007 for GNU CommonC++ by  doxygen 1.3.9.1