-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
BSeq.hpp
204 lines (200 loc) · 4.64 KB
/
BSeq.hpp
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// Copyright Kabuki Starship� <kabukistarship.com>.
#pragma once
#ifndef SCRIPT_BSQ_INLINE_CODE
#define SCRIPT_BSQ_INLINE_CODE
#include "BSeq.h"
#if SEAM >= SCRIPT2_CRABS
namespace _ {
template<typename Printer>
Printer& TBSeqPrint(Printer& o, const ISN* params) {
ISN param_count = *params++,
i = 0;
DTB type = 0,
value = 0;
o << "Param<";
if (param_count > BSQMax) {
o << "\nInvalid num_params: " << param_count;
return o;
}
o << param_count << ": ";
for (i = 1; i < param_count; ++i) {
value = *params++;
type = value & 0x1f; //< Mask off type.
value = value >> 5; //< Shift over array type.
o << ATypef(value) << ", ";
if (type >= STR_) {
if (value) {
o << "\nError: arrays may only be created from POD types.";
return o;
}
// Print out the max length of the .
++i;
value = *params++;
o << value;
} else if (value > 31) {
if (value > 127) { //< It's a multi-dimensional array.
o << "Multi-dimensional Array:" << value << ", ";
}
// Then it's an array.
++i;
switch (value) { //< Print out the Array type.
case 0: {
break;
}
case 1: {
value = *params++;
o << "IUA:" << value << ", ";
break;
}
case 2: {
value = *params++;
o << "IUB:" << value << ", ";
break;
}
case 3: {
value = *params++;
o << "IUC:" << value << ", ";
break;
}
case 4: {
value = *params++;
o << "UI8:" << value << ", ";
break;
}
case 5: {
value = *params++;
if (value == 0) {
o << "IUA:[0]";
break;
}
o << "IUA:[" << value << ": ";
for (ISN i = value; i != 0; --i) {
value = *params++;
o << value << ", ";
}
value = *params++;
o << value << "]";
break;
}
case 6: {
value = *params++;
if (value == 0) {
o << "IUB:[0]";
break;
}
o << "IUB:[" << value << ": ";
for (ISN i = value; i != 0; --i) {
value = *params++;
o << value << ", ";
}
value = *params++;
o << value << "]";
break;
}
case 7: {
value = *params++;
if (value == 0) {
o << "IUC:[0]";
break;
}
o << "IUC:[" << value << ": ";
for (ISN i = value; i != 0; --i) {
value = *params++;
o << value << ", ";
}
value = *params++;
o << value << "]";
break;
}
}
}
}
// Do the last set without a comma.
value = *params++;
o << ATypef(value) << ", ";
if (value == STR_) {
++i;
value = *params++;
o << value;
} else if (value > 31) {
// Then it's an array.
type = value & 0x1f; //< Mask off type.
value = value >> 5; //< Shift over array type.
++i;
switch (value) {
case 0: {
break;
}
case 1: {
value = *params++;
o << "IUA:" << value << ", ";
break;
}
case 2: {
value = *params++;
o << "IUB:" << value << ", ";
break;
}
case 3: {
value = *params++;
o << "IUC:" << value << ", ";
break;
}
case 4: {
value = *params++;
o << "UI5:" << value << ", ";
break;
}
case 5: {
value = *params++;
if (value == 0) {
o << "IUA:[0]";
break;
}
o << "IUA:[" << value << ": ";
for (ISN i = value; i != 0; --i) {
value = *params++;
o << value << ", ";
}
value = *params++;
o << value << "]";
break;
}
case 6: {
value = *params++;
if (value == 0) {
o << "IUB:[0]";
break;
}
o << "IUB:[" << value << ": ";
for (ISN i = value; i != 0; --i) {
value = *params++;
o << value << ", ";
}
value = *params++;
o << value << "]";
break;
}
case 7: {
value = *params++;
if (value == 0) {
o << "IUC:[0]";
break;
}
o << "IUC:[" << value << ": ";
for (ISN i = value; i != 0; --i) {
value = *params++;
o << value << ", ";
}
value = *params++;
o << value << "]";
break;
}
}
}
o << '>';
return o;
}
} //< namespace _
#endif
#endif