blob: 3a10ba5e89557d03c5750c18002198396f5286e5 [file] [log] [blame]
Jeff Thompson482fbd52013-07-15 16:45:29 -07001/**
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
11namespace 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 Thompson48abd922013-07-16 16:08:26 -070017class ElementListener : public ndn_ElementListener {
Jeff Thompson482fbd52013-07-15 16:45:29 -070018public:
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
32private:
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