Xbase64 Class Library 3.1.2
xbstring.h
Go to the documentation of this file.
1/* xbstring.h
2
3 Xbase64 project source code
4
5 This file contains the Class definition for a xbString object.
6
7 Copyright (C) 1997,2003 Gary A Kunkel
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23
24 Contact:
25
26 Email:
27
28 xdb-devel@lists.sourceforge.net
29 xdb-users@lists.sourceforge.net
30
31
32 Regular Mail:
33
34 XBase Support
35 149C South Main St
36 Keller Texas, 76248
37 USA
38
39*/
40
41#ifndef __XBSTRING_H__
42#define __XBSTRING_H__
43
44#ifdef __GNU_LesserG__
45#pragma interface
46#endif
47
48#ifdef __WIN32__
49#include <xbase64/xbwincfg.h>
50#else
51#include <xbase64/xbconfig.h>
52#endif
53
54#include <stdlib.h>
55#include <iostream>
56
61
64public:
65 enum {npos = -1};
66
67 xbString();
68 xbString(size_t size);
69 xbString(char c);
70 xbString(const char *s);
71 xbString(const char *s, size_t maxlen);
72 xbString(const xbString &s);
73 virtual ~xbString();
74
75 operator const char *() const;
76 char operator[](int n) { return data[n]; }
77
78 xbString &operator=(const xbString &s);
79 xbString &operator=(const char *s);
80 xbString &operator=(char c);
81 xbString &operator+=(const char *s);
82 xbString &operator+=(char c);
83 xbString &operator-=(const char *s);
84
85 xbBool operator == ( const xbString& ) const;
86 xbBool operator != ( const xbString& ) const;
87 xbBool operator < ( const xbString& ) const;
88 xbBool operator > ( const xbString& ) const;
89 xbBool operator <= ( const xbString& ) const;
90 xbBool operator >= ( const xbString& ) const;
91
92 friend XBDLLEXPORT std::ostream& operator << ( std::ostream&,
93 const xbString& );
94 void addBackSlash( char c );
95 xbString &assign(const xbString& str, size_t pos = 0, int n = npos);
96 xbString &assign(char* str, int n);
97 xbString copy() const;
98 const char *c_str() const;
99 int countChar( char c ) const;
100 int cvtHexChar( char & out );
101 int cvtHexString( xbString & out );
102 char getCharacter( int n ) const { return data[n]; }
103 const char *getData() const;
104 xbBool hasAlphaChars() const;
105 xbBool isEmpty() const;
106 xbBool isNull() const;
107 size_t len() const;
108 size_t length() const;
109 xbString mid(size_t pos = 0, int n = npos) const;
110 void lTrunc( size_t cnt );
111 int pos(char c);
112 int pos(const char* s);
113 void putAt(size_t pos, char c);
114 xbString &remove(size_t pos = 0, int n = npos);
115 void resize(size_t size);
116 void setNum(long num);
117 void setNum(char * fmt, double num);
118 xbString &sprintf(const char *format, ...);
119 void swapChars( char from, char to );
120 void toLowerCase();
121 void toUpperCase();
122 void trim();
123 void zapChar( char c );
124 void zapLeadingChar( char c );
125 int setFromDelimitedInput(const char *,char, int, int );
126
127protected:
128 void ctor(const char *s);
129 void ctor(const char *s, size_t maxlen);
130 char *data;
131 size_t size;
132 static const char * NullString;
133};
134
135XBDLLEXPORT xbString operator-(const xbString &s1, const xbString &s2);
136XBDLLEXPORT xbString operator+(const xbString &s1, const xbString &s2);
137XBDLLEXPORT xbString operator+(const xbString &s1, const char *s2);
138XBDLLEXPORT xbString operator+(const char *s1, const xbString &s2);
139XBDLLEXPORT xbString operator+(const xbString &s1, char c2);
140XBDLLEXPORT xbString operator+(char c1, const xbString &s2);
141XBDLLEXPORT xbBool operator==(const xbString &s1, const char *s2);
142XBDLLEXPORT xbBool operator!=(const xbString &s1, const char *s2);
143
144#endif
145
xbString class
Definition xbstring.h:63
char operator[](int n)
Definition xbstring.h:76
char getCharacter(int n) const
Definition xbstring.h:102
size_t size
Definition xbstring.h:131
char * data
Definition xbstring.h:130
static const char * NullString
Definition xbstring.h:132
#define XBDLLEXPORT
Definition xbase64.h:86
XBDLLEXPORT std::ostream & operator<<(std::ostream &os, const xbString &xbs)
Short description.
Definition xbstring.cpp:592
XBDLLEXPORT xbBool operator==(const xbString &s1, const char *s2)
Short description.
Definition xbstring.cpp:476
XBDLLEXPORT xbBool operator!=(const xbString &s1, const char *s2)
Short description.
Definition xbstring.cpp:495
XBDLLEXPORT xbBool operator==(const xbString &s1, const char *s2)
Short description.
Definition xbstring.cpp:476
XBDLLEXPORT xbString operator-(const xbString &s1, const xbString &s2)
Short description.
Definition xbstring.cpp:600
XBDLLEXPORT xbString operator+(const xbString &s1, const xbString &s2)
Short description.
Definition xbstring.cpp:609
XBDLLEXPORT xbBool operator!=(const xbString &s1, const char *s2)
Short description.
Definition xbstring.cpp:495
short int xbBool
xbBool type
Definition xbtypes.h:78