Commit eb41b032dfc4dc1cf048386e8f27746084ee0c91
1 parent
37122edb
count uses
Showing
2 changed files
with
27 additions
and
2 deletions
src/cxxopts.cpp
src/cxxopts.hpp
| ... | ... | @@ -154,6 +154,17 @@ namespace cxxopts |
| 154 | 154 | std::shared_ptr<const Value> m_parser; |
| 155 | 155 | }; |
| 156 | 156 | |
| 157 | + struct ParsedOption | |
| 158 | + { | |
| 159 | + boost::any value; | |
| 160 | + int count; | |
| 161 | + | |
| 162 | + ParsedOption() | |
| 163 | + : count(0) | |
| 164 | + { | |
| 165 | + } | |
| 166 | + }; | |
| 167 | + | |
| 157 | 168 | class Options |
| 158 | 169 | { |
| 159 | 170 | public: |
| ... | ... | @@ -164,13 +175,26 @@ namespace cxxopts |
| 164 | 175 | OptionAdder |
| 165 | 176 | add_options(); |
| 166 | 177 | |
| 178 | + int | |
| 179 | + count(const std::string& o) const | |
| 180 | + { | |
| 181 | + auto iter = m_parsed.find(o); | |
| 182 | + | |
| 183 | + if (iter == m_parsed.end()) | |
| 184 | + { | |
| 185 | + return 0; | |
| 186 | + } | |
| 187 | + | |
| 188 | + return iter->second.count; | |
| 189 | + } | |
| 190 | + | |
| 167 | 191 | private: |
| 168 | 192 | friend class OptionAdder; |
| 169 | 193 | |
| 170 | 194 | std::map<std::string, std::shared_ptr<OptionDetails>> m_short; |
| 171 | 195 | std::map<std::string, std::shared_ptr<OptionDetails>> m_long; |
| 172 | 196 | |
| 173 | - std::map<std::string, boost::any> m_parsed; | |
| 197 | + std::map<std::string, ParsedOption> m_parsed; | |
| 174 | 198 | }; |
| 175 | 199 | |
| 176 | 200 | class OptionAdder | ... | ... |