blob: b59af8face232f2fd9819c8c5c29286f2305f2d2 [file] [log] [blame]
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016, Regents of the University of California.
Alexander Afanasyev49a30d02013-01-21 21:38:48 -08004 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08005 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
Alexander Afanasyev49a30d02013-01-21 21:38:48 -08006 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08007 * 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 Afanasyev49a30d02013-01-21 21:38:48 -080010 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080011 * 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 Afanasyev49a30d02013-01-21 21:38:48 -080014 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080015 * 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 Afanasyev49a30d02013-01-21 21:38:48 -080019 */
20
21#ifndef SYNC_STATE_HELPER_H
22#define SYNC_STATE_HELPER_H
23
Alexander Afanasyevf4cde4e2016-12-25 13:42:57 -080024#include "sync-state.pb.hpp"
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080025
26inline std::ostream &
27operator << (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 Afanasyev1dd37ed2013-08-14 18:08:09 -070042 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 Afanasyev49a30d02013-01-21 21:38:48 -080044 << ", 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