• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

  • tdeio
  • tdeio
ktraderparsetree.h
1 /* This file is part of the KDE project
2  Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef __parse_tree_h__
21 #define __parse_tree_h__
22 
23 #include <tqstring.h>
24 #include <tqstringlist.h>
25 #include <tqvaluelist.h>
26 #include <tqmap.h>
27 #include <tqshared.h>
28 
29 #include <kservice.h>
30 #include <kuserprofile.h>
31 
32 #include "ktrader.h"
33 
34 namespace TDEIO {
35 
36 class ParseTreeBase;
37 
39 struct TDEIO_EXPORT PreferencesReturn
40 {
41  enum Type { PRT_DOUBLE, PRT_ERROR };
42 
43  PreferencesReturn() { type = PRT_ERROR; }
44 
45  PreferencesReturn( const PreferencesReturn& _r )
46  {
47  type = _r.type;
48  f = _r.f;
49  }
50 
51  Type type;
52  double f;
53 };
54 
55 
62 TDEIO_EXPORT int matchConstraint( const ParseTreeBase *_tree, const KService::Ptr &,
63  const KServiceTypeProfile::OfferList& );
64 
69 TDEIO_EXPORT PreferencesReturn matchPreferences( const ParseTreeBase *_tree, const KService::Ptr &,
70  const KServiceTypeProfile::OfferList& );
71 
75 struct TDEIO_EXPORT PreferencesMaxima
76 {
77  enum Type { PM_ERROR, PM_INVALID_INT, PM_INVALID_DOUBLE, PM_DOUBLE, PM_INT };
78 
79  Type type;
80  int iMax;
81  int iMin;
82  double fMax;
83  double fMin;
84 };
85 
89 class TDEIO_EXPORT ParseContext
90 {
91 public:
95  ParseContext( const ParseContext* _ctx ) : service( _ctx->service ), maxima( _ctx->maxima ),
96  offers( _ctx->offers ) {}
97  ParseContext( const KService::Ptr & _service, const KServiceTypeProfile::OfferList& _offers,
98  TQMap<TQString,PreferencesMaxima>& _m )
99  : service( _service ), maxima( _m ), offers( _offers ) {}
100 
101  bool initMaxima( const TQString& _prop);
102 
103  enum Type { T_STRING = 1, T_DOUBLE = 2, T_NUM = 3, T_BOOL = 4,
104  T_STR_SEQ = 5, T_SEQ = 6 };
105 
106  TQString str;
107  int i;
108  double f;
109  bool b;
110  TQValueList<TQVariant> seq;
111  TQStringList strSeq;
112  Type type;
113 
114  KService::Ptr service;
115 
116  TQMap<TQString,PreferencesMaxima>& maxima;
117  const KServiceTypeProfile::OfferList& offers;
118 };
119 
123 class TDEIO_EXPORT ParseTreeBase : public TDEShared
124 {
125 public:
126  typedef TDESharedPtr<ParseTreeBase> Ptr;
127  ParseTreeBase() { }
128 
129  virtual bool eval( ParseContext *_context ) const = 0;
130 protected:
131  virtual ~ParseTreeBase() { };
132 };
133 
134 TDEIO_EXPORT ParseTreeBase::Ptr parseConstraints( const TQString& _constr );
135 TDEIO_EXPORT ParseTreeBase::Ptr parsePreferences( const TQString& _prefs );
136 
140 class TDEIO_EXPORT ParseTreeOR : public ParseTreeBase
141 {
142 public:
143  ParseTreeOR( ParseTreeBase *_ptr1, ParseTreeBase *_ptr2 ) { m_pLeft = _ptr1; m_pRight = _ptr2; }
144 
145  bool eval( ParseContext *_context ) const;
146 
147 protected:
148  ParseTreeBase::Ptr m_pLeft;
149  ParseTreeBase::Ptr m_pRight;
150 };
151 
155 class TDEIO_EXPORT ParseTreeAND : public ParseTreeBase
156 {
157 public:
158  ParseTreeAND( ParseTreeBase *_ptr1, ParseTreeBase *_ptr2 ) { m_pLeft = _ptr1; m_pRight = _ptr2; }
159 
160  bool eval( ParseContext *_context ) const;
161 
162 protected:
163  ParseTreeBase::Ptr m_pLeft;
164  ParseTreeBase::Ptr m_pRight;
165 };
166 
170 class TDEIO_EXPORT ParseTreeCMP : public ParseTreeBase
171 {
172 public:
173  ParseTreeCMP( ParseTreeBase *_ptr1, ParseTreeBase *_ptr2, int _i ) { m_pLeft = _ptr1; m_pRight = _ptr2; m_cmd = _i; }
174 
175  bool eval( ParseContext *_context ) const;
176 
177 protected:
178  ParseTreeBase::Ptr m_pLeft;
179  ParseTreeBase::Ptr m_pRight;
180  int m_cmd;
181 };
182 
186 class TDEIO_EXPORT ParseTreeIN : public ParseTreeBase
187 {
188 public:
189  ParseTreeIN( ParseTreeBase *_ptr1, ParseTreeBase *_ptr2 ) { m_pLeft = _ptr1; m_pRight = _ptr2; }
190 
191  bool eval( ParseContext *_context ) const;
192 
193 protected:
194  ParseTreeBase::Ptr m_pLeft;
195  ParseTreeBase::Ptr m_pRight;
196 };
197 
201 class TDEIO_EXPORT ParseTreeMATCH : public ParseTreeBase
202 {
203 public:
204  ParseTreeMATCH( ParseTreeBase *_ptr1, ParseTreeBase *_ptr2 ) { m_pLeft = _ptr1; m_pRight = _ptr2; }
205 
206  bool eval( ParseContext *_context ) const;
207 
208 protected:
209  ParseTreeBase::Ptr m_pLeft;
210  ParseTreeBase::Ptr m_pRight;
211 };
212 
216 class TDEIO_EXPORT ParseTreeCALC : public ParseTreeBase
217 {
218 public:
219  ParseTreeCALC( ParseTreeBase *_ptr1, ParseTreeBase *_ptr2, int _i ) { m_pLeft = _ptr1; m_pRight = _ptr2; m_cmd = _i; }
220 
221  bool eval( ParseContext *_context ) const;
222 
223 protected:
224  ParseTreeBase::Ptr m_pLeft;
225  ParseTreeBase::Ptr m_pRight;
226  int m_cmd;
227 };
228 
232 class TDEIO_EXPORT ParseTreeBRACKETS : public ParseTreeBase
233 {
234 public:
235  ParseTreeBRACKETS( ParseTreeBase *_ptr ) { m_pLeft = _ptr; }
236 
237  bool eval( ParseContext *_context ) const { return m_pLeft->eval( _context ); }
238 
239 protected:
240  ParseTreeBase::Ptr m_pLeft;
241 };
242 
246 class TDEIO_EXPORT ParseTreeNOT : public ParseTreeBase
247 {
248 public:
249  ParseTreeNOT( ParseTreeBase *_ptr ) { m_pLeft = _ptr; }
250 
251  bool eval( ParseContext *_context ) const;
252 
253 protected:
254  ParseTreeBase::Ptr m_pLeft;
255 };
256 
260 class TDEIO_EXPORT ParseTreeEXIST : public ParseTreeBase
261 {
262 public:
263  ParseTreeEXIST( const char *_id ) { m_id = _id; }
264 
265  bool eval( ParseContext *_context ) const;
266 
267 protected:
268  TQString m_id;
269 };
270 
274 class TDEIO_EXPORT ParseTreeID : public ParseTreeBase
275 {
276 public:
277  ParseTreeID( const char *arg ) { m_str = arg; }
278 
279  bool eval( ParseContext *_context ) const;
280 
281 protected:
282  TQString m_str;
283 };
284 
288 class TDEIO_EXPORT ParseTreeSTRING : public ParseTreeBase
289 {
290 public:
291  ParseTreeSTRING( const char *arg ) { m_str = arg; }
292 
293  bool eval( ParseContext *_context ) const { _context->type = ParseContext::T_STRING; _context->str = m_str; return true; }
294 
295 protected:
296  TQString m_str;
297 };
298 
302 class TDEIO_EXPORT ParseTreeNUM : public ParseTreeBase
303 {
304 public:
305  ParseTreeNUM( int arg ) { m_int = arg; }
306 
307  bool eval( ParseContext *_context ) const { _context->type = ParseContext::T_NUM; _context->i = m_int; return true; }
308 
309 protected:
310  int m_int;
311 };
312 
316 class TDEIO_EXPORT ParseTreeDOUBLE : public ParseTreeBase
317 {
318 public:
319  ParseTreeDOUBLE( double arg ) { m_double = arg; }
320 
321  bool eval( ParseContext *_context ) const { _context->type = ParseContext::T_DOUBLE; _context->f = m_double; return true; }
322 
323 protected:
324  double m_double;
325 };
326 
330 class TDEIO_EXPORT ParseTreeBOOL : public ParseTreeBase
331 {
332 public:
333  ParseTreeBOOL( bool arg ) { m_bool = arg; }
334 
335  bool eval( ParseContext *_context ) const { _context->type = ParseContext::T_BOOL; _context->b = m_bool; return true; }
336 
337 protected:
338  bool m_bool;
339 };
340 
344 class TDEIO_EXPORT ParseTreeMAX2 : public ParseTreeBase
345 {
346 public:
347  ParseTreeMAX2( const char *_id ) { m_strId = _id; }
348 
349  bool eval( ParseContext *_context ) const;
350 
351 protected:
352  TQString m_strId;
353 };
354 
358 class TDEIO_EXPORT ParseTreeMIN2 : public ParseTreeBase
359 {
360 public:
361  ParseTreeMIN2( const char *_id ) { m_strId = _id; }
362 
363  bool eval( ParseContext *_context ) const;
364 
365 protected:
366  TQString m_strId;
367 };
368 
369 }
370 
371 #endif
TDEIO
A namespace for TDEIO globals.
Definition: authinfo.h:29

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.8.8
This website is maintained by Timothy Pearson.