Skip to content

Commit 5d3dafa

Browse files
author
Andres Sevillano
committed
Initial values for header/footer
1 parent fc850a7 commit 5d3dafa

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

include/boilerplateCodeDoc.h

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,21 @@ namespace boilerplateCodeDoc {
3838
/// @return if success returns true, otherwise false.
3939
explicit JsonSchema(std::string filename);
4040

41+
/// @brief Error code
4142
ParseErrorCode error {ParseErrorCode::OK};
43+
44+
///@brief Error message
4245
std::string message {}; // error message
43-
void* document_ptr {nullptr}; // void to avoid rapidjson dependencies
46+
47+
///@brief Internal pointer: void to avoid rapidjson dependencies
48+
void* document_ptr {nullptr};
49+
50+
///@brief Json Schema title
51+
///@remarks for debugging
4452
std::string title {};
53+
54+
///@brief Json Schema description
55+
///@remarks for debugging
4556
std::string description {};
4657
};
4758

@@ -52,6 +63,9 @@ namespace boilerplateCodeDoc {
5263
///@brief typical virtual destructor just in case
5364
virtual ~JsonSchemaFilter() = default;
5465

66+
///@brief simplest consturctor
67+
JsonSchemaFilter(std::string header_ = "", std::string footer_ = "") : header{std::move(header_)}, footer{std::move(footer_)} {}
68+
5569
///@brief Error code
5670
ParseErrorCode error {ParseErrorCode::OK};
5771

@@ -64,6 +78,14 @@ namespace boilerplateCodeDoc {
6478

6579
///@brief result of that filter
6680
std::string filtered {};
81+
82+
///@brief preambule
83+
/// @remark to override
84+
std::string header {};
85+
86+
///@brief ending
87+
/// @remark to override
88+
std::string footer {};
6789
};
6890

6991

@@ -103,17 +125,15 @@ namespace boilerplateCodeDoc {
103125
</html>
104126
)"};
105127

128+
///@brief simplest constructor
129+
JsonSchema2HTML(std::string header_ = HEADER, std::string footer_ = FOOTER, std::string css_id_ = CSS_ID) :
130+
JsonSchemaFilter(header_, footer_), css_id{std::move(css_id_)} {}
131+
106132
///@brief filter to apply
107133
bool operator()(const JsonSchema& jsonSchema) override;
108134

109135
///@brief css id to be added to generated tables
110-
std::string css_id {CSS_ID};
111-
112-
///@brief HTML page header
113-
std::string header {HEADER};
114-
115-
///@brief HTML page footer
116-
std::string footer {FOOTER};
136+
std::string css_id {};
117137
};
118138

119139
} // namespace

src/boilerplateCodeDoc.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
#include "version.h"
1616
#include "boilerplateCodeDoc.h"
1717

18-
// debug
19-
//#include <iostream>
18+
/****************************************************************************************/
19+
/****************************************************************************************/
20+
/****************************************************************************************/
21+
/*********************** BOILERPLATE CODE ***********************************************/
22+
/****************************************************************************************/
23+
/****************************************************************************************/
24+
/****************************************************************************************/
2025

2126
static inline std::string to_string(const boilerplateCodeDoc::ParseErrorCode& error) {
2227
switch(error) {
@@ -286,6 +291,15 @@ static void SetProperties(const rapidjson::Document& document, std::string eleme
286291

287292
}
288293

294+
295+
/****************************************************************************************/
296+
/****************************************************************************************/
297+
/****************************************************************************************/
298+
/*********************** ACTUAL LOGIC CODE **********************************************/
299+
/****************************************************************************************/
300+
/****************************************************************************************/
301+
/****************************************************************************************/
302+
289303
static lambda_t html = [](const Properties& properties, std::string& filtered)
290304
{
291305
for(const auto& p : properties) {
@@ -301,8 +315,6 @@ static lambda_t html = [](const Properties& properties, std::string& filtered)
301315
}
302316
};
303317

304-
305-
306318
bool boilerplateCodeDoc::JsonSchema2HTML::operator()(const boilerplateCodeDoc::JsonSchema& jsonSchema)
307319
{
308320
if( not jsonSchema.document_ptr ) {

0 commit comments

Comments
 (0)