other versions
- wheezy 3.01.00-1+b1
- jessie 3.23.01-1
- testing 4.04.00-1
- unstable 4.04.00-1
- experimental 4.07.00-1
other sections
FBB::String(3bobcat) | Error handler | FBB::String(3bobcat) |
NAME¶
FBB::String - Several extensions to std::stringSYNOPSIS¶
#include <bobcat/string>DESCRIPTION¶
This class offers the same functionality as std::string, adding facilities for often used transformations, currently missing in std::string.NAMESPACE¶
FBBINHERITS FROM¶
--ENUMERATION¶
- o
- Type:
- DQUOTE, a series of characters surrounded by double quotes in the original string;
- DQUOTE_UNTERMINATED, a series of characters beginning with a double quote in the original string, but lacking the matching terminating double quote;
- ESCAPED_END, a series of characters representing an otherwise normal string, but terminating in a plain backslash;
- NORMAL, a normal string;
- SEPARATOR, a separator;
- SQUOTE, a series of characters surrounded by single quotes in the original string;
- SQUOTE_UNTERMINATED, a series of characters
beginning with a single quote in the original string, but lacking the
matching terminating single quote.
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¶
- o
- char const **argv(std::vector<std::string> const
&words):
- o
- int casecmp(std::string const &lhs, std::string
const &rhs):
- o
- std::string escape(std::string const &str,
char const *series = "’\"\\"):
- o
- std::string lc(std::string const &str) const:
- o
- std::string trim(std::string const &str):
- o
- size_t split(std::vector<std::string> *words,
std::string const &str, char const *separators = "
\t", bool addEmpty = false):
- o
- size_t split(std::vector<SplitPair> *words,
std::string const &str, char const *separators = "
\t", bool addEmpty = false):
- o
- std::string unescape(std::string const &str):
- o
- std::string uc(std::string const &str):
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 interfaceSEE ALSO¶
bobcat(7)BUGS¶
None Reported.DISTRIBUTION FILES¶
- o
- bobcat_3.01.00-x.dsc: detached signature;
- o
- bobcat_3.01.00-x.tar.gz: source archive;
- o
- bobcat_3.01.00-x_i386.changes: change log;
- o
- libbobcat1_3.01.00-x_*.deb: debian package holding the libraries;
- o
- libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages;
- o
- http://sourceforge.net/projects/bobcat: public
archive location;
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).2005-2012 | libbobcat1-dev_3.01.00-x.tar.gz |