User Tutorial

See also

Developer Tutorial
Extending RST by adding types or converters

This tutorial explains using RST in programs.

C++

In order to use the RST library in a C++ project based on the CMake build system, add the following lines to you CMakeLists.txt file:

FIND_PACKAGE(RST REQUIRED)
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${RST_INCLUDE_DIRS})
ADD_DEFINITIONS(${RST_CFLAGS})

This will search for RST and makes the include directories available.

In case you also want to use data types from the sandbox, use these lines instead:

FIND_PACKAGE(RST REQUIRED COMPONENTS sandbox)
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${RST_INCLUDE_DIRS})
ADD_DEFINITIONS(${RST_CFLAGS} ${RSTSANDBOX_CFLAGS})

Important

Do not omit the ADD_DEFINITIONS line. Otherwise you end up with hard to interpret compiler errors.

Afterwards you can construct a usual target in CMake and finally link it against RST:

ADD_EXECUTABLE(tester tester.cpp)
TARGET_LINK_LIBRARIES(tester ${RST_LIBRARIES}) # only stable
TARGET_LINK_LIBRARIES(tester ${RST_LIBRARIES} ${RSTSANDBOX_LIBRARIES}) # only stable

Java

Add rst.jar and if you need sandbox types rstsandbox.jar to your project’s classpath. These jars are installed under PREFIX/share/java/, where PREFIX was chosen by you during the installation as described in Installing RST.

RST depends on Google Protocol Buffers. So make sure that their jar file is also available on the classpath.

Python

The installation installs Python eggs to PREFIX/lib/python2.7/dist-packages/ or PREFIX/lib/python2.7/site-packages/ (depending on your Python installation, watch the CMake installation output), where PREFIX was chosen by you during the installation as described in Installing RST. Add this path to your PYTHONPATH as well as all contained *.egg files, e.g. by executing this code before launching the Python interpreter:

$ export PYTHONPATH=PREFIX/lib/python2.7/dist-packages/:PREFIX/lib/python2.7/dist-packages/rst-0.10*.egg:PREFIX/lib/python2.7/dist-packages/rstsandbox-0.10*.egg:$PYTHONPATH
$ python2

Note

The installation path PREFIX mentioned above depends on your system’s Python 2 version. Please verify this version with python2 --version and adapt the path accordingly if necessary.

Inside your Python project you can afterwards import rst and optionally rstsandbox:

import rst
import rstsandbox

Important

Always access all types, also the ones contained in the rstsandbox module, through the rst module. We have implemented special support for this non-standard behavior. By doing so, you shield your Python project against potential moves of data types from sandbox to stable, which would otherwise require changes to your code.

E.g. assuming you want to access the sandbox data type rst.foo.Bar, use the following import statements in your code:

import rst
import rstsandbox
from rst.foo.Bar_pb2 import Bar

Table Of Contents

Related Documentation

This Page