Added Util::parse_status_code().
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Tue, 15 Sep 2009 15:35:29 +0000 (17:35 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Tue, 15 Sep 2009 15:35:29 +0000 (17:35 +0200)
src/service_dyns.cpp
src/service_dyns.h
src/service_tzo.cpp
src/service_tzo.h
src/service_zoneedit.cpp
src/service_zoneedit.h
src/util.cpp
src/util.h

index c113027..b8ad563 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include "service_dyns.h"
+#include "util.h"
 
 #include <time.h>
 #include <boost/foreach.hpp>
@@ -117,7 +118,7 @@ int ServiceDyns::perform_update(const std::string& ip)
     {
         // Get the received http data and parse the status code.
         string curl_data = HTTPHelp->get_curl_data();
-        string status_code = parse_status_code(curl_data);
+        string status_code = Util::parse_status_code(curl_data);
 
         if ( status_code == "200" )
         {
@@ -142,19 +143,6 @@ int ServiceDyns::perform_update(const std::string& ip)
 
 
 /**
- * Get the status code from the returned http data
- * @param data The returned http data.
- * @return The status code.
- */
-string ServiceDyns::parse_status_code(const string& data) const
-{
-    list<string> tokens;
-    ba::split(tokens,data,boost::is_any_of(" "));
-    return tokens.front();
-}
-
-
-/**
  * Serialize function needed by boost/serialization to define which members should be stored as the object state.
  * @param ar Archive
  * @param version Version
index aaa7b73..2fc868a 100644 (file)
@@ -34,8 +34,6 @@ private:
 
     std::string assemble_base_url(const std::string& fqhn, const std::string& username, const std::string& password) const;
 
-    std::string parse_status_code(const std::string& data) const;
-
 public:
 
     typedef boost::shared_ptr<ServiceDyns> Ptr;
index ce3cb2f..8ee64bd 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include "service_tzo.h"
+#include "util.h"
 
 #include <time.h>
 #include <boost/foreach.hpp>
@@ -117,7 +118,7 @@ int ServiceTzo::perform_update(const std::string& ip)
     {
         // Get the received http data and parse the status code.
         string curl_data = HTTPHelp->get_curl_data();
-        string status_code = parse_status_code(curl_data);
+        string status_code = Util::parse_status_code(curl_data);
 
         if ( status_code == "200" )
         {
@@ -142,19 +143,6 @@ int ServiceTzo::perform_update(const std::string& ip)
 
 
 /**
- * Get the status code from the returned http data
- * @param data The returned http data.
- * @return The status code.
- */
-string ServiceTzo::parse_status_code(const string& data) const
-{
-    list<string> tokens;
-    ba::split(tokens,data,boost::is_any_of(" "));
-    return tokens.front();
-}
-
-
-/**
  * Serialize function needed by boost/serialization to define which members should be stored as the object state.
  * @param ar Archive
  * @param version Version
index cfb6f2c..7e58f9d 100644 (file)
@@ -34,8 +34,6 @@ private:
 
     std::string assemble_base_url(const std::string& fqhn, const std::string& username, const std::string& password) const;
 
-    std::string parse_status_code(const std::string& data) const;
-
 public:
 
     typedef boost::shared_ptr<ServiceTzo> Ptr;
index a714146..61cbaa0 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include "service_zoneedit.h"
+#include "util.h"
 
 #include <time.h>
 #include <boost/foreach.hpp>
@@ -111,7 +112,7 @@ int ServiceZoneedit::perform_update(const std::string& ip)
     {
         // Get the received http data and parse the status code.
         string curl_data = HTTPHelp->get_curl_data();
-        string status_code = parse_status_code(curl_data);
+        string status_code = Util::parse_status_code(curl_data);
 
         if ( status_code == "200" )
         {
@@ -136,19 +137,6 @@ int ServiceZoneedit::perform_update(const std::string& ip)
 
 
 /**
- * Get the status code from the returned http data
- * @param data The returned http data.
- * @return The status code.
- */
-string ServiceZoneedit::parse_status_code(const string& data) const
-{
-    list<string> tokens;
-    ba::split(tokens,data,boost::is_any_of(" "));
-    return tokens.front();
-}
-
-
-/**
  * Serialize function needed by boost/serialization to define which members should be stored as the object state.
  * @param ar Archive
  * @param version Version
index 98dfc3d..7e5dc5b 100644 (file)
@@ -34,8 +34,6 @@ private:
 
     std::string assemble_base_url(const std::string& fqhn) const;
 
-    std::string parse_status_code(const std::string& data) const;
-
 public:
 
     typedef boost::shared_ptr<ServiceZoneedit> Ptr;
index d2078d7..18ad24c 100644 (file)
@@ -73,3 +73,16 @@ string Util::compute_md5_digest(string data) throw (invalid_argument)
 
     return oss_digest_md5_hex.str();
 }
+
+
+/**
+ * Get the status code from the given data.
+ * @param data The data containing the status code at front, limited by " ".
+ * @return The parsed status code.
+ */
+string Util::parse_status_code(string data)
+{
+    list<string> tokens;
+    ba::split(tokens,data,boost::is_any_of(" "));
+    return tokens.front();
+}
index b7cb9fc..870c346 100644 (file)
@@ -13,7 +13,9 @@
 
 namespace Util
 {
-    static std::string compute_md5_digest(std::string) throw (std::invalid_argument);
+    static std::string compute_md5_digest(std::string data) throw (std::invalid_argument);
+
+    static std::string parse_status_code(std::string data);
 };
 
 #endif