#include <folly/Format.h>
+#include <folly/ConstexprMath.h>
#include <folly/CppAttributes.h>
-#include <folly/portability/Constexpr.h>
#include <double-conversion/double-conversion.h>
if (*p == ':') {
// parse format spec
- if (++p == end) return;
+ if (++p == end) {
+ return;
+ }
// fill/align, or just align
Align a;
fill = *p;
align = a;
p += 2;
- if (p == end) return;
+ if (p == end) {
+ return;
+ }
} else if ((a = formatAlignTable[static_cast<unsigned char>(*p)]) !=
Align::INVALID) {
align = a;
- if (++p == end) return;
+ if (++p == end) {
+ return;
+ }
}
Sign s;
unsigned char uSign = static_cast<unsigned char>(*p);
if ((s = formatSignTable[uSign]) != Sign::INVALID) {
sign = s;
- if (++p == end) return;
+ if (++p == end) {
+ return;
+ }
}
if (*p == '#') {
basePrefix = true;
- if (++p == end) return;
+ if (++p == end) {
+ return;
+ }
}
if (*p == '0') {
enforce(align == Align::DEFAULT, "alignment specified twice");
fill = '0';
align = Align::PAD_AFTER_SIGN;
- if (++p == end) return;
+ if (++p == end) {
+ return;
+ }
}
auto readInt = [&] {
width = kDynamicWidth;
++p;
- if (p == end) return;
+ if (p == end) {
+ return;
+ }
- if (*p >= '0' && *p <= '9') widthIndex = readInt();
+ if (*p >= '0' && *p <= '9') {
+ widthIndex = readInt();
+ }
- if (p == end) return;
+ if (p == end) {
+ return;
+ }
} else if (*p >= '0' && *p <= '9') {
width = readInt();
- if (p == end) return;
+ if (p == end) {
+ return;
+ }
}
if (*p == ',') {
thousandsSeparator = true;
- if (++p == end) return;
+ if (++p == end) {
+ return;
+ }
}
if (*p == '.') {
trailingDot = true;
}
- if (p == end) return;
+ if (p == end) {
+ return;
+ }
}
presentation = *p;
- if (++p == end) return;
+ if (++p == end) {
+ return;
+ }
}
error("extra characters in format string");
}
} // namespace detail
+FormatKeyNotFoundException::FormatKeyNotFoundException(StringPiece key)
+ : std::out_of_range(kMessagePrefix.str() + key.str()) {}
+
+constexpr StringPiece const FormatKeyNotFoundException::kMessagePrefix;
+
+namespace detail {
+[[noreturn]] void throwFormatKeyNotFoundException(StringPiece key) {
+ throw FormatKeyNotFoundException(key);
+}
+} // namespace detail
+
} // namespace folly