SaveMessage.h
SaveMessage.h
CPP1/* Copyright Statement:2 *3 * (C) 2021-2025 Cubios Inc. All rights reserved.4 */56#ifndef WASMLIBS_CPP_SAVEMESSAGE_H_7#define WASMLIBS_CPP_SAVEMESSAGE_H_8#include <memory>9#include <vector>10#include "native.h"1112namespace Cubios13{14class SaveMessage15{16 public:17 SaveMessage(uint8_t* data=NULL,int length=GAME_SAVE_SIZE);18 virtual ~SaveMessage();1920 void Print();2122 void WriteInt(int value, int bits);23 void WriteByte(uint8_t value);24 void WriteSignedInt(int value, int bits);25 void WriteBool(bool value);26 void WriteFloat(float value);2728 int ReadInt(int bits);29 int ReadSignedInt(int bits);30 uint8_t ReadByte();31 bool ReadBool();32 float ReadFloat();3334 uint8_t* GetData(int& length);35 void SetData(uint8_t* data, int length);3637 inline void Reset(bool zero=false) { this->m_curPos = 0; this->m_usedBits = 0; this->m_numBytes = GAME_SAVE_SIZE; if(zero) memset(this->m_bytes,0x00,GAME_SAVE_SIZE);}3839 private:40 int m_numBytes;41 int m_usedBits;42 int m_curPos;43 uint8_t m_bytes[GAME_SAVE_SIZE];4445 bool checkOverflow(int bits);4647 inline int curByte() { return m_curPos / 8;}48 inline int curBit() { return m_curPos % 8; }4950};5152}53#endif /* WASMLIBS_CPP_SAVEMESSAGE_H_ */54
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.