generated from seqan/app-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from smehringer/debug_stream_alternative
[MISC] Remove seqan3::debug_stream and seqan3::detail::to_string.
- Loading branch information
Showing
9 changed files
with
128 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// ----------------------------------------------------------------------------------------------------------- | ||
// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin | ||
// Copyright (c) 2016-2021, 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/sharg-parser/blob/master/LICENSE.md | ||
// ----------------------------------------------------------------------------------------------------------- | ||
|
||
/*!\file | ||
* \author Svenja Mehringer <svenja.mehringer AT fu-berlin.de> | ||
* \brief Provides sharg::detail::to_string. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <sstream> | ||
|
||
#include <sharg/detail/concept.hpp> | ||
#include <sharg/concept.hpp> | ||
|
||
namespace sharg::detail | ||
{ | ||
|
||
/*!\brief Streams all parameters via std::ostringstream and returns a concatenated string. | ||
* \tparam value_types Must be sharg::ostreamable (stream << value). | ||
* \param[in] values Variable number of parameters of any type that implement the stream operator. | ||
* \returns A concatenated string of all values (no separator in between is added). | ||
*/ | ||
template <typename ...value_types> | ||
requires (ostreamable<value_types> && ...) | ||
std::string to_string(value_types && ...values) | ||
{ | ||
std::stringstream stream; | ||
|
||
auto print = [&stream] (auto val) | ||
{ | ||
if constexpr (is_container_option<decltype(val)>) | ||
{ | ||
if (val.empty()) | ||
{ | ||
stream << "[]"; | ||
} | ||
else | ||
{ | ||
stream << '['; | ||
stream << val[0]; | ||
for (size_t i = 1; i < val.size(); ++i) | ||
stream << ", " << val[i]; | ||
stream << ']'; | ||
} | ||
} | ||
else if constexpr (std::is_same_v<std::remove_cvref_t<decltype(val)>, int8_t> || | ||
std::is_same_v<std::remove_cvref_t<decltype(val)>, uint8_t>) | ||
{ | ||
stream << static_cast<int16_t>(val); | ||
} | ||
else | ||
{ | ||
stream << val; | ||
} | ||
}; | ||
|
||
(print(std::forward<value_types>(values)),...); | ||
|
||
return stream.str(); | ||
} | ||
|
||
} // namespace sharg::detail |
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
b86e79e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: