Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / FUiEffects_ParserXMLParser.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        FUiEffects_ParserXMLParser.h
19  * @brief       This file contains a declaration of XmlParser class
20  */
21
22 #ifndef _FUI_EFFECTS_INTERNAL_PARSER_XMLPARSER_H_
23 #define _FUI_EFFECTS_INTERNAL_PARSER_XMLPARSER_H_
24
25 #include <libxml/parser.h>
26
27 namespace Tizen { namespace Ui { namespace Effects { namespace _Parser
28 {
29
30 class EffectParser;
31
32 /**
33  * @class       XmlParser
34  * @brief       An intermediate functionality between tizen's xmlSAXHandler and EffectParser class
35  *                      Uses the former for parsing an .xml file and sends information to the latter
36  *                      Implemented according to the singleton pattern
37  *
38  * @since 2.0
39  *
40  */
41 class XmlParser
42 {
43 public:
44
45         /**
46          * Class constructor
47          *
48          * @since 2.0
49          *
50          */
51         XmlParser(EffectParser* pParent);
52
53         /**
54          * Class destructor
55          *
56          * @since 2.0
57          *
58          */
59         virtual ~XmlParser(void);
60
61         /**
62          * Performs a complete parsing of an .xml file by usage xmlSAXHandler
63          *
64          * @since 2.0
65          *
66          * @return              A boolean result of XML-parsing only
67          * @param[in]   pFilePath - a full path to the input file
68          * @param[in]   sendcallbacks - determines whether to send information to EffectParser
69          *                              or just to parse the input file
70          * @exception   E_PARSING_FAILED        XML parsing hasn't been successful
71          */
72         bool Parse(const char* pFilePath, bool sendCallbacks);
73
74         /**
75          * Unzips a .zip-archive
76          *
77          * @since 2.0
78          *
79          * @param[in]   pArchivePath - a full path to the archive
80          * @param[in]   pDestinationPath - a path to the directory for the archive
81          *                              to be extracted to
82          */
83         static bool ExtractFromArchive(const char* pArchivePath, const char* pDestinationPath);
84
85 protected:
86
87 private:
88
89         // Hidden copy constructor
90         XmlParser(const XmlParser& rhs);
91
92         // Hidden assignment operator
93         XmlParser& operator=(const XmlParser& rhs);
94
95         // SAX callback that handles an opening tag of a new element
96         static void StartElementNs(void * pCtx, const xmlChar* pLocalName, const xmlChar* pPrefix, const xmlChar* pUri,
97                         int namespaceCount, const xmlChar** ppNamespaces, int attributeCount, int defaultedCount, const xmlChar** ppAttributes);
98
99         // SAX callback that handles a closing tag of an element
100         static void EndElementNs(void* pCtx, const xmlChar* pLocalName, const xmlChar* pPrefix, const xmlChar* pUri);
101
102         // SAX callback that handles precense of a text line inside some element
103         static void CharactersM(void* pCtx, const xmlChar* pCh, int len);
104
105         // SAX callback that handles a sax error message
106         static void Error(void* pCtx, const char* pMsg, ... );
107
108         // SAX callback that handles a sax warning
109         static void Warning(void* pCtx, const char* pMsg, ... );
110
111 private:
112
113         static EffectParser* __pCurrentParent;
114         static bool __justParse;
115 };
116
117 } } } } // Tizen::Ui::Effects::_Parser
118
119 #endif //_FUI_EFFECTS_INTERNAL_PARSER_XMLPARSER_H_