forked from y-scope/clp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75b9bbd
commit 5990117
Showing
5 changed files
with
89 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "RegexErrorCode.hpp" | ||
|
||
#include <string> | ||
|
||
#include <error_handling/ErrorCode.hpp> | ||
//#include "GenericErrorCode.hpp" | ||
|
||
namespace clp::error_handling { | ||
template <> | ||
auto clp::regex_utils::RegexErrorCategory::name() const noexcept -> char const* { | ||
return "regex utility"; | ||
} | ||
|
||
template <> | ||
auto clp::regex_utils::RegexErrorCategory::message(int ev) const -> std::string { | ||
switch (static_cast<clp::regex_utils::RegexErrorEnum>(ev)) { | ||
case clp::regex_utils::RegexErrorEnum::Success: | ||
return "Success."; | ||
|
||
case clp::regex_utils::RegexErrorEnum::IllegalState: | ||
return "Unrecognized state."; | ||
|
||
case clp::regex_utils::RegexErrorEnum::Star: | ||
return "Failed to translate due to metachar `*` (zero or more occurences)."; | ||
|
||
case clp::regex_utils::RegexErrorEnum::Plus: | ||
return "Failed to translate due to metachar `+` (one or more occurences)."; | ||
|
||
case clp::regex_utils::RegexErrorEnum::Question: | ||
return "Currently does not support returning a list of wildcard translations. The " | ||
"metachar `?` (lazy match) may be supported in the future."; | ||
|
||
default: | ||
return "(unrecognized error)"; | ||
} | ||
} | ||
} | ||
|
||
template class clp::error_handling::ErrorCategory<clp::regex_utils::RegexErrorEnum>; | ||
template class clp::error_handling::ErrorCode<clp::regex_utils::RegexErrorEnum>; |
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,40 @@ | ||
#ifndef CLP_REGEXERRORCODE_HPP | ||
#define CLP_REGEXERRORCODE_HPP | ||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <system_error> | ||
|
||
#include <error_handling/ErrorCode.hpp> | ||
//#include "GenericErrorCode.hpp" | ||
|
||
namespace clp::regex_utils { | ||
enum class RegexErrorEnum : uint8_t { | ||
Success = 0, | ||
IllegalState, | ||
Star, | ||
Plus, | ||
Question, | ||
Pipe, | ||
Caret, | ||
Dollar, | ||
DisallowedEscapeSequence, | ||
UnmatchedParenthesis, | ||
UnsupportedCharsets, | ||
IncompleteCharsetStructure, | ||
UnsupportedQuantifier, | ||
TokenUnquantifiable, | ||
}; | ||
|
||
//using RegexErrorCategory = clp::error_handling::ErrorCategory<RegexErrorEnum>; | ||
//using RegexErrorCode = clp::error_handling::ErrorCode<RegexErrorEnum>; | ||
using RegexErrorCategory = clp::error_handling::ErrorCategory<RegexErrorEnum>; | ||
using RegexErrorCode = clp::error_handling::ErrorCode<RegexErrorEnum>; | ||
} // namespace clp::regex_utils | ||
|
||
namespace std { | ||
template <> | ||
struct is_error_code_enum<clp::regex_utils::RegexErrorCode> : std::true_type {}; | ||
} // namespace std | ||
|
||
#endif // CLP_REGEXERRORCODE_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
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