Skip to content

Commit d98fd52

Browse files
authored
Add support for Json format input files (#118)
This change introduces a JSON parser and serializer for handling input options. While the overall implementation is incomplete, key functionality has been added. Changes: - Add nlohmann json to CMakeLists.txt - Update to C++20 - Update CMake version as needed - Add JsonParser for parsing a single options file - Add JsonSerializer for serializing a single options file - Refactor existing serialization to "LegacySerializer" - Remove: cvDoubleVec jointXcoord cvDoubleVec jointYcoord cvDoubleVec jointZcoord from options (unused) - Add "nodeAssociation" to joints list for explicit node associations in future updates TODO: - Add support for nested option files in JSON parser - Add a converter for legacy format - Update joint creation to use explicit node associations - Update legacy parser to provide implicit node associations so they can be reused - Verify changes against existing tests - Add tests for parser, converter, etc.
1 parent 4aac52c commit d98fd52

16 files changed

+1587
-586
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ build
3838
.cproject
3939
.project
4040
.settings/
41-
.vscode/
41+
42+
# Vscode
43+
.vscode/

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ if (BUILD_SV_INSTALLER)
111111
add_subdirectory("${CMAKE_SOURCE_DIR}/Distribution")
112112
ENDIF()
113113

114+
# NLOHMANN JSON FOR SERIALIZATION
115+
include(FetchContent)
116+
FetchContent_Declare(
117+
nlohmann_json
118+
GIT_REPOSITORY https://github.com/nlohmann/json.git
119+
GIT_TAG v3.11.2 # You can specify a version or use the latest tag
120+
)
121+
FetchContent_MakeAvailable(nlohmann_json)
122+
target_include_directories(${PROJECT_NAME} PUBLIC ${nlohmann_json_SOURCE_DIR}/single_include)
123+
114124
# Unit tests and Google Test
115125
if(ENABLE_UNIT_TEST)
116126

@@ -164,6 +174,13 @@ if(ENABLE_UNIT_TEST)
164174
# handle both use cases.
165175
target_link_libraries(UnitTestsExecutable gtest gtest_main pthread)
166176

177+
# We need to include Nlohmann when compiling the unit test executable
178+
# A better strategy would be to build up a list of what we're going to
179+
# include and reuse it.
180+
# Another option: we could simply build the library of cvOneD functionality
181+
# and link against that both here and in the main executable.
182+
target_include_directories(UnitTestsExecutable PRIVATE ${nlohmann_json_SOURCE_DIR}/single_include)
183+
167184
# It's likely we'll need to include additional directories for some
168185
# versions of the unit tests. That can be updated when/if we update
169186
# the general strategy.

0 commit comments

Comments
 (0)