Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2016, Regents of the University of California. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 5 | * This file is part of ChronoShare, a decentralized file sharing application over NDN. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 7 | * ChronoShare is free software: you can redistribute it and/or modify it under the terms |
| 8 | * of the GNU General Public License as published by the Free Software Foundation, either |
| 9 | * version 3 of the License, or (at your option) any later version. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 11 | * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 14 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 15 | * You should have received copies of the GNU General Public License along with |
| 16 | * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * See AUTHORS.md for complete list of ChronoShare authors and contributors. |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #ifndef SYNC_STATE_HELPER_H |
| 22 | #define SYNC_STATE_HELPER_H |
| 23 | |
Alexander Afanasyev | f4cde4e | 2016-12-25 13:42:57 -0800 | [diff] [blame] | 24 | #include "sync-state.pb.hpp" |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 25 | |
| 26 | inline std::ostream & |
| 27 | operator << (std::ostream &os, const SyncStateMsgPtr &msg) |
| 28 | { |
| 29 | os << " ===== start Msg ======" << std::endl; |
| 30 | |
| 31 | int size = msg->state_size(); |
| 32 | if (size > 0) |
| 33 | { |
| 34 | int index = 0; |
| 35 | while (index < size) |
| 36 | { |
| 37 | SyncState state = msg->state(index); |
| 38 | string strName = state.name(); |
| 39 | string strLocator = state.locator(); |
| 40 | sqlite3_int64 seq = state.seq(); |
| 41 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 42 | os << "Name: " << Ndnx::Name((const unsigned char *)strName.c_str(), strName.size()) |
| 43 | << ", Locator: " << Ndnx::Name((const unsigned char *)strLocator.c_str(), strLocator.size()) |
Alexander Afanasyev | 49a30d0 | 2013-01-21 21:38:48 -0800 | [diff] [blame] | 44 | << ", seq: " << seq << std::endl; |
| 45 | index ++; |
| 46 | } |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | os << "Msg size 0" << std::endl; |
| 51 | } |
| 52 | os << " ++++++++ end Msg ++++++++ " << std::endl; |
| 53 | |
| 54 | return os; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | #endif // SYNC_STATE_HELPER_H |