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 | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame^] | 19 | /** |
| 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 Thompson | b0979fd | 2013-07-30 15:48:21 -0700 | [diff] [blame] | 24 | virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeInterest(const Interest &interest); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame^] | 25 | |
| 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 Thompson | 7c30eda | 2013-07-03 18:37:07 -0700 | [diff] [blame] | 32 | virtual void decodeInterest(Interest &interest, const unsigned char *input, unsigned int inputLength); |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 33 | |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 34 | /** |
| 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 Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame^] | 60 | |
| 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 Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | } |
| 78 | |
| 79 | #endif |
| 80 | |