diff options
author | nyamatongwe <unknown> | 2004-04-02 11:33:55 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2004-04-02 11:33:55 +0000 |
commit | b745b468bb0d82b3406b86325f69d18d7cf791c2 (patch) | |
tree | 94c976ec45aeaee9d82a43f8a37fe1a52125e9d2 /include/SString.h | |
parent | 9cdfd99f604c738656504beb18ebe6c7dd8ba99c (diff) | |
download | scintilla-mirror-b745b468bb0d82b3406b86325f69d18d7cf791c2.tar.gz |
String code from Pavol Bosik used by Anjuta.
Diffstat (limited to 'include/SString.h')
-rw-r--r-- | include/SString.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/SString.h b/include/SString.h index 3efb84a03..960945dbc 100644 --- a/include/SString.h +++ b/include/SString.h @@ -109,6 +109,18 @@ public: const char *c_str() const { return s ? s : ""; } + /** Attach to a string allocated by means of StringAlloc(len). */ + SString &attach(char *s_, lenpos_t sLen_ = measure_length, lenpos_t sSize_ = measure_length) { + delete []s; + s = s_; + if (!s) { + sLen = sSize = 0; + } else { + sLen = (sLen_ == measure_length ? strlen(s) : sLen_); + sSize = (sSize_ == measure_length ? sLen + 1 : sSize_); + } + return *this; + } /** Give ownership of buffer to caller which must use delete[] to free buffer. */ char *detach() { char *sRet = s; @@ -175,6 +187,11 @@ public: static char *StringAllocate( const char *s, ///< The string to duplicate lenpos_t len=measure_length); ///< The length of memory to allocate. Optional. + /** + * Allocate uninitialized memory big enough to fit a string of the given length + * @return the pointer to the new string + */ + static char *StringAllocate(lenpos_t len); }; /** |