include VERSION
[libt2n] / codegen / main.cpp
index ec97403..fb57155 100644 (file)
@@ -6,6 +6,9 @@
 #include <list>
 #include <stdexcept>
 #include <boost/lexical_cast.hpp>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 //! convert string to upper case
 std::string
@@ -444,7 +447,7 @@ struct header_file : public std::ofstream
      header_file(const char* fname) : std::ofstream(fname) {
          std::cerr << "create header: '" << fname << "'" << std::endl;
          std::string macro(replace(toupper(fname),'.','_'));
-         *this << "// automatically generated code - do not edit\n" << std::endl;
+         *this << "// automatically generated code (generated by libt2n-codegen " << VERSION << ") - do not edit\n" << std::endl;
          *this << "#ifndef " << macro << "\n"
                << "#define " << macro << "\n";
      }
@@ -464,12 +467,18 @@ struct cpp_file : public std::ofstream
 int
 main(int argc, char* argv[])
 {
-     if (argc < 3) {
-         std::cerr << "Usage: " << argv[0] << "default-group gccxml-file1 gccxml-file2 ... " << std::endl;
-         return 1;
-     }
+    // todo: maybe use getopt
+    if ((argc>1)&&(std::string(argv[1])=="--version")) {
+       std::cerr << VERSION << std::endl;
+       return 0;
+    }
+    if (argc < 3)
+    {
+       std::cerr << "Usage: " << argv[0] << "default-group gccxml-file1 gccxml-file2 ... " << std::endl;
+       return 1;
+    }
 
-     try{
+    try{
          std::string group(argv[1]);
          std::list<std::string> xmlfiles;
          for (int i=2;i<argc;++i)