MCPcopy Create free account
hub / github.com/VitalAudio/visage / parseNumber

Function parseNumber

visage_graphics/path.cpp:162–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160 }
161
162 static float parseNumber(const std::string& str, size_t& i, bool bit_flags = false) {
163 std::string number;
164 while (i < str.size()) {
165 bool sign = str[i] == '-' || str[i] == '+';
166 if (std::isdigit(str[i]) || (number.empty() && sign) || str[i] == '.' || str[i] == 'e' ||
167 str[i] == 'E') {
168 if (str[i] == '.') {
169 if (number.find('.') != std::string::npos)
170 return toFloat(number);
171 }
172 number += str[i++];
173 }
174 else if (str[i] == ',' || std::isspace(str[i]) || sign) {
175 if (!number.empty())
176 return toFloat(number);
177 if (!sign)
178 ++i;
179 }
180 else if (std::isalpha(str[i]))
181 break;
182 else
183 ++i;
184
185 if (bit_flags && !number.empty())
186 return toFloat(number);
187 }
188 if (number.empty()) {
189 VISAGE_ASSERT(false);
190 return 0.0f;
191 }
192 return toFloat(number);
193 }
194
195 Path::CommandList Path::parseSvgPath(const std::string& path) {
196 CommandList commands;

Callers 1

parseSvgPathMethod · 0.70

Calls 3

toFloatFunction · 0.85
findMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected