acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
byte2_stream.h
1
//
2
// Created by camilo on 2025-08-31 17:12 <3ThomasBorregaarSorensen!!
3
//
4
#pragma once
5
6
7
#include "file.h"
8
#include "stream.h"
9
#include "acme/prototype/prototype/memory.h"
10
11
class
byte2_stream
;
12
13
struct
stream_output_t
{};
14
struct
stream_input_t
{};
15
16
template
<
typename
BYTE2_EXCHANGABLE >
17
concept
byte2_exchangable
=
requires
(BYTE2_EXCHANGABLE & t,
::byte2_stream
&s)
18
{
19
t.byte2_exchange(s);
20
21
};
22
23
class
CLASS_DECL_ACME byte2_stream :
24
virtual
public
stream_base
25
{
26
public
:
27
28
29
::file_pointer m_pfile;
30
31
32
byte2_stream();
33
byte2_stream(
stream_input_t
, const ::block &
block
);
34
byte2_stream(
stream_output_t
,
memory
&
memory
);
35
byte2_stream(const ::file_pointer & pfile);
36
~byte2_stream()
override
;
37
38
byte2_stream & operator >>(
bool
&b);
39
byte2_stream & operator << (
bool
b);
40
byte2_stream & operator >>(::i32 & i);
41
byte2_stream & operator << (::i32 i);
42
byte2_stream & operator >>(::i64 & ll);
43
byte2_stream & operator << (::i64 ll);
44
byte2_stream & operator >>(
string
& str);
45
byte2_stream & operator << (
string
& str);
46
byte2_stream & operator >>(
memory
&
memory
);
47
byte2_stream & operator << (
memory
&
memory
);
48
49
template
<
byte
2_exchangable BYTE2_EXCHANGABLE >
50
byte2_stream & operator >>(BYTE2_EXCHANGABLE & t)
51
{
52
53
t.byte2_exchange(*
this
);
54
55
return
*
this
;
56
57
}
58
59
template
<
byte
2_exchangable BYTE2_EXCHANGABLE >
60
byte2_stream & operator <<(BYTE2_EXCHANGABLE & t)
61
{
62
63
t.byte2_exchange(*
this
);
64
65
return
*
this
;
66
67
}
68
69
70
template
<
typename
TYPE >
71
void
exchange(TYPE & t)
72
{
73
if
(m_estream == file::e_stream_output)
74
{
75
76
*
this
<< t;
77
78
}
79
else
if
(m_estream == file::e_stream_input)
80
{
81
82
*
this
>> t;
83
84
}
85
else
86
{
87
88
throw
"byte2_stream unsupported m_estream"
;
89
90
}
91
92
}
93
94
95
};
96
97
98
class
CLASS_DECL_ACME input_byte2_stream :
99
virtual
public
byte2_stream
100
{
101
public
:
102
103
104
105
input_byte2_stream(const ::block &
block
);
106
~input_byte2_stream()
override
;
107
108
109
110
};
111
112
113
class
CLASS_DECL_ACME output_byte2_stream :
114
virtual
public
byte2_stream
115
{
116
public
:
117
118
119
120
output_byte2_stream();
121
output_byte2_stream(
memory
&
memory
);
122
~output_byte2_stream()
override
;
123
124
125
126
};
127
128
129
byte2_stream
Definition
byte2_stream.h:25
memory
Definition
memory.h:33
byte2_exchangable
Definition
byte2_stream.h:17
block
Definition
block.h:46
stream_input_t
Definition
byte2_stream.h:14
stream_output_t
Definition
byte2_stream.h:13
filesystem
file
byte2_stream.h
Generated by
1.17.0