/* 
 * Author: Jeff Thompson
 *
 * BSD license, See the LICENSE file for more information.
 */

#ifndef BINARYXMLSTRUCTUREDECODER_HPP
#define	BINARYXMLSTRUCTUREDECODER_HPP

#include <stdexcept>
#include "BinaryXMLStructureDecoder.h"

namespace ndn {
  
/**
 * A BinaryXMLStructureDecoder wraps a C struct ndn_BinaryXMLStructureDecoder and
 * related functions.
 */
class BinaryXMLStructureDecoder {
public:
  BinaryXMLStructureDecoder() {
    ndn_BinaryXMLStructureDecoder_init(&base_);
  }
  
  /**
   * Continue scanning input starting from getOffset() to find the element end.  
   * If the end of the element which started at offset 0 is found, then return true and getOffset() is the length of 
   *   the element.  Otherwise return false, which means you should read more into input and call again.
   * @param input the input buffer. You have to pass in input each time because the buffer could be reallocated.
   * @param inputLength the number of bytes in input.
   * @return true if found the element end, false if need to read more. (This is the same as returning gotElementEnd().)
   */
  bool findElementEnd(unsigned char *input, unsigned int inputLength) {
    char *error;
    if (error = ndn_BinaryXMLStructureDecoder_findElementEnd(&base_, input, inputLength))
      throw std::runtime_error(error);
    return gotElementEnd();
  }
  
  unsigned int getOffset() { return base_.
          offset; }
  bool gotElementEnd() { return base_.gotElementEnd != 0; }
  
private:
  struct ndn_BinaryXMLStructureDecoder base_;
};

}

#endif	/* BINARYXMLSTRUCTUREDECODER_HPP */

