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