-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YT-CPPAP-26: Split the implementation to separate header files
- Split the library implementation into multiple header files - Changed the license info in all implementation files - Changed the names of some elements to better describe their purpose
- Loading branch information
1 parent
d288aff
commit 3afa032
Showing
29 changed files
with
1,537 additions
and
1,476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[submodule "cpp-ap-demo"] | ||
path = cpp-ap-demo | ||
url = https://github.com/SpectraL519/cpp-ap-demo.git | ||
branch = cpp-ap-v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule cpp-ap-demo
updated
5 files
+1 −1 | CMakeLists.txt | |
+4 −4 | file_merger/merge_files.cpp | |
+2 −2 | numbers_converter/app/main.cpp | |
+2 −2 | power_calculator/power.cpp | |
+2 −2 | verbosity/app/main.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2023-2025 Jakub Musiał | ||
// This file is part of the CPP-AP project (https://github.com/SpectraL519/cpp-ap). | ||
// Licensed under the MIT License. See the LICENSE file in the project root for full license information. | ||
|
||
#pragma once | ||
|
||
#include "ap/action/specifiers.hpp" | ||
|
||
namespace ap::action::detail { | ||
|
||
/** | ||
* @brief The concept is satisfied when `AS` is either a valued or void argument action | ||
* @tparam AS The action specifier type. | ||
*/ | ||
template <typename AS> | ||
concept c_action_specifier = ap::detail::c_one_of<AS, action_type::transform, action_type::modify>; | ||
|
||
/// @brief Template argument action callable type alias. | ||
template <c_action_specifier AS, ap::detail::c_argument_value_type T> | ||
using callable_type = typename AS::template type<T>; | ||
|
||
/// @brief Template argument action callabla variant type alias. | ||
template <ap::detail::c_argument_value_type T> | ||
using action_variant_type = | ||
std::variant<callable_type<action_type::transform, T>, callable_type<action_type::modify, T>>; | ||
|
||
/** | ||
* @brief Checks if an argument action variant holds a void action. | ||
* @tparam T The argument value type. | ||
* @param action The action variant. | ||
* @return True if the held action is a void action. | ||
*/ | ||
template <ap::detail::c_argument_value_type T> | ||
[[nodiscard]] constexpr inline bool is_modify_action(const action_variant_type<T>& action | ||
) noexcept { | ||
return std::holds_alternative<callable_type<action_type::modify, T>>(action); | ||
} | ||
|
||
} // namespace ap::action::detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2023-2025 Jakub Musiał | ||
// This file is part of the CPP-AP project (https://github.com/SpectraL519/cpp-ap). | ||
// Licensed under the MIT License. See the LICENSE file in the project root for full license information. | ||
|
||
#pragma once | ||
|
||
#include "ap/error/exceptions.hpp" | ||
#include "detail/utility.hpp" | ||
|
||
#include <filesystem> | ||
|
||
namespace ap::action { | ||
|
||
/// @brief Returns a default argument action. | ||
template <ap::detail::c_argument_value_type T> | ||
detail::callable_type<ap::action_type::modify, T> none() noexcept { | ||
return [](T&) {}; | ||
} | ||
|
||
/// @brief Returns a predefined action for file name handling arguments. Checks whether a file with the given name exists. | ||
inline detail::callable_type<ap::action_type::modify, std::string> check_file_exists() noexcept { | ||
return [](std::string& file_path) { | ||
if (not std::filesystem::exists(file_path)) | ||
throw argument_parser_exception(std::format("File `{}` does not exists!", file_path)); | ||
}; | ||
} | ||
|
||
} // namespace ap::action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2023-2025 Jakub Musiał | ||
// This file is part of the CPP-AP project (https://github.com/SpectraL519/cpp-ap). | ||
// Licensed under the MIT License. See the LICENSE file in the project root for full license information. | ||
|
||
#pragma once | ||
|
||
#include "ap/detail/concepts.hpp" | ||
|
||
#include <functional> | ||
|
||
namespace ap::action_type { | ||
|
||
// TODO: | ||
// * on_read_action | ||
// * on_flag_action | ||
|
||
/* | ||
* @brief Represents a transformating action. | ||
* | ||
* Represents an argument action which transforms the parsed value and | ||
* returns a new value with which the argument will be initialized. | ||
*/ | ||
struct transform { | ||
template <ap::detail::c_argument_value_type T> | ||
using type = std::function<T(const T&)>; | ||
}; | ||
|
||
/* | ||
* @brief Represents a modifying action. | ||
* | ||
* Represents an argument action which modifies the value of an | ||
* already initialized argument. | ||
* | ||
* NOTE: The modify action doesn't have to actually modify the | ||
* underlying value - it can simply perform some action on it. | ||
* Example: `ap::action::check_file_exists` | ||
*/ | ||
struct modify { | ||
template <ap::detail::c_argument_value_type T> | ||
using type = std::function<void(T&)>; | ||
}; | ||
|
||
} // namespace ap::action_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2023-2025 Jakub Musiał | ||
// This file is part of the CPP-AP project (https://github.com/SpectraL519/cpp-ap). | ||
// Licensed under the MIT License. See the LICENSE file in the project root for full license information. | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace ap::argument { | ||
|
||
/// @brief Enum class representing positional arguments. | ||
enum class default_positional : uint8_t { input, output }; | ||
|
||
/// @brief Enum class representing optional arguments. | ||
enum class default_optional : uint8_t { help, input, output, multi_input, multi_output }; | ||
|
||
} // namespace ap::argument |
Oops, something went wrong.