scnlib  0.1.2
FormattedinputformodernC++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
SizedStream
SizedStream is a refinement of Stream. The size (number of characters) in a SizedStream source shall not change after construction.
An example of a SizedStream is scn::basic_static_container_stream.
Valid expressions
A type S satisfies SizedStream, if
  • the type S satisfies Stream, and
given
  • s, an lvalue of type S, and
  • ch, a value of type S::char_type, and
  • sz, a value of type std::size_t, and
  • buf, a value of type span<S::char_type>,
the following expressions must be valid and have their specified effects:
  • s.read_sized(buf) -> void: Fills buf with characters from s. Precondition: s must be readable and s.chars_to_read() must be greater or equal to buf.size().
  • s.putback_n(sz) -> void: Puts back the last sz characters read into s. Precondition: s.rcount() >= sz must be true. Postcondition: s will be readable for sz characters.
  • s.chars_to_read() -> std::size_t: Returns the number of characters s has available to read.
  • s.skip(sz) -> void: Skips sz characters. Precondition: s must be readable for sz characters.
  • s.skip_all() -> void: Skips to the end of s. Postcondition: s is not readable.
Notes
For the definitions of stream source and readable, see Stream.
Exposition-only Concept
// exposition-only
template <typename S>
concept SizedStream =
Stream<S> &&
requires(S& s, typename S::char_type ch, std::size_t sz,
span<typename S::char_type> buf)
{
{ s.read_sized(buf) } -> void;
{ s.putback_n(sz) } -> void;
{ s.chars_to_read() } -> std::size_t;
{ s.skip(sz) } -> void;
{ s.skip_all() } -> void;
}