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 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include <dali/public-api/object/base-object.h>
27 #include <dali-toolkit/public-api/builder/json-parser.h>
28 #include <dali-toolkit/public-api/builder/tree-node.h>
30 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
32 namespace Dali DALI_IMPORT_API
38 namespace Internal DALI_INTERNAL
44 class JsonParser : public BaseObject
48 * @copydoc Toolkit::JsonParser::JsonParser()
53 * @copydoc Toolkit::JsonParser::JsonParser(const TreeNode& tree)
55 explicit JsonParser(const TreeNode& tree);
62 * @copydoc Toolkit::JsonParser::Parse()
64 int Parse(const std::string& source);
67 * @copydoc Toolkit::JsonParser::Pack()
72 * @copydoc Toolkit::JsonParser::GetRoot()
74 const TreeNode* GetRoot() const;
77 * @copydoc Toolkit::JsonParser::ParseError()
79 bool ParseError() const;
82 * @copydoc Toolkit::JsonParser::GetErrorPosition()
84 int GetErrorPosition() const;
87 * @copydoc Toolkit::JsonParser::GetErrorDescription()
89 std::string GetErrorDescription() const;
92 * @copydoc Toolkit::JsonParser::GetErrorLineNumber()
94 int GetErrorLineNumber() const;
97 * @copydoc Toolkit::JsonParser::GetErrorColumn()
99 int GetErrorColumn() const;
102 * @copydoc Toolkit::JsonParser::Write()
104 void Write(std::ostream& output, int indent) const;
107 typedef std::vector<char> VectorChar;
108 typedef VectorChar::iterator VectorCharIter;
110 typedef std::list<VectorChar> SourceContainer;
111 typedef std::list<VectorChar>::iterator SourceContainerIter;
113 JsonParser(JsonParser &);
114 JsonParser& operator=(const JsonParser&);
116 SourceContainer mSources; ///< List of strings from Parse() merge operations
118 TreeNode* mRoot; ///< Tree root
120 const char *mErrorDescription; ///< Last parse error description
121 int mErrorPosition; ///< Last parse error position
122 int mErrorLine; ///< Last parse error line
123 int mErrorColumn; ///< Last parse error column
125 int mNumberOfChars; ///< The size of string data for all nodes
126 int mNumberOfNodes; ///< Node count
130 } // namespace Internal
133 inline const Internal::JsonParser& GetImplementation(const Toolkit::JsonParser& parser)
135 DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
137 const BaseObject& handle = parser.GetBaseObject();
139 return static_cast<const Internal::JsonParser&>(handle);
143 inline Internal::JsonParser& GetImplementation(Toolkit::JsonParser& parser)
145 DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
147 BaseObject& handle = parser.GetBaseObject();
149 return static_cast<Internal::JsonParser&>(handle);
152 } // namespace Toolkit
157 #endif // __DALI_JSON_PARSER_IMPL_H__