NCBI C++ ToolKit
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
xml::init Class Reference

Search Toolkit Book for xml::init

The xml::init class is used to configure the XML parser. More...

#include <misc/xmlwrapp/xml_init.hpp>

+ Inheritance diagram for xml::init:

Public Member Functions

 init (void)
 
virtual ~init (void)
 

Static Public Member Functions

static void indent_output (bool flag)
 This member function controls whether or not the XML parser should add text nodes for indenting when generating XML text output from a node tree. More...
 
static void remove_whitespace (bool flag)
 This member function controls whether or not the XML parser should remove ignorable whitespace around XML elements. More...
 
static bool get_remove_whitespace (void)
 This member function provides the current setting of the XML parser which tells whether it should remove ignorable whitespace around XML elements. More...
 
static void substitute_entities (bool flag)
 This member function controls whether or not the XML parser should substitute entities while parsing. More...
 
static void load_external_subsets (bool flag)
 This member function controls whether or not the XML parser should load external (DTD) subsets while parsing. More...
 
static void validate_xml (bool flag)
 This member function controls whether or not the XML parser should validate every XML document that is parses with its DTD. More...
 
static void library_cleanup_on_exit (bool flag)
 This member function controls whether or not the libxml2 library data will be cleaned up at exit. More...
 

Private Member Functions

 init (const init &)
 
initoperator= (const init &)
 
void init_library ()
 
void shutdown_library ()
 

Static Private Attributes

static int ms_counter = 0
 
static bool do_cleanup_at_exit = true
 

Detailed Description

The xml::init class is used to configure the XML parser.

If you want to use and of the xml::init member functions, do so before you start any threads or use any other part of xmlwrapp. The member functions may alter global and/or static variables and affect the behavior of subsequently created classes (and the parser in particular). In other words, this class is not thread safe.

Note
In xmlwrapp versions prior to 0.6.0, this class was used to initialize the library and exactly one instance had to be created before first use. This is no longer true: user code doesn't have to create any instances, but it can create as many instances as it wants.

Definition at line 64 of file xml_init.hpp.

Constructor & Destructor Documentation

◆ init() [1/2]

xml::init::init ( void  )

Definition at line 62 of file xml_init.cpp.

References init_library(), and ms_counter.

◆ ~init()

xml::init::~init ( void  )
virtual

Reimplemented in xslt::init.

Definition at line 67 of file xml_init.cpp.

◆ init() [2/2]

xml::init::init ( const init )
private

Member Function Documentation

◆ get_remove_whitespace()

bool xml::init::get_remove_whitespace ( void  )
static

This member function provides the current setting of the XML parser which tells whether it should remove ignorable whitespace around XML elements.

Returns
True if the parser will remove whitespace, false to leave alone.
See also
xml::init::remove_whitespace()

Definition at line 106 of file xml_init.cpp.

◆ indent_output()

void xml::init::indent_output ( bool  flag)
static

This member function controls whether or not the XML parser should add text nodes for indenting when generating XML text output from a node tree.

The default is true.

Parameters
flagTrue to turn on indenting, false to turn it off.
Author
Peter Jones

Definition at line 98 of file xml_init.cpp.

◆ init_library()

void xml::init::init_library ( )
private

Definition at line 72 of file xml_init.cpp.

References xml::impl::cleanup_node(), and xml::impl::register_https_input().

Referenced by init().

◆ library_cleanup_on_exit()

void xml::init::library_cleanup_on_exit ( bool  flag)
static

This member function controls whether or not the libxml2 library data will be cleaned up at exit.

The default is true.

Note
By default the library clears all the libxml2 data at exit. However it is possible that some parts of an application interact with libxml2 directly and might call the libxml2 library cleanup too. In mutithreaded applications double cleaning of the libxml2 data may lead to a crash. This member provides a workaround for the cases when multiple parties cleanup libxml2 data at exit in multithreaded applications. It is supposed that at the beginning of the application there is a call similar to the following: xml::init::library_cleanup_on_exit(false); and it is the application responsibility to make sure that XmlWrapp finishes data handling before the other part of the application calls xmlCleanupParser().
Parameters
flagTrue to turn on libxml2 cleanup at exit, false to turn it off.
Author
Denis Vakatov

Definition at line 122 of file xml_init.cpp.

◆ load_external_subsets()

void xml::init::load_external_subsets ( bool  flag)
static

This member function controls whether or not the XML parser should load external (DTD) subsets while parsing.

This will only affect the loading of the subsets, it does not cause files to be validated. The default is true.

Parameters
flagTrue to turn on loading, false to turn it off.
Author
Peter Jones

Definition at line 114 of file xml_init.cpp.

◆ operator=()

init& xml::init::operator= ( const init )
private

◆ remove_whitespace()

void xml::init::remove_whitespace ( bool  flag)
static

This member function controls whether or not the XML parser should remove ignorable whitespace around XML elements.

The default is false. The setting is per thread.

Parameters
flagTrue to remove whitespace, false to leave alone.
See also
xml::init::get_remove_whitespace()
Author
Peter Jones

Definition at line 102 of file xml_init.cpp.

◆ shutdown_library()

void xml::init::shutdown_library ( )
private

Definition at line 93 of file xml_init.cpp.

◆ substitute_entities()

void xml::init::substitute_entities ( bool  flag)
static

This member function controls whether or not the XML parser should substitute entities while parsing.

The default is true.

Note
see the xml::event_parser::text(...) and xml::event_parser::entity_reference(...) callback notes as they are affected by this flag.
Parameters
flagTrue to turn on substitution, false to turn off.
Author
Peter Jones

Definition at line 110 of file xml_init.cpp.

◆ validate_xml()

void xml::init::validate_xml ( bool  flag)
static

This member function controls whether or not the XML parser should validate every XML document that is parses with its DTD.

The default is false.

Parameters
flagTrue to turn on validation, false to turn it off.
Author
Peter Jones

Definition at line 118 of file xml_init.cpp.

Member Data Documentation

◆ do_cleanup_at_exit

bool xml::init::do_cleanup_at_exit = true
staticprivate

Definition at line 180 of file xml_init.hpp.

◆ ms_counter

int xml::init::ms_counter = 0
staticprivate

Definition at line 179 of file xml_init.hpp.

Referenced by init().


The documentation for this class was generated from the following files:
Modified on Wed May 29 18:37:17 2024 by modify_doxy.py rev. 669887