3rdparty
libpointmatcher
contrib
yaml-cpp-pm
src
ostream.cpp
Go to the documentation of this file.
1
#include "
yaml-cpp-pm/ostream.h
"
2
#include <cstring>
3
4
namespace
YAML_PM
5
{
6
ostream::ostream
(): m_buffer(0), m_pos(0), m_size(0), m_row(0), m_col(0)
7
{
8
reserve
(1024);
9
}
10
11
ostream::~ostream
()
12
{
13
delete
[]
m_buffer
;
14
}
15
16
void
ostream::reserve
(
unsigned
size)
17
{
18
if
(size <=
m_size
)
19
return
;
20
21
char
*newBuffer =
new
char
[size];
22
std::memset(newBuffer, 0, size *
sizeof
(
char
));
23
std::memcpy(newBuffer,
m_buffer
,
m_size
*
sizeof
(
char
));
24
delete
[]
m_buffer
;
25
m_buffer
= newBuffer;
26
m_size
= size;
27
}
28
29
void
ostream::put
(
char
ch)
30
{
31
if
(
m_pos
>=
m_size
- 1)
// an extra space for the NULL terminator
32
reserve
(
m_size
* 2);
33
34
m_buffer
[
m_pos
] = ch;
35
m_pos
++;
36
37
if
(ch ==
'\n'
) {
38
m_row
++;
39
m_col
= 0;
40
}
else
41
m_col
++;
42
}
43
44
ostream
&
operator <<
(
ostream
&
out
,
const
char
*str)
45
{
46
std::size_t
length
= std::strlen(str);
47
for
(std::size_t i=0;i<
length
;i++)
48
out
.put(str[i]);
49
return
out
;
50
}
51
52
ostream
&
operator <<
(
ostream
&
out
,
const
std::string
& str)
53
{
54
out
<< str.c_str();
55
return
out
;
56
}
57
58
ostream
&
operator <<
(
ostream
&
out
,
char
ch)
59
{
60
out
.put(ch);
61
return
out
;
62
}
63
}
ostream.h
YAML_PM::ostream::put
void put(char ch)
Definition:
ostream.cpp:29
YAML_PM::ostream::ostream
ostream()
Definition:
ostream.cpp:6
YAML_PM
Definition:
aliasmanager.h:11
YAML_PM::ostream::reserve
void reserve(unsigned size)
Definition:
ostream.cpp:16
testing::internal::string
::std::string string
Definition:
gtest.h:1979
kitti-batch-convert.out
string out
Definition:
kitti-batch-convert.py:7
YAML_PM::ostream::m_size
unsigned m_size
Definition:
ostream.h:30
YAML_PM::ostream::m_col
unsigned m_col
Definition:
ostream.h:32
YAML_PM::ostream::m_pos
unsigned m_pos
Definition:
ostream.h:29
YAML_PM::ostream::~ostream
~ostream()
Definition:
ostream.cpp:11
YAML_PM::ostream::m_buffer
char * m_buffer
Definition:
ostream.h:28
YAML_PM::ostream::m_row
unsigned m_row
Definition:
ostream.h:32
YAML_PM::operator<<
Emitter & operator<<(Emitter &emitter, const std::string &v)
Definition:
emitter.h:148
YAML_PM::ostream
Definition:
ostream.h:13
length
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
mp2p_icp
Author(s):
autogenerated on Fri Dec 20 2024 03:45:59