souffle  2.0.2-371-g6315b36
Namespaces | Data Structures | Typedefs | Functions
tinyformat Namespace Reference

Namespaces

 detail
 

Data Structures

class  FormatList
 List of template arguments format(), held in a type-opaque way. More...
 

Typedefs

using FormatListRef = const FormatList &
 Reference to type-opaque format list for passing to vformat() More...
 

Functions

std::string format (const char *fmt)
 
void format (std::ostream &out, const char *fmt)
 
template<typename T >
void formatValue (std::ostream &out, const char *, const char *fmtEnd, int ntrunc, const T &value)
 Format a value into a stream, delegating to operator<< by default. More...
 
detail::FormatListN< 0 > makeFormatList ()
 
void printf (const char *fmt)
 
void printfln (const char *fmt)
 
void vformat (std::ostream &out, const char *fmt, FormatListRef list)
 Format list of arguments to the stream according to the given format string. More...
 

Typedef Documentation

◆ FormatListRef

using tinyformat::FormatListRef = typedef const FormatList &

Reference to type-opaque format list for passing to vformat()

Definition at line 956 of file tinyformat.h.

Function Documentation

◆ format() [1/2]

std::string tinyformat::format ( const char *  fmt)
inline

Definition at line 1094 of file tinyformat.h.

1095 {
1096  std::ostringstream oss;
1097  format(oss, fmt);
1098  return oss.str();
1099 }

References format().

Here is the call graph for this function:

◆ format() [2/2]

void tinyformat::format ( std::ostream &  out,
const char *  fmt 
)
inline

◆ formatValue()

template<typename T >
void tinyformat::formatValue ( std::ostream &  out,
const char *  ,
const char *  fmtEnd,
int  ntrunc,
const T &  value 
)
inline

Format a value into a stream, delegating to operator<< by default.

Users may override this for their own types. When this function is called, the stream flags will have been modified according to the format string. The format specification is provided in the range [fmtBegin, fmtEnd). For truncating conversions, ntrunc is set to the desired maximum number of characters, for example "%.7s" calls formatValue with ntrunc = 7.

By default, formatValue() uses the usual stream insertion operator operator<< to format the type T, with special cases for the c and p conversions.

Definition at line 328 of file tinyformat.h.

330 {
331 #ifndef TINYFORMAT_ALLOW_WCHAR_STRINGS
332  // Since we don't support printing of wchar_t using "%ls", make it fail at
333  // compile time in preference to printing as a void* at runtime.
334  using DummyType = typename detail::is_wchar<T>::tinyformat_wchar_is_not_supported;
335  (void) DummyType(); // avoid unused type warning with gcc-4.8
336 #endif
337  // The mess here is to support the %c and %p conversions: if these
338  // conversions are active we try to convert the type to a char or const
339  // void* respectively and format that instead of the value itself. For the
340  // %p conversion it's important to avoid dereferencing the pointer, which
341  // could otherwise lead to a crash when printing a dangling (const char*).
342  const bool canConvertToChar = detail::is_convertible<T,char>::value;
343  const bool canConvertToVoidPtr = detail::is_convertible<T, const void*>::value;
344  if (canConvertToChar && *(fmtEnd-1) == 'c')
345  detail::formatValueAsType<T, char>::invoke(out, value);
346  else if (canConvertToVoidPtr && *(fmtEnd-1) == 'p')
347  detail::formatValueAsType<T, const void*>::invoke(out, value);
348 #ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND
349  else if (detail::formatZeroIntegerWorkaround<T>::invoke(out, value)) /**/;
350 #endif
351  else if (ntrunc >= 0) {
352  // Take care not to overread C strings in truncating conversions like
353  // "%.4s" where at most 4 characters may be read.
354  detail::formatTruncated(out, value, ntrunc);
355  }
356  else
357  out << value;
358 }

References tinyformat::detail::formatTruncated().

Referenced by tinyformat::detail::FormatArg::formatImpl().

Here is the call graph for this function:

◆ makeFormatList()

detail::FormatListN<0> tinyformat::makeFormatList ( )
inline

Definition at line 1028 of file tinyformat.h.

1029 {
1030  return detail::FormatListN<0>();
1031 }

Referenced by format().

◆ printf()

void tinyformat::printf ( const char *  fmt)
inline

Definition at line 1101 of file tinyformat.h.

1102 {
1103  format(std::cout, fmt);
1104 }

References format().

Referenced by configuration(), graphBySize(), graphByTime(), help(), id(), iterRel(), iterRul(), memoryUsage(), rel(), relRul(), rul(), souffle::profile::Tui::runCommand(), top(), usage(), verAtoms(), verGraph(), and verRul().

Here is the call graph for this function:

◆ printfln()

void tinyformat::printfln ( const char *  fmt)
inline

Definition at line 1106 of file tinyformat.h.

1107 {
1108  format(std::cout, fmt);
1109  std::cout << '\n';
1110 }

References format().

Here is the call graph for this function:

◆ vformat()

void tinyformat::vformat ( std::ostream &  out,
const char *  fmt,
FormatListRef  list 
)
inline

Format list of arguments to the stream according to the given format string.

The name vformat() is chosen for the semantic similarity to vprintf(): the list of format arguments is held in a single function argument.

Definition at line 1047 of file tinyformat.h.

1048 {
1049  detail::formatImpl(out, fmt, list.m_args, list.m_N);
1050 }

References tinyformat::detail::formatImpl(), tinyformat::FormatList::m_args, and tinyformat::FormatList::m_N.

Referenced by format().

Here is the call graph for this function:
tinyformat::detail::formatImpl
void formatImpl(std::ostream &out, const char *fmt, const detail::FormatArg *args, int numArgs)
Definition: tinyformat.h:867
tinyformat::vformat
void vformat(std::ostream &out, const char *fmt, FormatListRef list)
Format list of arguments to the stream according to the given format string.
Definition: tinyformat.h:1047
tinyformat::format
std::string format(const char *fmt)
Definition: tinyformat.h:1094
tinyformat::makeFormatList
detail::FormatListN< 0 > makeFormatList()
Definition: tinyformat.h:1028
tinyformat::detail::formatTruncated
void formatTruncated(std::ostream &out, const T &value, int ntrunc)
Definition: tinyformat.h:287