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
|
/*
driver.cc
*/
#include <iostream>
#include "../string"
using namespace std;
using namespace FBB;
static char const *type[] =
{
"DQUOTE_UNTERMINATED",
"SQUOTE_UNTERMINATED",
"ESCAPED_END",
"SEPARATOR",
"NORMAL",
"DQUOTE",
"SQUOTE",
};
int main(int argc, char **argv)
{
if (argc == 1)
cout << "Provide an 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 " <<
String::split(&splitpair, line, " \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::unescape(it->first) <<
"'\n";
cout << line << "Upper case: " << String::uc(line) << ", lc: " <<
String::lc(line) << '\n';
}
}
|