Wt examples  3.3.0
Git.h
Go to the documentation of this file.
1 // This may look like C code, but it's really -*- C++ -*-
2 /*
3  * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
4  *
5  * See the LICENSE file for terms of use.
6  */
7 #ifndef GIT_H_
8 #define GIT_H_
9 
10 #include <stdexcept>
11 #include <list>
12 #include <boost/array.hpp>
13 
18 
23 class Git {
24 public:
27  class Exception : public std::runtime_error {
28  public:
31  Exception(const std::string& msg);
32  };
33 
38  class ObjectId : public boost::array<unsigned char, 20> {
39  public:
42  ObjectId();
43 
49  explicit ObjectId(const std::string& id);
50 
53  std::string toString() const;
54  };
55 
58  enum ObjectType { Tree, Commit, Blob };
59 
62  struct Object {
65  std::string name;
66 
67  Object(const ObjectId& id, ObjectType type);
68  };
69 
72  Git();
73 
78  void setRepositoryPath(const std::string& repository);
79 
84  ObjectId getCommitTree(const std::string& revision) const;
85 
90  ObjectId getCommit(const std::string& revision) const;
91 
96  ObjectId getTreeFromCommit(const ObjectId& commit) const;
97 
105  Object treeGetObject(const ObjectId& tree, int index) const;
106 
111  int treeSize(const ObjectId& tree) const;
112 
117  std::string catFile(const ObjectId& id) const;
118 
119  typedef std::list<std::pair<std::string, std::string> > Cache;
120 
121 private:
124  std::string repository_;
125 
128  mutable Cache cache_;
129 
134  void checkRepository() const;
135 
144  bool getCmdResult(const std::string& cmd, std::string& result,
145  const std::string& tag) const;
146 
155  bool getCmdResult(const std::string& cmd, std::string& result,
156  int index) const;
157 
162  int getCmdResultLineCount(const std::string& cmd) const;
163 };
164 
167 #endif // GIT_H_

Generated on Fri May 31 2013 for the C++ Web Toolkit (Wt) by doxygen 1.8.3.1