Commit d7409c12 authored by Alessio Netti's avatar Alessio Netti

Metadata: fixed parsing of scaling factors

- Default C++ to_string implementation only supplies 6 decimal digits of
accuracy, truncating very small scaling factors
- Now using string streams
parent c4f29335
......@@ -37,6 +37,7 @@
#include <boost/property_tree/json_parser.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string.hpp>
#include <sstream>
#include "globalconfiguration.h"
using namespace std;
......@@ -196,6 +197,8 @@ protected:
// Dumps the contents of "s" in "config"
void _dumpPTREE(boost::property_tree::ptree& config) const {
std::ostringstream scaleStream;
scaleStream << this->scale;
config.clear();
config.push_back(boost::property_tree::ptree::value_type("isVirtual", boost::property_tree::ptree(this->isVirtual ? "true" : "false")));
config.push_back(boost::property_tree::ptree::value_type("monotonic", boost::property_tree::ptree(this->monotonic ? "true" : "false")));
......@@ -203,7 +206,7 @@ protected:
config.push_back(boost::property_tree::ptree::value_type("unit", boost::property_tree::ptree(this->unit)));
config.push_back(boost::property_tree::ptree::value_type("publicName", boost::property_tree::ptree(this->publicName)));
config.push_back(boost::property_tree::ptree::value_type("pattern", boost::property_tree::ptree(this->pattern)));
config.push_back(boost::property_tree::ptree::value_type("scale", boost::property_tree::ptree(to_string(this->scale))));
config.push_back(boost::property_tree::ptree::value_type("scale", boost::property_tree::ptree(scaleStream.str())));
config.push_back(boost::property_tree::ptree::value_type("interval", boost::property_tree::ptree(to_string(this->interval / 1000000))));
config.push_back(boost::property_tree::ptree::value_type("ttl", boost::property_tree::ptree(to_string(this->ttl / 1000000))));
config.push_back(boost::property_tree::ptree::value_type("operations", boost::property_tree::ptree(this->operations)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment