Commit 1978fdb2 authored by Michael Ott's avatar Michael Ott
Browse files

Add toString() function for SensorId

parent 2589f831
......@@ -104,6 +104,13 @@ public:
*/
std::string serialize() const;
/**
* @brief This function returns a hex string which corresponds to the
* supplied SensorId object.
* @return Returns a human-readable hex string of the SensorId.
*/
std::string toString() const;
/**
* @brief This function matches the sensor against a
* sensor pattern string.
......
......@@ -28,6 +28,7 @@
#include <algorithm>
#include <cstdint>
#include <cinttypes>
#include <cstdio>
#include <boost/algorithm/string.hpp>
......@@ -150,6 +151,18 @@ std::string SensorId::serialize() const
return std::string((char*)ll, 16);
}
/**
* @details
* This function returns a hex representation of a SensorId as a
* 32-character std::string.
*/
std::string SensorId::toString() const
{
char buf[33];
snprintf(buf, sizeof(buf), "%016lx%016lx", data.raw[0], data.raw[1]);
return std::string(buf);
}
/**
* @details
* This function strips all slashes from the pattern string and
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment