helics  2.8.1
Functions
TomlProcessingFunctions.hpp File Reference
#include "../core/helics-time.hpp"
#include "toml.hpp"
#include <functional>
#include <string>

Go to the source code of this file.

Functions

toml::value loadToml (const std::string &tomlString)
 
bool hasTomlExtension (const std::string &tomlString)
 
toml::value loadTomlStr (const std::string &tomlString)
 
std::string tomlAsString (const toml::value &element)
 
helics::Time loadTomlTime (const toml::value &timeElement, time_units defaultUnits=time_units::sec)
 
std::string getKey (const toml::value &element)
 
std::string getOrDefault (const toml::value &element, const std::string &key, const std::string &defVal)
 
double getOrDefault (const toml::value &element, const std::string &key, double defVal)
 
bool getOrDefault (const toml::value &element, const std::string &key, bool defVal)
 
int64_t getOrDefault (const toml::value &element, const std::string &key, int64_t defVal)
 
bool callIfMember (const toml::value &element, const std::string &key, const std::function< void(const std::string &)> &call)
 
bool callIfMember (const toml::value &element, const std::string &key, const std::function< void(const std::string &, helics::Time)> &call)
 
template<class X >
bool callIfMember (const toml::value &element, const std::string &key, const std::function< void(const std::string &, X)> &call)
 
void replaceIfMember (const toml::value &element, const std::string &key, helics::Time &timeVal)
 
void replaceIfMember (const toml::value &element, const std::string &key, std::string &loc)
 
template<class X >
void replaceIfMember (const toml::value &element, const std::string &key, X &loc)
 
bool isMember (const toml::value &element, const std::string &key)
 

Detailed Description

functions related to loading and evaluating TOML files and helper functions for reading them using the toml library

Function Documentation

◆ callIfMember() [1/3]

bool callIfMember ( const toml::value &  element,
const std::string &  key,
const std::function< void(const std::string &)> &  call 
)
inline

call a function if a member element exists and pass the string to the invoked object

◆ callIfMember() [2/3]

bool callIfMember ( const toml::value &  element,
const std::string &  key,
const std::function< void(const std::string &, helics::Time)> &  call 
)
inline

call a function if a member element exists and pass a time to the invoked object

References loadTomlTime().

◆ callIfMember() [3/3]

template<class X >
bool callIfMember ( const toml::value &  element,
const std::string &  key,
const std::function< void(const std::string &, X)> &  call 
)
inline

call a function if a member element exists and pass a specific type to the invoked object

◆ getKey()

std::string getKey ( const toml::value &  element)

get a name or key from the element

◆ getOrDefault() [1/4]

bool getOrDefault ( const toml::value &  element,
const std::string &  key,
bool  defVal 
)
inline

get a boolean value or use the default if it is not a member

◆ getOrDefault() [2/4]

std::string getOrDefault ( const toml::value &  element,
const std::string &  key,
const std::string &  defVal 
)
inline

get a string value or use the default if it is not a member

◆ getOrDefault() [3/4]

double getOrDefault ( const toml::value &  element,
const std::string &  key,
double  defVal 
)
inline

get a double value or use the default if it is not a member

◆ getOrDefault() [4/4]

int64_t getOrDefault ( const toml::value &  element,
const std::string &  key,
int64_t  defVal 
)
inline

get an integer value or use the default if it is not a member

◆ isMember()

bool isMember ( const toml::value &  element,
const std::string &  key 
)
inline

check if a key is a member of a table object

◆ loadToml()

toml::value loadToml ( const std::string &  tomlString)

load a TOML string or filename that points to a TOML file and return a toml::Value to the root object

References loadTomlStr().

Referenced by helics::FederateInfo::loadInfoFromToml().

◆ loadTomlStr()

toml::value loadTomlStr ( const std::string &  tomlString)

load a TOML object in a string

Referenced by loadToml().

◆ loadTomlTime()

helics::Time loadTomlTime ( const toml::value &  timeElement,
time_units  defaultUnits 
)

read a time from a TOML value element

read a time from a JSON value element

References tomlAsString().

Referenced by callIfMember().

◆ tomlAsString()

std::string tomlAsString ( const toml::value &  element)

get a toml value as a string

Referenced by loadTomlTime().