[ATSPI] make ScrollToChild use descendant
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / builder / json-parser.h
1 #ifndef DALI_JSON_PARSER_H
2 #define DALI_JSON_PARSER_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23 #include <list>
24 #include <ostream>
25 #include <string>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/devel-api/builder/tree-node.h>
29
30 namespace Dali
31 {
32 namespace Toolkit
33 {
34 namespace Internal DALI_INTERNAL
35 {
36 class JsonParser;
37 }
38
39 /*
40  * Parses JSON
41  */
42 class DALI_TOOLKIT_API JsonParser : public BaseHandle
43 {
44 public:
45   /*
46    * Create new parser
47    * @return JsonParser
48    */
49   static JsonParser New();
50
51   /*
52    * Create new parser from the given tree
53    * This method will deep copy the given tree.
54    * @return JsonParser
55    */
56   static JsonParser New(const TreeNode& tree);
57
58   /*
59    * Create empty handle
60    */
61   JsonParser();
62
63   /**
64    * @brief Destructor
65    *
66    * This is non-virtual since derived Handle types must not contain data or virtual methods.
67    */
68   ~JsonParser();
69
70   /**
71    * Downcast an Object handle to JsonParser if it is a JsonParser.
72    * @param[in] handle Handle to an object
73    * @return A handle to a JsonParser or an uninitialized handle
74    */
75   static JsonParser DownCast(BaseHandle handle);
76
77   /*
78    * Parse the source and construct a node tree.
79    * Subsequent calls to this function will merge the trees.
80    * @param source The json source to parse
81    * @return true if parsed okay, otherwise an error.
82    */
83   bool Parse(const std::string& source);
84
85   /*
86    * Optimize memory usage by packing strings
87    */
88   void Pack(void);
89
90   /*
91    * Get the tree root node
92    */
93   const TreeNode* GetRoot() const;
94
95   /*
96    * Get the parser error flag
97    * @return true if there was a parse error
98    */
99   bool ParseError() const;
100
101   /*
102    * Get the last error position
103    * @return The character position of the most recent Parse() error
104    */
105   int GetErrorPosition() const;
106
107   /*
108    * Get the last error description
109    * @return A string description of the error
110    */
111   std::string GetErrorDescription() const;
112
113   /*
114    * Get the last error line number
115    * @return the line number of the most recent Parse() error.
116    */
117   int GetErrorLineNumber() const;
118
119   /*
120    * Get the last error line number
121    * @return the line number of the most recent Parse() error.
122    */
123   int GetErrorColumn() const;
124
125   /*
126    * Write to output stream with optional indent
127    * @param output The stream to write to
128    * @param indent The indent to use
129    */
130   void Write(std::ostream& output, int indent) const;
131
132 public: // Not intended for application developers
133   /**
134    * This constructor is used by Dali New() methods
135    * @param [in] parser A pointer to a newly allocated Dali resource
136    */
137   explicit DALI_INTERNAL JsonParser(Internal::JsonParser* parser);
138 };
139
140 } // namespace Toolkit
141
142 } // namespace Dali
143
144 #endif // DALI_JSON_PARSER_H