diff options
Diffstat (limited to 'linden/indra/llui/lluistring.cpp')
-rwxr-xr-x | linden/indra/llui/lluistring.cpp | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/linden/indra/llui/lluistring.cpp b/linden/indra/llui/lluistring.cpp new file mode 100755 index 0000000..5029082 --- /dev/null +++ b/linden/indra/llui/lluistring.cpp | |||
@@ -0,0 +1,106 @@ | |||
1 | /** | ||
2 | * @file lluistring.cpp | ||
3 | * @brief LLUIString base class | ||
4 | * | ||
5 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "linden_common.h" | ||
29 | |||
30 | #include "lluistring.h" | ||
31 | |||
32 | // public | ||
33 | |||
34 | LLUIString::LLUIString(const LLString& instring, const LLString::format_map_t& args) | ||
35 | : mOrig(instring), | ||
36 | mArgs(args) | ||
37 | { | ||
38 | format(); | ||
39 | } | ||
40 | |||
41 | void LLUIString::assign(const LLString& s) | ||
42 | { | ||
43 | mOrig = s; | ||
44 | format(); | ||
45 | } | ||
46 | |||
47 | void LLUIString::setArgList(const LLString::format_map_t& args) | ||
48 | { | ||
49 | mArgs = args; | ||
50 | format(); | ||
51 | } | ||
52 | |||
53 | void LLUIString::setArg(const LLString& key, const LLString& replacement) | ||
54 | { | ||
55 | mArgs[key] = replacement; | ||
56 | format(); | ||
57 | } | ||
58 | |||
59 | void LLUIString::truncate(S32 maxchars) | ||
60 | { | ||
61 | if (mWResult.size() > (size_t)maxchars) | ||
62 | { | ||
63 | LLWString::truncate(mWResult, maxchars); | ||
64 | mResult = wstring_to_utf8str(mWResult); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | void LLUIString::erase(S32 charidx, S32 len) | ||
69 | { | ||
70 | mWResult.erase(charidx, len); | ||
71 | mResult = wstring_to_utf8str(mWResult); | ||
72 | } | ||
73 | |||
74 | void LLUIString::insert(S32 charidx, const LLWString& wchars) | ||
75 | { | ||
76 | mWResult.insert(charidx, wchars); | ||
77 | mResult = wstring_to_utf8str(mWResult); | ||
78 | } | ||
79 | |||
80 | void LLUIString::replace(S32 charidx, llwchar wc) | ||
81 | { | ||
82 | mWResult[charidx] = wc; | ||
83 | mResult = wstring_to_utf8str(mWResult); | ||
84 | } | ||
85 | |||
86 | void LLUIString::clear() | ||
87 | { | ||
88 | // Keep Args | ||
89 | mOrig.clear(); | ||
90 | mResult.clear(); | ||
91 | mWResult.clear(); | ||
92 | } | ||
93 | |||
94 | void LLUIString::clearArgs() | ||
95 | { | ||
96 | mArgs.clear(); | ||
97 | } | ||
98 | |||
99 | // private | ||
100 | |||
101 | void LLUIString::format() | ||
102 | { | ||
103 | mResult = mOrig; | ||
104 | LLString::format(mResult, mArgs); | ||
105 | mWResult = utf8str_to_wstring(mResult); | ||
106 | } | ||