blob: f2a86ff9eb8c8988ab9a9f394b48c97bdd387e04 [file] [log] [blame]
/**
* Copyright (C) 2013 Regents of the University of California.
* @author: Jeff Thompson <jefft0@remap.ucla.edu>
* See COPYING for copyright and distribution information.
*/
#ifndef NDN_BINARYXMLELEMENTREADER_HPP
#define NDN_BINARYXMLELEMENTREADER_HPP
#include "../c/encoding/binary-xml-element-reader.h"
namespace ndn {
/**
* An ElementListener extends an ndn_ElementListener struct to proved an abstract virtual onReceivedElement function which wraps
* the onReceivedElement used by the ndn_ElementListener struct. You must extend this class to override onReceivedElement.
*/
class ElementListener : public ndn_ElementListener {
public:
ElementListener()
{
ndn_ElementListener_initialize(this, staticOnReceivedElement);
}
/**
* This is called when an entire binary XML element is received. You must extend this class to override this method.
* @param element pointer to the binary XML element. This buffer is only valid during this call. If you need the data
* later, you must copy.
* @param elementLength length of element
*/
virtual void onReceivedElement(const unsigned char *element, unsigned int elementLength) = 0;
private:
/**
* Call the virtual method onReceivedElement. This is used to initialize the base ndn_ElementListener struct.
* @param self
* @param element
* @param elementLength
*/
static void staticOnReceivedElement(struct ndn_ElementListener *self, unsigned char *element, unsigned int elementLength);
};
}
#endif