[ox/mc] Add def writer

This commit is contained in:
2019-02-11 05:59:33 +00:00
parent 96c56e2589
commit 75aeedb7b5
20 changed files with 468 additions and 17 deletions

View File

@@ -6,8 +6,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <ox/std/assert.hpp>
#include <ox/std/byteswap.hpp>
#include <ox/std/memops.hpp>
#include "write.hpp"
namespace ox {
@@ -17,6 +19,10 @@ MetalClawWriter::MetalClawWriter(uint8_t *buff, std::size_t buffLen): m_fieldPre
m_buffLen = buffLen;
}
MetalClawWriter::~MetalClawWriter() noexcept {
oxAssert(m_field == m_fields, "MetalClawWriter: incorrect fields number given");
}
int MetalClawWriter::op(const char*, int8_t *val) {
return appendInteger(*val);
}
@@ -54,7 +60,7 @@ int MetalClawWriter::op(const char*, bool *val) {
return m_fieldPresence.set(m_field++, *val);
}
void MetalClawWriter::setFields(int fields) {
void MetalClawWriter::setTypeInfo(const char*, int fields) {
m_fields = fields;
m_buffIt = (fields / 8 + 1) - (fields % 8 == 0);
m_fieldPresence.setMaxLen(m_buffIt);