2.3 KiB
2.3 KiB
Text ASCII Helpers, View Splitting, and Bounded Growth
Task ID: M-TEXT-02 Phase: P1 Status: APPROVED Contracts: C-01, C-05, C-13
1. Context and baseline
src/Text/module.cmake declares zero dependencies. include/Void/Text/Str.hpp currently uses std::isspace/std::tolower/std::toupper/std::isalpha/std::isdigit/std::isalnum without an explicit locale-free ASCII byte contract (0..127 classified, bytes >= 128 preserved unchanged) and lacks overflow/output-bounded splitting, replacing, repeating, and joining utilities.
2. Deliverables
- Extended
include/Void/Text/Str.hppaddingconstexpr noexceptASCII-only classifiers,trim_*_ascii,to_lower_ascii/to_upper_ascii, andiequals_ascii. - New
include/Void/Text/Bounded.hppdefiningVoid::Text::{TextLimits, TextError, EmptyParts, split_views, replace_bounded, repeat_bounded, join_bounded}and re-exporting ASCII helpers. - Tests in
tests/standalone/Text/Str.cppandtests/standalone/Text/Bounded.cpp.
3. Exact files and interfaces
include/Void/Text/Str.hpp: keep all 1.xVoid::Strsignatures intact; addis_ascii_*,to_*_ascii_char,trim_{left,right,}_ascii,to_{lower,upper}_ascii,is_{alpha,digit,alnum}_ascii,iequals_ascii.include/Void/Text/Bounded.hpp:TextLimits(max_input=16MiB,max_output=16MiB,max_parts=65536),TextError,split_views,replace_bounded,repeat_bounded,join_bounded.
4. Edge cases
- High bytes
0x80..0xFFand multi-byte UTF-8 sequences preserved untouched by ASCII trim/case helpers; embedded NUL bytes preserved. - Empty delimiter/needle rejected with
TextError::Code::invalid_rule; oversized input/parts/output rejected BEFORE allocating;SIZE_MAXcount*size multiplication rejected withTextError::Code::overflow; shrinkingreplace_boundedverified cleanly.
5. Acceptance criteria
Str*andBounded*tests plus fullText;Testingsuite pass under-DVOID_WARNINGS_AS_ERRORS=ONwithout Unicode linkage.
6. Verification commands
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-p1-text -G Ninja -DVOID_ENABLED_MODULES="Text;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-p1-text && /tmp/void-p1-text/tests/VoidTests --filter "Str*|Bounded*" && ctest --test-dir /tmp/void-p1-text --output-on-failure --timeout 60'