refl-cpp
refl::runtime Namespace Reference

Contains utilities that can have runtime-overhead (like proxy, debug, invoke) More...

Classes

struct  proxy
 A proxy object that has a static interface identical to the reflected functions and fields of the target. More...
 

Functions

template<typename T >
void debug (std::ostream &os, const T &value, bool compact=false)
 
template<typename T >
void debug (std::ostream &os, const T &value, [[maybe_unused]] bool compact)
 
template<typename... Ts>
void debug_all (std::ostream &os, const Ts &... values)
 
template<typename T >
std::string debug_str (const T &value, bool compact=false)
 
template<typename... Ts>
std::string debug_all_str (const Ts &... values)
 
template<typename U , typename T , typename... Args>
invoke (T &&target, const char *name, Args &&... args)
 

Detailed Description

Contains utilities that can have runtime-overhead (like proxy, debug, invoke)

Function Documentation

◆ debug() [1/2]

template<typename T >
void refl::runtime::debug ( std::ostream &  os,
const T &  value,
[[maybe_unused] ] bool  compact 
)

Writes the debug representation of value to the given std::ostream. Calls the function specified by the debug<F> attribute whenever possible, before falling back to recursively interating the members and printing them. Takes an optional arguments specifying whether to print a compact representation. The compact representation contains no newlines.

◆ debug() [2/2]

template<typename T >
void refl::runtime::debug ( std::ostream &  os,
const T &  value,
bool  compact = false 
)

◆ debug_all()

template<typename... Ts>
void refl::runtime::debug_all ( std::ostream &  os,
const Ts &...  values 
)

Writes the compact debug representation of the provided values to the given std::ostream.

◆ debug_all_str()

template<typename... Ts>
std::string refl::runtime::debug_all_str ( const Ts &...  values)

Writes the compact debug representation of the provided values to an std::string and returns it.

◆ debug_str()

template<typename T >
std::string refl::runtime::debug_str ( const T &  value,
bool  compact = false 
)

Writes the debug representation of the provided value to an std::string and returns it. Takes an optional arguments specifying whether to print a compact representation. The compact representation contains no newlines.

◆ invoke()

template<typename U , typename T , typename... Args>
U refl::runtime::invoke ( T &&  target,
const char *  name,
Args &&...  args 
)

Invokes the specified member with the provided arguments. When used with a member that is a field, the function gets or sets the value of the field. The list of members is initially filtered by the type of the arguments provided. THe filtered list is then searched at runtime by member name for the specified member and that member is then invoked by operator(). If no match is found, an std::runtime_error is thrown.