MRPT
1.9.9
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Variables
_
a
b
c
d
e
g
h
i
l
m
n
p
r
s
t
u
v
w
+
Typedefs
_
a
c
f
m
o
p
r
s
t
v
+
Enumerations
e
f
g
m
n
p
s
t
v
+
Enumerator
a
b
c
d
e
f
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
+
Enumerations
a
f
j
l
m
p
r
s
t
v
x
+
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
y
+
Related Functions
c
d
g
m
o
p
t
w
x
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
+
Typedefs
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Enumerations
c
d
f
i
j
s
t
x
+
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
w
x
+
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
format.cpp
Go to the documentation of this file.
1
/* +------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+------------------------------------------------------------------------+ */
9
10
#include "
core-precomp.h
"
// Precompiled headers
11
12
#include <
mrpt/core/format.h
>
13
#include <cstdarg>
14
15
// A sprintf-like function for std::string
16
std::string
mrpt::format
(
const
char
* fmt, ...)
17
{
18
if
(!fmt)
return
std::string
();
19
20
int
result = -1,
length
= 2048;
21
std::string
buffer
;
22
while
(result == -1)
23
{
24
buffer
.resize(
length
);
25
26
va_list args;
// This must be done WITHIN the loop
27
va_start(args, fmt);
28
#if defined(_MSC_VER)
29
result = ::vsnprintf_s(&
buffer
[0],
length
, _TRUNCATE, fmt, args);
30
#else
31
result =
::vsnprintf
(&
buffer
[0],
length
, fmt, args);
32
#endif
33
va_end(args);
34
35
// Truncated?
36
if
(result >=
length
) result = -1;
37
length
*= 2;
38
39
// Ok?
40
if
(result >= 0)
41
{
42
buffer
.resize(result);
43
}
44
}
45
return
buffer
;
46
}
buffer
GLuint buffer
Definition:
glext.h:3917
format.h
vsnprintf
#define vsnprintf
Definition:
zutil.h:203
string
GLsizei const GLchar ** string
Definition:
glext.h:4101
mrpt::format
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition:
format.cpp:16
length
GLuint GLsizei GLsizei * length
Definition:
glext.h:4064
core-precomp.h
Page generated by
Doxygen 1.8.14
for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020