2022-03-16 14:20:26 +11:00
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* Copyright 2022, Danny Robson <danny@nerdcruft.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-03-18 12:38:30 +11:00
|
|
|
#include "./fwd.hpp"
|
2022-03-16 14:20:26 +11:00
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
namespace cruft::cmdopt2 {
|
|
|
|
class parser {
|
|
|
|
public:
|
|
|
|
int parse (int argc, char const* const* argv);
|
|
|
|
|
|
|
|
positional& add (positional const&) &;
|
|
|
|
keyword& add (keyword const&) &;
|
|
|
|
|
|
|
|
void usage (int argc, char const * const* argv, std::ostream&) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int parse_named (int argc, char const* const* argv) const;
|
|
|
|
int parse_short (int argc, char const* const* argv) const;
|
|
|
|
int parse_long (int argc, char const* const* argv) const;
|
|
|
|
|
|
|
|
std::vector<positional> m_positional;
|
|
|
|
std::vector<keyword> m_keyword;
|
|
|
|
};
|
|
|
|
}
|