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 CONTENTREADER_HXX_INCLUDED
25cdf0e10cSrcweir #define CONTENTREADER_HXX_INCLUDED
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "internal/basereader.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir class ITag;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir class CContentReader : public CBaseReader
32cdf0e10cSrcweir {
33cdf0e10cSrcweir public:
34cdf0e10cSrcweir 	virtual ~CContentReader();
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 	//CContentReader( const std::string& DocumentName );
37cdf0e10cSrcweir 	CContentReader( const std::string& DocumentName, LocaleSet_t const & DocumentLocale );
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 	CContentReader( void* stream, LocaleSet_t const & DocumentLocale, zlib_filefunc_def* fa );
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 	/** Get the chunkbuffer.
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 		@return
45cdf0e10cSrcweir 		the chunkbuffer of the document.
46cdf0e10cSrcweir 	*/
getChunkBuffer() const47cdf0e10cSrcweir 	inline ChunkBuffer_t const & getChunkBuffer( ) const{ return m_ChunkBuffer; };
48cdf0e10cSrcweir 
49cdf0e10cSrcweir protected: // protected because its only an implementation relevant class
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 	/** start_element occurs when a tag is start.
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 		@param raw_name
54cdf0e10cSrcweir 		raw name of the tag.
55cdf0e10cSrcweir 		@param local_name
56cdf0e10cSrcweir 		local name of the tag.
57cdf0e10cSrcweir 		@param attributes
58cdf0e10cSrcweir 		attribute structure.
59cdf0e10cSrcweir 	*/
60cdf0e10cSrcweir 	virtual void start_element(
61cdf0e10cSrcweir 		const std::wstring& raw_name,
62cdf0e10cSrcweir 		const std::wstring& local_name,
63cdf0e10cSrcweir 		const XmlTagAttributes_t& attributes);
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	/** end_element occurs when a tag is closed
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 		@param raw_name
68cdf0e10cSrcweir 		raw name of the tag.
69cdf0e10cSrcweir 		@param local_name
70cdf0e10cSrcweir 		local name of the tag.
71cdf0e10cSrcweir 	*/
72cdf0e10cSrcweir 	virtual void end_element(
73cdf0e10cSrcweir 		const std::wstring& raw_name, const std::wstring& local_name);
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	/** characters occurs when receiving characters
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 		@param character
78cdf0e10cSrcweir 		content of the information received.
79cdf0e10cSrcweir 	*/
80cdf0e10cSrcweir 	virtual void characters(const std::wstring& character);
81cdf0e10cSrcweir 
82cdf0e10cSrcweir protected:
83cdf0e10cSrcweir 	/** choose an appropriate tag reader to handle the tag.
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 		@param tag_name
86cdf0e10cSrcweir 		the name of the tag.
87cdf0e10cSrcweir 		@param XmlAttributes
88cdf0e10cSrcweir 		attribute structure of the tag to save in.
89cdf0e10cSrcweir 	*/
90cdf0e10cSrcweir 	ITag* chooseTagReader(
91cdf0e10cSrcweir 		const std::wstring& tag_name, const XmlTagAttributes_t& XmlAttributes );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	/** Get the list of style locale pair.
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 		@return
96cdf0e10cSrcweir 		the Style-Locale map
97cdf0e10cSrcweir 	*/
getStyleMap() const98cdf0e10cSrcweir 	inline StyleLocaleMap_t const & getStyleMap( ) const{ return m_StyleMap; };
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	/** get style of the current content.
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 		@return style of the current content.
103cdf0e10cSrcweir 	*/
104cdf0e10cSrcweir 	::std::wstring getCurrentContentStyle( void );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	/** add chunk into Chunk Buffer.
107cdf0e10cSrcweir 	*/
108cdf0e10cSrcweir 	void addChunk( LocaleSet_t const & Locale, Content_t const & Content );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	/** get a style's locale field.
111cdf0e10cSrcweir 	*/
112cdf0e10cSrcweir 	LocaleSet_t const & getLocale( const StyleName_t Style );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir private:
115cdf0e10cSrcweir     std::stack<ITag*> m_TagBuilderStack;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	ChunkBuffer_t   m_ChunkBuffer;
118cdf0e10cSrcweir 	StyleLocaleMap_t      m_StyleMap;
119cdf0e10cSrcweir 	LocaleSet_t m_DefaultLocale;
120cdf0e10cSrcweir };
121cdf0e10cSrcweir 
122cdf0e10cSrcweir #endif
123