• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • misc
argsparser.h
Go to the documentation of this file.
1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
2 
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 
18 #ifndef KIG_MISC_ARGSPARSER_H
19 #define KIG_MISC_ARGSPARSER_H
20 
21 #include "../objects/common.h"
22 
23 #include <string>
24 
25 class ObjectImpType;
26 
106 class ArgsParser
107 {
108 public:
112  enum { Invalid = 0, Valid = 1, Complete = 2 };
113  struct spec { const ObjectImpType* type; std::string usetext; std::string selectstat; bool onOrThrough;};
114 private:
118  std::vector<spec> margs;
119 
120  spec findSpec( const ObjectImp* o, const Args& parents ) const;
121 public:
122  ArgsParser( const struct spec* args, int n );
123  ArgsParser( const std::vector<spec>& args );
124  ArgsParser();
125  ~ArgsParser();
126 
127  void initialize( const std::vector<spec>& args );
128  void initialize( const struct spec* args, int n );
129 
134  ArgsParser without( const ObjectImpType* type ) const;
135  // checks if os matches the argument list this parser should parse..
136  int check( const Args& os ) const;
137  int check( const std::vector<ObjectCalcer*>& os ) const;
143  std::string usetext( const ObjectImp* o, const Args& sel ) const;
144 
149  std::string selectStatement( const Args& sel ) const;
150 
151  // this reorders the objects or args so that they are in the same
152  // order as the requested arguments..
153  Args parse( const Args& os ) const;
154  std::vector<ObjectCalcer*> parse( const std::vector<ObjectCalcer*>& os ) const;
155 
160  const ObjectImpType* impRequirement( const ObjectImp* o, const Args& parents ) const;
161 
167  bool isDefinedOnOrThrough( const ObjectImp* o, const Args& parents ) const;
168 
169  // Checks the args according to this args specification. If the
170  // objects should never have occurred, then an assertion failure
171  // will happen, if one of the args is invalid, then false will be
172  // returned, if all is fine, then true is returned..
173  // assert that the objects are of the right types, and in the right
174  // order as what would be returned by parse( os ).. If minobjects
175  // is provided, then not all objects are needed, and it is enough if
176  // at least minobjects are available.. Use this for object types
177  // that can calc a temporary example object using less than the
178  // required args. These args need to be at the end of argsspec +
179  // anyobjsspec. If minobjects is not provided, then it is assumed
180  // that all args are necessary.
181  bool checkArgs( const std::vector<ObjectCalcer*>& os ) const;
182  bool checkArgs( const std::vector<ObjectCalcer*>& os, uint minobjects ) const;
183  bool checkArgs( const Args& os ) const;
184  bool checkArgs( const Args& os, uint minobjects ) const;
185 };
186 
187 #endif
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
ArgsParser::~ArgsParser
~ArgsParser()
Definition: argsparser.cpp:232
ArgsParser::ArgsParser
ArgsParser()
Definition: argsparser.cpp:33
ArgsParser::selectStatement
std::string selectStatement(const Args &sel) const
returns the select statement for the next selectable argument when the given args are selected...
Definition: argsparser.cpp:242
ArgsParser::Complete
Definition: argsparser.h:112
ArgsParser::spec::type
const ObjectImpType * type
Definition: argsparser.h:113
ArgsParser::initialize
void initialize(const std::vector< spec > &args)
Definition: argsparser.cpp:42
ArgsParser::spec::usetext
std::string usetext
Definition: argsparser.h:113
ArgsParser::without
ArgsParser without(const ObjectImpType *type) const
returns a new ArgsParser that wants the same args, except for the ones of the given type...
Definition: argsparser.cpp:145
Args
std::vector< const ObjectImp * > Args
Definition: objects/common.h:47
ArgsParser::Invalid
Definition: argsparser.h:112
ArgsParser::checkArgs
bool checkArgs(const std::vector< ObjectCalcer * > &os) const
Definition: argsparser.cpp:222
ArgsParser::spec
Definition: argsparser.h:113
ArgsParser
This class is meant to take care of checking the types of the parents to ObjectCalcer's, and to put them in the correct order.
Definition: argsparser.h:106
ArgsParser::isDefinedOnOrThrough
bool isDefinedOnOrThrough(const ObjectImp *o, const Args &parents) const
Supposing that parents would be given as parents, this function returns whether the returned ObjectIm...
Definition: argsparser.cpp:236
ArgsParser::impRequirement
const ObjectImpType * impRequirement(const ObjectImp *o, const Args &parents) const
returns the minimal ObjectImp ID that o needs to inherit in order to be useful.
Definition: argsparser.cpp:185
ArgsParser::usetext
std::string usetext(const ObjectImp *o, const Args &sel) const
returns the usetext for the argument that o would be used for, if sel were used as parents...
Definition: argsparser.cpp:192
ArgsParser::spec::selectstat
std::string selectstat
Definition: argsparser.h:113
ArgsParser::check
int check(const Args &os) const
Definition: argsparser.cpp:99
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
ArgsParser::Valid
Definition: argsparser.h:112
ArgsParser::spec::onOrThrough
bool onOrThrough
Definition: argsparser.h:113
uint
unsigned int uint
Definition: object_imp.h:87
ArgsParser::parse
Args parse(const Args &os) const
Definition: argsparser.cpp:135
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal