Browse Source

[4081] Option::toString() and OptionString::toString() implemented.

Tomek Mrugalski 9 years ago
parent
commit
8aeff03fda

+ 1 - 1
src/lib/Makefile.am

@@ -1,3 +1,3 @@
 # The following build order must be maintained.
 # The following build order must be maintained.
 SUBDIRS = exceptions util log hooks cryptolink dns cc asiolink dhcp config stats \
 SUBDIRS = exceptions util log hooks cryptolink dns cc asiolink dhcp config stats \
-          asiodns testutils dhcp_ddns dhcpsrv cfgrpt
+          asiodns testutils dhcp_ddns dhcpsrv cfgrpt eval

+ 7 - 0
src/lib/dhcp/option.cc

@@ -214,6 +214,13 @@ std::string Option::toText(int indent) {
 }
 }
 
 
 std::string
 std::string
+Option::toString() {
+    /// @todo: Implement actual conversion in derived classes.
+    return (toText(0));
+}
+
+
+std::string
 Option::headerToText(const int indent, const std::string& type_name) {
 Option::headerToText(const int indent, const std::string& type_name) {
     std::stringstream output;
     std::stringstream output;
     for (int i = 0; i < indent; i++)
     for (int i = 0; i < indent; i++)

+ 8 - 0
src/lib/dhcp/option.h

@@ -206,6 +206,14 @@ public:
     /// @return string with text representation.
     /// @return string with text representation.
     virtual std::string toText(int indent = 0);
     virtual std::string toText(int indent = 0);
 
 
+    /// @brief Returns string representation of the value
+    ///
+    /// This is terse repesentation used in cases where client classification
+    /// refers to a specific option.
+    ///
+    /// @return string that represents the value of the option.
+    virtual std::string toString();
+
     /// Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
     /// Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
     ///
     ///
     /// @return option type
     /// @return option type

+ 5 - 0
src/lib/dhcp/option_string.cc

@@ -92,5 +92,10 @@ OptionString::toText(int indent) {
     return (output.str());
     return (output.str());
 }
 }
 
 
+std::string
+OptionString::toString() {
+    return (getValue());
+}
+
 } // end of isc::dhcp namespace
 } // end of isc::dhcp namespace
 } // end of isc namespace
 } // end of isc namespace

+ 6 - 0
src/lib/dhcp/option_string.h

@@ -110,6 +110,12 @@ public:
     ///
     ///
     /// @return Option information in the textual format.
     /// @return Option information in the textual format.
     virtual std::string toText(int indent = 0);
     virtual std::string toText(int indent = 0);
+
+    /// @brief Returns actual value of the option in string format.
+    ///
+    /// This method is used in client classification.
+    /// @return Content of the option.
+    virtual std::string toString();
 };
 };
 
 
 /// Pointer to the OptionString object.
 /// Pointer to the OptionString object.