|
@@ -23,52 +23,52 @@ void PrintVariant(const DKString& name, const DKVariant& var, int indent = 0)
|
23
|
23
|
switch (var.ValueType())
|
24
|
24
|
{
|
25
|
25
|
case DKVariant::TypeUndefined:
|
26
|
|
- DKLog("%s %ls (Undefined)", ind, (const wchar_t*)name);
|
|
26
|
+ DKLog("%s \"%ls\" (Undefined)", ind, (const wchar_t*)name);
|
27
|
27
|
break;
|
28
|
28
|
case DKVariant::TypeInteger:
|
29
|
|
- DKLog("%s %ls (Integer) : %lld", ind, (const wchar_t*)name, var.Integer());
|
|
29
|
+ DKLog("%s \"%ls\" (Integer) : %lld", ind, (const wchar_t*)name, var.Integer());
|
30
|
30
|
break;
|
31
|
31
|
case DKVariant::TypeFloat:
|
32
|
|
- DKLog("%s %ls (Float) : %f", ind, (const wchar_t*)name, var.Float());
|
|
32
|
+ DKLog("%s \"%ls\" (Float) : %f", ind, (const wchar_t*)name, var.Float());
|
33
|
33
|
break;
|
34
|
34
|
case DKVariant::TypeVector2:
|
35
|
|
- DKLog("%s %ls (Vector2)", ind, (const wchar_t*)name);
|
|
35
|
+ DKLog("%s \"%ls\" (Vector2)", ind, (const wchar_t*)name);
|
36
|
36
|
break;
|
37
|
37
|
case DKVariant::TypeVector3:
|
38
|
|
- DKLog("%s %ls (Vector3)", ind, (const wchar_t*)name);
|
|
38
|
+ DKLog("%s \"%ls\" (Vector3)", ind, (const wchar_t*)name);
|
39
|
39
|
break;
|
40
|
40
|
case DKVariant::TypeVector4:
|
41
|
|
- DKLog("%s %ls (Vector4)", ind, (const wchar_t*)name);
|
|
41
|
+ DKLog("%s \"%ls\" (Vector4)", ind, (const wchar_t*)name);
|
42
|
42
|
break;
|
43
|
43
|
case DKVariant::TypeMatrix2:
|
44
|
|
- DKLog("%s %ls (Matrix2x2)", ind, (const wchar_t*)name);
|
|
44
|
+ DKLog("%s \"%ls\" (Matrix2x2)", ind, (const wchar_t*)name);
|
45
|
45
|
break;
|
46
|
46
|
case DKVariant::TypeMatrix3:
|
47
|
|
- DKLog("%s %ls (Matrix3x3)", ind, (const wchar_t*)name);
|
|
47
|
+ DKLog("%s \"%ls\" (Matrix3x3)", ind, (const wchar_t*)name);
|
48
|
48
|
break;
|
49
|
49
|
case DKVariant::TypeMatrix4:
|
50
|
|
- DKLog("%s %ls (Matrix4x4)", ind, (const wchar_t*)name);
|
|
50
|
+ DKLog("%s \"%ls\" (Matrix4x4)", ind, (const wchar_t*)name);
|
51
|
51
|
break;
|
52
|
52
|
case DKVariant::TypeQuaternion:
|
53
|
|
- DKLog("%s %ls (Quat)", ind, (const wchar_t*)name);
|
|
53
|
+ DKLog("%s \"%ls\" (Quat)", ind, (const wchar_t*)name);
|
54
|
54
|
break;
|
55
|
55
|
case DKVariant::TypeRational:
|
56
|
|
- DKLog("%s %ls (Rational) %lld / %lld", ind, (const wchar_t*)name, var.Rational().Numerator(), var.Rational().Denominator());
|
|
56
|
+ DKLog("%s \"%ls\" (Rational) %lld / %lld", ind, (const wchar_t*)name, var.Rational().Numerator(), var.Rational().Denominator());
|
57
|
57
|
break;
|
58
|
58
|
case DKVariant::TypeString:
|
59
|
|
- DKLog("%s %ls (String) : %ls", ind, (const wchar_t*)name, (const wchar_t*)var.String());
|
|
59
|
+ DKLog("%s \"%ls\" (String) : %ls", ind, (const wchar_t*)name, (const wchar_t*)var.String());
|
60
|
60
|
break;
|
61
|
61
|
case DKVariant::TypeDateTime:
|
62
|
|
- DKLog("%s %ls (DateTime)", ind, (const wchar_t*)name);
|
|
62
|
+ DKLog("%s \"%ls\" (DateTime)", ind, (const wchar_t*)name);
|
63
|
63
|
break;
|
64
|
64
|
case DKVariant::TypeData:
|
65
|
|
- DKLog("%s %ls (Data)", ind, (const wchar_t*)name);
|
|
65
|
+ DKLog("%s \"%ls\" (Data)", ind, (const wchar_t*)name);
|
66
|
66
|
break;
|
67
|
67
|
case DKVariant::TypeStructData:
|
68
|
|
- DKLog("%s %ls (StructData)", ind, (const wchar_t*)name);
|
|
68
|
+ DKLog("%s \"%ls\" (StructData)", ind, (const wchar_t*)name);
|
69
|
69
|
break;
|
70
|
70
|
case DKVariant::TypeArray:
|
71
|
|
- DKLog("%s %ls (Array)", ind, (const wchar_t*)name);
|
|
71
|
+ DKLog("%s \"%ls\" (Array)", ind, (const wchar_t*)name);
|
72
|
72
|
for (int i = 0; i < var.Array().Count(); ++i)
|
73
|
73
|
{
|
74
|
74
|
const DKVariant& sub = var.Array().Value(i);
|
|
@@ -76,7 +76,7 @@ void PrintVariant(const DKString& name, const DKVariant& var, int indent = 0)
|
76
|
76
|
}
|
77
|
77
|
break;
|
78
|
78
|
case DKVariant::TypePairs:
|
79
|
|
- DKLog("%s %ls (Pairs)", ind, (const wchar_t*)name);
|
|
79
|
+ DKLog("%s \"%ls\" (Pairs)", ind, (const wchar_t*)name);
|
80
|
80
|
var.Pairs().EnumerateForward([indent](const DKVariant::VPairs::Pair& pair)
|
81
|
81
|
{
|
82
|
82
|
PrintVariant(pair.key, pair.value, indent+4);
|
|
@@ -103,12 +103,37 @@ int main(int argc, const char * argv[])
|
103
|
103
|
|
104
|
104
|
DKVariant::VPairs& root = prop.Pairs();
|
105
|
105
|
DKVariant::VPairs& sub1 = root.Value("Sub1").Pairs();
|
106
|
|
-
|
|
106
|
+ DKVariant::VPairs& sub1ss1 = sub1.Value("SS1").Pairs();
|
|
107
|
+ DKVariant::VPairs& sub1ss2 = sub1.Value("SS2").Pairs();
|
|
108
|
+ DKVariant::VPairs& sub1ss3 = sub1.Value("SS3").Pairs();
|
107
|
109
|
|
108
|
110
|
DKVariant::VPairs& sub2 = root.Value("Sub2").Pairs();
|
|
111
|
+ DKVariant::VPairs& sub2ss1 = sub2.Value("SS1").Pairs();
|
|
112
|
+ DKVariant::VPairs& sub2ss2 = sub2.Value("SS2").Pairs();
|
|
113
|
+ DKVariant::VPairs& sub2ss2hid = sub2ss2.Value("").Pairs();
|
|
114
|
+ sub2ss2hid.Value("VV2").String() = "hidden";
|
|
115
|
+
|
|
116
|
+ sub2.Value("SS2.VV2").String() = "Better";
|
|
117
|
+
|
|
118
|
+ sub2ss2.Value("VV1").Integer() = 0;
|
|
119
|
+ sub2ss2.Value("VV2").String() = "Good";
|
|
120
|
+
|
|
121
|
+ DKVariant::VPairs& sub2ss3 = sub2.Value("SS3").Pairs();
|
|
122
|
+
|
109
|
123
|
DKVariant::VInteger& sub3 = root.Value("Sub3").Integer();
|
|
124
|
+ root.Value("Sub2.SS2.VV2.KK").String() = "Bad1";
|
|
125
|
+ root.Value("Sub2.SS2.VV2.").String() = "Bad2";
|
|
126
|
+ root.Value("Sub2.SS2.VV2").String() = "Best";
|
110
|
127
|
|
111
|
128
|
PrintVariant("ROOT", prop);
|
|
129
|
+ DKLog("-------------------");
|
|
130
|
+ DKString findKey = "Sub2.SS2.VV2";
|
|
131
|
+ bool b = prop.FindObjectAtKeyPath(findKey, DKFunction([&](DKVariant& var)
|
|
132
|
+ {
|
|
133
|
+ PrintVariant(DKString::Format("(%ls)", (const wchar_t*)findKey), var);
|
|
134
|
+ return false;
|
|
135
|
+ }));
|
|
136
|
+ DKLog("FindObjectAtKeyPath result: %d", (int)b);
|
112
|
137
|
|
113
|
138
|
|
114
|
139
|
return 0;
|