
// AUTO GENERATED by vnxcppcodegen

#include <mmx/package.hxx>
#include <mmx/Router_get_blocks_at.hxx>
#include <mmx/Router_get_blocks_at_return.hxx>
#include <vnx/Value.h>

#include <vnx/vnx.h>


namespace mmx {


const vnx::Hash64 Router_get_blocks_at::VNX_TYPE_HASH(0x1eb0c0d7eae3c33aull);
const vnx::Hash64 Router_get_blocks_at::VNX_CODE_HASH(0x258cf68611e58fe8ull);

vnx::Hash64 Router_get_blocks_at::get_type_hash() const {
	return VNX_TYPE_HASH;
}

std::string Router_get_blocks_at::get_type_name() const {
	return "mmx.Router.get_blocks_at";
}

const vnx::TypeCode* Router_get_blocks_at::get_type_code() const {
	return mmx::vnx_native_type_code_Router_get_blocks_at;
}

std::shared_ptr<Router_get_blocks_at> Router_get_blocks_at::create() {
	return std::make_shared<Router_get_blocks_at>();
}

std::shared_ptr<vnx::Value> Router_get_blocks_at::clone() const {
	return std::make_shared<Router_get_blocks_at>(*this);
}

void Router_get_blocks_at::read(vnx::TypeInput& _in, const vnx::TypeCode* _type_code, const uint16_t* _code) {
	vnx::read(_in, *this, _type_code, _code);
}

void Router_get_blocks_at::write(vnx::TypeOutput& _out, const vnx::TypeCode* _type_code, const uint16_t* _code) const {
	vnx::write(_out, *this, _type_code, _code);
}

void Router_get_blocks_at::accept(vnx::Visitor& _visitor) const {
	const vnx::TypeCode* _type_code = mmx::vnx_native_type_code_Router_get_blocks_at;
	_visitor.type_begin(*_type_code);
	_visitor.type_field(_type_code->fields[0], 0); vnx::accept(_visitor, height);
	_visitor.type_end(*_type_code);
}

void Router_get_blocks_at::write(std::ostream& _out) const {
	_out << "{\"__type\": \"mmx.Router.get_blocks_at\"";
	_out << ", \"height\": "; vnx::write(_out, height);
	_out << "}";
}

void Router_get_blocks_at::read(std::istream& _in) {
	if(auto _json = vnx::read_json(_in)) {
		from_object(_json->to_object());
	}
}

vnx::Object Router_get_blocks_at::to_object() const {
	vnx::Object _object;
	_object["__type"] = "mmx.Router.get_blocks_at";
	_object["height"] = height;
	return _object;
}

void Router_get_blocks_at::from_object(const vnx::Object& _object) {
	for(const auto& _entry : _object.field) {
		if(_entry.first == "height") {
			_entry.second.to(height);
		}
	}
}

vnx::Variant Router_get_blocks_at::get_field(const std::string& _name) const {
	if(_name == "height") {
		return vnx::Variant(height);
	}
	return vnx::Variant();
}

void Router_get_blocks_at::set_field(const std::string& _name, const vnx::Variant& _value) {
	if(_name == "height") {
		_value.to(height);
	}
}

/// \private
std::ostream& operator<<(std::ostream& _out, const Router_get_blocks_at& _value) {
	_value.write(_out);
	return _out;
}

/// \private
std::istream& operator>>(std::istream& _in, Router_get_blocks_at& _value) {
	_value.read(_in);
	return _in;
}

const vnx::TypeCode* Router_get_blocks_at::static_get_type_code() {
	const vnx::TypeCode* type_code = vnx::get_type_code(VNX_TYPE_HASH);
	if(!type_code) {
		type_code = vnx::register_type_code(static_create_type_code());
	}
	return type_code;
}

std::shared_ptr<vnx::TypeCode> Router_get_blocks_at::static_create_type_code() {
	auto type_code = std::make_shared<vnx::TypeCode>();
	type_code->name = "mmx.Router.get_blocks_at";
	type_code->type_hash = vnx::Hash64(0x1eb0c0d7eae3c33aull);
	type_code->code_hash = vnx::Hash64(0x258cf68611e58fe8ull);
	type_code->is_native = true;
	type_code->is_class = true;
	type_code->is_method = true;
	type_code->native_size = sizeof(::mmx::Router_get_blocks_at);
	type_code->create_value = []() -> std::shared_ptr<vnx::Value> { return std::make_shared<Router_get_blocks_at>(); };
	type_code->is_const = true;
	type_code->is_async = true;
	type_code->return_type = ::mmx::Router_get_blocks_at_return::static_get_type_code();
	type_code->fields.resize(1);
	{
		auto& field = type_code->fields[0];
		field.data_size = 4;
		field.name = "height";
		field.code = {3};
	}
	type_code->build();
	return type_code;
}


} // namespace mmx


namespace vnx {

void read(TypeInput& in, ::mmx::Router_get_blocks_at& value, const TypeCode* type_code, const uint16_t* code) {
	if(code) {
		switch(code[0]) {
			case CODE_OBJECT:
			case CODE_ALT_OBJECT: {
				Object tmp;
				vnx::read(in, tmp, type_code, code);
				value.from_object(tmp);
				return;
			}
			case CODE_DYNAMIC:
			case CODE_ALT_DYNAMIC:
				vnx::read_dynamic(in, value);
				return;
		}
	}
	if(!type_code) {
		vnx::skip(in, type_code, code);
		return;
	}
	if(code) {
		switch(code[0]) {
			case CODE_STRUCT: type_code = type_code->depends[code[1]]; break;
			case CODE_ALT_STRUCT: type_code = type_code->depends[vnx::flip_bytes(code[1])]; break;
			default: {
				vnx::skip(in, type_code, code);
				return;
			}
		}
	}
	const char* const _buf = in.read(type_code->total_field_size);
	if(type_code->is_matched) {
		if(const auto* const _field = type_code->field_map[0]) {
			vnx::read_value(_buf + _field->offset, value.height, _field->code.data());
		}
	}
	for(const auto* _field : type_code->ext_fields) {
		switch(_field->native_index) {
			default: vnx::skip(in, type_code, _field->code.data());
		}
	}
}

void write(TypeOutput& out, const ::mmx::Router_get_blocks_at& value, const TypeCode* type_code, const uint16_t* code) {
	if(code && code[0] == CODE_OBJECT) {
		vnx::write(out, value.to_object(), nullptr, code);
		return;
	}
	if(!type_code || (code && code[0] == CODE_ANY)) {
		type_code = mmx::vnx_native_type_code_Router_get_blocks_at;
		out.write_type_code(type_code);
		vnx::write_class_header<::mmx::Router_get_blocks_at>(out);
	}
	else if(code && code[0] == CODE_STRUCT) {
		type_code = type_code->depends[code[1]];
	}
	char* const _buf = out.write(4);
	vnx::write_value(_buf + 0, value.height);
}

void read(std::istream& in, ::mmx::Router_get_blocks_at& value) {
	value.read(in);
}

void write(std::ostream& out, const ::mmx::Router_get_blocks_at& value) {
	value.write(out);
}

void accept(Visitor& visitor, const ::mmx::Router_get_blocks_at& value) {
	value.accept(visitor);
}

} // vnx
