| @@ -1,3 +1,6 @@ | |||||
| [submodule "cmake/modules"] | [submodule "cmake/modules"] | ||||
| path = cmake/modules | path = cmake/modules | ||||
| url = b3rgmann@git.bergmann89.de:cpp/CmakeModules.git | url = b3rgmann@git.bergmann89.de:cpp/CmakeModules.git | ||||
| [submodule "/home/bergmann/projects/TotoStarOnline/projects/worker/cppargs/cmake/modules"] | |||||
| path = /home/bergmann/projects/TotoStarOnline/projects/worker/cppargs/cmake/modules | |||||
| url = b3rgmann@git.bergmann89.de:cpp/CmakeModules.git | |||||
| @@ -1,15 +1,56 @@ | |||||
| # Initialize CMake ################################################################################ | # Initialize CMake ################################################################################ | ||||
| CMake_Minimum_Required ( VERSION 3.5.1 FATAL_ERROR ) | |||||
| Include ( CTest ) | |||||
| If ( NOT CMAKE_BUILD_TYPE ) | |||||
| Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
| EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
| Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
| "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" | |||||
| "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) | |||||
| # Projects ######################################################################################## | |||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
| CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
| # Set CMAKE_BUILD_TYPE | |||||
| If ( NOT CMAKE_BUILD_TYPE ) | |||||
| Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
| EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
| Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
| # Set CMAKE_MODULE_PATH | |||||
| If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
| Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
| "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
| EndIf ( ) | |||||
| If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
| Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
| "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) | |||||
| EndIf ( ) | |||||
| # Project ######################################################################################### | |||||
| Include ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppargs-var.cmake" ) | |||||
| Project ( cppargs | |||||
| DESCRIPTION "A simple library" | |||||
| VERSION "${CPPARGS_VERSION}" ) | |||||
| Include ( CTest ) | |||||
| Include ( GNUInstallDirs ) | |||||
| # Subdirectories | |||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
| Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
| # Install | |||||
| Include ( CMakePackageConfigHelpers ) | |||||
| Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppargs-config-version.cmake" | |||||
| VERSION ${CPPARGS_VERSION} | |||||
| COMPATIBILITY AnyNewerVersion ) | |||||
| Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppargs-config.cmake" | |||||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppargs-config.cmake" | |||||
| @ONLY ) | |||||
| Set ( ConfigPackageLocation "${CPPARGS_INSTALL_DIR_SHARE}/cmake" ) | |||||
| Install ( EXPORT | |||||
| cppargs | |||||
| NAMESPACE | |||||
| cppargs:: | |||||
| DESTINATION | |||||
| ${ConfigPackageLocation} ) | |||||
| Install ( FILES | |||||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppargs-config.cmake" | |||||
| "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppargs-config-version.cmake" | |||||
| DESTINATION | |||||
| ${ConfigPackageLocation} | |||||
| COMPONENT | |||||
| Devel ) | |||||
| @@ -0,0 +1,10 @@ | |||||
| # cppargs-config.cmake - package configuration file | |||||
| Message ( WARNING "Please configure the dependencies of this package!" ) | |||||
| # Include ( CMakeFindDependencyMacro ) | |||||
| # Find_Dependency ( <dependency> ) | |||||
| Include ( FindPackageHandleStandardArgs ) | |||||
| Set ( ${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE} ) | |||||
| Find_Package_Handle_Standard_Args ( cppargs CONFIG_MODE ) | |||||
| Include ( "${CMAKE_CURRENT_LIST_DIR}/cppargs.cmake") | |||||
| @@ -0,0 +1,20 @@ | |||||
| # Version | |||||
| Set ( CPPARGS_VERSION_MAJOR 1 ) | |||||
| Set ( CPPARGS_VERSION_MINOR 0 ) | |||||
| Set ( CPPARGS_VERSION_PATCH 0 ) | |||||
| Set ( CPPARGS_VERSION_BUILD 0 ) | |||||
| Set ( CPPARGS_VERSION_SHORT "${CPPARGS_VERSION_MAJOR}.${CPPARGS_VERSION_MINOR}" ) | |||||
| Set ( CPPARGS_VERSION "${CPPARGS_VERSION_SHORT}.${CPPARGS_VERSION_PATCH}.${CPPARGS_VERSION_BUILD}" ) | |||||
| Set ( CPPARGS_NAME "cppargs-${CPPARGS_VERSION_SHORT}" ) | |||||
| Set ( CPPARGS_OUTPUTNAME "cppargs" ) | |||||
| # Install directories | |||||
| Set ( CPPARGS_INSTALL_DIR_INCLUDE "include/${CPPARGS_NAME}" ) | |||||
| Set ( CPPARGS_INSTALL_DIR_LIB "lib" ) | |||||
| Set ( CPPARGS_INSTALL_DIR_SHARE "share/${CPPARGS_NAME}" ) | |||||
| # C Standard | |||||
| Set ( CMAKE_C_STANDARD 11 ) | |||||
| Set ( CMAKE_CXX_STANDARD 17 ) | |||||
| Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
| Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) | |||||
| @@ -1 +1 @@ | |||||
| Subproject commit 1e74005bc2f91434fecb2e5f698c21b73f7e3a13 | |||||
| Subproject commit 1a32531aef2deeebd5637b1873bc4e976628801c | |||||
| @@ -1,5 +1,6 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <cppargs/group.h> | |||||
| #include <cppargs/misc.h> | #include <cppargs/misc.h> | ||||
| #include <cppargs/options.h> | #include <cppargs/options.h> | ||||
| #include <cppargs/parser.h> | #include <cppargs/parser.h> | ||||
| @@ -1,6 +1,6 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <cpputils/mp.h> | |||||
| // #include <cpputils/mp.h> | |||||
| #include "group.h" | #include "group.h" | ||||
| @@ -13,7 +13,7 @@ namespace cppargs | |||||
| template<typename T_arg> | template<typename T_arg> | ||||
| struct group_init< | struct group_init< | ||||
| std::unique_ptr<T_arg>, | std::unique_ptr<T_arg>, | ||||
| utl::mp::enable_if<utl::mp::is_base_of<option, T_arg>>> | |||||
| std::enable_if_t<std::is_base_of_v<option, T_arg>>> | |||||
| { | { | ||||
| using option_ptr_type = std::unique_ptr<option>; | using option_ptr_type = std::unique_ptr<option>; | ||||
| using option_vector_type = std::vector<option_ptr_type>; | using option_vector_type = std::vector<option_ptr_type>; | ||||
| @@ -31,7 +31,7 @@ namespace cppargs | |||||
| template<typename T_arg> | template<typename T_arg> | ||||
| struct group_init< | struct group_init< | ||||
| std::unique_ptr<T_arg>, | std::unique_ptr<T_arg>, | ||||
| utl::mp::enable_if<utl::mp::is_base_of<group, T_arg>>> | |||||
| std::enable_if_t<std::is_base_of_v<group, T_arg>>> | |||||
| { | { | ||||
| using option_ptr_type = std::unique_ptr<option>; | using option_ptr_type = std::unique_ptr<option>; | ||||
| using option_vector_type = std::vector<option_ptr_type>; | using option_vector_type = std::vector<option_ptr_type>; | ||||
| @@ -19,7 +19,7 @@ namespace cppargs | |||||
| template<typename T> | template<typename T> | ||||
| struct check< | struct check< | ||||
| std::unique_ptr<T>, | std::unique_ptr<T>, | ||||
| utl::mp::enable_if<utl::mp::is_base_of<member_owned_group<T_instance>, T>>> | |||||
| std::enable_if_t<std::is_base_of_v<member_owned_group<T_instance>, T>>> | |||||
| { | { | ||||
| template<typename X> | template<typename X> | ||||
| constexpr X&& operator()(X&& x) const | constexpr X&& operator()(X&& x) const | ||||
| @@ -29,7 +29,7 @@ namespace cppargs | |||||
| template<typename T> | template<typename T> | ||||
| struct check< | struct check< | ||||
| std::unique_ptr<T>, | std::unique_ptr<T>, | ||||
| utl::mp::enable_if<utl::mp::is_base_of<member_option<T_instance>, T>>> | |||||
| std::enable_if_t<std::is_base_of_v<member_option<T_instance>, T>>> | |||||
| { | { | ||||
| template<typename X> | template<typename X> | ||||
| constexpr X&& operator()(X&& x) const | constexpr X&& operator()(X&& x) const | ||||
| @@ -1,6 +1,7 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <cppargs/group/simple_group.h> | #include <cppargs/group/simple_group.h> | ||||
| #include <cppargs/options/simple/simple_option.h> | |||||
| namespace cppargs | namespace cppargs | ||||
| { | { | ||||
| @@ -19,7 +20,7 @@ namespace cppargs | |||||
| template<typename T> | template<typename T> | ||||
| struct check< | struct check< | ||||
| std::unique_ptr<T>, | std::unique_ptr<T>, | ||||
| utl::mp::enable_if<utl::mp::is_base_of<simple_group, T>>> | |||||
| std::enable_if_t<std::is_base_of_v<simple_group, T>>> | |||||
| { | { | ||||
| template<typename X> | template<typename X> | ||||
| constexpr X&& operator()(X&& x) const | constexpr X&& operator()(X&& x) const | ||||
| @@ -29,7 +30,7 @@ namespace cppargs | |||||
| template<typename T> | template<typename T> | ||||
| struct check< | struct check< | ||||
| std::unique_ptr<T>, | std::unique_ptr<T>, | ||||
| utl::mp::enable_if<utl::mp::is_base_of<simple_option, T>>> | |||||
| std::enable_if_t<std::is_base_of_v<simple_option, T>>> | |||||
| { | { | ||||
| template<typename X> | template<typename X> | ||||
| constexpr X&& operator()(X&& x) const | constexpr X&& operator()(X&& x) const | ||||
| @@ -1,11 +0,0 @@ | |||||
| #pragma once | |||||
| #include <string> | |||||
| #include <cpputils/mp.h> | |||||
| namespace cppargs | |||||
| { | |||||
| } | |||||
| @@ -1,14 +0,0 @@ | |||||
| #pragma once | |||||
| #include <list> | |||||
| #include <vector> | |||||
| #include <cpputils/misc/type_helper.h> | |||||
| #include <cppargs/misc/misc.h> | |||||
| namespace cppargs | |||||
| { | |||||
| } | |||||
| @@ -2,7 +2,7 @@ | |||||
| #include <list> | #include <list> | ||||
| #include <vector> | #include <vector> | ||||
| #include <cpputils/misc/string.h> | |||||
| #include <cppcore/conversion/string.h> | |||||
| #include <cppargs/misc/option_parser.h> | #include <cppargs/misc/option_parser.h> | ||||
| namespace cppargs | namespace cppargs | ||||
| @@ -25,7 +25,7 @@ namespace cppargs | |||||
| str = context.arg; | str = context.arg; | ||||
| } | } | ||||
| if (!utl::try_from_string(str, value)) | |||||
| if (!cppcore::try_from_string(str, value)) | |||||
| throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + str + ")"); | throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + str + ")"); | ||||
| } | } | ||||
| @@ -52,7 +52,7 @@ namespace cppargs | |||||
| } | } | ||||
| } | } | ||||
| if (str && !utl::try_from_string(str, value)) | |||||
| if (str && !cppcore::try_from_string(str, value)) | |||||
| throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + str + ")"); | throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + str + ")"); | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -140,7 +140,7 @@ namespace cppargs | |||||
| value_type tmp; | value_type tmp; | ||||
| std::string str(s, static_cast<size_t>(e - s)); | std::string str(s, static_cast<size_t>(e - s)); | ||||
| s = e + 1; | s = e + 1; | ||||
| if (!utl::try_from_string(str, tmp)) | |||||
| if (!cppcore::try_from_string(str, tmp)) | |||||
| throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + s + ")"); | throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + s + ")"); | ||||
| derived.emplace(std::move(tmp)); | derived.emplace(std::move(tmp)); | ||||
| } | } | ||||
| @@ -153,7 +153,7 @@ namespace cppargs | |||||
| while (new_context.next() == next_result::argument) | while (new_context.next() == next_result::argument) | ||||
| { | { | ||||
| value_type tmp; | value_type tmp; | ||||
| if (!utl::try_from_string(new_context.arg, tmp)) | |||||
| if (!cppcore::try_from_string(new_context.arg, tmp)) | |||||
| throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + new_context.arg + ")"); | throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + new_context.arg + ")"); | ||||
| derived.emplace(std::move(tmp)); | derived.emplace(std::move(tmp)); | ||||
| derived.context = new_context; | derived.context = new_context; | ||||
| @@ -1,6 +1,6 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <cpputils/misc/indent.h> | |||||
| #include <cppcore/misc/indent.h> | |||||
| #include <cppargs/misc/printing.h> | #include <cppargs/misc/printing.h> | ||||
| namespace cppargs | namespace cppargs | ||||
| @@ -11,7 +11,7 @@ namespace cppargs | |||||
| void printing::print_group(std::ostream& os, const group& g) const | void printing::print_group(std::ostream& os, const group& g) const | ||||
| { | { | ||||
| using namespace ::utl; | |||||
| using namespace ::cppcore; | |||||
| /* meta */ | /* meta */ | ||||
| if (!g.meta.name.empty()) | if (!g.meta.name.empty()) | ||||
| @@ -51,7 +51,7 @@ namespace cppargs | |||||
| void printing::print_option(std::ostream& os, const option& o) const | void printing::print_option(std::ostream& os, const option& o) const | ||||
| { | { | ||||
| using namespace ::utl; | |||||
| using namespace ::cppcore; | |||||
| auto& m = o.meta; | auto& m = o.meta; | ||||
| os << indent; | os << indent; | ||||
| if (m.short_name != '\0') | if (m.short_name != '\0') | ||||
| @@ -32,7 +32,7 @@ namespace cppargs | |||||
| /** | /** | ||||
| * @brief Parse the option using the current context. | * @brief Parse the option using the current context. | ||||
| * | * | ||||
| * @param[in|out] c Context to use for parsing. | |||||
| * @param[in,out] c Context to use for parsing. | |||||
| */ | */ | ||||
| virtual void parse(context& c) const override; | virtual void parse(context& c) const override; | ||||
| }; | }; | ||||
| @@ -11,6 +11,7 @@ namespace cppargs | |||||
| */ | */ | ||||
| struct option_meta | struct option_meta | ||||
| { | { | ||||
| public: | |||||
| char short_name { '\0' }; //!< short option of the option (without the prependding -) | char short_name { '\0' }; //!< short option of the option (without the prependding -) | ||||
| std::string long_name { "" }; //!< long name of the option (without the prepending --) | std::string long_name { "" }; //!< long name of the option (without the prepending --) | ||||
| std::string description { "" }; //!< description for this option | std::string description { "" }; //!< description for this option | ||||
| @@ -18,14 +19,47 @@ namespace cppargs | |||||
| std::string default_value { "" }; //!< default value for this option | std::string default_value { "" }; //!< default value for this option | ||||
| bool mandatory { false }; //!< TRUE if this option is optional, FALSE otherwise | bool mandatory { false }; //!< TRUE if this option is optional, FALSE otherwise | ||||
| inline option_meta& set_short_name (char value); | |||||
| inline option_meta& set_long_name (const std::string& value); | |||||
| inline option_meta& set_description (const std::string& value); | |||||
| inline option_meta& set_arguments (const std::string& value); | |||||
| public: | |||||
| /** | |||||
| * @brief Set the sort name of the option. | |||||
| */ | |||||
| inline option_meta& set_short_name(char value); | |||||
| /** | |||||
| * @brief Set the ling name of the option. | |||||
| */ | |||||
| inline option_meta& set_long_name(const std::string& value); | |||||
| /** | |||||
| * @brief Set description of the option. | |||||
| */ | |||||
| inline option_meta& set_description(const std::string& value); | |||||
| /** | |||||
| * @brief Set the argument description. | |||||
| */ | |||||
| inline option_meta& set_arguments(const std::string& value); | |||||
| /** | |||||
| * @brief Set the default value of the option. | |||||
| */ | |||||
| template <typename T_value> | template <typename T_value> | ||||
| inline option_meta& set_default_value (const T_value& value); | |||||
| inline option_meta& set_mandatory (bool value = true); | |||||
| inline option_meta& set_default_value(const T_value& value); | |||||
| /** | |||||
| * @brief Set to true if the option is mandatorey, false otherwise. | |||||
| */ | |||||
| inline option_meta& set_mandatory(bool value = true); | |||||
| public: | |||||
| /** | |||||
| * @brief Set the default values for the option depending on the passed value. | |||||
| * | |||||
| * @param[in] meta Meta object to set default values for. | |||||
| * @param[in] value Value to get default values from. | |||||
| * | |||||
| * @return New meta object with the default values for the passed value. | |||||
| */ | |||||
| template<typename T_value> | template<typename T_value> | ||||
| static option_meta prepare(const option_meta& meta, T_value&& value); | static option_meta prepare(const option_meta& meta, T_value&& value); | ||||
| }; | }; | ||||
| @@ -42,8 +76,7 @@ namespace cppargs | |||||
| /** | /** | ||||
| * @brief Constructor. | * @brief Constructor. | ||||
| * | * | ||||
| * @param[in] p_long_name Long name of the option. | |||||
| * @param[in] p_short_name Short name of the option. | |||||
| * @param[in] meta Meta data for this option. | |||||
| */ | */ | ||||
| inline option(const option_meta& meta); | inline option(const option_meta& meta); | ||||
| @@ -56,7 +89,7 @@ namespace cppargs | |||||
| /** | /** | ||||
| * @brief Parse the option using the current context. | * @brief Parse the option using the current context. | ||||
| * | * | ||||
| * @param[in|out] c Context to use for parsing. | |||||
| * @param[in,out] c Context to use for parsing. | |||||
| */ | */ | ||||
| virtual void parse(context& c) const = 0; | virtual void parse(context& c) const = 0; | ||||
| }; | }; | ||||
| @@ -1,7 +1,6 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <cpputils/misc/string.h> | |||||
| #include <cppargs/misc/misc.inl> | |||||
| #include <cppcore/conversion/string.h> | |||||
| #include "option.h" | #include "option.h" | ||||
| @@ -32,10 +31,10 @@ namespace cppargs | |||||
| }; | }; | ||||
| template<typename T_value> | template<typename T_value> | ||||
| struct argument_props<T_value, utl::mp::enable_if_c<!std::is_class<T_value>::value>> | |||||
| struct argument_props<T_value, std::enable_if_t<!std::is_class<T_value>::value>> | |||||
| { | { | ||||
| static std::string type(bool optional = false) | static std::string type(bool optional = false) | ||||
| { return enwrap_type(utl::type_helper<T_value>::name(), false); } | |||||
| { return enwrap_type(cppcore::type_helper<T_value>::name(), false); } | |||||
| }; | }; | ||||
| template<typename T_value> | template<typename T_value> | ||||
| @@ -67,13 +66,13 @@ namespace cppargs | |||||
| template<typename T_value, typename T_enable = void> | template<typename T_value, typename T_enable = void> | ||||
| struct prepare_impl | struct prepare_impl | ||||
| { | { | ||||
| static inline option_meta prepare(const option_meta& meta, T_value&& value) | |||||
| static inline option_meta prepare(const option_meta& meta, const T_value& value) | |||||
| { | { | ||||
| option_meta m = meta; | option_meta m = meta; | ||||
| if (m.arguments.empty()) | if (m.arguments.empty()) | ||||
| m.arguments = argument_props<T_value>::type(std::is_same<T_value, bool>::value); | |||||
| m.arguments = argument_props<T_value>::type(std::is_same<std::decay_t<T_value>, bool>::value); | |||||
| if (m.default_value.empty()) | if (m.default_value.empty()) | ||||
| m.set_default_value(std::forward<T_value>(value)); | |||||
| m.set_default_value(value); | |||||
| return m; | return m; | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -81,8 +80,7 @@ namespace cppargs | |||||
| template<typename T_value, typename T_object> | template<typename T_value, typename T_object> | ||||
| struct prepare_impl< | struct prepare_impl< | ||||
| T_value T_object::*, | T_value T_object::*, | ||||
| utl::mp::enable_if_c< | |||||
| std::is_default_constructible<T_object>::value>> | |||||
| std::enable_if_t<std::is_default_constructible_v<T_object>>> | |||||
| { | { | ||||
| static inline option_meta prepare(const option_meta& meta, T_value T_object::*member) | static inline option_meta prepare(const option_meta& meta, T_value T_object::*member) | ||||
| { | { | ||||
| @@ -124,7 +122,7 @@ namespace cppargs | |||||
| template <typename T_value> | template <typename T_value> | ||||
| option_meta& option_meta::set_default_value(const T_value& value) | option_meta& option_meta::set_default_value(const T_value& value) | ||||
| { | { | ||||
| default_value = utl::to_string(value); | |||||
| default_value = cppcore::to_string(value); | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| @@ -136,7 +134,7 @@ namespace cppargs | |||||
| template<typename T_value> | template<typename T_value> | ||||
| option_meta option_meta::prepare(const option_meta& meta, T_value&& value) | option_meta option_meta::prepare(const option_meta& meta, T_value&& value) | ||||
| { return prepare_impl<utl::mp::decay_t<T_value>>::prepare(meta, std::forward<T_value>(value)); } | |||||
| { return prepare_impl<std::decay_t<T_value>>::prepare(meta, std::forward<T_value>(value)); } | |||||
| option::option(const option_meta& p_meta) | option::option(const option_meta& p_meta) | ||||
| : meta(p_meta) | : meta(p_meta) | ||||
| @@ -34,7 +34,7 @@ namespace cppargs | |||||
| /** | /** | ||||
| * @brief Parse the current argument. | * @brief Parse the current argument. | ||||
| * | * | ||||
| * @param[in|out] c Context of the current argument. | |||||
| * @param[in,out] c Context of the current argument. | |||||
| */ | */ | ||||
| virtual void parse(context& c) const override; | virtual void parse(context& c) const override; | ||||
| }; | }; | ||||
| @@ -107,7 +107,7 @@ namespace cppargs | |||||
| template<typename... T_args> | template<typename... T_args> | ||||
| member_parser( | member_parser( | ||||
| option_ptr_type&& p_default, | option_ptr_type&& p_default, | ||||
| T_args&&... args); | |||||
| T_args&&... p_args); | |||||
| /** | /** | ||||
| * @brief Parse the command line arguments using the passed options. | * @brief Parse the command line arguments using the passed options. | ||||
| @@ -1,7 +1,5 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <cpputils/misc/type_helper.h> | |||||
| #include <cppargs/parser/parser.h> | #include <cppargs/parser/parser.h> | ||||
| #include <cppargs/options/member.h> | #include <cppargs/options/member.h> | ||||
| #include <cppargs/misc/option_parser.h> | #include <cppargs/misc/option_parser.h> | ||||
| @@ -77,9 +75,9 @@ namespace cppargs | |||||
| template<typename... T_args> | template<typename... T_args> | ||||
| member_parser<T_instance>::member_parser( | member_parser<T_instance>::member_parser( | ||||
| option_ptr_type&& p_default, | option_ptr_type&& p_default, | ||||
| T_args&&... args) | |||||
| T_args&&... p_args) | |||||
| : base_type (std::move(p_default), _group) | : base_type (std::move(p_default), _group) | ||||
| , _group (make_base_group(std::forward<T_args>(args)...)) | |||||
| , _group (make_base_group(std::forward<T_args>(p_args)...)) | |||||
| { update_map(); } | { update_map(); } | ||||
| template<typename T_instance> | template<typename T_instance> | ||||
| @@ -1,6 +1,5 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <cppargs/misc/misc.h> | |||||
| #include <cppargs/parser/parser.h> | #include <cppargs/parser/parser.h> | ||||
| #include <cppargs/group/simple_group.h> | #include <cppargs/group/simple_group.h> | ||||
| @@ -30,7 +29,7 @@ namespace cppargs | |||||
| template<typename... T_args> | template<typename... T_args> | ||||
| simple_parser( | simple_parser( | ||||
| option_ptr_type&& p_default, | option_ptr_type&& p_default, | ||||
| T_args&&... args); | |||||
| T_args&&... p_args); | |||||
| /** | /** | ||||
| * @brief Parse the command line arguments using the passed options. | * @brief Parse the command line arguments using the passed options. | ||||
| @@ -1,6 +1,5 @@ | |||||
| #pragma once | #pragma once | ||||
| #include <cpputils/mp.h> | |||||
| #include <cppargs/parser/parser.h> | #include <cppargs/parser/parser.h> | ||||
| #include <cppargs/group/simple_group.inl> | #include <cppargs/group/simple_group.inl> | ||||
| @@ -10,9 +9,9 @@ namespace cppargs | |||||
| template<typename... T_args> | template<typename... T_args> | ||||
| simple_parser::simple_parser( | simple_parser::simple_parser( | ||||
| option_ptr_type&& p_default, | option_ptr_type&& p_default, | ||||
| T_args&&... args) | |||||
| T_args&&... p_args) | |||||
| : base_type (std::move(p_default), _group) | : base_type (std::move(p_default), _group) | ||||
| , _group ({ }, std::forward<T_args>(args)...) | |||||
| , _group ({ }, std::forward<T_args>(p_args)...) | |||||
| { update_map(); } | { update_map(); } | ||||
| void simple_parser::parse(int argc, char const * argv[]) const | void simple_parser::parse(int argc, char const * argv[]) const | ||||
| @@ -4,25 +4,27 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE | |||||
| Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | ||||
| Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | ||||
| Set ( CMAKE_CXX_STANDARD 17 ) | |||||
| Find_Package ( cppcore REQUIRED ) | |||||
| # Project: cppargs ################################################################################ | |||||
| # Interface Library ############################################################################### | |||||
| Find_Package ( cpputils REQUIRED ) | |||||
| Project ( cppargs VERSION 1.0.0.0 LANGUAGES CXX ) | |||||
| Set ( CPPARGS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | Set ( CPPARGS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | ||||
| Add_Library ( cppargs INTERFACE ) | Add_Library ( cppargs INTERFACE ) | ||||
| Target_Include_Directories ( cppargs | Target_Include_Directories ( cppargs | ||||
| INTERFACE ${CPPARGS_INCLUDE_DIR} ) | |||||
| INTERFACE | |||||
| $<BUILD_INTERFACE:${CPPARGS_INCLUDE_DIR}> | |||||
| $<INSTALL_INTERFACE:${CPPARGS_INSTALL_DIR_INCLUDE}> ) | |||||
| Target_Link_Libraries ( cppargs | Target_Link_Libraries ( cppargs | ||||
| INTERFACE cpputils ) | |||||
| INTERFACE | |||||
| cppcore::cppcore ) | |||||
| If ( HAS_PEDANTIC ) | |||||
| Pedantic_Apply_Flags ( ALL ) | |||||
| EndIf ( ) | |||||
| # Install ######################################################################################### | |||||
| # Optimize | |||||
| If ( __COTIRE_INCLUDED ) | |||||
| Cotire ( cppargs ) | |||||
| EndIf ( ) | |||||
| # Header | |||||
| Install ( FILES ${CPPARGS_INCLUDE_DIR}/cppargs.h | |||||
| DESTINATION ${CPPARGS_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( DIRECTORY ${CPPARGS_INCLUDE_DIR}/cppargs | |||||
| DESTINATION ${CPPARGS_INSTALL_DIR_INCLUDE} ) | |||||
| Install ( TARGETS cppargs | |||||
| EXPORT cppargs | |||||
| DESTINATION ${CPPARGS_INSTALL_DIR_INCLUDE} ) | |||||
| @@ -2,31 +2,40 @@ | |||||
| Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | ||||
| Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | ||||
| Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
| Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
| Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
| Set ( CMAKE_CXX_STANDARD 17 ) | |||||
| # Test ############################################################################################ | |||||
| # Project: cppargs-test ########################################################################### | |||||
| Find_Package ( GTest ) | |||||
| If ( NOT "${GTest_FOUND}" ) | |||||
| Return ( ) | |||||
| EndIf ( ) | |||||
| Find_Package ( GTest REQUIRED ) | |||||
| File ( GLOB_RECURSE CPPARGS_TEST_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
| File ( GLOB_RECURSE CPPARGS_TEST_INLINE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
| File ( GLOB_RECURSE CPPARGS_TEST_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
| Project ( cppargs-test ) | |||||
| File ( GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
| Add_Executable ( cppargs-test EXCLUDE_FROM_ALL ${SOURCE_FILES} ) | |||||
| Add_Executable ( cppargs-test | |||||
| EXCLUDE_FROM_ALL | |||||
| ${CPPARGS_TEST_HEADER_FILES} | |||||
| ${CPPARGS_TEST_INLINE_FILES} | |||||
| ${CPPARGS_TEST_SOURCE_FILES} ) | |||||
| Target_Link_Libraries ( cppargs-test | Target_Link_Libraries ( cppargs-test | ||||
| cppargs | |||||
| GTest::Main ) | |||||
| If ( HAS_PEDANTIC ) | |||||
| Pedantic_Apply_Flags ( ALL ) | |||||
| EndIf ( ) | |||||
| PUBLIC | |||||
| cppargs | |||||
| GTest::Main ) | |||||
| # optimization | # optimization | ||||
| If ( HAS_COTIRE ) | If ( HAS_COTIRE ) | ||||
| Cotire ( cppargs-test ) | Cotire ( cppargs-test ) | ||||
| EndIf ( ) | EndIf ( ) | ||||
| # pedantic | |||||
| If ( HAS_PEDANTIC ) | |||||
| Pedantic_Apply_Flags_Target ( cppargs-test | |||||
| ALL ) | |||||
| EndIf ( ) | |||||
| # test | # test | ||||
| If ( HAS_CMAKE_TESTS ) | If ( HAS_CMAKE_TESTS ) | ||||
| Add_CMake_Test ( NAME cppargs TARGET cppargs-test ) | Add_CMake_Test ( NAME cppargs TARGET cppargs-test ) | ||||