Cogs.Core
JsonMemoryBufferStream.h
1#pragma once
2
3#include "Foundation/Memory/MemoryBuffer.h"
4#include <cassert>
5
6namespace Cogs {
7 namespace Core {
9 public:
10 using Ch = char;
11
12 JsonMemoryBufferStream(Memory::MemoryBuffer& buffer) : mBuffer(buffer) {}
13
15 char Peek() const { return static_cast<const char*>(mBuffer.data())[mBuffer.pos()]; }
16
18 char Take() { return mBuffer.read8(); }
19
22 size_t Tell() { return mBuffer.pos(); }
23
25 char* PutBegin() { assert(false); return nullptr; }
26
28 void Put(char c) { mBuffer.write8(c); }
29
31 void Flush() {}
32
36 size_t PutEnd(char* begin) { return mBuffer.pos() - reinterpret_cast<intptr_t>(begin); }
37
38 private:
39 Memory::MemoryBuffer& mBuffer;
40 };
41 }
42}
char Take()
Read the current character from stream and moving the read cursor to next character.
char * PutBegin()
Not used. See RapidJSON spec.
char Peek() const
Read the current character from stream without moving the read cursor.
void Put(char c)
Write a character.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23