diff options
Diffstat (limited to 'linden/indra/llcommon/llsdutil.cpp')
-rw-r--r-- | linden/indra/llcommon/llsdutil.cpp | 132 |
1 files changed, 7 insertions, 125 deletions
diff --git a/linden/indra/llcommon/llsdutil.cpp b/linden/indra/llcommon/llsdutil.cpp index d1ccce0..b619fb6 100644 --- a/linden/indra/llcommon/llsdutil.cpp +++ b/linden/indra/llcommon/llsdutil.cpp | |||
@@ -46,124 +46,6 @@ | |||
46 | 46 | ||
47 | #include "llsdserialize.h" | 47 | #include "llsdserialize.h" |
48 | 48 | ||
49 | // vector3 | ||
50 | LLSD ll_sd_from_vector3(const LLVector3& vec) | ||
51 | { | ||
52 | LLSD rv; | ||
53 | rv.append((F64)vec.mV[VX]); | ||
54 | rv.append((F64)vec.mV[VY]); | ||
55 | rv.append((F64)vec.mV[VZ]); | ||
56 | return rv; | ||
57 | } | ||
58 | |||
59 | LLVector3 ll_vector3_from_sd(const LLSD& sd, S32 start_index) | ||
60 | { | ||
61 | LLVector3 rv; | ||
62 | rv.mV[VX] = (F32)sd[start_index].asReal(); | ||
63 | rv.mV[VY] = (F32)sd[++start_index].asReal(); | ||
64 | rv.mV[VZ] = (F32)sd[++start_index].asReal(); | ||
65 | return rv; | ||
66 | } | ||
67 | |||
68 | // vector4 | ||
69 | LLSD ll_sd_from_vector4(const LLVector4& vec) | ||
70 | { | ||
71 | LLSD rv; | ||
72 | rv.append((F64)vec.mV[VX]); | ||
73 | rv.append((F64)vec.mV[VY]); | ||
74 | rv.append((F64)vec.mV[VZ]); | ||
75 | rv.append((F64)vec.mV[VW]); | ||
76 | return rv; | ||
77 | } | ||
78 | |||
79 | LLVector4 ll_vector4_from_sd(const LLSD& sd, S32 start_index) | ||
80 | { | ||
81 | LLVector4 rv; | ||
82 | rv.mV[VX] = (F32)sd[start_index].asReal(); | ||
83 | rv.mV[VY] = (F32)sd[++start_index].asReal(); | ||
84 | rv.mV[VZ] = (F32)sd[++start_index].asReal(); | ||
85 | rv.mV[VW] = (F32)sd[++start_index].asReal(); | ||
86 | return rv; | ||
87 | } | ||
88 | |||
89 | // vector3d | ||
90 | LLSD ll_sd_from_vector3d(const LLVector3d& vec) | ||
91 | { | ||
92 | LLSD rv; | ||
93 | rv.append(vec.mdV[VX]); | ||
94 | rv.append(vec.mdV[VY]); | ||
95 | rv.append(vec.mdV[VZ]); | ||
96 | return rv; | ||
97 | } | ||
98 | |||
99 | LLVector3d ll_vector3d_from_sd(const LLSD& sd, S32 start_index) | ||
100 | { | ||
101 | LLVector3d rv; | ||
102 | rv.mdV[VX] = sd[start_index].asReal(); | ||
103 | rv.mdV[VY] = sd[++start_index].asReal(); | ||
104 | rv.mdV[VZ] = sd[++start_index].asReal(); | ||
105 | return rv; | ||
106 | } | ||
107 | |||
108 | //vector2 | ||
109 | LLSD ll_sd_from_vector2(const LLVector2& vec) | ||
110 | { | ||
111 | LLSD rv; | ||
112 | rv.append((F64)vec.mV[VX]); | ||
113 | rv.append((F64)vec.mV[VY]); | ||
114 | return rv; | ||
115 | } | ||
116 | |||
117 | LLVector2 ll_vector2_from_sd(const LLSD& sd) | ||
118 | { | ||
119 | LLVector2 rv; | ||
120 | rv.mV[VX] = (F32)sd[0].asReal(); | ||
121 | rv.mV[VY] = (F32)sd[1].asReal(); | ||
122 | return rv; | ||
123 | } | ||
124 | |||
125 | // Quaternion | ||
126 | LLSD ll_sd_from_quaternion(const LLQuaternion& quat) | ||
127 | { | ||
128 | LLSD rv; | ||
129 | rv.append((F64)quat.mQ[VX]); | ||
130 | rv.append((F64)quat.mQ[VY]); | ||
131 | rv.append((F64)quat.mQ[VZ]); | ||
132 | rv.append((F64)quat.mQ[VW]); | ||
133 | return rv; | ||
134 | } | ||
135 | |||
136 | LLQuaternion ll_quaternion_from_sd(const LLSD& sd) | ||
137 | { | ||
138 | LLQuaternion quat; | ||
139 | quat.mQ[VX] = (F32)sd[0].asReal(); | ||
140 | quat.mQ[VY] = (F32)sd[1].asReal(); | ||
141 | quat.mQ[VZ] = (F32)sd[2].asReal(); | ||
142 | quat.mQ[VW] = (F32)sd[3].asReal(); | ||
143 | return quat; | ||
144 | } | ||
145 | |||
146 | // color4 | ||
147 | LLSD ll_sd_from_color4(const LLColor4& c) | ||
148 | { | ||
149 | LLSD rv; | ||
150 | rv.append(c.mV[0]); | ||
151 | rv.append(c.mV[1]); | ||
152 | rv.append(c.mV[2]); | ||
153 | rv.append(c.mV[3]); | ||
154 | return rv; | ||
155 | } | ||
156 | |||
157 | LLColor4 ll_color4_from_sd(const LLSD& sd) | ||
158 | { | ||
159 | LLColor4 c; | ||
160 | c.mV[0] = (F32)sd[0].asReal(); | ||
161 | c.mV[1] = (F32)sd[1].asReal(); | ||
162 | c.mV[2] = (F32)sd[2].asReal(); | ||
163 | c.mV[3] = (F32)sd[3].asReal(); | ||
164 | return c; | ||
165 | } | ||
166 | |||
167 | // U32 | 49 | // U32 |
168 | LLSD ll_sd_from_U32(const U32 val) | 50 | LLSD ll_sd_from_U32(const U32 val) |
169 | { | 51 | { |
@@ -263,12 +145,11 @@ LLSD ll_binary_from_string(const LLSD& sd) | |||
263 | { | 145 | { |
264 | std::vector<U8> binary_value; | 146 | std::vector<U8> binary_value; |
265 | 147 | ||
266 | LLString string_value = sd.asString(); | 148 | std::string string_value = sd.asString(); |
267 | const char* string_p = string_value.c_str(); | 149 | for (std::string::iterator iter = string_value.begin(); |
268 | while (*string_p) | 150 | iter != string_value.end(); ++iter) |
269 | { | 151 | { |
270 | binary_value.push_back(*string_p); | 152 | binary_value.push_back(*iter); |
271 | string_p++; | ||
272 | } | 153 | } |
273 | 154 | ||
274 | binary_value.push_back('\0'); | 155 | binary_value.push_back('\0'); |
@@ -303,8 +184,9 @@ char* ll_pretty_print_sd(const LLSD& sd) | |||
303 | } | 184 | } |
304 | 185 | ||
305 | //compares the structure of an LLSD to a template LLSD and stores the | 186 | //compares the structure of an LLSD to a template LLSD and stores the |
306 | //"valid" values in a 3rd LLSD. Default values are stored in the template | 187 | //"valid" values in a 3rd LLSD. Default values pulled from the template |
307 | // | 188 | //if the tested LLSD does not contain the key/value pair. |
189 | //Excess values in the test LLSD are ignored in the resultant_llsd. | ||
308 | //If the llsd to test has a specific key to a map and the values | 190 | //If the llsd to test has a specific key to a map and the values |
309 | //are not of the same type, false is returned or if the LLSDs are not | 191 | //are not of the same type, false is returned or if the LLSDs are not |
310 | //of the same value. Ordering of arrays matters | 192 | //of the same value. Ordering of arrays matters |