Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 6 | #ifndef NDN_BINARYXMLWIREFORMAT_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 7 | #define NDN_BINARYXMLWIREFORMAT_HPP |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 8 | |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 9 | #include "wire-format.hpp" |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 10 | |
| 11 | namespace ndn { |
| 12 | |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame^] | 13 | /** |
| 14 | * A BinaryXmlWireFormat extends WireFormat to override its virtual methods to implement encoding and decoding |
| 15 | * using binary XML. |
| 16 | */ |
Jeff Thompson | f0fea00 | 2013-07-30 17:22:42 -0700 | [diff] [blame] | 17 | class BinaryXmlWireFormat : public WireFormat { |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 18 | public: |
Jeff Thompson | b0979fd | 2013-07-30 15:48:21 -0700 | [diff] [blame] | 19 | virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeInterest(const Interest &interest); |
Jeff Thompson | 7c30eda | 2013-07-03 18:37:07 -0700 | [diff] [blame] | 20 | virtual void decodeInterest(Interest &interest, const unsigned char *input, unsigned int inputLength); |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 21 | |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame^] | 22 | /** |
| 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 Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | } |
| 51 | |
| 52 | #endif |
| 53 | |