Elaztek Developer Hub
Switch Project...
blam!
Editing Kit
Guerilla
Sapien
Tool
Foundry
Libraries
Keystone
Strings
Forums
Discord
Doxygen
Jenkins
Guides
Gitlab
Blamite Game Engine - blam!
00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
memorybuffer.h
Go to the documentation of this file.
1
// Tencent is pleased to support the open source community by making RapidJSON available.
2
//
3
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
4
//
5
// Licensed under the MIT License (the "License"); you may not use this file except
6
// in compliance with the License. You may obtain a copy of the License at
7
//
8
// http://opensource.org/licenses/MIT
9
//
10
// Unless required by applicable law or agreed to in writing, software distributed
11
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
// specific language governing permissions and limitations under the License.
14
15
#ifndef RAPIDJSON_MEMORYBUFFER_H_
16
#define RAPIDJSON_MEMORYBUFFER_H_
17
18
#include "
stream.h
"
19
#include "
internal/stack.h
"
20
21
RAPIDJSON_NAMESPACE_BEGIN
22
24
36
template
<
typename
Allocator = CrtAllocator>
37
struct
GenericMemoryBuffer
{
38
typedef
char
Ch
;
// byte
39
40
GenericMemoryBuffer
(
Allocator
*
allocator
= 0,
size_t
capacity =
kDefaultCapacity
) :
stack_
(
allocator
, capacity) {}
41
42
void
Put
(
Ch
c) { *
stack_
.template Push<Ch>() = c; }
43
void
Flush
() {}
44
45
void
Clear
() {
stack_
.Clear(); }
46
void
ShrinkToFit
() {
stack_
.ShrinkToFit(); }
47
Ch
*
Push
(
size_t
count) {
return
stack_
.template Push<Ch>(count); }
48
void
Pop
(
size_t
count) {
stack_
.template Pop<Ch>(count); }
49
50
const
Ch
*
GetBuffer
()
const
{
51
return
stack_
.template Bottom<Ch>();
52
}
53
54
size_t
GetSize
()
const
{
return
stack_
.GetSize(); }
55
56
static
const
size_t
kDefaultCapacity
= 256;
57
mutable
internal::Stack<Allocator>
stack_
;
58
};
59
60
typedef
GenericMemoryBuffer<>
MemoryBuffer
;
61
63
template
<>
64
inline
void
PutN
(
MemoryBuffer
& memoryBuffer,
char
c,
size_t
n) {
65
std::memset(memoryBuffer.
stack_
.Push<
char
>(n), c, n *
sizeof
(c));
66
}
67
68
RAPIDJSON_NAMESPACE_END
69
70
#endif // RAPIDJSON_MEMORYBUFFER_H_
GenericMemoryBuffer::GetSize
size_t GetSize() const
Definition:
memorybuffer.h:54
PutN
void PutN(MemoryBuffer &memoryBuffer, char c, size_t n)
Implement specialized version of PutN() with memset() for better performance.
Definition:
memorybuffer.h:64
RAPIDJSON_NAMESPACE_END
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition:
rapidjson.h:124
RAPIDJSON_NAMESPACE_BEGIN
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition:
rapidjson.h:121
Allocator
Concept for allocating, resizing and freeing memory block.
GenericMemoryBuffer::Ch
char Ch
Definition:
memorybuffer.h:38
GenericMemoryBuffer::Push
Ch * Push(size_t count)
Definition:
memorybuffer.h:47
MemoryBuffer
GenericMemoryBuffer MemoryBuffer
Definition:
memorybuffer.h:60
GenericMemoryBuffer::Clear
void Clear()
Definition:
memorybuffer.h:45
allocator
Blam::LinearAllocator allocator
– TO BE FILLED IN BY VERTIGO –
Definition:
main.cpp:76
GenericMemoryBuffer::Flush
void Flush()
Definition:
memorybuffer.h:43
stream.h
internal::Stack
A type-unsafe stack for storing different types of data.
Definition:
stack.h:37
GenericMemoryBuffer::stack_
internal::Stack< Allocator > stack_
Definition:
memorybuffer.h:57
GenericMemoryBuffer::GetBuffer
const Ch * GetBuffer() const
Definition:
memorybuffer.h:50
GenericMemoryBuffer::kDefaultCapacity
static const size_t kDefaultCapacity
Definition:
memorybuffer.h:56
GenericMemoryBuffer
Represents an in-memory output byte stream.
Definition:
fwd.h:74
GenericMemoryBuffer::GenericMemoryBuffer
GenericMemoryBuffer(Allocator *allocator=0, size_t capacity=kDefaultCapacity)
Definition:
memorybuffer.h:40
GenericMemoryBuffer::Put
void Put(Ch c)
Definition:
memorybuffer.h:42
GenericMemoryBuffer::Pop
void Pop(size_t count)
Definition:
memorybuffer.h:48
stack.h
GenericMemoryBuffer::ShrinkToFit
void ShrinkToFit()
Definition:
memorybuffer.h:46
blam
components
3rdparty
rapidjson
memorybuffer.h
Generated on Fri Sep 22 2023 23:44:55 for Blamite Game Engine - blam! by
1.8.17