|
Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
|
A read position over one canonical-encoding text, with the small lexical helpers the grammar needs (literals, words, netstrings, numbers). More...
#include <canonical_decoding.hpp>
Public Member Functions | |
| DecodingCursor (std::string const &text) | |
| Start reading text from its first byte. | |
| bool | AtEnd () const |
| Whether every byte has been consumed. | |
| std::size_t | Offset () const |
| The byte offset of the next unread character. | |
| char | Peek () const |
| The next unread character (throws at end of text). | |
| void | Expect (char c) |
| Consume exactly the character c, or throw. | |
| void | Expect (std::string_view lit) |
| Consume exactly the literal lit, or throw. | |
| bool | TryConsume (char c) |
| Consume c if it is next; report whether it was. | |
| void | SkipWhitespace () |
| Skip any run of spaces and newlines. | |
| std::string | ReadWord () |
| Read a maximal run of characters that are not whitespace or a parenthesis. | |
| std::string | ReadNetstring () |
| Read a netstring name: <byte-length>:<bytes>. | |
| unsigned long long | ReadUnsigned () |
| Read a non-negative decimal integer. | |
| long long | ReadInt () |
| Read a decimal integer with an optional sign. | |
| void | Fail (std::string const &what) const |
| Throw std::runtime_error describing what at the current position. | |
A read position over one canonical-encoding text, with the small lexical helpers the grammar needs (literals, words, netstrings, numbers).
The cursor does not own the text: keep the string alive for the cursor's lifetime. Every helper throws std::runtime_error with the byte offset and a snippet of the text when the input does not match, so a malformed or truncated encoding fails loudly at the first wrong byte instead of producing a wrong object.
|
inlineexplicit |
Start reading text from its first byte.
|
inline |
Whether every byte has been consumed.
| void bertini::node::DecodingCursor::Expect | ( | char | c | ) |
Consume exactly the character c, or throw.
| void bertini::node::DecodingCursor::Expect | ( | std::string_view | lit | ) |
Consume exactly the literal lit, or throw.
| void bertini::node::DecodingCursor::Fail | ( | std::string const & | what | ) | const |
Throw std::runtime_error describing what at the current position.
|
inline |
The byte offset of the next unread character.
| char bertini::node::DecodingCursor::Peek | ( | ) | const |
The next unread character (throws at end of text).
| long long bertini::node::DecodingCursor::ReadInt | ( | ) |
Read a decimal integer with an optional sign.
| std::string bertini::node::DecodingCursor::ReadNetstring | ( | ) |
Read a netstring name: <byte-length>:<bytes>.
| unsigned long long bertini::node::DecodingCursor::ReadUnsigned | ( | ) |
Read a non-negative decimal integer.
| std::string bertini::node::DecodingCursor::ReadWord | ( | ) |
Read a maximal run of characters that are not whitespace or a parenthesis.
| void bertini::node::DecodingCursor::SkipWhitespace | ( | ) |
Skip any run of spaces and newlines.
| bool bertini::node::DecodingCursor::TryConsume | ( | char | c | ) |
Consume c if it is next; report whether it was.