Added offset capabilities for integers
This commit is contained in:
@@ -83,7 +83,7 @@ namespace YAML {
|
|||||||
// return node;
|
// return node;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
static bool decode(const YAML::Node& node, GeneralSettings& rhs) {
|
static bool decode(const Node& node, GeneralSettings& rhs) {
|
||||||
|
|
||||||
node["version"] >> rhs.version;
|
node["version"] >> rhs.version;
|
||||||
node["versionBla"] >> rhs.version;
|
node["versionBla"] >> rhs.version;
|
||||||
@@ -93,8 +93,10 @@ namespace YAML {
|
|||||||
node["contrast"] >> rhs.contrast;
|
node["contrast"] >> rhs.contrast;
|
||||||
node["vBatWarn"] >> rhs.vBatWarn;
|
node["vBatWarn"] >> rhs.vBatWarn;
|
||||||
node["txVoltageCalibration"] >> rhs.txVoltageCalibration;
|
node["txVoltageCalibration"] >> rhs.txVoltageCalibration;
|
||||||
node["vBatMin"] >> rhs.vBatMin;
|
|
||||||
node["vBatMax"] >> rhs.vBatMax;
|
node["vBatMin"] >> ioffset_int(rhs.vBatMin, 90);
|
||||||
|
node["vBatMax"] >> ioffset_int(rhs.vBatMax, 120);
|
||||||
|
|
||||||
node["backlightMode"] >> backlightModeLut >> rhs.backlightMode;
|
node["backlightMode"] >> backlightModeLut >> rhs.backlightMode;
|
||||||
node["trainer"] >> rhs.trainer;
|
node["trainer"] >> rhs.trainer;
|
||||||
node["view"] >> rhs.view;
|
node["view"] >> rhs.view;
|
||||||
|
|||||||
@@ -25,6 +25,23 @@
|
|||||||
typedef std::pair<int, std::string> YamlLookupTableElmt;
|
typedef std::pair<int, std::string> YamlLookupTableElmt;
|
||||||
typedef std::vector<YamlLookupTableElmt> YamlLookupTable;
|
typedef std::vector<YamlLookupTableElmt> YamlLookupTable;
|
||||||
|
|
||||||
|
class ioffset_int {
|
||||||
|
|
||||||
|
public:
|
||||||
|
ioffset_int(int& val, int offset)
|
||||||
|
: value(val), offset(offset)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void assign(int newValue) const {
|
||||||
|
value = newValue - offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int& value;
|
||||||
|
int offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
YAML::Node operator >> (const YAML::Node& node, const YamlLookupTable& lut)
|
YAML::Node operator >> (const YAML::Node& node, const YamlLookupTable& lut)
|
||||||
{
|
{
|
||||||
if (node) {
|
if (node) {
|
||||||
@@ -44,6 +61,13 @@ YAML::Node operator>>(const YAML::Node& node, const YamlLookupTable& lut)
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator >> (const YAML::Node& node, const ioffset_int& value)
|
||||||
|
{
|
||||||
|
if (node && node.IsScalar()) {
|
||||||
|
value.assign(node.as<int>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void operator >> (const YAML::Node& node, T& value)
|
void operator >> (const YAML::Node& node, T& value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user