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);
64 BOOL8 contains(
const char c)
const;
67 const char *string()
const;
68 const char *c_str()
const;
71 inT32 len = length() + 1;
72 return strncpy(
new char[len], GetCStr(), len);
75 #if STRING_IS_PROTECTED
76 const char &operator[] (
inT32 index)
const;
78 void insert_range(
inT32 index,
const char*s,
int len);
79 void erase_range(
inT32 index,
int len);
81 char &operator[] (
inT32 index)
const;
84 void truncate_at(
inT32 index);
88 BOOL8 operator!= (
const char *
string)
const;
90 STRING & operator= (
const char *
string);
101 void assign(
const char *cstr,
int len);
107 void add_str_int(
const char* str,
int number);
109 void add_str_double(
const char* str,
double number);
112 inline void ensure(
inT32 min_capacity) { ensure_cstr(min_capacity); }
115 typedef struct STRING_HEADER {
137 STRING_HEADER* data_;
140 inline STRING_HEADER* GetHeader() {
143 inline const STRING_HEADER* GetHeader()
const {
148 inline char* GetCStr() {
149 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);
ICOORD operator+(const ICOORD &op1, const ICOORD &op2)
void ensure(inT32 min_capacity)
ICOORD & operator+=(ICOORD &op1, const ICOORD &op2)