Skip to content

Commit 70aa9a8

Browse files
committed
Add options for digit separators and prefix skipping
1 parent 221a492 commit 70aa9a8

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

include/fast_float/float_common.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,25 @@ using from_chars_result = from_chars_result_t<char>;
7070

7171
template <typename UC> struct parse_options_t {
7272
constexpr explicit parse_options_t(chars_format fmt = chars_format::general,
73-
UC dot = UC('.'), int b = 10)
74-
: format(fmt), decimal_point(dot), base(b) {}
73+
UC dot = UC('.'), int b = 10,
74+
UC sep = UC('\0'), uint8_t opts = 0)
75+
: format(fmt), decimal_point(dot), base(b), digit_separator(sep),
76+
format_options(opts) {}
7577

7678
/** Which number formats are accepted */
7779
chars_format format;
7880
/** The character used as decimal point */
7981
UC decimal_point;
8082
/** The base used for integers */
8183
int base;
84+
/** The character used as digit separator. Use '\0' to
85+
* disable */
86+
UC digit_separator;
87+
/** Additional format options (bitmask) */
88+
uint8_t format_options;
89+
90+
/** Option to skip prefixes like 0x, 0b */
91+
static constexpr uint8_t skip_prefix = 1;
8292
};
8393

8494
using parse_options = parse_options_t<char>;
@@ -199,12 +209,16 @@ using parse_options = parse_options_t<char>;
199209

200210
#ifndef FASTFLOAT_ASSERT
201211
#define FASTFLOAT_ASSERT(x) \
202-
{ ((void)(x)); }
212+
{ \
213+
((void)(x)); \
214+
}
203215
#endif
204216

205217
#ifndef FASTFLOAT_DEBUG_ASSERT
206218
#define FASTFLOAT_DEBUG_ASSERT(x) \
207-
{ ((void)(x)); }
219+
{ \
220+
((void)(x)); \
221+
}
208222
#endif
209223

210224
// rust style `try!()` macro, or `?` operator

0 commit comments

Comments
 (0)