MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / toInt

Method toInt

Core/Utilities/Tools/QString.cpp:120–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120int QString::toInt(bool *ok, BaseCovert base) const
121{
122 int value = 0;
123 bool flag = false;
124 try
125 {
126 switch (base)
127 {
128 case BIN:
129 value = std::stoi(m_data, nullptr, 2);
130 break;
131 case DEC:
132 value = std::stoi(m_data, nullptr, 10);
133 break;
134 case HEX:
135 value = std::stoi(m_data, nullptr, 16);
136 break;
137 }
138
139 flag = true;
140 }
141 catch (const std::invalid_argument& ia)
142 {
143 std::cout << "Invalid argument: " << ia.what() << std::endl;
144 flag = false;
145 }
146 catch (const std::out_of_range& oor) {
147 std::cout << "Out of Range error: " << oor.what() << std::endl;
148 flag = false;
149 }
150
151 if (ok)
152 {
153 *ok = flag;
154 }
155
156 return value;
157}
158
159float QString::toFloat(bool *ok) const
160{

Callers 7

restoreParaFromCacheMethod · 0.80
restoreParaFromCacheMethod · 0.80
restoreParaFromCacheMethod · 0.80
mainFunction · 0.80
genGraphFunction · 0.80
genQTermPairFunction · 0.80
getOrbitalActMethod · 0.80

Calls 1

whatMethod · 0.45

Tested by

no test coverage detected