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

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

#include "../include/oid.h"
#include "../include/repository.h"
#include "../include/object.h"
#include "../include/signature.h"
#include "../include/tag.h"
#include "../include/strarray.h"
// Forward declaration.
struct git_tag {
};

using namespace node;
using namespace v8;

class GitTag : public ObjectWrap {
public:

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

  git_tag *GetValue();
  git_tag **GetRefValue();

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

private:
  GitTag(git_tag *raw, bool selfFreeing);
  ~GitTag();

  static NAN_METHOD(JSNewFunction);


  static NAN_METHOD(AnnotationCreate);

  static NAN_METHOD(Create);

  static NAN_METHOD(CreateFrombuffer);

  static NAN_METHOD(CreateLightweight);

  static NAN_METHOD(Delete);

  static NAN_METHOD(Id);

  struct ListBaton {
    int error_code;
    const git_error* error;
    git_strarray * tag_names;
    git_repository * repo;
  };
  class ListWorker : public NanAsyncWorker {
  public:
    ListWorker(
      ListBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~ListWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    ListBaton *baton;
  };

  static NAN_METHOD(List);

  static NAN_METHOD(ListMatch);

  struct LookupBaton {
    int error_code;
    const git_error* error;
    git_tag * out;
    git_repository * repo;
    const git_oid * id;
    bool idNeedsFree;
  };
  class LookupWorker : public NanAsyncWorker {
  public:
    LookupWorker(
      LookupBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~LookupWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    LookupBaton *baton;
  };

  static NAN_METHOD(Lookup);

  struct LookupPrefixBaton {
    int error_code;
    const git_error* error;
    git_tag * out;
    git_repository * repo;
    const git_oid * id;
    bool idNeedsFree;
    size_t len;
  };
  class LookupPrefixWorker : public NanAsyncWorker {
  public:
    LookupPrefixWorker(
      LookupPrefixBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~LookupPrefixWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    LookupPrefixBaton *baton;
  };

  static NAN_METHOD(LookupPrefix);

  static NAN_METHOD(Message);

  static NAN_METHOD(Name);

  static NAN_METHOD(Owner);

  static NAN_METHOD(Peel);

  static NAN_METHOD(Tagger);

  static NAN_METHOD(Target);

  static NAN_METHOD(TargetId);

  static NAN_METHOD(TargetType);
  git_tag *raw;
};

#endif
