util: add printHex() overload that takes a uint64_t

And AsHex helper class.

Change-Id: If6fb6edea258ab281b5ea9cc30deffd2d8994dc5
Refs: #3006
diff --git a/src/mgmt/nfd/control-parameters.cpp b/src/mgmt/nfd/control-parameters.cpp
index 30f8fe9..4958749 100644
--- a/src/mgmt/nfd/control-parameters.cpp
+++ b/src/mgmt/nfd/control-parameters.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -23,6 +23,7 @@
 #include "encoding/tlv-nfd.hpp"
 #include "encoding/block-helpers.hpp"
 #include "util/concepts.hpp"
+#include "util/string-helper.hpp"
 
 namespace ndn {
 namespace nfd {
@@ -304,15 +305,11 @@
   }
 
   if (parameters.hasFlags()) {
-    std::ios_base::fmtflags osFlags = os.flags();
-    os << "Flags: " << std::showbase << std::hex << parameters.getFlags() << ", ";
-    os.flags(osFlags);
+    os << "Flags: " << AsHex{parameters.getFlags()} << ", ";
   }
 
   if (parameters.hasMask()) {
-    std::ios_base::fmtflags osFlags = os.flags();
-    os << "Mask: " << std::showbase << std::hex << parameters.getMask() << ", ";
-    os.flags(osFlags);
+    os << "Mask: " << AsHex{parameters.getMask()} << ", ";
   }
 
   if (parameters.hasStrategy()) {
diff --git a/src/mgmt/nfd/face-event-notification.cpp b/src/mgmt/nfd/face-event-notification.cpp
index 505026b..888fe61 100644
--- a/src/mgmt/nfd/face-event-notification.cpp
+++ b/src/mgmt/nfd/face-event-notification.cpp
@@ -24,8 +24,7 @@
 #include "encoding/encoding-buffer.hpp"
 #include "encoding/tlv-nfd.hpp"
 #include "util/concepts.hpp"
-
-#include <iomanip>
+#include "util/string-helper.hpp"
 
 namespace ndn {
 namespace nfd {
@@ -197,13 +196,8 @@
      << "          LocalUri: " << notification.getLocalUri() << ",\n"
      << "          FaceScope: " << notification.getFaceScope() << ",\n"
      << "          FacePersistency: " << notification.getFacePersistency() << ",\n"
-     << "          LinkType: " << notification.getLinkType() << ",\n";
-
-  auto osFlags = os.flags();
-  // std::showbase doesn't work with number 0
-  os << "          Flags: 0x" << std::noshowbase << std::noshowpos << std::nouppercase
-     << std::hex << notification.getFlags() << "\n";
-  os.flags(osFlags);
+     << "          LinkType: " << notification.getLinkType() << ",\n"
+     << "          Flags: " << AsHex{notification.getFlags()} << "\n";
 
   return os << "          )";
 }
diff --git a/src/mgmt/nfd/face-status.cpp b/src/mgmt/nfd/face-status.cpp
index ea0d546..df0521f 100644
--- a/src/mgmt/nfd/face-status.cpp
+++ b/src/mgmt/nfd/face-status.cpp
@@ -24,8 +24,7 @@
 #include "encoding/encoding-buffer.hpp"
 #include "encoding/tlv-nfd.hpp"
 #include "util/concepts.hpp"
-
-#include <iomanip>
+#include "util/string-helper.hpp"
 
 namespace ndn {
 namespace nfd {
@@ -366,15 +365,9 @@
 
   os << "     FaceScope: " << status.getFaceScope() << ",\n"
      << "     FacePersistency: " << status.getFacePersistency() << ",\n"
-     << "     LinkType: " << status.getLinkType() << ",\n";
-
-  auto osFlags = os.flags();
-  // std::showbase doesn't work with number 0
-  os << "     Flags: 0x" << std::noshowbase << std::noshowpos << std::nouppercase
-     << std::hex << status.getFlags() << ",\n";
-  os.flags(osFlags);
-
-  os << "     Counters: {Interests: {in: " << status.getNInInterests() << ", "
+     << "     LinkType: " << status.getLinkType() << ",\n"
+     << "     Flags: " << AsHex{status.getFlags()} << ",\n"
+     << "     Counters: {Interests: {in: " << status.getNInInterests() << ", "
      << "out: " << status.getNOutInterests() << "},\n"
      << "                Data: {in: " << status.getNInDatas() << ", "
      << "out: " << status.getNOutDatas() << "},\n"
diff --git a/src/mgmt/nfd/rib-entry.cpp b/src/mgmt/nfd/rib-entry.cpp
index 17b53d6..c7ec47a 100644
--- a/src/mgmt/nfd/rib-entry.cpp
+++ b/src/mgmt/nfd/rib-entry.cpp
@@ -24,6 +24,7 @@
 #include "encoding/encoding-buffer.hpp"
 #include "encoding/tlv-nfd.hpp"
 #include "util/concepts.hpp"
+#include "util/string-helper.hpp"
 
 #include <boost/range/adaptor/reversed.hpp>
 
@@ -206,13 +207,8 @@
   os << "Route("
      << "FaceId: " << route.getFaceId() << ", "
      << "Origin: " << route.getOrigin() << ", "
-     << "Cost: " << route.getCost() << ", ";
-
-  auto osFlags = os.flags();
-  // std::showbase doesn't work with number 0
-  os << "Flags: 0x" << std::noshowbase << std::noshowpos << std::nouppercase
-     << std::hex << route.getFlags() << ", ";
-  os.flags(osFlags);
+     << "Cost: " << route.getCost() << ", "
+     << "Flags: " << AsHex{route.getFlags()} << ", ";
 
   if (route.hasExpirationPeriod()) {
     os << "ExpirationPeriod: " << route.getExpirationPeriod();