proxygen
|
#include <FormatArg.h>
Public Types | |
enum | Type { Type::INTEGER, Type::FLOAT, Type::OTHER } |
enum | Align : uint8_t { Align::DEFAULT, Align::LEFT, Align::RIGHT, Align::PAD_AFTER_SIGN, Align::CENTER, Align::INVALID } |
enum | Sign : uint8_t { Sign::DEFAULT, Sign::PLUS_OR_MINUS, Sign::MINUS, Sign::SPACE_OR_MINUS, Sign::INVALID } |
Public Member Functions | |
FormatArg (StringPiece sp) | |
void | validate (Type type) const |
template<typename... Args> | |
void | enforce (bool v, Args &&...args) const |
template<typename... Args> | |
std::string | errorStr (Args &&...args) const |
template<typename... Args> | |
void | error (Args &&...args) const |
template<bool emptyOk = false> | |
StringPiece | splitKey () |
bool | keyEmpty () const |
int | splitIntKey () |
void | setNextIntKey (int val) |
void | setNextKey (StringPiece val) |
Public Attributes | |
StringPiece | fullArgString |
char | fill |
Align | align |
Sign | sign |
bool | basePrefix |
bool | thousandsSeparator |
bool | trailingDot |
int | width |
int | widthIndex |
int | precision |
char | presentation |
Static Public Attributes | |
static constexpr char | kDefaultFill = '\0' |
static constexpr int | kDefaultWidth = -1 |
static constexpr int | kDynamicWidth = -2 |
static constexpr int | kNoIndex = -1 |
static constexpr int | kDefaultPrecision = -1 |
static constexpr char | kDefaultPresentation = '\0' |
Private Types | |
enum | NextKeyMode { NextKeyMode::NONE, NextKeyMode::INT, NextKeyMode::STRING } |
Private Member Functions | |
void | initSlow () |
template<bool emptyOk> | |
StringPiece | doSplitKey () |
Private Attributes | |
StringPiece | key_ |
int | nextIntKey_ |
StringPiece | nextKey_ |
NextKeyMode | nextKeyMode_ |
Parsed format argument.
Definition at line 37 of file FormatArg.h.
|
strong |
Alignment
Enumerator | |
---|---|
DEFAULT | |
LEFT | |
RIGHT | |
PAD_AFTER_SIGN | |
CENTER | |
INVALID |
Definition at line 101 of file FormatArg.h.
|
strongprivate |
|
strong |
Sign
Enumerator | |
---|---|
DEFAULT | |
PLUS_OR_MINUS | |
MINUS | |
SPACE_OR_MINUS | |
INVALID |
Definition at line 114 of file FormatArg.h.
|
strong |
Enumerator | |
---|---|
INTEGER | |
FLOAT | |
OTHER |
Definition at line 60 of file FormatArg.h.
|
inlineexplicit |
Parse a format argument from a string. Keeps a reference to the passed-in string – does not copy the given characters.
Definition at line 42 of file FormatArg.h.
References folly::Range< Iter >::empty().
|
inlineprivate |
Definition at line 228 of file FormatArg.h.
References b, folly::pushmi::operators::error(), folly::NONE, and STRING.
|
inline |
Throw an exception if the first argument is false. The exception message will contain the argument string as well as any passed-in arguments to enforce, formatted using folly::to<std::string>.
Definition at line 76 of file FormatArg.h.
References testing::Args(), folly::pushmi::operators::error(), string, and UNLIKELY.
Referenced by folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat(), and folly::FormatValue< double >::formatHelper().
|
inline |
Definition at line 217 of file FormatArg.h.
Referenced by folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat(), folly::BaseFormatter< Formatter< containerMode, Args... >, containerMode, Args... >::doFormatFrom(), folly::FormatValue< double >::formatHelper(), folly::BaseFormatter< Formatter< containerMode, Args... >, containerMode, Args... >::getSizeArgFrom(), and folly::BaseFormatter< Formatter< containerMode, Args... >, containerMode, Args... >::getValue().
|
inline |
|
private |
Definition at line 228 of file Format.cpp.
References a, b, c, folly::test::end(), folly::pushmi::operators::error(), folly::detail::formatAlignTable, folly::detail::formatSignTable, and s.
|
inline |
|
inline |
|
inline |
|
inline |
Split an key component from "key", which must be non-empty and a valid integer (an exception is thrown otherwise).
Definition at line 266 of file FormatArg.h.
References folly::pushmi::operators::error(), and folly::NONE.
Referenced by folly::FormatValue< dynamic >::format(), and folly::FormatValue< detail::DefaultValueWrapper< dynamic, V > >::format().
|
inline |
Split a key component from "key", which must be non-empty (an exception is thrown otherwise).
Definition at line 222 of file FormatArg.h.
Referenced by folly::FormatValue< dynamic >::format(), and folly::FormatValue< detail::DefaultValueWrapper< dynamic, V > >::format().
void folly::FormatArg::validate | ( | Type | type | ) | const |
Validate the argument for the given type; throws on error.
Definition at line 358 of file Format.cpp.
Referenced by folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::format(), folly::FormatValue< bool >::format(), and folly::FormatValue< double >::formatHelper().
Align folly::FormatArg::align |
Definition at line 109 of file FormatArg.h.
Referenced by folly::format_value::formatFormatter(), folly::format_value::formatNumber(), and folly::format_value::formatString().
bool folly::FormatArg::basePrefix |
Output base prefix (0 for octal, 0x for hex)
Definition at line 126 of file FormatArg.h.
Referenced by folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat().
char folly::FormatArg::fill |
Definition at line 96 of file FormatArg.h.
Referenced by folly::format_value::formatString().
StringPiece folly::FormatArg::fullArgString |
Full argument string, as passed in to the constructor.
Definition at line 90 of file FormatArg.h.
|
static |
Fill
Definition at line 95 of file FormatArg.h.
|
static |
Precision
Definition at line 150 of file FormatArg.h.
Referenced by folly::FormatValue< double >::formatHelper().
|
static |
Presentation
Definition at line 156 of file FormatArg.h.
Referenced by folly::FormatValue< double >::formatHelper().
|
static |
Field width and optional argument index
Definition at line 141 of file FormatArg.h.
|
static |
Definition at line 142 of file FormatArg.h.
|
private |
Definition at line 196 of file FormatArg.h.
|
static |
Definition at line 143 of file FormatArg.h.
|
private |
Definition at line 197 of file FormatArg.h.
|
private |
Definition at line 198 of file FormatArg.h.
|
private |
Definition at line 204 of file FormatArg.h.
int folly::FormatArg::precision |
Definition at line 151 of file FormatArg.h.
Referenced by folly::format_value::formatFormatter(), folly::FormatValue< double >::formatHelper(), folly::format_value::formatNumber(), and folly::format_value::formatString().
char folly::FormatArg::presentation |
Sign folly::FormatArg::sign |
Definition at line 121 of file FormatArg.h.
Referenced by folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat(), and folly::FormatValue< double >::formatHelper().
bool folly::FormatArg::thousandsSeparator |
Output thousands separator (comma)
Definition at line 131 of file FormatArg.h.
Referenced by folly::FormatValue< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type >::doFormat().
bool folly::FormatArg::trailingDot |
Force a trailing decimal on doubles which could be rendered as ints
Definition at line 136 of file FormatArg.h.
Referenced by folly::FormatValue< double >::formatHelper().
int folly::FormatArg::width |
Definition at line 144 of file FormatArg.h.
Referenced by folly::format_value::formatFormatter(), folly::format_value::formatNumber(), and folly::format_value::formatString().
int folly::FormatArg::widthIndex |
Definition at line 145 of file FormatArg.h.