00001 /* 00002 This is an abstract base class for matching potential keys to arguments. 00003 00004 Copyright (C) 2002 Ross A. Beyer 00005 00006 Contact Author: Ross A. Beyer, rbeyer@rossbeyer.net 00007 00008 CVS $Id: matcher.hpp,v 1.3 2003/03/25 23:53:36 rbeyer Exp $ 00009 00010 00011 License & Copyright Information 00012 ------------------------------- 00013 00014 This file is part of the commandl package, 00015 $Name: commandl_Beta-1 $. 00016 00017 The commandl packge is free software; you can redistribute it 00018 and/or modify it under the terms of the GNU General Public License 00019 as published by the Free Software Foundation; either version 2 of the 00020 License, or (at your option) any later version. 00021 00022 The commandl package is distributed in the hope that it will be useful, 00023 but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 GNU General Public License for more details. 00026 00027 You should have received a copy of the GNU General Public License 00028 along with this program; if not, write to the Free Software 00029 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00030 00031 */ 00032 00033 #ifndef MATCHER_HEADER // Begin the Header Guard to prevent multiple 00034 #define MATCHER_HEADER // inclusions. 00035 00036 #include <map> 00037 #include <string> 00038 #include <vector> 00039 00040 00041 namespace commandl 00042 { 00043 class argument; // forward declaration 00044 00090 class matcher 00091 { 00092 00093 // ==================== Constructors & Destructor ===================== // 00094 public: 00095 matcher(); 00096 00097 /* It is highly suggested that you implement a constructor of this 00098 form when deriving a class from matcher. 00099 matcher 00100 ( 00101 std::vector<argument*> // arguments 00102 ); 00103 */ 00104 00105 virtual ~matcher() = 0; 00106 00107 // =========================== Accessors ============================== // 00108 public: 00109 00110 virtual argument* 00111 match( const std::string& ) const = 0; 00112 00113 virtual std::string 00114 usage_key( const std::string& ) const = 0; 00115 00116 virtual std::vector<std::string> 00117 usage_keys( const std::vector<std::string>& ) const = 0; 00118 00119 virtual std::map<std::string, argument*> 00120 keys() const; 00121 00122 // =========================== Methods ================================ // 00123 public: 00124 00125 virtual void 00126 set_arguments( const std::vector<argument*>& ); 00127 00128 virtual std::map<std::string, argument*> 00129 resolve_keys 00130 ( 00131 const std::vector<argument*>& 00132 ) = 0; 00133 00134 virtual matcher* 00135 clone() const = 0; 00136 00137 // --------------------------- Protected Methods ---------------------- // 00138 protected: 00139 00140 00141 // --------------------------- Private Methods ------------------------ // 00142 private: 00143 00144 00145 // =========================== Member Variables ======================= // 00146 protected: 00147 00149 std::map<std::string, argument*> Keys; 00150 00151 }; // End of the class declaration 00152 00153 } // End of the namespace declaration 00154 00155 #endif // End the Header Guard 00156