Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
ded0a3bb
Commit
ded0a3bb
authored
Jul 03, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internalize undocumented basic_writer
parent
83174f2a
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1187 additions
and
1193 deletions
+1187
-1193
include/fmt/chrono.h
include/fmt/chrono.h
+1
-1
include/fmt/format-inl.h
include/fmt/format-inl.h
+4
-5
include/fmt/format.h
include/fmt/format.h
+1177
-1178
test/format-test.cc
test/format-test.cc
+5
-9
No files found.
include/fmt/chrono.h
View file @
ded0a3bb
...
...
@@ -803,7 +803,7 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
basic_memory_buffer
<
Char
>
buf
;
auto
out
=
std
::
back_inserter
(
buf
);
using
range
=
internal
::
output_range
<
decltype
(
ctx
.
out
()),
Char
>
;
basic_writer
<
range
>
w
(
range
(
ctx
.
out
()));
internal
::
basic_writer
<
range
>
w
(
range
(
ctx
.
out
()));
internal
::
handle_dynamic_spec
<
internal
::
width_checker
>
(
spec
.
width_
,
width_ref
,
ctx
,
format_str
.
begin
());
internal
::
handle_dynamic_spec
<
internal
::
precision_checker
>
(
...
...
include/fmt/format-inl.h
View file @
ded0a3bb
...
...
@@ -164,7 +164,7 @@ FMT_FUNC void format_error_code(internal::buffer<char>& out, int error_code,
++
error_code_size
;
}
error_code_size
+=
internal
::
to_unsigned
(
internal
::
count_digits
(
abs_value
));
writer
w
(
out
);
internal
::
writer
w
(
out
);
if
(
message
.
size
()
<=
inline_buffer_size
-
error_code_size
)
{
w
.
write
(
message
);
w
.
write
(
SEP
);
...
...
@@ -245,10 +245,9 @@ template <typename T>
int
format_float
(
char
*
buf
,
std
::
size_t
size
,
const
char
*
format
,
int
precision
,
T
value
)
{
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if
(
precision
>
100000
)
{
if
(
precision
>
100000
)
throw
std
::
runtime_error
(
"fuzz mode - avoid large allocation inside snprintf"
);
}
#endif
// Suppress the warning about nonliteral format string.
auto
snprintf_ptr
=
FMT_SNPRINTF
;
...
...
@@ -898,7 +897,7 @@ FMT_FUNC void internal::format_windows_error(internal::buffer<char>& out,
if
(
result
!=
0
)
{
utf16_to_utf8
utf8_message
;
if
(
utf8_message
.
convert
(
system_message
)
==
ERROR_SUCCESS
)
{
writer
w
(
out
);
internal
::
writer
w
(
out
);
w
.
write
(
message
);
w
.
write
(
": "
);
w
.
write
(
utf8_message
);
...
...
@@ -927,7 +926,7 @@ FMT_FUNC void format_system_error(internal::buffer<char>& out, int error_code,
int
result
=
internal
::
safe_strerror
(
error_code
,
system_message
,
buf
.
size
());
if
(
result
==
0
)
{
writer
w
(
out
);
internal
::
writer
w
(
out
);
w
.
write
(
message
);
w
.
write
(
": "
);
w
.
write
(
system_message
);
...
...
include/fmt/format.h
View file @
ded0a3bb
This diff is collapsed.
Click to expand it.
test/format-test.cc
View file @
ded0a3bb
...
...
@@ -34,7 +34,7 @@
using
std
::
size_t
;
using
fmt
::
basic_memory_buffer
;
using
fmt
::
basic_writer
;
using
fmt
::
internal
::
basic_writer
;
using
fmt
::
format
;
using
fmt
::
format_error
;
using
fmt
::
memory_buffer
;
...
...
@@ -100,7 +100,7 @@ template <typename Char, typename T>
::
testing
::
AssertionResult
check_write
(
const
T
&
value
,
const
char
*
type
)
{
fmt
::
basic_memory_buffer
<
Char
>
buffer
;
using
range
=
fmt
::
internal
::
buffer_range
<
Char
>
;
fmt
::
basic_writer
<
range
>
writer
(
buffer
);
basic_writer
<
range
>
writer
(
buffer
);
writer
.
write
(
value
);
std
::
basic_string
<
Char
>
actual
=
to_string
(
buffer
);
std
::
basic_string
<
Char
>
expected
;
...
...
@@ -582,7 +582,7 @@ TEST(StringViewTest, Ctor) {
TEST
(
WriterTest
,
Data
)
{
memory_buffer
buf
;
fmt
::
writer
w
(
buf
);
fmt
::
internal
::
writer
w
(
buf
);
w
.
write
(
42
);
EXPECT_EQ
(
"42"
,
to_string
(
buf
));
}
...
...
@@ -649,13 +649,13 @@ TEST(WriterTest, WriteLongDouble) {
TEST
(
WriterTest
,
WriteDoubleAtBufferBoundary
)
{
memory_buffer
buf
;
fmt
::
writer
writer
(
buf
);
fmt
::
internal
::
writer
writer
(
buf
);
for
(
int
i
=
0
;
i
<
100
;
++
i
)
writer
.
write
(
1.23456789
);
}
TEST
(
WriterTest
,
WriteDoubleWithFilledBuffer
)
{
memory_buffer
buf
;
fmt
::
writer
writer
(
buf
);
fmt
::
internal
::
writer
writer
(
buf
);
// Fill the buffer.
for
(
int
i
=
0
;
i
<
fmt
::
inline_buffer_size
;
++
i
)
writer
.
write
(
' '
);
writer
.
write
(
1.2
);
...
...
@@ -671,14 +671,10 @@ TEST(WriterTest, WriteWideChar) { CHECK_WRITE_WCHAR(L'a'); }
TEST
(
WriterTest
,
WriteString
)
{
CHECK_WRITE_CHAR
(
"abc"
);
CHECK_WRITE_WCHAR
(
"abc"
);
// The following line shouldn't compile:
// std::declval<fmt::basic_writer<fmt::buffer>>().write(L"abc");
}
TEST
(
WriterTest
,
WriteWideString
)
{
CHECK_WRITE_WCHAR
(
L"abc"
);
// The following line shouldn't compile:
// std::declval<fmt::basic_writer<fmt::wbuffer>>().write("abc");
}
TEST
(
FormatToTest
,
FormatWithoutArgs
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment