Jeff Thompson | 482fbd5 | 2013-07-15 16:45:29 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NDN_BINARYXMLELEMENTREADER_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 7 | #define NDN_BINARYXMLELEMENTREADER_HPP |
Jeff Thompson | 482fbd5 | 2013-07-15 16:45:29 -0700 | [diff] [blame] | 8 | |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 9 | #include "../c/encoding/binary-xml-element-reader.h" |
Jeff Thompson | 482fbd5 | 2013-07-15 16:45:29 -0700 | [diff] [blame] | 10 | |
| 11 | namespace ndn { |
| 12 | |
| 13 | /** |
| 14 | * An ElementListener extends an ndn_ElementListener struct to proved an abstract virtual onReceivedElement function which wraps |
| 15 | * the onReceivedElement used by the ndn_ElementListener struct. You must extend this class to override onReceivedElement. |
| 16 | */ |
Jeff Thompson | 48abd92 | 2013-07-16 16:08:26 -0700 | [diff] [blame] | 17 | class ElementListener : public ndn_ElementListener { |
Jeff Thompson | 482fbd5 | 2013-07-15 16:45:29 -0700 | [diff] [blame] | 18 | public: |
| 19 | ElementListener() |
| 20 | { |
| 21 | ndn_ElementListener_init(this, staticOnReceivedElement); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * This is called when an entire binary XML element is received. You must extend this class to override this method. |
| 26 | * @param element pointer to the binary XML element. This buffer is only valid during this call. If you need the data |
| 27 | * later, you must copy. |
| 28 | * @param elementLength length of element |
| 29 | */ |
| 30 | virtual void onReceivedElement(unsigned char *element, unsigned int elementLength) = 0; |
| 31 | |
| 32 | private: |
| 33 | /** |
| 34 | * Call the virtual method onReceivedElement. This is used to initialize the base ndn_ElementListener struct. |
| 35 | * @param self |
| 36 | * @param element |
| 37 | * @param elementLength |
| 38 | */ |
| 39 | static void staticOnReceivedElement(struct ndn_ElementListener *self, unsigned char *element, unsigned int elementLength); |
| 40 | }; |
| 41 | |
| 42 | } |
| 43 | |
| 44 | #endif |