diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llcommon/llstring.h | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/linden/indra/llcommon/llstring.h b/linden/indra/llcommon/llstring.h index 60a4492..7b08fd3 100644 --- a/linden/indra/llcommon/llstring.h +++ b/linden/indra/llcommon/llstring.h | |||
@@ -155,14 +155,28 @@ public: | |||
155 | static BOOL isDigit(llwchar a) { return iswdigit(a) != 0; } | 155 | static BOOL isDigit(llwchar a) { return iswdigit(a) != 0; } |
156 | }; | 156 | }; |
157 | 157 | ||
158 | /** | ||
159 | * @brief Return a string constructed from in without crashing if the | ||
160 | * pointer is NULL. | ||
161 | */ | ||
162 | std::string ll_safe_string(const char* in); | ||
163 | std::string ll_safe_string(const char* in, S32 maxlen); | ||
164 | |||
165 | |||
158 | // Allowing assignments from non-strings into format_map_t is apparently | 166 | // Allowing assignments from non-strings into format_map_t is apparently |
159 | // *really* error-prone, so subclass std::string with just basic c'tors. | 167 | // *really* error-prone, so subclass std::string with just basic c'tors. |
160 | class FormatMapString : public std::string | 168 | class LLFormatMapString |
161 | { | 169 | { |
162 | public: | 170 | public: |
163 | FormatMapString() : std::string() {}; | 171 | LLFormatMapString() {}; |
164 | FormatMapString(const char* s) : std::string(s) {}; | 172 | LLFormatMapString(const char* s) : mString(ll_safe_string(s)) {}; |
165 | FormatMapString(const std::string& s) : std::string(s) {}; | 173 | LLFormatMapString(const std::string& s) : mString(s) {}; |
174 | operator std::string() const { return mString; } | ||
175 | bool operator<(const LLFormatMapString& rhs) const { return mString < rhs.mString; } | ||
176 | std::size_t length() const { return mString.length(); } | ||
177 | |||
178 | private: | ||
179 | std::string mString; | ||
166 | }; | 180 | }; |
167 | 181 | ||
168 | template <class T> | 182 | template <class T> |
@@ -177,7 +191,7 @@ public: | |||
177 | 191 | ||
178 | static std::basic_string<T> null; | 192 | static std::basic_string<T> null; |
179 | 193 | ||
180 | typedef std::map<FormatMapString, FormatMapString> format_map_t; | 194 | typedef std::map<LLFormatMapString, LLFormatMapString> format_map_t; |
181 | static S32 format(std::basic_string<T>& s, const format_map_t& fmt_map); | 195 | static S32 format(std::basic_string<T>& s, const format_map_t& fmt_map); |
182 | 196 | ||
183 | static BOOL isValidIndex(const std::basic_string<T>& string, size_type i) | 197 | static BOOL isValidIndex(const std::basic_string<T>& string, size_type i) |
@@ -312,13 +326,6 @@ inline std::string chop_tail_copy( | |||
312 | } | 326 | } |
313 | 327 | ||
314 | /** | 328 | /** |
315 | * @brief Return a string constructed from in without crashing if the | ||
316 | * pointer is NULL. | ||
317 | */ | ||
318 | std::string ll_safe_string(const char* in); | ||
319 | std::string ll_safe_string(const char* in, S32 maxlen); | ||
320 | |||
321 | /** | ||
322 | * @brief This translates a nybble stored as a hex value from 0-f back | 329 | * @brief This translates a nybble stored as a hex value from 0-f back |
323 | * to a nybble in the low order bits of the return byte. | 330 | * to a nybble in the low order bits of the return byte. |
324 | */ | 331 | */ |