use protobuf instead of tinyxml
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 943126b..b72a061 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -29,6 +29,7 @@
#include "sync-diff-leaf.h"
#include "sync-full-leaf.h"
#include "sync-log.h"
+#include "sync-state.h"
#include <boost/make_shared.hpp>
#include <boost/foreach.hpp>
@@ -278,10 +279,10 @@
DiffState diff;
SyncStateMsg msg;
- if (!msg.parseFromArray(wireData, len) || !msg.IsInitialized())
+ if (!msg.ParseFromArray(wireData, len) || !msg.IsInitialized())
{
//Throw
- BOOST_THROW_EXCEPTION (SyncStateMsgDecodingFailure () << info_str ("Can not decode data"));
+ BOOST_THROW_EXCEPTION (Error::SyncStateMsgDecodingFailure () );
}
msg >> diff;
@@ -526,11 +527,12 @@
// sending
SyncStateMsg ssm;
ssm << (*state);
- char *wireData = new char[ssm.size()];
- ssm.SerializedToArray(wireData, ssm.size());
+ int size = ssm.ByteSize();
+ char *wireData = new char[size];
+ ssm.SerializeToArray(wireData, size);
m_ccnxHandle->publishRawData (name,
wireData,
- ssm.size(),
+ size,
m_syncResponseFreshness); // in NS-3 it doesn't have any effect... yet
delete wireData;
diff --git a/model/sync-state.cc b/model/sync-state.cc
index 45a7ab7..137e8b0 100644
--- a/model/sync-state.cc
+++ b/model/sync-state.cc
@@ -74,9 +74,9 @@
{
BOOST_FOREACH (shared_ptr<const Leaf> leaf, state.getLeaves ().get<ordered> ())
{
- SyncState *oss = ossm->add_ss();
+ SyncState *oss = ossm.add_ss();
shared_ptr<const DiffLeaf> diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
- if (diffLeaf != 0 && diffLeaf->getOperation != UPDATE)
+ if (diffLeaf != 0 && diffLeaf->getOperation() != UPDATE)
{
oss->set_type(SyncState::DELETE);
}
@@ -91,10 +91,9 @@
if (diffLeaf == 0 || (diffLeaf != 0 && diffLeaf->getOperation () == UPDATE))
{
- SyncState::SeqNo seqNo;
- seqNo->set_session(leaf->getSeq()->getSession());
- seqNo->set_seq(leaf->getSeq()->getSeq());
- oss->set_seqNo(seqNo);
+ SyncState::SeqNo *seqNo = oss->mutable_seqno();
+ seqNo->set_session(leaf->getSeq().getSession());
+ seqNo->set_seq(leaf->getSeq().getSeq());
}
}
return ossm;
@@ -150,7 +149,7 @@
*/
SyncStateMsg &
-operator >> (SyncStateMsg &issm, const State &state)
+operator >> (SyncStateMsg &issm, State &state)
{
int n = issm.ss_size();
for (int i = 0; i < n; i++)
@@ -159,10 +158,10 @@
NameInfoConstPtr info = StdNameInfo::FindOrCreate (ss.name());
if (ss.type() == SyncState::UPDATE)
{
- state.update(info, SeqNo(
- lexical_cast<uint32_t> (ss.seqNo().session()),
- lexical_cast<uint32_t> (ss.seqNo().seq()),
- ));
+ uint32_t session = lexical_cast<uint32_t>(ss.seqno().session());
+ uint32_t seq = lexical_cast<uint32_t>(ss.seqno().seq());
+ SeqNo seqNo(session, seq);
+ state.update(info, seqNo);
}
else
{