Skip to content

Commit ef2cf31

Browse files
committed
String formatting overhaul: Parsing of std::format strings
C++20 adds std::format to the STL as a type-safe and more flexible alternative to printf and IO streams. fly::BasicString::format was also an alternative, but used a very tiny subset of printf-styled formatting strings. This adds (nearly) fully compliant parsing of the new std::format style of strings. This style is not used by BasicString yet. Unsupported features include nested replacement fields and a type analogous to std::formatter (rather, the ostream<< operator is still used). Unlike std::format, this implementation supports all character types (not just char- and wchar_t-based strings). This implementation also supports full validation of the format string at compile time with compilers that support consteval. Other compilers will drop invalid format strings at runtime.
1 parent 0dd9659 commit ef2cf31

File tree

6 files changed

+2266
-0
lines changed

6 files changed

+2266
-0
lines changed

build/win/libfly/libfly.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
<ClInclude Include="..\..\..\fly\types\string\detail\string_classifier.hpp" />
223223
<ClInclude Include="..\..\..\fly\types\string\detail\string_converter.hpp" />
224224
<ClInclude Include="..\..\..\fly\types\string\detail\string_formatter.hpp" />
225+
<ClInclude Include="..\..\..\fly\types\string\detail\string_formatter_types.hpp" />
225226
<ClInclude Include="..\..\..\fly\types\string\detail\string_lexer.hpp" />
226227
<ClInclude Include="..\..\..\fly\types\string\detail\string_streamer.hpp" />
227228
<ClInclude Include="..\..\..\fly\types\string\detail\string_streamer_traits.hpp" />

build/win/libfly/libfly.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@
277277
<ClInclude Include="..\..\..\fly\types\string\detail\string_formatter.hpp">
278278
<Filter>types\string\detail</Filter>
279279
</ClInclude>
280+
<ClInclude Include="..\..\..\fly\types\string\detail\string_formatter_types.hpp">
281+
<Filter>types\string\detail</Filter>
282+
</ClInclude>
280283
<ClInclude Include="..\..\..\fly\types\string\detail\string_lexer.hpp">
281284
<Filter>types\string\detail</Filter>
282285
</ClInclude>

build/win/libfly_unit_tests/libfly_unit_tests.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@
246246
<ClCompile Include="..\..\..\test\types\string_classifier.cpp" />
247247
<ClCompile Include="..\..\..\test\types\string_converter.cpp" />
248248
<ClCompile Include="..\..\..\test\types\string_formatter.cpp" />
249+
<ClCompile Include="..\..\..\test\types\string_formatter_types.cpp" />
249250
<ClCompile Include="..\..\..\test\types\string_lexer.cpp" />
250251
<ClCompile Include="..\..\..\test\types\string_traits.cpp" />
251252
<ClCompile Include="..\..\..\test\types\string_unicode.cpp" />

build/win/libfly_unit_tests/libfly_unit_tests.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
<ClCompile Include="..\..\..\test\types\string_formatter.cpp">
138138
<Filter>types</Filter>
139139
</ClCompile>
140+
<ClCompile Include="..\..\..\test\types\string_formatter_types.cpp">
141+
<Filter>types</Filter>
142+
</ClCompile>
140143
<ClCompile Include="..\..\..\test\types\string_lexer.cpp">
141144
<Filter>types</Filter>
142145
</ClCompile>

0 commit comments

Comments
 (0)