Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
4 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> | ||||
Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 5 | * See COPYING for copyright and distribution information. |
6 | */ | ||||
7 | |||||
Alexander Afanasyev | 09c613f | 2014-01-29 00:23:58 -0800 | [diff] [blame] | 8 | #include "common.hpp" |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame^] | 9 | |
Alexander Afanasyev | 1e0a077 | 2014-01-28 20:07:07 -0800 | [diff] [blame] | 10 | #include "util/time.hpp" |
Yingdi Yu | 31b4af2 | 2014-01-14 14:13:00 -0800 | [diff] [blame] | 11 | |
Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 12 | using namespace std; |
13 | |||||
14 | namespace ndn { | ||||
15 | |||||
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 16 | string |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 17 | toHex(const vector<uint8_t>& array) |
Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 18 | { |
Jeff Thompson | b0948a5 | 2013-09-12 14:38:26 -0700 | [diff] [blame] | 19 | if (!&array) |
20 | return ""; | ||||
21 | |||||
Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 22 | ostringstream result; |
23 | result.flags(ios::hex | ios::uppercase); | ||||
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 24 | for (size_t i = 0; i < array.size(); ++i) { |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 25 | uint8_t x = array[i]; |
Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 26 | if (x < 16) |
27 | result << '0'; | ||||
28 | result << (unsigned int)x; | ||||
29 | } | ||||
30 | |||||
31 | return result.str(); | ||||
32 | } | ||||
33 | |||||
Yingdi Yu | 31b4af2 | 2014-01-14 14:13:00 -0800 | [diff] [blame] | 34 | MillisecondsSince1970 |
35 | getNow() | ||||
36 | { | ||||
Alexander Afanasyev | 1e0a077 | 2014-01-28 20:07:07 -0800 | [diff] [blame] | 37 | return getNowMilliseconds(); |
Yingdi Yu | 31b4af2 | 2014-01-14 14:13:00 -0800 | [diff] [blame] | 38 | } |
39 | |||||
40 | |||||
Jeff Thompson | a8d7b06 | 2013-08-08 15:56:35 -0700 | [diff] [blame] | 41 | } |
42 |