quicktype 17.0.6 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/cli/CompressedJSONFromStream.js +26 -38
  2. package/dist/cli/GraphQLIntrospection.js +33 -41
  3. package/dist/cli/TypeSource.d.ts +1 -1
  4. package/dist/cli/URLGrammar.js +4 -3
  5. package/dist/cli/index.js +363 -364
  6. package/dist/quicktype-core/Annotation.js +2 -0
  7. package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
  8. package/dist/quicktype-core/ConvenienceRenderer.js +104 -81
  9. package/dist/quicktype-core/DateTime.js +1 -0
  10. package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
  11. package/dist/quicktype-core/DeclarationIR.js +13 -10
  12. package/dist/quicktype-core/EncodedMarkovChain.js +1 -0
  13. package/dist/quicktype-core/GatherNames.js +47 -25
  14. package/dist/quicktype-core/Graph.d.ts +2 -2
  15. package/dist/quicktype-core/Graph.js +23 -19
  16. package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
  17. package/dist/quicktype-core/GraphRewriting.js +65 -54
  18. package/dist/quicktype-core/MakeTransformations.js +23 -22
  19. package/dist/quicktype-core/MarkovChain.d.ts +3 -3
  20. package/dist/quicktype-core/MarkovChain.js +9 -8
  21. package/dist/quicktype-core/Messages.d.ts +3 -3
  22. package/dist/quicktype-core/Messages.js +8 -3
  23. package/dist/quicktype-core/Naming.d.ts +11 -11
  24. package/dist/quicktype-core/Naming.js +76 -61
  25. package/dist/quicktype-core/Renderer.d.ts +6 -6
  26. package/dist/quicktype-core/Renderer.js +34 -17
  27. package/dist/quicktype-core/RendererOptions.d.ts +5 -5
  28. package/dist/quicktype-core/RendererOptions.js +6 -3
  29. package/dist/quicktype-core/Run.d.ts +9 -9
  30. package/dist/quicktype-core/Run.js +72 -67
  31. package/dist/quicktype-core/Source.d.ts +3 -3
  32. package/dist/quicktype-core/Source.js +19 -18
  33. package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
  34. package/dist/quicktype-core/TargetLanguage.js +6 -2
  35. package/dist/quicktype-core/Transformers.d.ts +25 -25
  36. package/dist/quicktype-core/Transformers.js +94 -66
  37. package/dist/quicktype-core/Type.d.ts +41 -43
  38. package/dist/quicktype-core/Type.js +96 -71
  39. package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
  40. package/dist/quicktype-core/TypeBuilder.js +53 -47
  41. package/dist/quicktype-core/TypeGraph.d.ts +4 -4
  42. package/dist/quicktype-core/TypeGraph.js +49 -40
  43. package/dist/quicktype-core/TypeUtils.d.ts +2 -2
  44. package/dist/quicktype-core/TypeUtils.js +23 -22
  45. package/dist/quicktype-core/UnifyClasses.js +16 -12
  46. package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
  47. package/dist/quicktype-core/UnionBuilder.js +33 -30
  48. package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
  49. package/dist/quicktype-core/attributes/AccessorNames.js +18 -17
  50. package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
  51. package/dist/quicktype-core/attributes/Constraints.js +8 -4
  52. package/dist/quicktype-core/attributes/Description.js +6 -5
  53. package/dist/quicktype-core/attributes/EnumValues.js +4 -3
  54. package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
  55. package/dist/quicktype-core/attributes/StringTypes.js +24 -21
  56. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
  57. package/dist/quicktype-core/attributes/TypeAttributes.js +12 -10
  58. package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
  59. package/dist/quicktype-core/attributes/TypeNames.js +49 -21
  60. package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
  61. package/dist/quicktype-core/attributes/URIAttributes.js +10 -6
  62. package/dist/quicktype-core/index.js +128 -125
  63. package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
  64. package/dist/quicktype-core/input/CompressedJSON.js +49 -54
  65. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +5 -13
  66. package/dist/quicktype-core/input/Inference.d.ts +2 -2
  67. package/dist/quicktype-core/input/Inference.js +25 -17
  68. package/dist/quicktype-core/input/Inputs.d.ts +2 -2
  69. package/dist/quicktype-core/input/Inputs.js +38 -54
  70. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
  71. package/dist/quicktype-core/input/JSONSchemaInput.js +503 -523
  72. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
  73. package/dist/quicktype-core/input/JSONSchemaStore.js +24 -35
  74. package/dist/quicktype-core/input/PostmanCollection.js +2 -1
  75. package/dist/quicktype-core/input/io/NodeIO.js +55 -44
  76. package/dist/quicktype-core/input/io/get-stream/index.js +6 -2
  77. package/dist/quicktype-core/language/All.js +3 -2
  78. package/dist/quicktype-core/language/CPlusPlus.d.ts +8 -8
  79. package/dist/quicktype-core/language/CPlusPlus.js +185 -151
  80. package/dist/quicktype-core/language/CSharp.d.ts +7 -7
  81. package/dist/quicktype-core/language/CSharp.js +82 -72
  82. package/dist/quicktype-core/language/Crystal.d.ts +2 -2
  83. package/dist/quicktype-core/language/Crystal.js +18 -17
  84. package/dist/quicktype-core/language/Dart.d.ts +4 -4
  85. package/dist/quicktype-core/language/Dart.js +36 -34
  86. package/dist/quicktype-core/language/Elm.d.ts +6 -6
  87. package/dist/quicktype-core/language/Elm.js +47 -45
  88. package/dist/quicktype-core/language/Golang.d.ts +4 -4
  89. package/dist/quicktype-core/language/Golang.js +23 -20
  90. package/dist/quicktype-core/language/Haskell.d.ts +5 -5
  91. package/dist/quicktype-core/language/Haskell.js +25 -23
  92. package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
  93. package/dist/quicktype-core/language/JSONSchema.js +17 -16
  94. package/dist/quicktype-core/language/Java.d.ts +2 -2
  95. package/dist/quicktype-core/language/Java.js +97 -97
  96. package/dist/quicktype-core/language/JavaScript.d.ts +7 -7
  97. package/dist/quicktype-core/language/JavaScript.js +19 -17
  98. package/dist/quicktype-core/language/JavaScriptPropTypes.js +15 -13
  99. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +12 -11
  100. package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
  101. package/dist/quicktype-core/language/Kotlin.js +39 -37
  102. package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
  103. package/dist/quicktype-core/language/Objective-C.js +45 -41
  104. package/dist/quicktype-core/language/Php.d.ts +2 -2
  105. package/dist/quicktype-core/language/Php.js +66 -41
  106. package/dist/quicktype-core/language/Pike.d.ts +1 -1
  107. package/dist/quicktype-core/language/Pike.js +18 -17
  108. package/dist/quicktype-core/language/Python.d.ts +8 -8
  109. package/dist/quicktype-core/language/Python.js +63 -64
  110. package/dist/quicktype-core/language/Rust.d.ts +2 -2
  111. package/dist/quicktype-core/language/Rust.js +21 -19
  112. package/dist/quicktype-core/language/Swift.d.ts +7 -7
  113. package/dist/quicktype-core/language/Swift.js +568 -565
  114. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
  115. package/dist/quicktype-core/language/TypeScriptFlow.js +28 -26
  116. package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
  117. package/dist/quicktype-core/language/ruby/index.js +49 -24
  118. package/dist/quicktype-core/language/ruby/keywords.js +1 -0
  119. package/dist/quicktype-core/rewrites/CombineClasses.js +9 -8
  120. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
  121. package/dist/quicktype-core/rewrites/ExpandStrings.js +18 -17
  122. package/dist/quicktype-core/rewrites/FlattenStrings.js +7 -6
  123. package/dist/quicktype-core/rewrites/FlattenUnions.js +9 -8
  124. package/dist/quicktype-core/rewrites/InferMaps.js +11 -10
  125. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +8 -7
  126. package/dist/quicktype-core/rewrites/ResolveIntersections.js +68 -67
  127. package/dist/quicktype-core/support/Acronyms.js +3 -1
  128. package/dist/quicktype-core/support/Chance.js +10 -0
  129. package/dist/quicktype-core/support/Converters.js +1 -0
  130. package/dist/quicktype-core/support/Strings.d.ts +4 -4
  131. package/dist/quicktype-core/support/Strings.js +17 -16
  132. package/dist/quicktype-core/support/Support.d.ts +1 -1
  133. package/dist/quicktype-core/support/Support.js +30 -6
  134. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
  135. package/dist/quicktype-graphql-input/GraphQLSchema.js +1 -0
  136. package/dist/quicktype-graphql-input/index.d.ts +1 -1
  137. package/dist/quicktype-graphql-input/index.js +229 -212
  138. package/dist/quicktype-typescript-input/index.js +28 -4
  139. package/package.json +24 -20
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CPlusPlusRenderer = exports.MemberNames = exports.GlobalNames = exports.IncludeKind = exports.CPlusPlusTargetLanguage = exports.cPlusPlusOptions = void 0;
3
4
  const collection_utils_1 = require("collection-utils");
