Changeset 973 for cpp/frams/util/sstring-simple.h
- Timestamp:
- 07/03/20 00:37:13 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/util/sstring-simple.h
r955 r973 14 14 private: 15 15 char *txt; ///< string buffer or NULL for empty string 16 int size; ///< allocated memory (including \0)16 int allocated; ///< allocated memory (including \0) 17 17 int used; ///< string length 18 18 int appending; ///< append mode, changes can occur after character # 'appending' … … 20 20 void initEmpty(); 21 21 void copyFrom(SString &from); ///< copy from SString 22 void re size(int newsize);23 void ensure Size(int needed);22 void reallocate(int newsize); 23 void ensureAllocated(int needed); 24 24 const char* getPtr() const { return txt ? txt : ""; } 25 25 … … 34 34 35 35 void copyFrom(const char* ch, int chlen = -1); ///< copy string, length of -1 == unknown 36 37 void* operator new(size_t s, void* mem) { return mem; }36 37 void* operator new(size_t s, void* mem) { return mem; } 38 38 #ifdef _MSC_VER 39 39 void operator delete(void* mem, void* t) {} 40 40 #endif 41 void* operator new(size_t s) { return malloc(sizeof(SString)); }41 void* operator new(size_t s) { return malloc(sizeof(SString)); } 42 42 void operator delete(void* mem) { free(mem); } 43 43 44 int len() const { return used; } ///< get string length 44 int length() const { return used; } ///< get string length 45 int size() const { return length(); } ///< get string length 45 46 void shrink(); ///< free unnecessary buffer 46 void reserve(int needed) { ensureSize(needed); } ///< like in std::string47 void reserve(int cap) { ensureAllocated(cap + 1); } ///< like in std::string 47 48 48 49 /// after this call, you can modify sstring directly. … … 87 88 void endAppend(int appendlength = -1); 88 89 89 void memoryHint(int howbig) { ensureSize(howbig); } 90 int directMaxLen() { return size - 1; } ///< when called after directWrite: max number of characters allowed (can be more than requested) 90 int capacity() { return (allocated > 0) ? (allocated - 1) : allocated; } ///< std::string.capacity() 91 91 92 92 /// find a character in SString.
Note: See TracChangeset
for help on using the changeset viewer.