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.
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:
- Threads and synchronization (gxThread, gxMutex, gxCondition, gxSemaphore, thread-specific data, thread pools) move to
<thread>,<mutex>,<condition_variable>,<future>,thread_local, and in C++20std::jthread,std::stop_token,<semaphore>and<latch>. - Strings, containers and buffers (gxString, gxList, gxBStree, MemoryBuffer) move to
std::string,std::string_view,std::list,std::set/std::map,std::vectorandstd::span. - Files, directories, configuration, logs and time (DiskFileB, futils, gxConfig, LogFile, SysTime, CDate) move to
<fstream>,<filesystem>,<charconv>,<chrono>and<format>.
Other parts have no standard replacement, and stay DataReel classes, with modern C++ around them:
- The object database (gxDatabase, gxBtree, POD, InfoHog, the page cache and journal): the file format is DataReel's, and DataReel 7 reads and writes the same files. The examples keep the classes and add RAII, exceptions, compile-time layout checks and std::filesystem.
- Sockets, TLS and the protocol clients (gxSocket, gxSSL, gxStream, HTTP, SMTP, POP3, IMAP, FTP, telnet): C++20 and C++23 did not adopt networking. The examples keep the classes, run servers in
std::jthreads that stop through astd::stop_token, and parse replies withstd::string_viewandstd::from_chars. - HTML and XML parsing: no standard parser. The examples show what the standard library gives (fast scanning with string_view) and point to parser libraries.
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
| Standard | What it brings to a DataReel 6 program |
|---|---|
| C++11 | std::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++14 | std::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++20 | std::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.4 | Modern C++ | Standard | Notes |
|---|---|---|---|
| gxThread subclass, CreateThread() | std::thread t(callable, args...) | C++11 | Any function, lambda or functor runs in the thread; arguments are copied with their types (no void *). |
| JoinThread() | t.join(); std::future::get() | C++11 | join() waits; a std::async future's get() also returns the result. |
| DestroyThread(), delete gxThread_t | nothing: the std::thread object owns the thread | C++11 | Join 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 destructor | C++20 | Cancellation 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++11 | An exception thrown in the thread comes out of get(). |
| SuspendThread(), ResumeThread() | std::binary_semaphore acquire()/release() | C++20 | A 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_DETACHED | t.detach(); std::latch to wait for the work | C++11 / C++20 | A latch replaces 'sleep and hope the threads are done'. |
| SetThreadPriority() | t.native_handle() + pthread_setschedparam() / SetThreadPriority() | platform | The standard has no priorities; a std::priority_queue orders work. |
| CreateThread(..., stack size) | pthread_attr_setstacksize() / _beginthreadex() | platform | std::thread cannot set a stack size. |
| thrPool, CreateThreadPool() | a small pool: std::thread workers, std::queue, std::condition_variable, std::packaged_task | C++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_lock | C++11 / C++17 | The 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 Lockable | C++11 / POSIX | Within one process RAII locks make an abandoned mutex impossible. |
| gxCondition, ConditionWait()/ConditionSignal() | std::condition_variable wait(lock, predicate) / notify_one() | C++11 | The predicate form handles spurious wake ups. |
| ConditionTimedWait() | std::condition_variable::wait_for() / wait_until() | C++11 | Waits use std::chrono::steady_clock. |
| gxThreadKey, ThreadSetSpecific()/ThreadGetSpecific() | thread_local variables | C++11 | One copy per thread, built in the thread and destroyed when it ends. |
| gxSemaphore | std::counting_semaphore / std::binary_semaphore | C++20 | |
| gxThread_t IDs and state messages | std::thread::id, std::this_thread::get_id(); program-owned std::atomic state | C++11 |
Strings and text
| DataReel 6.4 | Modern C++ | Standard | Notes |
|---|---|---|---|
| gxString / UString | std::string, std::string_view | C++98 / C++17 | string_view looks at text without copying it. |
| Find(), IFind(), FindLast() | find(), a std::search with a case-folding predicate, rfind() | C++98 | Watch out: rfind("") returns size(), where FindLast("") returns -1. |
| DeleteAt(), InsertAt(), ReplaceAt(), ReplaceString() | erase(), insert(), replace(); std::replace for characters | C++98 | A 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_view | C++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 char | C++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++17 | Overflow and junk are reported, not turned into 0. |
| SetWidth(), SetFill(), Precision(), sprintf() | std::format("{:*>10} {:.3f}", ...) | C++20 | C++17 and older: <iomanip> setw, setfill, setprecision. |
| UStringw, wide strings | std::wstring; std::u8string (char8_t) for UTF-8 | C++98 / C++20 | std::codecvt is deprecated since C++17: convert with the platform API. |
| gxsBase64Encode()/Decode() | a short RFC 4648 function over std::string_view returning std::optional | C++17 | No standard Base64. |
Containers and memory
| DataReel 6.4 | Modern C++ | Standard | Notes |
|---|---|---|---|
| gxList, gxListNode | std::list; splice() for MoveBefore()/MoveAfter() | C++98 | The list owns its nodes: no DestroyList()/DestroyArrayList(). |
| gxBStree | std::set / std::map; extract() for ExtractFirst() | C++98 / C++17 | A balanced tree; contains() in C++20. |
| MemoryBuffer | std::vector<unsigned char> or std::vector<std::byte>; std::span for views | C++98 / C++17 / C++20 | std::search finds a byte pattern; std::fill for MemSet(). |
| new / delete | automatic objects, containers, std::unique_ptr / std::make_unique | C++11 / C++14 | Ownership is in the type, and release() shows a hand-over. |
| strcpy(), strncpy(), memmove() into char arrays | std::string; std::array<char, N> + string_view::copy() | C++11 / C++17 |
Files and time
| DataReel 6.4 | Modern C++ | Standard | Notes |
|---|---|---|---|
| DiskFileB | std::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++17 | Errors through std::error_code or std::filesystem_error. |
| LogFile | std::ofstream + std::chrono::system_clock + std::format | C++11 / C++20 | Keep LogFile's 6.3 rules: owner-only file, no write through a symbolic link. |
| gxConfig | std::getline() into a std::map; std::optional lookups; std::from_chars | C++17 | A rewrite through a temporary file and rename(). |
| gxDeviceCache, gxDeviceBucketCache | streams buffer themselves: std::filesystem::copy_file(), out << in.rdbuf() | C++17 | |
| clock(), SysTime, GetSystemTime() | std::chrono::steady_clock (elapsed), system_clock (calendar) | C++11 | clock() is CPU time, not elapsed time. |
| CDate | std::chrono::year_month_day, sys_days | C++20 | An impossible date is !ok(). |
Database (stays DataReel)
| DataReel 6.4 | Modern C++ | Standard | Notes |
|---|---|---|---|
| gxDatabase | keep gxDatabase: a stack object, errors as exceptions, static_assert(std::is_trivially_copyable_v<Record>) | C++17 | The standard library has no database file; the file format is DataReel's. |
| gxBtree, DatabaseKeyB key classes | keep gxBtree; key classes with std::array storage and correct copies (rule of three); std::set for in-memory indexes | C++11 / C++17 | DatabaseKeyB's copy keeps the other object's db_key pointer: define the copies. |
| BtreeCache | keep BtreeCache; flush it with an RAII guard | C++11 | |
| POD, InfoHog | keep them; std::unique_ptr + release() for PODIndexFile ownership; std::optional members | C++17 | |
| gxdJournal Begin()/Commit()/Rollback() | keep gxdJournal; an RAII Transaction that rolls back unless commit() was called | C++11 | |
| gxv7VectorIndex, gxv7ObjRepl, gxv7ObjectClient | keep them; std::span, <random>, std::ranges for checks | C++20 | Needs DATAREEL7_FEATURES_DIR. |
Networking (stays DataReel or POSIX)
| DataReel 6.4 | Modern C++ | Standard | Notes |
|---|---|---|---|
| gxSocket | keep gxSocket (C++ has no sockets); servers in std::jthread with std::stop_token and select() timeouts | C++20 | Stopping 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 2 | IPv4 and IPv6, thread safe. |
| gxsPing (raw socket, root) | unprivileged ICMP socket (SOCK_DGRAM, IPPROTO_ICMP) on Linux | POSIX | |
| gxSSL | keep gxSSL; certificate checking on (SetCAList + RequireVerifyCert); RAII close | C++11 | |
| gxsHTTPClient, gxsSMTPClient, gxsPOP3Client, gxsIMAPClient, gxsFTPClient, gxsTelnetClient | keep them; std::string buffers; reply parsing with std::string_view and std::from_chars | C++17 | |
| gxStream, gxDatagram blocks | keep gxStream for mutual TLS; length-checked blocks with std::span, std::endian, std::optional | C++20 |
Differences that bite
- Building DataReel 6.4 itself with C++20. C++20 removed
operator>>(std::istream&, char*)(P0487R1), whichUString's stream input used. DataReel 6.4.3 fixessrc/ustring.cppso the library builds with-std=c++20as well as C++17; the CMake build still defaults to C++17. - rfind of an empty string.
std::string::rfind("")returnssize();gxString::FindLast("")returns -1. Check the pattern first when you port FindLast() calls. - A position past the end throws.
substr(),erase()andinsert()throwstd::out_of_rangefor a start position past the end (a count past the end is clamped). gxString clamped or ignored those. - from_chars stops at junk.
std::from_charsparses "12ab" as 12 and points at "ab": check that the whole text was used, as the examples do. - No forced cancel.
std::jthreadasks a thread to stop; it does not kill it. Threads that block in a system call must wait with a timeout (select(), poll(),wait_for()) and check their stop token. - A joinable std::thread must not be destroyed. It calls
std::terminate(). Join it, detach it, or usestd::jthread. - Thread arguments are copied. The legacy condition example passes the address of its loop counter to five threads, so they can see the same number;
std::thread(worker, i)gives each thread its own copy (usestd::refto share on purpose). - DatabaseKeyB copies. The base class copy keeps the other object's
db_keypointer. A key class with its own key bytes must define its copy constructor and assignment to point at its own bytes (see database_btree). - right_child belongs to the B-tree. It is a child node address, not a place for the object address: put the object address in the key data (see database_pod).
- BtreeNode holds order-1 keys.
InsertDatabaseKey()does not check: testIsFull()first (see database_btree_node). - Raw structs on disk. Anything written with
Write(&rec, sizeof rec)must be trivially copyable and keep its size: say so withstatic_assert(std::is_trivially_copyable_v<Record>)andstatic_assert(sizeof(Record) == N), and pad explicitly. - windows.h and std::min. The DataReel headers include
windows.hon Windows, whoseminandmaxmacros breakstd::min(a, b)andstd::numeric_limits<T>::max(). DefineNOMINMAXfor the whole program (the examples' CMakeLists.txt does), or write(std::min)(a, b). - Unicode conversion.
std::codecvtandstd::wstring_convertare deprecated since C++17; keep UTF-8 instd::stringand convert at the platform boundary. - Networking is still not standard. Keep gxSocket and gxSSL (or DataReel 7). Do not trade a checked DataReel parser for an unchecked hand-written one: the modern parser examples were fuzzed, and the fuzzer found a bounds bug in the first version of one of them.
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.