HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
format.h File Reference
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <limits>
#include <memory>
#include <stdexcept>
#include <stdint.h>
#include "core.h"
+ Include dependency graph for format.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  internal::function< Result >
 
struct  internal::function< Result >::result< T >
 
struct  internal::dummy_int
 
class  std::numeric_limits< fmt::internal::dummy_int >
 
class  basic_writer< Range >
 
class  output_range< OutputIt, T >
 
class  back_insert_range< Container >
 
class  format_error
 
struct  internal::checked< T >
 
class  u8string_view
 
class  basic_memory_buffer< T, SIZE, Allocator >
 
struct  internal::char_traits< Char >
 
struct  internal::char_traits< char >
 
struct  internal::char_traits< wchar_t >
 
class  internal::null_terminating_iterator< Char >
 
class  internal::null_terminating_iterator< Char >
 
class  internal::counting_iterator< T >
 
class  internal::truncating_iterator_base< OutputIt >
 
class  internal::truncating_iterator< OutputIt, Enable >
 
class  internal::truncating_iterator< OutputIt, std::false_type >
 
class  internal::truncating_iterator< OutputIt, std::true_type >
 
struct  internal::int_traits< T >
 
struct  internal::basic_data< T >
 
struct  internal::needs_conversion< InputIt, OutChar >
 
class  internal::decimal_formatter
 
class  internal::decimal_formatter_null
 
struct  internal::no_thousands_sep
 
class  internal::add_thousands_sep< Char >
 
struct  internal::null< T >
 
struct  align_spec
 
struct  core_format_specs
 
struct  basic_format_specs< Char >
 
class  internal::int_type_checker< ErrorHandler >
 
class  internal::float_type_checker< ErrorHandler >
 
class  internal::char_specs_checker< ErrorHandler >
 
class  internal::cstring_type_checker< ErrorHandler >
 
class  internal::arg_formatter_base< Range >
 
struct  internal::arg_formatter_base< Range >::char_spec_handler
 
struct  internal::arg_formatter_base< Range >::cstring_spec_handler
 
class  internal::custom_formatter< Char, Context >
 
struct  internal::is_integer< T >
 
class  internal::width_checker< ErrorHandler >
 
class  internal::precision_checker< ErrorHandler >
 
class  internal::specs_setter< Char >
 
class  internal::specs_checker< Handler >
 
struct  internal::auto_id
 
class  internal::specs_handler< Context >
 
struct  internal::arg_ref< Char >
 
struct  internal::dynamic_format_specs< Char >
 
class  internal::dynamic_specs_handler< ParseContext >
 
struct  internal::width_adapter< SpecHandler, Char >
 
struct  internal::precision_adapter< SpecHandler, Char >
 
struct  internal::id_adapter< Handler, Char >
 
class  internal::format_string_checker< Char, ErrorHandler, Args >
 
struct  internal::format_type< Context, T >
 
class  arg_formatter< Range >
 
class  system_error
 
class  basic_writer< Range >
 
struct  basic_writer< Range >::int_writer< Int, Spec >::dec_writer
 
struct  basic_writer< Range >::int_writer< Int, Spec >::hex_writer
 
struct  basic_writer< Range >::int_writer< Int, Spec >::bin_writer< BITS >
 
struct  basic_writer< Range >::int_writer< Int, Spec >::num_writer
 
struct  float_spec_handler
 
class  format_int
 
struct  formatter< T, Char, typename std::enable_if< internal::format_type< typename buffer_context< Char >::type, T >::value >::type >
 
class  dynamic_formatter< Char >
 
struct  format_handler< ArgFormatter, Char, Context >
 
struct  arg_join< It, Char >
 
struct  formatter< arg_join< It, Char >, Char >
 
struct  internal::void_< Ts >
 
struct  internal::it_category< T, Enable >
 
struct  internal::it_category< T * >
 
struct  internal::it_category< T, typename void_< typename T::iterator_category >::type >
 
class  internal::is_output_iterator< It >
 
struct  format_context_t< OutputIt, Char >
 
struct  format_args_t< OutputIt, Char >
 
