Follow the include-order coding conventions
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / builder / json-parser-impl.h
1 #ifndef __DALI_JSON_PARSER_IMPL_H__
2 #define __DALI_JSON_PARSER_IMPL_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23 #include <vector>
24 #include <list>
25
26 #include <dali/public-api/object/base-object.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/public-api/builder/json-parser.h>
30 #include <dali-toolkit/public-api/builder/tree-node.h>
31
32 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
33
34 namespace Dali
35 {
36
37 namespace Toolkit
38 {
39
40 namespace Internal
41 {
42
43 /*
44  * Parses JSON
45  */
46 class JsonParser : public BaseObject
47 {
48 public:
49   /*
50    * @copydoc Toolkit::JsonParser::JsonParser()
51    */
52   JsonParser();
53
54   /*
55    * @copydoc Toolkit::JsonParser::JsonParser(const TreeNode& tree)
56    */
57   explicit JsonParser(const TreeNode& tree);
58
59   /*
60    */
61   ~JsonParser();
62
63   /*
64    * @copydoc Toolkit::JsonParser::Parse()
65    */
66   int Parse(const std::string& source);
67
68   /*
69    * @copydoc Toolkit::JsonParser::Pack()
70    */
71   void Pack(void);
72
73   /*
74    * @copydoc Toolkit::JsonParser::GetRoot()
75    */
76   const TreeNode* GetRoot() const;
77
78   /*
79    * @copydoc Toolkit::JsonParser::ParseError()
80    */
81   bool ParseError() const;
82
83   /*
84    * @copydoc Toolkit::JsonParser::GetErrorPosition()
85    */
86   int GetErrorPosition() const;
87
88   /*
89    * @copydoc Toolkit::JsonParser::GetErrorDescription()
90    */
91   std::string GetErrorDescription() const;
92
93   /*
94    * @copydoc Toolkit::JsonParser::GetErrorLineNumber()
95    */
96   int GetErrorLineNumber() const;
97
98   /*
99    * @copydoc Toolkit::JsonParser::GetErrorColumn()
100    */
101   int GetErrorColumn() const;
102
103   /*
104    * @copydoc Toolkit::JsonParser::Write()
105    */
106   void Write(std::ostream& output, int indent) const;
107
108 private:
109   typedef std::vector<char> VectorChar;
110   typedef VectorChar::iterator VectorCharIter;
111
112   typedef std::list<VectorChar> SourceContainer;
113   typedef std::list<VectorChar>::iterator SourceContainerIter;
114
115   JsonParser(JsonParser &);
116   JsonParser& operator=(const JsonParser&);
117
118   SourceContainer mSources;         ///< List of strings from Parse() merge operations
119
120   TreeNode* mRoot;                  ///< Tree root
121
122   const char *mErrorDescription;    ///< Last parse error description
123   int mErrorPosition;               ///< Last parse error position
124   int mErrorLine;                   ///< Last parse error line
125   int mErrorColumn;                 ///< Last parse error column
126
127   int mNumberOfChars;               ///< The size of string data for all nodes
128   int mNumberOfNodes;               ///< Node count
129
130 };
131
132 } // namespace Internal
133
134
135 inline const Internal::JsonParser& GetImplementation(const Toolkit::JsonParser& parser)
136 {
137   DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
138
139   const BaseObject& handle = parser.GetBaseObject();
140
141   return static_cast<const Internal::JsonParser&>(handle);
142 }
143
144
145 inline Internal::JsonParser& GetImplementation(Toolkit::JsonParser& parser)
146 {
147   DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
148
149   BaseObject& handle = parser.GetBaseObject();
150
151   return static_cast<Internal::JsonParser&>(handle);
152 }
153
154 } // namespace Toolkit
155
156 } // namespace Dali
157
158
159 #endif // __DALI_JSON_PARSER_IMPL_H__