diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-11 15:49:47 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-11 15:49:47 +0200 |
commit | a58d40b5ae336a54408201963b065ee049b43acd (patch) | |
tree | 9769e3d5b624e0238fe550df601e5382f259c52e /can-config-generator/src/openxc/mapping.cpp | |
parent | 9e444ade872bc436cf12bc12d03c3a5d51ac0b9e (diff) | |
parent | b7591d16c2686214d5d8dcc0739a233f15aee5db (diff) |
Add 'can-config-generator/' from commit 'b7591d16c2686214d5d8dcc0739a233f15aee5db'
git-subtree-dir: can-config-generator
git-subtree-mainline: 9e444ade872bc436cf12bc12d03c3a5d51ac0b9e
git-subtree-split: b7591d16c2686214d5d8dcc0739a233f15aee5db
Diffstat (limited to 'can-config-generator/src/openxc/mapping.cpp')
-rwxr-xr-x | can-config-generator/src/openxc/mapping.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/can-config-generator/src/openxc/mapping.cpp b/can-config-generator/src/openxc/mapping.cpp new file mode 100755 index 00000000..74d5c94e --- /dev/null +++ b/can-config-generator/src/openxc/mapping.cpp @@ -0,0 +1,59 @@ +#include "mapping.hpp"
+
+namespace openxc
+{
+ std::string mapping::mapping_name() const
+ {
+ return mapping_name_;
+ }
+
+ std::string mapping::bus() const
+ {
+ return bus_;
+ }
+
+ std::string mapping::database() const
+ {
+ return database_;
+ }
+
+ bool mapping::bit_numbering_inverted() const
+ {
+ return bit_numbering_inverted_;
+ }
+
+ bool mapping::enabled() const
+ {
+ return enabled_;
+ }
+
+ void mapping::from_json(const nlohmann::json& j)
+ {
+ mapping_name_ = j.count("mapping") ? j["mapping"].get<std::string>() : "";
+ bus_ = j.count("bus") ? j["bus"].get<std::string>() : "";
+ database_ = j.count("database") ? j["database"].get<std::string>() : "";
+ bit_numbering_inverted_ = j.count("bit_numbering_inverted") ? j["bit_numbering_inverted"].get<bool>() : false;
+ enabled_ = j.count("enabled") ? j["enabled"].get<bool>() : true;
+ }
+
+ nlohmann::json mapping::to_json() const
+ {
+ nlohmann::json j;
+ j["mapping"] = mapping_name_;
+ j["bus"] = bus_;
+ j["database"] = database_;
+ j["bit_numbering_inverted"] = bit_numbering_inverted_;
+ j["enabled"] = enabled_;
+ return j;
+ }
+
+ void to_json(nlohmann::json& j, const mapping& p)
+ {
+ j = p.to_json();
+ }
+
+ void from_json(const nlohmann::json& j, mapping& p)
+ {
+ p.from_json(j);
+ }
+}
|