/* * 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 */ #pragma once #include "./fwd.hpp" #include #include namespace cruft::cmdopt2 { class parser { public: explicit parser (char const *desc); int parse [[nodiscard]] (int argc, char const* const* argv); positional_t& add (positional_t const&) &; keyword_t& add (keyword_t const&) &; void usage (int argc, char const * const* argv, FILE*) const; private: int parse_named (int argc, char const* const* argv, int*) const; int parse_short (int argc, char const* const* argv, int*) const; int parse_long (int argc, char const* const* argv, int*) const; std::vector m_positional; std::vector m_keyword; char const *m_description; }; }