tfel
Loading...
Searching...
No Matches
Data.hxx File Reference
#include <map>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <string_view>
#include "TFEL/Config/TFELConfig.hxx"
#include "TFEL/Utilities/GenTypeBase.hxx"
#include "TFEL/Utilities/CxxTokenizer.hxx"
#include "TFEL/Utilities/Data.ixx"

Classes

struct  tfel::utilities::DataStructure
 a structure in charge of containing a complex data structure. More...
struct  tfel::utilities::DataParsingOptions
struct  tfel::utilities::internals::isDataTypeCheck< T >
 a simple meta function to the check if the given type is part of the DataTypes type list. More...
struct  tfel::utilities::Data
 A structure able to contain values extracted from a JSON-like file. More...
struct  tfel::utilities::DataMapValidator
 an helper structure used to validate a data map. More...

Namespaces

namespace  tfel
 the namespace tfel encloses all the TFEL project. This namespace is empty.

Typedefs

using tfel::utilities::DataMap = std::map<std::string, Data, std::less<>>
 a simple alias
using tfel::utilities::DataTypes
 list of all type handled by the Data structure
template<typename T>
using tfel::utilities::isDataType = tfel::utilities::internals::isDataTypeCheck<T>
 a simple alias

Functions

TFELUTILITIES_VISIBILITY_EXPORT bool tfel::utilities::operator== (const Data &, const Data &)
 comparison operator
template<typename T>
T tfel::utilities::convert (const Data &)
 extract a value of the given type from a Data structure
template<typename T>
bool tfel::utilities::is_convertible (const Data &)
TFELUTILITIES_VISIBILITY_EXPORT void tfel::utilities::check_keys (const DataMap &, const std::vector< std::string > &)
 check that all the keys of the data map are in the given list.
TFELUTILITIES_VISIBILITY_EXPORT void tfel::utilities::raiseUnmatchedDataType (const std::string_view)
 throw an exception stating that the parameter type is not the expected one.
TFELUTILITIES_VISIBILITY_EXPORT bool tfel::utilities::contains (const DataMap &, std::string_view)
template<typename ResultType>
bool tfel::utilities::is (const DataMap &, std::string_view)
TFELUTILITIES_VISIBILITY_EXPORT const Data & tfel::utilities::get (const DataMap &, std::string_view)
template<typename ResultType>
const ResultType & tfel::utilities::get (const DataMap &, std::string_view)
template<typename ResultType>
ResultType tfel::utilities::get_if (const DataMap &, std::string_view, const ResultType &)
TFELUTILITIES_VISIBILITY_EXPORT Data tfel::utilities::get_if (const DataMap &, std::string_view, const Data &)
TFELUTILITIES_VISIBILITY_EXPORT DataMap tfel::utilities::extract (const DataMap &, const std::vector< std::string > &)
TFELUTILITIES_VISIBILITY_EXPORT DataMap tfel::utilities::remove (const DataMap &, const std::vector< std::string > &)
TFELUTILITIES_VISIBILITY_EXPORT DataMap tfel::utilities::merge (const DataMap &, const DataMap &, const bool)

Detailed Description

Author
Thomas Helfer
Date
12/09/2016

Typedef Documentation

◆ DataTypes

Initial value:
tfel::meta::GenerateTypeList<bool,
int,
double,
std::string,
std::vector<Data>,
std::map<double, double>,
std::map< std::string, Data, std::less<> > DataMap
a simple alias
Definition Data.hxx:32
a structure in charge of containing a complex data structure.
Definition Data.hxx:37

list of all type handled by the Data structure

Function Documentation

◆ check_keys()

TFELUTILITIES_VISIBILITY_EXPORT void tfel::utilities::check_keys ( const DataMap & ,
const std::vector< std::string > &  )

check that all the keys of the data map are in the given list.

Parameters
[in]ddata map
[in]keysallowed keys

◆ contains()

TFELUTILITIES_VISIBILITY_EXPORT bool tfel::utilities::contains ( const DataMap & ,
std::string_view  )
Returns
true if the given data exists
Parameters
[in]mdata map
[in]nname

◆ convert()

template<typename T>
T tfel::utilities::convert ( const Data & d)

extract a value of the given type from a Data structure

Parameters
[in]ddata
Returns
the extracted value

◆ extract()

TFELUTILITIES_VISIBILITY_EXPORT DataMap tfel::utilities::extract ( const DataMap & ,
const std::vector< std::string > &  )
Returns
a data map containing only data with the given names
Parameters
[in]mdata map
[in]nameslist of names of data to be extracted

◆ get() [1/2]

TFELUTILITIES_VISIBILITY_EXPORT const Data & tfel::utilities::get ( const DataMap & ,
std::string_view  )
Returns
the data associated with the given name
Parameters
[in]mdata map
[in]nname

◆ get() [2/2]

template<typename ResultType>
const ResultType & tfel::utilities::get ( const DataMap & m,
std::string_view n )
Returns
value of the data
Template Parameters
ResultTypeexpected type of the data
Parameters
[in]mdata map
[in]nname
Exceptions
ifthe data does not exists or does not have the good type.

◆ get_if() [1/2]

TFELUTILITIES_VISIBILITY_EXPORT Data tfel::utilities::get_if ( const DataMap & ,
std::string_view ,
const Data &  )
Returns
value of the data if present, a default value otherwise
Parameters
[in]mdata map
[in]nname
[in]vdefault value

◆ get_if() [2/2]

template<typename ResultType>
ResultType tfel::utilities::get_if ( const DataMap & m,
std::string_view n,
const ResultType & v )
Returns
value of the data if present, a default value otherwise
Template Parameters
ResultTypeexpected type of the data
Parameters
[in]mdata map
[in]nname
[in]vdefault value
Exceptions
ifthe data exists but does not have the good type.

◆ is()

template<typename ResultType>
bool tfel::utilities::is ( const DataMap & m,
std::string_view n )
Returns
true if the given data has the given type
Parameters
[in]mdata map
[in]nname
Exceptions
ifthe data does not exists

◆ is_convertible()

template<typename T>
bool tfel::utilities::is_convertible ( const Data & d)
Parameters
[in]ddata
Returns
true if the Data can be converted to the given type

◆ merge()

TFELUTILITIES_VISIBILITY_EXPORT DataMap tfel::utilities::merge ( const DataMap & ,
const DataMap & ,
const bool  )
Returns
the data map resulting from the merge of two data maps.
Parameters
[in]m1first data map
[in]m2second data map
[in]bboolean stating if multiple data definition are allowed. If so, the resulting map will contain the value of the first data map. Otherwise, an exception is thrown.

◆ raiseUnmatchedDataType()

TFELUTILITIES_VISIBILITY_EXPORT void tfel::utilities::raiseUnmatchedDataType ( const std::string_view )

throw an exception stating that the parameter type is not the expected one.

Parameters
[in]nname of the variable

◆ remove()

TFELUTILITIES_VISIBILITY_EXPORT DataMap tfel::utilities::remove ( const DataMap & ,
const std::vector< std::string > &  )
Returns
a data map containing only data that does not match the given names
Parameters
[in]mdata map
[in]nameslist of names of data to be removed