api-changes: Use ndn-cpp-dev
Change-Id: I4540e601106598d51601e59e5fe9524a9080a572
diff --git a/src/profile-data.cpp b/src/profile-data.cpp
index 2288f9d..98ce957 100644
--- a/src/profile-data.cpp
+++ b/src/profile-data.cpp
@@ -9,16 +9,16 @@
*/
#include "profile-data.h"
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include "logging.h"
+#include "logging.h"
using namespace ndn;
using namespace std;
-using namespace boost::posix_time;
INIT_LOGGER("ProfileData");
+namespace chronos{
+
ProfileData::ProfileData()
: Data()
{}
@@ -29,45 +29,26 @@
, m_profile(profile)
{
Name dataName = m_identity;
-
- time_duration now = microsec_clock::universal_time () - ptime(boost::gregorian::date (1970, boost::gregorian::Jan, 1));
- uint64_t version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244));
- dataName.append("PROFILE").appendVersion(version);
+ dataName.append("PROFILE").appendVersion();
setName(dataName);
- string content;
- profile.encode(&content);
- setContent((const uint8_t *)&content[0], content.size());
-
+ OBufferStream os;
+ profile.encode(os);
+ setContent(os.buf());
}
-// ProfileData::ProfileData(const ProfileData& profileData)
-// : Data(profileData)
-// , m_identity(profileData.m_identity)
-// , m_profile(profileData.m_profile)
-// {}
-
ProfileData::ProfileData(const Data& data)
: Data(data)
{
- const Name& dataName = data.getName();
- Name::Component appFlag(Name::fromEscapedString("PROFILE"));
-
- int profileIndex = -1;
- for(int i = 0; i < dataName.size(); i++)
- {
- if(0 == dataName.get(i).compare(appFlag))
- {
- profileIndex = i;
- break;
- }
- }
-
- if(profileIndex < 0)
+ if(data.getName().get(-2).toEscapedString() == "PROFILE")
throw Error("No PROFILE component in data name!");
- m_identity = dataName.getPrefix(profileIndex);
+ m_identity = data.getName().getPrefix(-2);
- string encoded(reinterpret_cast<const char*>(data.getContent().value()), data.getContent().value_size());
- m_profile = *Profile::decode(encoded);
+ boost::iostreams::stream <boost::iostreams::array_source> is
+ (reinterpret_cast<const char*>(data.getContent().value()), data.getContent().value_size());
+
+ m_profile.decode(is);
}
+
+}//chronos