Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

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  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         xdb-devel@lists.sourceforge.net
00037         xdb-users@lists.sourceforge.net
00038 
00039       See our website at:
00040 
00041         xdb.sourceforge.net
00042 
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>
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   virtual ~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 XBDLLEXPORT std::ostream& operator << ( std::ostream&,
00123                                                  const xbString& );
00124 
00125   xbString &remove(size_t pos = 0, int n = npos);
00126   xbString mid(size_t pos = 0, int n = npos) const;
00127 
00128 protected:
00129   void ctor(const char *s);
00130   void ctor(const char *s, size_t maxlen);
00131 
00132   char *data;
00133   size_t size;
00134   static const char * NullString;
00135 };
00136 
00137 XBDLLEXPORT xbString operator-(const xbString &s1, const xbString &s2);
00138 XBDLLEXPORT xbString operator+(const xbString &s1, const xbString &s2);
00139 XBDLLEXPORT xbString operator+(const xbString &s1, const char *s2);
00140 XBDLLEXPORT xbString operator+(const char *s1, const xbString &s2);
00141 XBDLLEXPORT xbString operator+(const xbString &s1, char c2);
00142 XBDLLEXPORT xbString operator+(char c1, const xbString &s2);
00143 XBDLLEXPORT bool operator==(const xbString &s1, const char *s2);
00144 XBDLLEXPORT bool operator!=(const xbString &s1, const char *s2);
00145 
00146 #endif
00147 

Generated on Wed Jan 26 11:45:09 2005 for Xbase Class Library by  doxygen 1.4.1