xmlwrapp
|
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 */ 00073 static void indent_output(bool flag); 00074 00075 /** 00076 This member function controls whether or not the XML parser should 00077 remove ignorable whitespace around XML elements. The default 00078 is false. 00079 00080 @param flag True to remove whitespace, false to leave alone. 00081 */ 00082 static void remove_whitespace(bool flag); 00083 00084 /** 00085 This member function controls whether or not the XML parser should 00086 substitute entities while parsing. The default is true. 00087 00088 @param flag True to turn on substitution, false to turn off. 00089 */ 00090 static void substitute_entities(bool flag); 00091 00092 /** 00093 This member function controls whether or not the XML parser should 00094 load external (DTD) subsets while parsing. This will only affect the 00095 loading of the subsets, it does not cause files to be validated. The 00096 default is true. 00097 00098 @param flag True to turn on loading, false to turn it off. 00099 */ 00100 static void load_external_subsets(bool flag); 00101 00102 /** 00103 This member function controls whether or not the XML parser should 00104 validate every XML document that is parses with its DTD. The default 00105 is false. 00106 00107 @return flag True to turn on validation, false to turn it off. 00108 */ 00109 static void validate_xml(bool flag); 00110 00111 private: 00112 init(const init&); 00113 init& operator=(const init&); 00114 00115 void init_library(); 00116 void shutdown_library(); 00117 00118 static int ms_counter; 00119 }; 00120 00121 } // namespace xml 00122 00123 // use a "nifty counter" to ensure that any source file that uses xmlwrapp 00124 // will initialize the library prior to its first use 00125 namespace 00126 { 00127 xml::init g_xmlwrapp_initializer; 00128 } 00129 00130 #endif // _xmlwrapp_init_h_