diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2017-11-23 12:15:00 -0800 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2017-11-24 14:04:48 +0000 |
commit | fd920609819a5b10d3d7c8d34fe4fa4214c7da22 (patch) | |
tree | fb0b5c3b5a9ba56308ef704ef922e959aafad17f /src/vpp-api/vom/types.cpp | |
parent | 227bf211ab65e7aed6862fc881cc949c342200fd (diff) |
VOM: Additions to allow uses to UT applications that use VOM
- find object by key
- compare objects
Change-Id: I36ec8612be9482bcef7ceced2a59f7403f77b3e8
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vpp-api/vom/types.cpp')
-rw-r--r-- | src/vpp-api/vom/types.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/vpp-api/vom/types.cpp b/src/vpp-api/vom/types.cpp index 128d757e539..c5325d287a5 100644 --- a/src/vpp-api/vom/types.cpp +++ b/src/vpp-api/vom/types.cpp @@ -18,6 +18,8 @@ #include <iostream> #include <sstream> +#include <boost/algorithm/string.hpp> + #include "vom/types.hpp" namespace VOM { @@ -111,6 +113,19 @@ mac_address_t::mac_address_t(std::initializer_list<uint8_t> i) std::copy(i.begin(), i.end(), std::begin(bytes)); } +mac_address_t::mac_address_t(const std::string& str) +{ + std::vector<std::string> parts; + + boost::split(parts, str, boost::is_any_of(":")); + + size_t n_bytes = std::min(bytes.size(), parts.size()); + + for (uint32_t ii = 0; ii < n_bytes; ii++) { + bytes[ii] = std::stoul(parts[ii], nullptr, 16); + } +} + const mac_address_t mac_address_t::ONE({ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }); const mac_address_t mac_address_t::ZERO({ 0x0 }); @@ -131,7 +146,6 @@ mac_address_t::to_string() const s.fill('0'); s << std::hex; - s << "mac:["; for (auto byte : bytes) { if (first) first = false; @@ -139,7 +153,6 @@ mac_address_t::to_string() const s << ":"; s << std::setw(2) << static_cast<unsigned int>(byte); } - s << "]"; return (s.str()); } |