DataReelDataReelC++ Transition Guide

DataReel 6.4 C++ Transition Guide

How to move DataReel 6.x programs from the library's own classes to the C++11, C++17 and C++20 standard library, with every 6.4 example program side by side with its modern equivalent.

Release status. DataReel 6.4.3 is the legacy release: bug fixes and security updates only, no new features. DataReel 7.5 is the main, fully supported release. This guide changes no 6.x library feature: it is documentation and example programs. Use it to modernize the code around DataReel in an existing 6.x program, or as a first step toward DataReel 7.
Contents

What moves and what stays
C++11, C++17 and C++20 at a glance
Transition tables
Threads
Strings and text
Containers and memory
Files and time
Database (stays DataReel)
Networking (stays DataReel or POSIX)
Differences that bite
Building and testing the examples
All 82 modern examples

What moves and what stays

Much of DataReel 6 was written before C++ had threads, file system calls, string views or smart pointers, so the library carried its own. Those parts now have standard replacements, and moving to them makes a program shorter, safer and portable without DataReel:

Other parts have no standard replacement, and stay DataReel classes, with modern C++ around them:

The 82 modern programs cover all 93 source files of the 6.4 example programs. Every one of them builds with each C++ standard from the one it names up to C++20 and runs as a self test: client and server pairs run both ends in one process on 127.0.0.1, and the protocol clients talk to a scripted local server, so no network or outside server is needed.

C++11, C++17 and C++20 at a glance

StandardWhat it brings to a DataReel 6 program
C++11std::thread, std::mutex, std::condition_variable, std::async/std::future, thread_local, std::chrono, std::unique_ptr, lambdas, auto, range-for, move semantics, std::array, std::unordered_map, <random>, static_assert.
C++14std::make_unique, generic lambdas, chrono literals (1s, 500ms).
C++17<filesystem>, std::string_view, std::optional, std::variant, std::from_chars/std::to_chars, std::scoped_lock, structured bindings, if constexpr, fold expressions, std::set::extract, the _v type traits.
C++20std::jthread and std::stop_token, std::latch, std::barrier, std::counting_semaphore, std::span, std::format, chrono calendar dates, ranges, starts_with/ends_with, std::endian, std::bit_cast, designated initializers, char8_t.

Compilers: the examples were built and run with GCC 14 on RHEL 10. The C++20 examples need a standard library with std::format, std::jthread and the chrono calendar: GCC 13 or later, Visual Studio 2022, or Clang 18 or later with libc++. Set the standard with -std=c++20, /std:c++20 or CMAKE_CXX_STANDARD 20.

Transition tables

Each row is a DataReel 6.4 class or call, its modern replacement and the standard that has it. Every example page lists the rows that apply to its legacy program.

Threads

DataReel 6.4Modern C++StandardNotes
gxThread subclass, CreateThread()std::thread t(callable, args...)C++11Any function, lambda or functor runs in the thread; arguments are copied with their types (no void *).
JoinThread()t.join(); std::future::get()C++11join() waits; a std::async future's get() also returns the result.
DestroyThread(), delete gxThread_tnothing: the std::thread object owns the threadC++11Join or detach before the object is destroyed, or use std::jthread, which joins itself.
CancelThread(), ThreadCleanupHandler()std::jthread::request_stop() + std::stop_token; cleanup in a destructorC++20Cancellation is cooperative: the thread checks stop_requested() or waits on a condition_variable_any with the token.
ExitThread(), GetThreadExitCode()return a value; std::async / std::future::get()C++11An exception thrown in the thread comes out of get().
SuspendThread(), ResumeThread()std::binary_semaphore acquire()/release()C++20A thread waits for itself; no thread is stopped from outside (C++11: mutex + condition_variable + bool).
sSleep(), mSleep(), uSleep(), nSleep()std::this_thread::sleep_for(1s), (500ms), (100us), (100ns)C++11 (literals C++14)The unit is part of the std::chrono duration type.
gxTHREAD_TYPE_DETACHEDt.detach(); std::latch to wait for the workC++11 / C++20A latch replaces 'sleep and hope the threads are done'.
SetThreadPriority()t.native_handle() + pthread_setschedparam() / SetThreadPriority()platformThe standard has no priorities; a std::priority_queue orders work.
CreateThread(..., stack size)pthread_attr_setstacksize() / _beginthreadex()platformstd::thread cannot set a stack size.
thrPool, CreateThreadPool()a small pool: std::thread workers, std::queue, std::condition_variable, std::packaged_taskC++11 (C++17 invoke_result)submit() returns a std::future; the destructor joins the workers.
gxMutex, MutexLock()/MutexUnlock()std::mutex + std::scoped_lock / std::lock_guard / std::unique_lockC++11 / C++17The lock is released by a destructor on every path, so a return cannot leave it locked.
robust mutex, MakeConsistent()std::timed_mutex::try_lock_for(); a POSIX robust mutex wrapped as a LockableC++11 / POSIXWithin one process RAII locks make an abandoned mutex impossible.
gxCondition, ConditionWait()/ConditionSignal()std::condition_variable wait(lock, predicate) / notify_one()C++11The predicate form handles spurious wake ups.
ConditionTimedWait()std::condition_variable::wait_for() / wait_until()C++11Waits use std::chrono::steady_clock.
gxThreadKey, ThreadSetSpecific()/ThreadGetSpecific()thread_local variablesC++11One copy per thread, built in the thread and destroyed when it ends.
gxSemaphorestd::counting_semaphore / std::binary_semaphoreC++20
gxThread_t IDs and state messagesstd::thread::id, std::this_thread::get_id(); program-owned std::atomic stateC++11

