/* 
 * File:   test-no-boost.cpp
 * Author: jefft0
 *
 * Created on June 10, 2013, 4:21 PM
 */

#include <cstdlib>
#include <sstream>
#include <iostream>
#include "../ndn-cpp/interest.h"
#include "../ndn-cpp/encoding/ccnb.h"
#include "../ndn-cpp/encoding/BinaryXMLStructureDecoder.hpp"

using namespace std;
using namespace ndn;

const unsigned char Interest1[] = {
0x01, 0xd2,
  0xf2, 0xfa, 0x9d, 0x6e, 0x64, 0x6e, 0x00, 0xfa, 0x9d, 0x61, 0x62, 0x63, 0x00, 0x00, 
  0x05, 0x9a, 0x8e, 0x32, 0x00, 
  0x05, 0xa2, 0x8e, 0x34, 0x00,
  0x03, 0xe2, 
    0x02, 0x85, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 
  0x00,
  0x02, 0xda, 0xfa, 0x9d, 0x61, 0x62, 0x63, 0x00, 0xea, 0x00, 0x00, 0x05, 0xaa, 0x8e, 0x31, 0x00, 0x02,
  0xfa, 0x8e, 0x34, 0x00, 0x02, 0xd2, 0x8e, 0x32, 0x00, 0x03, 0x82, 0x9d, 0x01, 0xe0, 0x00, 0x00, 0x02, 0xca, 0xb5, 0x61,
  0x62, 0x61, 0x62, 0x61, 0x62, 0x00, 
0x00, 
1
};

/*
 * 
 */
int main(int argc, char** argv)
{
  try {
  BinaryXMLStructureDecoder structureDecoder;
  for (unsigned int i = 1; i <= sizeof(Interest1); ++i) {
    if (structureDecoder.findElementEnd(Interest1, i)) {
      cout << "got element end at " << structureDecoder.getOffset() << " vs. sizeof(Interest1) " << sizeof(Interest1) << endl;
      break;
    }
  }
  } catch (exception &e) {
    cout << "exception " << e.what() << endl;
  }
  
  ndn::ptr_lib::shared_ptr<Interest> interest(new Interest());
  interest->setName(Name("/test"));
  interest->setMinSuffixComponents(2);
  interest->setMaxSuffixComponents(2);
  interest->setInterestLifetime(boost::posix_time::seconds(10));
  interest->setScope(Interest::SCOPE_LOCAL_CCND);
  interest->setAnswerOriginKind(Interest::AOK_STALE);
  interest->setChildSelector(Interest::CHILD_RIGHT);
  // i.setPublisherPublicKeyDigest(?);
  ostringstream binary;
  wire::Ccnb::appendInterest(binary, *interest);
  cout << binary.str().size() << endl;
  
  return 0;
}
