MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / rd_string

Method rd_string

extern/boost/boost/multiprecision/cpp_dec_float.hpp:2064–3485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2062
2063template <unsigned Digits10, class ExponentType, class Allocator>
2064bool 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 }

Callers

nothing calls this directly

Calls 15

negateMethod · 0.95
find_ifFunction · 0.85
zeroFunction · 0.85
absFunction · 0.85
eval_frexpFunction · 0.85
isoneMethod · 0.80
iszeroMethod · 0.80
isnegMethod · 0.80
negateClass · 0.50
twoClass · 0.50
findMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected