30 inline bool FromString(
const std::string& stringToCopyDataFrom, T& data)
noexcept {
return false; }
43 inline bool FromString(
const std::string& stringToCopyDataFrom, std::string& data)
noexcept
45 data = stringToCopyDataFrom;
64 inline bool FromString(
const std::string& stringToCopyDataFrom,
bool& data)
noexcept
66 if (stringToCopyDataFrom ==
"true")
71 if (stringToCopyDataFrom ==
"false")
94 if (stringToCopyDataFrom.length() == 0)
return false;
96 int integer = 0, fractional = 0;
99 bool isNegative =
false;
101 if (stringToCopyDataFrom[0] ==
'-' && stringToCopyDataFrom.length() > 1)
107 for (; i < stringToCopyDataFrom.length(); ++i)
109 if (stringToCopyDataFrom[i] ==
'.')
115 if (stringToCopyDataFrom[i] <
'0' || stringToCopyDataFrom[i] >
'9')
return false;
117 integer +=
static_cast<int>(stringToCopyDataFrom[i] -
'0');
121 for (; i < stringToCopyDataFrom.length(); ++i)
123 if (stringToCopyDataFrom[i] <
'0' || stringToCopyDataFrom[i] >
'9')
return false;
126 fractional +=
static_cast<int>(stringToCopyDataFrom[i] -
'0');
129 data =
static_cast<T
>(integer) +
static_cast<T
>(fractional) * coeff;
131 if (isNegative) data *= -1;
147 inline bool FromString(
const std::string& stringToCopyDataFrom,
float& data)
noexcept
163 inline bool FromString(
const std::string& stringToCopyDataFrom,
double& data)
noexcept
185 if (stringToCopyDataFrom.length() == 0)
return false;
190 bool isNegative =
false;
192 if (stringToCopyDataFrom[0] ==
'-' && stringToCopyDataFrom.length() > 1)
198 for (; i < stringToCopyDataFrom.length(); ++i)
200 if (stringToCopyDataFrom[i] <
'0' || stringToCopyDataFrom[i] >
'9')
return false;
202 res +=
static_cast<int>(stringToCopyDataFrom[i] -
'0');
205 if (isNegative) data = res * -1;
222 inline bool FromString(
const std::string& stringToCopyDataFrom,
short& data)
noexcept
238 inline bool FromString(
const std::string& stringToCopyDataFrom,
int& data)
noexcept
254 inline bool FromString(
const std::string& stringToCopyDataFrom,
long& data)
noexcept
270 inline bool FromString(
const std::string& stringToCopyDataFrom,
long long& data)
noexcept
292 if (stringToCopyDataFrom.length() == 0)
return false;
296 for (std::size_t i = 0; i < stringToCopyDataFrom.length(); ++i)
298 if (stringToCopyDataFrom[i] <
'0' || stringToCopyDataFrom[i] >
'9')
return false;
300 res +=
static_cast<int>(stringToCopyDataFrom[i] -
'0');
318 inline bool FromString(
const std::string& stringToCopyDataFrom,
unsigned short& data)
noexcept
334 inline bool FromString(
const std::string& stringToCopyDataFrom,
unsigned int& data)
noexcept
350 inline bool FromString(
const std::string& stringToCopyDataFrom,
unsigned long& data)
noexcept
366 inline bool FromString(
const std::string& stringToCopyDataFrom,
unsigned long long& data)
noexcept
bool FromStringUnsignedInt(const std::string &stringToCopyDataFrom, T &data) noexcept
FromStringSignedInt template for working with all unsigned signed integers.
Definition FromString.h:290
bool FromStringDoubleAndFloat(const std::string &stringToCopyDataFrom, T &data) noexcept
FromStringDoubleAndFloat template for working with float and double.
Definition FromString.h:92
bool FromStringSignedInt(const std::string &stringToCopyDataFrom, T &data) noexcept
FromStringSignedInt template for working with all signed integers.
Definition FromString.h:183
bool FromString(const std::string &stringToCopyDataFrom, T &data) noexcept
A template method for providing an interface converting string to a any type.
Definition FromString.h:30