@@ -145,21 +145,25 @@ using Required = std::vector<std::string>;
145
145
using OneOf = std::vector<Required>;
146
146
struct Property {
147
147
bool required {false };
148
+ std::string element {};
148
149
std::string scope {};
149
150
std::string name {};
150
151
std::string type {};
151
152
std::string description {};
152
153
std::string title {};
153
154
std::string parentTitle {};
155
+ std::string parentType {};
154
156
std::string metatype {};
155
157
std::string parentMetatype {};
156
158
std::string metainfo {};
157
159
std::string bookmark_source {};
158
160
std::string bookmark_target {};
159
- Property (bool req, std::string sco, std::string nam, std::string typ, std::string des, std::string tit,
161
+ Property (bool req, std::string elm, std::string sco, std::string nam, std::string typ, std::string ptyp , std::string des, std::string tit,
160
162
std::string par, std::string met, std::string pm, std::string inf, std::string bs, std::string bt)
161
- : required{req}, scope{std::move (sco)}, name{std::move (nam)}, type{std::move (typ)}, description{std::move (des)}, title{std::move (tit)},
162
- parentTitle{std::move (par)}, metatype{std::move (met)}, parentMetatype{std::move (pm)}, metainfo{std::move (inf)},
163
+ : required{req}, element{std::move (elm)},
164
+ scope{std::move (sco)}, name{std::move (nam)}, type{std::move (typ)}, parentType{std::move (ptyp)},
165
+ description{std::move (des)}, title{std::move (tit)}, parentTitle{std::move (par)},
166
+ metatype{std::move (met)}, parentMetatype{std::move (pm)}, metainfo{std::move (inf)},
163
167
bookmark_source{std::move (bs)}, bookmark_target{std::move (bt)} {}
164
168
};
165
169
using Properties = std::map<std::string, Property>;
@@ -209,9 +213,21 @@ static void processProperties(const OneOf& oneOf, const Required& required, Prop
209
213
}
210
214
}
211
215
212
- // by default "scope" will be "optional"
213
216
for (auto && p : properties) {
214
- if ( p.second .scope .empty () ) { p.second .scope = " optional" ; }
217
+
218
+ auto && e {p.second }; // alias
219
+
220
+ // by default "scope" will be "optional"
221
+ if ( e.scope .empty () ) { e.scope = " optional" ; }
222
+
223
+ // get ready in a lazy way for HTML table internal links
224
+ if (e.type == " object" || e.type == " array" ) {
225
+ if ( e.bookmark_source .empty () ) { e.bookmark_source = " #" + (e.title .empty ()?e.parentTitle :e.title ); }
226
+ }
227
+ if ( e.parentType == " object" || e.parentType == " array" ) {
228
+ if ( e.bookmark_target .empty () ) { e.bookmark_target = e.parentTitle ; }
229
+ }
230
+
215
231
}
216
232
217
233
}
@@ -258,9 +274,11 @@ static void SetProperties(const rapidjson::Document& document, std::string eleme
258
274
std::string title {}; // optional
259
275
getString (document, element, " /properties/" , name, " /title" , title);
260
276
std::string parentTitle {}; // optional
261
- getString (document, element, " " , " " , " /title" , parentTitle);
277
+ getString (document, element, " " , " " , " /title" , parentTitle);
262
278
std::string parentMetatype {}; // required
263
279
if (not getString (document, element, " " , " " , " /metatype" , parentMetatype)) { continue ; }
280
+ std::string parentType {}; // required
281
+ if (not getString (document, element, " " , " " , " /type" , parentType)) { continue ; }
264
282
std::string metatype {}; // required
265
283
if (not getString (document, element, " /properties/" , name, " /metatype" , metatype)) { continue ; }
266
284
std::string metainfo {}; // optional
@@ -271,7 +289,7 @@ static void SetProperties(const rapidjson::Document& document, std::string eleme
271
289
getString (document, element, " /properties/" , name, " /bookmarkSource" , bookmark_source);
272
290
std::string bookmark_target {}; // optional
273
291
getString (document, element, " " , " " , " /bookmarkTarget" , bookmark_target);
274
- properties.emplace (std::make_pair (name, Property{false , scope, name, type, description, title,
292
+ properties.emplace (std::make_pair (name, Property{false , element, scope, name, type, parentType , description, title,
275
293
parentTitle, metatype, parentMetatype, metainfo, bookmark_source, bookmark_target}));
276
294
}
277
295
@@ -288,10 +306,12 @@ static void SetProperties(const rapidjson::Document& document, std::string eleme
288
306
getString (document, element, " /items/properties/" , name, " /description" , description);
289
307
std::string title {}; // optional
290
308
getString (document, element, " /items/properties/" , name, " /title" , title);
291
- std::string parentTitle {}; // optional
309
+ std::string parentTitle {}; // optional
292
310
getString (document, element, " /items" , " " , " /title" , parentTitle);
293
- std::string parentMetatype {}; // optional
294
- getString (document, element, " /items" , " " , " /metatype" , parentMetatype);
311
+ std::string parentType {}; // required
312
+ if (not getString (document, element, " /items" , " " , " /type" , parentType)) { continue ; }
313
+ std::string parentMetatype {}; // required
314
+ if (not getString (document, element, " /items" , " " , " /metatype" , parentMetatype)) { continue ; }
295
315
std::string metatype {}; // optional
296
316
getString (document, element, " /items/properties/" , name, " /metatype" , metatype);
297
317
std::string metainfo {}; // optional
@@ -302,7 +322,7 @@ static void SetProperties(const rapidjson::Document& document, std::string eleme
302
322
getString (document, element, " /items/properties/" , name, " /bookmarkSource" , bookmark_source);
303
323
std::string bookmark_target {}; // optional
304
324
getString (document, element, " /items" , " " , " /bookmarkTarget" , bookmark_target);
305
- properties.emplace (std::make_pair (name, Property{false , scope, name, type, description, title,
325
+ properties.emplace (std::make_pair (name, Property{false , element, scope, name, type, parentType , description, title,
306
326
parentTitle, metatype, parentMetatype, metainfo, bookmark_source, bookmark_target}));
307
327
}
308
328
@@ -323,7 +343,7 @@ static void SetProperties(const rapidjson::Document& document, std::string eleme
323
343
oneOf.emplace_back (temp);
324
344
}
325
345
}
326
- }
346
+ }
327
347
}
328
348
processProperties (oneOf, required, properties); // what is required
329
349
lambda (properties); // apply filter
@@ -509,46 +529,30 @@ if( not jsonSchema.cpp_filename.empty() && not header.empty() ) {
509
529
}
510
530
return boilerplateOperator (jsonSchema, *this , [this , namespace_id = jsonSchema.namespace_id ](const Properties& properties) {
511
531
512
- /*
532
+ static std::string rapidjsonPointerInfo {};
533
+
513
534
if (properties.size () > 0 ) {
514
535
515
536
// supposed metatype is a must
516
- std::string parentMetatype {};
517
- parentMetatype = properties.begin()->second.parentMetatype ;
518
- if( parentMetatype .empty() ) { return; } // required
537
+ std::string parentType {};
538
+ parentType = properties.begin ()->second .parentType ;
539
+ if ( parentType .empty () ) { return ; } // required
519
540
520
541
// if nothing is implemented, do nothing
521
542
bool nothing_implemented {true };
522
543
for (const auto & p : properties) {
523
544
if ( implemented (p.second .metainfo ) ) { nothing_implemented = false ; break ; }
524
545
}
525
546
if ( nothing_implemented ) {
526
- filtered = "\n// " + parentMetatype + ": all their properties are not implemented\n\n" + filtered;
547
+ filtered = " \n // " + parentType + " : all their properties are not implemented\n\n " + filtered;
527
548
return ;
528
549
}
529
550
530
- std::string addition {};
531
- if( not namespace_id.empty() ) { addition += "namespace " + namespace_id + " {\n"; }
532
- addition += "\n" + parentMetatype + " {\n\n";
533
-
534
- for(const auto& p : properties) {
535
-
536
- if( not implemented(p.second.metainfo) ) { addition += "// " + p.second.name + ": " + p.second.metainfo + "\n"; continue; }
537
-
538
- std::string metatype {p.second.metatype};
539
- if( metatype.empty() ) { continue; } // required
540
- std::string name {p.second.name};
541
- if( name.empty() ) { continue; } // required
542
-
543
- if( not p.second.description.empty() ) { addition += "///@ brief " + p.second.description + "\n"; }
544
- addition += metatype + " " + name + " {};\n";
545
- }
551
+ rapidjsonPointerInfo += properties.begin ()->second .element + " \n " ;
546
552
547
- addition += "\n}; // " + parentMetatype + "\n";
548
- if( not namespace_id.empty() ) { addition += "\n} // namespace " + namespace_id + "\n\n"; }
553
+ std::string addition {rapidjsonPointerInfo + " \n " };
549
554
550
555
filtered = addition + filtered;
551
556
}
552
- */
553
557
}); // return boilerplateOperator
554
558
} // operator()
0 commit comments