From 31e7c77a411d94bc87f0232588b339149bb29a49 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Sun, 28 Sep 2008 17:21:23 -0500 Subject: Second Life viewer sources 1.21.3-RC --- linden/indra/llcommon/llstring.h | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'linden/indra/llcommon/llstring.h') 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: static BOOL isDigit(llwchar a) { return iswdigit(a) != 0; } }; +/** + * @brief Return a string constructed from in without crashing if the + * pointer is NULL. + */ +std::string ll_safe_string(const char* in); +std::string ll_safe_string(const char* in, S32 maxlen); + + // Allowing assignments from non-strings into format_map_t is apparently // *really* error-prone, so subclass std::string with just basic c'tors. -class FormatMapString : public std::string +class LLFormatMapString { public: - FormatMapString() : std::string() {}; - FormatMapString(const char* s) : std::string(s) {}; - FormatMapString(const std::string& s) : std::string(s) {}; + LLFormatMapString() {}; + LLFormatMapString(const char* s) : mString(ll_safe_string(s)) {}; + LLFormatMapString(const std::string& s) : mString(s) {}; + operator std::string() const { return mString; } + bool operator<(const LLFormatMapString& rhs) const { return mString < rhs.mString; } + std::size_t length() const { return mString.length(); } + +private: + std::string mString; }; template @@ -177,7 +191,7 @@ public: static std::basic_string null; - typedef std::map format_map_t; + typedef std::map format_map_t; static S32 format(std::basic_string& s, const format_map_t& fmt_map); static BOOL isValidIndex(const std::basic_string& string, size_type i) @@ -312,13 +326,6 @@ inline std::string chop_tail_copy( } /** - * @brief Return a string constructed from in without crashing if the - * pointer is NULL. - */ -std::string ll_safe_string(const char* in); -std::string ll_safe_string(const char* in, S32 maxlen); - -/** * @brief This translates a nybble stored as a hex value from 0-f back * to a nybble in the low order bits of the return byte. */ -- cgit v1.1