blob: 673deaf2fbc9f07b24d9726a3b1f4d68bc48d891 [file] [log] [blame]
Jeff Thompson3b3aabf2013-06-21 16:50:20 -07001/*
2 * File: test-no-boost.cpp
3 * Author: jefft0
4 *
5 * Created on June 10, 2013, 4:21 PM
6 */
7
8#include <cstdlib>
9#include <sstream>
10#include <iostream>
Jeff Thompson7afc98e2013-06-27 14:33:53 -070011#include "../ndn-cpp/interest.h"
12#include "../ndn-cpp/encoding/ccnb.h"
13#include "../ndn-cpp/encoding/BinaryXMLStructureDecoder.hpp"
Jeff Thompson3b3aabf2013-06-21 16:50:20 -070014
15using namespace std;
16using namespace ndn;
17
Jeff Thompson7afc98e2013-06-27 14:33:53 -070018const unsigned char Interest1[] = {
190x01, 0xd2,
20 0xf2, 0xfa, 0x9d, 0x6e, 0x64, 0x6e, 0x00, 0xfa, 0x9d, 0x61, 0x62, 0x63, 0x00, 0x00,
21 0x05, 0x9a, 0x8e, 0x32, 0x00,
22 0x05, 0xa2, 0x8e, 0x34, 0x00,
23 0x03, 0xe2,
24 0x02, 0x85, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
25 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
26 0x00,
27 0x02, 0xda, 0xfa, 0x9d, 0x61, 0x62, 0x63, 0x00, 0xea, 0x00, 0x00, 0x05, 0xaa, 0x8e, 0x31, 0x00, 0x02,
28 0xfa, 0x8e, 0x34, 0x00, 0x02, 0xd2, 0x8e, 0x32, 0x00, 0x03, 0x82, 0x9d, 0x01, 0xe0, 0x00, 0x00, 0x02, 0xca, 0xb5, 0x61,
29 0x62, 0x61, 0x62, 0x61, 0x62, 0x00,
300x00,
311
32};
33
Jeff Thompson3b3aabf2013-06-21 16:50:20 -070034/*
35 *
36 */
Jeff Thompson7afc98e2013-06-27 14:33:53 -070037int main(int argc, char** argv)
38{
39 try {
40 BinaryXMLStructureDecoder structureDecoder;
41 for (unsigned int i = 1; i <= sizeof(Interest1); ++i) {
42 if (structureDecoder.findElementEnd(Interest1, i)) {
43 cout << "got element end at " << structureDecoder.getOffset() << " vs. sizeof(Interest1) " << sizeof(Interest1) << endl;
44 break;
45 }
46 }
47 } catch (exception &e) {
48 cout << "exception " << e.what() << endl;
49 }
50
Jeff Thompson3b3aabf2013-06-21 16:50:20 -070051 ndn::ptr_lib::shared_ptr<Interest> interest(new Interest());
52 interest->setName(Name("/test"));
53 interest->setMinSuffixComponents(2);
54 interest->setMaxSuffixComponents(2);
55 interest->setInterestLifetime(boost::posix_time::seconds(10));
56 interest->setScope(Interest::SCOPE_LOCAL_CCND);
57 interest->setAnswerOriginKind(Interest::AOK_STALE);
58 interest->setChildSelector(Interest::CHILD_RIGHT);
59 // i.setPublisherPublicKeyDigest(?);
60 ostringstream binary;
61 wire::Ccnb::appendInterest(binary, *interest);
Jeff Thompson7afc98e2013-06-27 14:33:53 -070062 cout << binary.str().size() << endl;
Jeff Thompson3b3aabf2013-06-21 16:50:20 -070063
64 return 0;
65}