aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/OVR_JSON.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LibOVR/Src/OVR_JSON.cpp')
-rw-r--r--LibOVR/Src/OVR_JSON.cpp63
1 files changed, 58 insertions, 5 deletions
diff --git a/LibOVR/Src/OVR_JSON.cpp b/LibOVR/Src/OVR_JSON.cpp
index 0625f6d..209a41f 100644
--- a/LibOVR/Src/OVR_JSON.cpp
+++ b/LibOVR/Src/OVR_JSON.cpp
@@ -30,16 +30,16 @@ Notes :
THE SOFTWARE.
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
-Licensed under the Oculus VR SDK License Version 2.0 (the "License");
-you may not use the Oculus VR SDK except in compliance with the License,
+Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-2.0
+http://www.oculusvr.com/licenses/LICENSE-3.1
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -949,6 +949,17 @@ void JSON::ReplaceItem(unsigned int index, JSON* new_item)
}
*/
+// Removes and frees the last child item
+void JSON::RemoveLast()
+{
+ JSON* child = Children.GetLast();
+ if (!Children.IsNull(child))
+ {
+ child->RemoveNode();
+ child->Release();
+ }
+}
+
// Helper function to simplify creation of a typed object
JSON* JSON::createHelper(JSONItemType itemType, double dval, const char* strVal)
{
@@ -973,6 +984,31 @@ void JSON::AddArrayElement(JSON *item)
Children.PushBack(item);
}
+// Inserts an element into a valid array position
+void JSON::InsertArrayElement(int index, JSON *item)
+{
+ if (!item)
+ return;
+
+ if (index == 0)
+ {
+ Children.PushFront(item);
+ return;
+ }
+
+ JSON* iter = Children.GetFirst();
+ int i=0;
+ while (iter && i<index)
+ {
+ iter = Children.GetNext(iter);
+ i++;
+ }
+
+ if (iter)
+ iter->InsertNodeBefore(item);
+ else
+ Children.PushBack(item);
+}
// Returns the size of an array
int JSON::GetArraySize()
@@ -1011,6 +1047,23 @@ const char* JSON::GetArrayString(int index)
}
}
+JSON* JSON::Copy()
+{
+ JSON* copy = new JSON(Type);
+ copy->Name = Name;
+ copy->Value = Value;
+ copy->dValue = dValue;
+
+ JSON* child = Children.GetFirst();
+ while (!Children.IsNull(child))
+ {
+ copy->Children.PushBack(child->Copy());
+ child = Children.GetNext(child);
+ }
+
+ return copy;
+}
+
//-----------------------------------------------------------------------------
// Loads and parses the given JSON file pathname and returns a JSON object tree.
// The returned object must be Released after use.
@@ -1051,7 +1104,7 @@ bool JSON::Save(const char* path)
if (text)
{
SPInt len = OVR_strlen(text);
- OVR_ASSERT(len < (SPInt)(int)len);
+ OVR_ASSERT(len <= (SPInt)(int)len);
int bytes = f.Write((UByte*)text, (int)len);
f.Close();