diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-20 11:01:01 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-20 11:01:01 +0000 |
| commit | 65599524f5b41ffb6d8d55664611612c0b57ad47 (patch) | |
| tree | 69eafa5e5651c13100c9509502efc1659b186d1c /pseudocode-lib/_exp_string.cc | |
| parent | 0c4db4fea1960571318444bd39593533b04b3716 (diff) | |
feat(library): add experimental string MID function
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'pseudocode-lib/_exp_string.cc')
| -rw-r--r-- | pseudocode-lib/_exp_string.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pseudocode-lib/_exp_string.cc b/pseudocode-lib/_exp_string.cc index d881187..d406274 100644 --- a/pseudocode-lib/_exp_string.cc +++ b/pseudocode-lib/_exp_string.cc @@ -80,6 +80,14 @@ void _exp_string_impl_right(void *Target, void *Handle, long long Count) { text(Target) = Source.substr(Source.size() - Length, Length); }); } +void _exp_string_impl_mid(void *Target, void *Handle, long long Start, long long Count) { + checked([&] { + const auto &Source = text(Handle); + auto Position = Start <= 1 ? 0 : std::min(static_cast<std::size_t>(Start - 1), Source.size()); + auto Length = Count <= 0 ? 0 : std::min(static_cast<std::size_t>(Count), Source.size() - Position); + text(Target) = Source.substr(Position, Length); + }); +} void _exp_string_impl_output(void *Handle) { checked([&] { const auto &Text = text(Handle); |
