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
b9a06baf
Commit
b9a06baf
authored
Jul 08, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal::FormatParser -> BasicFormatter.
parent
e825156a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
23 deletions
+19
-23
format.cc
format.cc
+6
-6
format.h
format.h
+11
-15
test/format-test.cc
test/format-test.cc
+1
-1
test/util-test.cc
test/util-test.cc
+1
-1
No files found.
format.cc
View file @
b9a06baf
...
...
@@ -559,7 +559,7 @@ void fmt::BasicWriter<Char>::write_str(
template
<
typename
Char
>
inline
const
Arg
&
fmt
::
internal
::
FormatPars
er
<
Char
>::
ParseArgIndex
(
const
Char
*&
s
)
{
&
fmt
::
BasicFormatt
er
<
Char
>::
ParseArgIndex
(
const
Char
*&
s
)
{
unsigned
arg_index
=
0
;
if
(
*
s
<
'0'
||
*
s
>
'9'
)
{
if
(
*
s
!=
'}'
&&
*
s
!=
':'
)
...
...
@@ -586,7 +586,7 @@ inline const Arg
}
template
<
typename
Char
>
void
fmt
::
internal
::
FormatPars
er
<
Char
>::
CheckSign
(
void
fmt
::
BasicFormatt
er
<
Char
>::
CheckSign
(
const
Char
*&
s
,
const
Arg
&
arg
)
{
char
sign
=
static_cast
<
char
>
(
*
s
);
if
(
arg
.
type
>
Arg
::
LAST_NUMERIC_TYPE
)
{
...
...
@@ -868,7 +868,7 @@ void fmt::internal::PrintfParser<Char>::Format(
}
template
<
typename
Char
>
const
Char
*
fmt
::
internal
::
FormatPars
er
<
Char
>::
format
(
const
Char
*
fmt
::
BasicFormatt
er
<
Char
>::
format
(
const
Char
*
format_str
,
const
internal
::
Arg
&
arg
)
{
const
Char
*
s
=
format_str
;
const
char
*
error
=
0
;
...
...
@@ -1073,7 +1073,7 @@ const Char *fmt::internal::FormatParser<Char>::format(
}
template
<
typename
Char
>
void
fmt
::
internal
::
FormatPars
er
<
Char
>::
Format
(
void
fmt
::
BasicFormatt
er
<
Char
>::
Format
(
BasicStringRef
<
Char
>
format_str
,
const
ArgList
&
args
)
{
const
Char
*
s
=
start_
=
format_str
.
c_str
();
args_
=
args
;
...
...
@@ -1142,7 +1142,7 @@ template fmt::BasicWriter<char>::CharPtr
fmt
::
BasicWriter
<
char
>::
FillPadding
(
CharPtr
buffer
,
unsigned
total_size
,
std
::
size_t
content_size
,
wchar_t
fill
);
template
void
fmt
::
internal
::
FormatPars
er
<
char
>
::
Format
(
template
void
fmt
::
BasicFormatt
er
<
char
>
::
Format
(
BasicStringRef
<
char
>
format
,
const
ArgList
&
args
);
template
void
fmt
::
internal
::
PrintfParser
<
char
>
::
Format
(
...
...
@@ -1154,7 +1154,7 @@ template fmt::BasicWriter<wchar_t>::CharPtr
fmt
::
BasicWriter
<
wchar_t
>::
FillPadding
(
CharPtr
buffer
,
unsigned
total_size
,
std
::
size_t
content_size
,
wchar_t
fill
);
template
void
fmt
::
internal
::
FormatPars
er
<
wchar_t
>
::
Format
(
template
void
fmt
::
BasicFormatt
er
<
wchar_t
>
::
Format
(
BasicStringRef
<
wchar_t
>
format
,
const
ArgList
&
args
);
template
void
fmt
::
internal
::
PrintfParser
<
wchar_t
>
::
Format
(
...
...
format.h
View file @
b9a06baf
...
...
@@ -130,13 +130,11 @@ typedef BasicWriter<wchar_t> WWriter;
struct
FormatSpec
;
namespace
internal
{
template
<
typename
Char
>
class
FormatParser
;
}
class
BasicFormatter
;
template
<
typename
Char
,
typename
T
>
void
format
(
internal
::
FormatPars
er
<
Char
>
&
f
,
const
Char
*
format_str
,
const
T
&
value
);
void
format
(
BasicFormatt
er
<
Char
>
&
f
,
const
Char
*
format_str
,
const
T
&
value
);
/**
\rst
...
...
@@ -654,7 +652,7 @@ class MakeArg : public Arg {
template
<
typename
T
>
static
void
format_custom_arg
(
void
*
formatter
,
const
void
*
arg
,
const
void
*
format_str
)
{
format
(
*
static_cast
<
FormatPars
er
<
Char
>*>
(
formatter
),
format
(
*
static_cast
<
BasicFormatt
er
<
Char
>*>
(
formatter
),
static_cast
<
const
Char
*>
(
format_str
),
*
static_cast
<
const
T
*>
(
arg
));
}
...
...
@@ -751,17 +749,15 @@ class ArgList {
}
};
namespace
internal
{
// Format string parser.
// TODO: rename to Formatter
// A formatter.
template
<
typename
Char
>
class
FormatPars
er
{
class
BasicFormatt
er
{
private:
BasicWriter
<
Char
>
&
writer_
;
ArgList
args_
;
int
next_arg_index_
;
const
Char
*
start_
;
fmt
::
internal
::
FormatErrorReporter
<
Char
>
report_error_
;
internal
::
FormatErrorReporter
<
Char
>
report_error_
;
// Parses argument index and returns an argument with this index.
const
internal
::
Arg
&
ParseArgIndex
(
const
Char
*&
s
);
...
...
@@ -769,7 +765,7 @@ private:
void
CheckSign
(
const
Char
*&
s
,
const
internal
::
Arg
&
arg
);
public:
explicit
FormatPars
er
(
BasicWriter
<
Char
>
&
w
)
:
writer_
(
w
)
{}
explicit
BasicFormatt
er
(
BasicWriter
<
Char
>
&
w
)
:
writer_
(
w
)
{}
BasicWriter
<
Char
>
&
writer
()
{
return
writer_
;
}
...
...
@@ -778,6 +774,7 @@ public:
const
Char
*
format
(
const
Char
*
format_str
,
const
internal
::
Arg
&
arg
);
};
namespace
internal
{
// Printf format string parser.
template
<
typename
Char
>
class
PrintfParser
{
...
...
@@ -1256,7 +1253,7 @@ class BasicWriter {
// Do not implement!
void
operator
<<
(
typename
internal
::
CharTraits
<
Char
>::
UnsupportedStrType
);
friend
class
internal
::
FormatPars
er
<
Char
>
;
friend
class
BasicFormatt
er
<
Char
>
;
friend
class
internal
::
PrintfParser
<
Char
>
;
public:
...
...
@@ -1337,7 +1334,7 @@ class BasicWriter {
\endrst
*/
void
write
(
BasicStringRef
<
Char
>
format
,
const
ArgList
&
args
)
{
internal
::
FormatPars
er
<
Char
>
(
*
this
).
Format
(
format
,
args
);
BasicFormatt
er
<
Char
>
(
*
this
).
Format
(
format
,
args
);
}
FMT_VARIADIC_VOID
(
write
,
fmt
::
BasicStringRef
<
Char
>
)
...
...
@@ -1588,8 +1585,7 @@ void BasicWriter<Char>::FormatInt(T value, const Spec &spec) {
// Formats a value.
template
<
typename
Char
,
typename
T
>
void
format
(
internal
::
FormatParser
<
Char
>
&
f
,
const
Char
*
format_str
,
const
T
&
value
)
{
void
format
(
BasicFormatter
<
Char
>
&
f
,
const
Char
*
format_str
,
const
T
&
value
)
{
std
::
basic_ostringstream
<
Char
>
os
;
os
<<
value
;
f
.
format
(
format_str
,
internal
::
MakeArg
<
Char
>
(
os
.
str
()));
...
...
test/format-test.cc
View file @
b9a06baf
...
...
@@ -1318,7 +1318,7 @@ TEST(FormatterTest, FormatUsingIOStreams) {
class
Answer
{};
template
<
typename
Char
>
void
format
(
fmt
::
internal
::
FormatPars
er
<
Char
>
&
f
,
const
Char
*
,
Answer
)
{
void
format
(
fmt
::
BasicFormatt
er
<
Char
>
&
f
,
const
Char
*
,
Answer
)
{
f
.
writer
()
<<
"42"
;
}
...
...
test/util-test.cc
View file @
b9a06baf
...
...
@@ -185,7 +185,7 @@ TEST(UtilTest, MakeArg) {
EXPECT_EQ
(
fmt
::
internal
::
Arg
::
CUSTOM
,
arg
.
type
);
arg
.
custom
.
value
=
&
t
;
fmt
::
Writer
w
;
fmt
::
internal
::
FormatPars
er
<
char
>
formatter
(
w
);
fmt
::
BasicFormatt
er
<
char
>
formatter
(
w
);
arg
.
custom
.
format
(
&
formatter
,
&
t
,
"}"
);
EXPECT_EQ
(
"test"
,
w
.
str
());
}
...
...
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