4
5
  const TargetLanguage_1 = require("../TargetLanguage");
5
6
  const Type_1 = require("../Type");
@@ -100,19 +101,19 @@ class CPlusPlusTargetLanguage extends TargetLanguage_1.TargetLanguage {
100
101
  return true;
101
102
  }
102
103
  makeRenderer(renderContext, untypedOptionValues) {
103
- return new CPlusPlusRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.cPlusPlusOptions, untypedOptionValues));
104
+ return new CPlusPlusRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.cPlusPlusOptions, untypedOptionValues));
104
105
  }
105
106
  }
106
107
  exports.CPlusPlusTargetLanguage = CPlusPlusTargetLanguage;
107
108
  function constraintsForType(t) {
108
- const minMax = Constraints_1.minMaxValueForType(t);
109
- const minMaxLength = Constraints_1.minMaxLengthForType(t);
110
- const pattern = Constraints_1.patternForType(t);
109
+ const minMax = (0, Constraints_1.minMaxValueForType)(t);
110
+ const minMaxLength = (0, Constraints_1.minMaxLengthForType)(t);
111
+ const pattern = (0, Constraints_1.patternForType)(t);
111
112
  if (minMax === undefined && minMaxLength === undefined && pattern === undefined)
112
113
  return undefined;
113
114
  return { minMax, minMaxLength, pattern };
114
115
  }
115
- const legalizeName = Strings_1.legalizeCharacters(cp => Strings_1.isAscii(cp) && Strings_1.isLetterOrUnderscoreOrDigit(cp));
116
+ const legalizeName = (0, Strings_1.legalizeCharacters)(cp => (0, Strings_1.isAscii)(cp) && (0, Strings_1.isLetterOrUnderscoreOrDigit)(cp));
116
117
  const keywords = [
117
118
  "alignas",
118
119
  "alignof",
@@ -274,6 +275,8 @@ function addQualifier(qualifier, qualified) {
274
275
  return [qualifier, qualified];
275
276
  }
276
277
  class WrappingCode {
278
+ _start;
279
+ _end;
277
280
  constructor(start, end) {
278
281
  this._start = start;
279
282
  this._end = end;
@@ -283,6 +286,14 @@ class WrappingCode {
283
286
  }
284
287
  }
285
288
  class BaseString {
289
+ _stringType;
290
+ _constStringType;
291
+ _smatch;
292
+ _regex;
293
+ _stringLiteralPrefix;
294
+ _toString;
295
+ _encodingClass;
296
+ _encodingFunction;
286
297
  constructor(stringType, constStringType, smatch, regex, stringLiteralPrefix, toString, encodingClass, encodingFunction) {
287
298
  (this._stringType = stringType),
288
299
  (this._constStringType = constStringType),
@@ -313,112 +324,39 @@ class BaseString {
313
324
  }
314
325
  }
315
326
  class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
327
+ _options;
328
+ /**
329
+ * For forward declaration practically
330
+ */
331
+ _enumType;
332
+ _generatedFiles;
333
+ _currentFilename;
334
+ _allTypeNames;
335
+ _gettersAndSettersForPropertyName = new Map();
336
+ _namespaceNames;
337
+ _memberNameStyle;
338
+ _namedTypeNameStyle;
339
+ _generatedGlobalNames;
340
+ _generatedMemberNames;
341
+ _forbiddenGlobalNames;
342
+ _memberNamingFunction;
343
+ _stringType;
344
+ _optionalType;
345
+ _nulloptType;
346
+ _variantType;
347
+ _variantIndexMethodName;
348
+ typeNamingStyle;
349
+ enumeratorNamingStyle;
316
350
  constructor(targetLanguage, renderContext, _options) {
317
351
  super(targetLanguage, renderContext);
318
352
  this._options = _options;
319
- this._gettersAndSettersForPropertyName = new Map();
320
- this.NarrowString = new (class extends BaseString {
321
- constructor() {
322
- super("std::string", "const std::string & ", "std::smatch", "std::regex", "", new WrappingCode(["std::to_string("], [")"]), "", "");
323
- }
324
- wrapEncodingChange(_qualifier, _fromType, _toType, inner) {
325
- return inner;
326
- }
327
- emitHelperFunctions() {
328
- return;
329
- }
330
- })();
331
- this.WideString = new (class extends BaseString {
332
- constructor(superThis) {
333
- super("std::wstring", "const std::wstring & ", "std::wsmatch", "std::wregex", "L", new WrappingCode(["std::to_wstring("], [")"]), "Utf16_Utf8", "convert");
334
- this.superThis = superThis;
335
- }
336
- wrapEncodingChange(qualifier, fromType, toType, inner) {
337
- if (this.superThis.sourcelikeToString(fromType) === this.superThis.sourcelikeToString(toType)) {
338
- return inner;
339
- }
340
- return [
341
- addQualifier(qualifier, [this._encodingClass]),
342
- "<",
343
- fromType,
344
- ", ",
345
- toType,
346
- ">::",
347
- this._encodingFunction,
348
- "(",
349
- inner,
350
- ")"
351
- ];
352
- }
353
- emitHelperFunctions() {
354
- this.superThis.emitLine("template<typename T>");
355
- this.superThis.emitLine("struct tag {};");
356
- this.superThis.ensureBlankLine();
357
- this.superThis.emitLine("template<typename fromType, typename toType>");
358
- this.superThis.emitBlock(["class Utf16_Utf8"], true, () => {
359
- this.superThis.emitLine("private:");
360
- this.superThis.emitLine("template<typename TF, typename TT>");
361
- this.superThis.emitBlock(["static toType convert(tag<std::shared_ptr<TF> >, tag<std::shared_ptr<TT> >, fromType ptr)"], false, () => {
362
- this.superThis.emitLine("if (ptr == nullptr) return std::unique_ptr<TT>(); else return std::unique_ptr<TT>(new TT(Utf16_Utf8<TF,TT>::convert(*ptr)));");
363
- });
364
- this.superThis.ensureBlankLine();
365
- this.superThis.emitLine("template<typename TF, typename TT>");
366
- this.superThis.emitBlock(["static toType convert(tag<std::vector<TF> >, tag<std::vector<TT> >, fromType v)"], false, () => {
367
- this.superThis.emitLine("auto it = v.begin();");
368
- this.superThis.emitLine("auto newVector = std::vector<TT>();");
369
- this.superThis.emitBlock(["while (it != v.end())"], false, () => {
370
- this.superThis.emitLine("newVector.push_back(Utf16_Utf8<TF,TT>::convert(*it));");
371
- this.superThis.emitLine("it++;");
372
- });
373
- this.superThis.emitLine("return newVector;");
374
- });
375
- this.superThis.ensureBlankLine();
376
- this.superThis.emitLine("template<typename KF, typename VF, typename KT, typename VT>");
377
- this.superThis.emitBlock(["static toType convert(tag<std::map<KF,VF> >, tag<std::map<KT,VT> >, fromType m)"], false, () => {
378
- this.superThis.emitLine("auto it = m.begin();");
379
- this.superThis.emitLine("auto newMap = std::map<KT, VT>();");
380
- this.superThis.emitBlock(["while (it != m.end())"], false, () => {
381
- this.superThis.emitLine("newMap.insert(std::pair<KT, VT>(Utf16_Utf8<KF, KT>::convert(it->first), Utf16_Utf8<VF, VT>::convert(it->second)));");
382
- this.superThis.emitLine("it++;");
383
- });
384
- this.superThis.emitLine("return newMap;");
385
- });
386
- this.superThis.ensureBlankLine();
387
- this.superThis.emitLine("template<typename TF, typename TT>");
388
- this.superThis.emitBlock(["static fromType convert(tag<TF>, tag<TT>, fromType from)"], false, () => {
389
- this.superThis.emitLine("return from;");
390
- });
391
- this.superThis.ensureBlankLine();
392
- this.superThis.emitBlock(["static std::wstring convert(tag<std::string>, tag<std::wstring>, std::string str)"], false, () => {
393
- this.superThis.emitLine("return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t>{}.from_bytes(str.data());");
394
- });
395
- this.superThis.ensureBlankLine();
396
- this.superThis.emitBlock(["static std::string convert(tag<std::wstring>, tag<std::string>, std::wstring str)"], false, () => {
397
- this.superThis.emitLine("return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t>{}.to_bytes(str.data());");
398
- });
399
- this.superThis.ensureBlankLine();
400
- this.superThis.emitLine("public:");
401
- this.superThis.emitBlock(["static toType convert(fromType in)"], false, () => {
402
- this.superThis.emitLine("return convert(tag<fromType>(), tag<toType>(), in);");
403
- });
404
- });
405
- this.superThis.ensureBlankLine();
406
- this.superThis.emitLine("template<typename T>");
407
- this.superThis.emitBlock(["std::wstring wdump(const T& j)"], false, () => {
408
- this.superThis.emitLine("std::ostringstream s;");
409
- this.superThis.emitLine("s << j;");
410
- this.superThis.emitLine("return ", this.superThis.ourQualifier(false), "Utf16_Utf8<std::string, std::wstring>::convert(s.str()); ");
411
- });
412
- this.superThis.ensureBlankLine();
413
- }
414
- })(this);
415
353
  this._enumType = _options.enumType;
416
354
  this._namespaceNames = _options.namespace.split("::");
417
355
  this.typeNamingStyle = _options.typeNamingStyle;
418
- this._namedTypeNameStyle = Strings_1.makeNameStyle(this.typeNamingStyle, legalizeName);
356
+ this._namedTypeNameStyle = (0, Strings_1.makeNameStyle)(this.typeNamingStyle, legalizeName);
419
357
  this.enumeratorNamingStyle = _options.enumeratorNamingStyle;
420
- this._memberNameStyle = Strings_1.makeNameStyle(_options.memberNamingStyle, legalizeName);
421
- this._memberNamingFunction = Naming_1.funPrefixNamer("members", this._memberNameStyle);
358
+ this._memberNameStyle = (0, Strings_1.makeNameStyle)(_options.memberNamingStyle, legalizeName);
359
+ this._memberNamingFunction = (0, Naming_1.funPrefixNamer)("members", this._memberNameStyle);
422
360
  this._gettersAndSettersForPropertyName = new Map();
423
361
  this._allTypeNames = new Set();
424
362
  this._generatedFiles = new Set();
@@ -481,10 +419,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
481
419
  ];
482
420
  }
483
421
  lookupGlobalName(type) {
484
- return Support_1.defined(this._generatedGlobalNames.get(type));
422
+ return (0, Support_1.defined)(this._generatedGlobalNames.get(type));
485
423
  }
486
424
  lookupMemberName(type) {
487
- return Support_1.defined(this._generatedMemberNames.get(type));
425
+ return (0, Support_1.defined)(this._generatedMemberNames.get(type));
488
426
  }
489
427
  addGlobalName(type) {
490
428
  const genName = this._namedTypeNameStyle(GlobalNames[type]);
@@ -495,10 +433,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
495
433
  this._generatedMemberNames.set(type, this._memberNameStyle(MemberNames[type]));
496
434
  }
497
435
  setupGlobalNames() {
498
- for (const v of Support_1.numberEnumValues(GlobalNames)) {
436
+ for (const v of (0, Support_1.numberEnumValues)(GlobalNames)) {
499
437
  this.addGlobalName(v);
500
438
  }
501
- for (const v of Support_1.numberEnumValues(MemberNames)) {
439
+ for (const v of (0, Support_1.numberEnumValues)(MemberNames)) {
502
440
  this.addMemberName(v);
503
441
  }
504
442
  }
@@ -512,7 +450,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
512
450
  return { names: [], includeGlobalForbidden: true };
513
451
  }
514
452
  makeNamedTypeNamer() {
515
- return Naming_1.funPrefixNamer("types", this._namedTypeNameStyle);
453
+ return (0, Naming_1.funPrefixNamer)("types", this._namedTypeNameStyle);
516
454
  }
517
455
  namerForObjectProperty() {
518
456
  return this._memberNamingFunction;
@@ -521,7 +459,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
521
459
  return null;
522
460
  }
523
461
  makeEnumCaseNamer() {
524
- return Naming_1.funPrefixNamer("enumerators", Strings_1.makeNameStyle(this.enumeratorNamingStyle, legalizeName));
462
+ return (0, Naming_1.funPrefixNamer)("enumerators", (0, Strings_1.makeNameStyle)(this.enumeratorNamingStyle, legalizeName));
525
463
  }
526
464
  makeNamesForPropertyGetterAndSetter(_c, _className, _p, _jsonName, name) {
527
465
  const getterName = new Naming_1.DependencyName(this._memberNamingFunction, name.order, lookup => `get_${lookup(name)}`);
@@ -546,7 +484,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
546
484
  this.emitLine("#include ", global ? "<" : '"', name, global ? ">" : '"');
547
485
  }
548
486
  startFile(basename, includeHelper = true) {
549
- Support_2.assert(this._currentFilename === undefined, "Previous file wasn't finished");
487
+ (0, Support_2.assert)(this._currentFilename === undefined, "Previous file wasn't finished");
550
488
  if (basename !== undefined) {
551
489
  this._currentFilename = this.sourcelikeToString(basename);
552
490
  }
@@ -606,7 +544,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
606
544
  this.ensureBlankLine();
607
545
  }
608
546
  finishFile() {
609
- super.finishFile(Support_1.defined(this._currentFilename));
547
+ super.finishFile((0, Support_1.defined)(this._currentFilename));
610
548
  this._currentFilename = undefined;
611
549
  }
612
550
  get needsTypeDeclarationBeforeUse() {
@@ -637,7 +575,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
637
575
  }
638
576
  }
639
577
  emitNamespaces(namespaceNames, f) {
640
- const namesArray = collection_utils_1.toReadonlyArray(namespaceNames);
578
+ const namesArray = (0, collection_utils_1.toReadonlyArray)(namespaceNames);
641
579
  const first = namesArray[0];
642
580
  if (first === undefined) {
643
581
  f();
@@ -648,7 +586,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
648
586
  }
649
587
  cppTypeInOptional(nonNulls, ctx, withIssues, forceNarrowString) {
650
588
  if (nonNulls.size === 1) {
651
- return this.cppType(Support_1.defined(collection_utils_1.iterableFirst(nonNulls)), ctx, withIssues, forceNarrowString, false);
589
+ return this.cppType((0, Support_1.defined)((0, collection_utils_1.iterableFirst)(nonNulls)), ctx, withIssues, forceNarrowString, false);
652
590
  }
653
591
  const typeList = [];
654
592
  for (const t of nonNulls) {
@@ -664,8 +602,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
664
602
  return [this._variantType, "<", typeList, ">"];
665
603
  }
666
604
  variantType(u, inJsonNamespace) {
667
- const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(u, true);
668
- Support_2.assert(nonNulls.size >= 2, "Variant not needed for less than two types.");
605
+ const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u, true);
606
+ (0, Support_2.assert)(nonNulls.size >= 2, "Variant not needed for less than two types.");
669
607
  const indirection = maybeNull !== null;
670
608
  const variant = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: !indirection, needsOptionalIndirection: !indirection, inJsonNamespace }, true, false);
671
609
  if (!indirection) {
@@ -674,7 +612,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
674
612
  return [optionalType, "<", variant, ">"];
675
613
  }
676
614
  ourQualifier(inJsonNamespace) {
677
- return inJsonNamespace ? [collection_utils_1.arrayIntercalate("::", this._namespaceNames), "::"] : [];
615
+ return inJsonNamespace ? [(0, collection_utils_1.arrayIntercalate)("::", this._namespaceNames), "::"] : [];
678
616
  }
679
617
  jsonQualifier(inJsonNamespace) {
680
618
  return inJsonNamespace ? [] : "nlohmann::";
@@ -695,12 +633,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
695
633
  }
696
634
  }
697
635
  }
698
- let typeSource = TypeUtils_1.matchType(t, _anyType => {
636
+ let typeSource = (0, TypeUtils_1.matchType)(t, _anyType => {
699
637
  isOptional = false;
700
- return Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
638
+ return (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
701
639
  }, _nullType => {
702
640
  isOptional = false;
703
- return Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
641
+ return (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
704
642
  }, _boolType => "bool", _integerType => "int64_t", _doubleType => "double", _stringType => {
705
643
  if (forceNarrowString) {
706
644
  return "std::string";
@@ -725,7 +663,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
725
663
  ">"
726
664
  ];
727
665
  }, enumType => [this.ourQualifier(inJsonNamespace), this.nameForNamedType(enumType)], unionType => {
728
- const nullable = TypeUtils_1.nullableFromUnion(unionType);
666
+ const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
729
667
  if (nullable === null)
730
668
  return [this.ourQualifier(inJsonNamespace), this.nameForNamedType(unionType)];
731
669
  isOptional = true;
@@ -792,7 +730,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
792
730
  });
793
731
  /** intentional "fall-through", add all subtypes as well - but forced include */
794
732
  }
795
- const [hasNull, nonNulls] = TypeUtils_1.removeNullFromUnion(t);
733
+ const [hasNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(t);
796
734
  isVariant = hasNull !== null;
797
735
  /** we need to collect all the subtypes of the union */
798
736
  for (const tt of nonNulls) {
@@ -829,7 +767,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
829
767
  this.emitMember(this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional), name);
830
768
  }
831
769
  else {
832
- const [getterName, mutableGetterName, setterName] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
770
+ const [getterName, mutableGetterName, setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
833
771
  const rendered = this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional);
834
772
  /**
835
773
  * fix for optional type -> e.g. unique_ptrs can't be copied
@@ -888,7 +826,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
888
826
  : [
889
827
  this._stringType.getType(),
890
828
  "(",
891
- this._stringType.createStringLiteral([Strings_1.stringEscape(pattern)]),
829
+ this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(pattern)]),
892
830
  ")"
893
831
  ],
894
832
  ")"
@@ -979,7 +917,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
979
917
  let toType;
980
918
  this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, "& x)"], false, () => {
981
919
  this.forEachClassProperty(c, "none", (name, json, p) => {
982
- const [, , setterName] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
920
+ const [, , setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
983
921
  const t = p.type;
984
922
  let assignment;
985
923
  if (this._options.codeFormat) {
@@ -992,7 +930,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
992
930
  this.emitLine(assignment.wrap([], [
993
931
  ourQualifier,
994
932
  "get_untyped(j, ",
995
- this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(json)])]),
933
+ this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])]),
996
934
  ")"
997
935
  ]), ";");
998
936
  return;
@@ -1000,7 +938,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1000
938
  if (p.isOptional || t instanceof Type_1.UnionType) {
1001
939
  const [nullOrOptional, typeSet] = (function () {
1002
940
  if (t instanceof Type_1.UnionType) {
1003
- const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(t, true);
941
+ const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(t, true);
1004
942
  return [maybeNull !== null || p.isOptional, nonNulls];
1005
943
  }
1006
944
  else {
@@ -1026,7 +964,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1026
964
  "get_optional<",
1027
965
  cppType,
1028
966
  ">(j, ",
1029
- this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(json)])]),
967
+ this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])]),
1030
968
  ")"
1031
969
  ])
1032
970
  ]), ";");
@@ -1037,7 +975,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1037
975
  toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, false, p.isOptional);
1038
976
  this.emitLine(assignment.wrap([], this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, [
1039
977
  "j.at(",
1040
- this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([Strings_1.stringEscape(json)])),
978
+ this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])),
1041
979
  ").get<",
1042
980
  cppType,
1043
981
  ">()"
@@ -1051,7 +989,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1051
989
  const t = p.type;
1052
990
  cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, false, p.isOptional);
1053
991
  toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, true, p.isOptional);
1054
- const [getterName, ,] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
992
+ const [getterName, ,] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
1055
993
  let getter;
1056
994
  if (this._options.codeFormat) {
1057
995
  getter = [getterName, "()"];
@@ -1061,7 +999,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1061
999
  }
1062
1000
  let assignment = [
1063
1001
  "j[",
1064
- this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([Strings_1.stringEscape(json)])),
1002
+ this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])),
1065
1003
  "] = ",
1066
1004
  this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, ["x.", getter]),
1067
1005
  ";"
@@ -1083,13 +1021,13 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1083
1021
  }
1084
1022
  emitEnum(e, enumName) {
1085
1023
  const caseNames = [];
1086
- const enumValues = EnumValues_1.enumCaseValues(e, this.targetLanguage.name);
1024
+ const enumValues = (0, EnumValues_1.enumCaseValues)(e, this.targetLanguage.name);
1087
1025
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1088
1026
  if (caseNames.length > 0)
1089
1027
  caseNames.push(", ");
1090
1028
  caseNames.push(name);
1091
1029
  if (enumValues !== undefined) {
1092
- const [enumValue] = AccessorNames_1.getAccessorName(enumValues, jsonName);
1030
+ const [enumValue] = (0, AccessorNames_1.getAccessorName)(enumValues, jsonName);
1093
1031
  if (enumValue !== undefined) {
1094
1032
  caseNames.push(" = ", enumValue.toString());
1095
1033
  }
@@ -1107,7 +1045,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1107
1045
  // variant type. If at least one of the Ts is our type then we could get away with regular adl definitions,
1108
1046
  // but it's nontrivial to detect that (consider variant<string, variant<map<string, string>, int>> which
1109
1047
  // does need an adl_serializer specialization) so we'll just specialize every time.
1110
- const nonNulls = TypeUtils_1.removeNullFromUnion(u, true)[1];
1048
+ const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
1111
1049
  const variantType = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false);
1112
1050
  this.emitLine("template <>");
1113
1051
  this.emitBlock(["struct adl_serializer<", variantType, ">"], true, () => {
@@ -1128,12 +1066,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1128
1066
  ["array", "is_array"],
1129
1067
  ["enum", "is_string"]
1130
1068
  ];
1131
- const nonNulls = TypeUtils_1.removeNullFromUnion(u, true)[1];
1069
+ const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
1132
1070
  const variantType = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false);
1133
1071
  this.emitBlock(["inline void adl_serializer<", variantType, ">::from_json(", this.withConst("json"), " & j, ", variantType, " & x)"], false, () => {
1134
1072
  let onFirst = true;
1135
1073
  for (const [kind, func] of functionForKind) {
1136
- const typeForKind = collection_utils_1.iterableFind(nonNulls, t => t.kind === kind);
1074
+ const typeForKind = (0, collection_utils_1.iterableFind)(nonNulls, t => t.kind === kind);
1137
1075
  if (typeForKind === undefined)
1138
1076
  continue;
1139
1077
  this.emitLine(onFirst ? "if" : "else if", " (j.", func, "())");
@@ -1203,7 +1141,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1203
1141
  "> enumValues"
1204
1142
  ], true, () => {
1205
1143
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1206
- this.emitLine("{", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(jsonName)])]), ", ", ourQualifier, enumName, "::", name, "},");
1144
+ this.emitLine("{", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(jsonName)])]), ", ", ourQualifier, enumName, "::", name, "},");
1207
1145
  });
1208
1146
  });
1209
1147
  this.emitLine(`auto iter = enumValues.find(j.get<${this._stringType.getType()}>());`);
@@ -1215,7 +1153,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1215
1153
  let onFirst = true;
1216
1154
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1217
1155
  const maybeElse = onFirst ? "" : "else ";
1218
- this.emitLine(maybeElse, "if (j == ", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(jsonName)])]), ") x = ", ourQualifier, enumName, "::", name, ";");
1156
+ this.emitLine(maybeElse, "if (j == ", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(jsonName)])]), ") x = ", ourQualifier, enumName, "::", name, ";");
1219
1157
  onFirst = false;
1220
1158
  });
1221
1159
  this.emitLine('else throw "Input JSON does not conform to schema";');
@@ -1225,7 +1163,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1225
1163
  this.emitBlock(["inline void to_json(json & j, ", this.withConst([ourQualifier, enumName]), " & x)"], false, () => {
1226
1164
  this.emitBlock("switch (x)", false, () => {
1227
1165
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1228
- this.emitLine("case ", ourQualifier, enumName, "::", name, ": j = ", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(jsonName)])]), "; break;");
1166
+ this.emitLine("case ", ourQualifier, enumName, "::", name, ": j = ", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(jsonName)])]), "; break;");
1229
1167
  });
1230
1168
  this.emitLine('default: throw "This should not happen";');
1231
1169
  });
@@ -1235,10 +1173,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1235
1173
  this.emitLine("using ", name, " = ", this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, false), ";");
1236
1174
  }
1237
1175
  emitAllUnionFunctions() {
1238
- this.forEachUniqueUnion("leading-and-interposing", u => this.sourcelikeToString(this.cppTypeInOptional(TypeUtils_1.removeNullFromUnion(u, true)[1], { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false)), (u) => this.emitUnionFunctions(u));
1176
+ this.forEachUniqueUnion("leading-and-interposing", u => this.sourcelikeToString(this.cppTypeInOptional((0, TypeUtils_1.removeNullFromUnion)(u, true)[1], { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false)), (u) => this.emitUnionFunctions(u));
1239
1177
  }
1240
1178
  emitAllUnionHeaders() {
1241
- this.forEachUniqueUnion("interposing", u => this.sourcelikeToString(this.cppTypeInOptional(TypeUtils_1.removeNullFromUnion(u, true)[1], { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false)), (u) => this.emitUnionHeaders(u));
1179
+ this.forEachUniqueUnion("interposing", u => this.sourcelikeToString(this.cppTypeInOptional((0, TypeUtils_1.removeNullFromUnion)(u, true)[1], { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false)), (u) => this.emitUnionHeaders(u));
1242
1180
  }
1243
1181
  emitOptionalHelpers() {
1244
1182
  this.emitLine("#ifndef NLOHMANN_OPT_HELPER");
@@ -1279,11 +1217,11 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1279
1217
  this.emitUnionTypedefs(t, name);
1280
1218
  }
1281
1219
  else {
1282
- return Support_1.panic(`Cannot declare type ${t.kind}`);
1220
+ return (0, Support_1.panic)(`Cannot declare type ${t.kind}`);
1283
1221
  }
1284
1222
  }
1285
1223
  else {
1286
- return Support_1.assertNever(decl.kind);
1224
+ return (0, Support_1.assertNever)(decl.kind);
1287
1225
  }
1288
1226
  }
1289
1227
  emitGetterSetter(t, getterName, setterName, memberName) {
@@ -1317,12 +1255,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1317
1255
  const member = this.lookupMemberName(name);
1318
1256
  return [member, "(", member, ")"];
1319
1257
  });
1320
- this.emitLine(") : ", collection_utils_1.arrayIntercalate([", "], args), " {}");
1258
+ this.emitLine(") : ", (0, collection_utils_1.arrayIntercalate)([", "], args), " {}");
1321
1259
  this.emitLine(classConstraint, "() = default;");
1322
1260
  this.emitLine("virtual ~", classConstraint, "() = default;");
1323
1261
  for (const member of constraintMembers) {
1324
1262
  this.ensureBlankLine();
1325
- this.emitGetterSetter(collection_utils_1.withDefault(member.cppConstType, member.cppType), this.lookupMemberName(member.getter), this.lookupMemberName(member.setter), this.lookupMemberName(member.name));
1263
+ this.emitGetterSetter((0, collection_utils_1.withDefault)(member.cppConstType, member.cppType), this.lookupMemberName(member.getter), this.lookupMemberName(member.setter), this.lookupMemberName(member.name));
1326
1264
  }
1327
1265
  });
1328
1266
  this.ensureBlankLine();
@@ -1415,7 +1353,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1415
1353
  emitHelperFunctions() {
1416
1354
  this._stringType.emitHelperFunctions();
1417
1355
  if (this._options.codeFormat &&
1418
- collection_utils_1.iterableSome(this.typeGraph.allTypesUnordered(), t => constraintsForType(t) !== undefined)) {
1356
+ (0, collection_utils_1.iterableSome)(this.typeGraph.allTypesUnordered(), t => constraintsForType(t) !== undefined)) {
1419
1357
  this.emitConstraintClasses();
1420
1358
  this.ensureBlankLine();
1421
1359
  }
@@ -1628,7 +1566,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1628
1566
  else if (t.type instanceof Type_1.UnionType) {
1629
1567
  propRecord.typeKind = "union";
1630
1568
  /** Recurse into the union */
1631
- const [maybeNull] = TypeUtils_1.removeNullFromUnion(t.type, true);
1569
+ const [maybeNull] = (0, TypeUtils_1.removeNullFromUnion)(t.type, true);
1632
1570
  if (maybeNull !== undefined) {
1633
1571
  /** Houston this is a variant, include it */
1634
1572
  propRecord.kind = IncludeKind.Include;
@@ -1712,7 +1650,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1712
1650
  this.emitLine("enum class ", name, " : ", this._enumType, ";");
1713
1651
  }
1714
1652
  else {
1715
- Support_1.panic(`Invalid type "${rec.typeKind}" to forward declare`);
1653
+ (0, Support_1.panic)(`Invalid type "${rec.typeKind}" to forward declare`);
1716
1654
  }
1717
1655
  });
1718
1656
  });
@@ -1783,8 +1721,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1783
1721
  /** Gather all the unique/custom types used by the schema */
1784
1722
  this._allTypeNames.clear();
1785
1723
  this.forEachDeclaration("none", decl => {
1786
- const definedTypes = TypeUtils_1.directlyReachableTypes(decl.type, t => {
1787
- if (TypeUtils_1.isNamedType(t) && (t instanceof Type_1.ClassType || t instanceof Type_1.EnumType || t instanceof Type_1.UnionType)) {
1724
+ const definedTypes = (0, TypeUtils_1.directlyReachableTypes)(decl.type, t => {
1725
+ if ((0, TypeUtils_1.isNamedType)(t) && (t instanceof Type_1.ClassType || t instanceof Type_1.EnumType || t instanceof Type_1.UnionType)) {
1788
1726
  return new Set([
1789
1727
  this.sourcelikeToString(this.cppType(t, {
1790
1728
  needsForwardIndirection: false,
@@ -1795,7 +1733,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1795
1733
  }
1796
1734
  return null;
1797
1735
  });
1798
- this._allTypeNames = collection_utils_1.setUnion(definedTypes, this._allTypeNames);
1736
+ this._allTypeNames = (0, collection_utils_1.setUnion)(definedTypes, this._allTypeNames);
1799
1737
  });
1800
1738
  if (this._options.typeSourceStyle) {
1801
1739
  this.emitSingleSourceStructure(proposedFilename);
@@ -1809,5 +1747,101 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1809
1747
  let newType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
1810
1748
  return originalType !== newType;
1811
1749
  }
1750
+ NarrowString = new (class extends BaseString {
1751
+ constructor() {
1752
+ super("std::string", "const std::string & ", "std::smatch", "std::regex", "", new WrappingCode(["std::to_string("], [")"]), "", "");
1753
+ }
1754
+ wrapEncodingChange(_qualifier, _fromType, _toType, inner) {
1755
+ return inner;
1756
+ }
1757
+ emitHelperFunctions() {
1758
+ return;
1759
+ }
1760
+ })();
1761
+ WideString = new (class extends BaseString {
1762
+ superThis;
1763
+ constructor(superThis) {
1764
+ super("std::wstring", "const std::wstring & ", "std::wsmatch", "std::wregex", "L", new WrappingCode(["std::to_wstring("], [")"]), "Utf16_Utf8", "convert");
1765
+ this.superThis = superThis;
1766
+ }
1767
+ wrapEncodingChange(qualifier, fromType, toType, inner) {
1768
+ if (this.superThis.sourcelikeToString(fromType) === this.superThis.sourcelikeToString(toType)) {
1769
+ return inner;
1770
+ }
1771
+ return [
1772
+ addQualifier(qualifier, [this._encodingClass]),
1773
+ "<",
1774
+ fromType,
1775
+ ", ",
1776
+ toType,
1777
+ ">::",
1778
+ this._encodingFunction,
1779
+ "(",
1780
+ inner,
1781
+ ")"
1782
+ ];
1783
+ }
1784
+ emitHelperFunctions() {
1785
+ this.superThis.emitLine("template<typename T>");
1786
+ this.superThis.emitLine("struct tag {};");
1787
+ this.superThis.ensureBlankLine();
1788
+ this.superThis.emitLine("template<typename fromType, typename toType>");
1789
+ this.superThis.emitBlock(["class Utf16_Utf8"], true, () => {
1790
+ this.superThis.emitLine("private:");
1791
+ this.superThis.emitLine("template<typename TF, typename TT>");
1792
+ this.superThis.emitBlock(["static toType convert(tag<std::shared_ptr<TF> >, tag<std::shared_ptr<TT> >, fromType ptr)"], false, () => {
1793
+ this.superThis.emitLine("if (ptr == nullptr) return std::unique_ptr<TT>(); else return std::unique_ptr<TT>(new TT(Utf16_Utf8<TF,TT>::convert(*ptr)));");
1794
+ });
1795
+ this.superThis.ensureBlankLine();
1796
+ this.superThis.emitLine("template<typename TF, typename TT>");
1797
+ this.superThis.emitBlock(["static toType convert(tag<std::vector<TF> >, tag<std::vector<TT> >, fromType v)"], false, () => {
1798
+ this.superThis.emitLine("auto it = v.begin();");
1799
+ this.superThis.emitLine("auto newVector = std::vector<TT>();");
1800
+ this.superThis.emitBlock(["while (it != v.end())"], false, () => {
1801
+ this.superThis.emitLine("newVector.push_back(Utf16_Utf8<TF,TT>::convert(*it));");
1802
+ this.superThis.emitLine("it++;");
1803
+ });
1804
+ this.superThis.emitLine("return newVector;");
1805
+ });
1806
+ this.superThis.ensureBlankLine();
1807
+ this.superThis.emitLine("template<typename KF, typename VF, typename KT, typename VT>");
1808
+ this.superThis.emitBlock(["static toType convert(tag<std::map<KF,VF> >, tag<std::map<KT,VT> >, fromType m)"], false, () => {
1809
+ this.superThis.emitLine("auto it = m.begin();");
1810
+ this.superThis.emitLine("auto newMap = std::map<KT, VT>();");
1811
+ this.superThis.emitBlock(["while (it != m.end())"], false, () => {
1812
+ this.superThis.emitLine("newMap.insert(std::pair<KT, VT>(Utf16_Utf8<KF, KT>::convert(it->first), Utf16_Utf8<VF, VT>::convert(it->second)));");
1813
+ this.superThis.emitLine("it++;");
1814
+ });
1815
+ this.superThis.emitLine("return newMap;");
1816
+ });
1817
+ this.superThis.ensureBlankLine();
1818
+ this.superThis.emitLine("template<typename TF, typename TT>");
1819
+ this.superThis.emitBlock(["static fromType convert(tag<TF>, tag<TT>, fromType from)"], false, () => {
1820
+ this.superThis.emitLine("return from;");
1821
+ });
1822
+ this.superThis.ensureBlankLine();
1823
+ this.superThis.emitBlock(["static std::wstring convert(tag<std::string>, tag<std::wstring>, std::string str)"], false, () => {
1824
+ this.superThis.emitLine("return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t>{}.from_bytes(str.data());");
1825
+ });
1826
+ this.superThis.ensureBlankLine();
1827
+ this.superThis.emitBlock(["static std::string convert(tag<std::wstring>, tag<std::string>, std::wstring str)"], false, () => {
1828
+ this.superThis.emitLine("return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t>{}.to_bytes(str.data());");
1829
+ });
1830
+ this.superThis.ensureBlankLine();
1831
+ this.superThis.emitLine("public:");
1832
+ this.superThis.emitBlock(["static toType convert(fromType in)"], false, () => {
1833
+ this.superThis.emitLine("return convert(tag<fromType>(), tag<toType>(), in);");
1834
+ });
1835
+ });
1836
+ this.superThis.ensureBlankLine();
1837
+ this.superThis.emitLine("template<typename T>");
1838
+ this.superThis.emitBlock(["std::wstring wdump(const T& j)"], false, () => {
1839
+ this.superThis.emitLine("std::ostringstream s;");
1840
+ this.superThis.emitLine("s << j;");
1841
+ this.superThis.emitLine("return ", this.superThis.ourQualifier(false), "Utf16_Utf8<std::string, std::wstring>::convert(s.str()); ");
1842
+ });
1843
+ this.superThis.ensureBlankLine();
1844
+ }
1845
+ })(this);
1812
1846
  }
1813
1847
  exports.CPlusPlusRenderer = CPlusPlusRenderer;