@@ -43,6 +43,10 @@ class String
43
43
{
44
44
public:
45
45
// constructors
46
+ // creates a copy of the initial value.
47
+ // if the initial value is null or invalid, or if memory allocation
48
+ // fails, the string will be marked as invalid (i.e. operator bool()
49
+ // will return false).
46
50
String (const char *cstr = " " );
47
51
String (const String &str);
48
52
#ifdef __GXX_EXPERIMENTAL_CXX0X__
@@ -58,9 +62,15 @@ class String
58
62
~String (void );
59
63
60
64
// memory management
65
+ // return true on success, false on failure (in which case, the string
66
+ // is left unchanged). reserve(0), if successful, will validate an
67
+ // invalid string (i.e., operator bool() will return true afterwards)
61
68
unsigned char reserve (unsigned int size);
62
69
inline unsigned int length (void ) const {return len;}
63
70
71
+ // creates a copy of the assigned value. if the value is null or
72
+ // invalid, or if the memory allocation fails, the string will be
73
+ // marked as invalid (operator bool() will return false).
64
74
String & operator = (const String &rhs);
65
75
String & operator = (const char *cstr);
66
76
#ifdef __GXX_EXPERIMENTAL_CXX0X__
@@ -70,6 +80,9 @@ class String
70
80
String & operator = (char c);
71
81
72
82
// concat
83
+ // returns true on success, false on failure (in which case, the string
84
+ // is left unchanged). if the argument is null or invalid, the
85
+ // concatenation is considered unsucessful.
73
86
unsigned char concat (const String &str);
74
87
unsigned char concat (const char *cstr);
75
88
unsigned char concat (char c);
@@ -78,6 +91,9 @@ class String
78
91
unsigned char concat (unsigned int num);
79
92
unsigned char concat (long num);
80
93
unsigned char concat (unsigned long num);
94
+
95
+ // if there's not enough memory for the concatenated value, the string
96
+ // will be left unchanged (but this isn't signalled in any way)
81
97
String & operator += (const String &rhs) {concat (rhs); return (*this );}
82
98
String & operator += (const char *cstr) {concat (cstr); return (*this );}
83
99
String & operator += (char c) {concat (c); return (*this );}
0 commit comments