-
Notifications
You must be signed in to change notification settings - Fork 82
feat(clp-s): Implement part of the parsing side of the new timestamp_parser
utility.
#1385
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
base: main
Are you sure you want to change the base?
Changes from 12 commits
2ea3998
4db78ef
e79d682
fb0a3f0
10a5199
8c26f52
377b176
ba6d645
3e22cbc
a843fec
8293c92
c673b7d
bdcd7b1
921f622
6e5915b
c247921
b21dbc4
a8222d0
7d0e335
36ad265
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,12 @@ option( | |
ON | ||
) | ||
|
||
option( | ||
CLP_BUILD_CLP_S_TIMESTAMP_PARSER | ||
"Build clp_s::timestamp_parser" | ||
ON | ||
) | ||
Comment on lines
+86
to
+90
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. 🧹 Nitpick | 🔵 Trivial Add trailing period for option description. All other option descriptions end in a period. Matching that pattern keeps help text tidy. 🤖 Prompt for AI Agents
|
||
|
||
option( | ||
CLP_BUILD_CLP_S_TIMESTAMPPATTERN | ||
"Build clp_s::timestamp_pattern." | ||
|
@@ -359,6 +365,19 @@ function(set_clp_s_search_sql_dependencies) | |
) | ||
endfunction() | ||
|
||
function(validate_clp_s_timestamp_parser_dependencies) | ||
validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_TIMESTAMP_PARSER | ||
CLP_BUILD_CLP_STRING_UTILS | ||
) | ||
endfunction() | ||
|
||
function(set_clp_s_timestamp_parser_dependencies) | ||
set_clp_need_flags( | ||
CLP_NEED_DATE | ||
CLP_NEED_YSTDLIB | ||
) | ||
endfunction() | ||
Comment on lines
+368
to
+379
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. Missing dependency on CLP_BUILD_CLP_S_TIMESTAMP_PATTERN. The parser implementation pulls in function(validate_clp_s_timestamp_parser_dependencies)
validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_TIMESTAMP_PARSER
CLP_BUILD_CLP_STRING_UTILS
+ CLP_BUILD_CLP_S_TIMESTAMPPATTERN
)
endfunction()
🤖 Prompt for AI Agents
|
||
|
||
function(validate_clp_s_timestamppattern_dependencies) | ||
validate_clp_dependencies_for_target(CLP_BUILD_CLP_S_TIMESTAMPPATTERN | ||
CLP_BUILD_CLP_STRING_UTILS | ||
|
@@ -443,6 +462,11 @@ function(validate_and_setup_all_clp_dependency_flags) | |
set_clp_s_search_sql_dependencies() | ||
endif() | ||
|
||
if (CLP_BUILD_CLP_S_TIMESTAMP_PARSER) | ||
validate_clp_s_timestamp_parser_dependencies() | ||
set_clp_s_timestamp_parser_dependencies() | ||
endif() | ||
Comment on lines
+465
to
+468
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. Tests need the timestamp parser option enabled.
function(validate_clp_tests_dependencies)
validate_clp_dependencies_for_target(CLP_BUILD_TESTING
CLP_BUILD_CLP_REGEX_UTILS
CLP_BUILD_CLP_STRING_UTILS
CLP_BUILD_CLP_S_SEARCH_AST
CLP_BUILD_CLP_S_SEARCH_KQL
CLP_BUILD_CLP_S_SEARCH_SQL
CLP_BUILD_CLP_S_TIMESTAMPPATTERN
+ CLP_BUILD_CLP_S_TIMESTAMP_PARSER
)
endfunction() 🤖 Prompt for AI Agents
|
||
|
||
if (CLP_BUILD_CLP_S_TIMESTAMPPATTERN) | ||
validate_clp_s_timestamppattern_dependencies() | ||
set_clp_s_timestamppattern_dependencies() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
add_subdirectory(indexer) | ||
add_subdirectory(search) | ||
add_subdirectory(timestamp_parser) | ||
|
||
set( | ||
CLP_S_CLP_SOURCES | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
set( | ||
CLP_S_TIMESTAMP_PARSER_SOURCES | ||
../Defs.hpp | ||
TimestampParser.cpp | ||
TimestampParser.hpp | ||
ErrorCode.cpp | ||
ErrorCode.hpp | ||
) | ||
|
||
if(CLP_BUILD_CLP_S_TIMESTAMP_PARSER) | ||
add_library( | ||
clp_s_timestamp_parser | ||
${CLP_S_TIMESTAMP_PARSER_SOURCES} | ||
) | ||
add_library(clp_s::timestamp_parser ALIAS clp_s_timestamp_parser) | ||
target_compile_features(clp_s_timestamp_parser PRIVATE cxx_std_20) | ||
target_include_directories(clp_s_timestamp_parser PUBLIC ../../) | ||
target_link_libraries( | ||
clp_s_timestamp_parser | ||
PRIVATE | ||
clp::string_utils | ||
date::date | ||
ystdlib::error_handling | ||
) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "ErrorCode.hpp" | ||
|
||
#include <string> | ||
|
||
#include <ystdlib/error_handling/ErrorCode.hpp> | ||
|
||
namespace { | ||
using clp_s::timestamp_parser::ErrorCodeEnum; | ||
using ErrorCategory = ystdlib::error_handling::ErrorCategory<ErrorCodeEnum>; | ||
} // namespace | ||
|
||
template <> | ||
auto ErrorCategory::name() const noexcept -> char const* { | ||
return "clp_s::timestamp_parser::ErrorCode"; | ||
} | ||
|
||
template <> | ||
auto ErrorCategory::message(ErrorCodeEnum error_enum) const -> std::string { | ||
switch (error_enum) { | ||
case ErrorCodeEnum::InvalidTimestampPattern: | ||
return "Encountered timestamp pattern with invalid syntax."; | ||
case ErrorCodeEnum::IncompatibleTimestampPattern: | ||
return "Timestamp pattern does not match the format of the given timestamp."; | ||
case ErrorCodeEnum::InvalidDate: | ||
return "Timestamp was parsed successfully, but did not yield a valid date."; | ||
case ErrorCodeEnum::FormatSpecifierNotImplemented: | ||
return "Encountered unimplemented format specifier in timestamp pattern."; | ||
default: | ||
return "Unknown error code enum."; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef CLP_S_TIMESTAMPPARSERERRORCODE_HPP | ||
#define CLP_S_TIMESTAMPPARSERERRORCODE_HPP | ||
|
||
|
||
#include <cstdint> | ||
|
||
#include <ystdlib/error_handling/ErrorCode.hpp> | ||
|
||
namespace clp_s::timestamp_parser { | ||
enum class ErrorCodeEnum : uint8_t { | ||
InvalidTimestampPattern = 1, | ||
IncompatibleTimestampPattern, | ||
InvalidDate, | ||
FormatSpecifierNotImplemented | ||
}; | ||
|
||
using ErrorCode = ystdlib::error_handling::ErrorCode<ErrorCodeEnum>; | ||
} // namespace clp_s::timestamp_parser | ||
|
||
YSTDLIB_ERROR_HANDLING_MARK_AS_ERROR_CODE_ENUM(clp_s::timestamp_parser::ErrorCodeEnum); | ||
|
||
#endif // CLP_S_TIMESTAMPPARSERERRORCODE_HPP |
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.
Protect test sources behind the build option.
If
CLP_BUILD_CLP_S_TIMESTAMP_PARSER
is OFF, this source file should not be compiled. Consider wrapping the addition withif(CLP_BUILD_CLP_S_TIMESTAMP_PARSER)
to avoid missing-file errors when the feature is disabled.📝 Committable suggestion
🤖 Prompt for AI Agents