FBB::String

FBB::String

libbobcat1-dev_2.02.03-x.tar.gz

2005-2009


FBB::String(3bobcat)

FBB::String(3bobcat)

libbobcat1-dev_2.02.03-x.tar.gz Error handler

2005-2009

NAME

FBB::String - Several extensions to std::string

SYNOPSIS

#include <bobcat/string>
Linking option: -lbobcat

DESCRIPTION

This class offers the same functionality as std::string, adding facilities for often used transformations, currently missing in std::string.

NAMESPACE

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

INHERITS FROM

--

ENUMERATION

TYPEDEF

The typedef SplitPair represents std::pair<std::string, String::Type> and is used in the second variant of the split member (see below).

HISTORY

Initially this class was derived from std::string. Deriving from std::string, however, is considerd bad design as std::string was not designed as a base-class.

Currently String offers a series of static member functions providing the facilities originally implemented in non-static members.

STATIC MEMBER FUNCTIONS

EXAMPLE


#include <iostream>
#include <vector>

#include <bobcat/string>

using namespace std;
using namespace FBB;

char const *type[] = 
{
    "DQUOTE_UNTERMINATED",
    "SQUOTE_UNTERMINATED",
    "ESCAPED_END",
    "SEPARATOR",
    "NORMAL",
    "DQUOTE",
    "SQUOTE",
};

int main(int argc, char **argv)
{
    cout << "Program's name in uppercase: " << String::uc(argv[0]) << endl;

    if (argc == 1)
        cout << "Provide any argument to suppress SEPARATOR fields\n";

    while (true)
    {
        cout << "Enter a line, or empty line to stop:" << endl;

        String line;
        if (!getline(cin, line) || !line.length())
            break;

        vector<String::SplitPair> splitpair;
        cout << "Split into " << line.split(&splitpair, " \t", argc == 1) << 
                " fields\n"; 
        for 
        (
            vector<String::SplitPair>::iterator it = splitpair.begin();
                it != splitpair.end();
                    ++it
        )
            cout << (it - splitpair.begin() + 1) << ": " <<
                    type[it->second] << ": `" << it->first << 
                    "', unescaped: `" << String(it->first).unescape() << 
                    "'" << endl;
    }
    return 0;
}
    

FILES

bobcat/string - 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).