00001 /* 00002 * Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org) 00003 * All Rights Reserved 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in 00013 * the documentation and/or other materials provided with the 00014 * distribution. 00015 * 3. Neither the name of the Author nor the names of its contributors 00016 * may be used to endorse or promote products derived from this software 00017 * without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00021 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00022 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 00023 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00024 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00025 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00026 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00027 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00028 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00029 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00030 * SUCH DAMAGE. 00031 */ 00032 00033 /** 00034 @file 00035 00036 This file contains the definition of the xml::init class. 00037 */ 00038 00039 #ifndef _xmlwrapp_init_h_ 00040 #define _xmlwrapp_init_h_ 00041 00042 /// XML library namespace 00043 namespace xml 00044 { 00045 00046 /** 00047 The xml::init class is used to configure the XML parser. 00048 00049 If you want to use and of the xml::init member functions, do so before 00050 you start any threads or use any other part of xmlwrapp. The member 00051 functions may alter global and/or static variables and affect the behavior 00052 of subsequently created classes (and the parser in particular). 00053 In other words, this class is not thread safe. 00054 00055 @note In xmlwrapp versions prior to 0.6.0, this class was used to initialize 00056 the library and exactly one instance had to be created before first 00057 use. This is no longer true: user code doesn't have to create any 00058 instances, but it @em can create as many instances as it wants. 00059 */ 00060 class init 00061 { 00062 public: 00063 init(); 00064 ~init(); 00065 00066 /** 00067 This member function controls whether or not the XML parser should 00068 add text nodes for indenting when generating XML text output from a 00069 node tree. The default is true. 00070 00071 @param flag True to turn on indenting, false to turn it off. 00072 @author Peter Jones 00073 */ 00074 static void indent_output(bool flag); 00075 00076 /** 00077 This member function controls whether or not the XML parser should 00078 remove ignorable whitespace around XML elements. The default 00079 is false. 00080 00081 @param flag True to remove whitespace, false to leave alone. 00082 @author Peter Jones 00083 */ 00084 static void remove_whitespace(bool flag); 00085 00086 /** 00087 This member function controls whether or not the XML parser should 00088 substitute entities while parsing. The default is true. 00089 00090 @param flag True to turn on substitution, false to turn off. 00091 @author Peter Jones 00092 */ 00093 static void substitute_entities(bool flag); 00094 00095 /** 00096 This member function controls whether or not the XML parser should 00097 load external (DTD) subsets while parsing. This will only affect the 00098 loading of the subsets, it does not cause files to be validated. The 00099 default is true. 00100 00101 @param flag True to turn on loading, false to turn it off. 00102 @author Peter Jones 00103 */ 00104 static void load_external_subsets(bool flag); 00105 00106 /** 00107 This member function controls whether or not the XML parser should 00108 validate every XML document that is parses with its DTD. The default 00109 is false. 00110 00111 @return flag True to turn on validation, false to turn it off. 00112 @author Peter Jones 00113 */ 00114 static void validate_xml(bool flag); 00115 00116 private: 00117 init(const init&); 00118 init& operator=(const init&); 00119 00120 void init_library(); 00121 void shutdown_library(); 00122 00123 static int ms_counter; 00124 }; 00125 00126 } // namespace xml 00127 00128 // use a "nifty counter" to ensure that any source file that uses xmlwrapp 00129 // will initialize the library prior to its first use 00130 namespace 00131 { 00132 xml::init g_xmlwrapp_initializer; 00133 } 00134 00135 #endif // _xmlwrapp_init_h_