[ox/claw] Add readClawHeader to public API
This commit is contained in:
16
deps/ox/src/ox/claw/read.cpp
vendored
16
deps/ox/src/ox/claw/read.cpp
vendored
@@ -6,13 +6,13 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <ox/std/buffer.hpp>
|
||||
|
||||
#include "read.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
namespace detail {
|
||||
|
||||
Result<ClawHeader> readHeader(const char *buff, std::size_t buffLen) noexcept {
|
||||
Result<ClawHeader> readClawHeader(const char *buff, std::size_t buffLen) noexcept {
|
||||
const auto s1End = ox_strchr(buff, ';', buffLen);
|
||||
if (!s1End) {
|
||||
return OxError(1);
|
||||
@@ -57,13 +57,19 @@ Result<ClawHeader> readHeader(const char *buff, std::size_t buffLen) noexcept {
|
||||
return hdr;
|
||||
}
|
||||
|
||||
Result<ClawHeader> readClawHeader(const ox::Buffer &buff) noexcept {
|
||||
return readClawHeader(buff.data(), buff.size());
|
||||
}
|
||||
|
||||
Result<Buffer> stripClawHeader(const char *buff, std::size_t buffLen) noexcept {
|
||||
oxRequire(header, detail::readHeader(buff, buffLen));
|
||||
oxRequire(header, readClawHeader(buff, buffLen));
|
||||
Buffer out(header.dataSize);
|
||||
ox_memcpy(out.data(), header.data, out.size());
|
||||
return move(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
Result<Buffer> stripClawHeader(const ox::Buffer &buff) noexcept {
|
||||
return stripClawHeader(buff.data(), buff.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user