MCPcopy Create free account
hub / github.com/csmith-project/csmith / str2int

Method str2int

src/StringUtils.cpp:172–187  ·  view source on GitHub ↗

convert string to number, take care of surrounding parentheses */

Source from the content-addressed store, hash-verified

170
171/* convert string to number, take care of surrounding parentheses */
172int
173StringUtils::str2int(const std::string &s)
174{
175 if (!s.empty() && s[0] == '(') {
176 assert(s[s.length()-1] == ')');
177 return str2int(s.substr(1, s.length()-2));
178 }
179 stringstream ss(s);
180 int i = -1;
181 if (s.find("0x")==0) {
182 ss >> std::hex >> i;
183 } else {
184 ss >> i;
185 }
186 return i;
187}
188
189std::string
190StringUtils::int2str(int i)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected