blob: 68be55029add4d433614961c4bea1e1560d8c82a [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07004 */
5
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07006#ifndef NDN_BINARYXMLWIREFORMAT_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07007#define NDN_BINARYXMLWIREFORMAT_HPP
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07008
Jeff Thompson53412192013-08-06 13:35:50 -07009#include "wire-format.hpp"
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070010
11namespace ndn {
12
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070013/**
14 * A BinaryXmlWireFormat extends WireFormat to override its virtual methods to implement encoding and decoding
15 * using binary XML.
16 */
Jeff Thompsonf0fea002013-07-30 17:22:42 -070017class BinaryXmlWireFormat : public WireFormat {
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070018public:
Jeff Thompson990599b2013-08-27 15:14:25 -070019 /**
20 * Encode interest in binary XML and return the encoding.
21 * @param interest The Interest object to encode.
22 * @return A shared_ptr with the vector<unsigned char> containing the encoding.
23 */
Jeff Thompsonb0979fd2013-07-30 15:48:21 -070024 virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeInterest(const Interest &interest);
Jeff Thompson990599b2013-08-27 15:14:25 -070025
26 /**
27 * Decode input as an interest in binary XML and set the fields of the interest object.
28 * @param interest The Interest object whose fields are updated.
29 * @param input A pointer to the input buffer to decode.
30 * @param inputLength The number of bytes in input.
31 */
Jeff Thompson7c30eda2013-07-03 18:37:07 -070032 virtual void decodeInterest(Interest &interest, const unsigned char *input, unsigned int inputLength);
Jeff Thompson5cae5e52013-07-10 19:41:20 -070033
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070034 /**
35 * Encode data with binary XML and return the encoding.
36 * @param data The Data object to encode.
37 * @param signedFieldsBeginOffset Return the offset in the encoding of the beginning of the fields which are signed.
38 * If you are not encoding in order to sign, you can call encodeData(const Data &data) to ignore this returned value.
39 * @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed.
40 * If you are not encoding in order to sign, you can call encodeData(const Data &data) to ignore this returned value.
41 * @return A shared_ptr with the vector<unsigned char> containing the encoding.
42 */
43 virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeData
44 (const Data &data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset);
45
46 /**
47 * Decode input as a data packet in binary XML and set the fields in the data object.
48 * @param data The Data object whose fields are updated.
49 * @param input A pointer to the input buffer to decode.
50 * @param inputLength The number of bytes in input.
51 * @param signedFieldsBeginOffset Return the offset in the input buffer of the beginning of the fields which are signed.
52 * If you are not decoding in order to verify, you can call
53 * decodeData(Data &data, const unsigned char *input, unsigned int inputLength) to ignore this returned value.
54 * @param signedFieldsEndOffset Return the offset in the input buffer of the end of the fields which are signed.
55 * If you are not decoding in order to verify, you can call
56 * decodeData(Data &data, const unsigned char *input, unsigned int inputLength) to ignore this returned value.
57 */
58 virtual void decodeData
59 (Data &data, const unsigned char *input, unsigned int inputLength, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset);
Jeff Thompson990599b2013-08-27 15:14:25 -070060
61 /**
62 * Encode forwardingEntry in binary XML and return the encoding.
63 * @param forwardingEntry The ForwardingEntry object to encode.
64 * @return A shared_ptr with the vector<unsigned char> containing the encoding.
65 */
66 virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeForwardingEntry(const ForwardingEntry &forwardingEntry);
67
68 /**
69 * Decode input as a forwarding entry in binary XML and set the fields of the forwardingEntry object.
70 * @param forwardingEntry The ForwardingEntry object whose fields are updated.
71 * @param input A pointer to the input buffer to decode.
72 * @param inputLength The number of bytes in input.
73 */
74 virtual void decodeForwardingEntry(ForwardingEntry &forwardingEntry, const unsigned char *input, unsigned int inputLength);
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070075};
76
77}
78
79#endif
80