28 extern std::ostream
verr;
34 return WriteVar(name, std::string(val));
41 throw std::logic_error{
"this case is unimplement for rank 0"};
46 std::cerr <<
"Unknown file type in WriteVar.\n";
52 template<
typename T,
int LEN>
56 for (
int i = 0; i < LEN; i++)
63 template<
typename T,
int RANK>
72 std::cerr <<
"Unknown file type in WriteVar.\n";
78 template<
typename T,
int RANK,
int LEN>
82 for (
int dim = 0; dim < RANK; dim++)
83 shape[dim] = val.extent(dim);
93 inline std::string
Extension(std::string fileName);
122 bool OpenFile(std::string fileName);
128 bool NewFile(std::string fileName);
159 bool NewSection(std::string name, std::string fileName);
174 bool ReadVar(std::string name, T& var, T Default)
176 bool success =
ReadVar(name, var);
189 template<
typename T,
int RANK>
201 template<
typename T,
int RANK>
IOSectionClass(IOSectionClass &io)
bool WriteVar(std::string name, T val)
These create a new variable with the given name and value:
IOTreeClass * NewTree(std::string fileName, std::string myName, IOTreeClass *parent)
void PrintTree()
Calls CurrentSections virtual PrintTree() function.
bool OpenSection(std::string name, int num=0)
Opens the num'th section with the given name.
int CountSections(std::string name)
Returns the number of subsections with the given name within the present section. ...
bool AppendVar(std::string name, const Array< T, RANK > &val)
bool NewFile(std::string fileName)
Creates a file at the top level, choosing the appropriate type based on the file extension.
std::string Extension(std::string fileName)
In the file name format name.extn, returns the extension.
void SetUnderscores(bool use)
IOVarBase * GetVarPtr(std::string name)
bool ReadVar(std::string name, T &var, T Default)
bool WriteVar(std::string name, T val)
Writes a variable under the current section.
This class stores a tree of input file sections.
void CloseSection()
Closes the current section.
void CloseFile()
Calls CurrentSections close file and then deletes the CurrentSection.
void NewSection(std::string name)
Creates a new section of the same type as currentSection under currentSection.
IOVarBase * GetVarPtr(int num)
std::list< IOVarBase * > VarList
void SetUnderscores(bool use)
IOVarBase * GetVarPtr(std::string name)
virtual IOTreeClass * NewSection(std::string name)=0
Write me!
constexpr class neverDeleteData_t neverDeleteData
void FlushFile()
Flush all buffers to disk for safety.
bool ReadVar(std::string name, T &var)
virtual IOFileType GetFileType()=0
IOTreeClass * CurrentSection
bool AppendVar(std::string name, T val)
std::string GetVarName(int num)
Wrapper class for IOTreeClass that gives a nearly identical interface as the OutputSectionClass.
bool WriteVar(std::string name, const Array< T, RANK > &val)
bool IncludeSection(std::string name, std::string fileName)
This mounts a file in the current tree under CurrentSection at the end of CurrentsSection's SectionLi...
std::string GetName() const
std::string GetFileName()
bool OpenFile(std::string fileName)
Opens the file reference by fileName and reads the contents into the tree in CurrentSection.
IOTreeClass * ReadTree(std::string fileName, std::string myName, IOTreeClass *parent)
This function takes a filename, determines it extension, creates a new IOTreeASCIIClass or IOTreeHDF5...
int CountSections(std::string name="")
Returns the number of subsections within the present section which have the name name.
void SetVerbose(bool verb)
virtual void PrintTree()=0
bool ReadVar(std::string name, T &var)
Template function which reads a variable in the present section into the passed-by-reference T variab...
bool AppendVar(std::string name, T val)
Append a value to a variable of dimension of 1 higher than val.