xbstring.h

Go to the documentation of this file.
00001 /* 
00002 
00003     Xbase project source code
00004 
00005     This file contains the Class definition for a xbString object.
00006 
00007     Copyright (C) 1997  StarTech, Gary A. Kunkel   
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public
00020     License along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     Contact:
00024 
00025       Mail:
00026 
00027         Technology Associates, Inc.
00028         XBase Project
00029         1455 Deming Way #11
00030         Sparks, NV 89434
00031         USA
00032 
00033       Email:
00034 
00035         xbase@techass.com
00036 
00037       See our website at:
00038 
00039         xdb.sourceforge.net
00040 
00041 
00042     V 1.9.2  9/14/99    - Misc user supplied updates 
00043 */
00044 
00045 #ifndef __XBSTRING_H__
00046 #define __XBSTRING_H__
00047 
00048 #ifdef __GNUG__
00049 #pragma interface
00050 #endif
00051 
00052 #ifdef __WIN32__
00053 #include <xbase/xbconfigw32.h>
00054 #else
00055 #include <xbase/xbconfig.h>
00056 #endif
00057 
00058 #include <stdlib.h>
00059 #include <iostream.h>
00060 
00064 
00065 
00068 class XBDLLEXPORT xbString {
00069 public:
00070   enum {npos = -1};
00071 
00072   xbString();
00073   xbString(size_t size);
00074   xbString(char c);
00075   xbString(const char *s);
00076   xbString(const char *s, size_t maxlen);
00077   xbString(const xbString &s);
00078 
00079   ~xbString();
00080 
00081   xbString &operator=(const xbString &s);
00082   xbString &operator=(const char *s);
00083   xbString &operator=(char c);
00084   
00085   bool isNull() const;
00086   bool isEmpty() const;
00087   size_t len() const;
00088   size_t length() const;
00089 
00090   void resize(size_t size);  
00091   xbString copy() const;
00092   
00093   xbString &sprintf(const char *format, ...);
00094   void setNum(long num);
00095   
00096   xbString& assign(const xbString& str, size_t pos = 0, int n = npos);
00097   xbString& assign(char* str, int n);
00098   char operator[](int n) { return data[n]; }
00099   char getCharacter( int n ) const { return data[n]; }
00100   operator const char *() const;
00101   xbString &operator+=(const char *s);
00102   xbString &operator+=(char c);
00103   xbString &operator-=(const char *s);
00104   void putAt(size_t pos, char c);
00105 
00106   const char *getData() const;
00107   const char *c_str() const;
00108   void toLowerCase();
00109   int pos(char c);
00110   int pos(const char* s);
00111   void trim();
00112   bool compare(char s);
00113   bool compare(const char *s);
00114 
00115   bool operator == ( const xbString& ) const;
00116   bool operator != ( const xbString& ) const;
00117   bool operator < ( const xbString& ) const;
00118   bool operator > ( const xbString& ) const;
00119   bool operator <= ( const xbString& ) const;
00120   bool operator >= ( const xbString& ) const;
00121 
00122   friend ostream& operator << ( ostream&, const xbString& );
00123 
00124   xbString &remove(size_t pos = 0, int n = npos);
00125   xbString mid(size_t pos = 0, int n = npos) const;
00126 
00127 protected:
00128   void ctor(const char *s);
00129   void ctor(const char *s, size_t maxlen);
00130 
00131   char *data;
00132   size_t size;
00133   static const char * NullString;
00134 };
00135 
00136 bool operator==(const xbString &s1, const char *s2);
00137 bool operator!=(const xbString &s1, const char *s2);
00138 bool operator==(const xbString &s1, char s2);
00139 bool operator!=(const xbString &s1, char s2);
00140 
00141 xbString operator+(const xbString &s1, const xbString &s2);
00142 xbString operator+(const xbString &s1, const char *s2);
00143 xbString operator+(const char *s1, const xbString &s2);
00144 xbString operator+(const xbString &s1, char c2);
00145 xbString operator+(char c1, const xbString &s2);
00146 xbString operator-(const xbString &s1, const xbString &s2);
00147 
00148 #endif
00149 

Generated on Fri Aug 17 03:28:42 2007 for Xbase Class Library by  doxygen 1.5.2