MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / GetBinary

Method GetBinary

plugins/base/utils/osc-helpers.cpp:112–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112std::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
133void OSCBlob::Save(obs_data_t *obj, const char *name) const
134{

Callers 1

operator()Method · 0.80

Calls 4

sizeMethod · 0.80
substrMethod · 0.80
c_strMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected