00001 /*00002 * The Software License00003 * =================================================================================00004 * Copyright (c) 2003-.The Terimber Corporation. All rights reserved.00005 * =================================================================================00006 * Redistributions of source code must retain the above copyright notice, 00007 * this list of conditions and the following disclaimer.00008 * Redistributions in binary form must reproduce the above copyright notice, 00009 * this list of conditions and the following disclaimer in the documentation 00010 * and/or other materials provided with the distribution.00011 * The end-user documentation included with the redistribution, if any, 00012 * must include the following acknowledgment:00013 * "This product includes software developed by the Terimber Corporation."00014 * =================================================================================00015 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00016 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00017 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00018 * IN NO EVENT SHALL THE TERIMBER CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR 00019 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00021 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00022 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE00024 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.00025 * ================================================================================00026 */00027
00028 #ifndef _terimber_persxml_h_00029 #define _terimber_persxml_h_00030
00031 #include "base/stack.h"00032 #include "xml/sxml.h"00033 #include "xml/miscxml.h"00034
00035 BEGIN_TERIMBER_NAMESPACE00036 #pragma pack(4)00037
00041typedef_stack< const xml_tree_node* >persistor_stack_t;
00042
00045class xml_persistor00046 {
00047 public:
00049 xml_persistor( byte_consumer& stream,
00050 constxml_document& doc,
00051 mem_pool_t& small_pool,
00052 mem_pool_t& big_pool,
00053 bool validate,
00054 bool save_doc_type,
00055 size_t size
00056 );
00057
00059 ~xml_persistor();
00061 bool00062 persist();
00064 constchar*
00065 get_error() const;
00066
00067 protected:
00069 void00070 persistDocument();
00072 void00073 persistDocType();
00075 void00076 persistElement();
00078 void00079 persistAttributes();
00081 void00082 persistText();
00084 void00085 persistCDATA();
00087 void00088 persistComment();
00090 void00091 persistPI();
00093 void00094 persistEntityDecl(constentityDecl* decl = 0
00095 );
00097 void00098 persistNotationDecl(constnotationDecl* decl = 0
00099 );
00101 void00102 persistElementDecl(constelementDecl* decl = 0
00103 );
00105 void00106 persistAttributeDecl(constattributeDecl& decl
00107 );
00108
00110 void00111 persistMixed( constdfa_token* parent
00112 );
00114 void00115 persistChildren(constdfa_token* parent,
00116 dfaRule prevRule
00117 );
00119 void00120 restore_stack( bool makeShift = true00121 );
00123 void00124 persistValue( constchar* value,
00125 bool charData = false00126 );
00127 private:
00128constsize_t_xml_size;
00129byte_consumer& _stream;
00130constxml_document& _doc;
00131mem_pool_t& _small_pool;
00132mem_pool_t& _big_pool;
00133persistor_stack_t_element_stack;
00134string_t_error;
00135bool_validate;
00136bool_save_doc_type;
00137byte_allocator* _tmp_allocator;
00138byte_allocator* _stack_allocator;
00139bool_in_doc_type;
00140 };
00141
00142 #pragma pack()00143 END_TERIMBER_NAMESPACE00144
00145 #endif // _terimber_persxml_h_