#ifndef __Tag_h__
#define __Tag_h__

#include "ZString.h"
#include "MString.h"
#include "Global.h"
#include <map>

namespace jet {

   class Tag : public coreutils::ZString {

    public:
      Tag(coreutils::ZString &in, coreutils::MString &parent, Global &global, coreutils::ZString splitTagName = "");
      virtual ~Tag();
      coreutils::ZString name;
      coreutils::ZString container;
      coreutils::ZString container2;

    protected:
      bool hasContainer;
      bool hasContainer2;
      std::map<coreutils::ZString, coreutils::MString> variables;
      bool variableDefined(coreutils::ZString variable);
      void parseContainer(coreutils::ZString &in);
      void processContainer(coreutils::ZString &container);
      void copyContainer(coreutils::ZString &in, coreutils::MString &out);

      Global &global;
      coreutils::MString &parent;

      coreutils::MString out;

      bool output = true;
      bool evaluate = true;
      bool filterBlankLines = false;
      bool trimLines = false;
      bool cleanWhitespace = false;

    private:
      coreutils::ZString splitTagName;

      int skipBlankLine(coreutils::ZString in);

      void scanContainer(coreutils::ZString &in);
      bool ifNested(coreutils::ZString &in);
      bool ifTagName(coreutils::ZString &in, const char *tag);
      bool ifTagName(coreutils::ZString &in);
      bool ifEndTagName(coreutils::ZString &in);
      bool ifSplitTagName(coreutils::ZString &in);

   };

}

#endif
