| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#ifndef SIMPLE_STRING_LIB |
| 10 |
#define SIMPLE_STRING_LIB |
| 11 |
|
| 12 |
#ifdef use_namespace |
| 13 |
namespace RBD_COMMON { |
| 14 |
#endif |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
class SimpleString |
| 19 |
{ |
| 20 |
char* S; |
| 21 |
unsigned int n; |
| 22 |
public: |
| 23 |
SimpleString(); |
| 24 |
~SimpleString() { delete [] S; } |
| 25 |
SimpleString(const SimpleString& s); |
| 26 |
SimpleString(const char* c); |
| 27 |
SimpleString(unsigned int i, char c); |
| 28 |
void operator=(const SimpleString& s); |
| 29 |
void operator=(const char*); |
| 30 |
void operator=(char); |
| 31 |
void operator+=(const SimpleString& s); |
| 32 |
void operator+=(const char*); |
| 33 |
void operator+=(char); |
| 34 |
friend SimpleString operator+(const SimpleString& s1, const SimpleString& s2); |
| 35 |
friend SimpleString operator+(const char* c1, const SimpleString& s2); |
| 36 |
friend SimpleString operator+(const SimpleString& s1, const char* c2); |
| 37 |
friend SimpleString operator+(char c1, const SimpleString& s2); |
| 38 |
friend SimpleString operator+(const SimpleString& s1, char c2); |
| 39 |
unsigned int length() const { return n; } |
| 40 |
unsigned int size() const { return n; } |
| 41 |
const char* c_str() const { return S; } |
| 42 |
const char* data() const { return S; } |
| 43 |
}; |
| 44 |
|
| 45 |
#ifdef use_namespace |
| 46 |
} |
| 47 |
#endif |
| 48 |
|
| 49 |
|
| 50 |
#endif |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|