1 #ifndef __DALI_JSON_PARSER_IMPL_H__
2 #define __DALI_JSON_PARSER_IMPL_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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
11 // http://floralicense.org/license/
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.
25 #include <dali/public-api/object/base-object.h>
26 #include <dali-toolkit/public-api/builder/json-parser.h>
27 #include <dali-toolkit/public-api/builder/tree-node.h>
29 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
31 namespace Dali DALI_IMPORT_API
37 namespace Internal DALI_INTERNAL
43 class JsonParser : public BaseObject
47 * @copydoc Toolkit::JsonParser::JsonParser()
52 * @copydoc Toolkit::JsonParser::JsonParser(const TreeNode& tree)
54 explicit JsonParser(const TreeNode& tree);
61 * @copydoc Toolkit::JsonParser::Parse()
63 int Parse(const std::string& source);
66 * @copydoc Toolkit::JsonParser::Pack()
71 * @copydoc Toolkit::JsonParser::GetRoot()
73 const TreeNode* GetRoot() const;
76 * @copydoc Toolkit::JsonParser::ParseError()
78 bool ParseError() const;
81 * @copydoc Toolkit::JsonParser::GetErrorPosition()
83 int GetErrorPosition() const;
86 * @copydoc Toolkit::JsonParser::GetErrorDescription()
88 std::string GetErrorDescription() const;
91 * @copydoc Toolkit::JsonParser::GetErrorLineNumber()
93 int GetErrorLineNumber() const;
96 * @copydoc Toolkit::JsonParser::GetErrorColumn()
98 int GetErrorColumn() const;
101 * @copydoc Toolkit::JsonParser::Write()
103 void Write(std::ostream& output, int indent) const;
106 typedef std::vector<char> VectorChar;
107 typedef VectorChar::iterator VectorCharIter;
109 typedef std::list<VectorChar> SourceContainer;
110 typedef std::list<VectorChar>::iterator SourceContainerIter;
112 JsonParser(JsonParser &);
113 JsonParser& operator=(const JsonParser&);
115 SourceContainer mSources; ///< List of strings from Parse() merge operations
117 TreeNode* mRoot; ///< Tree root
119 const char *mErrorDescription; ///< Last parse error description
120 int mErrorPosition; ///< Last parse error position
121 int mErrorLine; ///< Last parse error line
122 int mErrorColumn; ///< Last parse error column
124 int mNumberOfChars; ///< The size of string data for all nodes
125 int mNumberOfNodes; ///< Node count
129 } // namespace Internal
132 inline const Internal::JsonParser& GetImplementation(const Toolkit::JsonParser& parser)
134 DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
136 const BaseObject& handle = parser.GetBaseObject();
138 return static_cast<const Internal::JsonParser&>(handle);
142 inline Internal::JsonParser& GetImplementation(Toolkit::JsonParser& parser)
144 DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
146 BaseObject& handle = parser.GetBaseObject();
148 return static_cast<Internal::JsonParser&>(handle);
151 } // namespace Toolkit
156 #endif // __DALI_JSON_PARSER_IMPL_H__