blob: 53ac888375d34e93580e3c7f86e0330a58a5cc10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/***************************************************************************
* Copyright (C) 2004 by Juanjo Álvarez *
* juanjux@yahoo.es *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _ALTPARSER_H_
#define _ALTPARSER_H_
#include <config.h>
#include <tqstring.h>
#include <tqobject.h>
#include <tqptrlist.h>
#include <tqstringlist.h>
class Item;
struct Slave
{
TQString slname;
TQString slpath;
};
class Alternative
{
TQString m_altPath;
TQString m_selectError;
int m_priority;
Item *m_parent;
TQStringList *m_altSlaves;
public:
Alternative(Item *parentarg);
Alternative(const Alternative &alt);
~Alternative();
Alternative& operator=(const Alternative &alt);
Item* getParent() const { return m_parent; }
TQString getPath() const { return m_altPath; }
void setPath(const TQString &patharg) { m_altPath = patharg; }
int getPriority() const { return m_priority; }
void setPriority(int priorityarg) { m_priority = priorityarg; }
TQStringList* getSlaves() const { return m_altSlaves; }
void setSlaves(TQStringList *m_altSlaves);
void addSlave(const TQString &slave) { m_altSlaves->append(slave); }
uint countSlaves() const { return m_altSlaves->count(); }
TQString getSlave(int pos) const { return *(m_altSlaves->at(pos)); }
bool isSelected() const;
bool isBroken() const;
bool select();
TQString getSelectError() const { return m_selectError; }
};
typedef TQPtrList<Slave> SlaveList;
typedef TQPtrList<Alternative> AltsPtrList;
class Item
{
TQString m_name;
TQString m_mode;
TQString m_path;
SlaveList *m_itemSlaves;
AltsPtrList *m_itemAlts;
public:
Item();
// Deep copy constructor:
Item(const Item &item);
~Item();
Item& operator=(const Item &item);
Alternative* getSelected() const;
TQString getName() const { return m_name; }
void setName(const TQString &namearg) { m_name = namearg; }
TQString getMode() const { return m_mode; }
//Check the input (FIXME)
void setMode(const TQString &modearg) { m_mode = modearg; }
TQString getPath() const { return m_path; }
void setPath(const TQString &patharg) { m_path = patharg; }
SlaveList *getSlaves() const { return m_itemSlaves; }
void setSlaves(SlaveList *slaves);
void addSlave(const TQString &namearg, const TQString &patharg);
void delSlave(const TQString &namearg);
void delSlaveByPath(const TQString &patharg);
AltsPtrList *getAlternatives() const { return m_itemAlts; }
Alternative *getAlternative(const TQString &altpath);
void setAlternatives(AltsPtrList &alts);
int countAlternatives() const { return m_itemAlts->count(); }
void delAlternativeByPath(const TQString &patharg);
void delAlternativeByPriority(int priorityarg);
void addAlternative(Alternative *altarg) { m_itemAlts->append(altarg); }
bool isBroken() const;
};
typedef TQPtrList<Item> ItemPtrList;
class AltFilesManager
{
ItemPtrList *m_itemlist;
TQString m_altdir;
TQString m_errorMsg;
bool m_parseOk;
bool parseAltFiles(TQString &errorstr);
public:
AltFilesManager(const TQString &altdir);
~AltFilesManager();
ItemPtrList* getGlobalAlternativeList() const { return this->m_itemlist; }
bool parsingOk() const { return m_parseOk; }
TQString getErrorMsg() const { return m_errorMsg; }
Item* getItem (const TQString &name) const;
//FIXME: Put in a #ifdef
void debugPrintAlts() const;
TQString getAltDir() { return m_altdir ;}
};
#endif // _ALTPARSER_H_
|