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

kig

argsparser.h

Go to the documentation of this file.
00001 // Copyright (C)  2002  Dominique Devriese <devriese@kde.org>
00002 
00003 // This program is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU General Public License
00005 // as published by the Free Software Foundation; either version 2
00006 // of the License, or (at your option) any later version.
00007 
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00016 // 02110-1301, USA.
00017 
00018 #ifndef KIG_MISC_ARGSPARSER_H
00019 #define KIG_MISC_ARGSPARSER_H
00020 
00021 #include "../objects/common.h"
00022 
00023 #include <string>
00024 
00025 class ObjectImpType;
00026 
00106 class ArgsParser
00107 {
00108 public:
00112   enum { Invalid = 0, Valid = 1, Complete = 2 };
00113   struct spec { const ObjectImpType* type; std::string usetext; std::string selectstat; bool onOrThrough;};
00114 private:
00118   std::vector<spec> margs;
00119 
00120   spec findSpec( const ObjectImp* o, const Args& parents ) const;
00121 public:
00122   ArgsParser( const struct spec* args, int n );
00123   ArgsParser( const std::vector<spec>& args );
00124   ArgsParser();
00125   ~ArgsParser();
00126 
00127   void initialize( const std::vector<spec>& args );
00128   void initialize( const struct spec* args, int n );
00129 
00134   ArgsParser without( const ObjectImpType* type ) const;
00135   // checks if os matches the argument list this parser should parse..
00136   int check( const Args& os ) const;
00137   int check( const std::vector<ObjectCalcer*>& os ) const;
00143   std::string usetext( const ObjectImp* o, const Args& sel ) const;
00144 
00149   std::string selectStatement( const Args& sel ) const;
00150 
00151   // this reorders the objects or args so that they are in the same
00152   // order as the requested arguments..
00153   Args parse( const Args& os ) const;
00154   std::vector<ObjectCalcer*> parse( const std::vector<ObjectCalcer*>& os ) const;
00155 
00160   const ObjectImpType* impRequirement( const ObjectImp* o, const Args& parents ) const;
00161 
00167   bool isDefinedOnOrThrough( const ObjectImp* o, const Args& parents ) const;
00168 
00169   // Checks the args according to this args specification.  If the
00170   // objects should never have occurred, then an assertion failure
00171   // will happen, if one of the args is invalid, then false will be
00172   // returned, if all is fine, then true is returned..
00173   // assert that the objects are of the right types, and in the right
00174   // order as what would be returned by parse( os )..  If minobjects
00175   // is provided, then not all objects are needed, and it is enough if
00176   // at least minobjects are available..  Use this for object types
00177   // that can calc a temporary example object using less than the
00178   // required args.  These args need to be at the end of argsspec +
00179   // anyobjsspec.  If minobjects is not provided, then it is assumed
00180   // that all args are necessary.
00181   bool checkArgs( const std::vector<ObjectCalcer*>& os ) const;
00182   bool checkArgs( const std::vector<ObjectCalcer*>& os, uint minobjects ) const;
00183   bool checkArgs( const Args& os ) const;
00184   bool checkArgs( const Args& os, uint minobjects ) const;
00185 };
00186 
00187 #endif

kig

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

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal