-
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
19ab4cd
commit 2ca02ec
Showing
11 changed files
with
473 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_named_enumeration.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::enumeration_naming 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::enumeration_naming. | ||
* \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::enumeration_naming 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 named_enumeration<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] : enumeration_naming(op)) | ||
{ | ||
if (op == value) | ||
return s << key; | ||
} | ||
|
||
return s << "<UNKNOWN_VALUE>"; | ||
} | ||
//!\} | ||
|
||
} // namespace seqan3 |
Oops, something went wrong.