Loading...
Searching...
No Matches
auxiliary.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <concepts>
#include <sstream>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <seqan3/core/debug_stream/debug_stream_type.hpp>
#include <seqan3/core/detail/customisation_point.hpp>
#include <seqan3/io/stream/concept.hpp>
SEQAN3_DEPRECATED_HEADER("This header and its functionality is deprecated and will be removed in a future version of SeqAn. Please use the sharg-parser (url: https://github.com/seqan/sharg-parser) instead.");
namespace seqan3::custom
{
template <typename t>
struct argument_parsing
{}; // forward
template <typename t>
struct argument_parsing<t const> : argument_parsing<t>
{};
template <typename t>
struct argument_parsing<t &> : argument_parsing<t>
{};
template <typename t>
struct argument_parsing<t const &> : argument_parsing<t>
{};
} // namespace seqan3::custom
namespace seqan3::detail::adl_only
{
template <typename t>
std::unordered_map<std::string_view, t> enumeration_names(t) = delete;
template <typename option_t>
struct enumeration_names_cpo : public detail::customisation_point_object<enumeration_names_cpo<option_t>, 1>
{
using base_t = detail::customisation_point_object<enumeration_names_cpo<option_t>, 1>;
using base_t::base_t;
template <typename option_type>
using option_or_type_identity =
std::conditional_t<std::is_nothrow_default_constructible_v<std::remove_cvref_t<option_type>>,
std::remove_cvref_t<option_type>,
std::type_identity<option_type>>;
template <typename option_type = option_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>)(
/*return*/ seqan3::custom::argument_parsing<option_type>::enumeration_names /*;*/
);
template <typename option_type = option_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>)(
/*return*/ enumeration_names(option_or_type_identity<option_type>{}) /*;*/
);
};
} // namespace seqan3::detail::adl_only
namespace seqan3
{
template <typename option_type>
requires requires {
{ detail::adl_only::enumeration_names_cpo<option_type>{}() };
}
inline auto const enumeration_names = detail::adl_only::enumeration_names_cpo<option_type>{}();
template <typename option_type>
concept named_enumeration = requires {
{ seqan3::enumeration_names<option_type> };
};
template <typename option_type>
concept argument_parser_compatible_option =
input_stream_over<std::istringstream, option_type> || named_enumeration<option_type>;
* \tparam enum_t Type of the enum to be printed; must model seqan3::named_enumeration.
* \ingroup argument_parser
*/
template <named_enumeration enum_t>
struct enumeration_printer<enum_t>
{
*
* If for the given enumeration value no enumeration name can be found, "<UNKNOWN_VALUE>" is printed.
*/
template <typename stream_t>
constexpr void operator()(stream_t & stream, enum_t const arg) const
{
for (auto & [label, enumerator] : enumeration_names<enum_t>)
{
if (arg == enumerator)
{
stream << label;
return;
}
}
stream << "<UNKNOWN_VALUE>";
}
};
* \include test/snippet/argument_parser/auxiliary.cpp
*
* \remark For a complete overview, take a look at \ref argument_parser
*/
enum option_spec
{
standard = 0,
required = 1,
advanced = 2,
hidden = 4
*/
};
enum class update_notifications
{
on,
off
};
* point that can be easily extended.
*
* \remark For a complete overview, take a look at \ref argument_parser
*/
struct argument_parser_meta_data // holds all meta information
{
std::string app_name;
std::string version;
std::string short_description;
std::string author;
std::string email;
std::string date;
std::string url;
std::string short_copyright;
std::string long_copyright;
std::string citation;
std::string man_page_title;
unsigned man_page_section{1};
std::vector<std::string> description;
std::vector<std::string> synopsis;
std::vector<std::string> examples;
};
} // namespace seqan3
std::string
customisation_point.hpp
Helper utilities for defining customisation point objects (CPOs).
SEQAN3_CPO_OVERLOAD
#define SEQAN3_CPO_OVERLOAD(...)
A macro that helps to define a seqan3::detail::customisation_point_object.
Definition customisation_point.hpp:106
debug_stream_type.hpp
Provides seqan3::debug_stream and related types.
seqan3::enumeration_names
auto const enumeration_names
Return a conversion map from std::string_view to option_type.
Definition auxiliary.hpp:162
seqan3::option_spec
option_spec
Used to further specify argument_parser options/flags.
Definition auxiliary.hpp:249
seqan3::standard
@ standard
The default were no checking or special displaying is happening.
Definition auxiliary.hpp:250
seqan3::advanced
@ advanced
Definition auxiliary.hpp:256
seqan3::hidden
@ hidden
Definition auxiliary.hpp:260
seqan3::required
@ required
Definition auxiliary.hpp:251
concept.hpp
Stream concepts.
seqan3::custom
A namespace for third party and standard library specialisations of SeqAn customisation points.
Definition char.hpp:40
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
seqan3::update_notifications
update_notifications
Indicates whether application allows automatic update notifications by the seqan3::argument_parser.
Definition auxiliary.hpp:268
seqan3::update_notifications::off
@ off
Automatic update notifications should be disabled.
Definition auxiliary.hpp:270
seqan3::update_notifications::on
@ on
Automatic update notifications should be enabled.
Definition auxiliary.hpp:269
sstream
seqan3::argument_parser_meta_data
Stores all parser related meta information of the seqan3::argument_parser.
Definition auxiliary.hpp:287
seqan3::argument_parser_meta_data::long_copyright
std::string long_copyright
Detailed copyright information that will be displayed when the user specifies "--copyright" on the co...
Definition auxiliary.hpp:313
seqan3::argument_parser_meta_data::man_page_title
std::string man_page_title
The title of your man page when exported by specifying "--export-help man" on the common line.
Definition auxiliary.hpp:319
seqan3::argument_parser_meta_data::email
std::string email
The author's e-mail address for correspondence.
Definition auxiliary.hpp:301
seqan3::argument_parser_meta_data::short_copyright
std::string short_copyright
Brief copyright (and/or license) information.
Definition auxiliary.hpp:309
seqan3::argument_parser_meta_data::date
std::string date
The date that the application was last updated. Keep this updated, ! since it will tell your users th...
Definition auxiliary.hpp:305
seqan3::argument_parser_meta_data::author
std::string author
Your name ;-).
Definition auxiliary.hpp:299
seqan3::argument_parser_meta_data::version
std::string version
The version information MAJOR.MINOR.PATH (e.g. 3.1.3).
Definition auxiliary.hpp:295
seqan3::argument_parser_meta_data::app_name
std::string app_name
The application name that will be displayed on the help page.
Definition auxiliary.hpp:293
seqan3::argument_parser_meta_data::synopsis
std::vector< std::string > synopsis
Add lines of usage to the synopsis section of the help page (e.g. "./my_read_mapper [OPTIONS] FILE1 F...
Definition auxiliary.hpp:331
seqan3::argument_parser_meta_data::short_description
std::string short_description
A short description of the application (e.g. "A tool for mapping reads to the genome").
Definition auxiliary.hpp:297
seqan3::argument_parser_meta_data::url
std::string url
A link to your github/gitlab project with the newest release.
Definition auxiliary.hpp:307
seqan3::argument_parser_meta_data::citation
std::string citation
How users shall cite your application.
Definition auxiliary.hpp:315
seqan3::argument_parser_meta_data::description
std::vector< std::string > description
A more detailed description that is displayed on the help page in the section "DESCRIPTION"....
Definition auxiliary.hpp:327
seqan3::argument_parser_meta_data::examples
std::vector< std::string > examples
Provide some examples on how to use your tool and what standard parameters might be appropriate in di...
Definition auxiliary.hpp:336
seqan3::argument_parser_meta_data::man_page_section
unsigned man_page_section
The man page section info (type man man on the command line for more information).
Definition auxiliary.hpp:321
seqan3::custom::argument_parsing
A type that can be specialised to provide customisation point implementations for the seqan3::argumen...
Definition auxiliary.hpp:51
seqan3::enumeration_printer< enum_t >::operator()
constexpr void operator()(stream_t &stream, enum_t const arg) const
Prints the associated label of the given enum value.
Definition auxiliary.hpp:221
seqan3::enumeration_printer
Definition default_printer.hpp:35
type_traits
unordered_map
vector
Hide me