| 110 | } |
| 111 | |
| 112 | std::optional<std::vector<char>> OSCBlob::GetBinary() const |
| 113 | { |
| 114 | std::vector<char> bytes; |
| 115 | std::string hexString = _stringRep; |
| 116 | |
| 117 | for (std::size_t i = 2; i < hexString.size(); i += 4) { |
| 118 | try { |
| 119 | auto byteString = hexString.substr(i, 2); |
| 120 | int value = std::stoi(byteString, nullptr, 16); |
| 121 | bytes.push_back(static_cast<char>(value)); |
| 122 | } catch (const std::exception &e) { |
| 123 | blog(LOG_WARNING, |
| 124 | "failed to convert hex \"%s\" to binary: %s", |
| 125 | hexString.c_str(), e.what()); |
| 126 | return {}; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | return bytes; |
| 131 | } |
| 132 | |
| 133 | void OSCBlob::Save(obs_data_t *obj, const char *name) const |
| 134 | { |
no test coverage detected