FBB::CSV(3bobcat)

CSV convertor
(libbobcat-dev_4.07.00-x.tar.gz)

2005-2017

NAME

FBB::CSV - Converter for comma separated values

SYNOPSIS

#include <bobcat/csv>

Linking option: -lbobcat

DESCRIPTION

Objects of the class CSV can be used to convert series of comma separated values to the individual separated values. These values may be converted (individually or as a group) to standard integral types int, size_t, long long, etc., to floating point types (float, double, long double), or they can be accessed as std::string values.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

TYPEDEFS AND ENUMS

The enum Mode specifies how a CSV is extracted from std::istream objects:

These enumeration values may be combined using the bit-or operator.

The enum InsertType specifies how a CSV is inserted into std::ostream objects:

The class CSV defines the nested classes const_iterator and const_reverse_iterator which are InputIterators, which can be used to iterate over the sequence of comma-separated values.

CONSTRUCTORS

The default, copy, and move constructors are available.

OVERLOADED OPERATORS

The copy and move assignment operators are available.

MEMBER FUNCTIONS

EXAMPLE

#include <iostream>
#include <bobcat/csv>

using namespace std;
using namespace FBB;

int main()
{
    CSV csv("I5 X2 S2 D3");

    cin >> csv;

    cout << 
        "Nr. of field specs: " << csv.length() << "\n"
        "Nr. of fields: " << csv.size() << "\n"
        "Nr. of available fields: " << csv.count() << "\n"
        "Field 2 as int via get: " << csv.get<int>(2) << "\n"
        "Field 2 as int via available: " << csv.field<int>(2) << "\n"
        "Field 3 via operator[]: " << csv[3] << "\n"
        "Field 6 as string via get: " << csv.get<string>(6) << "\n"
        "Field 6 as string via available: " << csv.field<string>(6) << "\n"
    ;

    cout << "First element as string: " << *csv.begin() << "\n";

    cout << "All elements as strings:\n";
    copy(csv.begin(), csv.end(), ostream_iterator<string>(cout, " "));
    cout << '\n';
    
    cout << "All elements as ints:\n";
    copy(csv.begin<int>(), csv.end<int>(), ostream_iterator<int>(cout, " "));
    cout << '\n';

    cout << "All elements as strings, backward:\n";
    copy(csv.rbegin(), csv.rend(), ostream_iterator<string>(cout, " "));
    cout << '\n';
    
    cout << "All elements as ints, backward:\n";
    copy(csv.rbegin<int>(), csv.rend<int>(), ostream_iterator<int>(cout, " "));
    cout << '\n';

    cout << "Insert LENGTH (default):\n" <<
            csv << '\n';

    csv.setInsertType(CSV::SIZE);

    cout << "Insert SIZE:\n" <<
            csv << '\n';

    csv.setInsertType(CSV::COUNT);

    cout << "Insert COUNT:\n" <<
            csv << '\n';
}


FILES

bobcat/csv - defines the class interface

SEE ALSO

bobcat(7)

BUGS

None Reported.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).