Skip to content

Commit 7260c24

Browse files
committed
alternative
1 parent 4abed1a commit 7260c24

File tree

7 files changed

+47
-50
lines changed

7 files changed

+47
-50
lines changed

include/sharg/auxiliary.hpp

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,40 @@ enum class update_notifications : uint8_t
2828
off //!< Automatic update notifications should be disabled.
2929
};
3030

31+
//!\brief A `std::vector<std::string>` that can also be constructed from `std::string`.
32+
class vector_of_string : public std::vector<std::string>
33+
{
34+
private:
35+
using base_t = std::vector<std::string>;
36+
37+
public:
38+
using base_t::base_t;
39+
40+
vector_of_string() = default; //!< Defaulted.
41+
vector_of_string(vector_of_string const &) = default; //!< Defaulted.
42+
vector_of_string & operator=(vector_of_string const &) = default; //!< Defaulted.
43+
vector_of_string(vector_of_string &&) = default; //!< Defaulted.
44+
vector_of_string & operator=(vector_of_string &&) = default; //!< Defaulted.
45+
~vector_of_string() = default; //!< Defaulted.
46+
47+
//!\brief Delegate to `std::string` constructor if possible.
48+
template <typename... t>
49+
requires std::constructible_from<std::string, t...>
50+
constexpr vector_of_string(t &&... str) : base_t{std::string(std::forward<t>(str)...)}
51+
{}
52+
53+
//!\brief Construct from iterator pair.
54+
template <typename Iter>
55+
requires std::constructible_from<std::string, Iter, Iter>
56+
&& std::same_as<std::decay_t<Iter>, std::string::value_type *>
57+
constexpr vector_of_string(Iter begin, Iter end) : base_t{std::string(begin, end)}
58+
{}
59+
60+
//!\brief Construct from an initializer list.
61+
constexpr vector_of_string(std::initializer_list<std::string::value_type> il) : base_t{{il}}
62+
{}
63+
};
64+
3165
/*!\brief Stores all parser related meta information of the sharg::parser.
3266
* \ingroup parser
3367
* \details
@@ -43,19 +77,6 @@ enum class update_notifications : uint8_t
4377
*/
4478
struct parser_meta_data // holds all meta information
4579
{
46-
// These are only needed to silence the deprecation warning for `citation`.
47-
//!\cond
48-
#pragma GCC diagnostic push
49-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
50-
parser_meta_data() = default;
51-
parser_meta_data(parser_meta_data const &) = default;
52-
parser_meta_data & operator=(parser_meta_data const &) = default;
53-
parser_meta_data(parser_meta_data &&) = default;
54-
parser_meta_data & operator=(parser_meta_data &&) = default;
55-
~parser_meta_data() = default;
56-
#pragma GCC diagnostic pop
57-
//!\endcond
58-
5980
/*!\brief The application name that will be displayed on the help page.
6081
*
6182
* The application name must only contain alpha-numeric characters, '_' or '-',
@@ -91,15 +112,8 @@ struct parser_meta_data // holds all meta information
91112
*/
92113
std::string long_copyright;
93114

94-
/*!\brief How users shall cite your application.
95-
* \deprecated This member is deprecated, please use `sharg::parser_meta_data::citations` instead.
96-
*/
97-
SHARG_DEPRECATED_200("sharg::parser::info::citation (std::string) will be removed in Sharg 2.0.0. ",
98-
"Please use sharg::parser::info::citations (std::vector<std::string>) instead.")
99-
std::string citation;
100-
101115
//!\brief How users shall cite your application.
102-
std::vector<std::string> citations;
116+
vector_of_string citation;
103117

104118
/*!\brief The title of your man page when exported by specifying
105119
* "--export-help man" on the common line.

include/sharg/detail/format_base.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,6 @@ class format_help_base : public format_base
361361
void parse(parser_meta_data & parser_meta)
362362
{
363363
meta = parser_meta;
364-
#pragma GCC diagnostic push
365-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
366-
if (!meta.citation.empty())
367-
meta.citations.emplace_back(std::move(meta.citation));
368-
#pragma GCC diagnostic pop
369364

370365
derived_t().print_header();
371366

@@ -573,7 +568,7 @@ class format_help_base : public format_base
573568
void print_legal()
574569
{
575570
// Print legal stuff
576-
if ((!empty(meta.short_copyright)) || (!empty(meta.long_copyright)) || (!empty(meta.citations))
571+
if ((!empty(meta.short_copyright)) || (!empty(meta.long_copyright)) || (!empty(meta.citation))
577572
|| (!empty(meta.author)) || (!empty(meta.email)))
578573
{
579574
derived_t().print_section("Legal");
@@ -598,18 +593,18 @@ class format_help_base : public format_base
598593
+ "2006-2025 Knut Reinert, FU-Berlin; released under the 3-clause BSDL.",
599594
false);
600595

601-
if (!empty(meta.citations))
596+
if (!empty(meta.citation))
602597
{
603598
derived_t().print_line(derived_t().in_bold("In your academic works please cite: "), false);
604-
for (size_t i = 0; i < meta.citations.size(); ++i)
599+
for (size_t i = 0; i < meta.citation.size(); ++i)
605600
{
606601
// Using `\\fB` and `\\fP` instead of `derived_t().in_bold()` here.
607602
// `format_help::print_list_item` uses `format_help::text_width` to determine whether
608603
// there should be a new line after the key ("[i]").
609604
// `format_help::text_width` ignores special sequences such as `\\fB` and `\\fP`,
610605
// but not the actual control sequences produced by `derived_t().in_bold()`.
611606
// All formats support `\\fB` and `\\fP`.
612-
derived_t().print_list_item("\\fB[" + std::to_string(i + 1u) + "]\\fP", meta.citations[i]);
607+
derived_t().print_list_item("\\fB[" + std::to_string(i + 1u) + "]\\fP", meta.citation[i]);
613608
}
614609
}
615610

include/sharg/platform.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,3 @@ static_assert(__cplusplus >= 201709L, "SHARG requires C++20, make sure that you
4242
#ifndef SHARG_DOXYGEN_ONLY
4343
# define SHARG_DOXYGEN_ONLY(x)
4444
#endif
45-
46-
//!\brief Deprecation message for Sharg 2.0.0 release.
47-
#ifndef SHARG_DEPRECATED_200
48-
# ifndef SHARG_DISABLE_DEPRECATED_WARNINGS
49-
# define SHARG_DEPRECATED_200(message, alternative) [[deprecated(message alternative)]]
50-
# else
51-
# define SHARG_DEPRECATED_200(message, alternative) /**/
52-
# endif
53-
#endif

test/documentation/sharg_doxygen_cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ PREDEFINED = "CEREAL_SERIALIZE_FUNCTION_NAME=serialize" \
353353
"SHARG_DOXYGEN_ONLY(x)= x" \
354354
"${SHARG_DOXYGEN_PREDEFINED_NDEBUG}" \
355355
"SHARG_HAS_TDL=1"
356-
EXPAND_AS_DEFINED = SHARG_DEPRECATED_200
356+
EXPAND_AS_DEFINED =
357357
SKIP_FUNCTION_MACROS = NO
358358
#---------------------------------------------------------------------------
359359
# Configuration options related to external references

test/unit/detail/format_help_test.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ TEST_F(format_help_test, with_long_copyright)
183183
TEST_F(format_help_test, with_citation)
184184
{
185185
auto parser = get_parser("-h");
186-
parser.info.citations = {"citation"};
186+
parser.info.citation = "citation";
187187

188188
expected = "test_parser\n"
189189
"===========\n"
@@ -196,13 +196,10 @@ TEST_F(format_help_test, with_citation)
196196
EXPECT_EQ(get_parse_cout_on_exit(parser), expected);
197197
}
198198

199-
TEST_F(format_help_test, with_citation_deprecated)
199+
TEST_F(format_help_test, with_multiple_citation)
200200
{
201201
auto parser = get_parser("-h");
202-
#pragma GCC diagnostic push
203-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
204-
parser.info.citation = "citation";
205-
#pragma GCC diagnostic pop
202+
parser.info.citation = {"citation1", "citation2"};
206203

207204
expected = "test_parser\n"
208205
"===========\n"
@@ -211,7 +208,7 @@ TEST_F(format_help_test, with_citation_deprecated)
211208
+ "LEGAL\n"
212209
" SeqAn Copyright: 2006-2025 Knut Reinert, FU-Berlin; released under the\n"
213210
" 3-clause BSDL.\n"
214-
" In your academic works please cite:\n [1] citation\n";
211+
" In your academic works please cite:\n [1] citation1\n [2] citation2\n";
215212
EXPECT_EQ(get_parse_cout_on_exit(parser), expected);
216213
}
217214

test/unit/detail/format_html_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ TEST_F(format_html_test, full_information_information)
7979
parser.info.url = "https://seqan.de";
8080
parser.info.short_copyright = "short copyright";
8181
parser.info.long_copyright = "long_copyright";
82-
parser.info.citations = {"citation"};
82+
parser.info.citation = "citation";
8383
parser.info.author = "author";
8484
parser.info.email = "email";
8585
parser.add_option(option_value,

test/unit/detail/format_man_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ TEST_F(format_man_test, full_info_short_and_citation)
291291

292292
// Add a short copyright & citation and test the dummy parser.
293293
parser.info.short_copyright = "short copyright";
294-
parser.info.citations = {"citation"};
294+
parser.info.citation = "citation";
295295

296296
std::string expected = this->expected + R"(.SH LEGAL
297297
\fBtest_parser Copyright: \fRshort copyright
@@ -316,7 +316,7 @@ TEST_F(format_man_test, full_info_short_long_and_citation)
316316

317317
// Add a short copyright & citation & long copyright and test the dummy parser.
318318
parser.info.short_copyright = "short copyright";
319-
parser.info.citations = {"citation"};
319+
parser.info.citation = "citation";
320320
parser.info.long_copyright = "looong copyright";
321321

322322
std::string expected = this->expected + R"(.SH LEGAL

0 commit comments

Comments
 (0)