@@ -90,6 +90,9 @@ options (po::options_description& d)
9090 (" cxx-source-regex" , po::value<std::string> ()->default_value (" /\\ ..*$//" ),
9191 " Use provided regular expression of the form /pattern/replacement/ when constructing "
9292 " the name of the source file." )
93+ (" cxx-header-guard" , po::value<std::string> ()->default_value (" " ),
94+ " Use this header include guard instead of the filename' "
95+ " when constructing the name of the header file." )
9396 (" cxx-banner-file" , po::value<std::string> ()->default_value (" " ),
9497 " Copy provided banner at the beginning of every generated "
9598 " file for which file-specific banner is not provided." )
@@ -382,22 +385,30 @@ generate (po::variables_map const& vm, Schema& schema, fs::path const& file_path
382385 // HXX
383386 //
384387 std::string guard (hxx_name);
388+ std::string guard_flag (vm[" cxx-header-guard" ].as <std::string> ());
389+ // When the userhas passed a special guard use that, else construct one
390+ if (!guard_flag.empty ())
391+ {
392+ guard = guard_flag;
393+ }
394+ else
395+ {
396+ // Split words
397+ //
398+ guard = regex::perl_s (guard, " /([a-z])([A-Z])/$1_$2/" );
385399
386- // Split words
387- //
388- guard = regex::perl_s (guard, " /([a-z])([A-Z])/$1_$2/" );
389-
390- // Upcase.
391- //
392- std::transform (guard.begin (), guard.end (), guard.begin (), upcase);
400+ // Upcase.
401+ //
402+ std::transform (guard.begin (), guard.end (), guard.begin (), upcase);
393403
394- // Replace '.' with '_'.
395- //
396- guard = regex::perl_s (guard, " /\\ ./_/" );
404+ // Replace '.' with '_'.
405+ //
406+ guard = regex::perl_s (guard, " /\\ ./_/" );
397407
398- // Replace '-' with '_'.
399- //
400- guard = regex::perl_s (guard, " /\\ -/_/" );
408+ // Replace '-' with '_'.
409+ //
410+ guard = regex::perl_s (guard, " /\\ -/_/" );
411+ }
401412
402413 hxx << " #ifndef " << guard.c_str () << endl
403414 << " #define " << guard.c_str () << endl
0 commit comments