xmlwrapp
Lightweight C++ XML parsing library
init.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2001-2003 Peter J Jones (pjones@pmade.org)
3  * All Rights Reserved
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name of the Author nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
23  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 
33 /**
34  @file
35 
36  This file contains the definition of the xml::init class.
37  */
38 
39 #ifndef _xmlwrapp_init_h_
40 #define _xmlwrapp_init_h_
41 
42 // xmlwrapp includes
43 #include "xmlwrapp/export.h"
44 
45 /// XML library namespace
46 namespace xml
47 {
48 
49 /**
50  The xml::init class is used to configure the XML parser.
51 
52  If you want to use and of the xml::init member functions, do so before
53  you start any threads or use any other part of xmlwrapp. The member
54  functions may alter global and/or static variables and affect the behavior
55  of subsequently created classes (and the parser in particular).
56  In other words, this class is not thread safe.
57 
58  @note In xmlwrapp versions prior to 0.6.0, this class was used to initialize
59  the library and exactly one instance had to be created before first
60  use. This is no longer true: user code doesn't have to create any
61  instances, but it @em can create as many instances as it wants.
62  */
63 class XMLWRAPP_API init
64 {
65 public:
66  init();
67  ~init();
68 
69  /**
70  This member function controls whether or not the XML parser should
71  add text nodes for indenting when generating XML text output from a
72  node tree. The default is true.
73 
74  @param flag True to turn on indenting, false to turn it off.
75  */
76  static void indent_output(bool flag);
77 
78  /**
79  This member function controls whether or not the XML parser should
80  remove ignorable whitespace around XML elements. The default
81  is false.
82 
83  @param flag True to remove whitespace, false to leave alone.
84  */
85  static void remove_whitespace(bool flag);
86 
87  /**
88  This member function controls whether or not the XML parser should
89  substitute entities while parsing. The default is true.
90 
91  @param flag True to turn on substitution, false to turn off.
92  */
93  static void substitute_entities(bool flag);
94 
95  /**
96  This member function controls whether or not the XML parser should
97  load external (DTD) subsets while parsing. This will only affect the
98  loading of the subsets, it does not cause files to be validated. The
99  default is true.
100 
101  @param flag True to turn on loading, false to turn it off.
102  */
103  static void load_external_subsets(bool flag);
104 
105  /**
106  This member function controls whether or not the XML parser should
107  validate every XML document that is parses with its DTD. The default
108  is false.
109 
110  @return flag True to turn on validation, false to turn it off.
111  */
112  static void validate_xml(bool flag);
113 
114 private:
115  init(const init&);
116  init& operator=(const init&);
117 
118  void init_library();
119  void shutdown_library();
120 
121  static int ms_counter;
122 };
123 
124 } // namespace xml
125 
126 // use a "nifty counter" to ensure that any source file that uses xmlwrapp
127 // will initialize the library prior to its first use
128 namespace
129 {
130  xml::init g_xmlwrapp_initializer;
131 }
132 
133 #endif // _xmlwrapp_init_h_
The xml::init class is used to configure the XML parser.
Definition: init.h:63
XML library namespace.
Definition: attributes.h:51