text
stringlengths 0
2.2M
|
---|
precision = to<int>(StringPiece(d, p));
|
if (p != end && *p == '.') {
|
trailingDot = true;
|
++p;
|
}
|
} else {
|
trailingDot = true;
|
}
|
if (p == end) {
|
return;
|
}
|
}
|
presentation = *p;
|
if (++p == end) {
|
return;
|
}
|
}
|
error("extra characters in format string");
|
}
|
void FormatArg::validate(Type type) const {
|
enforce(keyEmpty(), "index not allowed");
|
switch (type) {
|
case Type::INTEGER:
|
enforce(
|
precision == kDefaultPrecision, "precision not allowed on integers");
|
break;
|
case Type::FLOAT:
|
enforce(
|
!basePrefix, "base prefix ('#') specifier only allowed on integers");
|
enforce(
|
!thousandsSeparator,
|
"thousands separator (',') only allowed on integers");
|
break;
|
case Type::OTHER:
|
enforce(
|
align != Align::PAD_AFTER_SIGN,
|
"'='alignment only allowed on numbers");
|
enforce(sign == Sign::DEFAULT, "sign specifier only allowed on numbers");
|
enforce(
|
!basePrefix, "base prefix ('#') specifier only allowed on integers");
|
enforce(
|
!thousandsSeparator,
|
"thousands separator (',') only allowed on integers");
|
break;
|
}
|
}
|
namespace detail {
|
void insertThousandsGroupingUnsafe(char* start_buffer, char** end_buffer) {
|
auto remaining_digits = uint32_t(*end_buffer - start_buffer);
|
uint32_t separator_size = (remaining_digits - 1) / 3;
|
uint32_t result_size = remaining_digits + separator_size;
|
*end_buffer = *end_buffer + separator_size;
|
// get the end of the new string with the separators
|
uint32_t buffer_write_index = result_size - 1;
|
uint32_t buffer_read_index = remaining_digits - 1;
|
start_buffer[buffer_write_index + 1] = 0;
|
bool done = false;
|
uint32_t next_group_size = 3;
|
while (!done) {
|
uint32_t current_group_size = std::max<uint32_t>(
|
1, std::min<uint32_t>(remaining_digits, next_group_size));
|
// write out the current group's digits to the buffer index
|
for (uint32_t i = 0; i < current_group_size; i++) {
|
start_buffer[buffer_write_index--] = start_buffer[buffer_read_index--];
|
}
|
// if not finished, write the separator before the next group
|
if (buffer_write_index < buffer_write_index + 1) {
|
start_buffer[buffer_write_index--] = ',';
|
} else {
|
done = true;
|
}
|
remaining_digits -= current_group_size;
|
}
|
}
|
} // namespace detail
|
FormatKeyNotFoundException::FormatKeyNotFoundException(StringPiece key)
|
: std::out_of_range(kMessagePrefix.str() + key.str()) {}
|
constexpr StringPiece const FormatKeyNotFoundException::kMessagePrefix;
|
} // namespace folly
|
/*
|
==============================================================================
|
This file is part of the JUCE library.
|
Copyright (c) 2020 - Raw Material Software Limited
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.