/usr/share/doc/libbobcat4-dev/man/csv4180.3.html is in libbobcat-dev 4.08.02-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | <!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::CSV4180(3bobcat)</title>
<style type="text/css">
figure {text-align: center;}
img {vertical-align: center;}
.XXfc {margin-left:auto;margin-right:auto;}
.XXtc {text-align: center;}
.XXtl {text-align: left;}
.XXtr {text-align: right;}
.XXvt {vertical-align: top;}
.XXvb {vertical-align: bottom;}
</style>
<link rev="made" href="mailto:Frank B. Brokken: f.b.brokken@rug.nl">
</head>
<body text="#27408B" bgcolor="#FFFAF0">
<hr/>
<h1 id="title">FBB::CSV4180(3bobcat)</h1>
<h2 id="author">CSV4180 convertor<br/>(libbobcat-dev_4.08.02-x.tar.gz)</h2>
<h2 id="date">2005-2017</h2>
<p>
<h2 >NAME</h2>FBB::CSV4180 - Converter for comma separated values
<p>
<h2 >SYNOPSIS</h2>
<strong >#include <bobcat/csv></strong><br/>
<p>
Linking option: <em >-lbobcat</em>
<p>
<h2 >DESCRIPTION</h2>
<p>
Objects of the class <strong >CSV4180</strong> can be used to convert series of comma
separated values to the individual separated values (also called `fields'
below). The class implements RFC 4180
(cf. <a href="https://www.ietf.org/rfc/rfc4180.txt">https://www.ietf.org/rfc/rfc4180.txt</a>, section 2).
<p>
According to RFC 4180 lines contain comma separated values: comma separated
values on one line are processed together, as a series of values. The final
comma separated value on a line is not ended by a comma.
<p>
Comma separated values may be surrounded by double quotes. However, they
<em >must</em> be surrounded by double quotes in these cases:
<ul>
<li> if the values contain commas;
<li> if the values contain double quotes (in which case the double quote
is `escaped' by doubling it, e.g., <em >"a "" double quote"</em>);
<li> if the values extend over multiple lines. E.g.,
<pre>
"First line
second line"
</pre>
</ul>
<p>
Comma separated values may be empty: the following line defines three
empty comma separated values:
<pre>
,,
</pre>
The first empty value starts at the beginning of the line, and continues
up to the first comma; the second empty value starts beyond the first comma
and continues up to the second comma; the third empty value starts beyond the
second comma, and continues up to the end of the line. If the line ends in
blank space characters then the third value isn't empty, but contains those
blank space characters.
<p>
By default, values are interpreted as strings. The <strong >CSV4180</strong> class also
offers facilities to ignore specific fields, or to ensure that they can be
converted to integral or floating point values. The second constructor (below)
expects a <em >std::string</em> argument defining how to interpret fields. Options
are:
<ul>
<li> <em >I</em>: the field must be convertible to an integral value;
<li> <em >D</em>: the field must be convertible to a floating point value;
<li> <em >S</em>: the field is a string: it is used as-is;
<li> <em >X</em>: the field is omitted from the final set of comma separated
values. I.e., if a line contains three comma separated values, and the
specification <em >"SXS"</em> is used then this results in two comma
separated values: the first and third value of three comma separated
values encountered on lines.
<li> <em >-</em>: synonym of <em >X</em>.
</ul>
<p>
In addition, field specifications may contain blank spaces, which are
ignored.
<p>
When processing comma separated values the first line may be considered a
<em >header</em> line. <em >X</em> specifications also apply to header lines, but
otherwise they merely consist of <em >S</em>-type fields. In addition, when
processing multiple input lines all non-header lines are made available in a
vector of vectors of fields, whereas the header line itself can be accessed
via a dedicated member (<em >header()</em>).
<p>
<h2 >NAMESPACE</h2>
<strong >FBB</strong><br/>
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace <strong >FBB</strong>.
<p>
<h2 >INHERITS FROM</h2>
-
<p>
<h2 >CONSTRUCTORS</h2>
<ul>
<li> <strong >explicit CSV4180(size_t nFields = 0, bool header = false,
char fieldSep = ',')</strong>:<br/>
The first parameter specifies the number of fields that must be
present on input lines. When using the default value the number of
fields encountered on the first line determines the number of fields
that must be present on subsequent lines. If the second parameter is
<em >true</em> then the first line is interpreted as the header line. The
third parameter specifies the character separating the fields. By
default it's a comma, but sometimes (not part of the RFC) a semicolon
is used. By specifying <em >fieldSep</em> any character other than a comma
can be used as field separator.
<p>
<li> <strong >explicit CSV4180(std::string const &specs, bool header = false,
char fieldSep = ',')</strong>:<br/>
The first parameter defines the number and types of the comma separated
values on input lines. Specifications can be
<blockquote >
<ul>
<li> <em >D</em>: the field must be convertible to a floating point
value;
<li> <em >I</em>: the field must be convertible to an integral value;
<li> <em >S</em>: the field is left as-is, and can be retrieved as a
<em >std::string</em>.
<li> <em >X</em> or <em >-</em>: the field is ignored and is not stored inside
the <strong >CSV4180</strong> object.
<li> blank space characters are ignored.
</ul>
</blockquote>
An exception is thrown when encountering other than the abovementioned
characters are encountered.
<p>
If <em >I</em> or <em >D</em> fields cannot be properly converted, or if a line
contains too few or too many comma separated values the input stream's
fail status is set.
<p>
The last two parameters are interpreted as the last two parameters of
the previous constructor.
<p>
</ul><br/>
The copy and move constructors are available.
<p>
<h2 >OVERLOADED OPERATORS</h2>
<ul>
<li> <strong >std::istream &operator>>(std::istream &in, CSV4180 &csv)</strong>:<br/>
One line of text is extracted from <em >in</em> and processed by the <em >csv</em>
object. The <em >csv</em> object may or may not already contain converted
comma separated values. When empty, the first line is processed
according to the specifications provided to the <em >csv</em> object at
construction time. Otherwise, the comma separated values on extracted
lines must match the number and types of the fields, as specified by
the <em >csv</em> object. When input lines do not match these specifications
<em >in's</em> fail status is set.
</ul><br/>
<p>
The copy and move assignment operators are available.
<p>
<h2 >MEMBER FUNCTIONS</h2>
<ul>
<li> <strong >void clear(size_t nFields = 0)</strong>:<br/>
The internally stored data (referred to by the <em >data, header,</em> and
<em >lastLine</em> members) are erased. By default, the required number of
CSV fields is reset to 0, but can be set to a specific value by
specifying a value for its <em >nFields</em> parameter.
<p>
<li> <strong >std::vector<std::vector<std::string>> const &data() const</strong>:<br/>
A reference to the vector of vectors of fields stored inside the
<strong >CSV4180</strong> object is returned. The vector returned by <em >data</em> does
not contain the header line. If a header line was requested it can be
retrieved from the <em >header()</em> member.
<p>
<li> <strong >std::vector<std::string> const &header() const</strong>:<br/>
If the constructor's <em >header</em> parameter was specified as <em >true</em>
then this member returns the fields encountered on the first line that
was processed by the <em >read1</em> member. Otherwise, <em >header</em> returns
a reference to an empty vector.
<p>
<li> <strong >std::string const &lastLine() const</strong>:<br/>
A reference to the last line that was successfully extracted from the
input stream by the <em >read1</em> member is returned. So once the lines
containing the comma separated values have been processed, the next
line on the input stream can be obtained from this member.
<p>
<li> <strong >size_t nValues() const</strong>:<br/>
After successfully calling <em >read1</em> for the first time this member
returns the required number of comma separated values that must be
encountered on subsequent input lines.
<p>
<li> <strong >size_t read(std::istream &in, size_t nLines = 0)</strong>:<br/>
By default, all lines of <em >in</em> are read and are processed by the
<em >read1</em> member. By specifying a non-zero value for the <em >nLines</em>
parameter the specified number of lines is read from <em >in</em>.
Reading stops once <em >in's</em> status is not <em >good</em>. When <em >nLines</em> is
specified as zero, then <em >in's</em> status flags are cleared. The number
of successfully processed lines is returned.
<p>
<li> <strong >std::istream &read1(std::istream &in)</strong>:<br/>
One line is read from <em >in</em> and is parsed for its comma separated
values. If parsing fails, <em >in's fail</em> status is set. After
successfully calling <em >read1</em> for the first time all subsequent lines
read by <em >read1</em> must have the same number of comma separated values
as encountered when calling <em >read1</em> for the first time. The parsed
fields are stored in a vector of <em >std::string</em> objects, and that
vector is added to the vector of vectors of strings that is returned
by the <em >data</em> member.
<p>
<li> <strong >std::vector<std::vector<std::string>> release()</strong>:<br/>
The vector of vectors of fields stored inside the <strong >CSV4180</strong> object is
returned. After calling <em >release</em> the internally stored vector of
fields is empty. The vector returned by <em >data</em> does not contain the
header line. If a header line was requested it can be retrieved from
the <em >header()</em> member. Note that this member does not reset the
number of expected fields for subsequently processed CSV-lines. If
that's what you want, call <em >clear</em> after calling <em >release</em>.
<p>
</ul>
<p>
<h2 >EXAMPLE</h2>
<pre>
#include <iostream>
#include <bobcat/csv4180>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
</pre>
<p>
<pre>
CSV4180 csv; // this processes 'input'
</pre>
<p>
<pre>
size_t nLines = csv.read(cin);
cerr << nLines << " lines were read\n";
if (not csv.header().empty())
{
cerr << "header: " << '\n';
for (auto const &field: csv.header())
cerr << " `" << field << "'\n";
}
cerr << "# CSV values: " << csv.nValues() << '\n';
for (auto const &line: csv.data())
{
cerr << "Line:\n";
for (auto const &entry: line)
cerr << " `" << entry << "'\n";
}
}
</pre>
<p>
<h2 >FILES</h2>
<em >bobcat/csv</em> - defines the class interface
<p>
<h2 >SEE ALSO</h2>
<strong >bobcat</strong>(7)
<p>
<h2 >BUGS</h2>
None Reported.
<p>
<h2 >DISTRIBUTION FILES</h2>
<ul>
<li> <em >bobcat_4.08.02-x.dsc</em>: detached signature;
<li> <em >bobcat_4.08.02-x.tar.gz</em>: source archive;
<li> <em >bobcat_4.08.02-x_i386.changes</em>: change log;
<li> <em >libbobcat1_4.08.02-x_*.deb</em>: debian package holding the
libraries;
<li> <em >libbobcat1-dev_4.08.02-x_*.deb</em>: debian package holding the
libraries, headers and manual pages;
<li> <em >http://sourceforge.net/projects/bobcat</em>: public archive location;
</ul>
<p>
<h2 >BOBCAT</h2>
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
<p>
<h2 >COPYRIGHT</h2>
This is free software, distributed under the terms of the
GNU General Public License (GPL).
<p>
<h2 >AUTHOR</h2>
Frank B. Brokken (<strong >f.b.brokken@rug.nl</strong>).
<p>
</body>
</html>
|