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
4ec88607
Commit
4ec88607
authored
Feb 18, 2017
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ArgFormatter -> arg_formatter
parent
50e71673
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
23 deletions
+23
-23
fmt/format.h
fmt/format.h
+8
-8
fmt/ostream.h
fmt/ostream.h
+1
-1
fmt/printf.h
fmt/printf.h
+3
-3
test/custom-formatter-test.cc
test/custom-formatter-test.cc
+9
-9
test/ostream-test.cc
test/ostream-test.cc
+2
-2
No files found.
fmt/format.h
View file @
4ec88607
...
...
@@ -381,10 +381,10 @@ template <typename Context>
class
basic_arg
;
template
<
typename
Char
>
class
ArgF
ormatter
;
class
arg_f
ormatter
;
template
<
typename
Char
>
class
PrintfArgF
ormatter
;
class
printf_arg_f
ormatter
;
template
<
typename
Char
>
class
basic_context
;
...
...
@@ -2016,7 +2016,7 @@ class context_base {
/** The default argument formatter. */
template
<
typename
Char
>
class
ArgF
ormatter
:
public
internal
::
ArgFormatterBase
<
Char
>
{
class
arg_f
ormatter
:
public
internal
::
ArgFormatterBase
<
Char
>
{
private:
basic_context
<
Char
>
&
ctx_
;
...
...
@@ -2033,8 +2033,8 @@ class ArgFormatter : public internal::ArgFormatterBase<Char> {
format specifier information for standard argument types.
\endrst
*/
ArgF
ormatter
(
basic_buffer
<
Char
>
&
buffer
,
basic_context
<
Char
>
&
ctx
,
format_specs
&
spec
)
arg_f
ormatter
(
basic_buffer
<
Char
>
&
buffer
,
basic_context
<
Char
>
&
ctx
,
format_specs
&
spec
)
:
internal
::
ArgFormatterBase
<
Char
>
(
buffer
,
spec
),
ctx_
(
ctx
)
{}
using
internal
::
ArgFormatterBase
<
Char
>::
operator
();
...
...
@@ -2277,7 +2277,7 @@ class basic_writer {
friend
class
internal
::
ArgFormatterBase
;
template
<
typename
Char_
>
friend
class
PrintfArgF
ormatter
;
friend
class
printf_arg_f
ormatter
;
public:
/**
...
...
@@ -2939,11 +2939,11 @@ void vformat_to(basic_buffer<Char> &buffer, BasicCStringRef<Char> format_str,
basic_args
<
Context
>
args
);
inline
void
vformat_to
(
buffer
&
buf
,
CStringRef
format_str
,
args
args
)
{
vformat_to
<
ArgF
ormatter
<
char
>>
(
buf
,
format_str
,
args
);
vformat_to
<
arg_f
ormatter
<
char
>>
(
buf
,
format_str
,
args
);
}
inline
void
vformat_to
(
wbuffer
&
buf
,
WCStringRef
format_str
,
wargs
args
)
{
vformat_to
<
ArgF
ormatter
<
wchar_t
>>
(
buf
,
format_str
,
args
);
vformat_to
<
arg_f
ormatter
<
wchar_t
>>
(
buf
,
format_str
,
args
);
}
template
<
typename
...
Args
>
...
...
fmt/ostream.h
View file @
4ec88607
...
...
@@ -86,7 +86,7 @@ void format_value(basic_buffer<Char> &buf, const T &value,
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
internal
::
format_value
(
buffer
,
value
);
basic_string_view
<
Char
>
str
(
buffer
.
data
(),
buffer
.
size
());
do_format_arg
<
ArgF
ormatter
<
Char
>
>
(
do_format_arg
<
arg_f
ormatter
<
Char
>
>
(
buf
,
internal
::
make_arg
<
basic_context
<
Char
>
>
(
str
),
ctx
);
}
...
...
fmt/printf.h
View file @
4ec88607
...
...
@@ -210,7 +210,7 @@ class PrintfWidthHandler {
\endrst
*/
template
<
typename
Char
>
class
PrintfArgF
ormatter
:
public
internal
::
ArgFormatterBase
<
Char
>
{
class
printf_arg_f
ormatter
:
public
internal
::
ArgFormatterBase
<
Char
>
{
private:
void
write_null_pointer
()
{
this
->
spec
().
type_
=
0
;
...
...
@@ -229,7 +229,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
specifier information for standard argument types.
\endrst
*/
PrintfArgF
ormatter
(
basic_buffer
<
Char
>
&
buffer
,
format_specs
&
spec
)
printf_arg_f
ormatter
(
basic_buffer
<
Char
>
&
buffer
,
format_specs
&
spec
)
:
internal
::
ArgFormatterBase
<
Char
>
(
buffer
,
spec
)
{}
using
Base
::
operator
();
...
...
@@ -295,7 +295,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
/** This template formats data and writes the output to a writer. */
template
<
typename
Char
,
typename
ArgFormatter
=
PrintfArgF
ormatter
<
Char
>
>
typename
ArgFormatter
=
printf_arg_f
ormatter
<
Char
>
>
class
printf_context
:
private
internal
::
context_base
<
Char
,
printf_context
<
Char
,
ArgFormatter
>>
{
...
...
test/custom-formatter-test.cc
View file @
4ec88607
...
...
@@ -10,38 +10,38 @@
#include "fmt/printf.h"
#include "gtest-extra.h"
using
fmt
::
PrintfArgF
ormatter
;
using
fmt
::
printf_arg_f
ormatter
;
// A custom argument formatter that doesn't print `-` for floating-point values
// rounded to 0.
class
CustomArgFormatter
:
public
fmt
::
ArgF
ormatter
<
char
>
{
class
CustomArgFormatter
:
public
fmt
::
arg_f
ormatter
<
char
>
{
public:
CustomArgFormatter
(
fmt
::
buffer
&
buf
,
fmt
::
basic_context
<
char
>
&
ctx
,
fmt
::
format_specs
&
s
)
:
fmt
::
ArgF
ormatter
<
char
>
(
buf
,
ctx
,
s
)
{}
:
fmt
::
arg_f
ormatter
<
char
>
(
buf
,
ctx
,
s
)
{}
using
fmt
::
ArgF
ormatter
<
char
>::
operator
();
using
fmt
::
arg_f
ormatter
<
char
>::
operator
();
void
operator
()(
double
value
)
{
if
(
round
(
value
*
pow
(
10
,
spec
().
precision
()))
==
0
)
value
=
0
;
fmt
::
ArgF
ormatter
<
char
>::
operator
()(
value
);
fmt
::
arg_f
ormatter
<
char
>::
operator
()(
value
);
}
};
// A custom argument formatter that doesn't print `-` for floating-point values
// rounded to 0.
class
CustomPrintfArgFormatter
:
public
PrintfArgF
ormatter
<
char
>
{
class
CustomPrintfArgFormatter
:
public
printf_arg_f
ormatter
<
char
>
{
public:
CustomPrintfArgFormatter
(
fmt
::
buffer
&
buf
,
fmt
::
format_specs
&
spec
)
:
PrintfArgF
ormatter
<
char
>
(
buf
,
spec
)
{}
:
printf_arg_f
ormatter
<
char
>
(
buf
,
spec
)
{}
using
PrintfArgF
ormatter
<
char
>::
operator
();
using
printf_arg_f
ormatter
<
char
>::
operator
();
void
operator
()(
double
value
)
{
if
(
round
(
value
*
pow
(
10
,
spec
().
precision
()))
==
0
)
value
=
0
;
PrintfArgF
ormatter
<
char
>::
operator
()(
value
);
printf_arg_f
ormatter
<
char
>::
operator
()(
value
);
}
};
...
...
test/ostream-test.cc
View file @
4ec88607
...
...
@@ -58,9 +58,9 @@ TEST(OStreamTest, Enum) {
EXPECT_EQ
(
"0"
,
fmt
::
format
(
"{}"
,
A
));
}
struct
TestArgFormatter
:
fmt
::
ArgF
ormatter
<
char
>
{
struct
TestArgFormatter
:
fmt
::
arg_f
ormatter
<
char
>
{
TestArgFormatter
(
fmt
::
buffer
&
buf
,
fmt
::
context
&
ctx
,
fmt
::
format_specs
&
s
)
:
fmt
::
ArgF
ormatter
<
char
>
(
buf
,
ctx
,
s
)
{}
:
fmt
::
arg_f
ormatter
<
char
>
(
buf
,
ctx
,
s
)
{}
};
TEST
(
OStreamTest
,
CustomArg
)
{
...
...
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