| 2062 | |
| 2063 | template <unsigned Digits10, class ExponentType, class Allocator> |
| 2064 | bool cpp_dec_float<Digits10, ExponentType, Allocator>::rd_string(const char* const s) |
| 2065 | { |
| 2066 | #ifndef BOOST_NO_EXCEPTIONS |
| 2067 | try |
| 2068 | { |
| 2069 | #endif |
| 2070 | |
| 2071 | std::string str(s); |
| 2072 | |
| 2073 | // TBD: Using several regular expressions may significantly reduce |
| 2074 | // the code complexity (and perhaps the run-time) of rd_string(). |
| 2075 | |
| 2076 | // Get a possible exponent and remove it. |
| 2077 | exp = static_cast<exponent_type>(0); |
| 2078 | |
| 2079 | std::size_t pos; |
| 2080 | |
| 2081 | if (((pos = str.find('e')) != std::string::npos) || ((pos = str.find('E')) != std::string::npos)) |
| 2082 | { |
| 2083 | // Remove the exponent part from the string. |
| 2084 | #ifndef BOOST_MP_STANDALONE |
| 2085 | exp = boost::lexical_cast<exponent_type>(static_cast<const char*>(str.c_str() + (pos + 1u))); |
| 2086 | #else |
| 2087 | exp = static_cast<exponent_type>(std::atoll(static_cast<const char*>(str.c_str() + (pos + 1u)))); |
| 2088 | #endif |
| 2089 | |
| 2090 | str = str.substr(static_cast<std::size_t>(0u), pos); |
| 2091 | } |
| 2092 | |
| 2093 | // Get a possible +/- sign and remove it. |
| 2094 | neg = false; |
| 2095 | |
| 2096 | if (str.size()) |
| 2097 | { |
| 2098 | if (str[0] == '-') |
| 2099 | { |
| 2100 | neg = true; |
| 2101 | str.erase(0, 1); |
| 2102 | } |
| 2103 | else if (str[0] == '+') |
| 2104 | { |
| 2105 | str.erase(0, 1); |
| 2106 | } |
| 2107 | } |
| 2108 | // |
| 2109 | // Special cases for infinities and NaN's: |
| 2110 | // |
| 2111 | if ((str == "inf") || (str == "INF") || (str == "infinity") || (str == "INFINITY")) |
| 2112 | { |
| 2113 | if (neg) |
| 2114 | { |
| 2115 | *this = this->inf(); |
| 2116 | this->negate(); |
| 2117 | } |
| 2118 | else |
| 2119 | *this = this->inf(); |
| 2120 | return true; |
| 2121 | } |
nothing calls this directly
no test coverage detected