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 | 1656e6a | 2013-08-29 18:01:48 -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 | 1656e6a | 2013-08-29 18:01:48 -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. |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 38 | * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 39 | * @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed. |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 40 | * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 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 |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 44 | (const Data& data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset); |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 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 |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 53 | * decodeData(Data& data, const unsigned char *input, unsigned int inputLength) to ignore this returned value. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 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 |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 56 | * decodeData(Data& data, const unsigned char *input, unsigned int inputLength) to ignore this returned value. |
Jeff Thompson | c87f39a | 2013-08-12 11:55:11 -0700 | [diff] [blame] | 57 | */ |
| 58 | virtual void decodeData |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 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 | */ |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 66 | virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeForwardingEntry(const ForwardingEntry& forwardingEntry); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 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 | */ |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame^] | 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 | |