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
b656a1c1
Commit
b656a1c1
authored
Oct 25, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make value the second argument to format_value
parent
edf98792
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
23 deletions
+25
-23
fmt/format.h
fmt/format.h
+8
-8
fmt/ostream.h
fmt/ostream.h
+3
-2
fmt/printf.h
fmt/printf.h
+3
-3
fmt/time.h
fmt/time.h
+3
-2
test/format-test.cc
test/format-test.cc
+4
-4
test/util-test.cc
test/util-test.cc
+4
-4
No files found.
fmt/format.h
View file @
b656a1c1
...
...
@@ -993,7 +993,7 @@ struct Value {
};
typedef
void
(
*
FormatFunc
)(
void
*
writer
,
void
*
formatter
,
const
void
*
arg
,
void
*
format_str_ptr
);
void
*
writer
,
const
void
*
arg
,
void
*
formatter
,
void
*
format_str_ptr
);
struct
CustomValue
{
const
void
*
value
;
...
...
@@ -1159,8 +1159,8 @@ inline fmt::StringRef thousands_sep(...) { return ""; }
typedef int FMT_CONCAT_(Assert, __LINE__)[(cond) ? 1 : -1] FMT_UNUSED
#endif
template
<
typename
Formatter
,
typename
Char
,
typename
T
>
void
format_value
(
BasicWriter
<
Char
>
&
,
Formatter
&
,
const
Char
*
,
const
T
&
)
{
template
<
typename
Formatter
,
typename
T
,
typename
Char
>
void
format_value
(
BasicWriter
<
Char
>
&
,
const
T
&
,
Formatter
&
,
const
Char
*
)
{
FMT_STATIC_ASSERT
(
False
<
T
>::
value
,
"Cannot format argument. To enable the use of ostream "
"operator<< include fmt/ostream.h. Otherwise provide "
...
...
@@ -1271,12 +1271,12 @@ class MakeValue : public Arg {
// Formats an argument of a custom type, such as a user-defined class.
template
<
typename
T
>
static
void
format_custom_arg
(
void
*
writer
,
void
*
formatter
,
const
void
*
arg
,
void
*
format_str_ptr
)
{
void
*
writer
,
const
void
*
arg
,
void
*
formatter
,
void
*
format_str_ptr
)
{
typedef
BasicWriter
<
typename
Formatter
::
char_type
>
Writer
;
format_value
(
*
static_cast
<
Writer
*>
(
writer
),
*
static_cast
<
const
T
*>
(
arg
),
*
static_cast
<
Formatter
*>
(
formatter
),
*
static_cast
<
const
Char
**>
(
format_str_ptr
),
*
static_cast
<
const
T
*>
(
arg
));
*
static_cast
<
const
Char
**>
(
format_str_ptr
));
}
public:
...
...
@@ -2180,7 +2180,7 @@ class BasicArgFormatter : public internal::ArgFormatterBase<Impl, Char> {
/** Formats an argument of a custom (user-defined) type. */
void
visit_custom
(
internal
::
Arg
::
CustomValue
c
)
{
c
.
format
(
&
formatter_
.
writer
(),
&
formatter_
,
c
.
value
,
&
format_
);
c
.
format
(
&
formatter_
.
writer
(),
c
.
value
,
&
formatter_
,
&
format_
);
}
};
...
...
@@ -3469,7 +3469,7 @@ const Char *basic_formatter<Char, ArgFormatter>::format(
FormatSpec
spec
;
if
(
*
s
==
':'
)
{
if
(
arg
.
type
==
Arg
::
CUSTOM
)
{
arg
.
custom
.
format
(
&
writer
(),
this
,
arg
.
custom
.
value
,
&
s
);
arg
.
custom
.
format
(
&
writer
(),
arg
.
custom
.
value
,
this
,
&
s
);
return
s
;
}
++
s
;
...
...
fmt/ostream.h
View file @
b656a1c1
...
...
@@ -83,8 +83,9 @@ BasicStringRef<Char> format_value(
// Formats a value.
template
<
typename
Char
,
typename
ArgFormatter
,
typename
T
>
void
format_value
(
BasicWriter
<
Char
>
&
w
,
basic_formatter
<
Char
,
ArgFormatter
>
&
f
,
const
Char
*&
format_str
,
const
T
&
value
)
{
void
format_value
(
BasicWriter
<
Char
>
&
w
,
const
T
&
value
,
basic_formatter
<
Char
,
ArgFormatter
>
&
f
,
const
Char
*&
format_str
)
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
auto
str
=
internal
::
format_value
(
buffer
,
value
);
typedef
internal
::
MakeArg
<
basic_formatter
<
Char
>
>
MakeArg
;
...
...
fmt/printf.h
View file @
b656a1c1
...
...
@@ -266,7 +266,7 @@ class BasicPrintfArgFormatter : public internal::ArgFormatterBase<Impl, Char> {
this
->
writer
());
const
Char
format_str
[]
=
{
'}'
,
0
};
const
Char
*
format
=
format_str
;
c
.
format
(
&
formatter
.
writer
(),
&
formatter
,
c
.
value
,
&
format
);
c
.
format
(
&
formatter
.
writer
(),
c
.
value
,
&
formatter
,
&
format
);
}
};
...
...
@@ -497,8 +497,8 @@ void PrintfFormatter<Char, AF>::format(BasicCStringRef<Char> format_str) {
// Formats a value.
template
<
typename
Char
,
typename
T
>
void
format_value
(
BasicWriter
<
Char
>
&
w
,
PrintfFormatter
<
Char
>
&
f
,
const
Char
*&
,
const
T
&
value
)
{
void
format_value
(
BasicWriter
<
Char
>
&
w
,
const
T
&
value
,
PrintfFormatter
<
Char
>
&
f
,
const
Char
*&
)
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
f
.
writer
()
<<
internal
::
format_value
(
buffer
,
value
);
}
...
...
fmt/time.h
View file @
b656a1c1
...
...
@@ -16,8 +16,9 @@
namespace
fmt
{
template
<
typename
ArgFormatter
>
void
format_value
(
Writer
&
w
,
basic_formatter
<
char
,
ArgFormatter
>
&
f
,
const
char
*&
format_str
,
const
std
::
tm
&
tm
)
{
void
format_value
(
Writer
&
w
,
const
std
::
tm
&
tm
,
basic_formatter
<
char
,
ArgFormatter
>
&
f
,
const
char
*&
format_str
)
{
if
(
*
format_str
==
':'
)
++
format_str
;
const
char
*
end
=
format_str
;
...
...
test/format-test.cc
View file @
b656a1c1
...
...
@@ -1355,8 +1355,8 @@ TEST(FormatterTest, FormatCStringRef) {
EXPECT_EQ
(
"test"
,
format
(
"{0}"
,
CStringRef
(
"test"
)));
}
void
format_value
(
fmt
::
Writer
&
w
,
fmt
::
basic_formatter
<
char
>
&
f
,
const
char
*
,
const
Date
&
d
)
{
void
format_value
(
fmt
::
Writer
&
w
,
const
Date
&
d
,
fmt
::
basic_formatter
<
char
>
&
f
,
const
char
*
)
{
f
.
writer
()
<<
d
.
year
()
<<
'-'
<<
d
.
month
()
<<
'-'
<<
d
.
day
();
}
...
...
@@ -1369,8 +1369,8 @@ TEST(FormatterTest, FormatCustom) {
class
Answer
{};
template
<
typename
Char
>
void
format_value
(
BasicWriter
<
Char
>
&
w
,
fmt
::
basic_formatter
<
Char
>
&
f
,
const
Char
*
,
Answer
)
{
void
format_value
(
BasicWriter
<
Char
>
&
w
,
Answer
,
fmt
::
basic_formatter
<
Char
>
&
f
,
const
Char
*
)
{
f
.
writer
()
<<
"42"
;
}
...
...
test/util-test.cc
View file @
b656a1c1
...
...
@@ -64,8 +64,8 @@ namespace {
struct
Test
{};
template
<
typename
Char
>
void
format_value
(
fmt
::
BasicWriter
<
Char
>
&
w
,
fmt
::
basic_formatter
<
Char
>
&
f
,
const
Char
*
,
Test
)
{
void
format_value
(
fmt
::
BasicWriter
<
Char
>
&
w
,
Test
,
fmt
::
basic_formatter
<
Char
>
&
f
,
const
Char
*
)
{
w
<<
"test"
;
}
...
...
@@ -582,8 +582,8 @@ struct CustomFormatter {
typedef
char
char_type
;
};
void
format_value
(
fmt
::
Writer
&
,
CustomFormatter
&
,
const
char
*&
s
,
const
Test
&
)
{
void
format_value
(
fmt
::
Writer
&
,
const
Test
&
,
CustomFormatter
&
,
const
char
*&
s
)
{
s
=
"custom_format"
;
}
...
...
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