1 #ifndef DALI_JSON_PARSER_IMPL_H
2 #define DALI_JSON_PARSER_IMPL_H
5 * Copyright (c) 2021 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.
22 #include <dali/public-api/common/vector-wrapper.h>
23 #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>
42 class JsonParser : public BaseObject
46 * @copydoc Toolkit::JsonParser::JsonParser()
51 * @copydoc Toolkit::JsonParser::JsonParser(const TreeNode& tree)
53 explicit JsonParser(const TreeNode& tree);
57 ~JsonParser() override;
60 * @copydoc Toolkit::JsonParser::Parse()
62 bool Parse(const std::string& source);
65 * @copydoc Toolkit::JsonParser::Pack()
70 * @copydoc Toolkit::JsonParser::GetRoot()
72 const TreeNode* GetRoot() const;
75 * @copydoc Toolkit::JsonParser::ParseError()
77 bool ParseError() const;
80 * @copydoc Toolkit::JsonParser::GetErrorPosition()
82 int GetErrorPosition() const;
85 * @copydoc Toolkit::JsonParser::GetErrorDescription()
87 std::string GetErrorDescription() const;
90 * @copydoc Toolkit::JsonParser::GetErrorLineNumber()
92 int GetErrorLineNumber() const;
95 * @copydoc Toolkit::JsonParser::GetErrorColumn()
97 int GetErrorColumn() const;
100 * @copydoc Toolkit::JsonParser::Write()
102 void Write(std::ostream& output, int indent) const;
105 typedef std::vector<char> VectorChar;
106 typedef VectorChar::iterator VectorCharIter;
108 typedef std::list<VectorChar> SourceContainer;
109 typedef std::list<VectorChar>::iterator SourceContainerIter;
111 JsonParser(JsonParser&);
112 JsonParser& operator=(const JsonParser&);
114 SourceContainer mSources; ///< List of strings from Parse() merge operations
116 TreeNode* mRoot; ///< Tree root
118 const char* mErrorDescription; ///< Last parse error description
119 int mErrorPosition; ///< Last parse error position
120 int mErrorLine; ///< Last parse error line
121 int mErrorColumn; ///< Last parse error column
123 int mNumberOfChars; ///< The size of string data for all nodes
124 int mNumberOfNodes; ///< Node count
127 } // namespace Internal
129 inline const Internal::JsonParser& GetImplementation(const Toolkit::JsonParser& parser)
131 DALI_ASSERT_ALWAYS(parser && "JsonParser handle is empty");
133 const BaseObject& handle = parser.GetBaseObject();
135 return static_cast<const Internal::JsonParser&>(handle);
138 inline Internal::JsonParser& GetImplementation(Toolkit::JsonParser& parser)
140 DALI_ASSERT_ALWAYS(parser && "JsonParser handle is empty");
142 BaseObject& handle = parser.GetBaseObject();
144 return static_cast<Internal::JsonParser&>(handle);
147 } // namespace Toolkit
151 #endif // DALI_JSON_PARSER_IMPL_H