Skip to content

Migrate to capy post-#262 buffer API#270

Merged
mvandeberg merged 1 commit into
cppalliance:developfrom
mvandeberg:pr/capy-262-migration
May 15, 2026
Merged

Migrate to capy post-#262 buffer API#270
mvandeberg merged 1 commit into
cppalliance:developfrom
mvandeberg:pr/capy-262-migration

Conversation

@mvandeberg
Copy link
Copy Markdown
Contributor

cppalliance/capy#262 removes the slice CPO machinery (capy::prefix, capy::sans_prefix, capy::remove_prefix, capy::remove_suffix, capy::keep_prefix, capy::slice_of<>) and the capy::const_buffer_pair / capy::mutable_buffer_pair aliases. boost::http migrates to the replacements:

  • capy::const_buffer_pair / capy::mutable_buffer_pair --> std::array<capy::const_buffer, 2> / std::array<capy::mutable_buffer, 2>.

  • capy::prefix(seq, n) returning a 2-element buffer pair --> local helper prefix_pair(seq, n) in src/parser.cpp that constructs the trimmed array directly. Retained for the call sites that consume the result as a std::array (i.e. assigning to a parser member or passing to filter::process).

  • For one parser site where the result is consumed by capy::buffer_copy, the migration uses capy::buffer_slice directly: auto chunk = capy::buffer_slice(cb0_.data(), 0, n); then buffer_copy(target, chunk.data()). Demonstrates the by-value buffer_slice's idiomatic use; the slice owns its buffer-sequence copy and works with the prvalue cb0_.data().

  • capy::remove_prefix(pair, n) / capy::remove_suffix(pair, n) on 2-element buffer pairs --> local helpers trim_prefix_pair / trim_suffix_pair in src/serializer.cpp. Retained for out_prepare()'s in-place std::array trim.

  • capy::remove_prefix(buf, n) on a single buffer --> buf += n (member operator already provided by capy).

  • capy::sans_prefix(seq, n) --> capy::buffer_slice(seq, n) (returns a Slice exposing the buffer sequence via .data()). In iterative consumption loops, advance an existing slice in place via slice.remove_prefix(n).

  • filter::process now takes boost::span<const capy::mutable_buffer> and std::array<capy::const_buffer, 2> directly, and drives the loop using capy::buffer_slice internally.

  • Test serializer.cpp's read_some builds a slice in one expression via capy::buffer_slice(sr.prepare().value(), 0, 256) and iterates .data(). Since capy's buffer_slice captures its underlying buffer sequence by value, the prvalue sr.prepare() .value() is safe — the slice owns its own copy.

Coordinated with capy PR cppalliance/capy#262. Merge order: this PR lands before #262 (so http remains buildable against capy's `develop` during the brief window).

cppalliance/capy#262 removes the slice CPO machinery
(`capy::prefix`, `capy::sans_prefix`, `capy::remove_prefix`,
`capy::remove_suffix`, `capy::keep_prefix`, `capy::slice_of<>`)
and the `capy::const_buffer_pair` / `capy::mutable_buffer_pair`
aliases. boost::http migrates to the replacements:

- `capy::const_buffer_pair` / `capy::mutable_buffer_pair` -->
  `std::array<capy::const_buffer, 2>` /
  `std::array<capy::mutable_buffer, 2>`.

- `capy::prefix(seq, n)` returning a 2-element buffer pair -->
  local helper `prefix_pair(seq, n)` in `src/parser.cpp` that
  constructs the trimmed array directly. Retained for the call
  sites that consume the result as a std::array (i.e. assigning
  to a parser member or passing to `filter::process`).

- For one parser site where the result is consumed by
  `capy::buffer_copy`, the migration uses `capy::buffer_slice`
  directly: `auto chunk = capy::buffer_slice(cb0_.data(), 0, n);`
  then `buffer_copy(target, chunk.data())`. Demonstrates the
  by-value buffer_slice's idiomatic use; the slice owns its
  buffer-sequence copy and works with the prvalue `cb0_.data()`.

- `capy::remove_prefix(pair, n)` / `capy::remove_suffix(pair, n)`
  on 2-element buffer pairs --> local helpers
  `trim_prefix_pair` / `trim_suffix_pair` in `src/serializer.cpp`.
  Retained for `out_prepare()`'s in-place std::array trim.

- `capy::remove_prefix(buf, n)` on a single buffer -->
  `buf += n` (member operator already provided by capy).

- `capy::sans_prefix(seq, n)` --> `capy::buffer_slice(seq, n)`
  (returns a Slice exposing the buffer sequence via `.data()`).
  In iterative consumption loops, advance an existing slice in
  place via `slice.remove_prefix(n)`.

- `filter::process` now takes
  `boost::span<const capy::mutable_buffer>` and
  `std::array<capy::const_buffer, 2>` directly, and drives the
  loop using `capy::buffer_slice` internally.

- Test serializer.cpp's `read_some` builds a slice in one
  expression via `capy::buffer_slice(sr.prepare().value(), 0, 256)`
  and iterates `.data()`. Since capy's buffer_slice captures its
  underlying buffer sequence by value, the prvalue `sr.prepare()
  .value()` is safe — the slice owns its own copy.

Coordinated with capy PR cppalliance/capy#262. Merge order:
this PR lands before cppalliance#262 (so http remains buildable against
capy's \`develop\` during the brief window).
@cppalliance-bot
Copy link
Copy Markdown

An automated preview of the documentation is available at https://270.http.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-05-15 21:13:19 UTC

@mvandeberg mvandeberg merged commit 1ab0b6f into cppalliance:develop May 15, 2026
1 of 12 checks passed
@mvandeberg mvandeberg deleted the pr/capy-262-migration branch May 15, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants