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