QDP++
QDP::XMLReader Class Reference

XML reader class. More...

#include <qdp_xmlio.h>

Inheritance diagram for QDP::XMLReader:

Public Member Functions

 XMLReader ()
 Empty constructor.
 XMLReader (const std::string &filename)
 Construct from contents of file.
 XMLReader (std::istream &is)
 Construct from contents of stream.
 XMLReader (const XMLBufferWriter &mw)
 Construct from contents of a XMLBufferWriter.
 XMLReader (XMLReader &old, const std::string &xpath)
 Clone a reader but with a possibly different path.
 ~XMLReader ()
void open (const std::string &filename)
 Opens and reads an XML file.
void open (std::istream &is)
 Opens and reads an XML file.
void open (const XMLBufferWriter &mw)
 Reads content of a XMLBufferWriter.
bool is_open ()
 Queries whether the binary file is open.
bool is_derived () const
 Queries whether the XML data has been obtained from another XMLReader.
void close ()
 Closes the last file opened.
void get (const std::string &xpath, std::string &result)
 Xpath query.
void get (const std::string &xpath, int &result)
 Xpath query.
void get (const std::string &xpath, unsigned int &result)
 Xpath query.
void get (const std::string &xpath, short int &result)
 Xpath query.
void get (const std::string &xpath, unsigned short int &result)
 Xpath query.
void get (const std::string &xpath, long int &result)
 Xpath query.
void get (const std::string &xpath, unsigned long int &result)
 Xpath query.
void get (const std::string &xpath, float &result)
 Xpath query.
void get (const std::string &xpath, double &result)
 Xpath query.
void get (const std::string &xpath, bool &result)
 Xpath query.
void getAttribute (const std::string &xpath, const std::string &attrib_name, int &result)
 read integer attributes so that I can read Matrices in XML
template<typename T>
void set (const std::string &xpath, const T &to_set)
 Set a replacement of a primitive.
void print (std::ostream &is)
 Return the entire contents of the Reader as a stream.
void printCurrentContext (std::ostream &is)
 Print the current context.
int count (const std::string &xpath)
 Count the number of occurances from the Xpath query.
void registerNamespace (const std::string &prefix, const std::string &uri)

Protected Member Functions

template<typename T>
void readPrimitive (const std::string &xpath, T &output)
template<typename T>
void readAttrPrimitive (const std::string &xpath, const std::string &attrib_name, T &result)

Detailed Description

XML reader class.

This is used to read data from an XML file using Xpath.

Note that only the primary node opens and reads XML files. Results from Xpath queries are broadcast to all nodes.

Definition at line 43 of file qdp_xmlio.h.

Constructor & Destructor Documentation

◆ XMLReader() [1/5]

QDP::XMLReader::XMLReader ( )

Empty constructor.

Definition at line 17 of file qdp_xmlio.cc.

Referenced by XMLReader().

◆ XMLReader() [2/5]

QDP::XMLReader::XMLReader ( const std::string & filename)

Construct from contents of file.

Opens and reads an XML file.

Parameters
filenameThe name of the file.

Definition at line 19 of file qdp_xmlio.cc.

References open().

◆ XMLReader() [3/5]

QDP::XMLReader::XMLReader ( std::istream & is)

Construct from contents of stream.

Definition at line 25 of file qdp_xmlio.cc.

References open().

◆ XMLReader() [4/5]

QDP::XMLReader::XMLReader ( const XMLBufferWriter & mw)

Construct from contents of a XMLBufferWriter.

Definition at line 31 of file qdp_xmlio.cc.

References open().

◆ XMLReader() [5/5]

QDP::XMLReader::XMLReader ( XMLReader & old,
const std::string & xpath )

Clone a reader but with a possibly different path.

Definition at line 37 of file qdp_xmlio.cc.

References open(), and XMLReader().

◆ ~XMLReader()

QDP::XMLReader::~XMLReader ( )

Definition at line 125 of file qdp_xmlio.cc.

References close().

Member Function Documentation

◆ close()

void QDP::XMLReader::close ( )

Closes the last file opened.

Definition at line 107 of file qdp_xmlio.cc.

References is_open(), and QDP::Layout::primaryNode().

Referenced by QDP::read(), QDP::read(), QDP::read(), QDP::read(), and ~XMLReader().

◆ count()

int QDP::XMLReader::count ( const std::string & xpath)

Count the number of occurances from the Xpath query.

Definition at line 242 of file qdp_xmlio.cc.

References QDP::QDPInternal::broadcast(), and QDP::Layout::primaryNode().

Referenced by QDP::read(), QDP::read(), QDP::read(), QDP::read(), and QDP::read().

◆ get() [1/10]

void QDP::XMLReader::get ( const std::string & xpath,
bool & result )

Xpath query.

Definition at line 171 of file qdp_xmlio.cc.

References readPrimitive().

◆ get() [2/10]

void QDP::XMLReader::get ( const std::string & xpath,
double & result )

Xpath query.

Definition at line 167 of file qdp_xmlio.cc.

References readPrimitive().

◆ get() [3/10]

void QDP::XMLReader::get ( const std::string & xpath,
float & result )

Xpath query.

Definition at line 163 of file qdp_xmlio.cc.

