CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
pooled_byte_buffer_writer.h
1#pragma once
2
3#include <system/shared_ptr.h>
4#include <system/idisposable.h>
5#include <system/exceptions.h>
6#include <system/default.h>
7#include <system/memory.h>
8#include <cstdint>
9
10#include "system/net/array_buffer.h"
11#include "system/buffers/i_buffer_writer.h"
12
13namespace System
14{
15namespace IO
16{
17class Stream;
18} // namespace IO
19template <typename> class Memory;
20template <typename> class ReadOnlyMemory;
21template <typename> class ReadOnlySpan;
22template <typename> class Span;
23} // namespace System
24
25namespace System {
26
27namespace Text {
28
29namespace Json {
30
31class ASPOSECPP_SHARED_CLASS PooledByteBufferWriter final : public Buffers::IBufferWriter<uint8_t>, public IDisposable
32{
35 typedef IDisposable BaseType1;
36
37 typedef ::System::BaseTypesInfo<BaseType, BaseType1> ThisTypeBaseTypesInfo;
38 ASPOSECPP_SHARED_RTTI_INFO_DECL();
39
40public:
41
42 ASPOSECPP_SHARED_API ReadOnlySpan<uint8_t> get_WrittenSpan();
44 ASPOSECPP_SHARED_API int32_t get_Capacity();
45 ASPOSECPP_SHARED_API bool get_CanGetUnflushedBytes();
46 ASPOSECPP_SHARED_API int64_t get_UnflushedBytes();
47
48 ASPOSECPP_SHARED_API PooledByteBufferWriter(int32_t initialCapacity);
49
50 ASPOSECPP_SHARED_API void Clear();
51 ASPOSECPP_SHARED_API void ClearAndReturnBuffers();
52 ASPOSECPP_SHARED_API void Dispose() override;
53 ASPOSECPP_SHARED_API void InitializeEmptyInstance(int32_t initialCapacity);
55 ASPOSECPP_SHARED_API void Advance(int32_t count) override;
56 ASPOSECPP_SHARED_API Memory<uint8_t> GetMemory(int32_t sizeHint = MinimumBufferSize) override;
57 ASPOSECPP_SHARED_API Span<uint8_t> GetSpan(int32_t sizeHint = MinimumBufferSize) override;
58 ASPOSECPP_SHARED_API void WriteToStream(System::SharedPtr<IO::Stream> destination);
59
60protected:
61
62 #ifdef ASPOSE_GET_SHARED_MEMBERS
63 void GetSharedMembers(System::Object::shared_members_type& result) const override;
64 #endif
65
66private:
67
68 static const int32_t MinimumBufferSize = 256;
69 Net::ArrayBuffer _buffer;
70
71};
72
73} // namespace Json
74} // namespace Text
75} // namespace System
Represents a sink for data, into which a consumer can write data. Objects of this class should only b...
Definition: i_buffer_writer.h:24
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Definition: array_buffer.h:18
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Represents a contiguous region of arbitrary memory similar to C++20's std::span.
Definition: span.h:375
Definition: pooled_byte_buffer_writer.h:32
PooledByteBufferWriter(int32_t initialCapacity)
static System::SharedPtr< PooledByteBufferWriter > CreateEmptyInstanceForCaching()
void Advance(int32_t count) override
Notifies the IBufferWriter implementation that count elements were written to the output.
Span< uint8_t > GetSpan(int32_t sizeHint=MinimumBufferSize) override
Returns a Span that can be written to, and is guaranteed to have at least sizeHint elements.
void Dispose() override
Does nothing.
ReadOnlySpan< uint8_t > get_WrittenSpan()
void WriteToStream(System::SharedPtr< IO::Stream > destination)
Memory< uint8_t > GetMemory(int32_t sizeHint=MinimumBufferSize) override
Returns a Memory that can be written to, and is guaranteed to have at least sizeHint elements.
void InitializeEmptyInstance(int32_t initialCapacity)
ReadOnlyMemory< uint8_t > get_WrittenMemory()
@ Text
Defines color adjustment information for text.
@ Stream
The type that supports reliable, two-way, connection-based byte streams without duplication of data a...
Definition: db_command.h:9