26 #include <boost/algorithm/string/predicate.hpp>
27 #include <boost/lexical_cast.hpp>
42 return os <<
"non-local";
46 return os << static_cast<unsigned>(faceScope);
52 switch (facePersistency) {
56 return os <<
"persistent";
58 return os <<
"on-demand";
60 return os <<
"permanent";
62 return os << static_cast<unsigned>(facePersistency);
72 return os <<
"point-to-point";
74 return os <<
"multi-access";
78 return os << static_cast<unsigned>(linkType);
84 switch (faceEventKind) {
88 return os <<
"created";
90 return os <<
"destroyed";
96 return os << static_cast<unsigned>(faceEventKind);
102 using boost::algorithm::iequals;
107 if (iequals(s,
"none"))
109 else if (iequals(s,
"app"))
111 else if (iequals(s,
"autoreg"))
113 else if (iequals(s,
"client"))
115 else if (iequals(s,
"autoconf"))
117 else if (iequals(s,
"nlsr"))
119 else if (iequals(s,
"prefixann"))
121 else if (iequals(s,
"static"))
125 static_assert(std::numeric_limits<std::underlying_type_t<RouteOrigin>>::max() <=
126 std::numeric_limits<int>::max(),
"");
130 v = boost::lexical_cast<int>(s);
132 catch (
const boost::bad_lexical_cast&) {
135 if (v >= std::numeric_limits<std::underlying_type_t<RouteOrigin>>::min() &&
136 v <= std::numeric_limits<std::underlying_type_t<RouteOrigin>>::max()) {
141 is.setstate(std::ios::failbit);
151 switch (routeOrigin) {
157 return os <<
"autoreg";
159 return os <<
"client";
161 return os <<
"autoconf";
165 return os <<
"prefixann";
167 return os <<
"static";
169 return os << static_cast<unsigned>(routeOrigin);
179 static const std::map<RouteFlags, std::string> knownBits = {
185 for (
const auto& pair : knownBits) {
188 std::tie(bit, token) = pair;
190 if ((routeFlags & bit) != 0) {
192 routeFlags =
static_cast<RouteFlags>(routeFlags & ~bit);
197 join =
AsHex{routeFlags};
Helper class to convert a number to hexadecimal format, for use with stream insertion operators.
@ FACE_PERSISTENCY_ON_DEMAND
face is on-demand
@ FACE_PERSISTENCY_PERSISTENT
face is persistent
@ FACE_PERSISTENCY_PERMANENT
face is permanent
@ FACE_SCOPE_LOCAL
face is local
@ FACE_SCOPE_NON_LOCAL
face is non-local
@ ROUTE_FLAG_CHILD_INHERIT
@ LINK_TYPE_AD_HOC
link is ad hoc
@ LINK_TYPE_MULTI_ACCESS
link is multi-access
@ LINK_TYPE_POINT_TO_POINT
link is point-to-point
@ FACE_EVENT_DOWN
face went DOWN (from UP state)
@ FACE_EVENT_CREATED
face was created
@ FACE_EVENT_UP
face went UP (from DOWN state)
@ FACE_EVENT_DESTROYED
face was destroyed
std::istream & operator>>(std::istream &is, RouteOrigin &routeOrigin)
Extract RouteOrigin from stream.
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
ostream_joiner< std::decay_t< DelimT >, CharT, Traits > make_ostream_joiner(std::basic_ostream< CharT, Traits > &os, DelimT &&delimiter)
Backport of ostream_joiner from the Library Fundamentals v2 TS.