1 #ifndef DALI_JSON_PARSER_IMPL_H
2 #define DALI_JSON_PARSER_IMPL_H
5 * Copyright (c) 2019 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.
24 #include <dali/public-api/common/vector-wrapper.h>
25 #include <dali/public-api/object/base-object.h>
28 #include <dali-toolkit/devel-api/builder/json-parser.h>
29 #include <dali-toolkit/devel-api/builder/tree-node.h>
31 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
45 class JsonParser : public BaseObject
49 * @copydoc Toolkit::JsonParser::JsonParser()
54 * @copydoc Toolkit::JsonParser::JsonParser(const TreeNode& tree)
56 explicit JsonParser(const TreeNode& tree);
60 ~JsonParser() override;
63 * @copydoc Toolkit::JsonParser::Parse()
65 bool Parse(const std::string& source);
68 * @copydoc Toolkit::JsonParser::Pack()
73 * @copydoc Toolkit::JsonParser::GetRoot()
75 const TreeNode* GetRoot() const;
78 * @copydoc Toolkit::JsonParser::ParseError()
80 bool ParseError() const;
83 * @copydoc Toolkit::JsonParser::GetErrorPosition()
85 int GetErrorPosition() const;
88 * @copydoc Toolkit::JsonParser::GetErrorDescription()
90 std::string GetErrorDescription() const;
93 * @copydoc Toolkit::JsonParser::GetErrorLineNumber()
95 int GetErrorLineNumber() const;
98 * @copydoc Toolkit::JsonParser::GetErrorColumn()
100 int GetErrorColumn() const;
103 * @copydoc Toolkit::JsonParser::Write()
105 void Write(std::ostream& output, int indent) const;
108 typedef std::vector<char> VectorChar;
109 typedef VectorChar::iterator VectorCharIter;
111 typedef std::list<VectorChar> SourceContainer;
112 typedef std::list<VectorChar>::iterator SourceContainerIter;
114 JsonParser(JsonParser &);
115 JsonParser& operator=(const JsonParser&);
117 SourceContainer mSources; ///< List of strings from Parse() merge operations
119 TreeNode* mRoot; ///< Tree root
121 const char *mErrorDescription; ///< Last parse error description
122 int mErrorPosition; ///< Last parse error position
123 int mErrorLine; ///< Last parse error line
124 int mErrorColumn; ///< Last parse error column
126 int mNumberOfChars; ///< The size of string data for all nodes
127 int mNumberOfNodes; ///< Node count
131 } // namespace Internal
134 inline const Internal::JsonParser& GetImplementation(const Toolkit::JsonParser& parser)
136 DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
138 const BaseObject& handle = parser.GetBaseObject();
140 return static_cast<const Internal::JsonParser&>(handle);
144 inline Internal::JsonParser& GetImplementation(Toolkit::JsonParser& parser)
146 DALI_ASSERT_ALWAYS( parser && "JsonParser handle is empty" );
148 BaseObject& handle = parser.GetBaseObject();
150 return static_cast<Internal::JsonParser&>(handle);
153 } // namespace Toolkit
158 #endif // DALI_JSON_PARSER_IMPL_H