struct  format_to_n_result< OutputIt >
 
struct  format_to_n_context< OutputIt, Char >
 
struct  format_to_n_args< OutputIt, Char >
 

Namespaces

 internal
 
 std
 

Macros

#define FMT_CLANG_VERSION   0
 
#define FMT_ICC_VERSION   0
 
#define FMT_CUDA_VERSION   0
 
#define FMT_SECURE_SCL   0
 
#define FMT_HAS_BUILTIN(x)   0
 
#define FMT_THROW(x)   throw x
 
#define FMT_USE_USER_DEFINED_LITERALS   0
 
#define FMT_UDL_TEMPLATE   0
 
#define FMT_USE_EXTERN_TEMPLATES
 
#define FMT_USE_TRAILING_RETURN   0
 
#define FMT_USE_GRISU   0
 
#define FMT_ALWAYS_INLINE
 
#define FMT_USE_WINDOWS_H   0
 
#define FMT_STRING(s)
 
#define FMT_FUNC
 

Typedefs

typedef std::numeric_limits
< internal::dummy_int
internal::fputil
 
typedef basic_writer
< back_insert_range
< internal::buffer > > 
writer
 
typedef basic_writer
< back_insert_range
< internal::wbuffer > > 
wwriter
 
typedef basic_memory_buffer< char > memory_buffer
 
typedef basic_memory_buffer
< wchar_t > 
wmemory_buffer
 
typedef basic_data internal::data
 
typedef basic_format_specs< char > format_specs
 

Enumerations

enum  char8_t : unsigned char
 
enum  { inline_buffer_size = 500 }
 
enum  alignment {
  ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER,
  ALIGN_NUMERIC
}
 
enum  { SIGN_FLAG = 1, PLUS_FLAG = 2, MINUS_FLAG = 4, HASH_FLAG = 8 }
 

Functions

template<typename Dest , typename Source >
Dest internal::bit_cast (const Source &source)
 
template<typename C >
FMT_CONSTEXPR auto internal::begin (const C &c) -> decltype(c.begin())
 
template<typename T , std::size_t N>
FMT_CONSTEXPR T * internal::begin (T(&array)[N]) FMT_NOEXCEPT
 
template<typename C >
FMT_CONSTEXPR auto internal::end (const C &c) -> decltype(c.end())
 
template<typename T , std::size_t N>
FMT_CONSTEXPR T * internal::end (T(&array)[N]) FMT_NOEXCEPT
 
dummy_int internal::isinf (...)
 
dummy_int internal::_finite (...)
 
dummy_int internal::isnan (...)
 
dummy_int internal::_isnan (...)
 
template<typename Allocator >
Allocator::value_type * internal::allocate (Allocator &alloc, std::size_t n)
 
template<typename T >
internal::const_check (T value)
 
template<typename T >
T * internal::make_checked (T *p, std::size_t)
 
template<typename Container >
std::enable_if< is_contiguous
< Container >::value, typename
checked< typename
Container::value_type >::type >
::type 
internal::reserve (std::back_insert_iterator< Container > &it, std::size_t n)
 
template<typename Iterator >
Iterator & internal::reserve (Iterator &it, std::size_t)
 
template<typename Char >
FMT_CONSTEXPR_DECL const Char * internal::pointer_from (null_terminating_iterator< Char > it)
 
template<typename T >
FMT_CONSTEXPR const T * internal::pointer_from (const T *p)
 
template<typename Char >
FMT_CONSTEXPR const Char * internal::pointer_from (null_terminating_iterator< Char > it)
 
template<typename T >
FMT_CONSTEXPR std::enable_if
< std::numeric_limits< T >
::is_signed, bool >::type 
internal::is_negative (T value)
 
template<typename T >
FMT_CONSTEXPR std::enable_if
< !std::numeric_limits< T >
::is_signed, bool >::type 
internal::is_negative (T)
 
unsigned internal::count_digits (uint64_t n)
 
template<typename Char >
size_t internal::count_code_points (basic_string_view< Char > s)
 
FMT_API size_t internal::count_code_points (basic_string_view< char8_t > s)
 
