Gazebo Common
API Reference
6.0.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-common
io
include
gz
common
CSVStreams.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
#ifndef GZ_COMMON_CSVSTREAMS_HH_
18
#define GZ_COMMON_CSVSTREAMS_HH_
19
20
#include <istream>
21
#include <string>
22
#include <vector>
23
24
#include <gz/common/io/Export.hh>
25
26
#include <gz/utils/ImplPtr.hh>
27
28
namespace
gz
29
{
30
namespace
common
31
{
33
struct
GZ_COMMON_IO_VISIBLE
CSVDialect
34
{
36
char
delimiter
;
37
39
char
terminator
;
40
42
char
quote
;
43
45
static
const
CSVDialect
Unix
;
46
};
47
52
bool
GZ_COMMON_IO_VISIBLE
operator==
(
const
CSVDialect
&_lhs,
53
const
CSVDialect
&_rhs);
54
58
struct
CSVToken
59
{
61
enum
{
62
TEXT
= 0,
63
QUOTE
,
64
DELIMITER
,
65
TERMINATOR
66
}
type
;
67
69
char
character
;
70
};
71
80
GZ_COMMON_IO_VISIBLE
std::istream
&
ExtractCSVToken
(
81
std::istream
&_stream,
CSVToken
&_token,
82
const
CSVDialect
&_dialect =
CSVDialect::Unix
);
83
92
GZ_COMMON_IO_VISIBLE
std::istream
&
ParseCSVRow
(
93
std::istream
&_stream,
std::vector<std::string>
&_row,
94
const
CSVDialect
&_dialect =
CSVDialect::Unix
);
95
100
class
GZ_COMMON_IO_VISIBLE
CSVIStreamIterator
101
{
102
public
:
using
iterator_category
=
std::input_iterator_tag
;
103
public
:
using
value_type
=
std::vector<std::string>
;
104
public
:
using
difference_type
=
std::ptrdiff_t
;
105
public
:
using
pointer
=
const
value_type
*;
106
public
:
using
reference
=
const
value_type
&;
107
109
public
:
CSVIStreamIterator
();
110
119
public
:
explicit
CSVIStreamIterator
(
120
std::istream
&_stream,
121
const
CSVDialect
&_dialect = CSVDialect::Unix);
122
131
public
:
CSVIStreamIterator
&
operator++
();
132
143
public
:
CSVIStreamIterator
operator++
(
int
);
144
150
public
:
bool
operator==
(
const
CSVIStreamIterator
&_other)
const
;
151
155
public
:
bool
operator!=
(
const
CSVIStreamIterator
&_other)
const
;
156
162
public
:
reference
operator*
()
const
;
163
169
public
:
pointer
operator->
()
const
;
170
172
private
: GZ_UTILS_IMPL_PTR(dataPtr)
173
};
174
}
175
}
176
177
#endif