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
49StatusWithSize Format(span<char> buffer, const char* format, ...);
50
57 const char* format,
58 va_list args);
59
65Status Format(InlineString<>& string, const char* format, ...);
66
72Status FormatVaList(InlineString<>& string, const char* format, va_list args);
73
79Status FormatOverwrite(InlineString<>& string, const char* format, ...);
80
87 const char* format,
88 va_list args) {
89 string.clear();
90 return FormatVaList(string, format, args);
91}
92
94
95} // namespace pw::string
pw::InlineBasicString is a fixed-capacity version of std::basic_string. In brief:
Definition: string.h:68
Definition: status.h:120
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:86
Status FormatOverwrite(InlineString<> &string, const char *format,...)
pw::InlineBasicString and pw::InlineString are safer alternatives to std::basic_string and std::strin...