char8_t internal::to_char8_t (char c)
 
template<typename OutChar , typename InputIt , typename OutputIt >
std::enable_if
< !needs_conversion< InputIt,
OutChar >::value, OutputIt >
::type 
internal::copy_str (InputIt begin, InputIt end, OutputIt it)
 
template<typename OutChar , typename InputIt , typename OutputIt >
std::enable_if
< needs_conversion< InputIt,
OutChar >::value, OutputIt >
::type 
internal::copy_str (InputIt begin, InputIt end, OutputIt it)
 
template<typename Handler >
char * internal::lg (uint32_t n, Handler h) FMT_ALWAYS_INLINE
 
template<typename Char >
FMT_API Char internal::thousands_sep_impl (locale_ref loc)
 
template<typename Char >
Char internal::thousands_sep (locale_ref loc)
 
template<>
wchar_t internal::thousands_sep (locale_ref loc)
 
template<typename UInt , typename Char , typename ThousandsSep >
Char * internal::format_decimal (Char *buffer, UInt value, unsigned num_digits, ThousandsSep thousands_sep)
 
template<typename OutChar , typename UInt , typename Iterator , typename ThousandsSep >
Iterator internal::format_decimal (Iterator out, UInt value, unsigned num_digits, ThousandsSep sep)
 
template<typename OutChar , typename It , typename UInt >
It internal::format_decimal (It out, UInt value, unsigned num_digits)
 
template<unsigned BASE_BITS, typename Char , typename UInt >
Char * internal::format_uint (Char *buffer, UInt value, unsigned num_digits, bool upper=false)
 
template<unsigned BASE_BITS, typename Char , typename It , typename UInt >
It internal::format_uint (It out, UInt value, unsigned num_digits, bool upper=false)
 
template<typename Double >
FMT_API std::enable_if< sizeof(Double)==sizeof(uint64_t),
bool >::type 
internal::grisu2_format (Double value, buffer &buf, core_format_specs)
 
template<typename Double >
std::enable_if< sizeof(Double)!=sizeof(uint64_t),
bool >::type 
internal::grisu2_format (Double, buffer &, core_format_specs)
 
template<typename Double >
void internal::sprintf_format (Double value, internal::buffer &buffer, core_format_specs spec)
 
template<typename Handler >
FMT_CONSTEXPR void internal::handle_int_type_spec (char spec, Handler &&handler)
 
template<typename Handler >
FMT_CONSTEXPR void internal::handle_float_type_spec (char spec, Handler &&handler)
 
template<typename Char , typename Handler >
FMT_CONSTEXPR void internal::handle_char_specs (const basic_format_specs< Char > *specs, Handler &&handler)
 
template<typename Char , typename Handler >
FMT_CONSTEXPR void internal::handle_cstring_type_spec (Char spec, Handler &&handler)
 
template<typename Char , typename ErrorHandler >
FMT_CONSTEXPR void internal::check_string_type_spec (Char spec, ErrorHandler &&eh)
 
template<typename Char , typename ErrorHandler >
FMT_CONSTEXPR void internal::check_pointer_type_spec (Char spec, ErrorHandler &&eh)
 
template<typename Char >
FMT_CONSTEXPR bool internal::is_name_start (Char c)
 
template<typename Iterator , typename ErrorHandler >
FMT_CONSTEXPR unsigned internal::parse_nonnegative_int (Iterator &it, ErrorHandler &&eh)
 
template<typename Char , typename ErrorHandler >
FMT_CONSTEXPR unsigned internal::parse_nonnegative_int (const Char *&begin, const Char *end, ErrorHandler &&eh)
 
template<template< typename > class Handler, typename T , typename Context , typename ErrorHandler >
FMT_CONSTEXPR void internal::set_dynamic_spec (T &value, basic_format_arg< Context > arg, ErrorHandler eh)
 
template<typename Iterator , typename IDHandler >
FMT_CONSTEXPR Iterator internal::parse_arg_id (Iterator it, IDHandler &&handler)
 
