caosdb/utility.h

namespace caosdb::utility

Functions

template<typename Enum>
auto getEnumNameFromValue(Enum v) -> std::string

Get the name of the enum value. May be useful for higher-order CaosDB clients.

template<>
auto getEnumNameFromValue<caosdb::entity::AtomicDataType>(caosdb::entity::AtomicDataType v) -> std::string
template<>
auto getEnumNameFromValue<caosdb::entity::Importance>(caosdb::entity::Importance v) -> std::string
template<>
auto getEnumNameFromValue<caosdb::entity::Role>(caosdb::entity::Role v) -> std::string
template<typename Enum>
auto getEnumValueFromName(const std::string &name) -> Enum

Get the enum value from a string.

May be useful for higher-order CaosDB clients and only makes sense if specialized.

template<>
auto getEnumValueFromName<caosdb::entity::AtomicDataType>(const std::string &name) -> caosdb::entity::AtomicDataType
template<>
auto getEnumValueFromName<caosdb::entity::Importance>(const std::string &name) -> caosdb::entity::Importance
template<>
auto getEnumValueFromName<caosdb::entity::Role>(const std::string &name) -> caosdb::entity::Role
inline auto load_string_file(const path &path) -> std::string

Read a text file into a string and return the file’s content.

inline auto get_env_fallback(const char *key, const char *fallback) -> const char*

Return the environment variable KEY, or FALLBACK if it does not exist.

inline auto get_env_fallback(const std::string &key, const std::string &fallback) -> const std::string

Return the value of an environment variable or - if undefined - the fallback value.

inline auto base64_encode(const std::string &plain) -> std::string

Encode string as base64.

inline auto load_json_file(const path &json_file) -> value
inline auto get_home_directory() -> const path