Skip to content

Commit 41e2f24

Browse files
authored
Refactor parsing functions to return std::error_code and simplify error handling; update tests for ISO 8601 parsing. (#4)
* Refactor parsing functions to return std::error_code and simplify error handling; update tests for ISO 8601 parsing. * Refactor parsing functions to improve readability and maintainability; add free parsing functions for year, month, day, hour, minute, second, and fraction.
1 parent 5999001 commit 41e2f24

File tree

4 files changed

+230
-104
lines changed

4 files changed

+230
-104
lines changed

CMakeLists.txt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ project(
55
VERSION 1.0
66
LANGUAGES CXX)
77

8+
option(CHRONO_PARSE_BUILD_DOCS "Build documentation" OFF)
9+
option(CHRONO_PARSE_BUILD_EXAMPLE "Build example" ON)
10+
option(CHRONO_PARSE_NO_INSTALL "Skip installation of enum_name" OFF)
11+
option(CHRONO_PARSE_NO_TESTS "Skip testing of enum_name" OFF)
12+
813
# Define the library
914
add_library(chrono_parse INTERFACE)
1015
add_library(mgutility::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
@@ -65,21 +70,23 @@ if(NOT ${CHRONO_PARSE_NO_INSTALL})
6570
NAMESPACE mgutility::)
6671
endif()
6772

68-
# FetchContent to get the fmt library
69-
include(FetchContent)
70-
FetchContent_Declare(
71-
fmt
72-
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
73-
GIT_TAG 8.1.1) # Change the tag to the desired version
74-
FetchContent_MakeAvailable(fmt)
73+
if(${CHRONO_PARSE_BUILD_EXAMPLE})
74+
# FetchContent to get the fmt library
75+
include(FetchContent)
76+
FetchContent_Declare(
77+
fmt
78+
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
79+
GIT_TAG 8.1.1) # Change the tag to the desired version
80+
FetchContent_MakeAvailable(fmt)
7581

76-
# Add example executable
77-
add_executable(example_chrono_parse example/main.cpp)
82+
# Add example executable
83+
add_executable(example_chrono_parse example/main.cpp)
7884

79-
# Link the example executable with the library
80-
target_link_libraries(example_chrono_parse PRIVATE mgutility::chrono_parse fmt::fmt)
85+
# Link the example executable with the library
86+
target_link_libraries(example_chrono_parse PRIVATE mgutility::chrono_parse fmt::fmt)
87+
endif()
8188

82-
# if(NOT ${CHRONO_PARSE_NO_TESTS})
89+
if(NOT ${CHRONO_PARSE_NO_TESTS})
8390
# Enable testing
8491
enable_testing()
8592

@@ -100,7 +107,7 @@ target_link_libraries(example_chrono_parse PRIVATE mgutility::chrono_parse fmt::
100107

101108
# Add tests
102109
add_test(NAME test_chrono_parse COMMAND test_chrono_parse)
103-
# endif()
110+
endif()
104111

105112
if(${CHRONO_PARSE_BUILD_DOCS})
106113
add_subdirectory(doc)

0 commit comments

Comments
 (0)