template<typename Char , typename IDHandler >
FMT_CONSTEXPR const Char * internal::parse_arg_id (const Char *begin, const Char *end, IDHandler &&handler)
 
template<typename Iterator , typename SpecHandler >
FMT_CONSTEXPR Iterator internal::parse_format_specs (Iterator it, SpecHandler &&handler)
 
template<bool IS_CONSTEXPR, typename T , typename Ptr = const T*>
FMT_CONSTEXPR bool internal::find (Ptr first, Ptr last, T value, Ptr &out)
 
template<>
bool internal::find< false, char > (const char *first, const char *last, char value, const char *&out)
 
template<bool IS_CONSTEXPR, typename Char , typename Handler >
FMT_CONSTEXPR void internal::parse_format_string (basic_string_view< Char > format_str, Handler &&handler)
 
template<typename T , typename ParseContext >
FMT_CONSTEXPR const
ParseContext::char_type * 
internal::parse_format_specs (ParseContext &ctx)
 
template<typename Char , typename ErrorHandler , typename... Args>
FMT_CONSTEXPR bool internal::do_check_format_string (basic_string_view< Char > s, ErrorHandler eh=ErrorHandler())
 
template<typename... Args, typename S >
std::enable_if
< is_compile_string< S >
::value >::type 
internal::check_format_string (S)
 
template<template< typename > class Handler, typename Spec , typename Context >
void internal::handle_dynamic_spec (Spec &value, arg_ref< typename Context::char_type > ref, Context &ctx)
 
FMT_API void format_system_error (internal::buffer &out, int error_code, fmt::string_view message) FMT_NOEXCEPT
 
FMT_API void report_system_error (int error_code, string_view message) FMT_NOEXCEPT
 
template<typename T >
void format_decimal (char *&buffer, T value)
 
template<typename ArgFormatter , typename Char , typename Context >
Context::iterator vformat_to (typename ArgFormatter::range out, basic_string_view< Char > format_str, basic_format_args< Context > args, internal::locale_ref loc=internal::locale_ref())
 
template<typename T >
const voidptr (const T *p)
 
template<typename It >
arg_join< It, char > join (It begin, It end, string_view sep)
 
template<typename It >
arg_join< It, wchar_t > join (It begin, It end, wstring_view sep)
 
template<typename T >
std::string to_string (const T &value)
 
template<typename T >
std::wstring to_wstring (const T &value)
 
template<typename Char , std::size_t SIZE>
std::basic_string< Char > to_string (const basic_memory_buffer< Char, SIZE > &buf)
 
template<typename S , typename Char = FMT_CHAR(S)>
buffer_context< Char >
::type::iterator 
vformat_to (internal::basic_buffer< Char > &buf, const S &format_str, basic_format_args< typename buffer_context< Char >::type > args)
 
template<typename S , typename... Args, std::size_t SIZE = inline_buffer_size, typename Char = typename internal::char_t<S>::type>
buffer_context< Char >
::type::iterator 
format_to (basic_memory_buffer< Char, SIZE > &buf, const S &format_str, const Args &...args)
 
template<typename String , typename OutputIt , typename... Args>
std::enable_if
< internal::is_output_iterator
< OutputIt >::value, OutputIt >
::type 
vformat_to (OutputIt out, const String &format_str, typename format_args_t< OutputIt, FMT_CHAR(String)>::type args)
 
template<typename OutputIt , typename S , typename... Args>
std::enable_if
< internal::is_string< S >
::value
&&internal::is_output_iterator
< OutputIt >::value, OutputIt >
::type 
format_to (OutputIt out, const S &format_str, const Args &...args)
 
template<typename OutputIt , typename Char , typename... Args>
format_arg_store< typename
format_to_n_context< OutputIt,
Char >::type, Args...> 
make_format_to_n_args (const Args &...args)
 
template<typename OutputIt , typename Char , typename... Args>
std::enable_if
< internal::is_output_iterator
< OutputIt >::value,
format_to_n_result< OutputIt >
>::type 
vformat_to_n (OutputIt out, std::size_t n, basic_string_view< Char > format_str, typename format_to_n_args< OutputIt, Char >::type args)
 
template<typename OutputIt , typename S , typename... Args>
std::enable_if
< internal::is_string< S >
::value
&&internal::is_output_iterator
< OutputIt >::value,
format_to_n_result< OutputIt >
>::type 
format_to_n (OutputIt out, std::size_t n, const S &format_str, const Args &...args)
 
template<typename... Args>
std::size_t formatted_size (string_view format_str, const Args &...args)
 

Macro Definition Documentation

#define FMT_ALWAYS_INLINE

Definition at line 913 of file format.h.

#define FMT_CLANG_VERSION   0

Definition at line 43 of file format.h.

#define FMT_CUDA_VERSION   0

Definition at line 57 of file format.h.

#define FMT_FUNC

Definition at line 3701 of file format.h.

#define FMT_HAS_BUILTIN (   x)    0

Definition at line 91 of file format.h.

#define FMT_ICC_VERSION   0

Definition at line 51 of file format.h.

#define FMT_SECURE_SCL   0

Definition at line 81 of file format.h.

#define FMT_STRING (   s)
Value:
[] { \
typedef typename std::remove_cv<std::remove_pointer< \
struct str : fmt::compile_string { \
typedef ct char_type; \
FMT_CONSTEXPR operator fmt::basic_string_view<ct>() const { \
return {s, sizeof(s) / sizeof(ct) - 1}; \
} \
}; \
return str{}; \
}()
GLdouble s
Definition: glew.h:1390
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
#define FMT_CONSTEXPR
Definition: core.h:69
type
Definition: core.h:528

Definition at line 3667 of file format.h.

#define FMT_THROW (   x)    throw x

Definition at line 115 of file format.h.

#define FMT_UDL_TEMPLATE   0

Definition at line 144 of file format.h.

