Pigweed
 
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
54StatusWithSize Format(span<char> buffer, const char* format, ...);
55
61StatusWithSize FormatVaList(span<char> buffer,
62 const char* format,
63 va_list args);
64
70Status Format(InlineString<>& string, const char* format, ...);
71
77Status FormatVaList(InlineString<>& string, const char* format, va_list args);
78
84Status FormatOverwrite(InlineString<>& string, const char* format, ...);
85
91inline Status FormatOverwriteVaList(InlineString<>& string,
92 const char* format,
93 va_list args) {
94 string.clear();
95 return FormatVaList(string, format, args);
96}
97
98} // namespace pw::string
pw::InlineBasicString is a fixed-capacity version of std::basic_string. In brief:
Definition: string.h:64
Definition: status.h:85
Definition: status_with_size.h:49
StatusWithSize FormatVaList(span< char > buffer, const char *format, va_list args)
#define PW_PRINTF_FORMAT(format_index, parameter_index)
Definition: compiler.h:86
pw::InlineBasicString and pw::InlineString are safer alternatives to std::basic_string and std::strin...