1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  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,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef METAINFOREADER_HXX_INCLUDED
25 #define METAINFOREADER_HXX_INCLUDED
26 
27 #include "internal/basereader.hxx"
28 #include "internal/types.hxx"
29 
30 class ITag;
31 class CKeywordsTag;
32 class CSimpleTag;
33 class CDummyTag;
34 
35 class CMetaInfoReader : public CBaseReader
36 {
37 public:
38 	virtual ~CMetaInfoReader();
39 
40 	CMetaInfoReader( const std::string& DocumentName );
41 
42 	CMetaInfoReader( void* stream, zlib_filefunc_def* fa);
43 
44 	/** check if the Tag is in the target meta.xml file.
45 
46 		@param TagName
47 		the name of the tag that will be retrive.
48 	*/
49 	bool hasTag(std::wstring TagName) const;
50 
51 
52 	/** Get a specific tag content, compound tags will be returned as comma separated list.
53 
54 		@param TagName
55 		the name of the tag that will be retrive.
56 	*/
57 	std::wstring getTagData( const std::wstring& TagName);
58 
59 	/** check if the a tag has the specific attribute.
60 
61 		@param TagName
62 		the name of the tag.
63 		@param AttributeName
64 		the name of the attribute.
65 	*/
66 	bool hasTagAttribute( const std::wstring TagName,  std::wstring AttributeName);
67 
68 	/** Get a specific attribute content.
69 
70 		@param TagName
71 		the name of the tag.
72 		@param AttributeName
73 		the name of the attribute.
74 	*/
75 	std::wstring getTagAttribute( const std::wstring TagName,  std::wstring AttributeName);
76 
77 	/** Get the default language of the whole document.
78 	*/
79 	LocaleSet_t getDefaultLocale( );
80 
81 protected: // protected because its only an implementation relevant class
82 
83 	/** start_element occurs when a tag is start.
84 
85 		@param raw_name
86 		raw name of the tag.
87 		@param local_name
88 		local name of the tag.
89 		@param attributes
90 		attribute structure.
91 	*/
92 	virtual void start_element(
93 		const std::wstring& raw_name,
94 		const std::wstring& local_name,
95 		const XmlTagAttributes_t& attributes);
96 
97 	/** end_element occurs when a tag is closed
98 
99 		@param raw_name
100 		raw name of the tag.
101 		@param local_name
102 		local name of the tag.
103 	*/
104 	virtual void end_element(
105 		const std::wstring& raw_name, const std::wstring& local_name);
106 
107 	/** characters occurs when receiving characters
108 
109 		@param character
110 		content of the information received.
111 	*/
112 	virtual void characters(const std::wstring& character);
113 
114 protected:
115 	/** choose an appropriate tag reader to handle the tag.
116 
117 		@param tag_name
118 		the name of the tag.
119 		@param XmlAttributes
120 		attribute structure of the tag to save in.
121 	*/
122 	ITag* chooseTagReader(
123 		const std::wstring& tag_name, const XmlTagAttributes_t& XmlAttributes );
124 
125 	/** save the received content into structure.
126 
127 		@param tag_name
128 		the name of the tag.
129 	*/
130 	void saveTagContent( const std::wstring& tag_name );
131 
132 private:
133 	XmlTags_t      m_AllMetaInfo;
134 
135 private:
136     std::stack<ITag*> m_TagBuilderStack;
137 
138 private:
139 	CKeywordsTag* m_pKeywords_Builder;
140 	CDummyTag*   m_pDummy_Builder;
141 	CSimpleTag* m_pSimple_Builder;
142 };
143 
144 #endif
145