diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llui/lluistring.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rwxr-xr-x | linden/indra/llui/lluistring.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/linden/indra/llui/lluistring.h b/linden/indra/llui/lluistring.h new file mode 100755 index 0000000..efd200a --- /dev/null +++ b/linden/indra/llui/lluistring.h | |||
@@ -0,0 +1,106 @@ | |||
1 | /** | ||
2 | * @file lluistring.h | ||
3 | * @author: Steve Bennetts | ||
4 | * @brief LLUIString base class | ||
5 | * | ||
6 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #ifndef LL_LLUISTRING_H | ||
30 | #define LL_LLUISTRING_H | ||
31 | |||
32 | // lluistring.h | ||
33 | // | ||
34 | // Copyright 2006, Linden Research, Inc. | ||
35 | // Original aurthor: Steve | ||
36 | |||
37 | #include "stdtypes.h" | ||
38 | #include "llstring.h" | ||
39 | #include <string> | ||
40 | |||
41 | // Use this class to store translated text that may have arguments | ||
42 | // e.g. "Welcome [USERNAME] to [SECONDLIFE]!" | ||
43 | |||
44 | // Adding or changing an argument will update the result string, preserving the origianl | ||
45 | // Thus, subsequent changes to arguments or even the original string will produce | ||
46 | // the correct result | ||
47 | |||
48 | // Example Usage: | ||
49 | // LLUIString mMessage("Welcome [USERNAME] to [SECONDLIFE]!"); | ||
50 | // mMessage.setArg("[USERNAME]", "Steve"); | ||
51 | // mMessage.setArg("[SECONDLIFE]", "Second Life"); | ||
52 | // llinfos << mMessage.getString().c_str() << llendl; // outputs "Welcome Steve to Second Life" | ||
53 | // mMessage.setArg("[USERNAME]", "Joe"); | ||
54 | // llinfos << mMessage.getString().c_str() << llendl; // outputs "Welcome Joe to Second Life" | ||
55 | // mMessage = "Recepción a la [SECONDLIFE] [USERNAME]" | ||
56 | // mMessage.setArg("[SECONDLIFE]", "Segunda Vida"); | ||
57 | // llinfos << mMessage.getString().c_str() << llendl; // outputs "Recepción a la Segunda Vida Joe" | ||
58 | |||
59 | // Implementation Notes: | ||
60 | // Attempting to have operator[](const LLString& s) return mArgs[s] fails because we have | ||
61 | // to call format() after the assignment happens. | ||
62 | |||
63 | class LLUIString | ||
64 | { | ||
65 | public: | ||
66 | // These methods all perform appropriate argument substitution | ||
67 | // and modify mOrig where appropriate | ||
68 | LLUIString() {} | ||
69 | LLUIString(const LLString& instring, const LLString::format_map_t& args); | ||
70 | LLUIString(const LLString& instring) { assign(instring); } | ||
71 | |||
72 | void assign(const LLString& instring); | ||
73 | LLUIString& operator=(const LLString& s) { assign(s); return *this; } | ||
74 | |||
75 | void setArgList(const LLString::format_map_t& args); | ||
76 | void setArg(const LLString& key, const LLString& replacement); | ||
77 | |||
78 | const LLString& getString() const { return mResult; } | ||
79 | operator LLString() const { return mResult; } | ||
80 | |||
81 | const LLWString& getWString() const { return mWResult; } | ||
82 | operator LLWString() const { return mWResult; } | ||
83 | |||
84 | bool empty() const { return mWResult.empty(); } | ||
85 | S32 length() const { return mWResult.size(); } | ||
86 | |||
87 | void clear(); | ||
88 | void clearArgs(); | ||
89 | |||
90 | // These utuilty functions are included for text editing. | ||
91 | // They do not affect mOrig and do not perform argument substitution | ||
92 | void truncate(S32 maxchars); | ||
93 | void erase(S32 charidx, S32 len); | ||
94 | void insert(S32 charidx, const LLWString& wchars); | ||
95 | void replace(S32 charidx, llwchar wc); | ||
96 | |||
97 | private: | ||
98 | void format(); | ||
99 | |||
100 | LLString mOrig; | ||
101 | LLString mResult; | ||
102 | LLWString mWResult; // for displaying | ||
103 | LLString::format_map_t mArgs; | ||
104 | }; | ||
105 | |||
106 | #endif // LL_LLUISTRING_H | ||