DataReelDataReelC++ Toolkit Documentation

Example Programs

Every example is one source file and is built and tested with this release.

Contents

Building and Running
Object database
TLS networking
General support
Plain text diagnostics

Building and Running

The examples are in the examples folder and are built with the library by CMake:

cmake -S . -B cmake-build -DCMAKE_BUILD_TYPE=Release
cmake --build cmake-build -j
cmake-build/examples/db_infohog          # Linux
cmake-build\examples\Release\db_infohog  # Windows

The database examples pause for Enter between steps; give them empty input (< /dev/null or < nul) to run straight through. The TLS servers need a certificate and key; see Certificates for making test ones. tests/run_tests.sh builds everything and runs the examples against each other and against mock mail and FTPS servers.

Object database

examples/database/simple/testprog.cpp

db_simple: gxDatabase basics: create a file, allocate, write, read and delete blocks, file statistics.

examples/database/database/testprog.cpp

db_database: Store and find fixed-size objects in a gxDatabase file.

examples/database/btree/testprog.cpp

db_btree: gxBtree index with a custom key class: insert, find, walk in order, delete.

examples/database/btree_cached/testprog.cpp

db_btree_cached: The same B-tree operations through a BtreeCache.

examples/database/btree_node/testprog.cpp

db_btree_node: Inside a B-tree node: key layout and branches.

examples/database/database_cache/testprog.cpp

db_database_cache: gxDatabaseCache write-back cache over a database file.

examples/database/defrag/testprog.cpp

db_defrag: Free-space reuse and rebuilding (defragmenting) a database file.

examples/database/pod/testprog.cpp

db_pod: POD: a data file with one or several index files opened together.

examples/database/infohog/infohog.cpp

db_infohog: InfoHog object database: records with a key and variable members, add, find, change, delete, list and reopen.

examples/database/rdbms/rdbms.cpp

db_rdbms: gxRDBMS relational table: primary and secondary keys, find, change, search and a sorted listing.

TLS networking

examples/tls/tls_echo_server.cpp

tls_echo_server: TLS server using gxsTLSServer and a ThreadPool. Usage: tls_echo_server port cert.pem key.pem

examples/tls/tls_echo_client.cpp

tls_echo_client: TLS client with certificate checking. Usage: tls_echo_client host port [--ca ca.pem] [--insecure]

examples/tls/https_get.cpp

https_get: Fetch a URL or download a file with gxsHTTPClient. Usage: https_get url [file] [--ca ca.pem]

examples/tls/https_server.cpp

https_server: Small HTTPS file server built on gxsHTTPReadRequest() and gxsHTTPWriteResponse().

examples/tls/smtp_send.cpp

smtp_send: Send mail over implicit TLS or STARTTLS.

examples/tls/pop3_list.cpp

pop3_list: List and read a POP3 mailbox over TLS.

examples/tls/ftps_client.cpp

ftps_client: List, download and upload with FTPS.

examples/tls/stream_server.cpp

stream_server: gxStream server that stores client blocks in a gxDatabase file.

examples/tls/stream_client.cpp

stream_client: gxStream client that stores and reads back blocks over TLS.

General support

examples/general/config_file.cpp

config_file: gxConfig: write, read and change a configuration file.

examples/general/logfile.cpp

logfile: LogFile shared by several threads.

examples/general/thread_pool.cpp

thread_pool: ThreadPool tasks, results and exceptions.

Plain text diagnostics

examples/diagnostics/ping.cpp

ping: ICMP and ICMPv6 echo. Usage: ping host [count] [-4|-6]

examples/diagnostics/telnet_client.cpp

telnet_client: Telnet login and command (plain text; trusted networks only).