Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

policy.hpp

Go to the documentation of this file.
00001 /*
00002 This is an abstract base class for keeping track of parsing policies.
00003     
00004     Copyright (C) 2002 Ross A. Beyer
00005 
00006         Contact Author: Ross A. Beyer, rbeyer@rossbeyer.net
00007 
00008     CVS $Id: policy.hpp,v 1.3 2003/03/25 23:53:37 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 BASIC_POLICY_HEADER // Begin the Header Guard to prevent multiple
00034 #define BASIC_POLICY_HEADER //  inclusions.
00035 
00036 #include <bitset>
00037 #include <string>
00038 #include <utility>
00039 #include <vector>
00040 
00041 
00042 namespace commandl
00043 {
00044 
00057 class policy
00058 {
00059 
00060 // ==================== Constructors & Destructor ===================== //
00061 public:
00062     policy
00063         (
00064         std::vector<std::string>,                       // prefixes
00065         std::vector<std::string>,                       // assignments
00066         std::bitset<8>,                                 // policy bitset
00067         std::pair<std::string, std::string>             // optional_brackets
00068                 = std::make_pair(std::string("["), std::string("]")),
00069         std::pair<std::string, std::string>             // value_brackets
00070                 = std::make_pair(std::string("<"), std::string(">"))
00071         );
00072 
00073 /*
00074     policy
00075         (
00076         std::bitset<8>,             // policy bitset
00077         std::vector<std::string>    // prefixes
00078         std::vector<std::string>    // assignments
00079         );
00080 */
00081 
00082     policy();
00083 
00084 
00085 // =========================== Accessors ============================== //
00086 public:
00087 
00088     virtual std::vector<std::string>            prefixes()          const;
00089     virtual std::vector<std::string>            assignments()       const;
00090     virtual std::pair<std::string, std::string> optional_brackets() const;
00091     virtual std::pair<std::string, std::string> value_brackets()    const;
00092     
00093     virtual bool is_empty_valid_prefix()            const;
00094     virtual bool is_empty_valid_assignment()        const;
00095     virtual bool is_token_separator_assignment()    const;
00096     virtual bool no_prefix_keep_going()             const;
00097     virtual bool no_prefix_keep_element()           const;
00098     virtual bool no_key_keep_going()                const;
00099     virtual bool no_key_keep_element()              const;
00100     virtual bool ignore_prefix_if_value_required()  const;
00101     // virtual bool gobble_regardless_of_prefix()   const;
00102 
00103 
00104 // =========================== Methods ================================ //
00105 public:
00106 
00107     virtual void add_prefix(                        const std::string&  );
00108     virtual void add_assignment(                    const std::string&  );
00109     virtual void set_optional_brackets
00110                         (
00111                         const std::pair<std::string, std::string>&
00112                         );
00113     virtual void set_value_brackets
00114                         (
00115                         const std::pair<std::string, std::string>&
00116                         );
00117     virtual void is_empty_valid_prefix(             bool                );
00118     virtual void is_empty_valid_assignment(         bool                );
00119     virtual void is_token_separator_assignment(     bool                );
00120     virtual void no_prefix_keep_going(              bool                );
00121     virtual void no_prefix_keep_element(            bool                );
00122     virtual void no_key_keep_going(                 bool                );
00123     virtual void no_key_keep_element(               bool                );
00124     virtual void ignore_prefix_if_value_required(   bool                );
00125 
00126 
00127 // --------------------------- Protected Methods ---------------------- //
00128 protected:
00129 
00130 
00131 // --------------------------- Private Methods ------------------------ //
00132 private:
00133     
00134 
00135 // =========================== Member Variables ======================= //
00136 protected:
00137 
00148     std::vector<std::string>
00149     Prefixes;
00150 
00155     std::vector<std::string>
00156     Assignments;
00157 
00159     std::pair<std::string, std::string> Optional_Brackets;
00160 
00162     std::pair<std::string, std::string> Value_Brackets;
00163 
00165     bool
00166     Empty_Is_Prefix;
00167 
00169     bool
00170     Empty_Is_Assignment;
00171 
00173     bool
00174     Separator_Is_Assignment;
00175 
00177     bool
00178     No_Prefix_Keep_Going;
00179 
00181     bool
00182     No_Prefix_Keep_Element;
00183 
00185     bool
00186     No_Key_Keep_Going;
00187 
00189     bool
00190     No_Key_Keep_Element;
00191 
00195     bool
00196     Ignore_Prefix;
00197 
00198 };  // End of the class declaration
00199 
00200 }   // End of the namespace declaration
00201 
00202 #endif  // End the Header Guard
00203 

Generated on Sat Apr 5 21:17:27 2003 for commandl Library by doxygen1.2.15