C/C++ API Reference
Loading...
Searching...
No Matches
format.h
Go to the documentation of this file.
1// Copyright 2023 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14#pragma once
15
25
26#include <cstdarg>
27
28#include "pw_preprocessor/compiler.h"
29#include "pw_span/span.h"
30#include "pw_status/status_with_size.h"
31#include "pw_string/string.h"
32
33namespace pw::string {
34
36
56StatusWithSize Format(span<char> buffer, const char* format, ...);
57
64 const char* format,
65 va_list args);
66
72Status Format(InlineString<>& string, const char* format, ...);
73
79Status FormatVaList(InlineString<>& string, const char* format, va_list args);
80
86Status FormatOverwrite(InlineString<>& string, const char* format, ...);
87
94 const char* format,
95 va_list args) {
96 string.clear();
97 return FormatVaList(string, format, args);
98}
99
101
102} // namespace pw::string
pw::InlineBasicString is a fixed-capacity version of std::basic_string. In brief:
Definition: string.h:68
Definition: status.h:109
Definition: status_with_size.h:51
Definition: span_impl.h:235
#define PW_PRINTF_FORMAT(format_index, parameter_index)
Definition: compiler.h:89
StatusWithSize Format(span< char > buffer, const char *format,...)
StatusWithSize FormatVaList(span< char > buffer, const char *format, va_list args)
Status FormatOverwriteVaList(InlineString<> &string, const char *format, va_list args)
Definition: format.h:93
Status FormatOverwrite(InlineString<> &string, const char *format,...)
pw::InlineBasicString and pw::InlineString are safer alternatives to std::basic_string and std::strin...