WARPXM v1.10.0
Loading...
Searching...
No Matches
wxcryptset.h
Go to the documentation of this file.
1#ifndef wxcryptset_h
2#define wxcryptset_h
3
4// WarpX includes
5#include "wxcrypt.h"
6#include "wxcryptsetlexer.h"
7
8// std incudes
9#include <istream>
10#include <map>
11#include <stdexcept>
12#include <string>
13#include <vector>
14#include <cstring>
15
34class WxCryptSet : public WxCrypt
35{
36public:
37 // types of string->WxCryptSet map and pairs
38 typedef std::map<std::string, WxCryptSet*, std::less<std::string>> CryptSetMap_t;
39 typedef std::pair<std::string, WxCryptSet*> CryptSetPair_t;
40
41 // types of type -> list of WxCryptSets name
42 typedef std::map<std::string, std::vector<std::string>> TypeMap_t;
43 typedef std::pair<std::string, std::vector<std::string>> TypePair_t;
44
45 // type for parsed dependency string
46 typedef std::pair<std::string, std::vector<std::pair<std::string, std::string>>>
52
58 WxCryptSet(const std::string& name);
59
65 WxCryptSet(std::istream& istr);
66
67 virtual ~WxCryptSet();
68
73
78
82 std::string name() const
83 {
84 return _name;
85 }
86
92 void addSet(const WxCryptSet& wxc);
93
99 bool hasSet(const std::string& name) const;
100
106 const WxCryptSet& getSet(const std::string& name) const;
107
108 WxCryptSet& getSet(const std::string& name);
109
116 std::vector<std::string> getNamesOfType(const std::string& type) const;
117
124 std::vector<std::string> getNamesOfTypes(const std::vector<std::string>& types) const;
125
135 std::vector<std::string> getNamesOfTypes(const std::string& t0,
136 const std::string& t1) const;
137 std::vector<std::string> getNamesOfTypes(const std::string& t0,
138 const std::string& t1,
139 const std::string& t2) const;
140 std::vector<std::string> getNamesOfTypes(const std::string& t0,
141 const std::string& t1,
142 const std::string& t2,
143 const std::string& t3) const;
144 std::vector<std::string> getNamesOfTypes(const std::string& t0,
145 const std::string& t1,
146 const std::string& t2,
147 const std::string& t3,
148 const std::string& t4) const;
149
158 static DependencyList_t parseDependencyString(const std::string& ds);
159
160private:
161 std::string _name;
162 CryptSetMap_t _cryptSets;
163 TypeMap_t _typeMap;
164
170 void _setName(const std::string& name)
171 {
172 _name = name;
173 }
174
175 // class to parse input stream and initialize cryptset.
176 class _WxParser
177 {
178 public:
179 _WxParser(std::istream& istr, WxCryptSet* wxcs);
180 _WxParser(_WxParser* wxl, WxCryptSet* wxcs);
181
182 // symbol lookup functions
183 bool accept(int sym);
184 bool expect(int sym);
185
186 // non-terminals
187 void input_file();
188 void wx_decl();
189 void wx_decl_top();
190 void wx_decl_end();
191 void wx_decl_list();
192 void wx_decl_list_rest();
193 void wx_decl_value();
194 void wx_value();
195 void wx_value_list();
196 void wx_value_sub_list();
197 void wx_value_sub_list_rest();
198
199 WxCryptSetLexer _fl; // lexer
200 WxCryptSet* _wxcs; // pointer to cryptset being modified
201 int _sym; // current symbol read
202 std::string _tokenStr; // char pointer to token string
203 std::vector<WxAny> _tokens; // list of tokens
204 std::vector<WxAny> _valueList; // parse type of list
205 std::string _idName; // name of attribute being parsed
206 bool isParsingList; // are we parsing a list?
207 };
208
212 void _parse(_WxParser& fl);
213};
214
216#endif // wxcryptset_h
WxCrypt provides a container to store/retrive name-value pairs.
Definition: wxcrypt.h:33
WxCryptSet extends WxCrypt by providing, in addition to name-value pairs, an set of named WxCryptSets...
Definition: wxcryptset.h:35
WxCryptSet & getSet(const std::string &name)
std::vector< std::string > getNamesOfTypes(const std::string &t0, const std::string &t1, const std::string &t2, const std::string &t3) const
WxCryptSet & operator=(const WxCryptSet &wxc)
Assignment operator: makes a deep copy of supplied set.
std::string name() const
Name of crypt set.
Definition: wxcryptset.h:82
std::vector< std::string > getNamesOfType(const std::string &type) const
Return list of cryptset names with the given type.
std::vector< std::string > getNamesOfTypes(const std::string &t0, const std::string &t1, const std::string &t2, const std::string &t3, const std::string &t4) const
std::map< std::string, WxCryptSet *, std::less< std::string > > CryptSetMap_t
Definition: wxcryptset.h:38
std::vector< std::string > getNamesOfTypes(const std::vector< std::string > &types) const
Return list of cryptset names with the given types.
std::map< std::string, std::vector< std::string > > TypeMap_t
Definition: wxcryptset.h:42
std::pair< std::string, std::vector< std::pair< std::string, std::string > > > DependencyList_t
Definition: wxcryptset.h:47
bool hasSet(const std::string &name) const
Returns true if specified cyrptset exists.
WxCryptSet(const WxCryptSet &wxc)
Copy ctor: makes a deep copy of the supplied set.
WxCryptSet()
Create nameless cryptset.
static DependencyList_t parseDependencyString(const std::string &ds)
Parses dependency string and returns the child and list of dependencies (can be none).
WxCryptSet(const std::string &name)
Create empty cryptset with given name.
std::pair< std::string, WxCryptSet * > CryptSetPair_t
Definition: wxcryptset.h:39
void addSet(const WxCryptSet &wxc)
Add a new WxCryptSet.
std::pair< std::string, std::vector< std::string > > TypePair_t
Definition: wxcryptset.h:43
std::vector< std::string > getNamesOfTypes(const std::string &t0, const std::string &t1) const
Return list of cryptset names with the given types.
virtual ~WxCryptSet()
const WxCryptSet & getSet(const std::string &name) const
Get cryptset with given name.
WxCryptSet(std::istream &istr)
Create cryptset by parsing input from specified stream.
std::vector< std::string > getNamesOfTypes(const std::string &t0, const std::string &t1, const std::string &t2) const
Class that provides utility to read an input stream into a WxCryptSet.
Definition: wxcryptsetlexer.h:44