From: Tomek Mrugalski Date: Mon, 26 Oct 2015 19:12:17 +0000 (+0100) Subject: [4081] Option::toString() and OptionString::toString() implemented. X-Git-Tag: trac4106_base~1^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8aeff03fda4091d5ace0f57b1dcc0bcceac08cc8;p=thirdparty%2Fkea.git [4081] Option::toString() and OptionString::toString() implemented. --- diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index fc52cef7d9..4b77fcb324 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -1,3 +1,3 @@ # The following build order must be maintained. 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 diff --git a/src/lib/dhcp/option.cc b/src/lib/dhcp/option.cc index c74a16909b..063884ad34 100644 --- a/src/lib/dhcp/option.cc +++ b/src/lib/dhcp/option.cc @@ -213,6 +213,13 @@ std::string Option::toText(int indent) { return (output.str()); } +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) { std::stringstream output; diff --git a/src/lib/dhcp/option.h b/src/lib/dhcp/option.h index 1b3022a0b8..ad622e89ee 100644 --- a/src/lib/dhcp/option.h +++ b/src/lib/dhcp/option.h @@ -206,6 +206,14 @@ public: /// @return string with text representation. 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) /// /// @return option type diff --git a/src/lib/dhcp/option_string.cc b/src/lib/dhcp/option_string.cc index 8c1d0d4d14..b1bc4bbf47 100644 --- a/src/lib/dhcp/option_string.cc +++ b/src/lib/dhcp/option_string.cc @@ -92,5 +92,10 @@ OptionString::toText(int indent) { return (output.str()); } +std::string +OptionString::toString() { + return (getValue()); +} + } // end of isc::dhcp namespace } // end of isc namespace diff --git a/src/lib/dhcp/option_string.h b/src/lib/dhcp/option_string.h index 1b24b2dce1..844d593ba6 100644 --- a/src/lib/dhcp/option_string.h +++ b/src/lib/dhcp/option_string.h @@ -110,6 +110,12 @@ public: /// /// @return Option information in the textual format. 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.