Skip to content

Commit 13f36cf

Browse files
committed
Fix: Convert to index from string key of toml
1 parent 2aa5606 commit 13f36cf

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/lib/user_config.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// along with servoarray. If not, see <http://www.gnu.org/licenses/>.
1515

1616
#include <toml11/toml.hpp>
17+
#include <boost/lexical_cast.hpp>
1718

1819
#include "servoarray/user_config.h"
1920

@@ -73,7 +74,13 @@ UserConfig::UserConfig(const std::string& path) {
7374
auto const config = toml::parse(path);
7475

7576
this->mapping_.names_ = toml::get_or<std::unordered_map<std::string, std::size_t>>(config, "mapping", {});
76-
this->offset_.offsets_ = toml::get_or<std::unordered_map<std::size_t, double>>(config, "offsets", {});
77+
{
78+
auto const offsets = toml::get_or<std::unordered_map<std::string, double>>(config, "offsets", {});
79+
for (auto const& p : offsets) {
80+
auto const idx = boost::lexical_cast<std::size_t>(p.first);
81+
this->offset_.offsets_[idx] = p.second;
82+
}
83+
}
7784

7885
// TODO: Seperate this into some function
7986
{

0 commit comments

Comments
 (0)