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

#ifndef BINARYXMLSTRUCTUREDECODER_HPP
#define	BINARYXMLSTRUCTUREDECODER_HPP

#include <stdexcept>
#include "../c/encoding/BinaryXMLStructureDecoder.h"

namespace ndn {
  
/**
 * A BinaryXMLStructureDecoder wraps a C ndn_BinaryXMLStructureDecoder struct 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 */

