blob: 7bcf3f451a3b9a6bff4ddd2d6b190b309969c00c [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
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080026inline std::ostream&
27operator<<(std::ostream& os, const SyncStateMsgPtr& msg)
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080028{
29 os << " ===== start Msg ======" << std::endl;
30
31 int size = msg->state_size();
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080032 if (size > 0) {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080033 int index = 0;
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080034 while (index < size) {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080035 SyncState state = msg->state(index);
36 string strName = state.name();
37 string strLocator = state.locator();
38 sqlite3_int64 seq = state.seq();
39
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080040 os << "Name: " << Ccnx::Name((const unsigned char*)strName.c_str(), strName.size())
41 << ", Locator: " << Ccnx::Name((const unsigned char*)strLocator.c_str(), strLocator.size())
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080042 << ", seq: " << seq << std::endl;
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080043 index++;
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080044 }
45 }
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080046 else {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080047 os << "Msg size 0" << std::endl;
48 }
49 os << " ++++++++ end Msg ++++++++ " << std::endl;
50
51 return os;
52}
53
54
55#endif // SYNC_STATE_HELPER_H