quicktype 17.0.5 → 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 +12 -9
  79. package/dist/quicktype-core/language/CPlusPlus.js +283 -217
  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");
@@ -38,10 +39,6 @@ exports.cPlusPlusOptions = {
38
39
  ["use-string", false],
39
40
  ["use-wstring", true]
40
41
  ], "use-string"),
41
- msbuildPermissive: new RendererOptions_1.EnumOption("msbuildPermissive", "Moves to_json and from_json types into the nlohmann::details namespace, so that msbuild can build it with conformance mode disabled", [
42
- ["not-permissive", false],
43
- ["use-permissive", true]
44
- ], "not-permissive", "secondary"),
45
42
  westConst: new RendererOptions_1.EnumOption("const-style", "Put const to the left/west (const T) or right/east (T const)", [
46
43
  ["west-const", true],
47
44
  ["east-const", false]
@@ -86,7 +83,6 @@ class CPlusPlusTargetLanguage extends TargetLanguage_1.TargetLanguage {
86
83
  exports.cPlusPlusOptions.namespace,
87
84
  exports.cPlusPlusOptions.codeFormat,
88
85
  exports.cPlusPlusOptions.wstring,
89
- exports.cPlusPlusOptions.msbuildPermissive,
90
86
  exports.cPlusPlusOptions.westConst,
91
87
  exports.cPlusPlusOptions.typeSourceStyle,
92
88
  exports.cPlusPlusOptions.includeLocation,
@@ -105,19 +101,19 @@ class CPlusPlusTargetLanguage extends TargetLanguage_1.TargetLanguage {
105
101
  return true;
106
102
  }
107
103
  makeRenderer(renderContext, untypedOptionValues) {
108
- return new CPlusPlusRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.cPlusPlusOptions, untypedOptionValues));
104
+ return new CPlusPlusRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.cPlusPlusOptions, untypedOptionValues));
109
105
  }
110
106
  }
111
107
  exports.CPlusPlusTargetLanguage = CPlusPlusTargetLanguage;
112
108
  function constraintsForType(t) {
113
- const minMax = Constraints_1.minMaxValueForType(t);
114
- const minMaxLength = Constraints_1.minMaxLengthForType(t);
115
- 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);
116
112
  if (minMax === undefined && minMaxLength === undefined && pattern === undefined)
117
113
  return undefined;
118
114
  return { minMax, minMaxLength, pattern };
119
115
  }
120
- 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));
121
117
  const keywords = [
122
118
  "alignas",
123
119
  "alignof",
@@ -279,6 +275,8 @@ function addQualifier(qualifier, qualified) {
279
275
  return [qualifier, qualified];
280
276
  }
281
277
  class WrappingCode {
278
+ _start;
279
+ _end;
282
280
  constructor(start, end) {
283
281
  this._start = start;
284
282
  this._end = end;
@@ -288,6 +286,14 @@ class WrappingCode {
288
286
  }
289
287
  }
290
288
  class BaseString {
289
+ _stringType;
290
+ _constStringType;
291
+ _smatch;
292
+ _regex;
293
+ _stringLiteralPrefix;
294
+ _toString;
295
+ _encodingClass;
296
+ _encodingFunction;
291
297
  constructor(stringType, constStringType, smatch, regex, stringLiteralPrefix, toString, encodingClass, encodingFunction) {
292
298
  (this._stringType = stringType),
293
299
  (this._constStringType = constStringType),
@@ -318,112 +324,39 @@ class BaseString {
318
324
  }
319
325
  }
320
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;
321
350
  constructor(targetLanguage, renderContext, _options) {
322
351
  super(targetLanguage, renderContext);
323
352
  this._options = _options;
324
- this._gettersAndSettersForPropertyName = new Map();
325
- this.NarrowString = new (class extends BaseString {
326
- constructor() {
327
- super("std::string", "const std::string & ", "std::smatch", "std::regex", "", new WrappingCode(["std::to_string("], [")"]), "", "");
328
- }
329
- wrapEncodingChange(_qualifier, _fromType, _toType, inner) {
330
- return inner;
331
- }
332
- emitHelperFunctions() {
333
- return;
334
- }
335
- })();
336
- this.WideString = new (class extends BaseString {
337
- constructor(superThis) {
338
- super("std::wstring", "const std::wstring & ", "std::wsmatch", "std::wregex", "L", new WrappingCode(["std::to_wstring("], [")"]), "Utf16_Utf8", "convert");
339
- this.superThis = superThis;
340
- }
341
- wrapEncodingChange(qualifier, fromType, toType, inner) {
342
- if (this.superThis.sourcelikeToString(fromType) === this.superThis.sourcelikeToString(toType)) {
343
- return inner;
344
- }
345
- return [
346
- addQualifier(qualifier, [this._encodingClass]),
347
- "<",
348
- fromType,
349
- ", ",
350
- toType,
351
- ">::",
352
- this._encodingFunction,
353
- "(",
354
- inner,
355
- ")"
356
- ];
357
- }
358
- emitHelperFunctions() {
359
- this.superThis.emitLine("template<typename T>");
360
- this.superThis.emitLine("struct tag {};");
361
- this.superThis.ensureBlankLine();
362
- this.superThis.emitLine("template<typename fromType, typename toType>");
363
- this.superThis.emitBlock(["class Utf16_Utf8"], true, () => {
364
- this.superThis.emitLine("private:");
365
- this.superThis.emitLine("template<typename TF, typename TT>");
366
- this.superThis.emitBlock(["static toType convert(tag<std::shared_ptr<TF> >, tag<std::shared_ptr<TT> >, fromType ptr)"], false, () => {
367
- 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)));");
368
- });
369
- this.superThis.ensureBlankLine();
370
- this.superThis.emitLine("template<typename TF, typename TT>");
371
- this.superThis.emitBlock(["static toType convert(tag<std::vector<TF> >, tag<std::vector<TT> >, fromType v)"], false, () => {
372
- this.superThis.emitLine("auto it = v.begin();");
373
- this.superThis.emitLine("auto newVector = std::vector<TT>();");
374
- this.superThis.emitBlock(["while (it != v.end())"], false, () => {
375
- this.superThis.emitLine("newVector.push_back(Utf16_Utf8<TF,TT>::convert(*it));");
376
- this.superThis.emitLine("it++;");
377
- });
378
- this.superThis.emitLine("return newVector;");
379
- });
380
- this.superThis.ensureBlankLine();
381
- this.superThis.emitLine("template<typename KF, typename VF, typename KT, typename VT>");
382
- this.superThis.emitBlock(["static toType convert(tag<std::map<KF,VF> >, tag<std::map<KT,VT> >, fromType m)"], false, () => {
383
- this.superThis.emitLine("auto it = m.begin();");
384
- this.superThis.emitLine("auto newMap = std::map<KT, VT>();");
385
- this.superThis.emitBlock(["while (it != m.end())"], false, () => {
386
- this.superThis.emitLine("newMap.insert(std::pair<KT, VT>(Utf16_Utf8<KF, KT>::convert(it->first), Utf16_Utf8<VF, VT>::convert(it->second)));");
387
- this.superThis.emitLine("it++;");
388
- });
389
- this.superThis.emitLine("return newMap;");
390
- });
391
- this.superThis.ensureBlankLine();
392
- this.superThis.emitLine("template<typename TF, typename TT>");
393
- this.superThis.emitBlock(["static fromType convert(tag<TF>, tag<TT>, fromType from)"], false, () => {
394
- this.superThis.emitLine("return from;");
395
- });
396
- this.superThis.ensureBlankLine();
397
- this.superThis.emitBlock(["static std::wstring convert(tag<std::string>, tag<std::wstring>, std::string str)"], false, () => {
398
- this.superThis.emitLine("return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t>{}.from_bytes(str.data());");
399
- });
400
- this.superThis.ensureBlankLine();
401
- this.superThis.emitBlock(["static std::string convert(tag<std::wstring>, tag<std::string>, std::wstring str)"], false, () => {
402
- this.superThis.emitLine("return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t>{}.to_bytes(str.data());");
403
- });
404
- this.superThis.ensureBlankLine();
405
- this.superThis.emitLine("public:");
406
- this.superThis.emitBlock(["static toType convert(fromType in)"], false, () => {
407
- this.superThis.emitLine("return convert(tag<fromType>(), tag<toType>(), in);");
408
- });
409
- });
410
- this.superThis.ensureBlankLine();
411
- this.superThis.emitLine("template<typename T>");
412
- this.superThis.emitBlock(["std::wstring wdump(const T& j)"], false, () => {
413
- this.superThis.emitLine("std::ostringstream s;");
414
- this.superThis.emitLine("s << j;");
415
- this.superThis.emitLine("return ", this.superThis.ourQualifier(false), "Utf16_Utf8<std::string, std::wstring>::convert(s.str()); ");
416
- });
417
- this.superThis.ensureBlankLine();
418
- }
419
- })(this);
420
353
  this._enumType = _options.enumType;
421
354
  this._namespaceNames = _options.namespace.split("::");
422
355
  this.typeNamingStyle = _options.typeNamingStyle;
423
- this._namedTypeNameStyle = Strings_1.makeNameStyle(this.typeNamingStyle, legalizeName);
356
+ this._namedTypeNameStyle = (0, Strings_1.makeNameStyle)(this.typeNamingStyle, legalizeName);
424
357
  this.enumeratorNamingStyle = _options.enumeratorNamingStyle;
425
- this._memberNameStyle = Strings_1.makeNameStyle(_options.memberNamingStyle, legalizeName);
426
- 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);
427
360
  this._gettersAndSettersForPropertyName = new Map();
428
361
  this._allTypeNames = new Set();
429
362
  this._generatedFiles = new Set();
@@ -486,10 +419,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
486
419
  ];
487
420
  }
488
421
  lookupGlobalName(type) {
489
- return Support_1.defined(this._generatedGlobalNames.get(type));
422
+ return (0, Support_1.defined)(this._generatedGlobalNames.get(type));
490
423
  }
491
424
  lookupMemberName(type) {
492
- return Support_1.defined(this._generatedMemberNames.get(type));
425
+ return (0, Support_1.defined)(this._generatedMemberNames.get(type));
493
426
  }
494
427
  addGlobalName(type) {
495
428
  const genName = this._namedTypeNameStyle(GlobalNames[type]);
@@ -500,10 +433,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
500
433
  this._generatedMemberNames.set(type, this._memberNameStyle(MemberNames[type]));
501
434
  }
502
435
  setupGlobalNames() {
503
- for (const v of Support_1.numberEnumValues(GlobalNames)) {
436
+ for (const v of (0, Support_1.numberEnumValues)(GlobalNames)) {
504
437
  this.addGlobalName(v);
505
438
  }
506
- for (const v of Support_1.numberEnumValues(MemberNames)) {
439
+ for (const v of (0, Support_1.numberEnumValues)(MemberNames)) {
507
440
  this.addMemberName(v);
508
441
  }
509
442
  }
@@ -517,7 +450,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
517
450
  return { names: [], includeGlobalForbidden: true };
518
451
  }
519
452
  makeNamedTypeNamer() {
520
- return Naming_1.funPrefixNamer("types", this._namedTypeNameStyle);
453
+ return (0, Naming_1.funPrefixNamer)("types", this._namedTypeNameStyle);
521
454
  }
522
455
  namerForObjectProperty() {
523
456
  return this._memberNamingFunction;
@@ -526,7 +459,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
526
459
  return null;
527
460
  }
528
461
  makeEnumCaseNamer() {
529
- 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));
530
463
  }
531
464
  makeNamesForPropertyGetterAndSetter(_c, _className, _p, _jsonName, name) {
532
465
  const getterName = new Naming_1.DependencyName(this._memberNamingFunction, name.order, lookup => `get_${lookup(name)}`);
@@ -551,7 +484,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
551
484
  this.emitLine("#include ", global ? "<" : '"', name, global ? ">" : '"');
552
485
  }
553
486
  startFile(basename, includeHelper = true) {
554
- Support_2.assert(this._currentFilename === undefined, "Previous file wasn't finished");
487
+ (0, Support_2.assert)(this._currentFilename === undefined, "Previous file wasn't finished");
555
488
  if (basename !== undefined) {
556
489
  this._currentFilename = this.sourcelikeToString(basename);
557
490
  }
@@ -571,18 +504,18 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
571
504
  ]);
572
505
  if (this._options.typeSourceStyle) {
573
506
  this.forEachTopLevel("none", (_, topLevelName) => {
574
- this.emitLine("// ", this.ourQualifier(false), topLevelName, " data = nlohmann::json::parse(jsonString);");
507
+ this.emitLine("// ", topLevelName, " data = nlohmann::json::parse(jsonString);");
575
508
  });
576
509
  }
577
510
  else {
578
- this.emitLine("// ", this.ourQualifier(false), basename, " data = nlohmann::json::parse(jsonString);");
511
+ this.emitLine("// ", basename, " data = nlohmann::json::parse(jsonString);");
579
512
  }
580
513
  if (this._options.wstring) {
581
514
  this.emitLine("//");
582
515
  this.emitLine("// You can get std::wstring data back out using");
583
516
  this.emitLine("//");
584
517
  this.forEachTopLevel("none", (_, topLevelName) => {
585
- this.emitLine("// std::wcout << ", this.ourQualifier(false), "wdump((nlohmann::json) ", topLevelName, ");");
518
+ this.emitLine("// std::wcout << ", "wdump((nlohmann::json) ", topLevelName, ");");
586
519
  });
587
520
  }
588
521
  }
@@ -611,7 +544,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
611
544
  this.ensureBlankLine();
612
545
  }
613
546
  finishFile() {
614
- super.finishFile(Support_1.defined(this._currentFilename));
547
+ super.finishFile((0, Support_1.defined)(this._currentFilename));
615
548
  this._currentFilename = undefined;
616
549
  }
617
550
  get needsTypeDeclarationBeforeUse() {
@@ -642,7 +575,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
642
575
  }
643
576
  }
644
577
  emitNamespaces(namespaceNames, f) {
645
- const namesArray = collection_utils_1.toReadonlyArray(namespaceNames);
578
+ const namesArray = (0, collection_utils_1.toReadonlyArray)(namespaceNames);
646
579
  const first = namesArray[0];
647
580
  if (first === undefined) {
648
581
  f();
@@ -653,7 +586,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
653
586
  }
654
587
  cppTypeInOptional(nonNulls, ctx, withIssues, forceNarrowString) {
655
588
  if (nonNulls.size === 1) {
656
- 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);
657
590
  }
658
591
  const typeList = [];
659
592
  for (const t of nonNulls) {
@@ -669,8 +602,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
669
602
  return [this._variantType, "<", typeList, ">"];
670
603
  }
671
604
  variantType(u, inJsonNamespace) {
672
- const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(u, true);
673
- 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.");
674
607
  const indirection = maybeNull !== null;
675
608
  const variant = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: !indirection, needsOptionalIndirection: !indirection, inJsonNamespace }, true, false);
676
609
  if (!indirection) {
@@ -679,12 +612,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
679
612
  return [optionalType, "<", variant, ">"];
680
613
  }
681
614
  ourQualifier(inJsonNamespace) {
682
- return inJsonNamespace || this._options.msbuildPermissive
683
- ? [collection_utils_1.arrayIntercalate("::", this._namespaceNames), "::"]
684
- : [];
615
+ return inJsonNamespace ? [(0, collection_utils_1.arrayIntercalate)("::", this._namespaceNames), "::"] : [];
685
616
  }
686
617
  jsonQualifier(inJsonNamespace) {
687
- return inJsonNamespace || this._options.msbuildPermissive ? [] : "nlohmann::";
618
+ return inJsonNamespace ? [] : "nlohmann::";
688
619
  }
689
620
  variantIndirection(needIndirection, typeSrc) {
690
621
  if (!needIndirection)
@@ -702,18 +633,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
702
633
  }
703
634
  }
704
635
  }
705
- let typeSource = TypeUtils_1.matchType(t, _anyType => {
636
+ let typeSource = (0, TypeUtils_1.matchType)(t, _anyType => {
706
637
  isOptional = false;
707
- return Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, [
708
- this.jsonQualifier(inJsonNamespace),
709
- "json"
710
- ]);
638
+ return (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
711
639
  }, _nullType => {
712
640
  isOptional = false;
713
- return Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, [
714
- this.jsonQualifier(inJsonNamespace),
715
- "json"
716
- ]);
641
+ return (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
717
642
  }, _boolType => "bool", _integerType => "int64_t", _doubleType => "double", _stringType => {
718
643
  if (forceNarrowString) {
719
644
  return "std::string";
@@ -738,7 +663,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
738
663
  ">"
739
664
  ];
740
665
  }, enumType => [this.ourQualifier(inJsonNamespace), this.nameForNamedType(enumType)], unionType => {
741
- const nullable = TypeUtils_1.nullableFromUnion(unionType);
666
+ const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
742
667
  if (nullable === null)
743
668
  return [this.ourQualifier(inJsonNamespace), this.nameForNamedType(unionType)];
744
669
  isOptional = true;
@@ -805,7 +730,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
805
730
  });
806
731
  /** intentional "fall-through", add all subtypes as well - but forced include */
807
732
  }
808
- const [hasNull, nonNulls] = TypeUtils_1.removeNullFromUnion(t);
733
+ const [hasNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(t);
809
734
  isVariant = hasNull !== null;
810
735
  /** we need to collect all the subtypes of the union */
811
736
  for (const tt of nonNulls) {
@@ -842,7 +767,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
842
767
  this.emitMember(this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional), name);
843
768
  }
844
769
  else {
845
- const [getterName, mutableGetterName, setterName] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
770
+ const [getterName, mutableGetterName, setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
846
771
  const rendered = this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional);
847
772
  /**
848
773
  * fix for optional type -> e.g. unique_ptrs can't be copied
@@ -901,7 +826,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
901
826
  : [
902
827
  this._stringType.getType(),
903
828
  "(",
904
- this._stringType.createStringLiteral([Strings_1.stringEscape(pattern)]),
829
+ this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(pattern)]),
905
830
  ")"
906
831
  ],
907
832
  ")"
@@ -941,25 +866,28 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
941
866
  });
942
867
  }
943
868
  emitTopLevelHeaders(t, className) {
944
- // Maps need ecoding conversions, since they have a string in the key. Other types don't.
869
+ // Forward declarations for std::map<std::wstring, Key> (need to convert UTF16 <-> UTF8)
945
870
  if (t instanceof Type_1.MapType && this._stringType !== this.NarrowString) {
946
871
  const ourQualifier = this.ourQualifier(true);
947
- this.emitLine("void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, " & x);");
948
- this.emitLine("void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x);");
872
+ this.emitLine("template <>");
873
+ this.emitBlock(["struct adl_serializer<", ourQualifier, className, ">"], true, () => {
874
+ this.emitLine("static void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, " & x);");
875
+ this.emitLine("static void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x);");
876
+ });
949
877
  }
950
878
  }
951
879
  emitClassHeaders(className) {
952
- const ourQualifier = this.ourQualifier(true);
880
+ const ourQualifier = this.ourQualifier(false);
953
881
  this.emitLine("void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, " & x);");
954
882
  this.emitLine("void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x);");
955
883
  }
956
884
  emitTopLevelFunction(t, className) {
957
- // Maps need ecoding conversions, since they have a string in the key. Other types don't.
885
+ // Function definitions for std::map<std::wstring, Key> (need to convert UTF16 <-> UTF8)
958
886
  if (t instanceof Type_1.MapType && this._stringType !== this.NarrowString) {
959
887
  const ourQualifier = this.ourQualifier(true);
960
888
  let cppType;
961
889
  let toType;
962
- this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, "& x)"], false, () => {
890
+ this.emitBlock(["inline void adl_serializer<", ourQualifier, className, ">::from_json(", this.withConst("json"), " & j, ", ourQualifier, className, "& x)"], false, () => {
963
891
  cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
964
892
  toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
965
893
  this.emitLine([
@@ -972,7 +900,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
972
900
  ";"
973
901
  ]);
974
902
  });
975
- this.emitBlock(["inline void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x)"], false, () => {
903
+ this.emitBlock(["inline void adl_serializer<", ourQualifier, className, ">::to_json(json & j, ", this.withConst([ourQualifier, className]), " & x)"], false, () => {
976
904
  cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
977
905
  toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
978
906
  this.emitLine([
@@ -984,12 +912,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
984
912
  }
985
913
  }
986
914
  emitClassFunctions(c, className) {
987
- const ourQualifier = this.ourQualifier(true);
915
+ const ourQualifier = this.ourQualifier(false);
988
916
  let cppType;
989
917
  let toType;
990
918
  this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, "& x)"], false, () => {
991
919
  this.forEachClassProperty(c, "none", (name, json, p) => {
992
- const [, , setterName] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
920
+ const [, , setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
993
921
  const t = p.type;
994
922
  let assignment;
995
923
  if (this._options.codeFormat) {
@@ -1002,7 +930,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1002
930
  this.emitLine(assignment.wrap([], [
1003
931
  ourQualifier,
1004
932
  "get_untyped(j, ",
1005
- 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)])]),
1006
934
  ")"
1007
935
  ]), ";");
1008
936
  return;
@@ -1010,7 +938,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1010
938
  if (p.isOptional || t instanceof Type_1.UnionType) {
1011
939
  const [nullOrOptional, typeSet] = (function () {
1012
940
  if (t instanceof Type_1.UnionType) {
1013
- const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(t, true);
941
+ const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(t, true);
1014
942
  return [maybeNull !== null || p.isOptional, nonNulls];
1015
943
  }
1016
944
  else {
@@ -1023,12 +951,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1023
951
  cppType = this.cppTypeInOptional(typeSet, {
1024
952
  needsForwardIndirection: false,
1025
953
  needsOptionalIndirection: false,
1026
- inJsonNamespace: true
954
+ inJsonNamespace: false
1027
955
  }, false, true);
1028
956
  toType = this.cppTypeInOptional(typeSet, {
1029
957
  needsForwardIndirection: false,
1030
958
  needsOptionalIndirection: false,
1031
- inJsonNamespace: true
959
+ inJsonNamespace: false
1032
960
  }, false, false);
1033
961
  this.emitLine(assignment.wrap([], [
1034
962
  this._stringType.wrapEncodingChange([ourQualifier], [optionalType, "<", cppType, ">"], [optionalType, "<", toType, ">"], [
@@ -1036,18 +964,18 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1036
964
  "get_optional<",
1037
965
  cppType,
1038
966
  ">(j, ",
1039
- 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)])]),
1040
968
  ")"
1041
969
  ])
1042
970
  ]), ";");
1043
971
  return;
1044
972
  }
1045
973
  }
1046
- cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, p.isOptional);
1047
- toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, p.isOptional);
974
+ cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, true, p.isOptional);
975
+ toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, false, p.isOptional);
1048
976
  this.emitLine(assignment.wrap([], this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, [
1049
977
  "j.at(",
1050
- 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)])),
1051
979
  ").get<",
1052
980
  cppType,
1053
981
  ">()"
@@ -1059,9 +987,9 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1059
987
  this.emitLine("j = json::object();");
1060
988
  this.forEachClassProperty(c, "none", (name, json, p) => {
1061
989
  const t = p.type;
1062
- cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, p.isOptional);
1063
- toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, p.isOptional);
1064
- const [getterName, ,] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
990
+ cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, false, p.isOptional);
991
+ toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, true, p.isOptional);
992
+ const [getterName, ,] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
1065
993
  let getter;
1066
994
  if (this._options.codeFormat) {
1067
995
  getter = [getterName, "()"];
@@ -1071,7 +999,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1071
999
  }
1072
1000
  let assignment = [
1073
1001
  "j[",
1074
- 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)])),
1075
1003
  "] = ",
1076
1004
  this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, ["x.", getter]),
1077
1005
  ";"
@@ -1093,13 +1021,13 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1093
1021
  }
1094
1022
  emitEnum(e, enumName) {
1095
1023
  const caseNames = [];
1096
- const enumValues = EnumValues_1.enumCaseValues(e, this.targetLanguage.name);
1024
+ const enumValues = (0, EnumValues_1.enumCaseValues)(e, this.targetLanguage.name);
1097
1025
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1098
1026
  if (caseNames.length > 0)
1099
1027
  caseNames.push(", ");
1100
1028
  caseNames.push(name);
1101
1029
  if (enumValues !== undefined) {
1102
- const [enumValue] = AccessorNames_1.getAccessorName(enumValues, jsonName);
1030
+ const [enumValue] = (0, AccessorNames_1.getAccessorName)(enumValues, jsonName);
1103
1031
  if (enumValue !== undefined) {
1104
1032
  caseNames.push(" = ", enumValue.toString());
1105
1033
  }
@@ -1112,12 +1040,21 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1112
1040
  this.emitLine("using ", unionName, " = ", this.variantType(u, false), ";");
1113
1041
  }
1114
1042
  emitUnionHeaders(u) {
1115
- const nonNulls = TypeUtils_1.removeNullFromUnion(u, true)[1];
1043
+ // Forward declarations for boost::variant<Ts...>. If none of the Ts were defined by us (e.g. if we have
1044
+ // boost::variant<int32_t, std::string>) then we need to specialize nlohmann::adl_serializer for our
1045
+ // variant type. If at least one of the Ts is our type then we could get away with regular adl definitions,
1046
+ // but it's nontrivial to detect that (consider variant<string, variant<map<string, string>, int>> which
1047
+ // does need an adl_serializer specialization) so we'll just specialize every time.
1048
+ const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
1116
1049
  const variantType = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false);
1117
- this.emitLine("void from_json(", this.withConst("json"), " & j, ", variantType, " & x);");
1118
- this.emitLine("void to_json(json & j, ", this.withConst(variantType), " & x);");
1050
+ this.emitLine("template <>");
1051
+ this.emitBlock(["struct adl_serializer<", variantType, ">"], true, () => {
1052
+ this.emitLine("static void from_json(", this.withConst("json"), " & j, ", variantType, " & x);");
1053
+ this.emitLine("static void to_json(json & j, ", this.withConst(variantType), " & x);");
1054
+ });
1119
1055
  }
1120
1056
  emitUnionFunctions(u) {
1057
+ // Function definitions for boost::variant<Ts...>.
1121
1058
  const ourQualifier = this.ourQualifier(true);
1122
1059
  const functionForKind = [
1123
1060
  ["bool", "is_boolean"],
@@ -1129,12 +1066,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1129
1066
  ["array", "is_array"],
1130
1067
  ["enum", "is_string"]
1131
1068
  ];
1132
- const nonNulls = TypeUtils_1.removeNullFromUnion(u, true)[1];
1069
+ const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
1133
1070
  const variantType = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false);
1134
- this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", variantType, " & x)"], false, () => {
1071
+ this.emitBlock(["inline void adl_serializer<", variantType, ">::from_json(", this.withConst("json"), " & j, ", variantType, " & x)"], false, () => {
1135
1072
  let onFirst = true;
1136
1073
  for (const [kind, func] of functionForKind) {
1137
- const typeForKind = collection_utils_1.iterableFind(nonNulls, t => t.kind === kind);
1074
+ const typeForKind = (0, collection_utils_1.iterableFind)(nonNulls, t => t.kind === kind);
1138
1075
  if (typeForKind === undefined)
1139
1076
  continue;
1140
1077
  this.emitLine(onFirst ? "if" : "else if", " (j.", func, "())");
@@ -1152,7 +1089,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1152
1089
  this.emitLine('else throw "Could not deserialize";');
1153
1090
  });
1154
1091
  this.ensureBlankLine();
1155
- this.emitBlock(["inline void to_json(json & j, ", this.withConst(variantType), " & x)"], false, () => {
1092
+ this.emitBlock(["inline void adl_serializer<", variantType, ">::to_json(json & j, ", this.withConst(variantType), " & x)"], false, () => {
1156
1093
  this.emitBlock(["switch (x.", this._variantIndexMethodName, "())"], false, () => {
1157
1094
  let i = 0;
1158
1095
  for (const t of nonNulls) {
@@ -1182,7 +1119,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1182
1119
  });
1183
1120
  }
1184
1121
  emitEnumHeaders(enumName) {
1185
- const ourQualifier = this.ourQualifier(true);
1122
+ const ourQualifier = this.ourQualifier(false);
1186
1123
  this.emitLine("void from_json(", this.withConst("json"), " & j, ", ourQualifier, enumName, " & x);");
1187
1124
  this.emitLine("void to_json(json & j, ", this.withConst([ourQualifier, enumName]), " & x);");
1188
1125
  }
@@ -1192,7 +1129,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1192
1129
  return e.cases.size > 15;
1193
1130
  }
1194
1131
  emitEnumFunctions(e, enumName) {
1195
- const ourQualifier = this.ourQualifier(true);
1132
+ const ourQualifier = this.ourQualifier(false);
1196
1133
  this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, enumName, " & x)"], false, () => {
1197
1134
  if (this.isLargeEnum(e)) {
1198
1135
  this.emitBlock([
@@ -1204,7 +1141,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1204
1141
  "> enumValues"
1205
1142
  ], true, () => {
1206
1143
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1207
- 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, "},");
1208
1145
  });
1209
1146
  });
1210
1147
  this.emitLine(`auto iter = enumValues.find(j.get<${this._stringType.getType()}>());`);
@@ -1216,7 +1153,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1216
1153
  let onFirst = true;
1217
1154
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1218
1155
  const maybeElse = onFirst ? "" : "else ";
1219
- 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, ";");
1220
1157
  onFirst = false;
1221
1158
  });
1222
1159
  this.emitLine('else throw "Input JSON does not conform to schema";');
@@ -1226,7 +1163,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1226
1163
  this.emitBlock(["inline void to_json(json & j, ", this.withConst([ourQualifier, enumName]), " & x)"], false, () => {
1227
1164
  this.emitBlock("switch (x)", false, () => {
1228
1165
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1229
- 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;");
1230
1167
  });
1231
1168
  this.emitLine('default: throw "This should not happen";');
1232
1169
  });
@@ -1236,10 +1173,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1236
1173
  this.emitLine("using ", name, " = ", this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, false), ";");
1237
1174
  }
1238
1175
  emitAllUnionFunctions() {
1239
- this.forEachUniqueUnion("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));
1240
1177
  }
1241
1178
  emitAllUnionHeaders() {
1242
- 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));
1243
1180
  }
1244
1181
  emitOptionalHelpers() {
1245
1182
  this.emitLine("#ifndef NLOHMANN_OPT_HELPER");
@@ -1280,11 +1217,11 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1280
1217
  this.emitUnionTypedefs(t, name);
1281
1218
  }
1282
1219
  else {
1283
- return Support_1.panic(`Cannot declare type ${t.kind}`);
1220
+ return (0, Support_1.panic)(`Cannot declare type ${t.kind}`);
1284
1221
  }
1285
1222
  }
1286
1223
  else {
1287
- return Support_1.assertNever(decl.kind);
1224
+ return (0, Support_1.assertNever)(decl.kind);
1288
1225
  }
1289
1226
  }
1290
1227
  emitGetterSetter(t, getterName, setterName, memberName) {
@@ -1318,12 +1255,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1318
1255
  const member = this.lookupMemberName(name);
1319
1256
  return [member, "(", member, ")"];
1320
1257
  });
1321
- this.emitLine(") : ", collection_utils_1.arrayIntercalate([", "], args), " {}");
1258
+ this.emitLine(") : ", (0, collection_utils_1.arrayIntercalate)([", "], args), " {}");
1322
1259
  this.emitLine(classConstraint, "() = default;");
1323
1260
  this.emitLine("virtual ~", classConstraint, "() = default;");
1324
1261
  for (const member of constraintMembers) {
1325
1262
  this.ensureBlankLine();
1326
- 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));
1327
1264
  }
1328
1265
  });
1329
1266
  this.ensureBlankLine();
@@ -1416,14 +1353,14 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1416
1353
  emitHelperFunctions() {
1417
1354
  this._stringType.emitHelperFunctions();
1418
1355
  if (this._options.codeFormat &&
1419
- collection_utils_1.iterableSome(this.typeGraph.allTypesUnordered(), t => constraintsForType(t) !== undefined)) {
1356
+ (0, collection_utils_1.iterableSome)(this.typeGraph.allTypesUnordered(), t => constraintsForType(t) !== undefined)) {
1420
1357
  this.emitConstraintClasses();
1421
1358
  this.ensureBlankLine();
1422
1359
  }
1423
1360
  this.ensureBlankLine();
1424
- var untypedMacroName = new String("NLOHMANN_UNTYPED_");
1425
- var optionalMacroName = new String("NLOHMANN_OPTIONAL_");
1426
- this._namespaceNames.forEach(function (value) {
1361
+ let untypedMacroName = "NLOHMANN_UNTYPED_";
1362
+ let optionalMacroName = "NLOHMANN_OPTIONAL_";
1363
+ this._namespaceNames.forEach(value => {
1427
1364
  // We can't use upper name, because namespaces are case sensitive
1428
1365
  untypedMacroName += value;
1429
1366
  untypedMacroName += "_";
@@ -1523,35 +1460,68 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1523
1460
  return;
1524
1461
  this.forEachTopLevel("leading", (t, name) => this.emitTopLevelTypedef(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1525
1462
  }
1526
- emitGenerators() {
1527
- let didEmit = false;
1528
- const gathered = this.gatherSource(() => this.emitNamespaces(this._namespaceNames, () => {
1529
- didEmit = this.forEachTopLevel("none", (t, name) => this.emitTopLevelTypedef(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1530
- }));
1531
- if (didEmit) {
1532
- this.emitGatheredSource(gathered);
1463
+ gatherUserNamespaceForwardDecls() {
1464
+ return this.gatherSource(() => {
1465
+ this.forEachObject("leading-and-interposing", (_, className) => this.emitClassHeaders(className));
1466
+ this.forEachEnum("leading-and-interposing", (_, enumName) => this.emitEnumHeaders(enumName));
1467
+ });
1468
+ }
1469
+ gatherNlohmannNamespaceForwardDecls() {
1470
+ return this.gatherSource(() => {
1471
+ this.forEachTopLevel("leading-and-interposing", (t, className) => this.emitTopLevelHeaders(t, className));
1533
1472
  this.ensureBlankLine();
1473
+ this.emitAllUnionHeaders();
1474
+ });
1475
+ }
1476
+ emitUserNamespaceImpls() {
1477
+ this.forEachObject("leading-and-interposing", (c, className) => this.emitClassFunctions(c, className));
1478
+ this.forEachEnum("leading-and-interposing", (e, enumName) => this.emitEnumFunctions(e, enumName));
1479
+ }
1480
+ emitNlohmannNamespaceImpls() {
1481
+ this.forEachTopLevel("leading-and-interposing", (t, name) => this.emitTopLevelFunction(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1482
+ this.ensureBlankLine();
1483
+ this.emitAllUnionFunctions();
1484
+ }
1485
+ emitGenerators() {
1486
+ if (this._options.justTypes) {
1487
+ let didEmit = false;
1488
+ const gathered = this.gatherSource(() => this.emitNamespaces(this._namespaceNames, () => {
1489
+ didEmit = this.forEachTopLevel("none", (t, name) => this.emitTopLevelTypedef(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1490
+ }));
1491
+ if (didEmit) {
1492
+ this.emitGatheredSource(gathered);
1493
+ this.ensureBlankLine();
1494
+ }
1534
1495
  }
1535
- if (!this._options.justTypes) {
1536
- let namespaces = ["nlohmann"];
1537
- if (this._options.msbuildPermissive) {
1538
- namespaces = ["nlohmann", "detail"];
1496
+ else {
1497
+ let userNamespaceForwardDecls = this.gatherUserNamespaceForwardDecls();
1498
+ let nlohmannNamespaceForwardDecls = this.gatherNlohmannNamespaceForwardDecls();
1499
+ if (userNamespaceForwardDecls.length == 0 && nlohmannNamespaceForwardDecls.length > 0) {
1500
+ this.emitNamespaces(["nlohmann"], () => {
1501
+ this.emitGatheredSource(nlohmannNamespaceForwardDecls);
1502
+ this.emitNlohmannNamespaceImpls();
1503
+ });
1504
+ }
1505
+ else if (userNamespaceForwardDecls.length > 0 && nlohmannNamespaceForwardDecls.length == 0) {
1506
+ this.emitNamespaces(this._namespaceNames, () => {
1507
+ this.emitGatheredSource(userNamespaceForwardDecls);
1508
+ this.emitUserNamespaceImpls();
1509
+ });
1510
+ }
1511
+ else if (userNamespaceForwardDecls.length > 0 && nlohmannNamespaceForwardDecls.length > 0) {
1512
+ this.emitNamespaces(this._namespaceNames, () => {
1513
+ this.emitGatheredSource(userNamespaceForwardDecls);
1514
+ });
1515
+ this.emitNamespaces(["nlohmann"], () => {
1516
+ this.emitGatheredSource(nlohmannNamespaceForwardDecls);
1517
+ });
1518
+ this.emitNamespaces(this._namespaceNames, () => {
1519
+ this.emitUserNamespaceImpls();
1520
+ });
1521
+ this.emitNamespaces(["nlohmann"], () => {
1522
+ this.emitNlohmannNamespaceImpls();
1523
+ });
1539
1524
  }
1540
- this.emitNamespaces(namespaces, () => {
1541
- this.forEachObject("leading-and-interposing", (_, className) => this.emitClassHeaders(className));
1542
- this.forEachTopLevel("leading-and-interposing", (t, className) => this.emitTopLevelHeaders(t, className));
1543
- this.forEachEnum("leading-and-interposing", (_, enumName) => this.emitEnumHeaders(enumName));
1544
- if (this.haveUnions) {
1545
- this.emitAllUnionHeaders();
1546
- }
1547
- this.ensureBlankLine();
1548
- this.forEachObject("leading-and-interposing", (c, className) => this.emitClassFunctions(c, className));
1549
- this.forEachEnum("leading-and-interposing", (e, enumName) => this.emitEnumFunctions(e, enumName));
1550
- if (this.haveUnions) {
1551
- this.emitAllUnionFunctions();
1552
- }
1553
- this.forEachTopLevel("leading-and-interposing", (t, name) => this.emitTopLevelFunction(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1554
- });
1555
1525
  }
1556
1526
  }
1557
1527
  emitSingleSourceStructure(proposedFilename) {
@@ -1596,7 +1566,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1596
1566
  else if (t.type instanceof Type_1.UnionType) {
1597
1567
  propRecord.typeKind = "union";
1598
1568
  /** Recurse into the union */
1599
- const [maybeNull] = TypeUtils_1.removeNullFromUnion(t.type, true);
1569
+ const [maybeNull] = (0, TypeUtils_1.removeNullFromUnion)(t.type, true);
1600
1570
  if (maybeNull !== undefined) {
1601
1571
  /** Houston this is a variant, include it */
1602
1572
  propRecord.kind = IncludeKind.Include;
@@ -1680,7 +1650,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1680
1650
  this.emitLine("enum class ", name, " : ", this._enumType, ";");
1681
1651
  }
1682
1652
  else {
1683
- Support_1.panic(`Invalid type "${rec.typeKind}" to forward declare`);
1653
+ (0, Support_1.panic)(`Invalid type "${rec.typeKind}" to forward declare`);
1684
1654
  }
1685
1655
  });
1686
1656
  });
@@ -1751,8 +1721,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1751
1721
  /** Gather all the unique/custom types used by the schema */
1752
1722
  this._allTypeNames.clear();
1753
1723
  this.forEachDeclaration("none", decl => {
1754
- const definedTypes = TypeUtils_1.directlyReachableTypes(decl.type, t => {
1755
- 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)) {
1756
1726
  return new Set([
1757
1727
  this.sourcelikeToString(this.cppType(t, {
1758
1728
  needsForwardIndirection: false,
@@ -1763,7 +1733,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1763
1733
  }
1764
1734
  return null;
1765
1735
  });
1766
- this._allTypeNames = collection_utils_1.setUnion(definedTypes, this._allTypeNames);
1736
+ this._allTypeNames = (0, collection_utils_1.setUnion)(definedTypes, this._allTypeNames);
1767
1737
  });
1768
1738
  if (this._options.typeSourceStyle) {
1769
1739
  this.emitSingleSourceStructure(proposedFilename);
@@ -1777,5 +1747,101 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1777
1747
  let newType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
1778
1748
  return originalType !== newType;
1779
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);
1780
1846
  }
1781
1847
  exports.CPlusPlusRenderer = CPlusPlusRenderer;