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>
29 #include <dali-toolkit/public-api/builder/json-parser.h>
30 #include <dali-toolkit/public-api/builder/tree-node.h>
32 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
46 class JsonParser : public BaseObject
50 * @copydoc Toolkit::JsonParser::JsonParser()
55 * @copydoc Toolkit::JsonParser::JsonParser(const TreeNode& tree)
57 explicit JsonParser(const TreeNode& tree);
64 * @copydoc Toolkit::JsonParser::Parse()
66 int Parse(const std::string& source);
69 * @copydoc Toolkit::JsonParser::Pack()
74 * @copydoc Toolkit::JsonParser::GetRoot()
76 const TreeNode* GetRoot() const;
79 * @copydoc Toolkit::JsonParser::ParseError()
81 bool ParseError() const;
84 * @copydoc Toolkit::JsonParser::GetErrorPosition()
86 int GetErrorPosition() const;
89 * @copydoc Toolkit::JsonParser::GetErrorDescription()
91 std::string GetErrorDescription() const;
94 * @copydoc Toolkit::JsonParser::GetErrorLineNumber()
96 int GetErrorLineNumber() const;
99 * @copydoc Toolkit::JsonParser::GetErrorColumn()
101 int GetErrorColumn() const;
104 * @copydoc Toolkit::JsonParser::Write()
106 void Write(std::ostream& output, int indent) const;
109 typedef std::vector<char> VectorChar;
110 typedef VectorChar::iterator VectorCharIter;
112 typedef std::list<VectorChar> SourceContainer;
113 typedef std::list<VectorChar>::iterator SourceContainerIter;
115 JsonParser(JsonParser &);
116 JsonParser& operator=(const JsonParser&);
118 SourceContainer mSources; ///< List of strings from Parse() merge operations
120 TreeNode* mRoot; ///< Tree root
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
127 int mNumberOfChars; ///< The size of string data for all nodes
128 int mNumberOfNodes; ///< Node count
132 } // namespace Internal
135 inline const Internal::JsonParser& GetImplementation(const Toolkit::JsonParser& parser)
137 DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
139 const BaseObject& handle = parser.GetBaseObject();
141 return static_cast<const Internal::JsonParser&>(handle);
145 inline Internal::JsonParser& GetImplementation(Toolkit::JsonParser& parser)
147 DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
149 BaseObject& handle = parser.GetBaseObject();
151 return static_cast<Internal::JsonParser&>(handle);
154 } // namespace Toolkit
159 #endif // __DALI_JSON_PARSER_IMPL_H__