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 | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 31 | virtual void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame^] | 32 | onReceivedElement(const uint8_t *element, unsigned int elementLength) = 0; |
Jeff Thompson | 482fbd5 | 2013-07-15 16:45:29 -0700 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | /** |
| 36 | * Call the virtual method onReceivedElement. This is used to initialize the base ndn_ElementListener struct. |
| 37 | * @param self |
| 38 | * @param element |
| 39 | * @param elementLength |
| 40 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 41 | static void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame^] | 42 | staticOnReceivedElement(struct ndn_ElementListener *self, uint8_t *element, unsigned int elementLength); |
Jeff Thompson | 482fbd5 | 2013-07-15 16:45:29 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | } |
| 46 | |
| 47 | #endif |