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