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/llmessage/llnamevalue.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 '')
-rw-r--r-- | linden/indra/llmessage/llnamevalue.h | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llnamevalue.h b/linden/indra/llmessage/llnamevalue.h new file mode 100644 index 0000000..89fe71b --- /dev/null +++ b/linden/indra/llmessage/llnamevalue.h | |||
@@ -0,0 +1,205 @@ | |||
1 | /** | ||
2 | * @file llnamevalue.h | ||
3 | * @brief class for defining name value pairs. | ||
4 | * | ||
5 | * Copyright (c) 2001-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 | #ifndef LL_LLNAMEVALUE_H | ||
29 | #define LL_LLNAMEVALUE_H | ||
30 | |||
31 | #include <iostream> | ||
32 | #include <string.h> | ||
33 | |||
34 | #include "string_table.h" | ||
35 | #include "llskipmap.h" | ||
36 | #include "llmath.h" | ||
37 | //#include "vmath.h" | ||
38 | #include "v3math.h" | ||
39 | #include "lldbstrings.h" | ||
40 | |||
41 | class LLNameValue; | ||
42 | typedef void (*TNameValueCallback)(LLNameValue *changed, void **user_data); | ||
43 | |||
44 | void add_use_callback(char *name, TNameValueCallback ucb, void **user_data); | ||
45 | |||
46 | typedef enum e_name_value_types | ||
47 | { | ||
48 | NVT_NULL, | ||
49 | NVT_STRING, | ||
50 | NVT_F32, | ||
51 | NVT_S32, | ||
52 | NVT_VEC3, | ||
53 | NVT_U32, | ||
54 | NVT_CAMERA, // Deprecated, but leaving in case removing this will cause problems | ||
55 | NVT_ASSET, | ||
56 | NVT_U64, | ||
57 | NVT_EOF | ||
58 | } ENameValueType; | ||
59 | |||
60 | typedef enum e_name_value_class | ||
61 | { | ||
62 | NVC_NULL, | ||
63 | NVC_READ_ONLY, | ||
64 | NVC_READ_WRITE, | ||
65 | NVC_CALLBACK, | ||
66 | NVC_EOF | ||
67 | } ENameValueClass; | ||
68 | |||
69 | typedef enum e_name_value_sento | ||
70 | { | ||
71 | NVS_NULL, | ||
72 | NVS_SIM, | ||
73 | NVS_DATA_SIM, | ||
74 | NVS_SIM_VIEWER, | ||
75 | NVS_DATA_SIM_VIEWER, | ||
76 | NVS_EOF | ||
77 | } ENameValueSendto; | ||
78 | |||
79 | |||
80 | // NameValues can always be "printed" into a buffer of this length. | ||
81 | const U32 NAME_VALUE_BUF_SIZE = 1024; | ||
82 | |||
83 | |||
84 | const U32 NAME_VALUE_TYPE_STRING_LENGTH = 8; | ||
85 | const U32 NAME_VALUE_CLASS_STRING_LENGTH = 16; | ||
86 | const U32 NAME_VALUE_SENDTO_STRING_LENGTH = 18; | ||
87 | const U32 NAME_VALUE_DATA_SIZE = | ||
88 | NAME_VALUE_BUF_SIZE - | ||
89 | ( DB_NV_NAME_BUF_SIZE + | ||
90 | NAME_VALUE_TYPE_STRING_LENGTH + | ||
91 | NAME_VALUE_CLASS_STRING_LENGTH + | ||
92 | NAME_VALUE_SENDTO_STRING_LENGTH ); | ||
93 | |||
94 | |||
95 | extern char NameValueTypeStrings[NVT_EOF][NAME_VALUE_TYPE_STRING_LENGTH]; /* Flawfinder: Ignore */ | ||
96 | extern char NameValueClassStrings[NVC_EOF][NAME_VALUE_CLASS_STRING_LENGTH]; /* Flawfinder: Ignore */ | ||
97 | extern char NameValueSendtoStrings[NVS_EOF][NAME_VALUE_SENDTO_STRING_LENGTH]; /* Flawfinder: Ignore */ | ||
98 | |||
99 | typedef union u_name_value_reference | ||
100 | { | ||
101 | char *string; | ||
102 | F32 *f32; | ||
103 | S32 *s32; | ||
104 | LLVector3 *vec3; | ||
105 | U32 *u32; | ||
106 | U64 *u64; | ||
107 | } UNameValueReference; | ||
108 | |||
109 | |||
110 | class LLNameValue | ||
111 | { | ||
112 | public: | ||
113 | void baseInit(); | ||
114 | void init(const char *name, const char *data, const char *type, const char *nvclass, const char *nvsendto, | ||
115 | TNameValueCallback nvcb = NULL, void **user_data = NULL); | ||
116 | |||
117 | LLNameValue(); | ||
118 | LLNameValue(const char *data); | ||
119 | LLNameValue(const char *name, const char *type, const char *nvclass, | ||
120 | TNameValueCallback nvcb = NULL, void **user_data = NULL); | ||
121 | LLNameValue(const char *name, const char *data, const char *type, const char *nvclass, | ||
122 | TNameValueCallback nvcb = NULL, void **user_data = NULL); | ||
123 | LLNameValue(const char *name, const char *data, const char *type, const char *nvclass, const char *nvsendto, | ||
124 | TNameValueCallback nvcb = NULL, void **user_data = NULL); | ||
125 | |||
126 | ~LLNameValue(); | ||
127 | |||
128 | char *getString(); | ||
129 | const char *getAsset() const; | ||
130 | F32 *getF32(); | ||
131 | S32 *getS32(); | ||
132 | void getVec3(LLVector3 &vec); | ||
133 | LLVector3 *getVec3(); | ||
134 | F32 magnitude(); | ||
135 | U32 *getU32(); | ||
136 | U64 *getU64(); | ||
137 | |||
138 | const char *getType() const { return mStringType; } | ||
139 | const char *getClass() const { return mStringClass; } | ||
140 | const char *getSendto() const { return mStringSendto; } | ||
141 | |||
142 | BOOL sendToData() const; | ||
143 | BOOL sendToViewer() const; | ||
144 | |||
145 | void callCallback(); | ||
146 | std::string printNameValue(); | ||
147 | std::string printData(); | ||
148 | |||
149 | ENameValueType getTypeEnum() const { return mType; } | ||
150 | ENameValueClass getClassEnum() const { return mClass; } | ||
151 | ENameValueSendto getSendtoEnum() const { return mSendto; } | ||
152 | |||
153 | LLNameValue &operator=(const LLNameValue &a); | ||
154 | void setString(const char *a); | ||
155 | void setAsset(const char *a); | ||
156 | void setF32(const F32 a); | ||
157 | void setS32(const S32 a); | ||
158 | void setVec3(const LLVector3 &a); | ||
159 | void setU32(const U32 a); | ||
160 | |||
161 | BOOL nonzero(); | ||
162 | |||
163 | friend std::ostream& operator<<(std::ostream& s, const LLNameValue &a); | ||
164 | |||
165 | friend LLNameValue &operator+(const LLNameValue &a, const LLNameValue &b); | ||
166 | friend LLNameValue &operator-(const LLNameValue &a, const LLNameValue &b); | ||
167 | friend LLNameValue &operator*(const LLNameValue &a, const LLNameValue &b); | ||
168 | friend LLNameValue &operator/(const LLNameValue &a, const LLNameValue &b); | ||
169 | friend LLNameValue &operator%(const LLNameValue &a, const LLNameValue &b); | ||
170 | friend LLNameValue &operator*(const LLNameValue &a, F32 k); | ||
171 | friend LLNameValue &operator*(F32 k, const LLNameValue &a); | ||
172 | |||
173 | friend bool operator==(const LLNameValue &a, const LLNameValue &b); | ||
174 | friend bool operator<=(const LLNameValue &a, const LLNameValue &b); | ||
175 | friend bool operator>=(const LLNameValue &a, const LLNameValue &b); | ||
176 | friend bool operator<(const LLNameValue &a, const LLNameValue &b); | ||
177 | friend bool operator>(const LLNameValue &a, const LLNameValue &b); | ||
178 | friend bool operator!=(const LLNameValue &a, const LLNameValue &b); | ||
179 | |||
180 | friend LLNameValue &operator-(const LLNameValue &a); | ||
181 | |||
182 | private: | ||
183 | void printNameValue(std::ostream& s); | ||
184 | |||
185 | public: | ||
186 | char *mName; | ||
187 | |||
188 | char *mStringType; | ||
189 | ENameValueType mType; | ||
190 | char *mStringClass; | ||
191 | ENameValueClass mClass; | ||
192 | char *mStringSendto; | ||
193 | ENameValueSendto mSendto; | ||
194 | |||
195 | UNameValueReference mNameValueReference; | ||
196 | S32 mNumberEntries; | ||
197 | LLStringTable *mNVNameTable; | ||
198 | TNameValueCallback mNameValueCB; | ||
199 | void **mUserData; | ||
200 | }; | ||
201 | |||
202 | extern LLStringTable gNVNameTable; | ||
203 | |||
204 | |||
205 | #endif | ||