@@ -115,8 +115,8 @@ boilerplateCodeDoc::JsonSchema::JsonSchema(std::string filename)
115
115
if ( document.HasMember (" cssClass" ) ) {
116
116
css_class = document[" cssClass" ].GetString ();
117
117
}
118
- if ( document.HasMember (" headerFileName " ) ) {
119
- header_filename = document[" headerFileName " ].GetString ();
118
+ if ( document.HasMember (" cppFileName " ) ) {
119
+ cpp_filename = document[" cppFileName " ].GetString ();
120
120
}
121
121
122
122
error = boilerplateCodeDoc::ParseErrorCode::OK;
@@ -445,9 +445,9 @@ return boilerplateOperator(jsonSchema, *this, jsonSchema.css_class, [](const Pro
445
445
/* ***************************************************************************************/
446
446
/* ***************************************************************************************/
447
447
448
- bool boilerplateCodeDoc::JsonSchema2CPP ::operator ()(const boilerplateCodeDoc::JsonSchema& jsonSchema)
448
+ bool boilerplateCodeDoc::JsonSchema2H ::operator ()(const boilerplateCodeDoc::JsonSchema& jsonSchema)
449
449
{
450
- if ( not jsonSchema.header_filename .empty () && not header.empty () ) { header = " /** @file " + jsonSchema.header_filename + header; }
450
+ if ( not jsonSchema.cpp_filename .empty () && not header.empty () ) { header = " /** @file " + jsonSchema.cpp_filename + " .h " + header; }
451
451
return boilerplateOperator (jsonSchema, *this , jsonSchema.namespace_id , [](const Properties& properties, std::string& filtered, std::string& namespace_id) {
452
452
453
453
if (properties.size () > 0 ) {
@@ -492,3 +492,60 @@ return boilerplateOperator(jsonSchema, *this, jsonSchema.namespace_id, [](const
492
492
493
493
}); // return boilerplateOperator
494
494
} // operator()
495
+
496
+ /* ***************************************************************************************/
497
+ /* ***************************************************************************************/
498
+ /* ***************************************************************************************/
499
+ /* ********************** ACTUAL LOGIC CODE **********************************************/
500
+ /* ***************************************************************************************/
501
+ /* ***************************************************************************************/
502
+ /* ***************************************************************************************/
503
+
504
+ bool boilerplateCodeDoc::JsonSchema2CPP::operator ()(const boilerplateCodeDoc::JsonSchema& jsonSchema)
505
+ {
506
+ if ( not jsonSchema.cpp_filename .empty () && not header.empty () ) { header = " /** @file " + jsonSchema.cpp_filename + " .cpp" + header; }
507
+ return boilerplateOperator (jsonSchema, *this , jsonSchema.namespace_id , [](const Properties& properties, std::string& filtered, std::string& namespace_id) {
508
+
509
+ /*
510
+ if(properties.size() > 0) {
511
+
512
+ // supposed metatype is a must
513
+ std::string parentMetatype {};
514
+ parentMetatype = properties.begin()->second.parentMetatype;
515
+ if( parentMetatype.empty() ) { return; } // required
516
+
517
+ // if nothing is implemented, do nothing
518
+ bool nothing_implemented {true};
519
+ for(const auto& p : properties) {
520
+ if( implemented(p.second.metainfo) ) { nothing_implemented = false; break; }
521
+ }
522
+ if( nothing_implemented ) {
523
+ filtered = "\n// " + parentMetatype + ": all their properties are not implemented\n\n" + filtered;
524
+ return;
525
+ }
526
+
527
+ std::string addition {};
528
+ if( not namespace_id.empty() ) { addition += "namespace " + namespace_id + " {\n"; }
529
+ addition += "\n" + parentMetatype + " {\n\n";
530
+
531
+ for(const auto& p : properties) {
532
+
533
+ if( not implemented(p.second.metainfo) ) { addition += "// " + p.second.name + ": " + p.second.metainfo + "\n"; continue; }
534
+
535
+ std::string metatype {p.second.metatype};
536
+ if( metatype.empty() ) { continue; } // required
537
+ std::string name {p.second.name};
538
+ if( name.empty() ) { continue; } // required
539
+
540
+ if( not p.second.description.empty() ) { addition += "///@ brief " + p.second.description + "\n"; }
541
+ addition += metatype + " " + name + " {};\n";
542
+ }
543
+
544
+ addition += "\n}; // " + parentMetatype + "\n";
545
+ if( not namespace_id.empty() ) { addition += "\n} // namespace " + namespace_id + "\n\n"; }
546
+
547
+ filtered = addition + filtered;
548
+ }
549
+ */
550
+ }); // return boilerplateOperator
551
+ } // operator()
0 commit comments