blob: 09d9c9e88d065a294be192f52b11c46aa8376713 [file] [log] [blame]
Alexander Afanasyev49a30d02013-01-21 21:38:48 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Zhenkai Zhu <zhenkai@cs.ucla.edu>
20 */
21
22#ifndef SYNC_STATE_HELPER_H
23#define SYNC_STATE_HELPER_H
24
Alexander Afanasyevf4cde4e2016-12-25 13:42:57 -080025#include "sync-state.pb.hpp"
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080026
27inline std::ostream &
28operator << (std::ostream &os, const SyncStateMsgPtr &msg)
29{
30 os << " ===== start Msg ======" << std::endl;
31
32 int size = msg->state_size();
33 if (size > 0)
34 {
35 int index = 0;
36 while (index < size)
37 {
38 SyncState state = msg->state(index);
39 string strName = state.name();
40 string strLocator = state.locator();
41 sqlite3_int64 seq = state.seq();
42
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070043 os << "Name: " << Ndnx::Name((const unsigned char *)strName.c_str(), strName.size())
44 << ", Locator: " << Ndnx::Name((const unsigned char *)strLocator.c_str(), strLocator.size())
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080045 << ", seq: " << seq << std::endl;
46 index ++;
47 }
48 }
49 else
50 {
51 os << "Msg size 0" << std::endl;
52 }
53 os << " ++++++++ end Msg ++++++++ " << std::endl;
54
55 return os;
56}
57
58
59#endif // SYNC_STATE_HELPER_H