diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/test/llsd_new_tut.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/test/llsd_new_tut.cpp')
-rw-r--r-- | linden/indra/test/llsd_new_tut.cpp | 78 |
1 files changed, 4 insertions, 74 deletions
diff --git a/linden/indra/test/llsd_new_tut.cpp b/linden/indra/test/llsd_new_tut.cpp index d278a78..55e259d 100644 --- a/linden/indra/test/llsd_new_tut.cpp +++ b/linden/indra/test/llsd_new_tut.cpp | |||
@@ -5,6 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (c) 2006-2007, Linden Research, Inc. | 6 | * Copyright (c) 2006-2007, Linden Research, Inc. |
7 | * | 7 | * |
8 | * Second Life Viewer Source Code | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | 9 | * 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 | * 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 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -31,82 +32,11 @@ | |||
31 | #include "linden_common.h" | 32 | #include "linden_common.h" |
32 | #include "lltut.h" | 33 | #include "lltut.h" |
33 | 34 | ||
34 | #include "llsd.h" | 35 | #include "llsdtraits.h" |
35 | #include "llstring.h" | 36 | #include "llstring.h" |
36 | 37 | ||
37 | namespace tut | 38 | namespace tut |
38 | { | 39 | { |
39 | template<class T> | ||
40 | class SDTraits | ||
41 | { | ||
42 | protected: | ||
43 | typedef T (LLSD::*Getter)() const; | ||
44 | |||
45 | LLSD::Type type; | ||
46 | Getter getter; | ||
47 | |||
48 | public: | ||
49 | SDTraits(); | ||
50 | |||
51 | T get(const LLSD& actual) | ||
52 | { | ||
53 | return (actual.*getter)(); | ||
54 | } | ||
55 | |||
56 | bool checkType(const LLSD& actual) | ||
57 | { | ||
58 | return actual.type() == type; | ||
59 | } | ||
60 | }; | ||
61 | |||
62 | template<> | ||
63 | SDTraits<LLSD::Boolean>::SDTraits() | ||
64 | : type(LLSD::TypeBoolean), getter(&LLSD::asBoolean) | ||
65 | { } | ||
66 | |||
67 | template<> | ||
68 | SDTraits<LLSD::Integer>::SDTraits() | ||
69 | : type(LLSD::TypeInteger), getter(&LLSD::asInteger) | ||
70 | { } | ||
71 | |||
72 | template<> | ||
73 | SDTraits<LLSD::Real>::SDTraits() | ||
74 | : type(LLSD::TypeReal), getter(&LLSD::asReal) | ||
75 | { } | ||
76 | |||
77 | template<> | ||
78 | SDTraits<LLSD::UUID>::SDTraits() | ||
79 | : type(LLSD::TypeUUID), getter(&LLSD::asUUID) | ||
80 | { } | ||
81 | |||
82 | template<> | ||
83 | SDTraits<LLSD::String>::SDTraits() | ||
84 | : type(LLSD::TypeString), getter(&LLSD::asString) | ||
85 | { } | ||
86 | |||
87 | template<> | ||
88 | class SDTraits<LLString> : public SDTraits<LLSD::String> | ||
89 | { }; | ||
90 | |||
91 | template<> | ||
92 | class SDTraits<const char*> : public SDTraits<LLSD::String> | ||
93 | { }; | ||
94 | |||
95 | template<> | ||
96 | SDTraits<LLSD::Date>::SDTraits() | ||
97 | : type(LLSD::TypeDate), getter(&LLSD::asDate) | ||
98 | { } | ||
99 | |||
100 | template<> | ||
101 | SDTraits<LLSD::URI>::SDTraits() | ||
102 | : type(LLSD::TypeURI), getter(&LLSD::asURI) | ||
103 | { } | ||
104 | |||
105 | template<> | ||
106 | SDTraits<LLSD::Binary>::SDTraits() | ||
107 | : type(LLSD::TypeBinary), getter(&LLSD::asBinary) | ||
108 | { } | ||
109 | |||
110 | class SDCleanupCheck | 40 | class SDCleanupCheck |
111 | { | 41 | { |
112 | private: | 42 | private: |
@@ -145,7 +75,7 @@ namespace tut | |||
145 | static void ensureTypeAndValue(const char* msg, const LLSD& actual, | 75 | static void ensureTypeAndValue(const char* msg, const LLSD& actual, |
146 | T expectedValue) | 76 | T expectedValue) |
147 | { | 77 | { |
148 | SDTraits<T> traits; | 78 | LLSDTraits<T> traits; |
149 | 79 | ||
150 | std::string s(msg); | 80 | std::string s(msg); |
151 | 81 | ||
@@ -353,7 +283,7 @@ namespace tut | |||
353 | } | 283 | } |
354 | 284 | ||
355 | LLSD u(str); | 285 | LLSD u(str); |
356 | SDTraits<T> traits; | 286 | LLSDTraits<T> traits; |
357 | 287 | ||
358 | ensure_equals(msg + " value", traits.get(u), vExpected); | 288 | ensure_equals(msg + " value", traits.get(u), vExpected); |
359 | } | 289 | } |