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