Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ target_link_libraries(solver PRIVATE jres_solver_lib cxxopts nlohmann_json)
# --- JRES Formatter Logic ---
add_library(jres_formatter_lib STATIC src/formatter/formatter_core.cpp)
target_link_libraries(jres_formatter_lib PUBLIC jres_utils nlohmann_json)
target_include_directories(jres_formatter_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(jres_formatter_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/generated
)

# --- Formatter CLI ---
add_executable(formatter cmd/formatter/cli.cpp)
Expand Down
5 changes: 2 additions & 3 deletions cmd/formatter/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <algorithm>

#include "formatter/formatter_core.hpp"
#include "version.h"

using json = nlohmann::json;

Expand Down Expand Up @@ -44,7 +43,7 @@ int main(int argc, char* argv[]) {
auto result = options.parse(argc, argv);

if (result.count("version")) {
std::cout << "JRES Solver Version: " << JRES_VERSION_STRING << std::endl;
std::cout << "JRES Solver (formatter) Version: " << jres::get_version() << std::endl;
return 0;
}

Expand All @@ -53,7 +52,7 @@ int main(int argc, char* argv[]) {
return 0;
}

std::cout << "[App] JRES Solver " << JRES_VERSION_STRING << std::endl;
std::cout << "[App] JRES Solver (formatter) " << jres::get_version() << std::endl;

if (!result.count("input")) {
std::cerr << "Error: Input file is required (-i)" << std::endl;
Expand Down
6 changes: 2 additions & 4 deletions cmd/solver/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#include "jres_solver/jres_solver.hpp"

#include "version.h"

using json = nlohmann::json;

/**
Expand Down Expand Up @@ -50,7 +48,7 @@ int main(int argc, char **argv)

if (result.count("version"))
{
std::cout << "JRES Solver Version: " << JRES_VERSION_STRING << std::endl;
std::cout << "JRES Solver Version: " << jres_get_version() << std::endl;
return 0;
}

Expand All @@ -72,7 +70,7 @@ int main(int argc, char **argv)
bool runDiagnostics = result["diagnose"].as<bool>();

if (!quiet) {
std::cout << "[App] JRES Solver " << JRES_VERSION_STRING << std::endl;
std::cout << "[App] JRES Solver " << jres_get_version() << std::endl;
}

// Load Input JSON Data into a std::string
Expand Down
6 changes: 6 additions & 0 deletions include/jres_solver/jres_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ struct JresSolverOutput {
JRES_SOLVER_API JresSolverOutput* solve_race_schedule(const JresSolverInput* input, const JresSolverOptions* options);
JRES_SOLVER_API JresSolverOutput* diagnose_race_schedule(const JresSolverInput* input, const JresSolverOptions* options);

/**
* @brief Returns the version string of the library.
* @return A null-terminated string containing the version (e.g., "1.0.0").
*/
JRES_SOLVER_API const char* jres_get_version();

JRES_SOLVER_API JresSolverInput* jres_input_from_json(const char* jsonData);
JRES_SOLVER_API char* jres_output_to_json(const JresSolverOutput* output);

Expand Down
5 changes: 5 additions & 0 deletions src/formatter/formatter_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "utils/date_utils.hpp"
#include "utils/zip_writer.hpp"
#include "version.h"

#include <iostream>
#include <fstream>
Expand All @@ -19,6 +20,10 @@
using namespace jres;
using json = nlohmann::json;

const char* jres::get_version() {
return JRES_VERSION_STRING;
}

// --- Internal Structures ---
struct DutyBlock {
DateTime start_utc;
Expand Down
5 changes: 5 additions & 0 deletions src/formatter/formatter_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ namespace jres {
const std::string& output_file,
const std::string& format);

/**
* @brief Returns the version string of the library.
*/
const char* get_version();

// --- Exposed Helpers (for Testing) ---

std::string generate_schedule_csv_string(
Expand Down
5 changes: 5 additions & 0 deletions src/jres_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include "jres_solver/jres_solver.hpp"
#include "jres_internal_types.hpp"
#include "jres_standard_solver.hpp"
#include "version.h"

JRES_SOLVER_API const char* jres_get_version() {
return JRES_VERSION_STRING;
}

JRES_SOLVER_API JresSolverOutput* solve_race_schedule(const JresSolverInput* input, const JresSolverOptions* options) {
try {
Expand Down