#ifndef MKF_BOOK_HPP_INCLUDED
#define MKF_BOOK_HPP_INCLUDED


#include"mkf_node.hpp"




using DefinitionList = std::list<Definition>;


struct Block;


class
Book
{
  Definition  main_definition;

  DefinitionList  sub_definitions;

  struct CompareContext{
    const char*&       p0;
    const char*  const p1;

    Node*  nd;

    CompareContext(const char*&  p0_, const char*  p1_, Node*  nd_=nullptr):
    p0(p0_),
    p1(p1_),
    nd(nd_){}
  };


  bool  compare_for_any(CompareContext&  ctx, const Block&  blk) const;
  bool  compare_for_all(CompareContext&  ctx, const Block&  blk) const;

  bool  compare(CompareContext&  ctx, const Element*  elm) const;
  bool  compare(CompareContext&  ctx, const Group&    grp) const;

public:
  void  preset();

  void  append(const char*  id, Element&&  el);

  void  make(const std::string&  s);

  void  clear();

  const Definition*  find(const Identifier&  id) const;

  Node     parse(const std::string&  s) const;
  Node  subparse(const std::string&  s) const;

  void  print() const;

};




#endif




