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