blob: 826eb50e979014cf9202c09a439e93357c6afcfa [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 {
Jeff Thompsond1427fb2013-08-29 17:20:32 -070021 ndn_ElementListener_initialize(this, staticOnReceivedElement);
Jeff Thompson482fbd52013-07-15 16:45:29 -070022 }
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