40 #define STRING_IS_PROTECTED 0 49 STRING(
const char *
string);
50 STRING(
const char *data,
int length);
54 bool Serialize(FILE* fp)
const;
57 bool DeSerialize(
bool swap, FILE* fp);
66 BOOL8 contains(
const char c)
const;
69 const char *string()
const;
70 const char *c_str()
const;
73 inT32 len = length() + 1;
74 return strncpy(
new char[len], GetCStr(), len);
77 #if STRING_IS_PROTECTED 78 const char &operator[] (
inT32 index)
const;
80 void insert_range(
inT32 index,
const char*s,
int len);
81 void erase_range(
inT32 index,
int len);
83 char &operator[] (
inT32 index)
const;
86 void truncate_at(
inT32 index);
90 BOOL8 operator!= (
const char *
string)
const;
92 STRING & operator= (
const char *
string);
103 void assign(
const char *cstr,
int len);
109 void add_str_int(
const char* str,
int number);
111 void add_str_double(
const char* str,
double number);
114 inline void ensure(
inT32 min_capacity) { ensure_cstr(min_capacity); }
117 typedef struct STRING_HEADER {
139 STRING_HEADER* data_;
142 inline STRING_HEADER* GetHeader() {
145 inline const STRING_HEADER* GetHeader()
const {
150 inline char* GetCStr() {
return ((
char*)data_) +
sizeof(STRING_HEADER); }
152 inline const char* GetCStr()
const {
153 return ((
const char *)data_) +
sizeof(STRING_HEADER);
155 inline bool InvariantOk()
const {
156 #if STRING_IS_PROTECTED 157 return (GetHeader()->used_ == 0) ?
158 (string() == NULL) : (GetHeader()->used_ == (strlen(
string()) + 1));
167 char* ensure_cstr(
inT32 min_capacity);
169 void FixHeader()
const;
171 char* AllocData(
int used,
int capacity);
void ensure(inT32 min_capacity)
ICOORD & operator+=(ICOORD &op1, const ICOORD &op2)
ICOORD operator+(const ICOORD &op1, const ICOORD &op2)