blob: 53df6e1500e9dcfe6c3bcb0013e560f14e643d45 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompsona8d7b062013-08-08 15:56:35 -07002/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07003 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompsona8d7b062013-08-08 15:56:35 -07005 * See COPYING for copyright and distribution information.
6 */
7
8#include <sstream>
Yingdi Yu61ec2722014-01-20 14:22:32 -08009#include <ndn-cpp-dev/common.hpp>
Alexander Afanasyev1e0a0772014-01-28 20:07:07 -080010#include "util/time.hpp"
Yingdi Yu31b4af22014-01-14 14:13:00 -080011
Jeff Thompsona8d7b062013-08-08 15:56:35 -070012using namespace std;
13
14namespace ndn {
15
Jeff Thompson0050abe2013-09-17 12:50:25 -070016string
Jeff Thompson10ad12a2013-09-24 16:19:11 -070017toHex(const vector<uint8_t>& array)
Jeff Thompsona8d7b062013-08-08 15:56:35 -070018{
Jeff Thompsonb0948a52013-09-12 14:38:26 -070019 if (!&array)
20 return "";
21
Jeff Thompsona8d7b062013-08-08 15:56:35 -070022 ostringstream result;
23 result.flags(ios::hex | ios::uppercase);
Jeff Thompson97223af2013-09-24 17:01:27 -070024 for (size_t i = 0; i < array.size(); ++i) {
Jeff Thompson10ad12a2013-09-24 16:19:11 -070025 uint8_t x = array[i];
Jeff Thompsona8d7b062013-08-08 15:56:35 -070026 if (x < 16)
27 result << '0';
28 result << (unsigned int)x;
29 }
30
31 return result.str();
32}
33
Yingdi Yu31b4af22014-01-14 14:13:00 -080034MillisecondsSince1970
35getNow()
36{
Alexander Afanasyev1e0a0772014-01-28 20:07:07 -080037 return getNowMilliseconds();
Yingdi Yu31b4af22014-01-14 14:13:00 -080038}
39
40
Jeff Thompsona8d7b062013-08-08 15:56:35 -070041}
42