Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
dynamic_format_arg_store< Context > Class Template Reference

#include <core.h>

Classes

struct  need_copy
 

Public Member Functions

void clear ()
 
template<typename T >
void push_back (const T &arg)
 
template<typename T >
void push_back (std::reference_wrapper< T > arg)
 
template<typename T >
void push_back (const detail::named_arg< char_type, T > &arg)
 
void reserve (size_t new_cap, size_t new_cap_named)
 

Private Types

using char_type = typename Context::char_type
 
template<typename T >
using stored_type = conditional_t< detail::is_string< T >::value, std::basic_string< char_type >, T >
 

Private Member Functions

const basic_format_arg< Context > * data () const
 
template<typename T >
void emplace_arg (const T &arg)
 
template<typename T >
void emplace_arg (const detail::named_arg< char_type, T > &arg)
 
unsigned long long get_types () const
 

Private Attributes

std::vector< basic_format_arg< Context > > data_
 
detail::dynamic_arg_list dynamic_args_
 
std::vector< detail::named_arg_info< char_type > > named_info_
 

Friends

class basic_format_args< Context >
 

Detailed Description

template<typename Context>
class dynamic_format_arg_store< Context >

A dynamic version of fmt::format_arg_store. It's equipped with a storage to potentially temporary objects which lifetimes could be shorter than the format arguments object.

It can be implicitly converted into ~fmtbasic_format_args for passing into type-erased formatting functions such as ~fmtvformat.

Definition at line 618 of file core.h.

Member Typedef Documentation

template<typename Context>
using dynamic_format_arg_store< Context >::char_type = typename Context::char_type
private

Definition at line 1679 of file core.h.

template<typename Context>
template<typename T >
using dynamic_format_arg_store< Context >::stored_type = conditional_t<detail::is_string<T>::value, std::basic_string<char_type>, T>
private

Definition at line 1697 of file core.h.

Member Function Documentation

template<typename Context>
void dynamic_format_arg_store< Context >::clear ( )
inline

Erase all elements from the store

Definition at line 1814 of file core.h.

template<typename Context>
const basic_format_arg<Context>* dynamic_format_arg_store< Context >::data ( ) const
inlineprivate

Definition at line 1716 of file core.h.

template<typename Context>
template<typename T >
void dynamic_format_arg_store< Context >::emplace_arg ( const T &  arg)
inlineprivate

Definition at line 1720 of file core.h.

template<typename Context>
template<typename T >
void dynamic_format_arg_store< Context >::emplace_arg ( const detail::named_arg< char_type, T > &  arg)
inlineprivate

Definition at line 1725 of file core.h.

template<typename Context>
unsigned long long dynamic_format_arg_store< Context >::get_types ( ) const
inlineprivate

Definition at line 1709 of file core.h.

template<typename Context>
template<typename T >
void dynamic_format_arg_store< Context >::push_back ( const T &  arg)
inline

Adds an argument into the dynamic store for later passing to a formatting function.

Note that custom types and string types (but not string views) are copied into the store dynamically allocating memory if necessary.

Example**::

fmt::dynamic_format_arg_store<fmt::format_context> store; store.push_back(42); store.push_back("abc"); store.push_back(1.5f); std::string result = fmt::vformat("{} and {} and {}", store);

Definition at line 1759 of file core.h.

template<typename Context>
template<typename T >
void dynamic_format_arg_store< Context >::push_back ( std::reference_wrapper< T >  arg)
inline

Adds a reference to the argument into the dynamic store for later passing to a formatting function. Supports named arguments wrapped in std::reference_wrapper via std::ref()/std::cref().

Example**::

fmt::dynamic_format_arg_store<fmt::format_context> store; char str[] = "1234567890"; store.push_back(std::cref(str)); int a1_val{42}; auto a1 = fmt::arg("a1_", a1_val); store.push_back(std::cref(a1));

Changing str affects the output but only for string and custom types. str[0] = 'X';

std::string result = fmt::vformat("{} and {a1_}"); assert(result == "X234567890 and 42");

Definition at line 1788 of file core.h.

template<typename Context>
template<typename T >
void dynamic_format_arg_store< Context >::push_back ( const detail::named_arg< char_type, T > &  arg)
inline

Adds named argument into the dynamic store for later passing to a formatting function. std::reference_wrapper is supported to avoid copying of the argument.

Definition at line 1802 of file core.h.

template<typename Context>
void dynamic_format_arg_store< Context >::reserve ( size_t  new_cap,
size_t  new_cap_named 
)
inline

Reserves space to store at least new_cap arguments including new_cap_named* named arguments.

Definition at line 1826 of file core.h.

Friends And Related Function Documentation

template<typename Context>
friend class basic_format_args< Context >
friend

Definition at line 1707 of file core.h.

Member Data Documentation

template<typename Context>
std::vector<basic_format_arg<Context> > dynamic_format_arg_store< Context >::data_
private

Definition at line 1700 of file core.h.

template<typename Context>
detail::dynamic_arg_list dynamic_format_arg_store< Context >::dynamic_args_
private

Definition at line 1705 of file core.h.

template<typename Context>
std::vector<detail::named_arg_info<char_type> > dynamic_format_arg_store< Context >::named_info_
private

Definition at line 1701 of file core.h.


The documentation for this class was generated from the following file:


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:49