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