28 #include <boost/shared_array.hpp>
35 if (str.length() > 0 && escape_chars.length() > 0) {
37 boost::shared_array<char> escaped_str(
new char [(2 * str.length()) + 1]);
38 char *dst = escaped_str.get();
40 memset(escaped, 0, 256 *
sizeof(
bool));
41 for (
size_t i = 0; i < escape_chars.length(); i++)
42 escaped[(
size_t)escape_chars[i]] =
true;
43 escaped[(size_t)
'\\'] =
true;
45 const char *src = str.c_str();
48 if (escaped[(
size_t)*src])
53 str =
String(escaped_str.get());
58 if (str.length() > 0) {
59 boost::shared_array<char> escaped_str(
new char [str.length() + 1]);
60 char *dst = escaped_str.get();
61 for (
const char *src = str.c_str(); *src; src++) {
62 if (*src ==
'\\' && *(src + 1) ==
'\\')
64 else if (*src !=
'\\')
68 str =
String(escaped_str.get());
std::string String
A String is simply a typedef to std::string.
Po::typed_value< String > * str(String *v=0)
void escape(String &str, const String &escape_chars)
Escapes a string.
Compatibility Macros for C/C++.
void unescape(String &str)
Unescapes a string.
Escape/Unescape routines for strings.