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
4fd9a00f
Commit
4fd9a00f
authored
Sep 03, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify ostream interface
parent
56815638
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
21 deletions
+10
-21
include/fmt/ostream.h
include/fmt/ostream.h
+10
-21
No files found.
include/fmt/ostream.h
View file @
4fd9a00f
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
FMT_BEGIN_NAMESPACE
FMT_BEGIN_NAMESPACE
template
<
typename
Char
>
class
basic_printf_parse_context
;
template
<
typename
OutputIt
,
typename
Char
>
class
basic_printf_context
;
template
<
typename
OutputIt
,
typename
Char
>
class
basic_printf_context
;
namespace
detail
{
namespace
detail
{
...
@@ -27,7 +26,7 @@ template <class Char> class formatbuf : public std::basic_streambuf<Char> {
...
@@ -27,7 +26,7 @@ template <class Char> class formatbuf : public std::basic_streambuf<Char> {
buffer
<
Char
>&
buffer_
;
buffer
<
Char
>&
buffer_
;
public:
public:
formatbuf
(
buffer
<
Char
>&
buf
)
:
buffer_
(
buf
)
{}
explicit
formatbuf
(
buffer
<
Char
>&
buf
)
:
buffer_
(
buf
)
{}
protected:
protected:
// The put area is always empty. This makes the implementation simpler and has
// The put area is always empty. This makes the implementation simpler and has
...
@@ -36,7 +35,7 @@ template <class Char> class formatbuf : public std::basic_streambuf<Char> {
...
@@ -36,7 +35,7 @@ template <class Char> class formatbuf : public std::basic_streambuf<Char> {
// call to sputc always results in a (virtual) call to overflow. There is no
// call to sputc always results in a (virtual) call to overflow. There is no
// disadvantage here for sputn since this always results in a call to xsputn.
// disadvantage here for sputn since this always results in a call to xsputn.
auto
overflow
(
int_type
ch
=
traits_type
::
eof
())
->
int_type
FMT_OVERRIDE
{
auto
overflow
(
int_type
ch
=
traits_type
::
eof
())
->
int_type
override
{
if
(
!
traits_type
::
eq_int_type
(
ch
,
traits_type
::
eof
()))
if
(
!
traits_type
::
eq_int_type
(
ch
,
traits_type
::
eof
()))
buffer_
.
push_back
(
static_cast
<
Char
>
(
ch
));
buffer_
.
push_back
(
static_cast
<
Char
>
(
ch
));
return
ch
;
return
ch
;
...
@@ -79,6 +78,7 @@ struct is_streamable<
...
@@ -79,6 +78,7 @@ struct is_streamable<
!
std
::
is_enum
<
T
>::
value
)
>>
:
std
::
false_type
{};
!
std
::
is_enum
<
T
>::
value
)
>>
:
std
::
false_type
{};
// Write the content of buf to os.
// Write the content of buf to os.
// It is a separate function rather than a part of vprint to simplify testing.
template
<
typename
Char
>
template
<
typename
Char
>
void
write_buffer
(
std
::
basic_ostream
<
Char
>&
os
,
buffer
<
Char
>&
buf
)
{
void
write_buffer
(
std
::
basic_ostream
<
Char
>&
os
,
buffer
<
Char
>&
buf
)
{
const
Char
*
buf_data
=
buf
.
data
();
const
Char
*
buf_data
=
buf
.
data
();
...
@@ -96,8 +96,8 @@ void write_buffer(std::basic_ostream<Char>& os, buffer<Char>& buf) {
...
@@ -96,8 +96,8 @@ void write_buffer(std::basic_ostream<Char>& os, buffer<Char>& buf) {
template
<
typename
Char
,
typename
T
>
template
<
typename
Char
,
typename
T
>
void
format_value
(
buffer
<
Char
>&
buf
,
const
T
&
value
,
void
format_value
(
buffer
<
Char
>&
buf
,
const
T
&
value
,
locale_ref
loc
=
locale_ref
())
{
locale_ref
loc
=
locale_ref
())
{
formatbuf
<
Char
>
format_buf
(
buf
);
auto
&&
format_buf
=
formatbuf
<
Char
>
(
buf
);
std
::
basic_ostream
<
Char
>
output
(
&
format_buf
);
auto
&&
output
=
std
::
basic_ostream
<
Char
>
(
&
format_buf
);
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
if
(
loc
)
output
.
imbue
(
loc
.
get
<
std
::
locale
>
());
if
(
loc
)
output
.
imbue
(
loc
.
get
<
std
::
locale
>
());
#endif
#endif
...
@@ -110,33 +110,22 @@ void format_value(buffer<Char>& buf, const T& value,
...
@@ -110,33 +110,22 @@ void format_value(buffer<Char>& buf, const T& value,
template
<
typename
T
,
typename
Char
>
template
<
typename
T
,
typename
Char
>
struct
fallback_formatter
<
T
,
Char
,
enable_if_t
<
is_streamable
<
T
,
Char
>::
value
>>
struct
fallback_formatter
<
T
,
Char
,
enable_if_t
<
is_streamable
<
T
,
Char
>::
value
>>
:
private
formatter
<
basic_string_view
<
Char
>
,
Char
>
{
:
private
formatter
<
basic_string_view
<
Char
>
,
Char
>
{
FMT_CONSTEXPR
auto
parse
(
basic_format_parse_context
<
Char
>&
ctx
)
using
formatter
<
basic_string_view
<
Char
>
,
Char
>::
parse
;
->
decltype
(
ctx
.
begin
())
{
return
formatter
<
basic_string_view
<
Char
>
,
Char
>::
parse
(
ctx
);
}
// DEPRECATED!
template
<
typename
ParseCtx
,
FMT_ENABLE_IF
(
std
::
is_same
<
ParseCtx
,
basic_printf_parse_context
<
Char
>
>::
value
)
>
auto
parse
(
ParseCtx
&
ctx
)
->
decltype
(
ctx
.
begin
())
{
return
ctx
.
begin
();
}
template
<
typename
OutputIt
>
template
<
typename
OutputIt
>
auto
format
(
const
T
&
value
,
basic_format_context
<
OutputIt
,
Char
>&
ctx
)
auto
format
(
const
T
&
value
,
basic_format_context
<
OutputIt
,
Char
>&
ctx
)
->
OutputIt
{
->
OutputIt
{
basic_memory_buffer
<
Char
>
buffer
;
auto
buffer
=
basic_memory_buffer
<
Char
>
()
;
format_value
(
buffer
,
value
,
ctx
.
locale
());
format_value
(
buffer
,
value
,
ctx
.
locale
());
basic_string_view
<
Char
>
str
(
buffer
.
data
(),
buffer
.
size
());
return
formatter
<
basic_string_view
<
Char
>
,
Char
>::
format
(
return
formatter
<
basic_string_view
<
Char
>
,
Char
>::
format
(
str
,
ctx
);
{
buffer
.
data
(),
buffer
.
size
()}
,
ctx
);
}
}
// DEPRECATED!
// DEPRECATED!
template
<
typename
OutputIt
>
template
<
typename
OutputIt
>
auto
format
(
const
T
&
value
,
basic_printf_context
<
OutputIt
,
Char
>&
ctx
)
auto
format
(
const
T
&
value
,
basic_printf_context
<
OutputIt
,
Char
>&
ctx
)
->
OutputIt
{
->
OutputIt
{
basic_memory_buffer
<
Char
>
buffer
;
auto
buffer
=
basic_memory_buffer
<
Char
>
()
;
format_value
(
buffer
,
value
,
ctx
.
locale
());
format_value
(
buffer
,
value
,
ctx
.
locale
());
return
std
::
copy
(
buffer
.
begin
(),
buffer
.
end
(),
ctx
.
out
());
return
std
::
copy
(
buffer
.
begin
(),
buffer
.
end
(),
ctx
.
out
());
}
}
...
...
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