cli20 0.1.2
A C++20 typed-schema command-line parser
Loading...
Searching...
No Matches
cli::TokenizeResult Struct Reference

The result returned by tokenize(). More...

#include <parser.hh>

Classes

struct  SmallVector

Public Member Functions

constexpr operator bool () const noexcept
 Returns true when tokenization succeeded.
constexpr auto has_value () const noexcept -> bool
 Returns true when tokenization succeeded.
constexpr auto has_error () const noexcept -> bool
 Returns true when tokenization failed.
auto fail (ErrorCode code, std::size_t pos, std::string subject, std::string detail={}) -> TokenizeResult &
 Sets the error and returns *this for method chaining.

Public Attributes

SmallVector< Token, token_stack_capacity > tokens
ParseError error {}

Detailed Description

The result returned by tokenize().

On success, tokens contains the ordered token sequence and error is in the default (no-error) state. On failure, tokens may be partial and error describes the first problem encountered.

Definition at line 192 of file parser.hh.

Member Function Documentation

◆ fail()

auto cli::TokenizeResult::fail ( ErrorCode code,
std::size_t pos,
std::string subject,
std::string detail = {} ) -> TokenizeResult &
inline

Sets the error and returns *this for method chaining.

Parameters
codeThe error code.
posThe zero-based index into the input args span where the error occurred. Higher-level parser code may apply an offset when translating this to a caller-visible argument index.
subjectThe option or token name that caused the error.
detailOptional additional detail message.
Returns
Reference to *this.

Definition at line 272 of file parser.hh.

◆ has_error()

auto cli::TokenizeResult::has_error ( ) const -> bool
inlinenodiscardconstexprnoexcept

Returns true when tokenization failed.

Definition at line 256 of file parser.hh.

◆ has_value()

auto cli::TokenizeResult::has_value ( ) const -> bool
inlinenodiscardconstexprnoexcept

Returns true when tokenization succeeded.

Definition at line 250 of file parser.hh.

◆ operator bool()

cli::TokenizeResult::operator bool ( ) const
inlineexplicitnodiscardconstexprnoexcept

Returns true when tokenization succeeded.

Definition at line 244 of file parser.hh.

Member Data Documentation

◆ error

ParseError cli::TokenizeResult::error {}

Definition at line 240 of file parser.hh.

◆ tokens

SmallVector<Token, token_stack_capacity> cli::TokenizeResult::tokens

Definition at line 239 of file parser.hh.


The documentation for this struct was generated from the following file: