quicktype 17.0.4 → 17.0.6

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 +38 -26
  2. package/dist/cli/GraphQLIntrospection.js +41 -33
  3. package/dist/cli/TypeSource.d.ts +1 -1
  4. package/dist/cli/URLGrammar.js +3 -4
  5. package/dist/cli/index.js +364 -363
  6. package/dist/quicktype-core/Annotation.js +0 -2
  7. package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
  8. package/dist/quicktype-core/ConvenienceRenderer.js +81 -104
  9. package/dist/quicktype-core/DateTime.js +0 -1
  10. package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
  11. package/dist/quicktype-core/DeclarationIR.js +10 -13
  12. package/dist/quicktype-core/EncodedMarkovChain.js +0 -1
  13. package/dist/quicktype-core/GatherNames.js +25 -47
  14. package/dist/quicktype-core/Graph.d.ts +2 -2
  15. package/dist/quicktype-core/Graph.js +19 -23
  16. package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
  17. package/dist/quicktype-core/GraphRewriting.js +54 -65
  18. package/dist/quicktype-core/MakeTransformations.js +22 -23
  19. package/dist/quicktype-core/MarkovChain.d.ts +3 -3
  20. package/dist/quicktype-core/MarkovChain.js +8 -9
  21. package/dist/quicktype-core/Messages.d.ts +3 -3
  22. package/dist/quicktype-core/Messages.js +3 -8
  23. package/dist/quicktype-core/Naming.d.ts +11 -11
  24. package/dist/quicktype-core/Naming.js +61 -76
  25. package/dist/quicktype-core/Renderer.d.ts +6 -6
  26. package/dist/quicktype-core/Renderer.js +17 -34
  27. package/dist/quicktype-core/RendererOptions.d.ts +5 -5
  28. package/dist/quicktype-core/RendererOptions.js +3 -6
  29. package/dist/quicktype-core/Run.d.ts +9 -9
  30. package/dist/quicktype-core/Run.js +67 -72
  31. package/dist/quicktype-core/Source.d.ts +3 -3
  32. package/dist/quicktype-core/Source.js +18 -19
  33. package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
  34. package/dist/quicktype-core/TargetLanguage.js +2 -6
  35. package/dist/quicktype-core/Transformers.d.ts +25 -25
  36. package/dist/quicktype-core/Transformers.js +66 -94
  37. package/dist/quicktype-core/Type.d.ts +43 -41
  38. package/dist/quicktype-core/Type.js +71 -96
  39. package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
  40. package/dist/quicktype-core/TypeBuilder.js +47 -53
  41. package/dist/quicktype-core/TypeGraph.d.ts +4 -4
  42. package/dist/quicktype-core/TypeGraph.js +40 -49
  43. package/dist/quicktype-core/TypeUtils.d.ts +2 -2
  44. package/dist/quicktype-core/TypeUtils.js +22 -23
  45. package/dist/quicktype-core/UnifyClasses.js +12 -16
  46. package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
  47. package/dist/quicktype-core/UnionBuilder.js +30 -33
  48. package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
  49. package/dist/quicktype-core/attributes/AccessorNames.js +17 -18
  50. package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
  51. package/dist/quicktype-core/attributes/Constraints.js +4 -8
  52. package/dist/quicktype-core/attributes/Description.js +5 -6
  53. package/dist/quicktype-core/attributes/EnumValues.js +3 -4
  54. package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
  55. package/dist/quicktype-core/attributes/StringTypes.js +21 -24
  56. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
  57. package/dist/quicktype-core/attributes/TypeAttributes.js +10 -12
  58. package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
  59. package/dist/quicktype-core/attributes/TypeNames.js +21 -49
  60. package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
  61. package/dist/quicktype-core/attributes/URIAttributes.js +6 -10
  62. package/dist/quicktype-core/index.js +125 -128
  63. package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
  64. package/dist/quicktype-core/input/CompressedJSON.js +54 -49
  65. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +13 -5
  66. package/dist/quicktype-core/input/Inference.d.ts +2 -2
  67. package/dist/quicktype-core/input/Inference.js +17 -25
  68. package/dist/quicktype-core/input/Inputs.d.ts +2 -2
  69. package/dist/quicktype-core/input/Inputs.js +54 -38
  70. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
  71. package/dist/quicktype-core/input/JSONSchemaInput.js +523 -503
  72. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
  73. package/dist/quicktype-core/input/JSONSchemaStore.js +35 -24
  74. package/dist/quicktype-core/input/PostmanCollection.js +1 -2
  75. package/dist/quicktype-core/input/io/NodeIO.js +44 -55
  76. package/dist/quicktype-core/input/io/get-stream/index.js +2 -6
  77. package/dist/quicktype-core/language/All.js +2 -3
  78. package/dist/quicktype-core/language/CPlusPlus.d.ts +12 -9
  79. package/dist/quicktype-core/language/CPlusPlus.js +249 -251
  80. package/dist/quicktype-core/language/CSharp.d.ts +7 -7
  81. package/dist/quicktype-core/language/CSharp.js +72 -82
  82. package/dist/quicktype-core/language/Crystal.d.ts +2 -2
  83. package/dist/quicktype-core/language/Crystal.js +17 -18
  84. package/dist/quicktype-core/language/Dart.d.ts +4 -4
  85. package/dist/quicktype-core/language/Dart.js +34 -36
  86. package/dist/quicktype-core/language/Elm.d.ts +6 -6
  87. package/dist/quicktype-core/language/Elm.js +45 -47
  88. package/dist/quicktype-core/language/Golang.d.ts +4 -4
  89. package/dist/quicktype-core/language/Golang.js +20 -23
  90. package/dist/quicktype-core/language/Haskell.d.ts +5 -5
  91. package/dist/quicktype-core/language/Haskell.js +23 -25
  92. package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
  93. package/dist/quicktype-core/language/JSONSchema.js +16 -17
  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 +17 -19
  98. package/dist/quicktype-core/language/JavaScriptPropTypes.js +13 -15
  99. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +11 -12
  100. package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
  101. package/dist/quicktype-core/language/Kotlin.js +37 -39
  102. package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
  103. package/dist/quicktype-core/language/Objective-C.js +41 -45
  104. package/dist/quicktype-core/language/Php.d.ts +2 -2
  105. package/dist/quicktype-core/language/Php.js +41 -66
  106. package/dist/quicktype-core/language/Pike.d.ts +1 -1
  107. package/dist/quicktype-core/language/Pike.js +17 -18
  108. package/dist/quicktype-core/language/Python.d.ts +8 -8
  109. package/dist/quicktype-core/language/Python.js +64 -63
  110. package/dist/quicktype-core/language/Rust.d.ts +2 -2
  111. package/dist/quicktype-core/language/Rust.js +19 -21
  112. package/dist/quicktype-core/language/Swift.d.ts +7 -7
  113. package/dist/quicktype-core/language/Swift.js +804 -807
  114. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
  115. package/dist/quicktype-core/language/TypeScriptFlow.js +26 -28
  116. package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
  117. package/dist/quicktype-core/language/ruby/index.js +24 -49
  118. package/dist/quicktype-core/language/ruby/keywords.js +0 -1
  119. package/dist/quicktype-core/rewrites/CombineClasses.js +8 -9
  120. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
  121. package/dist/quicktype-core/rewrites/ExpandStrings.js +17 -18
  122. package/dist/quicktype-core/rewrites/FlattenStrings.js +6 -7
  123. package/dist/quicktype-core/rewrites/FlattenUnions.js +8 -9
  124. package/dist/quicktype-core/rewrites/InferMaps.js +10 -11
  125. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +7 -8
  126. package/dist/quicktype-core/rewrites/ResolveIntersections.js +67 -68
  127. package/dist/quicktype-core/support/Acronyms.js +1 -3
  128. package/dist/quicktype-core/support/Chance.js +0 -10
  129. package/dist/quicktype-core/support/Converters.js +0 -1
  130. package/dist/quicktype-core/support/Strings.d.ts +4 -4
  131. package/dist/quicktype-core/support/Strings.js +16 -17
  132. package/dist/quicktype-core/support/Support.d.ts +1 -1
  133. package/dist/quicktype-core/support/Support.js +6 -30
  134. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
  135. package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -1
  136. package/dist/quicktype-graphql-input/index.d.ts +1 -1
  137. package/dist/quicktype-graphql-input/index.js +212 -229
  138. package/dist/quicktype-typescript-input/index.js +4 -28
  139. package/package.json +19 -25
@@ -1,6 +1,5 @@
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;
4
3
  const collection_utils_1 = require("collection-utils");
5
4
  const TargetLanguage_1 = require("../TargetLanguage");
6
5
  const Type_1 = require("../Type");
@@ -39,10 +38,6 @@ exports.cPlusPlusOptions = {
39
38
  ["use-string", false],
40
39
  ["use-wstring", true]
41
40
  ], "use-string"),
42
- 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", [
43
- ["not-permissive", false],
44
- ["use-permissive", true]
45
- ], "not-permissive", "secondary"),
46
41
  westConst: new RendererOptions_1.EnumOption("const-style", "Put const to the left/west (const T) or right/east (T const)", [
47
42
  ["west-const", true],
48
43
  ["east-const", false]
@@ -87,7 +82,6 @@ class CPlusPlusTargetLanguage extends TargetLanguage_1.TargetLanguage {
87
82
  exports.cPlusPlusOptions.namespace,
88
83
  exports.cPlusPlusOptions.codeFormat,
89
84
  exports.cPlusPlusOptions.wstring,
90
- exports.cPlusPlusOptions.msbuildPermissive,
91
85
  exports.cPlusPlusOptions.westConst,
92
86
  exports.cPlusPlusOptions.typeSourceStyle,
93
87
  exports.cPlusPlusOptions.includeLocation,
@@ -106,19 +100,19 @@ class CPlusPlusTargetLanguage extends TargetLanguage_1.TargetLanguage {
106
100
  return true;
107
101
  }
108
102
  makeRenderer(renderContext, untypedOptionValues) {
109
- return new CPlusPlusRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.cPlusPlusOptions, untypedOptionValues));
103
+ return new CPlusPlusRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.cPlusPlusOptions, untypedOptionValues));
110
104
  }
111
105
  }
112
106
  exports.CPlusPlusTargetLanguage = CPlusPlusTargetLanguage;
113
107
  function constraintsForType(t) {
114
- const minMax = (0, Constraints_1.minMaxValueForType)(t);
115
- const minMaxLength = (0, Constraints_1.minMaxLengthForType)(t);
116
- const pattern = (0, Constraints_1.patternForType)(t);
108
+ const minMax = Constraints_1.minMaxValueForType(t);
109
+ const minMaxLength = Constraints_1.minMaxLengthForType(t);
110
+ const pattern = Constraints_1.patternForType(t);
117
111
  if (minMax === undefined && minMaxLength === undefined && pattern === undefined)
118
112
  return undefined;
119
113
  return { minMax, minMaxLength, pattern };
120
114
  }
121
- const legalizeName = (0, Strings_1.legalizeCharacters)(cp => (0, Strings_1.isAscii)(cp) && (0, Strings_1.isLetterOrUnderscoreOrDigit)(cp));
115
+ const legalizeName = Strings_1.legalizeCharacters(cp => Strings_1.isAscii(cp) && Strings_1.isLetterOrUnderscoreOrDigit(cp));
122
116
  const keywords = [
123
117
  "alignas",
124
118
  "alignof",
@@ -280,8 +274,6 @@ function addQualifier(qualifier, qualified) {
280
274
  return [qualifier, qualified];
281
275
  }
282
276
  class WrappingCode {
283
- _start;
284
- _end;
285
277
  constructor(start, end) {
286
278
  this._start = start;
287
279
  this._end = end;
@@ -291,14 +283,6 @@ class WrappingCode {
291
283
  }
292
284
  }
293
285
  class BaseString {
294
- _stringType;
295
- _constStringType;
296
- _smatch;
297
- _regex;
298
- _stringLiteralPrefix;
299
- _toString;
300
- _encodingClass;
301
- _encodingFunction;
302
286
  constructor(stringType, constStringType, smatch, regex, stringLiteralPrefix, toString, encodingClass, encodingFunction) {
303
287
  (this._stringType = stringType),
304
288
  (this._constStringType = constStringType),
@@ -329,39 +313,112 @@ class BaseString {
329
313
  }
330
314
  }
331
315
  class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
332
- _options;
333
- /**
334
- * For forward declaration practically
335
- */
336
- _enumType;
337
- _generatedFiles;
338
- _currentFilename;
339
- _allTypeNames;
340
- _gettersAndSettersForPropertyName = new Map();
341
- _namespaceNames;
342
- _memberNameStyle;
343
- _namedTypeNameStyle;
344
- _generatedGlobalNames;
345
- _generatedMemberNames;
346
- _forbiddenGlobalNames;
347
- _memberNamingFunction;
348
- _stringType;
349
- _optionalType;
350
- _nulloptType;
351
- _variantType;
352
- _variantIndexMethodName;
353
- typeNamingStyle;
354
- enumeratorNamingStyle;
355
316
  constructor(targetLanguage, renderContext, _options) {
356
317
  super(targetLanguage, renderContext);
357
318
  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);
358
415
  this._enumType = _options.enumType;
359
416
  this._namespaceNames = _options.namespace.split("::");
360
417
  this.typeNamingStyle = _options.typeNamingStyle;
361
- this._namedTypeNameStyle = (0, Strings_1.makeNameStyle)(this.typeNamingStyle, legalizeName);
418
+ this._namedTypeNameStyle = Strings_1.makeNameStyle(this.typeNamingStyle, legalizeName);
362
419
  this.enumeratorNamingStyle = _options.enumeratorNamingStyle;
363
- this._memberNameStyle = (0, Strings_1.makeNameStyle)(_options.memberNamingStyle, legalizeName);
364
- this._memberNamingFunction = (0, Naming_1.funPrefixNamer)("members", this._memberNameStyle);
420
+ this._memberNameStyle = Strings_1.makeNameStyle(_options.memberNamingStyle, legalizeName);
421
+ this._memberNamingFunction = Naming_1.funPrefixNamer("members", this._memberNameStyle);
365
422
  this._gettersAndSettersForPropertyName = new Map();
366
423
  this._allTypeNames = new Set();
367
424
  this._generatedFiles = new Set();
@@ -424,10 +481,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
424
481
  ];
425
482
  }
426
483
  lookupGlobalName(type) {
427
- return (0, Support_1.defined)(this._generatedGlobalNames.get(type));
484
+ return Support_1.defined(this._generatedGlobalNames.get(type));
428
485
  }
429
486
  lookupMemberName(type) {
430
- return (0, Support_1.defined)(this._generatedMemberNames.get(type));
487
+ return Support_1.defined(this._generatedMemberNames.get(type));
431
488
  }
432
489
  addGlobalName(type) {
433
490
  const genName = this._namedTypeNameStyle(GlobalNames[type]);
@@ -438,10 +495,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
438
495
  this._generatedMemberNames.set(type, this._memberNameStyle(MemberNames[type]));
439
496
  }
440
497
  setupGlobalNames() {
441
- for (const v of (0, Support_1.numberEnumValues)(GlobalNames)) {
498
+ for (const v of Support_1.numberEnumValues(GlobalNames)) {
442
499
  this.addGlobalName(v);
443
500
  }
444
- for (const v of (0, Support_1.numberEnumValues)(MemberNames)) {
501
+ for (const v of Support_1.numberEnumValues(MemberNames)) {
445
502
  this.addMemberName(v);
446
503
  }
447
504
  }
@@ -455,7 +512,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
455
512
  return { names: [], includeGlobalForbidden: true };
456
513
  }
457
514
  makeNamedTypeNamer() {
458
- return (0, Naming_1.funPrefixNamer)("types", this._namedTypeNameStyle);
515
+ return Naming_1.funPrefixNamer("types", this._namedTypeNameStyle);
459
516
  }
460
517
  namerForObjectProperty() {
461
518
  return this._memberNamingFunction;
@@ -464,7 +521,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
464
521
  return null;
465
522
  }
466
523
  makeEnumCaseNamer() {
467
- return (0, Naming_1.funPrefixNamer)("enumerators", (0, Strings_1.makeNameStyle)(this.enumeratorNamingStyle, legalizeName));
524
+ return Naming_1.funPrefixNamer("enumerators", Strings_1.makeNameStyle(this.enumeratorNamingStyle, legalizeName));
468
525
  }
469
526
  makeNamesForPropertyGetterAndSetter(_c, _className, _p, _jsonName, name) {
470
527
  const getterName = new Naming_1.DependencyName(this._memberNamingFunction, name.order, lookup => `get_${lookup(name)}`);
@@ -489,7 +546,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
489
546
  this.emitLine("#include ", global ? "<" : '"', name, global ? ">" : '"');
490
547
  }
491
548
  startFile(basename, includeHelper = true) {
492
- (0, Support_2.assert)(this._currentFilename === undefined, "Previous file wasn't finished");
549
+ Support_2.assert(this._currentFilename === undefined, "Previous file wasn't finished");
493
550
  if (basename !== undefined) {
494
551
  this._currentFilename = this.sourcelikeToString(basename);
495
552
  }
@@ -509,18 +566,18 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
509
566
  ]);
510
567
  if (this._options.typeSourceStyle) {
511
568
  this.forEachTopLevel("none", (_, topLevelName) => {
512
- this.emitLine("// ", this.ourQualifier(false), topLevelName, " data = nlohmann::json::parse(jsonString);");
569
+ this.emitLine("// ", topLevelName, " data = nlohmann::json::parse(jsonString);");
513
570
  });
514
571
  }
515
572
  else {
516
- this.emitLine("// ", this.ourQualifier(false), basename, " data = nlohmann::json::parse(jsonString);");
573
+ this.emitLine("// ", basename, " data = nlohmann::json::parse(jsonString);");
517
574
  }
518
575
  if (this._options.wstring) {
519
576
  this.emitLine("//");
520
577
  this.emitLine("// You can get std::wstring data back out using");
521
578
  this.emitLine("//");
522
579
  this.forEachTopLevel("none", (_, topLevelName) => {
523
- this.emitLine("// std::wcout << ", this.ourQualifier(false), "wdump((nlohmann::json) ", topLevelName, ");");
580
+ this.emitLine("// std::wcout << ", "wdump((nlohmann::json) ", topLevelName, ");");
524
581
  });
525
582
  }
526
583
  }
@@ -549,7 +606,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
549
606
  this.ensureBlankLine();
550
607
  }
551
608
  finishFile() {
552
- super.finishFile((0, Support_1.defined)(this._currentFilename));
609
+ super.finishFile(Support_1.defined(this._currentFilename));
553
610
  this._currentFilename = undefined;
554
611
  }
555
612
  get needsTypeDeclarationBeforeUse() {
@@ -580,7 +637,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
580
637
  }
581
638
  }
582
639
  emitNamespaces(namespaceNames, f) {
583
- const namesArray = (0, collection_utils_1.toReadonlyArray)(namespaceNames);
640
+ const namesArray = collection_utils_1.toReadonlyArray(namespaceNames);
584
641
  const first = namesArray[0];
585
642
  if (first === undefined) {
586
643
  f();
@@ -591,7 +648,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
591
648
  }
592
649
  cppTypeInOptional(nonNulls, ctx, withIssues, forceNarrowString) {
593
650
  if (nonNulls.size === 1) {
594
- return this.cppType((0, Support_1.defined)((0, collection_utils_1.iterableFirst)(nonNulls)), ctx, withIssues, forceNarrowString, false);
651
+ return this.cppType(Support_1.defined(collection_utils_1.iterableFirst(nonNulls)), ctx, withIssues, forceNarrowString, false);
595
652
  }
596
653
  const typeList = [];
597
654
  for (const t of nonNulls) {
@@ -607,8 +664,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
607
664
  return [this._variantType, "<", typeList, ">"];
608
665
  }
609
666
  variantType(u, inJsonNamespace) {
610
- const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u, true);
611
- (0, Support_2.assert)(nonNulls.size >= 2, "Variant not needed for less than two types.");
667
+ const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(u, true);
668
+ Support_2.assert(nonNulls.size >= 2, "Variant not needed for less than two types.");
612
669
  const indirection = maybeNull !== null;
613
670
  const variant = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: !indirection, needsOptionalIndirection: !indirection, inJsonNamespace }, true, false);
614
671
  if (!indirection) {
@@ -617,12 +674,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
617
674
  return [optionalType, "<", variant, ">"];
618
675
  }
619
676
  ourQualifier(inJsonNamespace) {
620
- return inJsonNamespace || this._options.msbuildPermissive
621
- ? [(0, collection_utils_1.arrayIntercalate)("::", this._namespaceNames), "::"]
622
- : [];
677
+ return inJsonNamespace ? [collection_utils_1.arrayIntercalate("::", this._namespaceNames), "::"] : [];
623
678
  }
624
679
  jsonQualifier(inJsonNamespace) {
625
- return inJsonNamespace || this._options.msbuildPermissive ? [] : "nlohmann::";
680
+ return inJsonNamespace ? [] : "nlohmann::";
626
681
  }
627
682
  variantIndirection(needIndirection, typeSrc) {
628
683
  if (!needIndirection)
@@ -640,18 +695,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
640
695
  }
641
696
  }
642
697
  }
643
- let typeSource = (0, TypeUtils_1.matchType)(t, _anyType => {
698
+ let typeSource = TypeUtils_1.matchType(t, _anyType => {
644
699
  isOptional = false;
645
- return (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, [
646
- this.jsonQualifier(inJsonNamespace),
647
- "json"
648
- ]);
700
+ return Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
649
701
  }, _nullType => {
650
702
  isOptional = false;
651
- return (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, [
652
- this.jsonQualifier(inJsonNamespace),
653
- "json"
654
- ]);
703
+ return Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
655
704
  }, _boolType => "bool", _integerType => "int64_t", _doubleType => "double", _stringType => {
656
705
  if (forceNarrowString) {
657
706
  return "std::string";
@@ -676,7 +725,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
676
725
  ">"
677
726
  ];
678
727
  }, enumType => [this.ourQualifier(inJsonNamespace), this.nameForNamedType(enumType)], unionType => {
679
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
728
+ const nullable = TypeUtils_1.nullableFromUnion(unionType);
680
729
  if (nullable === null)
681
730
  return [this.ourQualifier(inJsonNamespace), this.nameForNamedType(unionType)];
682
731
  isOptional = true;
@@ -743,7 +792,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
743
792
  });
744
793
  /** intentional "fall-through", add all subtypes as well - but forced include */
745
794
  }
746
- const [hasNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(t);
795
+ const [hasNull, nonNulls] = TypeUtils_1.removeNullFromUnion(t);
747
796
  isVariant = hasNull !== null;
748
797
  /** we need to collect all the subtypes of the union */
749
798
  for (const tt of nonNulls) {
@@ -780,7 +829,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
780
829
  this.emitMember(this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional), name);
781
830
  }
782
831
  else {
783
- const [getterName, mutableGetterName, setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
832
+ const [getterName, mutableGetterName, setterName] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
784
833
  const rendered = this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional);
785
834
  /**
786
835
  * fix for optional type -> e.g. unique_ptrs can't be copied
@@ -839,7 +888,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
839
888
  : [
840
889
  this._stringType.getType(),
841
890
  "(",
842
- this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(pattern)]),
891
+ this._stringType.createStringLiteral([Strings_1.stringEscape(pattern)]),
843
892
  ")"
844
893
  ],
845
894
  ")"
@@ -879,25 +928,28 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
879
928
  });
880
929
  }
881
930
  emitTopLevelHeaders(t, className) {
882
- // Maps need ecoding conversions, since they have a string in the key. Other types don't.
931
+ // Forward declarations for std::map<std::wstring, Key> (need to convert UTF16 <-> UTF8)
883
932
  if (t instanceof Type_1.MapType && this._stringType !== this.NarrowString) {
884
933
  const ourQualifier = this.ourQualifier(true);
885
- this.emitLine("void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, " & x);");
886
- this.emitLine("void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x);");
934
+ this.emitLine("template <>");
935
+ this.emitBlock(["struct adl_serializer<", ourQualifier, className, ">"], true, () => {
936
+ this.emitLine("static void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, " & x);");
937
+ this.emitLine("static void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x);");
938
+ });
887
939
  }
888
940
  }
889
941
  emitClassHeaders(className) {
890
- const ourQualifier = this.ourQualifier(true);
942
+ const ourQualifier = this.ourQualifier(false);
891
943
  this.emitLine("void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, " & x);");
892
944
  this.emitLine("void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x);");
893
945
  }
894
946
  emitTopLevelFunction(t, className) {
895
- // Maps need ecoding conversions, since they have a string in the key. Other types don't.
947
+ // Function definitions for std::map<std::wstring, Key> (need to convert UTF16 <-> UTF8)
896
948
  if (t instanceof Type_1.MapType && this._stringType !== this.NarrowString) {
897
949
  const ourQualifier = this.ourQualifier(true);
898
950
  let cppType;
899
951
  let toType;
900
- this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, "& x)"], false, () => {
952
+ this.emitBlock(["inline void adl_serializer<", ourQualifier, className, ">::from_json(", this.withConst("json"), " & j, ", ourQualifier, className, "& x)"], false, () => {
901
953
  cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
902
954
  toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
903
955
  this.emitLine([
@@ -910,7 +962,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
910
962
  ";"
911
963
  ]);
912
964
  });
913
- this.emitBlock(["inline void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x)"], false, () => {
965
+ this.emitBlock(["inline void adl_serializer<", ourQualifier, className, ">::to_json(json & j, ", this.withConst([ourQualifier, className]), " & x)"], false, () => {
914
966
  cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
915
967
  toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
916
968
  this.emitLine([
@@ -922,12 +974,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
922
974
  }
923
975
  }
924
976
  emitClassFunctions(c, className) {
925
- const ourQualifier = this.ourQualifier(true);
977
+ const ourQualifier = this.ourQualifier(false);
926
978
  let cppType;
927
979
  let toType;
928
980
  this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, "& x)"], false, () => {
929
981
  this.forEachClassProperty(c, "none", (name, json, p) => {
930
- const [, , setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
982
+ const [, , setterName] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
931
983
  const t = p.type;
932
984
  let assignment;
933
985
  if (this._options.codeFormat) {
@@ -940,7 +992,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
940
992
  this.emitLine(assignment.wrap([], [
941
993
  ourQualifier,
942
994
  "get_untyped(j, ",
943
- this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])]),
995
+ this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(json)])]),
944
996
  ")"
945
997
  ]), ";");
946
998
  return;
@@ -948,7 +1000,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
948
1000
  if (p.isOptional || t instanceof Type_1.UnionType) {
949
1001
  const [nullOrOptional, typeSet] = (function () {
950
1002
  if (t instanceof Type_1.UnionType) {
951
- const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(t, true);
1003
+ const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(t, true);
952
1004
  return [maybeNull !== null || p.isOptional, nonNulls];
953
1005
  }
954
1006
  else {
@@ -961,12 +1013,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
961
1013
  cppType = this.cppTypeInOptional(typeSet, {
962
1014
  needsForwardIndirection: false,
963
1015
  needsOptionalIndirection: false,
964
- inJsonNamespace: true
1016
+ inJsonNamespace: false
965
1017
  }, false, true);
966
1018
  toType = this.cppTypeInOptional(typeSet, {
967
1019
  needsForwardIndirection: false,
968
1020
  needsOptionalIndirection: false,
969
- inJsonNamespace: true
1021
+ inJsonNamespace: false
970
1022
  }, false, false);
971
1023
  this.emitLine(assignment.wrap([], [
972
1024
  this._stringType.wrapEncodingChange([ourQualifier], [optionalType, "<", cppType, ">"], [optionalType, "<", toType, ">"], [
@@ -974,18 +1026,18 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
974
1026
  "get_optional<",
975
1027
  cppType,
976
1028
  ">(j, ",
977
- this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])]),
1029
+ this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(json)])]),
978
1030
  ")"
979
1031
  ])
980
1032
  ]), ";");
981
1033
  return;
982
1034
  }
983
1035
  }
984
- cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, p.isOptional);
985
- toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, p.isOptional);
1036
+ cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, true, p.isOptional);
1037
+ toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, false, p.isOptional);
986
1038
  this.emitLine(assignment.wrap([], this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, [
987
1039
  "j.at(",
988
- this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])),
1040
+ this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([Strings_1.stringEscape(json)])),
989
1041
  ").get<",
990
1042
  cppType,
991
1043
  ">()"
@@ -997,9 +1049,9 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
997
1049
  this.emitLine("j = json::object();");
998
1050
  this.forEachClassProperty(c, "none", (name, json, p) => {
999
1051
  const t = p.type;
1000
- cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, p.isOptional);
1001
- toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, p.isOptional);
1002
- const [getterName, ,] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
1052
+ cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, false, p.isOptional);
1053
+ toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, true, p.isOptional);
1054
+ const [getterName, ,] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
1003
1055
  let getter;
1004
1056
  if (this._options.codeFormat) {
1005
1057
  getter = [getterName, "()"];
@@ -1009,7 +1061,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1009
1061
  }
1010
1062
  let assignment = [
1011
1063
  "j[",
1012
- this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])),
1064
+ this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([Strings_1.stringEscape(json)])),
1013
1065
  "] = ",
1014
1066
  this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, ["x.", getter]),
1015
1067
  ";"
@@ -1031,13 +1083,13 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1031
1083
  }
1032
1084
  emitEnum(e, enumName) {
1033
1085
  const caseNames = [];
1034
- const enumValues = (0, EnumValues_1.enumCaseValues)(e, this.targetLanguage.name);
1086
+ const enumValues = EnumValues_1.enumCaseValues(e, this.targetLanguage.name);
1035
1087
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1036
1088
  if (caseNames.length > 0)
1037
1089
  caseNames.push(", ");
1038
1090
  caseNames.push(name);
1039
1091
  if (enumValues !== undefined) {
1040
- const [enumValue] = (0, AccessorNames_1.getAccessorName)(enumValues, jsonName);
1092
+ const [enumValue] = AccessorNames_1.getAccessorName(enumValues, jsonName);
1041
1093
  if (enumValue !== undefined) {
1042
1094
  caseNames.push(" = ", enumValue.toString());
1043
1095
  }
@@ -1050,12 +1102,21 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1050
1102
  this.emitLine("using ", unionName, " = ", this.variantType(u, false), ";");
1051
1103
  }
1052
1104
  emitUnionHeaders(u) {
1053
- const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
1105
+ // Forward declarations for boost::variant<Ts...>. If none of the Ts were defined by us (e.g. if we have
1106
+ // boost::variant<int32_t, std::string>) then we need to specialize nlohmann::adl_serializer for our
1107
+ // variant type. If at least one of the Ts is our type then we could get away with regular adl definitions,
1108
+ // but it's nontrivial to detect that (consider variant<string, variant<map<string, string>, int>> which
1109
+ // does need an adl_serializer specialization) so we'll just specialize every time.
1110
+ const nonNulls = TypeUtils_1.removeNullFromUnion(u, true)[1];
1054
1111
  const variantType = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false);
1055
- this.emitLine("void from_json(", this.withConst("json"), " & j, ", variantType, " & x);");
1056
- this.emitLine("void to_json(json & j, ", this.withConst(variantType), " & x);");
1112
+ this.emitLine("template <>");
1113
+ this.emitBlock(["struct adl_serializer<", variantType, ">"], true, () => {
1114
+ this.emitLine("static void from_json(", this.withConst("json"), " & j, ", variantType, " & x);");
1115
+ this.emitLine("static void to_json(json & j, ", this.withConst(variantType), " & x);");
1116
+ });
1057
1117
  }
1058
1118
  emitUnionFunctions(u) {
1119
+ // Function definitions for boost::variant<Ts...>.
1059
1120
  const ourQualifier = this.ourQualifier(true);
1060
1121
  const functionForKind = [
1061
1122
  ["bool", "is_boolean"],
@@ -1067,12 +1128,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1067
1128
  ["array", "is_array"],
1068
1129
  ["enum", "is_string"]
1069
1130
  ];
1070
- const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
1131
+ const nonNulls = TypeUtils_1.removeNullFromUnion(u, true)[1];
1071
1132
  const variantType = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false);
1072
- this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", variantType, " & x)"], false, () => {
1133
+ this.emitBlock(["inline void adl_serializer<", variantType, ">::from_json(", this.withConst("json"), " & j, ", variantType, " & x)"], false, () => {
1073
1134
  let onFirst = true;
1074
1135
  for (const [kind, func] of functionForKind) {
1075
- const typeForKind = (0, collection_utils_1.iterableFind)(nonNulls, t => t.kind === kind);
1136
+ const typeForKind = collection_utils_1.iterableFind(nonNulls, t => t.kind === kind);
1076
1137
  if (typeForKind === undefined)
1077
1138
  continue;
1078
1139
  this.emitLine(onFirst ? "if" : "else if", " (j.", func, "())");
@@ -1090,7 +1151,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1090
1151
  this.emitLine('else throw "Could not deserialize";');
1091
1152
  });
1092
1153
  this.ensureBlankLine();
1093
- this.emitBlock(["inline void to_json(json & j, ", this.withConst(variantType), " & x)"], false, () => {
1154
+ this.emitBlock(["inline void adl_serializer<", variantType, ">::to_json(json & j, ", this.withConst(variantType), " & x)"], false, () => {
1094
1155
  this.emitBlock(["switch (x.", this._variantIndexMethodName, "())"], false, () => {
1095
1156
  let i = 0;
1096
1157
  for (const t of nonNulls) {
@@ -1120,7 +1181,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1120
1181
  });
1121
1182
  }
1122
1183
  emitEnumHeaders(enumName) {
1123
- const ourQualifier = this.ourQualifier(true);
1184
+ const ourQualifier = this.ourQualifier(false);
1124
1185
  this.emitLine("void from_json(", this.withConst("json"), " & j, ", ourQualifier, enumName, " & x);");
1125
1186
  this.emitLine("void to_json(json & j, ", this.withConst([ourQualifier, enumName]), " & x);");
1126
1187
  }
@@ -1130,7 +1191,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1130
1191
  return e.cases.size > 15;
1131
1192
  }
1132
1193
  emitEnumFunctions(e, enumName) {
1133
- const ourQualifier = this.ourQualifier(true);
1194
+ const ourQualifier = this.ourQualifier(false);
1134
1195
  this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, enumName, " & x)"], false, () => {
1135
1196
  if (this.isLargeEnum(e)) {
1136
1197
  this.emitBlock([
@@ -1142,7 +1203,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1142
1203
  "> enumValues"
1143
1204
  ], true, () => {
1144
1205
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1145
- this.emitLine("{", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(jsonName)])]), ", ", ourQualifier, enumName, "::", name, "},");
1206
+ this.emitLine("{", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(jsonName)])]), ", ", ourQualifier, enumName, "::", name, "},");
1146
1207
  });
1147
1208
  });
1148
1209
  this.emitLine(`auto iter = enumValues.find(j.get<${this._stringType.getType()}>());`);
@@ -1154,7 +1215,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1154
1215
  let onFirst = true;
1155
1216
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1156
1217
  const maybeElse = onFirst ? "" : "else ";
1157
- 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, ";");
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, ";");
1158
1219
  onFirst = false;
1159
1220
  });
1160
1221
  this.emitLine('else throw "Input JSON does not conform to schema";');
@@ -1164,7 +1225,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1164
1225
  this.emitBlock(["inline void to_json(json & j, ", this.withConst([ourQualifier, enumName]), " & x)"], false, () => {
1165
1226
  this.emitBlock("switch (x)", false, () => {
1166
1227
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1167
- 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;");
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;");
1168
1229
  });
1169
1230
  this.emitLine('default: throw "This should not happen";');
1170
1231
  });
@@ -1174,10 +1235,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1174
1235
  this.emitLine("using ", name, " = ", this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, false), ";");
1175
1236
  }
1176
1237
  emitAllUnionFunctions() {
1177
- 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.emitUnionFunctions(u));
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));
1178
1239
  }
1179
1240
  emitAllUnionHeaders() {
1180
- 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));
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));
1181
1242
  }
1182
1243
  emitOptionalHelpers() {
1183
1244
  this.emitLine("#ifndef NLOHMANN_OPT_HELPER");
@@ -1218,11 +1279,11 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1218
1279
  this.emitUnionTypedefs(t, name);
1219
1280
  }
1220
1281
  else {
1221
- return (0, Support_1.panic)(`Cannot declare type ${t.kind}`);
1282
+ return Support_1.panic(`Cannot declare type ${t.kind}`);
1222
1283
  }
1223
1284
  }
1224
1285
  else {
1225
- return (0, Support_1.assertNever)(decl.kind);
1286
+ return Support_1.assertNever(decl.kind);
1226
1287
  }
1227
1288
  }
1228
1289
  emitGetterSetter(t, getterName, setterName, memberName) {
@@ -1256,12 +1317,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1256
1317
  const member = this.lookupMemberName(name);
1257
1318
  return [member, "(", member, ")"];
1258
1319
  });
1259
- this.emitLine(") : ", (0, collection_utils_1.arrayIntercalate)([", "], args), " {}");
1320
+ this.emitLine(") : ", collection_utils_1.arrayIntercalate([", "], args), " {}");
1260
1321
  this.emitLine(classConstraint, "() = default;");
1261
1322
  this.emitLine("virtual ~", classConstraint, "() = default;");
1262
1323
  for (const member of constraintMembers) {
1263
1324
  this.ensureBlankLine();
1264
- this.emitGetterSetter((0, collection_utils_1.withDefault)(member.cppConstType, member.cppType), this.lookupMemberName(member.getter), this.lookupMemberName(member.setter), this.lookupMemberName(member.name));
1325
+ this.emitGetterSetter(collection_utils_1.withDefault(member.cppConstType, member.cppType), this.lookupMemberName(member.getter), this.lookupMemberName(member.setter), this.lookupMemberName(member.name));
1265
1326
  }
1266
1327
  });
1267
1328
  this.ensureBlankLine();
@@ -1354,14 +1415,14 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1354
1415
  emitHelperFunctions() {
1355
1416
  this._stringType.emitHelperFunctions();
1356
1417
  if (this._options.codeFormat &&
1357
- (0, collection_utils_1.iterableSome)(this.typeGraph.allTypesUnordered(), t => constraintsForType(t) !== undefined)) {
1418
+ collection_utils_1.iterableSome(this.typeGraph.allTypesUnordered(), t => constraintsForType(t) !== undefined)) {
1358
1419
  this.emitConstraintClasses();
1359
1420
  this.ensureBlankLine();
1360
1421
  }
1361
1422
  this.ensureBlankLine();
1362
- var untypedMacroName = new String("NLOHMANN_UNTYPED_");
1363
- var optionalMacroName = new String("NLOHMANN_OPTIONAL_");
1364
- this._namespaceNames.forEach(function (value) {
1423
+ let untypedMacroName = "NLOHMANN_UNTYPED_";
1424
+ let optionalMacroName = "NLOHMANN_OPTIONAL_";
1425
+ this._namespaceNames.forEach(value => {
1365
1426
  // We can't use upper name, because namespaces are case sensitive
1366
1427
  untypedMacroName += value;
1367
1428
  untypedMacroName += "_";
@@ -1461,35 +1522,68 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1461
1522
  return;
1462
1523
  this.forEachTopLevel("leading", (t, name) => this.emitTopLevelTypedef(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1463
1524
  }
1464
- emitGenerators() {
1465
- let didEmit = false;
1466
- const gathered = this.gatherSource(() => this.emitNamespaces(this._namespaceNames, () => {
1467
- didEmit = this.forEachTopLevel("none", (t, name) => this.emitTopLevelTypedef(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1468
- }));
1469
- if (didEmit) {
1470
- this.emitGatheredSource(gathered);
1525
+ gatherUserNamespaceForwardDecls() {
1526
+ return this.gatherSource(() => {
1527
+ this.forEachObject("leading-and-interposing", (_, className) => this.emitClassHeaders(className));
1528
+ this.forEachEnum("leading-and-interposing", (_, enumName) => this.emitEnumHeaders(enumName));
1529
+ });
1530
+ }
1531
+ gatherNlohmannNamespaceForwardDecls() {
1532
+ return this.gatherSource(() => {
1533
+ this.forEachTopLevel("leading-and-interposing", (t, className) => this.emitTopLevelHeaders(t, className));
1471
1534
  this.ensureBlankLine();
1535
+ this.emitAllUnionHeaders();
1536
+ });
1537
+ }
1538
+ emitUserNamespaceImpls() {
1539
+ this.forEachObject("leading-and-interposing", (c, className) => this.emitClassFunctions(c, className));
1540
+ this.forEachEnum("leading-and-interposing", (e, enumName) => this.emitEnumFunctions(e, enumName));
1541
+ }
1542
+ emitNlohmannNamespaceImpls() {
1543
+ this.forEachTopLevel("leading-and-interposing", (t, name) => this.emitTopLevelFunction(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1544
+ this.ensureBlankLine();
1545
+ this.emitAllUnionFunctions();
1546
+ }
1547
+ emitGenerators() {
1548
+ if (this._options.justTypes) {
1549
+ let didEmit = false;
1550
+ const gathered = this.gatherSource(() => this.emitNamespaces(this._namespaceNames, () => {
1551
+ didEmit = this.forEachTopLevel("none", (t, name) => this.emitTopLevelTypedef(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1552
+ }));
1553
+ if (didEmit) {
1554
+ this.emitGatheredSource(gathered);
1555
+ this.ensureBlankLine();
1556
+ }
1472
1557
  }
1473
- if (!this._options.justTypes) {
1474
- let namespaces = ["nlohmann"];
1475
- if (this._options.msbuildPermissive) {
1476
- namespaces = ["nlohmann", "detail"];
1558
+ else {
1559
+ let userNamespaceForwardDecls = this.gatherUserNamespaceForwardDecls();
1560
+ let nlohmannNamespaceForwardDecls = this.gatherNlohmannNamespaceForwardDecls();
1561
+ if (userNamespaceForwardDecls.length == 0 && nlohmannNamespaceForwardDecls.length > 0) {
1562
+ this.emitNamespaces(["nlohmann"], () => {
1563
+ this.emitGatheredSource(nlohmannNamespaceForwardDecls);
1564
+ this.emitNlohmannNamespaceImpls();
1565
+ });
1566
+ }
1567
+ else if (userNamespaceForwardDecls.length > 0 && nlohmannNamespaceForwardDecls.length == 0) {
1568
+ this.emitNamespaces(this._namespaceNames, () => {
1569
+ this.emitGatheredSource(userNamespaceForwardDecls);
1570
+ this.emitUserNamespaceImpls();
1571
+ });
1572
+ }
1573
+ else if (userNamespaceForwardDecls.length > 0 && nlohmannNamespaceForwardDecls.length > 0) {
1574
+ this.emitNamespaces(this._namespaceNames, () => {
1575
+ this.emitGatheredSource(userNamespaceForwardDecls);
1576
+ });
1577
+ this.emitNamespaces(["nlohmann"], () => {
1578
+ this.emitGatheredSource(nlohmannNamespaceForwardDecls);
1579
+ });
1580
+ this.emitNamespaces(this._namespaceNames, () => {
1581
+ this.emitUserNamespaceImpls();
1582
+ });
1583
+ this.emitNamespaces(["nlohmann"], () => {
1584
+ this.emitNlohmannNamespaceImpls();
1585
+ });
1477
1586
  }
1478
- this.emitNamespaces(namespaces, () => {
1479
- this.forEachObject("leading-and-interposing", (_, className) => this.emitClassHeaders(className));
1480
- this.forEachTopLevel("leading-and-interposing", (t, className) => this.emitTopLevelHeaders(t, className));
1481
- this.forEachEnum("leading-and-interposing", (_, enumName) => this.emitEnumHeaders(enumName));
1482
- if (this.haveUnions) {
1483
- this.emitAllUnionHeaders();
1484
- }
1485
- this.ensureBlankLine();
1486
- this.forEachObject("leading-and-interposing", (c, className) => this.emitClassFunctions(c, className));
1487
- this.forEachEnum("leading-and-interposing", (e, enumName) => this.emitEnumFunctions(e, enumName));
1488
- if (this.haveUnions) {
1489
- this.emitAllUnionFunctions();
1490
- }
1491
- this.forEachTopLevel("leading-and-interposing", (t, name) => this.emitTopLevelFunction(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
1492
- });
1493
1587
  }
1494
1588
  }
1495
1589
  emitSingleSourceStructure(proposedFilename) {
@@ -1534,7 +1628,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1534
1628
  else if (t.type instanceof Type_1.UnionType) {
1535
1629
  propRecord.typeKind = "union";
1536
1630
  /** Recurse into the union */
1537
- const [maybeNull] = (0, TypeUtils_1.removeNullFromUnion)(t.type, true);
1631
+ const [maybeNull] = TypeUtils_1.removeNullFromUnion(t.type, true);
1538
1632
  if (maybeNull !== undefined) {
1539
1633
  /** Houston this is a variant, include it */
1540
1634
  propRecord.kind = IncludeKind.Include;
@@ -1618,7 +1712,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1618
1712
  this.emitLine("enum class ", name, " : ", this._enumType, ";");
1619
1713
  }
1620
1714
  else {
1621
- (0, Support_1.panic)(`Invalid type "${rec.typeKind}" to forward declare`);
1715
+ Support_1.panic(`Invalid type "${rec.typeKind}" to forward declare`);
1622
1716
  }
1623
1717
  });
1624
1718
  });
@@ -1689,8 +1783,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1689
1783
  /** Gather all the unique/custom types used by the schema */
1690
1784
  this._allTypeNames.clear();
1691
1785
  this.forEachDeclaration("none", decl => {
1692
- const definedTypes = (0, TypeUtils_1.directlyReachableTypes)(decl.type, t => {
1693
- if ((0, TypeUtils_1.isNamedType)(t) && (t instanceof Type_1.ClassType || t instanceof Type_1.EnumType || t instanceof Type_1.UnionType)) {
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)) {
1694
1788
  return new Set([
1695
1789
  this.sourcelikeToString(this.cppType(t, {
1696
1790
  needsForwardIndirection: false,
@@ -1701,7 +1795,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1701
1795
  }
1702
1796
  return null;
1703
1797
  });
1704
- this._allTypeNames = (0, collection_utils_1.setUnion)(definedTypes, this._allTypeNames);
1798
+ this._allTypeNames = collection_utils_1.setUnion(definedTypes, this._allTypeNames);
1705
1799
  });
1706
1800
  if (this._options.typeSourceStyle) {
1707
1801
  this.emitSingleSourceStructure(proposedFilename);
@@ -1715,101 +1809,5 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1715
1809
  let newType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
1716
1810
  return originalType !== newType;
1717
1811
  }
1718
- NarrowString = new (class extends BaseString {
1719
- constructor() {
1720
- super("std::string", "const std::string & ", "std::smatch", "std::regex", "", new WrappingCode(["std::to_string("], [")"]), "", "");
1721
- }
1722
- wrapEncodingChange(_qualifier, _fromType, _toType, inner) {
1723
- return inner;
1724
- }
1725
- emitHelperFunctions() {
1726
- return;
1727
- }
1728
- })();
1729
- WideString = new (class extends BaseString {
1730
- superThis;
1731
- constructor(superThis) {
1732
- super("std::wstring", "const std::wstring & ", "std::wsmatch", "std::wregex", "L", new WrappingCode(["std::to_wstring("], [")"]), "Utf16_Utf8", "convert");
1733
- this.superThis = superThis;
1734
- }
1735
- wrapEncodingChange(qualifier, fromType, toType, inner) {
1736
- if (this.superThis.sourcelikeToString(fromType) === this.superThis.sourcelikeToString(toType)) {
1737
- return inner;
1738
- }
1739
- return [
1740
- addQualifier(qualifier, [this._encodingClass]),
1741
- "<",
1742
- fromType,
1743
- ", ",
1744
- toType,
1745
- ">::",
1746
- this._encodingFunction,
1747
- "(",
1748
- inner,
1749
- ")"
1750
- ];
1751
- }
1752
- emitHelperFunctions() {
1753
- this.superThis.emitLine("template<typename T>");
1754
- this.superThis.emitLine("struct tag {};");
1755
- this.superThis.ensureBlankLine();
1756
- this.superThis.emitLine("template<typename fromType, typename toType>");
1757
- this.superThis.emitBlock(["class Utf16_Utf8"], true, () => {
1758
- this.superThis.emitLine("private:");
1759
- this.superThis.emitLine("template<typename TF, typename TT>");
1760
- this.superThis.emitBlock(["static toType convert(tag<std::shared_ptr<TF> >, tag<std::shared_ptr<TT> >, fromType ptr)"], false, () => {
1761
- 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)));");
1762
- });
1763
- this.superThis.ensureBlankLine();
1764
- this.superThis.emitLine("template<typename TF, typename TT>");
1765
- this.superThis.emitBlock(["static toType convert(tag<std::vector<TF> >, tag<std::vector<TT> >, fromType v)"], false, () => {
1766
- this.superThis.emitLine("auto it = v.begin();");
1767
- this.superThis.emitLine("auto newVector = std::vector<TT>();");
1768
- this.superThis.emitBlock(["while (it != v.end())"], false, () => {
1769
- this.superThis.emitLine("newVector.push_back(Utf16_Utf8<TF,TT>::convert(*it));");
1770
- this.superThis.emitLine("it++;");
1771
- });
1772
- this.superThis.emitLine("return newVector;");
1773
- });
1774
- this.superThis.ensureBlankLine();
1775
- this.superThis.emitLine("template<typename KF, typename VF, typename KT, typename VT>");
1776
- this.superThis.emitBlock(["static toType convert(tag<std::map<KF,VF> >, tag<std::map<KT,VT> >, fromType m)"], false, () => {
1777
- this.superThis.emitLine("auto it = m.begin();");
1778
- this.superThis.emitLine("auto newMap = std::map<KT, VT>();");
1779
- this.superThis.emitBlock(["while (it != m.end())"], false, () => {
1780
- this.superThis.emitLine("newMap.insert(std::pair<KT, VT>(Utf16_Utf8<KF, KT>::convert(it->first), Utf16_Utf8<VF, VT>::convert(it->second)));");
1781
- this.superThis.emitLine("it++;");
1782
- });
1783
- this.superThis.emitLine("return newMap;");
1784
- });
1785
- this.superThis.ensureBlankLine();
1786
- this.superThis.emitLine("template<typename TF, typename TT>");
1787
- this.superThis.emitBlock(["static fromType convert(tag<TF>, tag<TT>, fromType from)"], false, () => {
1788
- this.superThis.emitLine("return from;");
1789
- });
1790
- this.superThis.ensureBlankLine();
1791
- this.superThis.emitBlock(["static std::wstring convert(tag<std::string>, tag<std::wstring>, std::string str)"], false, () => {
1792
- this.superThis.emitLine("return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t>{}.from_bytes(str.data());");
1793
- });
1794
- this.superThis.ensureBlankLine();
1795
- this.superThis.emitBlock(["static std::string convert(tag<std::wstring>, tag<std::string>, std::wstring str)"], false, () => {
1796
- this.superThis.emitLine("return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::little_endian>, wchar_t>{}.to_bytes(str.data());");
1797
- });
1798
- this.superThis.ensureBlankLine();
1799
- this.superThis.emitLine("public:");
1800
- this.superThis.emitBlock(["static toType convert(fromType in)"], false, () => {
1801
- this.superThis.emitLine("return convert(tag<fromType>(), tag<toType>(), in);");
1802
- });
1803
- });
1804
- this.superThis.ensureBlankLine();
1805
- this.superThis.emitLine("template<typename T>");
1806
- this.superThis.emitBlock(["std::wstring wdump(const T& j)"], false, () => {
1807
- this.superThis.emitLine("std::ostringstream s;");
1808
- this.superThis.emitLine("s << j;");
1809
- this.superThis.emitLine("return ", this.superThis.ourQualifier(false), "Utf16_Utf8<std::string, std::wstring>::convert(s.str()); ");
1810
- });
1811
- this.superThis.ensureBlankLine();
1812
- }
1813
- })(this);
1814
1812
  }
1815
1813
  exports.CPlusPlusRenderer = CPlusPlusRenderer;