PYTHIA  8.312
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
XMLTag Struct Reference

#include <LHEF3.h>

Public Types

typedef string::size_type pos_t
 Convenient typdef.
 

Public Member Functions

 ~XMLTag ()
 The destructor also destroys any sub-tags.
 
bool getattr (string n, double &v) const
 
bool getattr (string n, bool &v) const
 
bool getattr (string n, long &v) const
 
bool getattr (string n, int &v) const
 
bool getattr (string n, string &v) const
 
void list (ostream &os) const
 Print out this tag to a stream.
 

Static Public Member Functions

static vector< XMLTag * > findXMLTags (string str, string *leftover=0)
 

Public Attributes

string name
 The name of this tag.
 
map< string, string > attr
 The attributes of this tag.
 
vector< XMLTag * > tags
 A vector of sub-tags.
 
string contents
 The contents of this tag.
 

Static Public Attributes

static const pos_t end = string::npos
 Convenient alias for npos. More...
 

Detailed Description

The XMLTag struct is used to represent all information within an XML tag. It contains the attributes as a map, any sub-tags as a vector of pointers to other XMLTag objects, and any other information as a single string. The XMLTag struct written by Leif Lonnblad.

Member Function Documentation

static vector<XMLTag*> findXMLTags ( string  str,
string *  leftover = 0 
)
inlinestatic

Scan the given string and return all XML tags found as a vector of pointers to XMLTag objects.

Find the first tag.

Skip tags in lines beginning with #.

Logic: Last newline before begin was before last pound sign (or there was no last newline at all, i.e. this is the special case of the first line), and hence the pound sign was before the tag was opened (at begin) with '<'. Thus, skip forward to next new line.

Skip xml-style comments.

Also skip CDATA statements. Used for text data that should not be parsed by the XML parser. (e.g., JavaScript code contains a lot of "<" or "&" characters which XML would erroneously interpret as the start of a new element or the start of a character entity, respectively.) See eg http:///www.w3schools.com/xml/xml_cdata.asp

Find the tag name.

Now skip some white space to see if we can find an attribute.

OK now find the beginning and end of the atribute.

bool getattr ( string  n,
double &  v 
) const
inline

Find an attribute named n and set the double variable v to the corresponding value. Return false if no attribute was found.

bool getattr ( string  n,
bool &  v 
) const
inline

Find an attribute named n and set the bool variable v to true if the corresponding value is "yes". Return false if no attribute was found.

bool getattr ( string  n,
long &  v 
) const
inline

Find an attribute named n and set the long variable v to the corresponding value. Return false if no attribute was found.

bool getattr ( string  n,
int &  v 
) const
inline

Find an attribute named n and set the long variable v to the corresponding value. Return false if no attribute was found.

bool getattr ( string  n,
string &  v 
) const
inline

Find an attribute named n and set the string variable v to the corresponding value. Return false if no attribute was found.

Member Data Documentation

const XMLTag::pos_t end = string::npos
static

Convenient alias for npos.

Constants.

The XMLTag struct is used to represent all information within an XML tag. It contains the attributes as a map, any sub-tags as a vector of pointers to other XMLTag objects, and any other information as a single string.


The documentation for this struct was generated from the following files: