Revert "puzzle"
This reverts commit b7aba368f9afa5bc1a93ab342c748f730aa64cf8.
diff --git a/src/ccnx-pco.cpp b/src/ccnx-pco.cpp
index 1d83b26..dce3bcb 100644
--- a/src/ccnx-pco.cpp
+++ b/src/ccnx-pco.cpp
@@ -3,27 +3,15 @@
namespace Ccnx {
ParsedContentObject::ParsedContentObject(const unsigned char *data, size_t len)
+ : m_comps(NULL)
{
- ccn_indexbuf *comps = ccn_indexbuf_create();
- ccn_parsed_ContentObject pco;
- int res = ccn_parse_ContentObject(data, len, &pco, comps);
+ m_comps = ccn_indexbuf_create();
+ int res = ccn_parse_ContentObject(data, len, &m_pco, m_comps);
if (res < 0)
{
boost::throw_exception(MisformedContentObjectException());
}
-
- const unsigned char *content;
- size_t length;
- res = ccn_content_get_value(data, pco.offset[CCN_PCO_E], &pco, &content, &length);
- if (res < 0)
- {
- boost::throw_exception(MisformedContentObjectException());
- }
- readRaw(m_content, content, length);
-
- m_name = Name(data, comps);
- cout << "in Constructor: name " << m_name << endl;
- cout << "content : " << string((const char *)&m_content[0], m_content.size()) << endl;
+ readRaw(m_bytes, data, len);
}
ParsedContentObject::ParsedContentObject(const Bytes &bytes)
@@ -33,26 +21,35 @@
ParsedContentObject::ParsedContentObject(const ParsedContentObject &other)
{
- m_content = other.m_content;
- m_name = other.m_name;
+ ParsedContentObject(other.m_bytes);
}
ParsedContentObject::~ParsedContentObject()
{
+ ccn_indexbuf_destroy(&m_comps);
+ m_comps = NULL;
}
Bytes
ParsedContentObject::content() const
{
- cout << "content() : " << string((const char *)&m_content[0], m_content.size()) << endl;
- return m_content;
+ const unsigned char *content;
+ size_t len;
+ Bytes bytes;
+ int res = ccn_content_get_value(head(m_bytes), m_pco.offset[CCN_PCO_E], &m_pco, &content, &len);
+ if (res < 0)
+ {
+ boost::throw_exception(MisformedContentObjectException());
+ }
+
+ readRaw(bytes, content, len);
+ return bytes;
}
Name
ParsedContentObject::name() const
{
- cout <<"name() : " << m_name << endl;
- return m_name;
+ return Name(head(m_bytes), m_comps);
}
}