mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Update docs
This commit is contained in:
parent
6d339e32a0
commit
17258e9c63
44
doc/api.rst
44
doc/api.rst
@ -59,7 +59,9 @@ Named arguments
|
||||
Argument lists
|
||||
--------------
|
||||
|
||||
.. doxygenclass:: fmt::basic_arg
|
||||
.. doxygenfunction:: fmt::make_args(const Args&...)
|
||||
|
||||
.. doxygenclass:: fmt::arg_store
|
||||
:members:
|
||||
|
||||
.. doxygenclass:: fmt::basic_format_args
|
||||
@ -67,7 +69,8 @@ Argument lists
|
||||
|
||||
.. doxygenstruct:: fmt::format_args
|
||||
|
||||
.. doxygenfunction:: fmt::make_args(const Args&...)
|
||||
.. doxygenclass:: fmt::basic_arg
|
||||
:members:
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
@ -193,6 +196,7 @@ allocator::
|
||||
const Args & ... args) {
|
||||
return vformat(alloc, format_str, fmt::make_args(args...));
|
||||
}
|
||||
|
||||
Custom formatting of built-in types
|
||||
-----------------------------------
|
||||
|
||||
@ -237,9 +241,6 @@ custom argument formatter class::
|
||||
.. doxygenclass:: fmt::ArgVisitor
|
||||
:members:
|
||||
|
||||
.. doxygenclass:: fmt::arg_formatter_base
|
||||
:members:
|
||||
|
||||
.. doxygenclass:: fmt::arg_formatter
|
||||
:members:
|
||||
|
||||
@ -305,36 +306,3 @@ argument type doesn't match its format specification.
|
||||
.. doxygenfunction:: fprintf(std::ostream&, string_view, const Args&...)
|
||||
|
||||
.. doxygenfunction:: sprintf(string_view, const Args&...)
|
||||
|
||||
Write API
|
||||
=========
|
||||
|
||||
The write API provides classes for writing formatted data into character
|
||||
streams. It is usually faster than the `format API`_ but, as IOStreams,
|
||||
may result in larger compiled code size. The main writer class is
|
||||
`~fmt::basic_memory_writer` which stores its output in a memory buffer and
|
||||
provides direct access to it. It is possible to create custom writers that
|
||||
store output elsewhere by subclassing `~fmt::BasicWriter`.
|
||||
|
||||
.. doxygenclass:: fmt::BasicWriter
|
||||
:members:
|
||||
|
||||
.. doxygenclass:: fmt::basic_memory_writer
|
||||
:members:
|
||||
|
||||
.. doxygenclass:: fmt::BasicArrayWriter
|
||||
:members:
|
||||
|
||||
.. doxygenclass:: fmt::BasicStringWriter
|
||||
:members:
|
||||
|
||||
.. doxygenfunction:: bin(int)
|
||||
|
||||
.. doxygenfunction:: oct(int)
|
||||
|
||||
.. doxygenfunction:: hex(int)
|
||||
|
||||
.. doxygenfunction:: hexu(int)
|
||||
|
||||
.. doxygenfunction:: pad(int, unsigned, Char)
|
||||
|
||||
|
@ -950,6 +950,13 @@ inline typename std::enable_if<!IS_PACKED, basic_arg<Context>>::type
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
An array of references to arguments. It can be implicitly converted into
|
||||
`~fmt::basic_format_args` for passing into type-erased formatting functions
|
||||
such as `~fmt::vformat`.
|
||||
\endrst
|
||||
*/
|
||||
template <typename Context, typename ...Args>
|
||||
class arg_store {
|
||||
private:
|
||||
@ -964,6 +971,8 @@ class arg_store {
|
||||
// If the arguments are not packed, add one more element to mark the end.
|
||||
value_type data_[NUM_ARGS + (IS_PACKED && NUM_ARGS != 0 ? 0 : 1)];
|
||||
|
||||
friend class basic_format_args<Context>;
|
||||
|
||||
public:
|
||||
static const uint64_t TYPES;
|
||||
|
||||
@ -978,8 +987,6 @@ class arg_store {
|
||||
#endif
|
||||
|
||||
basic_format_args<Context> operator*() const { return *this; }
|
||||
|
||||
const value_type *data() const { return data_; }
|
||||
};
|
||||
|
||||
template <typename Context, typename ...Args>
|
||||
@ -987,6 +994,13 @@ const uint64_t arg_store<Context, Args...>::TYPES = IS_PACKED ?
|
||||
internal::get_types<Context, Args...>() :
|
||||
-static_cast<int64_t>(NUM_ARGS);
|
||||
|
||||
/**
|
||||
\rst
|
||||
Constructs an `~fmt::arg_store` object that contains references to arguments
|
||||
and can be implicitly converted to `~fmt::format_args`. `Context` can be
|
||||
omitted in which case it defaults to `~fmt::context`.
|
||||
\endrst
|
||||
*/
|
||||
template <typename Context, typename ...Args>
|
||||
inline arg_store<Context, Args...> make_args(const Args & ... args) {
|
||||
return arg_store<Context, Args...>(args...);
|
||||
@ -1050,10 +1064,15 @@ class basic_format_args {
|
||||
public:
|
||||
basic_format_args() : types_(0) {}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Constructs a `basic_format_args` object from `~fmt::arg_store`.
|
||||
\endrst
|
||||
*/
|
||||
template <typename... Args>
|
||||
basic_format_args(const arg_store<Context, Args...> &store)
|
||||
: types_(store.TYPES) {
|
||||
set_data(store.data());
|
||||
set_data(store.data_);
|
||||
}
|
||||
|
||||
/** Returns the argument at specified index. */
|
||||
@ -1065,9 +1084,9 @@ class basic_format_args {
|
||||
|
||||
unsigned max_size() const {
|
||||
int64_t signed_types = static_cast<int64_t>(types_);
|
||||
return static_cast<unsigned>(signed_types < 0
|
||||
? -signed_types
|
||||
: static_cast<int64_t>(internal::max_packed_args));
|
||||
return static_cast<unsigned>(
|
||||
signed_types < 0 ?
|
||||
-signed_types : static_cast<int64_t>(internal::max_packed_args));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1399,7 +1399,8 @@ class arg_formatter_base {
|
||||
}
|
||||
|
||||
void write(const char_type *value) {
|
||||
auto length = value != FMT_NULL ? std::char_traits<char_type>::length(value) : 0;
|
||||
auto length = value != FMT_NULL ?
|
||||
std::char_traits<char_type>::length(value) : 0;
|
||||
writer_.write_str(basic_string_view<char_type>(value, length), specs_);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user