WPILibC++ 2025.0.0-alpha-1-24-g6478ba6
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
12namespace wpi {
13
14inline void vprint(wpi::raw_ostream& os, fmt::string_view format_str,
15 fmt::format_args args) {
16 fmt::memory_buffer buffer;
17 fmt::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
29} // namespace wpi
30
31#endif // WPIUTIL_WPI_FMT_RAW_OSTREAM_H_
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)
basic_memory_buffer< char > memory_buffer
Definition: format.h:928
Definition: ntcore_cpp.h:26
void print(wpi::raw_ostream &os, const S &format_str, Args &&... args)
Prints formatted data to the stream os.
Definition: raw_ostream.h:25
void vprint(wpi::raw_ostream &os, fmt::string_view format_str, fmt::format_args args)
Definition: raw_ostream.h:14
#define S(label, offset, message)
Definition: Errors.h:119
basic_string_view< char > string_view
Definition: base.h:601
constexpr FMT_ALWAYS_INLINE auto make_format_args(T &... args) -> detail::format_arg_store< Context, NUM_ARGS, 0, DESC >
Constructs an object that stores references to arguments and can be implicitly converted to format_ar...
Definition: base.h:2000
basic_format_args< format_context > format_args
An alias for basic_format_args<format_context>.
Definition: base.h:2038
auto vformat_to(OutputIt out, const S &format_str, typename detail::vformat_args< Char >::type args) -> OutputIt
Definition: xchar.h:184