Namespaces | Defines | Functions | Variables

serialization/string_utils.cpp File Reference

Various string-routines. More...

#include "global.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "serialization/string_utils.hpp"
#include "util.hpp"
#include <boost/array.hpp>
Include dependency graph for string_utils.cpp:

Go to the source code of this file.

Namespaces

namespace  utils

Defines

#define ERR_GENERAL   LOG_STREAM(err, lg::general)
#define ERR_NG   LOG_STREAM(err, log_engine)

Functions

bool utils::isnewline (const char c)
bool utils::portable_isspace (const char c)
bool utils::notspace (const char c)
std::vector< std::string > utils::split (std::string const &val, char c, int flags)
std::vector< std::string > utils::parenthetical_split (std::string const &val, const char separator=0, std::string const &left="(", std::string const &right=")", int flags=REMOVE_EMPTY|STRIP_SPACES)
 Splits a string based either on a separator where text within parenthesis is protected from splitting (Note that one can use the same character for both the left and right parenthesis.
int utils::apply_modifier (const int number, const std::string &amount, const int minimum)
std::string utils::escape (const std::string &str, const char *special_chars)
 Prepends a configurable set of characters with a backslash.
static void utils::si_string_impl_stream_write (std::stringstream &ss, double input)
static bool utils::is_username_char (char c)
static bool utils::is_wildcard_char (char c)
static bool utils::is_word_boundary (char c)
std::vector< std::string > utils::quoted_split (std::string const &val, char c= ',', int flags=REMOVE_EMPTY|STRIP_SPACES, char quote= '\\')
 This function is identical to split(), except it does not split when it otherwise would if the previous character was identical to the parameter 'quote'.
std::pair< int, int > utils::parse_range (std::string const &str)
std::vector< std::pair< int,
int > > 
utils::parse_ranges (std::string const &str)
static int utils::byte_size_from_utf8_first (unsigned char ch)

std::string & utils::strip (std::string &str)
 Remove whitespace from the front and back of the string 'str'.
std::string utils::unescape (const std::string &str)
 Remove all escape characters (backslash).
bool utils::string_bool (const std::string &str, bool def=false)
 Convert no, false, off, 0, 0.0 to false, empty to def, and others to true.
std::string utils::signed_value (int val)
 Convert into a signed value (using the Unicode "−" and +0 convention.
std::string utils::half_signed_value (int val)
 Sign with Unicode "−" if negative.
std::string utils::si_string (double input, bool base2, std::string unit)
 Convert into a string with an SI-postfix.
bool utils::isvalid_username (const std::string &login)
 Check if the username contains only valid characters.
bool utils::isvalid_wildcard (const std::string &login)
 Check if the username pattern contains only valid characters.
bool utils::word_completion (std::string &text, std::vector< std::string > &wordlist)
 Try to complete the last word of 'text' with the 'wordlist'.
bool utils::word_match (const std::string &message, const std::string &word)
 Check if a message contains a word.
bool utils::wildcard_string_match (const std::string &str, const std::string &match)
 Match using '*' as any number of characters (including none), and '?' as any one character.
std::string utils::wstring_to_string (const wide_string &src)
std::string utils::wchar_to_string (const wchar_t c)
wide_string utils::string_to_wstring (const std::string &src)
utf8_string utils::lowercase (const utf8_string &)
 Returns a lowercased version of the string.
void utils::truncate_as_wstring (std::string &str, const size_t size)
 Truncates a string.
void utils::ellipsis_truncate (std::string &str, const size_t size)
 Truncates a string to a given utf-8 character count and then appends an ellipsis.

Variables

static lg::log_domain log_engine ("engine")
const std::string utils::ellipsis = "..."
const std::string utils::unicode_minus = "−"
const std::string utils::unicode_en_dash = "–"
const std::string utils::unicode_em_dash = "—"
const std::string utils::unicode_figure_dash = "‒"
const std::string utils::unicode_multiplication_sign = "×"
const std::string utils::unicode_bullet = "•"

Detailed Description

Various string-routines.

Definition in file string_utils.cpp.


Define Documentation

#define ERR_GENERAL   LOG_STREAM(err, lg::general)

Definition at line 32 of file string_utils.cpp.

#define ERR_NG   LOG_STREAM(err, log_engine)

Definition at line 33 of file string_utils.cpp.


Variable Documentation

lg::log_domain log_engine("engine") [static]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:10:12 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs