Wt examples  3.3.3
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 #include <string>
14 
19 
24 class Git {
25 public:
28  class Exception : public std::runtime_error {
29  public:
32  Exception(const std::string& msg);
33  };
34 
39  class ObjectId : public boost::array<unsigned char, 20> {
40  public:
43  ObjectId();
44 
50  explicit ObjectId(const std::string& id);
51 
54  std::string toString() const;
55  };
56 
59  enum ObjectType { Tree, Commit, Blob };
60 
63  struct Object {
66  std::string name;
67 
68  Object(const ObjectId& id, ObjectType type);
69  };
70 
73  Git();
74 
79  void setRepositoryPath(const std::string& repository);
80 
85  ObjectId getCommitTree(const std::string& revision) const;
86 
91  ObjectId getCommit(const std::string& revision) const;
92 
97  ObjectId getTreeFromCommit(const ObjectId& commit) const;
98 
106  Object treeGetObject(const ObjectId& tree, int index) const;
107 
112  int treeSize(const ObjectId& tree) const;
113 
118  std::string catFile(const ObjectId& id) const;
119 
120  typedef std::list<std::pair<std::string, std::string> > Cache;
121 
122 private:
125  std::string repository_;
126 
129  mutable Cache cache_;
130 
135  void checkRepository() const;
136 
145  bool getCmdResult(const std::string& cmd, std::string& result,
146  const std::string& tag) const;
147 
156  bool getCmdResult(const std::string& cmd, std::string& result,
157  int index) const;
158 
163  int getCmdResultLineCount(const std::string& cmd) const;
164 };
165 
168 #endif // GIT_H_

Generated on Tue May 27 2014 for the C++ Web Toolkit (Wt) by doxygen 1.8.4