WPILibC++ 2024.3.2
raw_ostream.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#ifndef WPIUTIL_WPI_FMT_RAW_OSTREAM_H_
6#define WPIUTIL_WPI_FMT_RAW_OSTREAM_H_
7
8#include <fmt/format.h>
9
10#include "wpi/raw_ostream.h"
11
13
14inline void vprint(wpi::raw_ostream& os, string_view format_str,
15 fmt::format_args args) {
16 memory_buffer buffer;
17 detail::vformat_to(buffer, format_str, args);
18 os.write(buffer.data(), buffer.size());
19}
20
21/**
22 * Prints formatted data to the stream *os*.
23 */
24template <typename S, typename... Args>
25void print(wpi::raw_ostream& os, const S& format_str, Args&&... args) {
26 vprint(os, format_str, fmt::make_format_args(args...));
27}
28
30
31#endif // WPIUTIL_WPI_FMT_RAW_OSTREAM_H_
\rst A dynamically growing memory buffer for trivially copyable/constructible types with the first SI...
Definition: format.h:918
constexpr auto size() const noexcept -> size_t
Returns the size of this buffer.
Definition: core.h:838
FMT_CONSTEXPR auto data() noexcept -> T *
Returns a pointer to the buffer data (not null-terminated).
Definition: core.h:844
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:43
raw_ostream & write(unsigned char C)
#define FMT_BEGIN_NAMESPACE
Definition: core.h:174
constexpr auto make_format_args(T &... args) -> format_arg_store< Context, remove_cvref_t< T >... >
\rst Constructs a ~fmtformat_arg_store object that contains references to arguments and can be implic...
Definition: core.h:1824
basic_format_args< format_context > format_args
An alias to basic_format_args<format_context>.
Definition: core.h:1971
#define FMT_END_NAMESPACE
Definition: core.h:177
void print(wpi::raw_ostream &os, const S &format_str, Args &&... args)
Prints formatted data to the stream os.
Definition: raw_ostream.h:25
FMT_BEGIN_NAMESPACE void vprint(wpi::raw_ostream &os, string_view format_str, fmt::format_args args)
Definition: raw_ostream.h:14
void vformat_to(buffer< Char > &buf, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
Definition: color.h:436
#define S(label, offset, message)
Definition: Errors.h:119