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 |
| 7 | #define NDN_BINARYXMLELEMENTREADER_HPP |
| 8 | |
| 9 | #include "../c/encoding/BinaryXMLElementReader.h" |
| 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 | */ |
| 17 | class ElementListener : private ndn_ElementListener { |
| 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 |