X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fdriver.cpp;h=6fbef93e1f13be64a90afcf3fb5a0037d11fe04a;hb=2c08ce7d004b20a1cd9bc68fccbf734a6ba2d242;hp=04df5f4e82465f9c8d57ab28b0e24ec222e122bb;hpb=269b667175f68821a3f2b871a097d4899d7abd78;p=r2c2.git diff --git a/source/libr2c2/driver.cpp b/source/libr2c2/driver.cpp index 04df5f4..6fbef93 100644 --- a/source/libr2c2/driver.cpp +++ b/source/libr2c2/driver.cpp @@ -1,3 +1,4 @@ +#include #include "arducontrol.h" #include "centralstation.h" #include "driver.h" @@ -5,6 +6,7 @@ #include "intellibox.h" using namespace std; +using namespace Msp; namespace R2C2 { @@ -29,4 +31,26 @@ Driver *Driver::create(const string &str) throw invalid_argument("Driver::create"); } + +Driver::Options::Options(const string &optstr) +{ + vector parts = split(optstr, ':'); + for(vector::const_iterator i=parts.begin(); i!=parts.end(); ++i) + { + string::size_type equals = i->find('='); + if(equals==0) + throw invalid_argument("Driver::Options::Options"); + + if(equals==string::npos) + set(string(), *i); + else + set(i->substr(0, equals), i->substr(equals+1)); + } +} + +void Driver::Options::set(const string &key, const string &value) +{ + opts[key] = value; +} + } // namespace R2C2