.. _dip-getting-started: Getting started =============== Native example -------------- This page shows the smallest native DIP workflow: register DIPL text, evaluate it, and read one known value. .. code-block:: cpp #include #include #include int main() { snt::dip::DIP parser; parser.add_string( "distance float = 12 m\n" "duration float = 3 s\n" "speed float = ({?distance} / {?duration}) m/s\n" ); snt::dip::Environment env = parser.parse(); std::cout << env["speed"].as() << "\n"; return 0; } ``parse()`` evaluates the declarations and returns an ``Environment``. The known path ``speed`` is read through an environment cursor; its units and provenance remain available through the same cursor. Build and run ------------- Install the C++ package using :doc:`../../installation` with the ``DIP`` module enabled. Save the example above as ``main.cpp`` and create this ``CMakeLists.txt`` in the same directory: .. code-block:: cmake cmake_minimum_required(VERSION 3.22) project(snt_dip_example LANGUAGES C CXX) find_package(snt CONFIG REQUIRED) add_executable(application main.cpp) target_compile_features(application PRIVATE cxx_std_17) target_link_libraries(application PRIVATE snt-dip) Configure with the installed package prefix, build, and run: .. code-block:: console cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/snt cmake --build build ./build/application Expected output: .. code-block:: text 4 Replace ``/path/to/snt`` with the installation prefix; omit that option if CMake already finds SNT. C is enabled for discovery of HDF5 in packages built with DIP support. See :ref:`cmake-consumer` for package discovery details. Continue with :doc:`Concepts and model ` for the core objects, :doc:`Workflows ` for common task sequences, and :doc:`Parsing and environments ` for source composition, cursors, schemas, and overrides.