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
223 std::ostringstream out;
227 out << std::setprecision(17);
254 std::ostringstream out;
268 std::ostringstream out;
281 return value ?
"true" :
"false";
302 const char*
what() const GEO_NOEXCEPT override;
316 inline
bool from_string(const
char* s, T& value) {
317 std::istringstream in(s);
318 return (in >> value) && (in.eof() || ((in >> std::ws) && in.eof()));
347 value = strtod(s, &end);
348 return end != s && *end ==
'\0' && errno == 0;
358 template <
typename T>
368 end != s && *end ==
'\0' && errno == 0 &&
369 v >= std::numeric_limits<T>::min() &&
370 v <= std::numeric_limits<T>::max()
372 value =
static_cast<T
>(v);
414 value = _strtoi64(s, &end, 10);
416 value = strtoll(s, &end, 10);
418 return end != s && *end ==
'\0' && errno == 0;
428 template <
typename T>
438 end != s && *end ==
'\0' && errno == 0 &&
439 v <= std::numeric_limits<T>::max()
441 value =
static_cast<T
>(v);
483 value = _strtoui64(s, &end, 10);
485 value = strtoull(s, &end, 10);
487 return end != s && *end ==
'\0' && errno == 0;
502 if(strcmp(s,
"true") == 0 ||
503 strcmp(s,
"True") == 0 ||
509 if(strcmp(s,
"false") == 0 ||
510 strcmp(s,
"False") == 0 ||
528 inline int to_int(
const std::string& s) {
545 inline unsigned int to_uint(
const std::string& s) {
Common include file, providing basic definitions. Should be included before anything else by all head...
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.
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 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.