c2f9538ed229c831f9216aa63aa1d640fa034966
[platform/core/uifw/libscl-ui-nui.git] / xml2binary / include / metadata_handler.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 __METADATA_HANDLER_H__
19 #define __METADATA_HANDLER_H__
20 #include <stdio.h>
21 #include <libxml/parser.h>
22 #include <string.h>
23 #include "encode_metadata.h"
24 #include "imetadata_encoder.h"
25 #include "imetadata_parser.h"
26 #include "imetadata_helper.h"
27 class MetaData_Handler:private IMetaData_Encoder, IMetaData_Parser, public IMetaData_Helper{
28     private:
29         typedef struct __Metadata_Width {
30             int string_id_width;
31         }MetaData_Width;
32
33     public:
34         MetaData_Handler(const char* file);
35         void set_current_metadata_record(const char* record_name);
36         //encode all strings and output
37         // bin file is assigned by parameter "file"
38         int encode(const char* file)const;
39
40         //encode all strings and output
41         // bin file is assigned by parameter "file"
42         int encode(const char* file, int&offset)const;
43
44         // encode all strings and output to storage
45         int encode(ResourceStorage& storage)const;
46
47         unsigned short get_width(const char* field_name) const;
48
49     private:
50         unsigned short get_width(const char* name, const MetaData_Record& metadata_record) const;
51         int find_metadata_record_index(const char* name) const;
52         int parsing_field(const xmlNodePtr node, MetaData_Field& data, const MetaData_Width& metadataWidth);
53         int parsing_record(const xmlNodePtr curNode, MetaData_Record& metadataRecord, const MetaData_Width& metadataWidth);
54         int parsing_metadata_type(const xmlNodePtr curNode, MetaData_Width& metadataWidth);
55         void parsing_metadata();
56         const MetaData* get_metadata()const;
57
58     private:
59         MetaData metadata;
60         int m_current_metadata_record_id;
61         const char* file_name;
62 };
63 #endif