mirror of
https://github.com/sametersoylu/argument-parser.git
synced 2026-04-13 03:41:18 +00:00
feat: Introduce a modular argument convention system for GNU and Windows styles, add .clang-format, and update CMake configuration to C++17.
This commit is contained in:
35
src/headers/conventions/base_convention.hpp
Normal file
35
src/headers/conventions/base_convention.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#ifndef BASE_CONVENTION_HPP
|
||||
#define BASE_CONVENTION_HPP
|
||||
|
||||
namespace argument_parser::conventions {
|
||||
enum class argument_type { SHORT, LONG, POSITIONAL, INTERCHANGABLE, ERROR };
|
||||
|
||||
using parsed_argument = std::pair<argument_type, std::string>;
|
||||
|
||||
class base_convention {
|
||||
public:
|
||||
virtual std::string extract_value(std::string const &) const = 0;
|
||||
virtual parsed_argument get_argument(std::string const &) const = 0;
|
||||
virtual bool requires_next_token() const = 0;
|
||||
virtual std::string name() const = 0;
|
||||
virtual std::string short_prec() const = 0;
|
||||
virtual std::string long_prec() const = 0;
|
||||
|
||||
protected:
|
||||
base_convention() = default;
|
||||
~base_convention() = default;
|
||||
};
|
||||
using convention = base_convention;
|
||||
} // namespace argument_parser::conventions
|
||||
|
||||
namespace argument_parser::conventions::helpers {
|
||||
static std::string to_lower(std::string s);
|
||||
|
||||
static std::string to_upper(std::string s);
|
||||
} // namespace argument_parser::conventions::helpers
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user