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 CharT , typename T >
void debug (std::basic_ostream< CharT > &os, const T &value, bool compact=false)
 
template<typename CharT , typename T >
void debug (std::basic_ostream< CharT > &os, const T &value, [[maybe_unused]] bool compact)
 Writes the debug representation of value to the given std::ostream. More...
 
template<typename CharT , typename... Ts>
void debug_all (std::basic_ostream< CharT > &os, const Ts &... values)
 Writes the compact debug representation of the provided values to the given std::ostream. More...
 
template<typename CharT = char, typename T >
std::basic_string< CharT > debug_str (const T &value, bool compact=false)
 Writes the debug representation of the provided value to an std::string and returns it. More...
 
template<typename CharT = char, typename... Ts>
std::basic_string< CharT > debug_all_str (const Ts &... values)
 Writes the compact debug representation of the provided values to an std::string and returns it. More...
 
template<typename U , typename T , typename... Args>
invoke (T &&target, const char *name, Args &&... args)
 Invokes the specified member with the provided arguments. More...
 

Variables

template<typename Derived , typename Target >
struct REFL_DETAIL_FORCE_EBO proxy
 

Detailed Description

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

Function Documentation

◆ debug() [1/2]

template<typename CharT , typename T >
void refl::runtime::debug ( std::basic_ostream< CharT > &  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 CharT , typename T >
void refl::runtime::debug ( std::basic_ostream< CharT > &  os,
const T &  value,
bool  compact = false 
)

◆ debug_all()

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

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

◆ debug_all_str()

template<typename CharT = char, typename... Ts>
std::basic_string<CharT> 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 CharT = char, typename T >
std::basic_string<CharT> 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.

Variable Documentation

◆ proxy

template<typename Derived , typename Target >
struct REFL_DETAIL_FORCE_EBO refl::runtime::proxy