1 #include <msp/strings/utils.h>
2 #include "arducontrol.h"
3 #include "centralstation.h"
6 #include "intellibox.h"
13 Driver *Driver::create(const string &str)
15 string::size_type colon = str.find(':');
16 string type = str.substr(0, colon);
19 if(colon!=string::npos)
20 params = str.substr(colon+1);
22 if(type=="ib" || type=="intellibox")
23 return new Intellibox(params);
24 else if(type=="cs" || type=="centralstation")
25 return new CentralStation(params);
26 else if(type=="ac" || type=="arducontrol")
27 return new ArduControl(params);
28 else if(type=="dummy")
29 return new Dummy(params);
31 throw invalid_argument("Driver::create");
35 Driver::Options::Options(const string &optstr)
37 vector<string> parts = split(optstr, ':');
38 for(vector<string>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
40 string::size_type equals = i->find('=');
42 throw invalid_argument("Driver::Options::Options");
44 if(equals==string::npos)
47 set(i->substr(0, equals), i->substr(equals+1));
51 void Driver::Options::set(const string &key, const string &value)