References readPrimitive().

◆ get() [4/10]

void QDP::XMLReader::get ( const std::string & xpath,
int & result )

Xpath query.

Definition at line 139 of file qdp_xmlio.cc.

References readPrimitive().

◆ get() [5/10]

void QDP::XMLReader::get ( const std::string & xpath,
long int & result )

Xpath query.

Definition at line 155 of file qdp_xmlio.cc.

References readPrimitive().

◆ get() [6/10]

void QDP::XMLReader::get ( const std::string & xpath,
short int & result )

Xpath query.

Definition at line 147 of file qdp_xmlio.cc.

References readPrimitive().

◆ get() [7/10]

void QDP::XMLReader::get ( const std::string & xpath,
std::string & result )

◆ get() [8/10]

void QDP::XMLReader::get ( const std::string & xpath,
unsigned int & result )

Xpath query.

Definition at line 143 of file qdp_xmlio.cc.

References readPrimitive().

◆ get() [9/10]

void QDP::XMLReader::get ( const std::string & xpath,
unsigned long int & result )

Xpath query.

Definition at line 159 of file qdp_xmlio.cc.

References readPrimitive().

◆ get() [10/10]

void QDP::XMLReader::get ( const std::string & xpath,
unsigned short int & result )

Xpath query.

Definition at line 151 of file qdp_xmlio.cc.

References readPrimitive().

◆ getAttribute()

void QDP::XMLReader::getAttribute ( const std::string & xpath,
const std::string & attrib_name,
int & result )

read integer attributes so that I can read Matrices in XML

Definition at line 176 of file qdp_xmlio.cc.

References readAttrPrimitive().

◆ is_derived()

bool QDP::XMLReader::is_derived ( ) const

Queries whether the XML data has been obtained from another XMLReader.

A private method allows this XMLReader to be copy the contents of another.

Definition at line 123 of file qdp_xmlio.cc.

Referenced by printCurrentContext().

◆ is_open()

bool QDP::XMLReader::is_open ( )

Queries whether the binary file is open.

Returns
true if the binary file is open; false otherwise.

Definition at line 121 of file qdp_xmlio.cc.

Referenced by close().

◆ open() [1/3]

void QDP::XMLReader::open ( const std::string & filename)

Opens and reads an XML file.

Parameters
filenameThe name of the file
Postcondition
Any previously opened file is closed.

Definition at line 45 of file qdp_xmlio.cc.

References QDP::QDPIO::cerr, QDP::Layout::primaryNode(), and QDP::QDP_abort().

Referenced by QDP::QDPFileReader::open(), QDP::QDPFileReader::read(), QDP::QDPFileReader::read(), QDP::QDPFileReader::read(), QDP::QDPFileReader::read(), QDP::QDPFileReader::read(), QDP::QDPFileReader::read(), QDP::readArchiv(), XMLReader(), XMLReader(), XMLReader(), and XMLReader().

◆ open() [2/3]

void QDP::XMLReader::open ( const XMLBufferWriter & mw)

Reads content of a XMLBufferWriter.

Definition at line 84 of file qdp_xmlio.cc.

References QDP::Layout::primaryNode().

◆ open() [3/3]

void QDP::XMLReader::open ( std::istream & is)

Opens and reads an XML file.

Parameters
idThe input stream of the file
Postcondition
Any previously opened file is closed

Definition at line 75 of file qdp_xmlio.cc.

References QDP::Layout::primaryNode().

◆ print()

void QDP::XMLReader::print ( std::ostream & is)

Return the entire contents of the Reader as a stream.

Definition at line 206 of file qdp_xmlio.cc.

References QDP::QDPInternal::broadcast_str(), and QDP::Layout::primaryNode().

◆ printCurrentContext()

void QDP::XMLReader::printCurrentContext ( std::ostream & is)

Print the current context.

Definition at line 222 of file qdp_xmlio.cc.

References QDP::QDPInternal::broadcast_str(), is_derived(), and QDP::Layout::primaryNode().

◆ readAttrPrimitive()

template<typename T>
void QDP::XMLReader::readAttrPrimitive ( const std::string & xpath,
const std::string & attrib_name,
T & result )
protected

Definition at line 194 of file qdp_xmlio.cc.

References QDP::QDPInternal::broadcast(), and QDP::Layout::primaryNode().

Referenced by getAttribute().

◆ readPrimitive()

template<typename T>
void QDP::XMLReader::readPrimitive ( const std::string & xpath,
T & output )
protected

Definition at line 183 of file qdp_xmlio.cc.

References QDP::QDPInternal::broadcast(), and QDP::Layout::primaryNode().

Referenced by get(), get(), get(), get(), get(), get(), get(), get(), and get().

◆ registerNamespace()

void QDP::XMLReader::registerNamespace ( const std::string & prefix,
const std::string & uri )

Definition at line 254 of file qdp_xmlio.cc.

References QDP::Layout::primaryNode().

◆ set()

template<typename T>
void QDP::XMLReader::set ( const std::string & xpath,
const T & to_set )
inline

Set a replacement of a primitive.

Definition at line 130 of file qdp_xmlio.h.

References QDP::Layout::primaryNode().


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