aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/utils
diff options
context:
space:
mode:
authorGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-31 01:58:40 +0000
committerGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-31 01:58:40 +0000
commit41f1c46ddc7d3ff622039bea8f67ea1efc8d5566 (patch)
treed28b824af76718729003681f38b8d223f75c7428 /include/utils
parent10afbefa5b60b0f7e8d2b02f4c996de88aa26830 (diff)
add experimental class for json
git-svn-id: http://skia.googlecode.com/svn/trunk@2939 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/SkJSONObject.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/utils/SkJSONObject.h b/include/utils/SkJSONObject.h
new file mode 100644
index 0000000000..d83183472d
--- /dev/null
+++ b/include/utils/SkJSONObject.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkJSONObject_DEFINED
+#define SkJSONObject_DEFINED
+
+#include "SkTypes.h"
+
+class SkString;
+
+class SkJSONObject {
+public:
+ SkJSONObject() : fHead(NULL), fTail(NULL) {}
+ ~SkJSONObject();
+
+ enum Type {
+ kInvalid,
+
+ kObject,
+ kString,
+ kInt,
+ kFloat,
+ kBool,
+ };
+
+ void addString(const char name[], const char value[]);
+ void addInt(const char name[], int32_t value);
+ void addFloat(const char name[], float value);
+ void addBool(const char name[], bool value);
+ /**
+ * Add the value object to this object, taking over
+ * ownership of the value object.
+ */
+ void addObject(const char name[], SkJSONObject* value);
+
+ Type find(const char name[], intptr_t* = NULL) const;
+ bool findString(const char name[], SkString* = NULL) const;
+ bool findInt(const char name[], int32_t* = NULL) const;
+ bool findFloat(const char name[], float* = NULL) const;
+ bool findBool(const char name[], bool* = NULL) const;
+ bool findObject(const char name[], SkJSONObject** = NULL) const;
+
+ void dump() const;
+
+private:
+ struct Slot;
+ Slot* fHead;
+ Slot* fTail;
+
+ const Slot* findSlot(const char name[]) const;
+ const Slot* findSlotAndType(const char name[], Type) const;
+ Slot* addSlot(Slot*);
+ void dumpLevel(int level) const;
+};
+
+#endif