UNPKG

jspurefix

Version:
56 lines 2.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QuickFixXmlFormatter = void 0; const os_1 = require("os"); class QuickFixXmlFormatter { static isRequired(r) { return r ? 'Y' : 'N'; } static whitespace(n) { return ' '.repeat(n); } static startFix(major, minor, servicePack) { return `<fix major='${major}' type='FIX' servicepack='${servicePack}' minor='${minor}'>${os_1.EOL}`; } static endFix() { return `</fix>${os_1.EOL}`; } static startEntity(name, ws) { return `${QuickFixXmlFormatter.whitespace(ws)}<${name}>${os_1.EOL}`; } static endEntity(name, ws) { return `${QuickFixXmlFormatter.whitespace(ws)}</${name}>${os_1.EOL}`; } static startComponent(name, ws) { return `${QuickFixXmlFormatter.whitespace(ws)}<component name='${name}'>${os_1.EOL}`; } static endComponent(ws) { return `${QuickFixXmlFormatter.whitespace(ws)}</component>${os_1.EOL}`; } static addField(sf, ws) { return `${QuickFixXmlFormatter.whitespace(ws)} <!-- ${sf.definition.tag} ${sf.definition.type} -->${os_1.EOL}${QuickFixXmlFormatter.whitespace(ws)}<field name='${sf.name}' required='${QuickFixXmlFormatter.isRequired(sf.required)}'/>${os_1.EOL}`; } static addComponent(cf, ws) { return `${QuickFixXmlFormatter.whitespace(ws)}<component name='${cf.name}' required='${QuickFixXmlFormatter.isRequired(cf.required)}'/>${os_1.EOL}`; } static addGroup(gf, ws) { var _a, _b, _c; return `${QuickFixXmlFormatter.whitespace(ws)} <!-- ${(_b = (_a = gf.definition.noOfField) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : -1} ${(_c = gf.definition.noOfField) === null || _c === void 0 ? void 0 : _c.type} -->${os_1.EOL}${QuickFixXmlFormatter.whitespace(ws)}<group name='${gf.name}' required='${QuickFixXmlFormatter.isRequired(gf.required)}'>${os_1.EOL}`; } static endGroup(ws) { return `${QuickFixXmlFormatter.whitespace(ws)}</group>${os_1.EOL}`; } static addEnum(fe, ws) { var _a; return `${QuickFixXmlFormatter.whitespace(ws)}<value enum='${fe === null || fe === void 0 ? void 0 : fe.key}' description='${(_a = fe === null || fe === void 0 ? void 0 : fe.description) !== null && _a !== void 0 ? _a : fe === null || fe === void 0 ? void 0 : fe.val}'/>${os_1.EOL}`; } static defineField(sf, ws) { const term = sf.isEnum() ? '>' : '/>'; return (`${QuickFixXmlFormatter.whitespace(ws)}<field number='${sf.tag}' name='${sf.name}' type='${sf.type}'${term}${os_1.EOL}`); } static defineMessage(def, ws) { return `${QuickFixXmlFormatter.whitespace(ws)}<message name='${def.name}' msgcat='${def.category}' msgtype='${def.msgType}'>${os_1.EOL}`; } } exports.QuickFixXmlFormatter = QuickFixXmlFormatter; //# sourceMappingURL=quick-fix-xml-formatter.js.map