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
8e158d74
Commit
8e158d74
authored
Jan 04, 2013
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document the API.
parent
00830b99
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
11 deletions
+47
-11
doc/format.rst
doc/format.rst
+3
-0
format.h
format.h
+44
-11
No files found.
doc/format.rst
View file @
8e158d74
...
...
@@ -10,6 +10,9 @@ String Formatting
.. doxygenclass:: format::Formatter
:members:
.. doxygenclass:: format::StringRef
:members:
.. ifconfig:: False
.. class:: Formatter
...
...
format.h
View file @
8e158d74
...
...
@@ -117,14 +117,15 @@ void Array<T, SIZE>::append(const T *begin, const T *end) {
class
ArgInserter
;
}
// A reference to a string. It can be constructed from a C string,
// std::string or as a result of a formatting operation. It is most useful
// as a parameter type to allow passing different types of strings in a
// function, for example:
// void SetName(StringRef s) {
// std::string name = s;
// ...
// }
/**
\rst
A string reference. It can be constructed from a C string, ``std::string``
or as a result of a formatting operation. It is most useful as a parameter
type to allow passing different types of strings in a function, for example::
TempFormatter<> Format(StringRef format);
\endrst
*/
class
StringRef
{
private:
const
char
*
data_
;
...
...
@@ -354,18 +355,50 @@ class Formatter : public BasicFormatter {
}
public
:
/**
\rst
Constructs a formatter with an empty output buffer.
\endrst
*/
Formatter
()
:
format_
(
0
)
{
buffer_
[
0
]
=
0
;
}
/// Formats a string appending the output to the internal buffer.
/// Arguments are accepted through the returned ArgInserter object
/// using inserter operator<<.
/**
\rst
Formats a string appending the output to the internal buffer.
Arguments are accepted through the returned ``ArgInserter`` object
using inserter operator ``<<``.
\endrst
*/
internal
::
ArgInserter
operator
()(
StringRef
format
);
/**
\rst
Returns the number of characters written to the output buffer.
\endrst
*/
std
::
size_t
size
()
const
{
return
buffer_
.
size
();
}
/**
\rst
Returns a pointer to the output buffer content. No terminating null
character is appended.
\endrst
*/
const
char
*
data
()
const
{
return
&
buffer_
[
0
];
}
/**
\rst
Returns a pointer to the output buffer content with terminating null
character appended.
\endrst
*/
const
char
*
c_str
()
const
{
return
&
buffer_
[
0
];
}
/**
\rst
Returns the content of the output buffer as an ``std::string``.
\endrst
*/
std
::
string
str
()
const
{
return
std
::
string
(
&
buffer_
[
0
],
buffer_
.
size
());
}
}
;
...
...
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