Skip to content

Commit

Permalink
trying stringstream for double (stod)
Browse files Browse the repository at this point in the history
  • Loading branch information
M4tteoP committed Aug 16, 2022
1 parent 6651741 commit 0ccef89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

11 changes: 6 additions & 5 deletions src/actions/rule_id.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ namespace actions {

bool RuleId::init(std::string *error) {
std::string a = m_parser_payload;

const auto format = std::chars_format::fixed;
const auto conv_res = std::from_chars(a.data(), a.data() + a.size(), m_ruleId, format);
if (conv_res.ec == std::errc::invalid_argument || conv_res.ec == std::errc::result_out_of_range) {
// Conversion error

std::stringstream ss;
ss<<a;
ss>>m_ruleId;
if (ss.fail()) {
ss.clear();
m_ruleId = 0;
error->assign("The input \"" + a + "\" does not " \
"seems to be a valid rule id.");
Expand Down

0 comments on commit 0ccef89

Please sign in to comment.