Changeset 955 for cpp/frams/util
- Timestamp:
- 06/25/20 00:34:29 (5 years ago)
- Location:
- cpp/frams/util
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/util/sstring-simple.cpp
r897 r955 22 22 } 23 23 24 SString::SString(int x)25 {26 initEmpty();27 if (x)28 ensureSize(x + 1);29 }30 31 24 SString::SString(const char *t, int t_len) 32 25 { … … 46 39 txt = from.txt; size = from.size; used = from.used; 47 40 from.txt = NULL; from.size = 0; from.used = 0; 41 } 42 43 SString::SString(char in) 44 { 45 initEmpty(); 46 append(&in, 1); 48 47 } 49 48 … … 117 116 SString SString::operator+(const SString& s) const 118 117 { 119 SString ret(len() + s.len()); 118 SString ret; 119 ret.reserve(len() + s.len()); 120 120 ret = *this; 121 121 ret += s; -
cpp/frams/util/sstring-simple.h
r793 r955 27 27 SString(); ///< make an empty string 28 28 SString(const char*t, int t_len = -1); ///< make a string from char* 29 SString(int x) ; ///< string with initial buffer allocated for x characters29 SString(int x) = delete; ///< disallow the former 'int' constructor (so the new 'char' version is not used through implicit conversion) 30 30 SString(const SString& from); ///< duplicate string 31 31 SString(SString&& from);///< move 32 SString(char in); 32 33 ~SString(); 33 34 34 35 void copyFrom(const char* ch, int chlen = -1); ///< copy string, length of -1 == unknown 35 36 36 37 void* operator new(size_t s, void* mem){ return mem; } 37 38 #ifdef _MSC_VER … … 43 44 int len() const { return used; } ///< get string length 44 45 void shrink(); ///< free unnecessary buffer 46 void reserve(int needed) { ensureSize(needed); } ///< like in std::string 45 47 46 48 /// after this call, you can modify sstring directly. -
cpp/frams/util/sstring.cpp
r897 r955 127 127 } 128 128 129 SString::SString(int x)130 {131 buf = new SBuf(x);132 }133 134 129 SString::SString(const char *t, int t_len) 135 130 { … … 157 152 REF_UNLOCK; 158 153 } 154 } 155 156 SString::SString(char in) 157 { 158 initEmpty(); 159 copyFrom(&in, 1); 159 160 } 160 161 -
cpp/frams/util/sstring.h
r889 r955 70 70 SString(); ///< make an empty string 71 71 SString(const char*t, int t_len = -1); ///< make a string from char* 72 SString(int x) ; ///< string with initial buffer size72 SString(int x) = delete; ///< disallow the former 'int' constructor (so the new 'char' version is not used through implicit conversion) 73 73 SString(const SString& from); ///< duplicate string 74 74 SString(SString&& from); ///< move 75 SString(char in); 75 76 ~SString(); 76 77 … … 86 87 int len() const { return buf->used; } ///< get string length 87 88 void shrink(); ///< free unnecessary buffer 89 void reserve(int needed) { ensureSize(needed); } ///< like in std::string 88 90 89 91 /// after this call, you can modify sstring directly.
Note: See TracChangeset
for help on using the changeset viewer.