QMCPACK
OhmmsElementBase Class Referenceabstract

Abstract class to provide xml-compatible I/O interfaces for the derived classes. More...

+ Inheritance diagram for OhmmsElementBase:
+ Collaboration diagram for OhmmsElementBase:

Public Types

enum  { useLIBXML = 0, useLIBXMLPP, usePLAIN }
 enumeration to choose the xml parser More...
 

Public Member Functions

 OhmmsElementBase (const char *aname="none")
 constructor with a name More...
 
virtual ~OhmmsElementBase ()
 destructor More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 set name More...
 
void setIOMode (int imode)
 set iomode More...
 
virtual bool get (std::ostream &) const =0
 write to a std::ostream More...
 
virtual bool put (std::istream &)=0
 read from std::istream More...
 
virtual bool put (xmlNodePtr cur)=0
 read from an xmlNode More...
 
virtual void reset ()=0
 reset member data More...
 
virtual bool add (xmlNodePtr parent)
 add a xmlNode to the children list of parent More...
 
void put (const std::string &s)
 read from string More...
 
virtual void begin_node (std::ostream &os) const
 write the start of a node More...
 
virtual void end_node (std::ostream &os) const
 write the end of a node More...
 

Protected Attributes

int myIOMode
 the type of IO mode: default is useLIBXML More...
 
std::string myName
 the name of the node, corresponds to the xml tag More...
 

Detailed Description

Abstract class to provide xml-compatible I/O interfaces for the derived classes.

Generic interfaces using std::iostream are much preferred. However, there isn't any pure c++ xml parser that is based on std::iostream alone. After evaluating several xml parsers, JK chose libxml (The XML C parser and toolkit of gnome, http://www.xmlsoft.org) based on its performance and availability on many platforms.

The base class is written to be able to handle DTD or Schema in future. Current implementation assumes that each OhmmsElementBase object handles a node and its child nodes. However, it does not specify how the derived classes hanlde the child nodes.

Definition at line 40 of file OhmmsElementBase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

enumeration to choose the xml parser

Enumerator
useLIBXML 

using libxml2 library

useLIBXMLPP 

using libxml++ library

usePLAIN 

using ascii parser

Definition at line 44 of file OhmmsElementBase.h.

45  {
46  useLIBXML = 0, /*!< using libxml2 library */
47  useLIBXMLPP, /*!< using libxml++ library */
48  usePLAIN /*!< using ascii parser */
49  };

Constructor & Destructor Documentation

◆ OhmmsElementBase()

OhmmsElementBase ( const char *  aname = "none")
inline

constructor with a name

Definition at line 52 of file OhmmsElementBase.h.

52 : myIOMode(useLIBXML), myName(aname) {}
std::string myName
the name of the node, corresponds to the xml tag
int myIOMode
the type of IO mode: default is useLIBXML

◆ ~OhmmsElementBase()

virtual ~OhmmsElementBase ( )
inlinevirtual

destructor

Definition at line 55 of file OhmmsElementBase.h.

55 {}

Member Function Documentation

◆ add()

virtual bool add ( xmlNodePtr  parent)
inlinevirtual

add a xmlNode to the children list of parent

Reimplemented in OhmmsParameter< bool >, and OhmmsParameter< T >.

Definition at line 79 of file OhmmsElementBase.h.

79 { return true; }

◆ begin_node()

virtual void begin_node ( std::ostream &  os) const
inlinevirtual

write the start of a node

Definition at line 89 of file OhmmsElementBase.h.

Referenced by XMLSaveParticle::get().

89 {}

◆ end_node()

virtual void end_node ( std::ostream &  os) const
inlinevirtual

write the end of a node

Definition at line 92 of file OhmmsElementBase.h.

Referenced by XMLSaveParticle::get().

92 {}

◆ get()

◆ getName()

◆ put() [1/3]

◆ put() [2/3]

◆ put() [3/3]

void put ( const std::string &  s)
inline

read from string

Definition at line 82 of file OhmmsElementBase.h.

References put(), and qmcplusplus::Units::time::s.

83  {
84  std::istringstream stream(s);
85  put(stream);
86  }
virtual bool put(std::istream &)=0
read from std::istream

◆ reset()

◆ setIOMode()

void setIOMode ( int  imode)
inline

set iomode

Definition at line 64 of file OhmmsElementBase.h.

References myIOMode.

64 { myIOMode = imode; }
int myIOMode
the type of IO mode: default is useLIBXML

◆ setName()

void setName ( const std::string &  aname)
inline

set name

Definition at line 61 of file OhmmsElementBase.h.

References myName.

Referenced by PWParameterSet::PWParameterSet().

61 { myName = aname; }
std::string myName
the name of the node, corresponds to the xml tag

Member Data Documentation

◆ myIOMode

int myIOMode
protected

the type of IO mode: default is useLIBXML

Definition at line 96 of file OhmmsElementBase.h.

Referenced by setIOMode().

◆ myName


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