ffead.server.doc
JSONElement.h
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * JSONElement.h
18  *
19  * Created on: 06-Aug-2012
20  * Author: sumeetc
21  */
22 
23 #ifndef JSONELEMENT_H_
24 #define JSONELEMENT_H_
25 #include "map"
26 #include "vector"
27 #include "string"
28 using namespace std;
29 
30 class JSONElement {
31 public:
32  static enum {JSON_OBJECT, JSON_ARRAY, JSON_STRING, JSON_NUMBER, JSON_BOOL, JSON_FLOAT} JSON_TYPE;
33  JSONElement();
34  virtual ~JSONElement();
35  bool hasChildren();
36  void addChild(JSONElement* child);
37  vector<JSONElement*> getChildren();
38  JSONElement* getNode(const string& name);
39  int getType() const;
40  void setType(int type);
41  string getValue() const;
42  void setValue(string value);
43  string getName() const;
44  void setName(string name);
45  string toString();
46 private:
47  string name;
48  string value;
49  int type;
50  vector<JSONElement*> children;
51  map<string, JSONElement*> allnodes;
52 };
53 
54 #endif /* JSONELEMENT_H_ */