#ifndef GITPATHSPEC_H
#define GITPATHSPEC_H
// generated from class_header.h
#include <nan.h>
#include <string>

extern "C" {
#include <git2.h>
}

#include "../include/pathspec_match_list.h"
#include "../include/diff.h"
#include "../include/pathspec.h"
#include "../include/index.h"
#include "../include/diff_delta.h"
#include "../include/tree.h"
#include "../include/repository.h"
// Forward declaration.
struct git_pathspec {
};

using namespace node;
using namespace v8;

class GitPathspec : public ObjectWrap {
  public:

    static Persistent<Function> constructor_template;
    static void InitializeComponent (Handle<v8::Object> target);

    git_pathspec *GetValue();
    git_pathspec **GetRefValue();

    static Handle<Value> New(void *raw, bool selfFreeing);
    bool selfFreeing;

  private:
    GitPathspec(git_pathspec *raw, bool selfFreeing);
    ~GitPathspec();

    static NAN_METHOD(JSNewFunction);


    struct MatchDiffBaton {
      int error_code;
      const git_error* error;
      git_pathspec_match_list * out;
      git_diff * diff;
      uint32_t flags;
      git_pathspec * ps;
    };
    class MatchDiffWorker : public NanAsyncWorker {
      public:
        MatchDiffWorker(
            MatchDiffBaton *_baton,
            NanCallback *callback
        ) : NanAsyncWorker(callback)
          , baton(_baton) {};
        ~MatchDiffWorker() {};
        void Execute();
        void HandleOKCallback();

      private:
        MatchDiffBaton *baton;
    };

    static NAN_METHOD(MatchDiff);

    struct MatchIndexBaton {
      int error_code;
      const git_error* error;
      git_pathspec_match_list * out;
      git_index * index;
      uint32_t flags;
      git_pathspec * ps;
    };
    class MatchIndexWorker : public NanAsyncWorker {
      public:
        MatchIndexWorker(
            MatchIndexBaton *_baton,
            NanCallback *callback
        ) : NanAsyncWorker(callback)
          , baton(_baton) {};
        ~MatchIndexWorker() {};
        void Execute();
        void HandleOKCallback();

      private:
        MatchIndexBaton *baton;
    };

    static NAN_METHOD(MatchIndex);

    static NAN_METHOD(MatchListDiffEntry);

    static NAN_METHOD(MatchListEntry);

    static NAN_METHOD(MatchListEntrycount);

    static NAN_METHOD(MatchListFailedEntry);

    static NAN_METHOD(MatchListFailedEntrycount);

    static NAN_METHOD(MatchListFree);

    struct MatchTreeBaton {
      int error_code;
      const git_error* error;
      git_pathspec_match_list * out;
      git_tree * tree;
      uint32_t flags;
      git_pathspec * ps;
    };
    class MatchTreeWorker : public NanAsyncWorker {
      public:
        MatchTreeWorker(
            MatchTreeBaton *_baton,
            NanCallback *callback
        ) : NanAsyncWorker(callback)
          , baton(_baton) {};
        ~MatchTreeWorker() {};
        void Execute();
        void HandleOKCallback();

      private:
        MatchTreeBaton *baton;
    };

    static NAN_METHOD(MatchTree);

    struct MatchWorkdirBaton {
      int error_code;
      const git_error* error;
      git_pathspec_match_list * out;
      git_repository * repo;
      uint32_t flags;
      git_pathspec * ps;
    };
    class MatchWorkdirWorker : public NanAsyncWorker {
      public:
        MatchWorkdirWorker(
            MatchWorkdirBaton *_baton,
            NanCallback *callback
        ) : NanAsyncWorker(callback)
          , baton(_baton) {};
        ~MatchWorkdirWorker() {};
        void Execute();
        void HandleOKCallback();

      private:
        MatchWorkdirBaton *baton;
    };

    static NAN_METHOD(MatchWorkdir);

    static NAN_METHOD(MatchesPath);
    git_pathspec *raw;
};

#endif
