Patch #3462 2013-05-18 21:35

bat

Autoversioning:option to use #define instead of static const
Download
3462-Autoversioning.patch (15.6 KB)
Category
Plugin::Refinement
Status
Accepted
Close date
2013-05-26 04:11
Assigned to
biplab
Index: AutoVersioning.cpp
===================================================================
--- AutoVersioning.cpp    (revision 8648)
+++ AutoVersioning.cpp    (working copy)
@@ -175,6 +175,10 @@
                 {
                     Config.Settings.DateDeclarations = Help?true:false;
                 }
+                if(pElem->QueryIntAttribute("use_define", &Help) == TIXML_SUCCESS)
+                {
+                    Config.Settings.UseDefine = Help?true:false;
+                }
                 // GJH 03/03/10 Added manifest updating.
                 if(pElem->QueryIntAttribute("update_manifest", &Help) == TIXML_SUCCESS)
                 {
@@ -264,6 +268,7 @@
             TiXmlElement Settings("Settings");
             Settings.SetAttribute("autoincrement", NewConfig.Settings.Autoincrement);
             Settings.SetAttribute("date_declarations", NewConfig.Settings.DateDeclarations);
+            Settings.SetAttribute("use_define", NewConfig.Settings.UseDefine);
             // GJH 03/03/10 Added manifest updating.
             Settings.SetAttribute("update_manifest", NewConfig.Settings.UpdateManifest);
             Settings.SetAttribute("do_auto_increment", NewConfig.Settings.DoAutoIncrement);
@@ -489,6 +494,7 @@
 
     VersionEditorDialog.SetAuto(GetConfig().Settings.Autoincrement);
     VersionEditorDialog.SetDates(GetConfig().Settings.DateDeclarations);
+    VersionEditorDialog.SetDefine(GetConfig().Settings.UseDefine);
     // GJH 03/03/10 Added manifest updating.
     VersionEditorDialog.SetManifest(GetConfig().Settings.UpdateManifest);
 
@@ -526,6 +532,7 @@
     GetConfig().Scheme.BuildTimesToIncrementMinor = VersionEditorDialog.GetBuildTimesToMinorIncrement();
     GetConfig().Settings.Autoincrement = VersionEditorDialog.GetAuto();
     GetConfig().Settings.DateDeclarations = VersionEditorDialog.GetDates();
+    GetConfig().Settings.UseDefine = VersionEditorDialog.GetDefine();
     // GJH 03/03/10 Added manifest updating.
     GetConfig().Settings.UpdateManifest = VersionEditorDialog.GetManifest();
     GetConfig().Settings.AskToIncrement = VersionEditorDialog.GetCommitAsk();
@@ -592,6 +599,11 @@
     }
 
     wxString prefix = cbC2U(GetConfig().Code.Prefix.c_str());
+    wxString def_define_char = _T("");
+    wxString def_define_long = _T("");
+    wxString def_equal = _T("");
+    wxString def_array = _T("");
+    wxString def_end = _T("");
 
     if(prefix != _T(""))
     {
@@ -608,42 +620,58 @@
         headerOutput << _T("namespace ") << cbC2U(GetConfig().Code.NameSpace.c_str()) << _T("{") << _T("\n");
         headerOutput << _T("\t") << _T("\n");
     }
+    if(GetConfig().Settings.UseDefine)
+    {
+        def_define_char << _T("#define ");
+        def_define_long << def_define_char;
+        def_equal << _T(" ");
+        def_array << _T("");
+        def_end << _T("");
+    }
+    else
+    {
+        def_define_char << _T("static const char ");
+        def_define_long << _T("static const long ");
+        def_equal << _T(" = ");
+        def_array << _T("[]");
+        def_end << _T(";");
+    }
 
     if(GetConfig().Settings.DateDeclarations)
     {
         wxDateTime actualDate = wxDateTime::Now();
         headerOutput << _T("\t") << _T("//Date Version Types") << _T("\n");
-        headerOutput << _T("\t") << _T("static const char ") << prefix << _T("DATE[] = ") << actualDate.Format(_T("\"%d\"")) << _T(";\n");
-        headerOutput << _T("\t") << _T("static const char ") << prefix << _T("MONTH[] = ") << actualDate.Format(_T("\"%m\"")) << _T(";\n");
-        headerOutput << _T("\t") << _T("static const char ") << prefix << _T("YEAR[] = ") << actualDate.Format(_T("\"%Y\"")) << _T(";\n");
+        headerOutput << _T("\t") << def_define_char << prefix << _T("DATE") << def_array << def_equal << actualDate.Format(_T("\"%d\"")) << def_end << _T("\n");
+        headerOutput << _T("\t") << def_define_char << prefix << _T("MONTH") << def_array << def_equal << actualDate.Format(_T("\"%m\"")) << def_end << _T("\n");
+        headerOutput << _T("\t") << def_define_char << prefix << _T("YEAR") << def_array << def_equal << actualDate.Format(_T("\"%Y\"")) << def_end << _T("\n");
         long ubuntuYearNumber = 0;
         actualDate.Format(_T("%y")).ToLong(&ubuntuYearNumber);
         wxString ubuntuYear;
         ubuntuYear.Printf(_T("%ld"),ubuntuYearNumber);
-        headerOutput << _T("\t") << _T("static const char ") << prefix << _T("UBUNTU_VERSION_STYLE[] = \"") << ubuntuYear << actualDate.Format(_T(".%m")) << _T("\";\n");
+        headerOutput << _T("\t") << def_define_char << prefix << _T("UBUNTU_VERSION_STYLE") << def_array << def_equal << _T(" \"") << ubuntuYear << actualDate.Format(_T(".%m")) << _T("\"") << def_end << _T("\n");
         headerOutput << _T("\t") << _T("\n");
     }
 
     headerOutput << _T("\t") << _T("//Software Status") << _T("\n");
-    headerOutput << _T("\t") << _T("static const char ") << prefix << _T("STATUS[] = \"") << cbC2U(GetVersionState().Sta
download for full patch...
biplab 2013-05-26 04:11

Thanks for the patch.