PSCF v1.1
Public Member Functions | List of all members
Util::XmlStartTag Class Reference

Parser for an XML start tag. More...

#include <XmlStartTag.h>

Inheritance diagram for Util::XmlStartTag:
Util::XmlBase

Public Member Functions

 XmlStartTag ()
 Constructor. More...
 
 ~XmlStartTag ()
 Destructor. More...
 
bool matchLabel (const std::string &string, int begin)
 Match opening bracket and any label. More...
 
void matchLabel (const std::string expected, const std::string &string, int begin)
 Match opening bracket and a specific required label. More...
 
bool matchAttribute (XmlAttribute &attribute)
 Attempt to match an attribute. More...
 
void finish ()
 Check if end bracket was found. More...
 
const std::string label ()
 Label string. More...
 
bool endBracket ()
 True if a closing bracket was found. More...
 
- Public Member Functions inherited from Util::XmlBase
 XmlBase ()
 Constructor. More...
 
 ~XmlBase ()
 Destructor. More...
 
void setString (const std::string &string, int cursor=0)
 Initialize string and cursor. More...
 
void setCursor (int cursor)
 Set cursor. More...
 
void skip ()
 Skip leading white space, if any. More...
 
void next ()
 Advance to the next character. More...
 
const std::string & string () const
 Return the associated string. More...
 
int cursor () const
 Return the index of the current character. More...
 
int c () const
 Return the current character. More...
 
bool isEnd () const
 Has the cursor reached the end of the string? More...
 

Detailed Description

Parser for an XML start tag.

Usage:

XmlAttribute attribute;
std::string line;
tag.matchLabel(line, 0);
while (matchAttribute(attribute)) {
// process attribute;
}
tag.finish();
Parser for an XML attribute.
Definition: XmlAttribute.h:24
Parser for an XML start tag.
Definition: XmlStartTag.h:37
bool matchAttribute(XmlAttribute &attribute)
Attempt to match an attribute.
Definition: XmlStartTag.cpp:71
bool matchLabel(const std::string &string, int begin)
Match opening bracket and any label.
Definition: XmlStartTag.cpp:21
void finish()
Check if end bracket was found.
Definition: XmlStartTag.cpp:93

Definition at line 36 of file XmlStartTag.h.

Constructor & Destructor Documentation

◆ XmlStartTag()

Util::XmlStartTag::XmlStartTag ( )

Constructor.

Definition at line 14 of file XmlStartTag.cpp.

◆ ~XmlStartTag()

Util::XmlStartTag::~XmlStartTag ( )

Destructor.

Definition at line 18 of file XmlStartTag.cpp.

Member Function Documentation

◆ matchLabel() [1/2]

bool Util::XmlStartTag::matchLabel ( const std::string &  string,
int  begin 
)

Match opening bracket and any label.

Parameters
stringcontaining text of XML tag
beginindex of first character
Returns
true if match, false otherwise

Definition at line 21 of file XmlStartTag.cpp.

References Util::XmlBase::c(), Util::XmlBase::cursor(), Util::XmlBase::isEnd(), Util::XmlBase::next(), Util::XmlBase::setString(), Util::XmlBase::skip(), and Util::XmlBase::string().

Referenced by matchLabel().

◆ matchLabel() [2/2]

void Util::XmlStartTag::matchLabel ( const std::string  expected,
const std::string &  string,
int  begin 
)

Match opening bracket and a specific required label.

Throws exception if no match.

Parameters
expectedexpected label string
stringcontaining text of XML tag
beginindex of first character

Definition at line 58 of file XmlStartTag.cpp.

References Util::Log::file(), label(), matchLabel(), and UTIL_THROW.

◆ matchAttribute()

bool Util::XmlStartTag::matchAttribute ( XmlAttribute attribute)

Attempt to match an attribute.

Parameters
attributeon return, matched attribute, if any
Returns
true if an attribute is found, false otherwise

Definition at line 71 of file XmlStartTag.cpp.

References Util::XmlBase::c(), Util::XmlBase::isEnd(), Util::XmlAttribute::match(), Util::XmlBase::next(), and Util::XmlBase::skip().

◆ finish()

void Util::XmlStartTag::finish ( )

Check if end bracket was found.

Throws exception if no end bracket was found.

Definition at line 93 of file XmlStartTag.cpp.

References endBracket(), Util::Log::file(), Util::XmlBase::string(), and UTIL_THROW.

◆ label()

const std::string Util::XmlStartTag::label ( )
inline

◆ endBracket()

bool Util::XmlStartTag::endBracket ( )
inline

True if a closing bracket was found.

Definition at line 96 of file XmlStartTag.h.

Referenced by finish().


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