17 #ifndef SCIP2_RESPONSE_PARAMETERS_H 18 #define SCIP2_RESPONSE_PARAMETERS_H 20 #include <boost/asio.hpp> 33 using Callback = boost::function<void(
34 const boost::posix_time::ptime&,
37 const std::map<std::string, std::string>&)>;
45 const boost::posix_time::ptime& time_read,
46 const std::string& echo_back,
47 const std::string& status,
50 std::map<std::string, std::string> params;
54 cb_(time_read, echo_back, status, params);
58 while (std::getline(stream, line))
62 const auto delm = std::find(line.begin(), line.end(),
':');
63 if (delm == line.end())
68 const auto end = std::find(line.begin(), line.end(),
';');
69 if (end == line.end())
74 const uint8_t checksum = line.back();
76 for (
auto it = line.begin(); it != end; ++it)
80 if ((sum & 0x3F) + 0x30 != checksum)
82 logger::error() <<
"Checksum mismatch; parameters dropped" << std::endl;
85 const std::string key(line.begin(), delm);
86 const std::string value(delm + 1, end);
90 cb_(time_read, echo_back, status, params);
103 return std::string(
"PP");
112 return std::string(
"VV");
121 return std::string(
"II");
127 #endif // SCIP2_RESPONSE_PARAMETERS_H void registerCallback(Callback cb)
virtual std::string getCommandCode() const =0
boost::function< void(const boost::posix_time::ptime &, const std::string &, const std::string &, const std::map< std::string, std::string > &)> Callback
void operator()(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, std::istream &stream)
std::string getCommandCode() const
std::string getCommandCode() const
std::string getCommandCode() const