BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
ChecksumSensorDataParser.h
1 #pragma once
2 
3 #include "util/SensorDataParser.h"
4 
5 namespace BeeeOn {
6 
14 public:
16  ChecksumSensorDataParser(SensorDataParser::Ptr parser);
17 
22  void setDelimiter(const std::string &delimiter);
23  void setParser(SensorDataParser::Ptr parser);
24 
30  SensorData parse(const std::string &data) const override;
31 
32 protected:
36  SensorData parseNoDelimiter(const std::string &data) const;
37 
43  const std::string &prefix,
44  const std::string &content) const;
45 
46 private:
47  std::string m_delimiter;
48  SensorDataParser::Ptr m_parser;
49 };
50 
51 }
Definition: SensorData.h:20
ChecksumSensorDataParser parses data serialized by the equivalently configured ChecksumSensorDataForm...
Definition: ChecksumSensorDataParser.h:13
SensorData checkAndParse(const std::string &prefix, const std::string &content) const
Check the given checksum and parse the content by the configured parser.
Definition: ChecksumSensorDataParser.cpp:62
Definition: SensorDataParser.h:11
SensorData parse(const std::string &data) const override
Parse the given data string. Expect it to start with a checksum following by the given delimiter...
Definition: ChecksumSensorDataParser.cpp:39
void setDelimiter(const std::string &delimiter)
Set delimiter between the prepended checksum and the actual data part formatted by the wrapped format...
Definition: ChecksumSensorDataParser.cpp:29
SensorData parseNoDelimiter(const std::string &data) const
Parse the input data in case when the preset delimiter is empty.
Definition: ChecksumSensorDataParser.cpp:54