| helics 3.6.1

Namespaces | Macros | Functions
TomlProcessingFunctions.hpp File Reference
`#include "../core/helicsTime.hpp"`
`#include <string_view>`
`#include "toml.hpp"`
`#include <functional>`
`#include <string>`

Go to the source code of this file.

## Namespaces
| helics
| the main namespace for the helics co-simulation library User functions will be in the helics namespace with internal functions possible in a lower level namespace

## Macros
#define | TOML11_USING_STRING_VIEW 1

## Functions
toml::value | helics::fileops::loadToml (const std::string &tomlString)
bool | helics::fileops::hasTomlExtension (std::string_view tomlString)
bool | helics::fileops::looksLikeConfigToml (std::string_view tomlString)
toml::value | helics::fileops::loadTomlStr (const std::string &tomlString)
std::string | helics::fileops::tomlAsString (const toml::value &element)
helics::Time | helics::fileops::loadTomlTime (const toml::value &timeElement, time_units defaultUnits=time_units::sec)
std::string | helics::fileops::getName (const toml::value &element)
std::string | helics::fileops::getOrDefault (const toml::value &element, const std::string &key, std::string_view defVal)
double | helics::fileops::getOrDefault (const toml::value &element, const std::string &key, double defVal)
bool | helics::fileops::getOrDefault (const toml::value &element, const std::string &key, bool defVal)
int64_t | helics::fileops::getOrDefault (const toml::value &element, const std::string &key, int64_t defVal)
bool | helics::fileops::callIfMember (const toml::value &element, const std::string &key, const std::function< void(const std::string &)> &call)
bool | helics::fileops::callIfMember (const toml::value &element, const std::string &key, const std::function< void(const std::string &, helics::Time)> &call)
template<class X >
bool | helics::fileops::callIfMember (const toml::value &element, const std::string &key, const std::function< void(const std::string &, X)> &call)
void | helics::fileops::replaceIfMember (const toml::value &element, const std::string &key, helics::Time &timeVal)
void | helics::fileops::replaceIfMember (const toml::value &element, const std::string &key, std::string &loc)
template<class X >
void | helics::fileops::replaceIfMember (const toml::value &element, const std::string &key, X &loc)
bool | helics::fileops::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 helics::fileops::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 helics::fileops::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 helics::fileops::loadTomlTime().

## ◆ callIfMember() [3/3]

template<class X >

bool helics::fileops::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

## ◆ getName()

std::string helics::fileops::getName | ( | const toml::value & | element | ) |

get a name or key from the element

## ◆ getOrDefault() [1/4]

bool helics::fileops::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]

double helics::fileops::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() [3/4]

int64_t helics::fileops::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

## ◆ getOrDefault() [4/4]

std::string helics::fileops::getOrDefault | ( | const toml::value & | element,
|  | const std::string & | key,
|  | std::string_view | defVal
| ) |  |
| inline

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

References helics::fileops::tomlAsString().

## ◆ hasTomlExtension()

bool helics::fileops::hasTomlExtension | ( | std::string_view | tomlString | ) |

return true if the string has a toml extension

## ◆ isMember()

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

check if a key is a member of a table object

References helics::fileops::isMember().

Referenced by helics::fileops::isMember().

## ◆ loadToml()

toml::value helics::fileops::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 helics::fileops::loadToml().

Referenced by helics::fileops::loadToml().

## ◆ loadTomlStr()

toml::value helics::fileops::loadTomlStr | ( | const std::string & | tomlString | ) |

load a TOML object in a string

Exceptions

  std::invalid_argument | if the string parsing failed through toml

References helics::fileops::loadTomlStr().

Referenced by helics::fileops::loadTomlStr().

## ◆ loadTomlTime()

helics::Time helics::fileops::loadTomlTime | ( | const toml::value & | timeElement,
|  | time_units | defaultUnits = `time_units::sec`
| ) |  |

read a time from a TOML value element

References helics::fileops::loadTomlTime().

Referenced by helics::fileops::callIfMember(), and helics::fileops::loadTomlTime().

## ◆ looksLikeConfigToml()

bool helics::fileops::looksLikeConfigToml | ( | std::string_view | tomlString | ) |

check if the string looks like a possible config object in toml format

## ◆ tomlAsString()

std::string helics::fileops::tomlAsString | ( | const toml::value & | element | ) |

get a toml value as a string

References helics::fileops::tomlAsString().

Referenced by helics::fileops::getOrDefault(), and helics::fileops::tomlAsString().