Validate string to double using std::isfinite
This commit is contained in:
parent
239396fec8
commit
75dd033cb0
3 changed files with 26 additions and 16 deletions
|
@ -35,17 +35,6 @@
|
|||
#include "support.h"
|
||||
#include "video.h"
|
||||
|
||||
bool str_to_double(const std::string& input, double &value) {
|
||||
bool result = false;
|
||||
size_t bytes_read = 0;
|
||||
try {
|
||||
value = std::stod(input, &bytes_read);
|
||||
if (bytes_read == input.size())
|
||||
result = true;
|
||||
} catch (std::invalid_argument &) {}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string get_basename(const std::string& filename) {
|
||||
// Guard against corner cases: '', '/', '\', 'a'
|
||||
if (filename.length() <= 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue