feat: libb20 C++20 #12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/lib/cpp20/main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
🚀 PR: Introduce C++20
libb20Library and Reference CLIBranch:
feat/lib/cpp20/mainVersion Target:
v0.5.0Summary
This PR adds the full C++20 implementation of the libb20 base-20 codec library, complete with an idiomatic C++ API, UTF-8–aware text mode, binary-digit mode, and a new
kb20-cpp20refcommand-line reference tool.It modernizes the original C90 codebase while preserving 100% on-wire compatibility with the base-20 format defined by the C90 reference implementation.
🔧 Key Features
C++20 Core Library (
libb20)b20::codecclass with clean encode/decode interface.b20::status,error_category(), andstatus_message()forstd::error_codeintegration.b20::alphabetandb20::optionsfor configurable alphabets and binary-digit modes.std::cin >> b20::encode(codec) >> std::string;std::cout << b20::decode(codec) << std::string;Reference CLI (
kb20-cpp20ref)encode/decode).--text,--bin|--binary-digits,--zero <utf8-scalar>,--alphabet <20-utf8-scalars>.stdin, writes tostdout(binary-safe).Generic Helper Libraries (
contrib/)contrib/io_helpers: robustread_all/write_all/read_exact/read_untilutilities.contrib/utf8_helpers: compact UTF-8 decoder/encoder withparse_n_exactandparse_prefix_n.Bugfixes / Parity
cur % baseinstead of& base).'-', no surrogates, 20 distinct scalars).✅
echo "this is test text" | kb20-cpp20ref encode→ matches C90 output (S-…).Build System
Makefilewith C++20 flags, cleaning, and debug target.contrib/path for helper libs.🧩 Directory Layout
✅ Testing & Verification
kb20-c90ref).clang++ -std=c++20 -Wall -Wextra -Wpedantic -O2.- Introduce b20::status + error_category() + status_message() (std::error_code integration) - Add b20::alphabet (defaults: [A..T] contiguous, [0-9A-J] mapped) with validate_text() - Add b20::options { binary_digits, alphabet } - Implement b20::codec interface: - no-throw encode()/decode() (bytes<->bytes) + throwing overloads - text helpers: encode_text()/decode_text() - binary-digits helpers: encode_binary()/decode_binary() - Provide two-step stream manipulators: - istream >> b20::encode(codec) >> std::string (encode remaining stream -> text) - ostream << b20::decode(codec) << std::string (decode text -> raw bytes) - Keep core I/O-agnostic; future helpers (read_all, etc.) will live in a separate header Refs: feat/lib/cpp20/main- Move io_helpers.{hpp,cpp} and utf8_helpers.{hpp,cpp} into contrib/ - Keeps core lib clean; helpers remain optional/reusable