System.AnsiString.from_string
C++
bool from_string(const AnsiStringT<CP> &str, bool &value);
bool from_string(const AnsiStringT<CP> &str, Extended &value);
bool from_string(const AnsiStringT<CP> &str, const Sysutils::TFormatSettings &settings, Extended &value);
bool from_string(const AnsiStringT<CP> &str, int &value);
bool from_string(const AnsiStringT<CP> &str, long long &value);
bool from_string(const AnsiStringT<CP> &str, unsigned int &value);
bool from_string(const AnsiStringT<CP> &str, unsigned long long &value);
bool from_string(const AnsiStringT<CP> &str, TDateTime &value);
bool from_string(const AnsiStringT<CP> &str, const Sysutils::TFormatSettings &settings, TDateTime &value);
bool from_string(const AnsiStringT<CP> &str, Currency &value);
bool from_string(const AnsiStringT<CP> &str, const Sysutils::TFormatSettings &settings, Currency &value);
bool from_string(const AnsiStringT<CP> &str, unsigned long long &value)
Properties
| Type | Visibility | Source | Unit | Parent |
|---|---|---|---|---|
| function | public | .h | System | AnsiString |
Description
Converts from an AnsiString to other types, such as from a string to an integer.
Several methods have overloads to apply specific formatting when converting the string, which specifies the format the string uses and how to convert it. For example, you can convert from an AnsiString to a Boolean, various sizes of signed and unsigned integers, floating-point types, and the special types Variant, TDateTime, and Currency.
The function converts all valid characters while ignoring the invalid ones, and in case there are no valid characters found the function returns false. Any leading spaces are ignored. The function´s base conversion assumes is 10 unless there is a leading x or 0x for which case the base is 16. See the example below:
AnsiString str = "100ABC";
int i;
from_string(str, i);
// In this case: i == 100