Doxygen 1.9.1
Toolkit for Adaptive Stochastic Modeling and Non-Intrusive ApproximatioN: Tasmanian v8.2 (development)

Templates to simply file I/O. More...

#include "tsgEnumerates.hpp"
#include <functional>
Include dependency graph for tsgIOHelpers.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TasGrid::IO::mode_ascii_type
 Type indicating ascii I/O mode. More...
 
struct  TasGrid::IO::mode_binary_type
 Type indicating binary I/O mode. More...
 

Namespaces

 TasGrid
 Encapsulates the Tasmanian Sparse Grid module.
 
 TasGrid::IO
 Collection of I/O handling templates.
 

Enumerations

enum  TasGrid::IO::IOPad {
  TasGrid::IO::pad_none , TasGrid::IO::pad_rspace , TasGrid::IO::pad_lspace , TasGrid::IO::pad_line ,
  TasGrid::IO::pad_auto
}
 Indicate the type of padding to use, none, space, new-line, etc. More...
 

Functions

std::map< std::string, TypeOneDRule > TasGrid::IO::getStringRuleMap ()
 Creates a map with std::string rule names (used by C/Python/CLI) mapped to TypeOneDRule enums.
 
TypeOneDRule TasGrid::IO::getRuleString (std::string const &name)
 Map the string rule name to the enumerate, used in ASCII I/O, command line and Python.
 
std::string TasGrid::IO::getRuleString (TypeOneDRule rule)
 Map the enumerate to a string, used in ASCII I/O, command line and Python.
 
std::vector< TypeOneDRule > TasGrid::IO::getIntRuleMap ()
 Creates a map with int (used by Fortran and binary I/O) mapped to TypeOneDRule enums.
 
TypeOneDRule TasGrid::IO::getRuleInt (int r)
 Map the int rule index to the enumerate, used in Fortran and binary IO.
 
int TasGrid::IO::getRuleInt (TypeOneDRule rule)
 Map the enumerate to an int, used in Fortran and binary IO.
 
std::map< std::string, TypeDepth > TasGrid::IO::getStringToDepthMap ()
 Creates a map with std::string rule names (used by C/Python/CLI) mapped to TypeDepth enums.
 
TypeDepth TasGrid::IO::getDepthTypeString (std::string const &name)
 Map the string to the enumerate multi-index selection strategy, used in command line and Python.
 
TypeDepth TasGrid::IO::getDepthTypeInt (int t)
 Map the integer to the enumerate multi-index selection strategy, used in Fortran.
 
std::map< std::string, TypeRefinement > TasGrid::IO::getStringToRefinementMap ()
 Creates a map with std::string rule names (used by C/Python/CLI) mapped to TypeRefinement enums.
 
TypeRefinement TasGrid::IO::getTypeRefinementString (std::string const &name)
 Map the string to the enumerate hierarchical refinement strategy, used in command line and Python.
 
TypeRefinement TasGrid::IO::getTypeRefinementInt (int refinement)
 Map the integer to the enumerate hierarchical refinement strategy, used by Fortran.
 
template<bool iomode, IOPad pad>
void TasGrid::IO::writeFlag (bool flag, std::ostream &os)
 Write the flag to file, ascii uses 0 and 1, binary uses characters y and n (counter intuitive, I know).
 
template<typename iomode >
bool TasGrid::IO::readFlag (std::istream &os)
 Read a flag, ascii uses 0 and 1, binary uses characters y and n (counter intuitive, I know).
 
template<bool iomode, IOPad pad, typename VecType >
void TasGrid::IO::writeVector (const std::vector< VecType > &x, std::ostream &os)
 Write the vector to the stream, the vector cannot be empty.
 
template<typename iomode , typename VecType >
void TasGrid::IO::readVector (std::istream &is, std::vector< VecType > &x)
 Read the vector from the stream, the size must already be set.
 
template<typename iomode , typename VecType , typename SizeType >
std::vector< VecType > TasGrid::IO::readVector (std::istream &is, SizeType num_entries)
 Read the vector with the specified size.
 
template<bool iomode, IOPad pad, typename... Vals>
void TasGrid::IO::writeNumbers (std::ostream &os, Vals... vals)
 Write a bunch of numbers with the same type.
 
template<typename iomode , typename Val >
Val TasGrid::IO::readNumber (std::istream &is)
 Read a single number, used to read ints (and potentially cast to size_t) or read a double.
 
template<bool iomode>
void TasGrid::IO::writeRule (TypeOneDRule rule, std::ostream &os)
 Write a rule.
 
template<typename iomode >
TypeOneDRule TasGrid::IO::readRule (std::istream &is)
 Read a rule.
 

Variables

constexpr bool TasGrid::mode_ascii = false
 Constant allowing for more expressive selection of ascii and binary mode in IO methods.
 
constexpr bool TasGrid::mode_binary = true
 Constant allowing for more expressive selection of ascii and binary mode in IO methods.
 

Detailed Description

Templates to simply file I/O.

Author
Miroslav Stoyanov

Several templates that simplify the I/O of Tasmanian. Commonly used operations are lumped into templates with simple binary/ascii switch.