arcslibmakerparser.h
1 /*
2  name: tools/libmaker/arcslibmakerparser.h
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #ifndef __ARCSLIBMAKERPARSER_H__
30 #define __ARCSLIBMAKERPARSER_H__
31 
32 #include <QStringList>
33 #include <QDomDocument>
34 #include <QList>
35 
36 
38 {
39 public:
40  ARCSTypeWrapper(QString n=QString::null, QString w=QString::null)
41  {
42  setWrapper(w);
43  setName(n);
44  }
45 
47  {
48  wrapper = t.wrapper;
49  name = t.name;
50  }
51 
52  QString getName() { return name; }
53  void setName(QString n) { name = n; }
54  QString getWrapper() { return wrapper; }
55  void setWrapper(QString w) { wrapper = w; }
56 
57 
58  bool operator==(const ARCSTypeWrapper& t)
59  {
60  return ((wrapper == t.wrapper) && (name == t.name)) ;
61 
62  }
63 
64 private:
65  QString name;
66  QString wrapper;
67 };
68 
69 
71 {
72 public:
74 
75  void clear();
76 
77  void setFileName(QString s) { fileName = s ; }
78  bool parseFile();
79  bool writeFile();
80 
81  void addComponent(QString name) { components.push_back(name); }
82  void addHeader(QString name) { headers.push_back(name); }
83  void addType(QString name) { types.push_back(name); }
84  void addFamily(QString name) { families.push_back(name); }
85 
86  void removeComponent(QString name) { components.removeAll(name); }
87  void removeHeader(QString name) { headers.removeAll(name); }
88  void removeType(QString name) { types.removeAll(name); }
89  void removeFamily(QString name) { families.removeAll(name); }
90 
91  QStringList getHeaders() { return headers; }
92  QStringList getComponents() { return components; }
93  QList<ARCSTypeWrapper> getTypes() { return types; }
94  QStringList getFamilies() { return families; }
95 
96 private:
97  void parseSection(QString secname, QStringList & strlist);
98  void parseHeaders() { parseSection("header",headers); }
99  void parseComponents() { parseSection("component", components); }
100  void parseTypes(); // { parseSection("type", types); }
101  void parseFamilies() { parseSection("family", families); }
102 
103  QStringList headers;
104  QStringList components;
105  QList<ARCSTypeWrapper> types;
106  QStringList families;
107 
108  QString fileName;
109 
110  QDomDocument doc;
111 };
112 
113 #endif //__ARCSLIBMAKERPARSER_H__