2023-10-24 14:54:00 -07:00
|
|
|
// Generated file - DO NOT MODIFY
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <glacier/buffer/byte_buffer.h>
|
|
|
|
#include <glacier/buffer/cap_buffer.h>
|
2023-12-01 09:30:52 -08:00
|
|
|
#include <glacier/status/status.h>
|
2023-11-10 12:26:59 -08:00
|
|
|
#include <glacier/container/vector.h>
|
2023-10-24 14:54:00 -07:00
|
|
|
#include <glacier/string/string.h>
|
2024-01-11 19:51:18 -08:00
|
|
|
#include <yunq/message_view.h>
|
2024-01-11 20:47:39 -08:00
|
|
|
#include <yunq/serialize.h>
|
2023-10-24 14:54:00 -07:00
|
|
|
#include <ztypes.h>
|
|
|
|
|
2023-11-30 08:50:15 -08:00
|
|
|
{% if package != None %}
|
|
|
|
namespace {{package.cpp_namespace()}} {
|
|
|
|
{% endif %}
|
2023-10-24 14:54:00 -07:00
|
|
|
|
|
|
|
{%- for message in messages %}
|
|
|
|
class {{message.name}} {
|
|
|
|
public:
|
|
|
|
{{message.name}}() {}
|
|
|
|
// Delete copy and move until implemented.
|
|
|
|
{{message.name}}(const {{message.name}}&) = delete;
|
2024-01-11 22:09:42 -08:00
|
|
|
{{message.name}}({{message.name}}&&) = default;
|
|
|
|
{{message.name}}& operator=({{message.name}}&&) = default;
|
2023-10-24 14:54:00 -07:00
|
|
|
|
2024-01-11 20:03:34 -08:00
|
|
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
|
|
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
2023-10-24 18:19:12 -07:00
|
|
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
|
|
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
2023-10-24 14:54:00 -07:00
|
|
|
|
|
|
|
{%- for field in message.fields %}
|
2024-01-11 22:09:42 -08:00
|
|
|
{%- if not field.repeated %}
|
|
|
|
|
2024-01-11 21:32:08 -08:00
|
|
|
const {{field.cpp_type()}}& {{field.name}}() const { return {{field.name}}_; }
|
|
|
|
{{field.cpp_type()}}& mutable_{{field.name}}() { return {{field.name}}_; }
|
|
|
|
|
2024-01-11 22:09:42 -08:00
|
|
|
{%- if field.type != Type.MESSAGE %}
|
2023-10-24 14:54:00 -07:00
|
|
|
void set_{{field.name}}(const {{field.cpp_type()}}& value) { {{field.name}}_ = value; }
|
2024-01-11 22:09:42 -08:00
|
|
|
{%- endif %}
|
|
|
|
|
2023-11-10 12:26:59 -08:00
|
|
|
{%- else %}
|
2024-01-11 22:09:42 -08:00
|
|
|
|
2023-11-10 12:26:59 -08:00
|
|
|
const glcr::Vector<{{field.cpp_type()}}>& {{field.name}}() const { return {{field.name}}_; }
|
2024-01-11 22:09:42 -08:00
|
|
|
glcr::Vector<{{field.cpp_type()}}>& mutable_{{field.name}}() { return {{field.name}}_; }
|
|
|
|
|
|
|
|
{%- if field.type != Type.MESSAGE %}
|
2023-11-10 12:26:59 -08:00
|
|
|
void add_{{field.name}}(const {{field.cpp_type()}}& value) { {{field.name}}_.PushBack(value); }
|
|
|
|
{%- endif %}
|
2024-01-11 22:09:42 -08:00
|
|
|
void add_{{field.name}}({{field.cpp_type()}}&& value) { {{field.name}}_.PushBack(glcr::Move(value)); }
|
2024-01-11 21:32:08 -08:00
|
|
|
|
|
|
|
{%- endif %}
|
2023-10-24 14:54:00 -07:00
|
|
|
{%- endfor %}
|
|
|
|
|
|
|
|
private:
|
|
|
|
{%- for field in message.fields %}
|
2023-11-10 12:26:59 -08:00
|
|
|
{%- if not field.repeated %}
|
2023-10-24 14:54:00 -07:00
|
|
|
{{field.cpp_type()}} {{field.name}}_;
|
2023-11-10 12:26:59 -08:00
|
|
|
{%- else %}
|
|
|
|
glcr::Vector<{{field.cpp_type()}}> {{field.name}}_;
|
|
|
|
{%- endif %}
|
2023-10-24 14:54:00 -07:00
|
|
|
{%- endfor %}
|
|
|
|
|
2023-11-10 12:51:23 -08:00
|
|
|
// Parses everything except for caps.
|
2024-01-11 19:51:18 -08:00
|
|
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
2024-01-11 20:47:39 -08:00
|
|
|
|
|
|
|
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
2023-10-24 14:54:00 -07:00
|
|
|
};
|
|
|
|
{%- endfor %}
|
2023-11-30 08:50:15 -08:00
|
|
|
|
|
|
|
{% if package != None %}
|
|
|
|
} // namepace {{package.cpp_namespace()}}
|
|
|
|
{% endif %}
|