| | |
| | | #include "ToolUnits.h" |
| | | #include <chrono> |
| | | #include <memory> |
| | | #include <sstream> |
| | | |
| | | |
| | | CToolUnits::CToolUnits() |
| | |
| | | bool CToolUnits::startsWith(const std::string& str, const std::string& prefix) |
| | | { |
| | | return str.size() >= prefix.size() && str.compare(0, prefix.size(), prefix) == 0; |
| | | } |
| | | |
| | | std::string& CToolUnits::toHexString(int value, std::string& strOut) |
| | | { |
| | | std::stringstream ss; |
| | | ss << std::hex << value; |
| | | strOut = ss.str(); |
| | | |
| | | return strOut; |
| | | } |
| | | |
| | | void CToolUnits::convertString(const char* pszBuffer, int size, std::string& strOut) |
| | | { |
| | | strOut.clear(); |
| | | int nLength = 0; |
| | | for (int i = 0; i < size; i++) { |
| | | if (pszBuffer[i] == '\0') break; |
| | | nLength++; |
| | | } |
| | | if (nLength > 0) { |
| | | strOut = std::string(pszBuffer, nLength); |
| | | } |
| | | } |