Upload initial version
[platform/core/uifw/libscl-ui-nui.git] / scl / xml_parser_utils.h
1 /*
2  * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef __XML_PARSER_UTILS_H__
19 #define __XML_PARSER_UTILS_H__
20 #include <assert.h>
21 #include <limits.h>
22 #include <libxml/parser.h>
23 #include "scltypes.h"
24
25 using namespace scl;
26
27 int get_content_int(const xmlNodePtr cur_node);
28 bool get_content_bool(const xmlNodePtr cur_node);
29
30
31 bool equal_prop(const xmlNodePtr cur_node, const char* prop, const char* str);
32
33 template <class T>
34 bool get_prop_number(const xmlNodePtr cur_node, const char* prop, T *ret) {
35     assert(cur_node != NULL);
36
37     bool succeeded = false;
38
39     xmlChar* key = xmlGetProp(cur_node, (const xmlChar*)prop);
40
41     if (ret && key != NULL) {
42         succeeded = true;
43         *ret = (T)atoi((const char*)key);
44         xmlFree(key);
45     }
46
47     return succeeded;
48 }
49 bool get_prop_bool(const xmlNodePtr cur_node, const char* prop, sclboolean *ret);
50 int dex_string_to_int(const char* str);
51 int get_content_dex_string_int(const xmlNodePtr cur_node);
52 #endif