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
4d5b1e8a
Commit
4d5b1e8a
authored
Jun 28, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the API and tests.
parent
876a5d1f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
232 additions
and
243 deletions
+232
-243
format.h
format.h
+17
-25
test/format-test.cc
test/format-test.cc
+215
-218
No files found.
format.h
View file @
4d5b1e8a
...
@@ -1392,13 +1392,21 @@ class BasicWriter {
...
@@ -1392,13 +1392,21 @@ class BasicWriter {
return
*
this
;
return
*
this
;
}
}
void
W
rite
(
const
std
::
basic_string
<
Char
>
&
s
,
const
FormatSpec
&
spec
)
{
void
w
rite
(
const
std
::
basic_string
<
Char
>
&
s
,
const
FormatSpec
&
spec
)
{
FormatString
(
s
.
data
(),
s
.
size
(),
spec
);
FormatString
(
s
.
data
(),
s
.
size
(),
spec
);
}
}
void
Clear
()
{
// This function is deprecated, use write instead.
buffer_
.
clear
();
FMT_DEPRECATED
(
void
Write
(
const
std
::
basic_string
<
Char
>
&
s
,
const
FormatSpec
&
spec
));
void
Write
(
const
std
::
basic_string
<
Char
>
&
s
,
const
FormatSpec
&
spec
)
{
write
(
s
,
spec
);
}
}
void
clear
()
{
buffer_
.
clear
();
}
// This function is deprecated, use clear instead.
FMT_DEPRECATED
(
void
Clear
());
void
Clear
()
{
clear
();
}
};
};
template
<
typename
Char
>
template
<
typename
Char
>
...
@@ -1577,7 +1585,7 @@ BasicFormatter<Char> BasicWriter<Char>::Format(StringRef format) {
...
@@ -1577,7 +1585,7 @@ BasicFormatter<Char> BasicWriter<Char>::Format(StringRef format) {
// The default formatting function.
// The default formatting function.
template
<
typename
Char
,
typename
T
>
template
<
typename
Char
,
typename
T
>
void
F
ormat
(
BasicWriter
<
Char
>
&
w
,
const
FormatSpec
&
spec
,
const
T
&
value
)
{
void
f
ormat
(
BasicWriter
<
Char
>
&
w
,
const
FormatSpec
&
spec
,
const
T
&
value
)
{
std
::
basic_ostringstream
<
Char
>
os
;
std
::
basic_ostringstream
<
Char
>
os
;
os
<<
value
;
os
<<
value
;
w
.
Write
(
os
.
str
(),
spec
);
w
.
Write
(
os
.
str
(),
spec
);
...
@@ -1808,32 +1816,16 @@ class Formatter : private Sink, public BasicFormatter<Char> {
...
@@ -1808,32 +1816,16 @@ class Formatter : private Sink, public BasicFormatter<Char> {
}
}
};
};
/**
// This function is deprecated, use format instead.
\rst
FMT_DEPRECATED
(
Formatter
<>
Format
(
StringRef
format
));
Formats a string similarly to Python's `str.format
<http://docs.python.org/3/library/stdtypes.html#str.format>`__ function.
Returns a temporary :cpp:class:`fmt::Formatter` object that accepts arguments
via operator ``<<``.
*format* is a format string that contains literal text and replacement
fields surrounded by braces ``{}``. The formatter object replaces the
fields with formatted arguments and stores the output in a memory buffer.
The content of the buffer can be converted to ``std::string`` with
:cpp:func:`fmt::str()` or accessed as a C string with
:cpp:func:`fmt::c_str()`.
**Example**::
std::string message = str(Format("The answer is {}") << 42);
See also `Format String Syntax`_.
\endrst
*/
inline
Formatter
<>
Format
(
StringRef
format
)
{
inline
Formatter
<>
Format
(
StringRef
format
)
{
Formatter
<>
f
(
format
);
Formatter
<>
f
(
format
);
return
f
;
return
f
;
}
}
// This function is deprecated, use format instead.
FMT_DEPRECATED
(
Formatter
<
NullSink
,
wchar_t
>
Format
(
WStringRef
format
));
inline
Formatter
<
NullSink
,
wchar_t
>
Format
(
WStringRef
format
)
{
inline
Formatter
<
NullSink
,
wchar_t
>
Format
(
WStringRef
format
)
{
Formatter
<
NullSink
,
wchar_t
>
f
(
format
);
Formatter
<
NullSink
,
wchar_t
>
f
(
format
);
return
f
;
return
f
;
...
...
test/format-test.cc
View file @
4d5b1e8a
This diff is collapsed.
Click to expand it.
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