#pragma once
#include <boost/filesystem.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/property_tree/ptree.hpp>
struct low_high_value
{
low_high_value() : m_low(0), m_high(0) { }
low_high_value(double low, double high) : m_low(low), m_high(high) { }
double m_low;
double m_high;
};
struct low_high_value_translator
{
typedef std::string internal_type;
typedef low_high_value external_type;
// Get a low_high_value from a string
boost::optional<external_type> get_value(const internal_type& str)
{
if (!str.empty())
{
low_high_value val;
std::stringstream s(str);
s >> val.m_high >> val.m_low;
return boost::optional<external_type>(val);
}
else
return boost::optional<external_type>(boost::none);
}
// Create a string from a low_high_value
boost::optional<internal_type> put_value(const external_type& b)
{
std::stringstream ss;
ss << b.m_low << " " << b.m_high;
return boost::optional<internal_type>(ss.str());
}
};
namespace boost {
namespace property_tree
{
template<typename Ch, typename Traits, typename Alloc>
struct translator_between<std::basic_string< Ch, Traits, Alloc >, low_high_value>
{
typedef low_high_value_translator type;
};
}
}