#include <string>#include <map>#include <locale>#include <iostream>#include <sstream>Include dependency graph for strtool.hpp:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Namespaces | |
| namespace | s11n |
| namespace | s11n::io |
| namespace | s11n::io::strtool |
| namespace | s11n::io::strtool::STPrivate |
Classes | |
| struct | s11n::io::strtool::entity_translator |
| YAGNI! More... | |
| struct | s11n::io::strtool::default_escapes_initializer |
| Internal-use initializer for setting up an entity translation map for default quote-escaping behaviour. More... | |
| struct | s11n::io::strtool::strtool_sharing_context< ContextT > |
| Internal marker type. More... | |
Defines | |
| #define | s11n_net_s11n_STRINGTOOL_HPP_INCLUDED 1 |
Typedefs | |
| typedef std::map< std::string, std::string > | s11n::io::strtool::entity_map |
| See translate_entities() for details. | |
Enumerations | |
| enum | s11n::io::strtool::TrimPolicy { s11n::io::strtool::TrimLeading = 0x01, s11n::io::strtool::TrimTrailing = 0x02, s11n::io::strtool::TrimAll = TrimLeading | TrimTrailing } |
| A policy enum used by trim_string(). More... | |
Functions | |
| template<typename value_type> | |
| value_type | s11n::io::strtool::STPrivate::from_string (const std::string &str, const value_type &errorVal) throw () |
| Lexically casts str to a value_type, returning errorVal if the conversion fails. | |
| template<typename value_type> | |
| std::string | s11n::io::strtool::STPrivate::to_string (const value_type &obj) throw () |
| Returns a string representation of the given object, which must be ostreamble. | |
| std::string | s11n::io::strtool::STPrivate::from_string (const std::string &str, const std::string &) throw () |
| Convenience/efficiency overload. | |
| std::string | s11n::io::strtool::STPrivate::from_string (const char *str, const char *) throw () |
| Convenience/efficiency overload. | |
| std::string | s11n::io::strtool::STPrivate::to_string (const char *obj) throw () |
| Convenience/efficiency overload. | |
| std::string | s11n::io::strtool::STPrivate::to_string (const std::string &obj) throw () |
| Convenience/efficiency overload. | |
| size_t | s11n::io::strtool::translate_entities (std::string &buffer, const entity_map &translation_map, bool reverse_translation=false) |
| For each entry in the input string, the characters are mapped to string sequences using the given translation_map. | |
| size_t | s11n::io::strtool::trim_string (std::string &, TrimPolicy=TrimAll) |
| Trims leading and trailing whitespace from the input string and returns the number of whitespace characters removed. | |
| std::string | s11n::io::strtool::trim_string (const std::string &, TrimPolicy=TrimAll) |
| Trims leading and trailing whitespace from the input string and returns the trimmed string. | |
| size_t | s11n::io::strtool::strip_slashes (std::string &str, const char slash= '\\') |
| Attempts to remove all backslash-escaped chars from str. | |
| size_t | s11n::io::strtool::escape_string (std::string &instring, const std::string &chars_to_escape, const std::string &escape_seq="\\") |
| Adds an escape sequence in front of any characters in instring which are also in the list of chars_to_escape. | |
| void | s11n::io::strtool::normalize_string (std::string &) |
| normalize_string() is like trim_string() and strip_slashes(), combined, plus it removes leading/trailing quotes: | |
| std::string | s11n::io::strtool::first_token (const std::string &) |
| Returns the first whitespace-delimited token from the given string, or an empty string if there is no such token. | |
| std::string | s11n::io::strtool::after_first_token (const std::string &) |
| Returns the passed-in string, minus the first whitespace-delimited token. | |
| int | s11n::io::strtool::int4hexchar (char character) |
| Returns int values for chars '0'-'9', 'a'-'f' and 'A'-'F', else -1. | |
| int | s11n::io::strtool::hex2int (const std::string &wd) |
| Returns decimal value of wd, which is assumed to be a hex-encoded number. | |
| template<typename ValueT> | |
| std::string | s11n::io::strtool::to (const ValueT &v) |
| Lexically casts v to a string. | |
| template<typename ValueT> | |
| ValueT | s11n::io::strtool::from (const std::string &v, const ValueT &dflt=ValueT()) |
| Lexically casts v to a ValueT, or returns dflt if conversion fails. | |
| const entity_map & | s11n::io::strtool::default_escapes_translations () |
| Returns the default entity translation map, which can be used to [un]slash-escape the folling entities: '\', '\'', '"'. | |
| template<typename ValueT> | |
| std::string | s11n::io::strtool::translate (const ValueT &v, const entity_map &trans, bool reverse) |
| Converts v to a string, applies translate_entities(. | |
| template<typename ValueT> | |
| std::string | s11n::io::strtool::escape (const ValueT &v, const entity_map &trans=default_escapes_translations()) |
| Calls translate( v,trans, false);. | |
| template<typename ValueT> | |
| std::string | s11n::io::strtool::unescape (const ValueT &v, const entity_map &trans=default_escapes_translations()) |
| Calls translate( v, trans, true );. | |
| template<typename ValueT> | |
| std::string | s11n::io::strtool::quote (const ValueT &v, const std::string "e="\'") |
| Returns v as a quoted string, using the given quote character. | |
| std::string | s11n::io::strtool::expand_dollar_refs (const std::string &text, const entity_map &src) |
| Exactly like expand_dollar_refs_inline() but returns a new string which results from the expansions. | |
| size_t | s11n::io::strtool::expand_dollar_refs_inline (std::string &buffer, const entity_map &src) |
| Parsed env vars out of buffer, replacing them with their values, as defined in the src map. | |
|
|
Definition at line 2 of file strtool.hpp. |
1.4.4