blob: 7266957d172607e22865ef99485c73d8f216b653 [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 Thompsonb0979fd2013-07-30 15:48:21 -070019 virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeInterest(const Interest &interest);
Jeff Thompson7c30eda2013-07-03 18:37:07 -070020 virtual void decodeInterest(Interest &interest, const unsigned char *input, unsigned int inputLength);
Jeff Thompson5cae5e52013-07-10 19:41:20 -070021
Jeff Thompsonc87f39a2013-08-12 11:55:11 -070022 /**
23 * Encode data with binary XML and return the encoding.
24 * @param data The Data object to encode.
25 * @param signedFieldsBeginOffset Return the offset in the encoding of the beginning of the fields which are signed.
26 * If you are not encoding in order to sign, you can call encodeData(const Data &data) to ignore this returned value.
27 * @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed.
28 * If you are not encoding in order to sign, you can call encodeData(const Data &data) to ignore this returned value.
29 * @return A shared_ptr with the vector<unsigned char> containing the encoding.
30 */
31 virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeData
32 (const Data &data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset);
33
34 /**
35 * Decode input as a data packet in binary XML and set the fields in the data object.
36 * @param data The Data object whose fields are updated.
37 * @param input A pointer to the input buffer to decode.
38 * @param inputLength The number of bytes in input.
39 * @param signedFieldsBeginOffset Return the offset in the input buffer of the beginning of the fields which are signed.
40 * If you are not decoding in order to verify, you can call
41 * decodeData(Data &data, const unsigned char *input, unsigned int inputLength) to ignore this returned value.
42 * @param signedFieldsEndOffset Return the offset in the input buffer of the end of the fields which are signed.
43 * If you are not decoding in order to verify, you can call
44 * decodeData(Data &data, const unsigned char *input, unsigned int inputLength) to ignore this returned value.
45 */
46 virtual void decodeData
47 (Data &data, const unsigned char *input, unsigned int inputLength, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset);
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070048};
49
50}
51
52#endif
53