-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Enum support for the argument parser.
- Loading branch information
1 parent
e2c5fec
commit eda8ad3
Showing
11 changed files
with
464 additions
and
16 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
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
52 changes: 52 additions & 0 deletions
52
include/seqan3/core/detail/debug_stream_string_convertible.hpp
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,52 @@ | ||
// ----------------------------------------------------------------------------------------------------- | ||
// Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin | ||
// Copyright (c) 2016-2019, Knut Reinert & MPI für molekulare Genetik | ||
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License | ||
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md | ||
// ----------------------------------------------------------------------------------------------------- | ||
|
||
/*!\file | ||
* \author Svenja Mehringer <svenja.mehringer AT fu-berlin.de> | ||
* \brief Provides an overload for the seqan3::debug_stream if a seqan3::string_conversion_map of the type exists. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <variant> | ||
|
||
#include <seqan3/argument_parser/auxiliary.hpp> | ||
#include <seqan3/core/detail/debug_stream_type.hpp> | ||
|
||
namespace seqan3 | ||
{ | ||
/*!\name Formatted output overloads | ||
* \{ | ||
*/ | ||
/*!\brief A type (e.g. an enum) can be made debug streamable by customizing the seqan3::string_conversion_map. | ||
* \tparam option_type Type of the enum to be printed. | ||
* \param s The seqan3::debug_stream. | ||
* \param op The value to print. | ||
* \relates seqan3::debug_stream_type | ||
* | ||
* \details | ||
* | ||
* This searches the seqan3::string_conversion_map of the respective type for the value \p op and prints the | ||
* respective string if found or '\<UNKNOWN_VALUE\>' if the value cannot be found in the map. | ||
*/ | ||
template <typename char_t, typename option_type> | ||
//!\cond | ||
requires string_convertible<remove_cvref_t<option_type>> | ||
//!\endcond | ||
inline debug_stream_type<char_t> & operator<<(debug_stream_type<char_t> & s, option_type && op) | ||
{ | ||
for (auto & [key, value] : string_conversion_map(op)) | ||
{ | ||
if (op == value) | ||
return s << key; | ||
} | ||
|
||
return s << "<UNKNOWN_VALUE>"; | ||
} | ||
//!\} | ||
|
||
} // namespace seqan3 |
Oops, something went wrong.