00001
00032 #include "linden_common.h"
00033 #include "lluistring.h"
00034
00035 const LLString::format_map_t LLUIString::sNullArgs;
00036
00037
00038 LLUIString::LLUIString(const LLString& instring, const LLString::format_map_t& args)
00039 : mOrig(instring),
00040 mArgs(args)
00041 {
00042 format();
00043 }
00044
00045 void LLUIString::assign(const LLString& s)
00046 {
00047 mOrig = s;
00048 format();
00049 }
00050
00051 void LLUIString::setArgList(const LLString::format_map_t& args)
00052 {
00053 mArgs = args;
00054 format();
00055 }
00056
00057 void LLUIString::setArg(const LLString& key, const LLString& replacement)
00058 {
00059 mArgs[key] = replacement;
00060 format();
00061 }
00062
00063 void LLUIString::truncate(S32 maxchars)
00064 {
00065 if (mWResult.size() > (size_t)maxchars)
00066 {
00067 LLWString::truncate(mWResult, maxchars);
00068 mResult = wstring_to_utf8str(mWResult);
00069 }
00070 }
00071
00072 void LLUIString::erase(S32 charidx, S32 len)
00073 {
00074 mWResult.erase(charidx, len);
00075 mResult = wstring_to_utf8str(mWResult);
00076 }
00077
00078 void LLUIString::insert(S32 charidx, const LLWString& wchars)
00079 {
00080 mWResult.insert(charidx, wchars);
00081 mResult = wstring_to_utf8str(mWResult);
00082 }
00083
00084 void LLUIString::replace(S32 charidx, llwchar wc)
00085 {
00086 mWResult[charidx] = wc;
00087 mResult = wstring_to_utf8str(mWResult);
00088 }
00089
00090 void LLUIString::clear()
00091 {
00092
00093 mOrig.clear();
00094 mResult.clear();
00095 mWResult.clear();
00096 }
00097
00098 void LLUIString::format()
00099 {
00100 mResult = mOrig;
00101 LLString::format(mResult, mArgs);
00102 mWResult = utf8str_to_wstring(mResult);
00103 }