40 #ifndef GEOGRAM_BASIC_STRING
41 #define GEOGRAM_BASIC_STRING
82 const std::string& in,
84 std::vector<std::string>& out,
85 bool skip_empty_fields =
true
100 const std::string& in,
101 const std::string& separator,
102 std::vector<std::string>& out,
103 bool skip_empty_fields =
true
120 const std::string& in,
136 const std::vector<std::string>& in,
150 const std::vector<std::string>& in,
151 const std::string& separator
179 return std::string(s);
191 const std::string& s,
char quotes =
'\"'
202 const std::string& haystack,
const std::string& needle
213 const std::string& haystack,
const std::string& needle
221 std::string GEOGRAM_API
format(
const char* format, ...)
223 #ifdef GEO_COMPILER_GCC_FAMILY
227 __attribute__ ((__format__(printf, 1, 2)))
239 std::ostringstream out;
243 out << std::setprecision(17);
270 std::ostringstream out;
284 std::ostringstream out;
297 return value ?
"true" :
"false";
318 const char*
what() const GEO_NOEXCEPT override;
332 inline
bool from_string(const
char* s, T& value) {
333 std::istringstream in(s);
334 return (in >> value) && (in.eof() || ((in >> std::ws) && in.eof()));
363 value = strtod(s, &end);
364 return end != s && *end ==
'\0' && errno == 0;
374 template <
typename T>
378 #ifdef GEO_OS_WINDOWS
384 end != s && *end ==
'\0' && errno == 0 &&
385 v >= std::numeric_limits<T>::min() &&
386 v <= std::numeric_limits<T>::max()
388 value =
static_cast<T
>(v);
429 #ifdef GEO_OS_WINDOWS
430 value = _strtoi64(s, &end, 10);
432 value = strtoll(s, &end, 10);
434 return end != s && *end ==
'\0' && errno == 0;
444 template <
typename T>
448 #ifdef GEO_OS_WINDOWS
454 end != s && *end ==
'\0' && errno == 0 &&
455 v <= std::numeric_limits<T>::max()
457 value =
static_cast<T
>(v);
498 #ifdef GEO_OS_WINDOWS
499 value = _strtoui64(s, &end, 10);
501 value = strtoull(s, &end, 10);
503 return end != s && *end ==
'\0' && errno == 0;
518 if(strcmp(s,
"true") == 0 ||
519 strcmp(s,
"True") == 0 ||
525 if(strcmp(s,
"false") == 0 ||
526 strcmp(s,
"False") == 0 ||
544 inline int to_int(
const std::string& s) {
561 inline unsigned int to_uint(
const std::string& s) {
ConversionError(const std::string &s, const std::string &type)
Constructs a conversion exception.
const char * what() const GEO_NOEXCEPT override
Gets the string identifying the exception.
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
Types and functions for numbers manipulation.
Functions for string manipulation.
std::string to_string(const T &value)
Converts a typed value to a string.
bool string_to_unsigned_integer(const char *s, T &value)
Converts a string to a unsigned integer value.
std::string wchar_to_UTF8(const wchar_t *in)
Converts a wide char string into an UTF8 string.
std::string to_uppercase(const std::string &s)
Converts a string to uppercase.
std::string char_to_string(char c)
Creates a one char string.
bool from_string(const char *s, T &value)
Converts a C string to a typed value.
void split_string(const std::string &in, char separator, std::vector< std::string > &out, bool skip_empty_fields=true)
Splits a string into parts.
int to_int(const std::string &s)
Converts a string to an int.
bool string_starts_with(const std::string &haystack, const std::string &needle)
Checks if a string starts with a substring.
bool string_ends_with(const std::string &haystack, const std::string &needle)
Checks if a string ends with a substring.
std::string format(const char *format,...)
Creates a string from a format string and additional arguments. Works like sprintf()
std::string join_strings(const std::vector< std::string > &in, char separator)
Join multiple strings.
std::string quote(const std::string &s, char quotes='\"' )
Adds quotes to a string.
unsigned int to_uint(const std::string &s)
Converts a string to an unsigned int.
std::string to_lowercase(const std::string &s)
Converts a string to lowercase.
std::string to_display_string(const T &value)
Converts a typed value to a string for display.
bool to_bool(const std::string &s)
Converts a string to a boolean.
bool string_to_signed_integer(const char *s, T &value)
Converts a string to a signed integer value.
double to_double(const std::string &s)
Converts a string to a double.