sbepp
Loading...
Searching...
No Matches
sbepp::cursor_ops Namespace Reference

Contains cursor wrappers which allow more precise control over its position. More...

Functions

template<typename Byte >
constexpr detail::init_cursor_wrapper< Byte > init (cursor< Byte > &c) noexcept
 Returns a wrapper which will initialize the cursor when it's used and advance after the usage.
 
template<typename Byte >
constexpr detail::dont_move_cursor_wrapper< Byte > dont_move (cursor< Byte > &c) noexcept
 Returns a wrapper which doesn't advance the cursor when it's used.
 
template<typename Byte >
constexpr detail::init_dont_move_cursor_wrapper< Byte > init_dont_move (cursor< Byte > &c) noexcept
 Returns a wrapper which initializes the cursor but doesn't move it. Behaves like a combination of init() and dont_move().
 
template<typename Byte >
constexpr detail::skip_cursor_wrapper< Byte > skip (cursor< Byte > &c) noexcept
 Returns a wrapper which moves the cursor to the end of field/group/data without returning the accessed value.
 

Detailed Description

Contains cursor wrappers which allow more precise control over its position.

Function Documentation

◆ dont_move()

template<typename Byte >
constexpr detail::dont_move_cursor_wrapper< Byte > sbepp::cursor_ops::dont_move ( cursor< Byte > & c)
constexprnoexcept

Returns a wrapper which doesn't advance the cursor when it's used.

Allows to access field/group/data more than once using cursor API. Useful to read and write the same field or to write data member. Example:

schema::messages::msg1<char> m{ptr, size};
auto c = sbepp::init_cursor(m);
// use but don't advance, otherwise we can't access `field` again
auto value = m.field(sbepp::cursor_ops::dont_move(c));
m.field(*value + 1, c);
// since data has unknown size, without `dont_move` cursor will be moved
// to a random position
auto d = m.data(sbepp::cursor_ops::dont_move(c));
d.resize(1); // init data somehow
m.data(c); // advance the cursor
constexpr detail::dont_move_cursor_wrapper< Byte > dont_move(cursor< Byte > &c) noexcept
Returns a wrapper which doesn't advance the cursor when it's used.
Definition sbepp.hpp:1694
constexpr cursor< byte_type_t< View > > init_cursor(View view) noexcept
Initializes cursor from a message/group view with the same byte type.
Definition sbepp.hpp:2846
Parameters
coriginal cursor
Returns
unspecified cursor wrapper

◆ init()

template<typename Byte >
constexpr detail::init_cursor_wrapper< Byte > sbepp::cursor_ops::init ( cursor< Byte > & c)
constexprnoexcept

Returns a wrapper which will initialize the cursor when it's used and advance after the usage.

Allows to start using cursor API from any field/group/data. Example:

schema::messages::msg1<char> m{ptr, size};
sbepp::cursor<char> c; // Note: not initialized
// initialize, use, advance
auto first = m.firstField(sbepp::cursor_ops::init(c));
auto second = m.secondField(c); // continue as usual
Represents cursor which is used in cursor-based API. Clients should not use undocumented methods.
Definition sbepp.hpp:783
constexpr detail::init_cursor_wrapper< Byte > init(cursor< Byte > &c) noexcept
Returns a wrapper which will initialize the cursor when it's used and advance after the usage.
Definition sbepp.hpp:1665
Parameters
coriginal cursor
Returns
unspecified cursor wrapper

◆ init_dont_move()

template<typename Byte >
constexpr detail::init_dont_move_cursor_wrapper< Byte > sbepp::cursor_ops::init_dont_move ( cursor< Byte > & c)
constexprnoexcept

Returns a wrapper which initializes the cursor but doesn't move it. Behaves like a combination of init() and dont_move().

Parameters
coriginal cursor
Returns
unspecified cursor wrapper

◆ skip()

template<typename Byte >
constexpr detail::skip_cursor_wrapper< Byte > sbepp::cursor_ops::skip ( cursor< Byte > & c)
constexprnoexcept

Returns a wrapper which moves the cursor to the end of field/group/data without returning the accessed value.

Allows to skip uninteresting members. Example:

schema::messages::msg1<char> m{ptr, size};
auto c = sbepp::init_cursor(m);
m.group(sbepp::cursor_ops::skip(c)); // skip the whole group
auto d = m.data(c); // access next member
constexpr detail::skip_cursor_wrapper< Byte > skip(cursor< Byte > &c) noexcept
Returns a wrapper which moves the cursor to the end of field/group/data without returning the accesse...
Definition sbepp.hpp:1728
Parameters
coriginal cursor
Returns
unspecified cursor wrapper