blob: 31569e3f12ae5442371caefaba25aa8b125b9f6d [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/**
* Copyright (C) 2013 Regents of the University of California.
* @author: Jeff Thompson <jefft0@remap.ucla.edu>
* See COPYING for copyright and distribution information.
*/
#include <sstream>
#include <ndn-cpp-dev/common.hpp>
#if NDN_CPP_HAVE_TIME_H
#include <time.h>
#endif
#if NDN_CPP_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
using namespace std;
namespace ndn {
string
toHex(const vector<uint8_t>& array)
{
if (!&array)
return "";
ostringstream result;
result.flags(ios::hex | ios::uppercase);
for (size_t i = 0; i < array.size(); ++i) {
uint8_t x = array[i];
if (x < 16)
result << '0';
result << (unsigned int)x;
}
return result.str();
}
MillisecondsSince1970
getNow()
{
struct timeval t;
// Note: configure.ac requires gettimeofday.
gettimeofday(&t, 0);
return t.tv_sec * 1000.0 + t.tv_usec / 1000.0;
}
}