xref: /freebsd/lib/libutil++/freebsd__stringf.3 (revision 159503125826bc2d3b988921e7e85735ee09ad46)
1*15950312SJohn Baldwin.\"
2*15950312SJohn Baldwin.\" SPDX-License-Identifier: BSD-2-Clause
3*15950312SJohn Baldwin.\"
4*15950312SJohn Baldwin.\" Copyright (c) 2025 Chelsio Communications, Inc.
5*15950312SJohn Baldwin.\" Written by: John Baldwin <jhb@FreeBSD.org>
6*15950312SJohn Baldwin.\"
7*15950312SJohn Baldwin.Dd July 31, 2025
8*15950312SJohn Baldwin.Dt FREEBSD::STRINGF 3
9*15950312SJohn Baldwin.Os
10*15950312SJohn Baldwin.Sh NAME
11*15950312SJohn Baldwin.Nm freebsd::stringf
12*15950312SJohn Baldwin.Nd build a std::string using stdio formatting
13*15950312SJohn Baldwin.Sh LIBRARY
14*15950312SJohn Baldwin.Lb libutil++
15*15950312SJohn Baldwin.Sh SYNOPSIS
16*15950312SJohn Baldwin.In libutil++.hh
17*15950312SJohn Baldwin.Ft std::string
18*15950312SJohn Baldwin.Fn freebsd::stringf "const char *fmt" "..."
19*15950312SJohn Baldwin.Ft std::string
20*15950312SJohn Baldwin.Fn freebsd::stringf "const char *fmt" "va_list ap"
21*15950312SJohn Baldwin.Sh DESCRIPTION
22*15950312SJohn BaldwinThese functions construct a
23*15950312SJohn Baldwin.Vt std::string
24*15950312SJohn Baldwinobject containing a formatted string.
25*15950312SJohn BaldwinThe output of the string is dictated by the
26*15950312SJohn Baldwin.Fa fmt
27*15950312SJohn Baldwinargument and additional arguments using the same conventions documented in
28*15950312SJohn Baldwin.Xr printf 3 .
29*15950312SJohn BaldwinThe first form provides functionality similar to
30*15950312SJohn Baldwin.Xr asprintf 3
31*15950312SJohn Baldwinand the second form is similar to
32*15950312SJohn Baldwin.Xr vasprintf 3 .
33*15950312SJohn Baldwin.Sh RETURN VALUES
34*15950312SJohn BaldwinThese functions return a std::string object.
35*15950312SJohn Baldwin.Sh EXCEPTIONS
36*15950312SJohn BaldwinThese functions may throw one of the following exceptions:
37*15950312SJohn Baldwin.Bl -tag -width Er
38*15950312SJohn Baldwin.It Bq Er std::bad_alloc
39*15950312SJohn BaldwinFailed to allocate memory.
40*15950312SJohn Baldwin.It Bq Er std::length_error
41*15950312SJohn BaldwinThe result would exceeed the maximum possible string size.
42*15950312SJohn Baldwin.El
43*15950312SJohn Baldwin.Sh EXAMPLES
44*15950312SJohn Baldwin.Bd -literal -offset indent
45*15950312SJohn Baldwinstd::string s = freebsd::stringf("hello %s", "world");
46*15950312SJohn Baldwin.Ed
47*15950312SJohn Baldwin.Sh SEE ALSO
48*15950312SJohn Baldwin.Xr asprintf 3
49