-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CondaURL::pretty_str #2830
Merged
Merged
Add CondaURL::pretty_str #2830
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,43 @@ | |
|
||
namespace mamba::util | ||
{ | ||
namespace detail | ||
{ | ||
// Working around MSVC limitation on private inheritance + using directive | ||
|
||
enum class StripScheme : bool | ||
{ | ||
no, | ||
yes | ||
}; | ||
|
||
enum class HideConfidential : bool | ||
{ | ||
no, | ||
yes | ||
}; | ||
|
||
struct Encode | ||
{ | ||
inline static constexpr struct yes_type | ||
{ | ||
} yes = {}; | ||
inline static constexpr struct no_type | ||
{ | ||
} no = {}; | ||
}; | ||
|
||
struct Decode | ||
{ | ||
inline static constexpr struct yes_type | ||
{ | ||
} yes = {}; | ||
inline static constexpr struct no_type | ||
{ | ||
} no = {}; | ||
}; | ||
} | ||
|
||
/** | ||
* Class representing a URL. | ||
* | ||
|
@@ -21,20 +58,10 @@ namespace mamba::util | |
{ | ||
public: | ||
|
||
// clang-format off | ||
enum class StripScheme : bool { no, yes }; | ||
enum class HidePassword : bool { no, yes }; | ||
struct Encode | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the limitations mentionned above due to inner types? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
{ | ||
inline static constexpr struct yes_type {} yes = {}; | ||
inline static constexpr struct no_type {} no = {}; | ||
}; | ||
struct Decode | ||
{ | ||
inline static constexpr struct yes_type {} yes = {}; | ||
inline static constexpr struct no_type {} no = {}; | ||
}; | ||
// clang-format on | ||
using StripScheme = detail::StripScheme; | ||
using HideConfidential = detail::HideConfidential; | ||
using Encode = detail::Encode; | ||
using Decode = detail::Decode; | ||
|
||
inline static constexpr std::string_view https = "https"; | ||
inline static constexpr std::string_view localhost = "localhost"; | ||
|
@@ -197,14 +224,20 @@ namespace mamba::util | |
* asset. | ||
* @param strip_scheme If true, remove the scheme and "localhost" on file URI. | ||
* @param rstrip_path If non-null, remove the given charaters at the end of the path. | ||
* @param hide_password If true, hide password in the decoded string. | ||
* @param hide_confidential If true, hide password in the decoded string. | ||
*/ | ||
[[nodiscard]] auto pretty_str( | ||
StripScheme strip_scheme = StripScheme::no, | ||
char rstrip_path = 0, | ||
HidePassword hide_password = HidePassword::no | ||
HideConfidential hide_confidential = HideConfidential::no | ||
) const -> std::string; | ||
|
||
protected: | ||
|
||
[[nodiscard]] auto | ||
pretty_str_path(StripScheme strip_scheme = StripScheme::no, char rstrip_path = 0) const | ||
-> std::string; | ||
|
||
private: | ||
|
||
std::string m_scheme = std::string(https); | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you detail the limitations? I never had any issue with using private inheritance + using directive on Windows, so this must be specific to some uses.
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.
It works for methods but not dependent types.
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.
Or maybe I missed somthing...