fix8
version 1.4.0
Open Source C++ FIX Framework
|
A simple xml parser with Xpath style lookup. More...
#include <xml.hpp>
Classes | |
struct | EntityOrderComp |
Comparitor. More... | |
Public Types | |
enum | Flags { noextensions, nocase } |
using | XmlSet = std::set< const XmlElement *, EntityOrderComp > |
using | XmlAttrs = std::map< std::string, std::string > |
using | XmlFlags = FIX8::ebitset< Flags > |
Public Member Functions | |
F8API | XmlElement (std::istream &ifs, int subidx, XmlElement *parent=nullptr, int txtline=0, int depth=0, const char *rootAttr=nullptr) |
virtual F8API | ~XmlElement () |
Dtor. More... | |
XmlElement (const XmlElement &)=delete | |
Copy Ctor. Non-copyable. More... | |
XmlElement & | operator= (const XmlElement &)=delete |
Assignment operator. Non-copyable. More... | |
F8API int | ParseAttrs (const std::string &attlst) |
F8API const XmlElement * | find (const std::string &what, const std::string *atag=nullptr, const std::string *aval=nullptr, const char delim='/') const |
F8API int | find (const std::string &what, XmlSet &eset, const std::string *atag=nullptr, const std::string *aval=nullptr, const char delim='/') const |
F8API const XmlElement * | find_child (const std::string &what, const std::string *atag=nullptr, const std::string *aval=nullptr, const char delim='/') const |
F8API int | find_child (const std::string &what, XmlSet &eset, const std::string *atag=nullptr, const std::string *aval=nullptr, const char delim='/') const |
F8API bool | GetAttr (const std::string &what, std::string &target) const |
bool | GetAttrValue (std::string &target) const |
bool | HasAttr (const std::string &what) const |
bool | FindAttrGetValue (const std::string &what, std::string &target) |
F8API bool | findAttrByValue (const std::string &what, const std::string &value) const |
template<typename T > | |
T | FindAttr (const std::string &what, const T defValue) const |
template<typename T > | |
T & | FindAttrRef (const std::string &what, T &target) const |
F8API bool | Insert (XmlElement *what) |
F8API const std::string & | InplaceXlate (std::string &what) |
int | GetDepth () const |
int | GetErrorCnt () const |
int | GetLineCnt () const |
int | GetChildCnt () const |
int | GetLine () const |
int | GetSubIdx () const |
int | GetSequence () const |
int | GetMaxDepthPermitted () const |
int | GetMaxDepth () const |
std::string | GetPath () const |
const std::string & | GetTag () const |
std::string | GetLocString () const |
const std::string * | GetVal () const |
const std::string * | GetDecl () const |
XmlAttrs::const_iterator | abegin () const |
XmlAttrs::const_iterator | aend () const |
XmlSet::const_iterator | begin () const |
XmlSet::const_iterator | end () const |
const XmlElement * | GetRoot () const |
const XmlElement * | GetParent () const |
Static Public Member Functions | |
static void | set_flags (XmlFlags flags) |
static F8API XmlElement * | Factory (std::istream &istr, const char *docpath=nullptr) |
static F8API XmlElement * | Factory (const std::string &fname) |
Public Attributes | |
XmlAttrs * | attrs_ |
Static Public Attributes | |
static F8API const XmlAttrs | emptyattrs_ |
static XmlFlags | flags_ |
Private Types | |
enum | { MaxDepth = 128 } |
Maximum depth levels supported. More... | |
using | XmlSubEls = std::multimap< std::string, XmlElement * > |
Private Attributes | |
XmlElement * | parent_ |
XmlElement * | root_ |
int | errors_ |
int | line_ |
int | incline_ |
int | maxdepth_ |
int | seq_ |
std::string | inclusion_ |
std::string | tag_ |
std::string * | value_ |
std::string * | decl_ |
int | depth_ |
int | sequence_ |
int | txtline_ |
int | chldcnt_ |
int | subidx_ |
XmlSubEls * | children_ |
simple n-ary tree More... | |
bool | _was_include |
XmlSet * | ordchildren_ |
Set of all child elements in file order. More... | |
Static Private Attributes | |
static const Str2Chr | stringtochar_ |
XML entity char lookup. More... | |
static FIX8::RegExp | rCE_ |
static FIX8::RegExp | rCX_ |
static FIX8::RegExp | rIn_ |
static FIX8::RegExp | rEn_ |
static FIX8::RegExp | rEv_ |
static F8API const XmlSet | emptyset_ |
Friends | |
F8API std::ostream & | operator<< (std::ostream &os, const XmlElement &en) |
using XmlElement::XmlAttrs = std::map<std::string, std::string> |
using XmlElement::XmlFlags = FIX8::ebitset<Flags> |
using XmlElement::XmlSet = std::set<const XmlElement *, EntityOrderComp> |
|
private |
|
private |
Maximum depth levels supported.
Enumerator | |
---|---|
MaxDepth |
Definition at line 54 of file xml.hpp.
enum XmlElement::Flags |
Enumerator | |
---|---|
noextensions | |
nocase |
Definition at line 79 of file xml.hpp.
F8API XmlElement::XmlElement | ( | std::istream & | ifs, |
int | subidx, | ||
XmlElement * | parent = nullptr , |
||
int | txtline = 0 , |
||
int | depth = 0 , |
||
const char * | rootAttr = nullptr |
||
) |
Ctor.
ifs | input file stream |
subidx | the subindex for this child |
parent | parent XmlElement element |
txtline | xml sourcefile line number |
depth | depth nesting level |
rootAttr | root attribute string |
|
virtual |
Dtor.
Definition at line 655 of file xml.cpp.
References _was_include, attrs_, children_, decl_, ordchildren_, and value_.
|
delete |
Copy Ctor. Non-copyable.
|
inline |
Get an iterator to the first child attribute.
Definition at line 324 of file xml.hpp.
Referenced by output_attributes().
|
inline |
Get an iterator to the last+1 child attribute.
Definition at line 328 of file xml.hpp.
Referenced by output_attributes().
|
inline |
Get an iterator to the first child element.
Definition at line 332 of file xml.hpp.
|
inline |
Get an iterator to the last+1 child element.
Definition at line 336 of file xml.hpp.
Referenced by FIX8::Configuration::find_element().
|
static |
Create a new root element (and recursively parse) from a given xml filename.
istr | an open std::istream of an xml document |
docpath | string providing info about the document or path |
Referenced by main().
|
static |
Create a new root element (and recursively parse) from a given xml istream.
fname | the xml filename |
F8API const XmlElement* XmlElement::find | ( | const std::string & | what, |
const std::string * | atag = nullptr , |
||
const std::string * | aval = nullptr , |
||
const char | delim = '/' |
||
) | const |
Find an element with a given name, attribute name and attribute value.
what | the name to search for |
atag | the attribute name |
aval | the attribute value |
delim | the Xpath delimiter |
Referenced by FIX8::Configuration::create_clients(), find_child(), FindAttrGetValue(), FIX8::Configuration::get_addresses(), load_fields(), load_fix_version(), FIX8::Configuration::load_map(), load_messages(), main(), precomp(), process(), and process_message_fields().
F8API int XmlElement::find | ( | const std::string & | what, |
XmlSet & | eset, | ||
const std::string * | atag = nullptr , |
||
const std::string * | aval = nullptr , |
||
const char | delim = '/' |
||
) | const |
Recursively find all elements with a given name, attribute name and attribute value.
what | the name to search for |
eset | target XmlSet to place results |
atag | the attribute name |
aval | the attribute value |
delim | the Xpath delimiter |
|
inline |
Find a child element with a given name, attribute name and attribute value. This version assumes the base of the search term already contains the current xpath tag and delimiter.
what | the name to search for |
atag | the attribute name |
aval | the attribute value |
delim | the Xpath delimiter |
Definition at line 144 of file xml.hpp.
References find().
|
inline |
Recursively find all child elements with a given name, attribute name and attribute value. This version assumes the base of the search term already contains the current xpath tag and delimiter.
what | the name to search for |
eset | target XmlSet to place results |
atag | the attribute name |
aval | the attribute value |
delim | the Xpath delimiter |
Definition at line 159 of file xml.hpp.
References find().
|
inline |
Find an attribute with the given name and return its typed value.
type | of target attribute |
what | attribute to find |
defValue | value to return if attribute was not found |
Definition at line 209 of file xml.hpp.
Referenced by FIX8::Configuration::create_persister(), FIX8::Configuration::create_schedule(), FIX8::Configuration::create_session_schedule(), FIX8::Configuration::find_or_default(), FIX8::Configuration::get_logname(), and FIX8::recover_line().
bool XmlElement::findAttrByValue | ( | const std::string & | what, |
const std::string & | value | ||
) | const |
|
inline |
Find an element and obtain the attribute's value with the name "value".
what | name to find |
target | where to place value |
Definition at line 191 of file xml.hpp.
References find(), and GetAttrValue().
|
inline |
Find an attribute with the given name and populate supplied target with its typed value.
type | of target attribute |
what | attribute to find |
target | location to return value |
Definition at line 227 of file xml.hpp.
Referenced by FIX8::Configuration::create_logger().
bool XmlElement::GetAttr | ( | const std::string & | what, |
std::string & | target | ||
) | const |
Find an attribute's with the given name.
what | attribute to find |
target | where to place value |
Definition at line 748 of file xml.cpp.
References attrs_.
Referenced by FIX8::Configuration::create_logger(), FIX8::Configuration::create_persister(), FIX8::Configuration::create_schedule(), FIX8::Configuration::create_session_schedule(), FIX8::Configuration::from_or_default(), FIX8::Configuration::get_logflags(), FIX8::Configuration::get_time_field(), and GetAttrValue().
|
inline |
Find an attribute's value with the name "value".
target | where to place value |
Definition at line 175 of file xml.hpp.
References GetAttr().
Referenced by FindAttrGetValue().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the source line of this element (element order).
Definition at line 268 of file xml.hpp.
References txtline_.
Referenced by output_attributes(), and FIX8::recover_line().
|
inline |
|
inline |
|
inline |
|
inline |
Get the maximum depth supported.
Definition at line 280 of file xml.hpp.
References MaxDepth.
|
inline |
|
inline |
|
inline |
|
inline |
Get the sequence number for this element (incremented for each new element).
Definition at line 276 of file xml.hpp.
References sequence_.
Referenced by XmlElement::EntityOrderComp::operator()().
|
inline |
|
inline |
|
inline |
|
inline |
Check if an attribute with the given name is present.
what | attribute to find |
Definition at line 184 of file xml.hpp.
Referenced by FIX8::Configuration::create_logger(), and FIX8::Configuration::find_or_default().
const string & XmlElement::InplaceXlate | ( | std::string & | what | ) |
Perform xml translation on the supplied string inplace. Translate predefined entities and numeric character references.
what | source string to translate |
Definition at line 764 of file xml.cpp.
References flags_, noextensions, rCE_, rCX_, rEn_, FIX8::RegExp::Replace(), rEv_, FIX8::RegExp::SearchString(), stringtochar_, and FIX8::RegExp::SubExpr().
bool XmlElement::Insert | ( | XmlElement * | what | ) |
Insert an element as a child of this element
what | elekent to insert |
Definition at line 523 of file xml.cpp.
References children_, chldcnt_, GetTag(), and ordchildren_.
Referenced by main().
|
delete |
Assignment operator. Non-copyable.
int XmlElement::ParseAttrs | ( | const std::string & | attlst | ) |
Parse the xml attributes from an element.
attlst | string of attributes |
Definition at line 542 of file xml.cpp.
References attrs_, errors_, flags_, incline_, inclusion_, line_, noextensions, and root_.
|
inlinestatic |
|
friend |
|
private |
Definition at line 88 of file xml.hpp.
Referenced by ~XmlElement().
XmlAttrs* XmlElement::attrs_ |
Definition at line 76 of file xml.hpp.
Referenced by findAttrByValue(), GetAttr(), operator<<(), ParseAttrs(), and ~XmlElement().
|
private |
simple n-ary tree
Definition at line 87 of file xml.hpp.
Referenced by Insert(), operator<<(), and ~XmlElement().
|
private |
Definition at line 63 of file xml.hpp.
Referenced by GetChildCnt(), and Insert().
|
private |
Definition at line 62 of file xml.hpp.
Referenced by GetDecl(), operator<<(), and ~XmlElement().
|
private |
Definition at line 63 of file xml.hpp.
Referenced by GetDepth(), and operator<<().
|
static |
|
staticprivate |
|
private |
Definition at line 59 of file xml.hpp.
Referenced by GetErrorCnt(), and ParseAttrs().
|
static |
Definition at line 81 of file xml.hpp.
Referenced by InplaceXlate(), and ParseAttrs().
|
private |
Definition at line 59 of file xml.hpp.
Referenced by ParseAttrs().
|
private |
Definition at line 60 of file xml.hpp.
Referenced by ParseAttrs().
|
private |
Definition at line 59 of file xml.hpp.
Referenced by GetLineCnt(), and ParseAttrs().
|
private |
Definition at line 59 of file xml.hpp.
Referenced by GetMaxDepth().
|
private |
Set of all child elements in file order.
Definition at line 91 of file xml.hpp.
Referenced by Insert(), operator<<(), and ~XmlElement().
|
private |
Definition at line 57 of file xml.hpp.
Referenced by GetParent().
|
staticprivate |
Definition at line 55 of file xml.hpp.
Referenced by InplaceXlate().
|
staticprivate |
Definition at line 55 of file xml.hpp.
Referenced by InplaceXlate().
|
staticprivate |
Definition at line 55 of file xml.hpp.
Referenced by InplaceXlate().
|
staticprivate |
Definition at line 55 of file xml.hpp.
Referenced by InplaceXlate().
|
private |
Definition at line 57 of file xml.hpp.
Referenced by GetRoot(), and ParseAttrs().
|
private |
Definition at line 63 of file xml.hpp.
Referenced by GetSequence().
|
staticprivate |
XML entity char lookup.
Definition at line 51 of file xml.hpp.
Referenced by InplaceXlate().
|
private |
Definition at line 63 of file xml.hpp.
Referenced by GetSubIdx().
|
private |
Definition at line 62 of file xml.hpp.
Referenced by GetPath(), GetTag(), and operator<<().
|
private |
Definition at line 63 of file xml.hpp.
Referenced by GetLine(), and operator<<().
|
private |
Definition at line 62 of file xml.hpp.
Referenced by GetVal(), operator<<(), and ~XmlElement().