cpp: Add more EngineInfo::Version ctors
authorAndre Heinecke <aheinecke@intevation.de>
Fri, 4 Nov 2016 11:29:32 +0000 (12:29 +0100)
committerAndre Heinecke <aheinecke@intevation.de>
Fri, 4 Nov 2016 11:29:32 +0000 (12:29 +0100)
* lang/cpp/src/engineinfo.h
(EngineInfo::Version::Version(const char*)),
(EngineInfo::Version::Version()): New.

NEWS
lang/cpp/src/engineinfo.h

diff --git a/NEWS b/NEWS
index e43aa30..4d2a110 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ Noteworthy changes in version 1.7.2 (unreleased)
  gpgme_query_swdb_result_t       NEW.
  qt: DN                          NEW.
  qt: DN::Attribute               NEW.
+ cpp: EngineInfo::Version::Version(const char*) NEW.
+ cpp: EngineInfo::Version::Version()            NEW.
 
 
 Noteworthy changes in version 1.7.1 (2016-10-18)
index 72e125c..aa6fcca 100644 (file)
@@ -40,6 +40,12 @@ public:
     struct Version
     {
         int major, minor, patch;
+        Version()
+        {
+          major = 0;
+          minor = 0;
+          patch = 0;
+        }
 
         Version(const std::string& version)
         {
@@ -51,6 +57,16 @@ public:
             }
         }
 
+        Version(const char *version)
+        {
+            if (!version ||
+                std::sscanf(version, "%d.%d.%d", &major, &minor, &patch) != 3) {
+                major = 0;
+                minor = 0;
+                patch = 0;
+            }
+        }
+
         bool operator < (const Version& other)
         {
             if (major < other.major)