Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | f4cde4e | 2016-12-25 13:42:57 -0800 | [diff] [blame^] | 25 | #include "sync-state.pb.hpp" |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 26 | |
| 27 | inline std::ostream & |
| 28 | operator << (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 Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 43 | 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 Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 45 | << ", 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 |