#include "ccnx-pco.h"

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);
  if (res < 0)
  {
    boost::throw_exception(MisformedContentObjectException());
  }
  readRaw(m_bytes, data, len);
}

ParsedContentObject::ParsedContentObject(const Bytes &bytes)
{
  ParsedContentObject(head(bytes), bytes.size());
}

ParsedContentObject::ParsedContentObject(const ParsedContentObject &other)
{
  ParsedContentObject(other.m_bytes);
}

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;
}

string
ParsedContentObject::name() const
{
  return CcnxWrapper::extractName(head(m_bytes), m_comps);
}

}
