LHEF  3.0(beta)
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
LHEF::XMLTag Struct Reference

The XMLTag struct is used to represent all information within an XML tag. More...

#include <LHEF.h>

Public Types

typedef std::string::size_type pos_t
 Convenient typdef.
 
typedef std::map< std::string,
std::string > 
AttributeMap
 Convenient typdef.
 

Public Member Functions

 XMLTag ()
 Default constructor.
 
 ~XMLTag ()
 The destructor also destroys any sub-tags.
 
bool getattr (std::string n, double &v) const
 Find an attribute named n and set the double variable v to the corresponding value.
 
bool getattr (std::string n, bool &v) const
 Find an attribute named n and set the bool variable v to true if the corresponding value is "yes".
 
bool getattr (std::string n, long &v) const
 Find an attribute named n and set the long variable v to the corresponding value.
 
bool getattr (std::string n, int &v) const
 Find an attribute named n and set the long variable v to the corresponding value.
 
bool getattr (std::string n, std::string &v) const
 Find an attribute named n and set the string variable v to the corresponding value.
 
void print (std::ostream &os) const
 Print out this tag to a stream.
 

Static Public Member Functions

static std::vector< XMLTag * > findXMLTags (std::string str, std::string *leftover=0)
 Scan the given string and return all XML tags found as a vector of pointers to XMLTag objects.
 
static void deleteAll (std::vector< XMLTag * > &tags)
 Delete all tags in a vector.
 

Public Attributes

std::string name
 The name of this tag.
 
AttributeMap attr
 The attributes of this tag.
 
std::vector< XMLTag * > tags
 A vector of sub-tags.
 
std::string contents
 The contents of this tag.
 

Static Public Attributes

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

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.

Definition at line 77 of file LHEF.h.

Member Function Documentation

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

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

Text which does not belong to any tag is stored in tags without name and in the string pointed to by leftover (if not null).

Definition at line 188 of file LHEF.h.

References end, name, tags, and XMLTag().

Referenced by LHEF::Reader::init(), and LHEF::Reader::readEvent().

bool LHEF::XMLTag::getattr ( std::string  n,
double &  v 
) const
inline

Find an attribute named n and set the double variable v to the corresponding value.

Returns
false if no attribute was found.

Definition at line 130 of file LHEF.h.

References attr.

Referenced by LHEF::Cut::Cut().

bool LHEF::XMLTag::getattr ( std::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".

Returns
false if no attribute was found.

Definition at line 142 of file LHEF.h.

References attr.

bool LHEF::XMLTag::getattr ( std::string  n,
long &  v 
) const
inline

Find an attribute named n and set the long variable v to the corresponding value.

Returns
false if no attribute was found.

Definition at line 153 of file LHEF.h.

References attr.

bool LHEF::XMLTag::getattr ( std::string  n,
int &  v 
) const
inline

Find an attribute named n and set the long variable v to the corresponding value.

Returns
false if no attribute was found.

Definition at line 164 of file LHEF.h.

References attr.

bool LHEF::XMLTag::getattr ( std::string  n,
std::string &  v 
) const
inline

Find an attribute named n and set the string variable v to the corresponding value.

Returns
false if no attribute was found.

Definition at line 175 of file LHEF.h.

References attr.


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