-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathTypes.js
199 lines (176 loc) · 5.93 KB
/
Types.js
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
// Copyright (c) International Business Machines Corp. 2019
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* From XMLSERVICEQUICK reference
* http://yips.idevcloud.com/wiki/index.php/XMLService/XMLSERVICEQuick
* -------------------------------------------------------------------
* | xmlservice | C/SQL | Fixed-format RPG |
* -------------------------------------------------------------------
* | 3i0 | int8/byte | D myint8 3i 0 |
* | 5i0 | int16/short | D myint16 5i 0 |
* | 10i0 | int32/int | D myint32 10i 0 |
* | 20i0 | int64/int64 | D myint64 20i 0 |
* | 3u0 | uint8/ubyte | D myint8 3u 0 |
* | 5u0 | uint16/ushort | D myint16 5u 0 |
* | 10u0 | uint32/uint | D myint32 10u 0 |
* | 20u0 | uint64/uint64 | D myint64 20u 0 |
* | 32a | char | D mychar 32a |
* | 32a (varying=2) | varchar | D mychar 32a varying |
* | 32a (varying=4) | varchar4 | D mychar 32a varying(4) |
* | 12p2 | packed | D mydec 12p 2 |
* | 12s2 | zoned | D myzone 12s 2 |
* | 4f2 | float | D myfloat 4f |
* | 8f4 | real/double | D myfloat 8f |
* | 3b | binary | D mybin (any) |
* -------------------------------------------------------------------
*/
/**
* @param {number} length - The number of binary characters.
* @returns {object} - The binary data type format expected by xml service.
*/
function Binary(length) {
return { type: `${length}b` };
}
/**
* @param {number} length - The number of characters within the varchar.
* @returns {object} - The character data type format expected by xml service.
*/
function Char(length) {
return { type: `${length}a` };
}
/**
* @param {number} length - The number of characters.
* @returns {object} - The long varchar data type format expected by
* xml service.
*/
function LongVarchar(length) {
return { type: `${length}a`, varying: '4' };
}
/**
* @param {number} length - The number of characters.
* @returns {object} - The varchar data type format expected by xml service.
*/
function Varchar(length) {
return { type: `${length}a`, varying: '2' };
}
/**
* @returns {object} - The double data type format expected by xml service.
*/
function Double() {
return { type: '8f4' };
}
/**
* @returns {object} - The float data type format expected by xml service.
*/
function Float() {
return { type: '4f2' };
}
/**
* @param {number} totalDigits -The number of integer digits.
* @param {number} decimalDigits - The number of decimal digits.
* @returns {object} - The packed data type format expected by xml service.
*/
function PackedDecimal(totalDigits, decimalDigits) {
return { type: `${totalDigits}p${decimalDigits}` };
}
/**
* @param {number} totalDigits - The number of integer digits.
* @param {number} decimalDigits - The number of decimal digits.
* @returns {object} - The zoned data type format expected by xml service.
*/
function ZonedDecimal(totalDigits, decimalDigits) {
return { type: `${totalDigits}s${decimalDigits}` };
}
/**
* @returns {object} The signed big int (int64) data type format expected by
* xml service.
*/
function SignedBigInt() {
return { type: '20i0' };
}
/**
* @returns {object} The signed byte (int8) data type foramt expected by
* xml service.
*/
function SignedByte() {
return { type: '3i0' };
}
/**
* @returns {object} The signed int (int32) data type format expected by xml service.
*/
function SignedInt() {
return { type: '10i0' };
}
/**
* @returns {object} The signed short (int16) data type format expected by
* xml service.
*/
function SignedShort() {
return { type: '5i0' };
}
// aliases for signed types
const BigInt = SignedBigInt;
const Byte = SignedByte;
const Int = SignedInt;
const Short = SignedShort;
/**
* @returns {object} The unsigned big int (int64) data type format expected by
* xml service.
*/
function UnsignedBigInt() {
return { type: '20u0' };
}
/**
* @returns {object} The unsigned byte (int8) data type foramt expected by
* xml service.
*/
function UnsignedByte() {
return { type: '3u0' };
}
/**
* @returns {object} The unsigned int (int32) data type format expected by
* xml service.
*/
function UnsignedInt() {
return { type: '10u0' };
}
/**
* @returns {object} - The signed short (int16) data type format expected by
* xml service.
*/
function UnsignedShort() {
return { type: '5u0' };
}
module.exports = {
Binary,
Char,
LongVarchar,
Varchar,
Double,
Float,
PackedDecimal,
ZonedDecimal,
SignedBigInt,
BigInt,
SignedByte,
Byte,
SignedInt,
Int,
SignedShort,
Short,
UnsignedBigInt,
UnsignedByte,
UnsignedInt,
UnsignedShort,
};