/usr/share/doc/libbobcat4-dev/man/string.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 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | <!DOCTYPE html><html><head>
<meta charset="UTF-8">
<title>FBB::String(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::String(3bobcat)</h1>
<h2 id="author">Operations on std::string objects<br/>(libbobcat-dev_4.08.02-x.tar.gz)</h2>
<h2 id="date">2005-2017</h2>
<p>
<h2 >NAME</h2>FBB::String - Several operations on <strong >std::string</strong> objects
<p>
<h2 >SYNOPSIS</h2>
<strong >#include <bobcat/string></strong><br/>
Linking option: <em >-lbobcat</em>
<p>
<h2 >DESCRIPTION</h2>
This class offers facilities for often used transformations on
<em >std::string</em> objects, which are not supported by the <em >std::string</em>
class itself. All members of <strong >FBB::String</strong> are static.
<p>
Initially this class was derived from <strong >std::string</strong>. Deriving from
<em >std::string</em>, however, is considerd bad design as <em >std::string</em> was
not designed as a base-class.
<p>
<strong >FBB::String</strong> offers a series of <em >static</em> member functions
providing the facilities originally implemented as non-static members. One of
these members is the (overloaded) <em >split</em> member, splitting a string into
elements separated by one or more configurable characters. These elements may
contain or consist of double- or single-quoted (sub) strings and escape
characters. Escape characters are converted to their implied byte-values
(e.g., <em >\n</em> is converted to byte value 10) unless they are embedded in
single-quoted (sub) strings. Quotes surrounding double- and single-quoted
(sub) strings are removed from the elements returned by the <em >split</em>
members.
<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 >ENUMERATIONS</h2>
<ul>
<li> <strong >Type</strong>:<br/>
This enumeration indicates the nature of the contents of an element in
the array returned by the overloaded <em >split</em> members (see below).
<p>
<strong >DQUOTE</strong>, a subset of the characters in the matching <em >string</em>
element was delimited by double quotes in the in the string that was parsed by
the <em >split</em> members.
<p>
<strong >DQUOTE_UNTERMINATED</strong>, the contents of the string that was
parsed by the <em >split</em> members started at some point with a double quote, but
the matching ending double quote was lacking.
<p>
<strong >ESCAPED_END</strong>, the contents of the string that was
parsed by the <em >split</em> members ended in a mere backslash.
<p>
<strong >NORMAL</strong>, a normal string;
<p>
<strong >SEPARATOR</strong>, a separator;
<p>
<strong >SQUOTE</strong>, a subset of the characters in the matching <em >string</em>
element was delimited by quotes in the in the string that was parsed by
the <em >split</em> members.
<p>
<strong >SQUOTE_UNTERMINATED</strong>, the contents of the string that was
parsed by the <em >split</em> members started at some point with a quote, but
the matching ending quote was lacking.
<li> <strong >SplitType</strong>:<br/>
This enumeration is used to specify how <em >split</em> members should
split the information in the string objects that are passed to these
members:
<p>
<strong >TOK</strong>: the <em >split</em> member acts like the standard <strong >C</strong> function
<strong >strtok</strong>(3). The essence here is that no empty elements are
returned. E.g., a string containing <em >"a,,"</em> which is processed using
the <em >TOK</em> mode returns a <em >NORMAL</em> element containing <em >"a"</em>.
<p>
<strong >TOKSEP</strong>: the <em >split</em> member acts like the standard <strong >C</strong> function
<strong >strtok</strong>(3), also returning information about encountered
separators. Since <em >strtok</em> doesn't return empty elements, <em >TOKSEP</em>
uses empty elements to indicate the occurrence of separators. E.g., a
string containing <em >"a,,"</em> which is processed using the <em >TOKSEP</em>
mode returns a <em >NORMAL</em> element containing <em >"a"</em>, followed by two
empty <em >SEPARATOR</em> elements.
<p>
<strong >STR</strong>: the <em >split</em> member acts like the standard <strong >C</strong> function
<strong >strstr</strong>(3). The essence here is that empty elements are also
returned. E.g., a string containing <em >"a,,"</em> which is processed using
the <em >STR</em> mode returns an element containing <em >"a"</em>, followed by
two empty <em >NORMAL</em> elements.
<p>
<strong >STRSEP</strong>: the <em >split</em> member acts like the standard <strong >C</strong> function
<strong >strstr</strong>(3), also returning information about encountered
separators. E.g., a string containing <em >"a,,"</em> which is processed
using the <em >STRSEP</em> mode returns a <em >NORMAL</em> element containing
<em >"a"</em>, followed by a <em >SEPARATOR</em> element containing <em >","</em>,
followed by a <em >NORMAL</em> empty element, followed by a <em >SEPARATOR</em>
element containing <em >","</em>, and finally followed by a <em >NORMAL</em> empty
element,
</ul>
<p>
<h2 >TYPEDEF</h2>
<p>
The <strong >typedef SplitPair</strong> represents <strong >std::pair<std::string,
String::Type></strong> and is used by some overloaded <strong >split</strong> members (see
below).
<p>
<h2 >STATIC MEMBER FUNCTIONS</h2>
<ul>
<p>
<li> <strong >char const **argv(std::vector<std::string> const &words)</strong>:<br/>
Returns a pointer to an allocated series of pointers to the <strong >C</strong>
strings stored in the vector <em >words</em>. The caller is responsible for
returning the array of pointers to the common pool, but should <em >not</em> delete
the <strong >C</strong>-strings to which the pointers point. The last element of the
returned array is guaranteed to be a 0-pointer.
<p>
<li> <strong >int casecmp(std::string const &lhs, std::string const &rhs)</strong>:<br/>
Performs a case-insensitive comparison of the contents of two
<em >std::string</em> objects. A negative value is returned if <em >lhs</em> should be
ordered before <em >rhs</em>; 0 is returned if the two strings have identical
contents; a positive value is returned if the <em >lhs</em> object should be ordered
beyond <em >rhs</em>.
<p>
<li> <strong >std::string escape(std::string const &str,
char const *series = "'\"\\")</strong>:<br/>
Returns a copy of <em >str</em> in which all characters in <em >series</em> are
prefixed by a backslash character.
<p>
<li> <strong >std::string join(std::vector<std::string> const &words, char sep)</strong>:<br/>
The elements of the <em >words</em> vector are returned as one string,
separated from each other by the <em >sep</em> character;
<p>
<li> <strong >std::string join(std::vector<SplitPair> const &entries, char sep,
bool all = true)</strong>:<br/>
The <em >first</em> fields of the elements in <em >entries</em> are returned as one
string, separated from each other by the <em >sep</em> character. If the
parameter <em >all</em> is specified as <em >false</em> then elements whose
<em >second</em> fields are equal to <em >String::SEPARATOR</em> are ignored.
<p>
<li> <strong >std::string lc(std::string const &str) const</strong>:<br/>
Returns a copy of <em >str</em> in which all letters were transformed to
lower case letters.
<p>
<li> <strong >std::vector<String::SplitPair> split(std::string const &str, SplitType
mode, char const *sep = " \t")</strong>:<br/>
The string <em >str</em> is split into substrings, separated by any of the
characters in <em >sep</em>. The substrings are returned in a vector of
<em >SplitPair</em> elements, using the specified <em >SplitType</em> mode
(cf. the description of the various <em >SplitPair</em> values and their
effects in the <em >ENUMERATIONS</em> section).
<p>
<li> <strong >std::vector<String::SplitPair> split(std::string const &str, char
const *separators = " \t", bool addEmpty = false)</strong>:<br/>
This member acts like the previous one, using <em >addEmpty == false</em>
to select <em >mode TOK</em> and <em >addEmpty == true</em> to select <em >mode
TOKSEP</em>.
<p>
<li> <strong >size_t split(std::vector<String::SplitPair> *entries, std::string
const &str, SplitType mode, char const *sep = " \t")</strong>:<br/>
Same functionality as the first <em >split</em> member, but this member
stores the <em >SplitPair</em> elements in the vector pointed at by the
<em >entries</em> parameter, first clearing the vector. This member returns
the new value of <em >entries->size()</em>.
<p>
<li> <strong >size_t split(std::vector<String::SplitPair> *entries, std::string
const &str, char const *sep = " \t", bool addEmpty = false)</strong>:<br/>
This member acts like the previous one, using <em >addEmpty == false</em>
to select <em >mode TOK</em> and <em >addEmpty == true</em> to select <em >mode
TOKSEP</em>.
<p>
<li> <strong >std::vector<std::string> split(Type *type, std::string const &str,
SplitType stype, char const *sep = " \t")</strong>:<br/>
Same functionality as the first <em >split</em> member, but this member
merely stores the <em >first</em> fields of the <em >SplitPair</em> elements in
the returned vector. The <em >String::Type</em> variable whose address is
passed to the <em >type</em> parameter is set to <em >NORMAL</em> if the final
entry was successfully determined; to <em >DQUOTE_UNTERMINATED</em> if a
final closing double quote could not be found; to
<em >SQUOTE_UNTERMINATED</em> if a final closing single quote could not be
found; and to <em >ESCAPE_END</em> if the final character in <em >str</em> is a
backslash character.
<p>
<li> <strong >std::vector<std::string> split(Type *type, std::string
const &str, char const *sep = " \t", bool addEmpty = false)</strong>:<br/>
This member acts like the previous one, using <em >addEmpty == false</em>
to select <em >mode TOK</em> and <em >addEmpty == true</em> to select <em >mode
TOKSEP</em>.
<p>
<li> <strong >size_t split(std::vector<std::string> *words, std::string const &str,
SplitType stype, char const *sep = " \t")</strong>:<br/>
Same functionality as the first <em >split</em> member, but this member
merely stores the <em >first</em> fields of the encountered <em >SplitPair</em>
elements in the vector pointed at by <em >words</em>, first clearing the
vector. This member returns the new value of <em >words->size()</em>.
<p>
<li> <strong >size_t split(std::vector<std::string> *words, std::string const &str,
char const *sep = " \t", bool addEmpty = false)</strong>:<br/>
This member acts like the previous one, using <em >addEmpty == false</em>
to select <em >mode TOK</em> and <em >addEmpty == true</em> to select <em >mode
TOKSEP</em>.
<p>
<li> <strong >std::string trim(std::string const &str)</strong>:<br/>
Returns a copy of <em >str</em> from which leading and trailing blank
characters were removed.
<p>
<li> <strong >std::string uc(std::string const &str)</strong>:<br/>
Returns a copy of <em >str</em> in which all letters were capitalized.
<p>
<li> <strong >std::string unescape(std::string const &str)</strong>:<br/>
Returns a copy of <em >str</em> in which the escaped (i.e., prefixed by a
backslash) characters were interpreted. All standard escape characters
(<em >\a</em>, <em >\b</em>, <em >\f</em>, <em >\n</em>, <em >\r</em>, <em >\t</em>, <em >\v</em>) are
recognized. If an escape character is followed by <em >x</em> at most the
next two characters are interpreted as a hexadecimal number. If an
escape character is followed by an octal digit, then at most the next
three characters following the <em >backslash</em> are interpreted as an
octal number. In all other cases, the backslash is removed and the
character following the backslash is kept.
<p>
<li> <strong >std::string urlDecode(std::string const &str)</strong>:<br/>
URL specifications use <em >%xx</em> encoding to encode characters, except
for alpha-numeric characters and the characters <em >- _ .</em> and <em >~</em>,
which are kept as-is. Other characters are encode by a <em >%</em>
character, followed by two hexadecimal characters representing those
characters' byte value. E.g., a blank space is encoded as <em >%20</em>, a
plus character is encoded as <em >%2B</em>. The member <em >urlDecode</em> returns
a <em >std::string</em> containing the decoded characters of the url-encoded
string that is passed as argument to this member.
<p>
<li> <strong >std::string urlEncode(std::string const &str)</strong>:<br/>
See the member <em >urlDecode</em>: <em >urlEncode</em> returns a <em >std::string</em>
containing the url-encoded characters of the characters in the string
that is passed as argument to this member.
</ul>
<p>
<h2 >EXAMPLE</h2>
<p>
<pre >
#include <iostream>
#include <vector>
#include <bobcat/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)
{
cout << "Program's name in uppercase: " << String::uc(argv[0]) << "\n\n";
vector<String::SplitPair> splitpair;
string text{ "one, two, 'thr\\x65\\145'" };
string encoded{ String::urlEncode(text) };
cout << "The string `" << text << "'\n"
" as url-encoded string: `" << encoded << "'\n"
" and the latter string url-decoded: " <<
String::urlDecode(encoded) << "\n"
"\n"
"Splitting `" << text << "' into " <<
String::split(&splitpair, text, String::STRSEP, ", ") <<
" fields\n";
for (auto it = splitpair.begin(); it != splitpair.end(); ++it)
cout << (it - splitpair.begin() + 1) << ": " <<
type[it->second] << ": `" << it->first <<
"', unescaped: `" << String::unescape(it->first) <<
"'\n";
cout << '\n' <<
text << ":\n"
" upper case: " << String::uc(text) << ",\n"
" lower case: " << String::lc(text) << '\n';
}
/*
Calling the program as
driver'
results in the following output:
Program's name in uppercase: DRIVER
Splitting `one, two, 'thr\x65\145'' into 9 fields
1: NORMAL: `one', unescaped: `one'
2: SEPARATOR: `,', unescaped: `,'
3: NORMAL: `', unescaped: `'
4: SEPARATOR: ` ', unescaped: ` '
5: NORMAL: `two', unescaped: `two'
6: SEPARATOR: `,', unescaped: `,'
7: NORMAL: `', unescaped: `'
8: SEPARATOR: ` ', unescaped: ` '
9: SQUOTE: `thr\x65\145', unescaped: `three'
one, two, 'thr\x65\145':
upper case: ONE, TWO, 'THR\X65\145',
lower case: one, two, 'thr\x65\145'
*/
</pre>
<p>
<h2 >FILES</h2>
<em >bobcat/string</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>
|