-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathSubString.h
73 lines (67 loc) · 2.16 KB
/
SubString.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef SubStringDefined //prevent multiple inclusion
#define SubStringDefined
#include <list>
using namespace std;
struct SubString
{
int Length;
char* Start;
SubString(){}
SubString(int offset, int length);
SubString(char* target);
char operator [] (int position);
int Find(char target, int startPos);
int FindBlank(int startPos);
SubString SubStr(int startPos, int length);
void RemoveBlankAtBeginning();
void RemoveBlankAtEnd();
bool Compare(SubString subString);
bool CompareIgnoreEndingBlank(SubString subString);
bool CompareWithCharArray(char* target, int length);
char* ToCharArray();
void SubEndWithNull();
void RecoverEndWithNull();
unsigned int ToImmediate32FromBinary();
unsigned int ToImmediate32FromHexConstant(bool acceptNegative);
unsigned int ToImmediate32FromFloat32();
unsigned int ToImmediate32FromFloat64();
unsigned int ToImmediate32FromInt32();
unsigned int ToImmediate32FromInt64();
unsigned int ToImmediate32FromIntConstant();
unsigned int ToImmediate32FromFloatConstant();
void ToGlobalMemory(int ®ister1, unsigned int&memory);
void ToConstantMemory(unsigned int &bank, int ®ister1, unsigned int &memory, int maxBank = 15);
int ToRegister();
unsigned int ToImmediate20FromHexConstant(bool acceptNegative);
unsigned int ToImmediate20FromIntConstant();
unsigned int ToImmediate20FromFloatConstant();
inline bool IsRegister()
{
return Start[0]=='R'||Start[0]=='r';
}
inline bool IsConstantMemory()
{
return Start[0]=='c' || Start[0]=='C';
}
inline bool IsHex()
{
return Length>2&& Start[0]=='0' &&(Start[1]=='x'||Start[1]=='X');
}
inline bool IsFloat()
{
return Start[0]=='F';
}
char* ToCharArrayStopOnCR();
};
struct SortElement
{
void *ExtraInfo;
SubString Name;
SortElement(){}
SortElement(void *extraInfo, SubString name);
};
extern SortElement SortNotFound;
unsigned int SortComputeIndex(SubString subString);
void SortInitialize(list<SortElement>elementList, SortElement* &sortedList, unsigned int* &indicesList);
SortElement SortFind(SortElement* sortedList, unsigned int* indicesList, unsigned int count, SubString target);
#endif