blob: ef0f9a285c63673b382968bb944c682ba8d37239 [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
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07007#define NDN_BINARYXMLELEMENTREADER_HPP
Jeff Thompson482fbd52013-07-15 16:45:29 -07008
Jeff Thompson53412192013-08-06 13:35:50 -07009#include "../c/encoding/binary-xml-element-reader.h"
Jeff Thompson482fbd52013-07-15 16:45:29 -070010
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 */
Jeff Thompson8b173cc2013-08-21 17:54:12 -070030 virtual void onReceivedElement(const unsigned char *element, unsigned int elementLength) = 0;
Jeff Thompson482fbd52013-07-15 16:45:29 -070031
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