1 #ifndef __DALI_JSON_PARSER_H__
2 #define __DALI_JSON_PARSER_H__
5 * Copyright (c) 2018 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.
25 #include <dali/public-api/object/base-handle.h>
28 #include <dali-toolkit/devel-api/builder/tree-node.h>
36 namespace Internal DALI_INTERNAL
44 class DALI_TOOLKIT_API JsonParser : public BaseHandle
52 static JsonParser New();
55 * Create new parser from the given tree
56 * This method will deep copy the given tree.
59 static JsonParser New(const TreeNode& tree);
69 * This is non-virtual since derived Handle types must not contain data or virtual methods.
74 * Downcast an Object handle to JsonParser if it is a JsonParser.
75 * @param[in] handle Handle to an object
76 * @return A handle to a JsonParser or an uninitialized handle
78 static JsonParser DownCast( BaseHandle handle );
81 * Parse the source and construct a node tree.
82 * Subsequent calls to this function will merge the trees.
83 * @param source The json source to parse
84 * @return true if parsed okay, otherwise an error.
86 bool Parse(const std::string& source);
89 * Optimize memory usage by packing strings
94 * Get the tree root node
96 const TreeNode* GetRoot() const;
99 * Get the parser error flag
100 * @return true if there was a parse error
102 bool ParseError() const;
105 * Get the last error position
106 * @return The character position of the most recent Parse() error
108 int GetErrorPosition() const;
111 * Get the last error description
112 * @return A string description of the error
114 std::string GetErrorDescription() const;
117 * Get the last error line number
118 * @return the line number of the most recent Parse() error.
120 int GetErrorLineNumber() const;
123 * Get the last error line number
124 * @return the line number of the most recent Parse() error.
126 int GetErrorColumn() const;
129 * Write to output stream with optional indent
130 * @param output The stream to write to
131 * @param indent The indent to use
133 void Write(std::ostream& output, int indent) const;
135 public: // Not intended for application developers
138 * This constructor is used by Dali New() methods
139 * @param [in] parser A pointer to a newly allocated Dali resource
141 explicit DALI_INTERNAL JsonParser(Internal::JsonParser* parser);
144 } // namespace Toolkit
149 #endif // __DALI_JSON_PARSER_H__