CernVM-FS  2.9.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)
18  : mode(modeParam) {}
20  for (std::map<std::string, SpecTreeNode*>::iterator it = nodes_.begin();
21  it != nodes_.end();
22  it++) {
23  delete it->second;
24  }
25  }
26  SpecTreeNode *GetNode(const std::string &name);
27  int GetListing(std::string base_path, char ***buf, size_t *len);
28 
29  void AddNode(const std::string &name, SpecTreeNode *node);
30 
41  char mode;
42 
43  private:
44  std::map<std::string, SpecTreeNode*> nodes_;
45 };
46 
47 class SpecTree {
48  public:
49  explicit SpecTree(char mode = 0) {
50  root_ = new SpecTreeNode(mode);
51  }
52  SpecTree(const SpecTree &tree) {
53  root_ = tree.root_;
54  }
56  delete root_;
57  }
58  static SpecTree *Create(const std::string &path);
59 
60  bool IsMatching(std::string path);
61 
76  int ListDir(const char *dir,
77  char ***buf,
78  size_t *len);
79 
80  private:
81  void Open(const std::string &path);
82  void Parse(FILE *spec_file);
83 
85 };
86 
87 
88 
89 #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
~SpecTree()
Definition: spec_tree.h:55
SpecTreeNode * root_
Definition: spec_tree.h:84
int GetListing(std::string base_path, char ***buf, size_t *len)
Definition: spec_tree.cc:248
SpecTree(const SpecTree &tree)
Definition: spec_tree.h:52
SpecTreeNode * GetNode(const std::string &name)
Definition: spec_tree.cc:237
std::map< std::string, SpecTreeNode * > nodes_
Definition: spec_tree.h:44
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:49
bool IsMatching(std::string path)
Definition: spec_tree.cc:47
void AddNode(const std::string &name, SpecTreeNode *node)
Definition: spec_tree.cc:244
int ListDir(const char *dir, char ***buf, size_t *len)
Definition: spec_tree.cc:196
SpecTreeNode(char modeParam)
Definition: spec_tree.h:17