Skip to content

Commit 7ce8149

Browse files
committed
created new type ArchivableUi16
1 parent cf8ae65 commit 7ce8149

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/KM_util.h

+29
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,35 @@ namespace Kumu
256256
}
257257
};
258258

259+
//
260+
class ArchivableUi16 : public Kumu::IArchive
261+
{
262+
ui16_t m_Value;
263+
264+
public:
265+
ArchivableUi16() : m_Value(0) {}
266+
ArchivableUi16(const ui16_t& value) : m_Value(value) {}
267+
virtual ~ArchivableUi16() {}
268+
269+
bool HasValue() const { return true; }
270+
ui32_t ArchiveLength() const { return sizeof(ui16_t); }
271+
272+
bool Archive(MemIOWriter* Writer) const {
273+
if ( Writer == 0 ) return false;
274+
return Writer->WriteUi16BE(m_Value);
275+
}
276+
277+
bool Unarchive(MemIOReader* Reader) {
278+
if ( Reader == 0 ) return false;
279+
return Reader->ReadUi16BE(&m_Value);
280+
}
281+
282+
const char* EncodeString(char* str_buf, ui32_t buf_len) const {
283+
snprintf(str_buf, buf_len, "%hu", m_Value);
284+
return str_buf;
285+
}
286+
};
287+
259288
//
260289
typedef Kumu::ArchivableList<ArchivableString> StringList;
261290

0 commit comments

Comments
 (0)