HepMC3 event record library: XMLTag Struct Reference

HepMC3 event record library

Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
XMLTag Struct Reference

## 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 89 of file LHEF.h.

`#include <LHEF.h>`

Collaboration diagram for XMLTag:
[legend]

## Public Types
typedef std::string::size_type | pos_t
typedef std::map< std::string, std::string > | AttributeMap

## Public Member Functions
| XMLTag ()
| ~XMLTag ()
bool | getattr (const std::string &n, double &v) const
bool | getattr (const std::string &n, bool &v) const
bool | getattr (const std::string &n, long &v) const
bool | getattr (const std::string &n, int &v) const
bool | getattr (const std::string &n, std::string &v) const
void | print (std::ostream &os) const

## Static Public Member Functions
static std::vector< XMLTag * > | findXMLTags (std::string str, std::string *leftover=nullptr)
static void | deleteAll (std::vector< XMLTag * > &tags)

## Data Fields
std::string | name
AttributeMap | attr
std::vector< XMLTag * > | tags
std::string | contents

## Static Public Attributes
static const pos_t | end = std::string::npos

## Member Typedef Documentation

## ◆ AttributeMap

typedef std::map<std::string,std::string> AttributeMap

Convenient typdef.

Definition at line 99 of file LHEF.h.

## ◆ pos_t

typedef std::string::size_type pos_t

Convenient typdef.

Definition at line 94 of file LHEF.h.

## Constructor & Destructor Documentation

## ◆ XMLTag()

XMLTag | ( |  | ) |
| inline

Default constructor.

Definition at line 109 of file LHEF.h.

## ◆ ~XMLTag()

~XMLTag | ( |  | ) |
| inline

The destructor also destroys any sub-tags.

Definition at line 114 of file LHEF.h.

References tags.

## Member Function Documentation

## ◆ deleteAll()

void deleteAll | ( | std::vector< XMLTag * > & | tags | ) |
| inlinestatic

Delete all tags in a vector.

Definition at line 310 of file LHEF.h.

References tags.

## ◆ findXMLTags()

std::vector< XMLTag * > findXMLTags | ( | std::string | str,
|  | std::string * | leftover = nullptr )
| 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).

Examples
  LHEF_example_cat.cc.

Definition at line 200 of file LHEF.h.

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

## ◆ getattr() [1/5]

bool getattr | ( | const 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 154 of file LHEF.h.

References attr.

## ◆ getattr() [2/5]

bool getattr | ( | const 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 142 of file LHEF.h.

References attr.

## ◆ getattr() [3/5]

bool getattr | ( | const 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 176 of file LHEF.h.

References attr.

## ◆ getattr() [4/5]

bool getattr | ( | const 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 165 of file LHEF.h.

References attr.

## ◆ getattr() [5/5]

bool getattr | ( | const 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 187 of file LHEF.h.

References attr.

## ◆ print()

void print | ( | std::ostream & | os | ) | const
| inline

Print out this tag to a stream.

Definition at line 319 of file LHEF.h.

References attr, contents, name, LHEF::oattr(), and tags.

## Field Documentation

## ◆ attr

AttributeMap attr

The attributes of this tag.

Definition at line 126 of file LHEF.h.

## ◆ contents

std::string contents

The contents of this tag.

Definition at line 136 of file LHEF.h.

## ◆ end

const pos_t end = std::string::npos
| static

Convenient alias for npos.

Definition at line 104 of file LHEF.h.

## ◆ name

std::string name

The name of this tag.

Definition at line 121 of file LHEF.h.

## ◆ tags

std::vector<XMLTag*> tags

A vector of sub-tags.

Definition at line 131 of file LHEF.h.

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

- LHEF.h