-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanCodeCLS.cpp
60 lines (60 loc) · 1.19 KB
/
cleanCodeCLS.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "cleanCLS.h"
CODE::CODE( void ) { Clear(); }
CODE::~CODE( void ) { Clear(); }
u64& CODE::operator[] ( s32 index )
{
if ( index < 0 || index >= GetCount() )
throw std::out_of_range( "Code tried to access value outside range" );
return p_value[ index ];
}
u64& CODE::operator[] ( u32 index )
{
if ( index >= ( u8 )GetCount() )
throw std::out_of_range( "Code tried to access value outside range" );
return p_value[ index ];
}
void CODE::Clear( void )
{
ram = 0u;
type = 0u;
size = 0u;
byte = 0u;
test = 0u;
slide = 0u;
loop = 0u;
ptrDepth = 0u;
increment = 0u;
isBigByte = false;
p_value.resize( 1, 0u );
}
void CODE::SetCount( s16 count )
{
if ( count < 1 ) count = 1;
if ( count < 256 )
{
p_value.resize( count, 0u );
}
}
u8 CODE::GetCount( void )
{
u8 count = p_value.size();
return count;
}
s16 CODE::NewItem( u64 value )
{
s16 index = -1;
s16 count = GetCount();
if ( count < 256 )
{
SetCount( count + 1 );
p_value[ count ] = value;
index = count;
}
return index;
}
void CODE::DelItem( s16 index )
{
s16 count = GetCount();
if ( index < 0 || index >= count )
p_value.erase( p_value.begin() + index );
}