[Yunq] Read capabilities using the parsing library.
This commit is contained in:
parent
0e6aa532a1
commit
75d84a0fa5
7 changed files with 41 additions and 40 deletions
|
|
@ -49,4 +49,14 @@ glcr::ErrorOr<glcr::Vector<uint64_t>> MessageView::ReadRepeated<uint64_t>(
|
|||
return v;
|
||||
}
|
||||
|
||||
glcr::ErrorOr<uint64_t> MessageView::ReadCapability(
|
||||
uint64_t field_index) const {
|
||||
return buffer_.At<uint64_t>(field_offset(field_index));
|
||||
}
|
||||
|
||||
glcr::ErrorOr<uint64_t> MessageView::ReadCapability(
|
||||
uint64_t field_index, const glcr::CapBuffer& caps) const {
|
||||
uint64_t offset = buffer_.At<uint64_t>(field_offset(field_index));
|
||||
return caps.At(offset);
|
||||
}
|
||||
} // namespace yunq
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/buffer/byte_buffer.h>
|
||||
#include <glacier/buffer/cap_buffer.h>
|
||||
#include <glacier/container/vector.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <glacier/status/status.h>
|
||||
|
|
@ -36,6 +37,10 @@ class MessageView {
|
|||
template <typename T>
|
||||
glcr::ErrorOr<glcr::Vector<T>> ReadRepeated(uint64_t field_index) const;
|
||||
|
||||
glcr::ErrorOr<uint64_t> ReadCapability(uint64_t field_index) const;
|
||||
glcr::ErrorOr<uint64_t> ReadCapability(uint64_t field_index,
|
||||
const glcr::CapBuffer& caps) const;
|
||||
|
||||
private:
|
||||
const glcr::ByteBuffer& buffer_;
|
||||
uint64_t offset_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue