QMCPACK
IOSectionClass Class Reference

Wrapper class for IOTreeClass that gives a nearly identical interface as the OutputSectionClass. More...

+ Collaboration diagram for IOSectionClass:

Public Member Functions

bool OpenFile (std::string fileName)
 Opens the file reference by fileName and reads the contents into the tree in CurrentSection. More...
 
std::string GetName ()
 
std::string GetFileName ()
 
std::string GetVarName (int num)
 
bool NewFile (std::string fileName)
 Creates a file at the top level, choosing the appropriate type based on the file extension. More...
 
void CloseFile ()
 Calls CurrentSections close file and then deletes the CurrentSection. More...
 
void FlushFile ()
 Flush all buffers to disk for safety. More...
 
bool OpenSection (std::string name, int num=0)
 Opens the num'th section with the given name. More...
 
bool OpenSection (int num)
 Opens the num'th section below CurrentSection. More...
 
bool IncludeSection (std::string name, std::string fileName)
 This mounts a file in the current tree under CurrentSection at the end of CurrentsSection's SectionList. More...
 
void NewSection (std::string name)
 Creates a new section of the same type as currentSection under currentSection. More...
 
bool NewSection (std::string name, std::string fileName)
 This function creates a new file of the appropriate type as determined by the extension of fileName and mounts it at the end of the list under CurrentSection. More...
 
void CloseSection ()
 Closes the current section. More...
 
template<class T >
bool ReadVar (std::string name, T &var)
 Template function which reads a variable in the present section into the passed-by-reference T variable. More...
 
template<class T >
bool ReadVar (std::string name, T &var, T Default)
 
template<typename T >
bool WriteVar (std::string name, T val)
 Writes a variable under the current section. More...
 
template<typename T , int RANK>
bool WriteVar (std::string name, const Array< T, RANK > &val)
 
template<class T >
bool AppendVar (std::string name, T val)
 
template<typename T , int RANK>
bool AppendVar (std::string name, const Array< T, RANK > &val)
 
IOVarBaseGetVarPtr (std::string name)
 
IOVarBaseGetVarPtr (int num)
 
void SetUnderscores (bool use)
 
int CountSections (std::string name="")
 Returns the number of subsections within the present section which have the name name. More...
 
int CountVars ()
 
void PrintTree ()
 Calls CurrentSections virtual PrintTree() function. More...
 
 IOSectionClass (IOSectionClass &io)
 
 IOSectionClass ()
 

Private Attributes

IOTreeClassCurrentSection
 

Detailed Description

Wrapper class for IOTreeClass that gives a nearly identical interface as the OutputSectionClass.

Definition at line 110 of file IO.h.

Constructor & Destructor Documentation

◆ IOSectionClass() [1/2]

IOSectionClass ( IOSectionClass io)
inline

Definition at line 223 of file IO.h.

References IOSectionClass::CurrentSection.

223 { CurrentSection = io.CurrentSection; }
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ IOSectionClass() [2/2]

IOSectionClass ( )
inline

Definition at line 225 of file IO.h.

References IOSectionClass::CurrentSection.

225 { CurrentSection = NULL; }
IOTreeClass * CurrentSection
Definition: IO.h:113

Member Function Documentation

◆ AppendVar() [1/2]

bool AppendVar ( std::string  name,
val 
)
inline

Definition at line 196 of file IO.h.

References IOTreeClass::AppendVar(), and IOSectionClass::CurrentSection.

197  {
198  return CurrentSection->AppendVar(name, val);
199  }
IOTreeClass * CurrentSection
Definition: IO.h:113
bool AppendVar(std::string name, T val)
Append a value to a variable of dimension of 1 higher than val.
Definition: IOBase.h:162

◆ AppendVar() [2/2]

bool AppendVar ( std::string  name,
const Array< T, RANK > &  val 
)
inline

Definition at line 202 of file IO.h.

References IOTreeClass::AppendVar(), and IOSectionClass::CurrentSection.

203  {
204  return CurrentSection->AppendVar(name, val);
205  }
IOTreeClass * CurrentSection
Definition: IO.h:113
bool AppendVar(std::string name, T val)
Append a value to a variable of dimension of 1 higher than val.
Definition: IOBase.h:162

◆ CloseFile()

void CloseFile ( )

Calls CurrentSections close file and then deletes the CurrentSection.

◆ CloseSection()

void CloseSection ( )

Closes the current section.

That is, CurrentSection becomes CurrentSection's parent.

Referenced by CubicSplineCommon::Read(), and CubicSplineCommon::Write().

◆ CountSections()

int CountSections ( std::string  name = "")
inline

Returns the number of subsections within the present section which have the name name.

If called without a name, it returns the total number of sections.

Definition at line 216 of file IO.h.

References IOTreeClass::CountSections(), and IOSectionClass::CurrentSection.

216 { return (CurrentSection->CountSections(name)); }
int CountSections(std::string name)
Returns the number of subsections with the given name within the present section. ...
Definition: IOBase.h:177
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ CountVars()

int CountVars ( )
inline

Definition at line 217 of file IO.h.

References IOTreeClass::CountVars(), and IOSectionClass::CurrentSection.

217 { return (CurrentSection->CountVars()); }
IOTreeClass * CurrentSection
Definition: IO.h:113
int CountVars()
Definition: IOBase.h:193

◆ FlushFile()

void FlushFile ( )

Flush all buffers to disk for safety.

◆ GetFileName()

std::string GetFileName ( )

◆ GetName()

std::string GetName ( )
inline

Definition at line 123 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::Name.

123 { return CurrentSection->Name; }
std::string Name
Definition: IOBase.h:56
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ GetVarName()

std::string GetVarName ( int  num)
inline

Definition at line 125 of file IO.h.

References IOVarBase::GetName(), and IOSectionClass::GetVarPtr().

125 { return GetVarPtr(num)->GetName(); }
IOVarBase * GetVarPtr(std::string name)
Definition: IO.h:207
std::string GetName() const
Definition: IOVarBase.h:75

◆ GetVarPtr() [1/2]

IOVarBase* GetVarPtr ( std::string  name)
inline

Definition at line 207 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::GetVarPtr().

Referenced by IOSectionClass::GetVarName().

207 { return (CurrentSection->GetVarPtr(name)); }
IOVarBase * GetVarPtr(std::string name)
Definition: IOBase.h:81
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ GetVarPtr() [2/2]

IOVarBase* GetVarPtr ( int  num)
inline

Definition at line 209 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::GetVarPtr().

209 { return (CurrentSection->GetVarPtr(num)); }
IOVarBase * GetVarPtr(std::string name)
Definition: IOBase.h:81
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ IncludeSection()

bool IncludeSection ( std::string  name,
std::string  fileName 
)

This mounts a file in the current tree under CurrentSection at the end of CurrentsSection's SectionList.

It does not change what CurrentSection points to, ie. it does not descend to the newly-opened section.

◆ NewFile()

bool NewFile ( std::string  fileName)

Creates a file at the top level, choosing the appropriate type based on the file extension.

◆ NewSection() [1/2]

void NewSection ( std::string  name)
inline

Creates a new section of the same type as currentSection under currentSection.

Pushes the new section to the end of the section list.

Definition at line 153 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::NewSection().

Referenced by CubicSplineCommon::Write().

virtual IOTreeClass * NewSection(std::string name)=0
Write me!
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ NewSection() [2/2]

bool NewSection ( std::string  name,
std::string  fileName 
)

This function creates a new file of the appropriate type as determined by the extension of fileName and mounts it at the end of the list under CurrentSection.

Returns false if the file couldn't be created.

◆ OpenFile()

bool OpenFile ( std::string  fileName)

Opens the file reference by fileName and reads the contents into the tree in CurrentSection.

Creates a new object based on the extnesion of the filename. For ".h5", it creates an IOTreeHDF5Class. For ".xml" it creaes an IOTreeXMLClass. After creating the object, it calls the objects virtual OpenFile function, reading the contents of the file into the tree.

◆ OpenSection() [1/2]

bool OpenSection ( std::string  name,
int  num = 0 
)

Opens the num'th section with the given name.

The default value for num is 0.

Referenced by CubicSplineCommon::Read().

◆ OpenSection() [2/2]

bool OpenSection ( int  num)

Opens the num'th section below CurrentSection.

◆ PrintTree()

void PrintTree ( )
inline

Calls CurrentSections virtual PrintTree() function.

This is for debugging purposes. It spits out a hierarchy of the sections and variable names.

Definition at line 221 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::PrintTree().

IOTreeClass * CurrentSection
Definition: IO.h:113
virtual void PrintTree()=0

◆ ReadVar() [1/2]

bool ReadVar ( std::string  name,
T &  var 
)
inline

Template function which reads a variable in the present section into the passed-by-reference T variable.

Definition at line 168 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::ReadVar().

Referenced by LinearGrid::Read(), CubicSplineCommon::Read(), GeneralGrid::Read(), OptimalGrid::Read(), OptimalGrid2::Read(), LogGrid::Read(), ClusterGrid::Read(), ReadGrid(), and IOSectionClass::ReadVar().

169  {
170  return (CurrentSection->ReadVar(name, var));
171  }
bool ReadVar(std::string name, T &var)
Definition: IOBase.h:63
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ ReadVar() [2/2]

bool ReadVar ( std::string  name,
T &  var,
Default 
)
inline

Definition at line 174 of file IO.h.

References IOSectionClass::ReadVar().

175  {
176  bool success = ReadVar(name, var);
177  if (!success)
178  var = Default;
179  return (success);
180  }
bool ReadVar(std::string name, T &var)
Template function which reads a variable in the present section into the passed-by-reference T variab...
Definition: IO.h:168

◆ SetUnderscores()

void SetUnderscores ( bool  use)
inline

Definition at line 211 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::SetUnderscores().

void SetUnderscores(bool use)
Definition: IOBase.h:143
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ WriteVar() [1/2]

bool WriteVar ( std::string  name,
val 
)
inline

Writes a variable under the current section.

Definition at line 184 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::WriteVar().

Referenced by LinearGrid::Write(), CubicSplineCommon::Write(), GeneralGrid::Write(), OptimalGrid::Write(), OptimalGrid2::Write(), LogGrid::Write(), and ClusterGrid::Write().

185  {
186  return CurrentSection->WriteVar(name, val);
187  }
bool WriteVar(std::string name, T val)
These create a new variable with the given name and value:
Definition: IO.h:37
IOTreeClass * CurrentSection
Definition: IO.h:113

◆ WriteVar() [2/2]

bool WriteVar ( std::string  name,
const Array< T, RANK > &  val 
)
inline

Definition at line 190 of file IO.h.

References IOSectionClass::CurrentSection, and IOTreeClass::WriteVar().

191  {
192  return CurrentSection->WriteVar(name, val);
193  }
bool WriteVar(std::string name, T val)
These create a new variable with the given name and value:
Definition: IO.h:37
IOTreeClass * CurrentSection
Definition: IO.h:113

Member Data Documentation

◆ CurrentSection


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