Railostools

Revision as of 09:45, 14 January 2023 by Krizar (talk | contribs) (Started C++ guide)

railostools is a set of Application Programming Interfaces for Railway Operation Simulator with implementations written in Python, C++, Java and Rust. Features for each implementation vary, but include libraries for constructing and parsing metadata files, railway and timetable files. The source code is available on the Railway-Op-Sim GitHub Organisation and the project can be contributed to by anyone.

C++

The C++ library can be found in the cpp directory of the railostools repository. The framework requires a compiler which supports C++17 or greater, and has been tested on both GCC and Clang for Windows, macOS and Linux. It is recommended that the repository be added as a submodule in git to your project:

$ mkdir external
$ git submodule add https://github.com/Railway-Op-Sim/railostools.git external/railostools

and the library be linked using CMake:

cmake_minimum_required( VERSION 3.21 )
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED True )
set( RAILOSTOOLS railostools )

project( MyProject VERSION 0.1.0 LANGUAGES CXX )

# E.g. find all project source files (in 'src' directory with .cxx suffix) to compile code
file( PROJECT_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src*.cxx )

add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/external/railostools/cpp )

add_executable( ${PROJECT_NAME} ${PROJECT_SRC_FILES} )
target_link_library( ${PROJECT_NAME} PUBLIC ${RAILOSTOOLS} )
target_include_directories( ${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/railostools/cpp/include )