CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
spec_tree.h
Go to the documentation of this file.
1 
4 #ifndef CVMFS_SHRINKWRAP_SPEC_TREE_H_
5 #define CVMFS_SHRINKWRAP_SPEC_TREE_H_
6 
7 #include <map>
8 #include <string>
9 
12  SPEC_READ_FS = -42, // <- The answer to no questions at all
13 };
14 
15 class SpecTreeNode {
16  public:
17  explicit SpecTreeNode(char modeParam) : mode(modeParam) { }
19  for (std::map<std::string, SpecTreeNode *>::iterator it = nodes_.begin();
20  it != nodes_.end();
21  it++) {
22  delete it->second;
23  }
24  }
25  SpecTreeNode *GetNode(const std::string &name);
26  int GetListing(std::string base_path, char ***buf, size_t *len);
27 
28  void AddNode(const std::string &name, SpecTreeNode *node);
29 
40  char mode;
41 
42  private:
43  std::map<std::string, SpecTreeNode *> nodes_;
44 };
45 
46 class SpecTree {
47  public:
48  explicit SpecTree(char mode = 0) { root_ = new SpecTreeNode(mode); }
49  SpecTree(const SpecTree &tree) { root_ = tree.root_; }
50  ~SpecTree() { delete root_; }
51  static SpecTree *Create(const std::string &path);
52 
53  bool IsMatching(std::string path);
54 
69  int ListDir(const char *dir, char ***buf, size_t *len);
70 
71  private:
72  void Open(const std::string &path);
73  void Parse(FILE *spec_file);
74 
76 };
77 
78 
79 #endif // CVMFS_SHRINKWRAP_SPEC_TREE_H_
static SpecTree * Create(const std::string &path)
Definition: spec_tree.cc:21
void Open(const std::string &path)
Definition: spec_tree.cc:32
std::map< std::string, SpecTreeNode * > nodes_
Definition: spec_tree.h:43
~SpecTree()
Definition: spec_tree.h:50
SpecTreeNode * root_
Definition: spec_tree.h:75
int GetListing(std::string base_path, char ***buf, size_t *len)
Definition: spec_tree.cc:247
SpecTree(const SpecTree &tree)
Definition: spec_tree.h:49
SpecTreeNode * GetNode(const std::string &name)
Definition: spec_tree.cc:236
SPEC_READ_ST
Definition: spec_tree.h:10
void Parse(FILE *spec_file)
Definition: spec_tree.cc:86
SpecTree(char mode=0)
Definition: spec_tree.h:48
bool IsMatching(std::string path)
Definition: spec_tree.cc:46
void AddNode(const std::string &name, SpecTreeNode *node)
Definition: spec_tree.cc:243
int ListDir(const char *dir, char ***buf, size_t *len)
Definition: spec_tree.cc:196
SpecTreeNode(char modeParam)
Definition: spec_tree.h:17