CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Complete.hh
Go to the documentation of this file.
1 #ifndef COMPLETE_HH
2 #define COMPLETE_HH
3 
4 #include <boost/program_options.hpp>
5 #include <stdexcept>
6 #include <string>
7 #include <utility>
8 #include <vector>
9 
12 
13 namespace CASM {
14 
15 class PrimClex;
16 
17 namespace Completer {
18 
21 std::string strip_argument(const std::string &raw_input);
22 
23 //*****************************************************************************************************//
24 
37 class Suboption {
38  public:
40 
42  Suboption(const std::string &init_longname, std::string init_short,
43  ARG_TYPE init_expected_types);
44 
46  Suboption(const po::option_description &init_boost_option);
47 
49  std::string long_tag() const;
50 
52  std::string short_tag() const;
53 
56  bool matches(const std::string &test_tag) const;
57 
59  ARG_TYPE argument_type() const;
60 
61  private:
63  const std::string m_long;
64 
66  const std::string m_short;
67 
70 
72  void _sanity_throw() const;
73 };
74 
75 namespace Suboption_impl {
77 std::string pull_short(const po::option_description &single_boost_option);
78 
80 std::string pull_long(const po::option_description &single_boost_option);
81 } // namespace Suboption_impl
82 
83 //*****************************************************************************************************//
84 
96 class Option {
97  typedef std::size_t size_type;
99 
100  public:
102  Option(const std::string &init_tag,
103  const po::options_description &init_premade_descs);
104 
106  std::string tag() const;
107 
109  std::vector<std::string> probe_suboptions() const;
110 
113  ARG_TYPE probe_argument_type(const std::string &suboption_tag) const;
114 
116  void push_back(const Suboption &new_suboption);
117 
119  bool matches(const std::string &test_tag) const;
120 
121  private:
123  Option(const std::string &init_tag,
124  const std::vector<Suboption> &init_allowed_subopts);
125 
127  std::string m_tag; // Make this const once the default constructors of Engine
128  // are gone?
129 
131  std::vector<Suboption> m_avail_suboptions;
132 };
133 
134 //*****************************************************************************************************//
135 
151 class Engine {
152  typedef std::size_t size_type;
154 
155  public:
157  Engine(){};
158 
160  Engine(const std::vector<Option> &init_options);
161 
164  // Engine(const std::vector<CASM::po::options_description>
165  // &init_premade_descs);
166 
168  std::vector<std::string> probe_options() const;
169 
171  std::vector<std::string> probe_suboptions(
172  const std::string &option_tag) const;
173 
175  std::vector<std::string> probe_arguments(
176  const std::string &option_tag, const std::string &suboption_tag) const;
177 
180  // std::vector<std::string> probe_guess(const std::string current_word) const;
181 
183  void push_back(const Option &new_option);
184 
185  private:
188  std::vector<Option> m_avail_options;
189 
192  ARG_TYPE _probe_argument_type(const std::string &option_tag,
193  const std::string &suboption_tag) const;
194 
197  // const *CASM::PrimClex m_pclex;
198 };
199 } // namespace Completer
200 } // namespace CASM
201 
202 #endif
Engine()
Default constructor so you can push back your own things.
Definition: Complete.hh:157
std::vector< std::string > probe_options() const
Get a list of all available options.
Definition: Complete.cc:162
std::vector< std::string > probe_suboptions(const std::string &option_tag) const
For a particular option, get the available suboptions.
Definition: Complete.cc:178
ARG_TYPE _probe_argument_type(const std::string &option_tag, const std::string &suboption_tag) const
Definition: Complete.cc:299
std::size_t size_type
Definition: Complete.hh:152
std::vector< Option > m_avail_options
Definition: Complete.hh:188
std::vector< std::string > probe_arguments(const std::string &option_tag, const std::string &suboption_tag) const
Return the arguments that should be bash completed.
Definition: Complete.cc:197
ArgHandler::ARG_TYPE ARG_TYPE
Definition: Complete.hh:153
void push_back(const Option &new_option)
Append a new option to the engine.
Definition: Complete.cc:310
Option(const std::string &init_tag, const po::options_description &init_premade_descs)
Construct with program options.
Definition: Complete.cc:102
ArgHandler::ARG_TYPE ARG_TYPE
Definition: Complete.hh:98
ARG_TYPE probe_argument_type(const std::string &suboption_tag) const
Definition: Complete.cc:137
std::vector< Suboption > m_avail_suboptions
List of all the available –suboptions this option has.
Definition: Complete.hh:131
void push_back(const Suboption &new_suboption)
Append a new suboption to the option.
std::string tag() const
Return the identifying name of *this (e.g. "super", "monte", etc)
Definition: Complete.cc:113
std::string m_tag
Name that identifies this casm option (e.g. "monte", "init", etc)
Definition: Complete.hh:127
bool matches(const std::string &test_tag) const
Check if the given string corresponds to the tag of *this.
Definition: Complete.cc:148
std::size_t size_type
Definition: Complete.hh:97
std::vector< std::string > probe_suboptions() const
Return what the suboptions (–long format) for *this are.
Definition: Complete.cc:120
std::string short_tag() const
Return short name as char.
Definition: Complete.cc:78
ARG_TYPE argument_type() const
Return the expected types of arguments that follow *this.
Definition: Complete.cc:94
const ARG_TYPE m_expected_arg
Type of arguments expected.
Definition: Complete.hh:69
void _sanity_throw() const
Make sure values make sense.
Definition: Complete.cc:63
const std::string m_long
–long identifier (includes leading "--")
Definition: Complete.hh:63
ArgHandler::ARG_TYPE ARG_TYPE
Definition: Complete.hh:39
const std::string m_short
-s(hort) identifyer (includes leading '-')
Definition: Complete.hh:66
Suboption(const std::string &init_longname, std::string init_short, ARG_TYPE init_expected_types)
Explicit construction. Be sure to include "--" and '-' in the tags.
Definition: Complete.cc:48
bool matches(const std::string &test_tag) const
Definition: Complete.cc:80
std::string long_tag() const
Return long name in string format.
Definition: Complete.cc:76
std::string pull_long(const po::option_description &single_boost_option)
Get the –long tag from boost.
Definition: Complete.cc:42
std::string pull_short(const po::option_description &single_boost_option)
Get the -s(hort) tag from boost, or make it "- " if it doesn't exist.
Definition: Complete.cc:30
std::string strip_argument(const std::string &raw_input)
Definition: Complete.cc:13
Main CASM namespace.
Definition: APICommand.hh:8