Skip to content

Commit

Permalink
[MISC] Apply Review
Browse files Browse the repository at this point in the history
Signed-off-by: Lydia Buntrock <[email protected]>
  • Loading branch information
Irallia committed Jan 13, 2022
1 parent f3d71e5 commit a6e904f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ If possible, provide tooling that performs the changes, e.g. a shell-script.

#### I/O

* To avoid using seqan3::io we changed the usage of the `seqan3::input_file_validator` and
`seqan3::output_file_validator`, you now have to give the formats explicitly:
`sharg::input_file_validator validator{std::vector{std::string{"exe"}, std::string{"fasta"}}};` and
`sharg::output_file_validator validator{sharg::output_file_open_options::create_new, std::vector{std::string{"exe"}, std::string{"fasta"}}};`.
* In order to avoid using the seqan3 I/O module, you now have to give a list of file extensions explicitly to
`sharg::input_file_validator` and `sharg::output_file_validator`:
For example `sharg::input_file_validator validator{std::vector<std::string>{{"exe"}, {"fasta"}}};`. Please follow
https://github.com/seqan/seqan3/issues/2927 to see how the list of file extensions can be extracted from seqan3 files.
We also removed the `default_extensions()` function, as we now can construct `output_file_validator` with just a given
mode: `output_file_validator(output_file_open_options const mode)`. The extensions will be an empty array in this case.
43 changes: 20 additions & 23 deletions include/sharg/validators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,7 @@ class file_validator_base
*
* \include test/snippet/argument_parser/validators_input_file.cpp
*
* The valid extensions can also be obtained from a seqan3 formatted file type, e.g. sharg::sequence_input_file, if
* it is given as template argument to this class. The following snippet demonstrates the different ways to instantiate
* the sharg::input_file_validator.
* The following snippet demonstrates the different ways to instantiate the sharg::input_file_validator.
*
* \include test/snippet/argument_parser/validators_input_file_ext_from_file.cpp
*
Expand All @@ -488,6 +486,7 @@ class input_file_validator : public file_validator_base
* \{
*/

input_file_validator() = default; //!< Defaulted.
input_file_validator(input_file_validator const &) = default; //!< Defaulted.
input_file_validator(input_file_validator &&) = default; //!< Defaulted.
input_file_validator & operator=(input_file_validator const &) = default; //!< Defaulted.
Expand Down Expand Up @@ -575,9 +574,7 @@ enum class output_file_open_options
*
* \include test/snippet/argument_parser/validators_output_file.cpp
*
* The valid extensions can also be obtained from a seqan3 formatted file type, e.g. sharg::sequence_input_file, if
* it is given as template argument to this class. The following snippet demonstrates the different ways to instantiate
* the sharg::output_file_validator.
* The following snippet demonstrates the different ways to instantiate the sharg::output_file_validator.
*
* \include test/snippet/argument_parser/validators_output_file_ext_from_file.cpp
*
Expand All @@ -597,23 +594,31 @@ class output_file_validator : public file_validator_base
*/

//!\copydoc sharg::input_file_validator::input_file_validator()
output_file_validator() : output_file_validator{output_file_open_options::create_new}
{}
output_file_validator() : output_file_validator{output_file_open_options::create_new} {}

output_file_validator(output_file_validator const &) = default; //!< Defaulted.
output_file_validator(output_file_validator &&) = default; //!< Defaulted.
output_file_validator(output_file_validator const &) = default; //!< Defaulted.
output_file_validator(output_file_validator &&) = default; //!< Defaulted.
output_file_validator & operator=(output_file_validator const &) = default; //!< Defaulted.
output_file_validator & operator=(output_file_validator &&) = default; //!< Defaulted.
output_file_validator & operator=(output_file_validator &&) = default; //!< Defaulted.
virtual ~output_file_validator() = default; //!< Virtual Destructor.

/*!\brief Constructs from a given overwrite mode.
* \param[in] mode A sharg::output_file_open_options indicating whether the validator throws if a file already
exists.
*/
explicit output_file_validator(output_file_open_options const mode)
: file_validator_base{}, mode{mode}
{
file_validator_base::extensions = std::move(std::vector<std::string> {});
file_validator_base::extensions_str = std::string {};
}

/*!\brief Constructs from a given overwrite mode and a list of valid extensions.
* \param[in] mode A sharg::output_file_open_options indicating whether the validator throws if a file already
exists.
* \param[in] extensions The valid extensions to validate for. Defaults to
* sharg::output_file_validator::default_extensions.
* \param[in] extensions The valid extensions to validate for.
*/
explicit output_file_validator(output_file_open_options const mode,
std::vector<std::string> extensions = default_extensions())
explicit output_file_validator(output_file_open_options const mode, std::vector<std::string> extensions)
: file_validator_base{}, mode{mode}
{
file_validator_base::extensions = std::move(extensions);
Expand All @@ -624,14 +629,6 @@ class output_file_validator : public file_validator_base
using file_validator_base::file_validator_base;
//!\}

/*!\brief The default extensions of `file_t`.
* \returns A list of default extensions for `file_t`, will be empty if `file_t` is `void`.
*/
static std::vector<std::string> default_extensions()
{
return {};
}

// Import the base::operator()
using file_validator_base::operator();

Expand Down

0 comments on commit a6e904f

Please sign in to comment.