/* -*- c++ -*- */
#ifndef AKAXISO_SEQUENCE_HANDLER_H__
#define AKAXISO_SEQUENCE_HANDLER_H__

/** @file akaxiso/parser/seqquence_handler.h */

#include <akaxiso/parser/handler.h>
#include <akaxiso/classes/member_cache.h>

namespace aka2 {

  class sequence_handler : public handler {
    friend class closure_handler;
  public:
    sequence_handler(const qname& tagname, void *seq, int depth,
		     const sequence_op& sop, 
		     parser_context &context);
    sequence_handler(const qname& tagname, sequence_handler *seqhandler, int depth);

    virtual ~sequence_handler(){}
    virtual parse_result query_element(const qname &tagname, const attribute_values &attrs);
    virtual parse_result end_element(const qname &tagname);
    virtual parse_result query_next(const qname &tagname, const attribute_values &attrs);
    virtual bool parse_entity(const std::string &entity);

    virtual node get_node();
    virtual void receive_child(const node &child);
    virtual bool can_skip();
    virtual void abort();
    
  private:
    parse_result parse_element(const qname &tagname, const attribute_values &attrs,
			       member_types::const_iterator &it);
    parse_result find_particle(const qname &tagname, const attribute_values &attrs,
			       member_types::const_iterator &it);
   
    bool can_skip_member();


    void *seq_;
    const sequence_op &sop_;
    member_types::const_iterator itend_;
    member_types::const_iterator current_;
    member_cache cache_;
  };

} // namespace aka2

#endif /* AKAXISO_SEQUENCE_HANDLER_H__ */