Strings and text

DataReel 6.4Modern C++StandardNotes
gxString / UStringstd::string, std::string_viewC++98 / C++17string_view looks at text without copying it.
Find(), IFind(), FindLast()find(), a std::search with a case-folding predicate, rfind()C++98Watch out: rfind("") returns size(), where FindLast("") returns -1.
DeleteAt(), InsertAt(), ReplaceAt(), ReplaceString()erase(), insert(), replace(); std::replace for charactersC++98A count past the end is clamped; a position past the end throws std::out_of_range.
Left(), Mid(), Right()substr() on std::string or std::string_viewC++98 / C++17
TrimLeading(), TrimTrailing()find_first_not_of() / find_last_not_of() + substr()C++98
ToUpper(), ToLower()std::transform with std::toupper on unsigned charC++98
StringICompare()a small iequals() (std::equal with a folding predicate)C++98
Atoi(), Atol(), Atof(), atoi()std::from_chars() into std::optional<T>; std::stoi()C++17Overflow and junk are reported, not turned into 0.
SetWidth(), SetFill(), Precision(), sprintf()std::format("{:*>10} {:.3f}", ...)C++20C++17 and older: <iomanip> setw, setfill, setprecision.
UStringw, wide stringsstd::wstring; std::u8string (char8_t) for UTF-8C++98 / C++20std::codecvt is deprecated since C++17: convert with the platform API.
gxsBase64Encode()/Decode()a short RFC 4648 function over std::string_view returning std::optionalC++17No standard Base64.

Containers and memory

DataReel 6.4Modern C++StandardNotes
gxList, gxListNodestd::list; splice() for MoveBefore()/MoveAfter()C++98The list owns its nodes: no DestroyList()/DestroyArrayList().
gxBStreestd::set / std::map; extract() for ExtractFirst()C++98 / C++17A balanced tree; contains() in C++20.
MemoryBufferstd::vector<unsigned char> or std::vector<std::byte>; std::span for viewsC++98 / C++17 / C++20std::search finds a byte pattern; std::fill for MemSet().
new / deleteautomatic objects, containers, std::unique_ptr / std::make_uniqueC++11 / C++14Ownership is in the type, and release() shows a hand-over.
strcpy(), strncpy(), memmove() into char arraysstd::string; std::array<char, N> + string_view::copy()C++11 / C++17

Files and time

DataReel 6.4Modern C++StandardNotes
DiskFileBstd::fstream (read, write, seekg/seekp, tellg)C++98
futils_*(), df_mkdir(), df_copy() ...std::filesystem (directory_iterator, create_directory, file_size, copy_file, rename, remove, current_path)C++17Errors through std::error_code or std::filesystem_error.
LogFilestd::ofstream + std::chrono::system_clock + std::formatC++11 / C++20Keep LogFile's 6.3 rules: owner-only file, no write through a symbolic link.
gxConfigstd::getline() into a std::map; std::optional lookups; std::from_charsC++17A rewrite through a temporary file and rename().
gxDeviceCache, gxDeviceBucketCachestreams buffer themselves: std::filesystem::copy_file(), out << in.rdbuf()C++17
clock(), SysTime, GetSystemTime()std::chrono::steady_clock (elapsed), system_clock (calendar)C++11clock() is CPU time, not elapsed time.
CDatestd::chrono::year_month_day, sys_daysC++20An impossible date is !ok().

Database (stays DataReel)

DataReel 6.4Modern C++StandardNotes
gxDatabasekeep gxDatabase: a stack object, errors as exceptions, static_assert(std::is_trivially_copyable_v<Record>)C++17The standard library has no database file; the file format is DataReel's.
gxBtree, DatabaseKeyB key classeskeep gxBtree; key classes with std::array storage and correct copies (rule of three); std::set for in-memory indexesC++11 / C++17DatabaseKeyB's copy keeps the other object's db_key pointer: define the copies.
BtreeCachekeep BtreeCache; flush it with an RAII guardC++11
POD, InfoHogkeep them; std::unique_ptr + release() for PODIndexFile ownership; std::optional membersC++17
gxdJournal Begin()/Commit()/Rollback()keep gxdJournal; an RAII Transaction that rolls back unless commit() was calledC++11
gxv7VectorIndex, gxv7ObjRepl, gxv7ObjectClientkeep them; std::span, <random>, std::ranges for checksC++20Needs DATAREEL7_FEATURES_DIR.

Networking (stays DataReel or POSIX)

DataReel 6.4Modern C++StandardNotes
gxSocketkeep gxSocket (C++ has no sockets); servers in std::jthread with std::stop_token and select() timeoutsC++20Stopping is a request, not a canceled thread blocked in accept().
GetHostInformation(), gethostbyname()getaddrinfo() owned by std::unique_ptr<addrinfo, decltype(&freeaddrinfo)>C++11 + POSIX/Winsock 2IPv4 and IPv6, thread safe.
gxsPing (raw socket, root)unprivileged ICMP socket (SOCK_DGRAM, IPPROTO_ICMP) on LinuxPOSIX
gxSSLkeep gxSSL; certificate checking on (SetCAList + RequireVerifyCert); RAII closeC++11
gxsHTTPClient, gxsSMTPClient, gxsPOP3Client, gxsIMAPClient, gxsFTPClient, gxsTelnetClientkeep them; std::string buffers; reply parsing with std::string_view and std::from_charsC++17
gxStream, gxDatagram blockskeep gxStream for mutual TLS; length-checked blocks with std::span, std::endian, std::optionalC++20

Differences that bite

Building and testing the examples

The examples have their own CMake project, which builds the 6.4.3 library from the parent folder with the same standard:

cmake -S examples_modern -B build-modern -DCMAKE_BUILD_TYPE=Release   # C++20 by default
cmake --build build-modern -j
cmake -S examples_modern -B build-modern17 -DCMAKE_CXX_STANDARD=17   # the C++17 subset

Add -DDATAREEL7_FEATURES_DIR=/path/to/datareel-7.4 (7.4 or later) for the vector index, vector client and replication examples. examples_modern/run_modern_tests.sh [DATAREEL7_DIR] builds every example with each standard from its minimum to C++20 (C++11 and C++14 directly with the compiler, C++17 and C++20 with CMake) and runs every C++20 program as a self test. Standard-library-only examples also build alone, for example g++ -std=c++11 -pthread examples_modern/threads/condition/modern.cpp.

Tested on 11/30/2026 on RHEL 10.3 with GCC 14.4 and OpenSSL 3.5, with the DataReel 7.5 source tree for the 7.x features. On Windows 11 with Visual Studio 2026 (Schannel) the 6.4.3 library builds with C++17 and C++20, and the 69 examples that are not marked POSIX and do not need the 7.x features build with C++20 and pass (the three TLS examples with .pem files made with openssl, since Schannel cannot make keys). Programs marked POSIX use Linux or UNIX calls.