#define FMT_USE_EXTERN_TEMPLATES
Value:
((FMT_CLANG_VERSION >= 209 && __cplusplus >= 201103L) || \
#define FMT_CLANG_VERSION
Definition: format.h:43
#define FMT_GCC_VERSION
Definition: core.h:43
#define FMT_HAS_GXX_CXX11
Definition: core.h:49

Definition at line 149 of file format.h.

#define FMT_USE_GRISU   0

Definition at line 165 of file format.h.

#define FMT_USE_TRAILING_RETURN   0

Definition at line 161 of file format.h.

#define FMT_USE_USER_DEFINED_LITERALS   0

Definition at line 131 of file format.h.

#define FMT_USE_WINDOWS_H   0

Definition at line 1115 of file format.h.

Typedef Documentation

Definition at line 1201 of file format.h.

Definition at line 550 of file format.h.

Definition at line 551 of file format.h.

Definition at line 362 of file format.h.

Enumeration Type Documentation

anonymous enum
Enumerator
inline_buffer_size 

Definition at line 431 of file format.h.

anonymous enum
Enumerator
SIGN_FLAG 
PLUS_FLAG 
MINUS_FLAG 
HASH_FLAG 

Definition at line 1170 of file format.h.

enum alignment
Enumerator
ALIGN_DEFAULT 
ALIGN_LEFT 
ALIGN_RIGHT 
ALIGN_CENTER 
ALIGN_NUMERIC 

Definition at line 1165 of file format.h.

enum char8_t : unsigned char

Definition at line 407 of file format.h.

Function Documentation

template<typename T >
void format_decimal ( char *&  buffer,
value 
)
inline

Definition at line 3045 of file format.h.

FMT_API void format_system_error ( internal::buffer out,
int  error_code,
fmt::string_view  message 
)

Formats an error returned by an operating system or a language runtime, for example a file opening error, and writes it to out in the following form:

.. parsed-literal:: <message>*: *<system-message>*

where *<message>* is the passed message and *<system-message>* is the system message corresponding to the error code. error_code* is a system error code as given by errno. If error_code is not a valid error code such as -1, the system message may look like "Unknown error -1" and is platform-dependent.

template<typename S , typename... Args, std::size_t SIZE = inline_buffer_size, typename Char = typename internal::char_t<S>::type>
buffer_context<Char>::type::iterator format_to ( basic_memory_buffer< Char, SIZE > &  buf,
const S &  format_str,
const Args &...  args 
)
inline

Definition at line 3406 of file format.h.

template<typename OutputIt , typename S , typename... Args>
std::enable_if< internal::is_string<S>::value && internal::is_output_iterator<OutputIt>::value, OutputIt>::type format_to ( OutputIt  out,
const S &  format_str,
const Args &...  args 
)
inline

Formats arguments, writes the result to the output iterator out and returns the iterator past the end of the output range.

Example**::

std::vector<char> out; fmt::format_to(std::back_inserter(out), "{}", 42);

Definition at line 3496 of file format.h.

template<typename OutputIt , typename S , typename... Args>
std::enable_if< internal::is_string<S>::value && internal::is_output_iterator<OutputIt>::value, format_to_n_result<OutputIt> >::type format_to_n ( OutputIt  out,
std::size_t  n,
const S &  format_str,
const Args &...  args 
)
inline

Formats arguments, writes up to n characters of the result to the output iterator out and returns the total output size and the iterator past the end of the output range.

Definition at line 3553 of file format.h.

template<typename... Args>
std::size_t formatted_size ( string_view  format_str,
const Args &...  args 
)
inline

Returns the number of characters in the output of format(format_str, args...).

Definition at line 3577 of file format.h.

template<typename It >
arg_join<It, char> join ( It  begin,
It  end,
string_view  sep 
)

Definition at line 3326 of file format.h.

template<typename It >
arg_join<It, wchar_t> join ( It  begin,
It  end,
wstring_view  sep 
)

Definition at line 3331 of file format.h.

template<typename OutputIt , typename Char , typename... Args>
format_arg_store< typename format_to_n_context<OutputIt, Char>::type, Args...> make_format_to_n_args ( const Args &...  args)
inline

Definition at line 3525 of file format.h.

template<typename T >
const void* ptr ( const T *  p)
inline
Examples:
standalone/tiledevice.C.

Definition at line 3292 of file format.h.

FMT_API void report_system_error ( int  error_code,
string_view  message 
)
template<typename T >
std::string to_string ( const T &  value)

Converts value to std::string using the default format for type T. It doesn't support user-defined types with custom formatters.

Example**::

#include <fmt/format.h>

std::string answer = fmt::to_string(42);

Definition at line 3363 of file format.h.

template<typename Char , std::size_t SIZE>
std::basic_string<Char> to_string ( const basic_memory_buffer< Char, SIZE > &  buf)

Definition at line 3382 of file format.h.

template<typename T >
std::wstring to_wstring ( const T &  value)

Converts value to std::wstring using the default format for type T.

Definition at line 3374 of file format.h.

template<typename ArgFormatter , typename Char , typename Context >
Context::iterator vformat_to ( typename ArgFormatter::range  out,
basic_string_view< Char >  format_str,
basic_format_args< Context >  args,
internal::locale_ref  loc = internal::locale_ref() 
)

Formats arguments and writes the output to the range.

Definition at line 3278 of file format.h.

template<typename S , typename Char = FMT_CHAR(S)>
buffer_context<Char>::type::iterator vformat_to ( internal::basic_buffer< Char > &  buf,
const S &  format_str,
basic_format_args< typename buffer_context< Char >::type args 
)
inline

Definition at line 3396 of file format.h.

template<typename String , typename OutputIt , typename... Args>
std::enable_if<internal::is_output_iterator<OutputIt>::value, OutputIt>::type vformat_to ( OutputIt  out,
const String &  format_str,
typename format_args_t< OutputIt, FMT_CHAR(String)>::type  args 
)
inline

Definition at line 3474 of file format.h.

template<typename OutputIt , typename Char , typename... Args>
std::enable_if< internal::is_output_iterator<OutputIt>::value, format_to_n_result<OutputIt> >::type vformat_to_n ( OutputIt  out,
std::size_t  n,
basic_string_view< Char >  format_str,
typename format_to_n_args< OutputIt, Char >::type  args 
)
inline

Definition at line 3533 of file format.h.