Classes | Namespaces | Macros | Typedefs | Functions
format-inl.h File Reference
#include "format.h"
#include <string.h>
#include <cctype>
#include <cerrno>
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <cstring>
#include <locale>

Go to the source code of this file.

Classes

class  internal::fp
 
struct  internal::gen_digits_params
 
struct  internal::prettify_handler
 
struct  internal::fill
 
struct  internal::char_counter
 

Namespaces

 FMT_BEGIN_NAMESPACE
 
 internal
 

Macros

#define FMT_TRY   try
 
#define FMT_CATCH(x)   catch (x)
 
#define FMT_SNPRINTF   snprintf
 
#define FMT_SWPRINTF   swprintf
 
#define FMT_POWERS_OF_10(factor)
 
#define FMT_FALLTHROUGH
 

Typedefs

typedef void(* FMT_BEGIN_NAMESPACE::FormatFunc) (internal::buffer &, int, string_view)
 

Functions

fmt::internal::null strerror_r (int, char *,...)
 
fmt::internal::null strerror_s (char *, std::size_t,...)
 
int FMT_BEGIN_NAMESPACE::safe_strerror (int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT
 
void FMT_BEGIN_NAMESPACE::format_error_code (internal::buffer &out, int error_code, string_view message) FMT_NOEXCEPT
 
void FMT_BEGIN_NAMESPACE::report_error (FormatFunc func, int error_code, string_view message) FMT_NOEXCEPT
 
template<typename Char >
FMT_FUNC Char internal::thousands_sep_impl (locale_ref loc)
 
fp internal::operator- (fp x, fp y)
 
FMT_API fp internal::operator* (fp x, fp y)
 
FMT_API fp internal::get_cached_power (int min_exponent, int &pow10_exponent)
 
FMT_FUNC bool internal::grisu2_round (char *buf, int &size, int max_digits, uint64_t delta, uint64_t remainder, uint64_t exp, uint64_t diff, int &exp10)
 
FMT_FUNC bool internal::grisu2_gen_digits (char *buf, int &size, uint32_t hi, uint64_t lo, int &exp, uint64_t delta, const fp &one, const fp &diff, int max_digits)
 
template<typename Handler >
FMT_FUNC void internal::write_exponent (int exp, Handler &&h)
 
template<typename Handler >
FMT_FUNC void internal::grisu2_prettify (const gen_digits_params &params, int size, int exp, Handler &&handler)
 
FMT_FUNC gen_digits_params internal::process_specs (const core_format_specs &specs, int exp, buffer &buf)
 
template<typename Double >
FMT_FUNC std::enable_if< sizeof(Double)==sizeof(uint64_t), bool >::type internal::grisu2_format (Double value, buffer &buf, core_format_specs specs)
 
template<typename Double >
void internal::sprintf_format (Double value, internal::buffer &buf, core_format_specs spec)
 
FMT_FUNC void format_system_error (internal::buffer &out, int error_code, string_view message) FMT_NOEXCEPT
 
FMT_FUNC void report_system_error (int error_code, fmt::string_view message) FMT_NOEXCEPT
 
FMT_FUNC void vprint (std::FILE *f, string_view format_str, format_args args)
 
FMT_FUNC void vprint (std::FILE *f, wstring_view format_str, wformat_args args)
 
FMT_FUNC void vprint (string_view format_str, format_args args)
 
FMT_FUNC void vprint (wstring_view format_str, wformat_args args)
 

Macro Definition Documentation

#define FMT_CATCH (   x)    catch (x)

Definition at line 41 of file format-inl.h.

#define FMT_FALLTHROUGH

Definition at line 538 of file format-inl.h.

#define FMT_POWERS_OF_10 (   factor)
Value:
factor * 10, \
factor * 100, \
factor * 1000, \
factor * 10000, \
factor * 100000, \
factor * 1000000, \
factor * 10000000, \
factor * 100000000, \
factor * 1000000000

Definition at line 269 of file format-inl.h.

#define FMT_SNPRINTF   snprintf

Definition at line 70 of file format-inl.h.

#define FMT_SWPRINTF   swprintf

Definition at line 85 of file format-inl.h.

#define FMT_TRY   try

Definition at line 40 of file format-inl.h.

Function Documentation

FMT_FUNC 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.

Definition at line 906 of file format-inl.h.

907  {
908  FMT_TRY {
909  memory_buffer buf;
911  for (;;) {
912  char *system_message = &buf[0];
913  int result = safe_strerror(error_code, system_message, buf.size());
914  if (result == 0) {
915  writer w(out);
916  w.write(message);
917  w.write(": ");
918  w.write(system_message);
919  return;
920  }
921  if (result != ERANGE)
922  break; // Can't get error message, report error code instead.
923  buf.resize(buf.size() * 2);
924  }
925  } FMT_CATCH(...) {}
926  format_error_code(out, error_code, message);
927 }
#define FMT_TRY
Definition: format-inl.h:40
static QCString result
void format_error_code(internal::buffer &out, int error_code, string_view message) FMT_NOEXCEPT
Definition: format-inl.h:159
void resize(std::size_t new_size)
Definition: core.h:264
std::size_t size() const FMT_NOEXCEPT
Definition: core.h:250
#define FMT_CATCH(x)
Definition: format-inl.h:41
int safe_strerror(int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT
Definition: format-inl.h:99
FMT_FUNC void report_system_error ( int  error_code,
fmt::string_view  message 
)

Definition at line 933 of file format-inl.h.

934  {
936 }
void report_error(FormatFunc func, int error_code, string_view message) FMT_NOEXCEPT
Definition: format-inl.h:186
FMT_FUNC void format_system_error(internal::buffer &out, int error_code, string_view message) FMT_NOEXCEPT
Definition: format-inl.h:906
fmt::internal::null strerror_r ( int  ,
char *  ,
  ... 
)
inline

Definition at line 58 of file format-inl.h.

58  {
59  return fmt::internal::null<>();
60 }
fmt::internal::null strerror_s ( char *  ,
std::size_t  ,
  ... 
)
inline

Definition at line 61 of file format-inl.h.

61  {
62  return fmt::internal::null<>();
63 }
FMT_FUNC void vprint ( std::FILE *  f,
string_view  format_str,
format_args  args 
)

Definition at line 945 of file format-inl.h.

945  {
947  internal::vformat_to(buffer, format_str,
949  std::fwrite(buffer.data(), 1, buffer.size(), f);
950 }
T * data() FMT_NOEXCEPT
Definition: core.h:256
buffer_context< Char >::type::iterator vformat_to(internal::basic_buffer< Char > &buf, basic_string_view< Char > format_str, basic_format_args< typename buffer_context< Char >::type > args)
Definition: format.h:3233
internal::basic_buffer< FMT_CHAR(S)> buffer
Definition: printf.h:757
std::size_t size() const FMT_NOEXCEPT
Definition: core.h:250
FMT_FUNC void vprint ( std::FILE *  f,
wstring_view  format_str,
wformat_args  args 
)

Definition at line 952 of file format-inl.h.

952  {
954  internal::vformat_to(buffer, format_str, args);
955  std::fwrite(buffer.data(), sizeof(wchar_t), buffer.size(), f);
956 }
T * data() FMT_NOEXCEPT
Definition: core.h:256
buffer_context< Char >::type::iterator vformat_to(internal::basic_buffer< Char > &buf, basic_string_view< Char > format_str, basic_format_args< typename buffer_context< Char >::type > args)
Definition: format.h:3233
internal::basic_buffer< FMT_CHAR(S)> buffer
Definition: printf.h:757
std::size_t size() const FMT_NOEXCEPT
Definition: core.h:250
FMT_FUNC void vprint ( string_view  format_str,
format_args  args 
)

Definition at line 958 of file format-inl.h.

958  {
959  vprint(stdout, format_str, args);
960 }
FMT_FUNC void vprint(std::FILE *f, string_view format_str, format_args args)
Definition: format-inl.h:945
FMT_FUNC void vprint ( wstring_view  format_str,
wformat_args  args 
)

Definition at line 962 of file format-inl.h.

962  {
963  vprint(stdout, format_str, args);
964 }
FMT_FUNC void vprint(std::FILE *f, string_view format_str, format_args args)
Definition: format-inl.h:945