arg_router  1.4.0
C++ command line argument parsing and routing
arg_router::parsing::dynamic_token_adapter Class Reference

#include <arg_router/parsing/dynamic_token_adapter.hpp>

Classes

class  iterator
 

Public Types

using value_type = token_type
 
using size_type = std::size_t
 

Public Member Functions

 dynamic_token_adapter (vector< token_type > &processed, vector< token_type > &unprocessed)
 
bool operator== (dynamic_token_adapter other) const
 
bool operator!= (dynamic_token_adapter other) const
 
iterator begin ()
 
iterator end ()
 
size_type size () const
 
bool empty () const
 
vector< value_type > & processed ()
 
vector< value_type > & unprocessed ()
 
iterator insert (iterator it, value_type value)
 
template<typename Iter >
iterator insert (iterator it, Iter first, Iter last)
 
iterator erase (iterator it)
 
void transfer (iterator it)
 

Detailed Description

An adaptor over the processed and unprocessed tokens. This is used during the pre-parse phase.

If an iterator element is read from that is beyond the end of the processed token container, then one is returned from the equivalent position in the unprocessed token container (as if the two containers were concatenated). Using iterator::set(value_type) will update the element pointed at by the iterator, if the iterator is passed the end of the processed tokens container then elements from the unprocessed container are transferred into it verbatim.

This allows the pre-parse phase implementing policies to not concern themselves with managing the processed/unprocessed containers.

Definition at line 22 of file dynamic_token_adapter.hpp.

Member Typedef Documentation

◆ size_type

Size type.

Definition at line 28 of file dynamic_token_adapter.hpp.

◆ value_type

Constructor & Destructor Documentation

◆ dynamic_token_adapter()

arg_router::parsing::dynamic_token_adapter::dynamic_token_adapter ( vector< token_type > &  processed,
vector< token_type > &  unprocessed 
)
inline

Constructor.

Parameters
processedProcessed tokens container
unprocessedUnprocessed tokens container

Definition at line 311 of file dynamic_token_adapter.hpp.

Member Function Documentation

◆ begin()

iterator arg_router::parsing::dynamic_token_adapter::begin ( )
inline

Returns an iterator to the beginning of the processed container.

If the processed container is empty, this will initialise it by moving an entry from the front of the raw command line token container into it, using prefix_type::none.

Returns
Begin iterator

Definition at line 347 of file dynamic_token_adapter.hpp.

◆ empty()

bool arg_router::parsing::dynamic_token_adapter::empty ( ) const
inline
Returns
True if there are no processed or unprocessed tokens.

Definition at line 364 of file dynamic_token_adapter.hpp.

◆ end()

iterator arg_router::parsing::dynamic_token_adapter::end ( )
inline

Returns a one-past-the-end iterator.

Returns
End iterator

Definition at line 354 of file dynamic_token_adapter.hpp.

◆ erase()

iterator arg_router::parsing::dynamic_token_adapter::erase ( iterator  it)
inline

Erases the element at it.

Does not perform any transfer between the process and unprocessed sides.

Parameters
itElement to remove. If one-past-the-end iterator, this method is a no-op
Returns
Element following the one removed

Definition at line 423 of file dynamic_token_adapter.hpp.

◆ insert() [1/2]

template<typename Iter >
iterator arg_router::parsing::dynamic_token_adapter::insert ( iterator  it,
Iter  first,
Iter  last 
)
inline

Inserts the value in the range [ first, last ) at position it.

Parameters
itPosition to start inserting at
firstIterator to first instance in range to insert
lastOne-past-the-end iterator of range to insert
Returns
Iterator to first of the range inserted

Definition at line 405 of file dynamic_token_adapter.hpp.

◆ insert() [2/2]

iterator arg_router::parsing::dynamic_token_adapter::insert ( iterator  it,
value_type  value 
)
inline

Inserts token at position it.

Note
No checking is performed that the iterator was created from the same adapter
Parameters
itPosition to insert at
valueValue to insert
Returns
Iterator to inserted value

Definition at line 385 of file dynamic_token_adapter.hpp.

◆ operator!=()

bool arg_router::parsing::dynamic_token_adapter::operator!= ( dynamic_token_adapter  other) const
inline

Inequality operator.

Note
The underlying containers' addresses are used in the comparison, so two separate but identical instances will return not equal
Parameters
otherInstance to compare against
Returns
True if not equal

Definition at line 339 of file dynamic_token_adapter.hpp.

◆ operator==()

bool arg_router::parsing::dynamic_token_adapter::operator== ( dynamic_token_adapter  other) const
inline

Equality operator.

Note
The underlying containers' addresses are used in the comparison, so two separate but identical instances will return not equal
Parameters
otherInstance to compare against
Returns
True if equal

Definition at line 327 of file dynamic_token_adapter.hpp.

◆ processed()

vector<value_type>& arg_router::parsing::dynamic_token_adapter::processed ( )
inline

The underlying processed container.

Returns
Processed container reference

Definition at line 370 of file dynamic_token_adapter.hpp.

◆ size()

size_type arg_router::parsing::dynamic_token_adapter::size ( ) const
inline

Returns the count of all tokens, processed and unprocessed.

Returns
Number of components

Definition at line 360 of file dynamic_token_adapter.hpp.

◆ transfer()

void arg_router::parsing::dynamic_token_adapter::transfer ( iterator  it)
inline

Transfer elements from the raw command line token container to processed one up to and including the one represented by it.

If it is before or within the processed container, then this is a no-op.

Parameters
itIterator, and the preceding elements too, to transfer

Definition at line 447 of file dynamic_token_adapter.hpp.

◆ unprocessed()

vector<value_type>& arg_router::parsing::dynamic_token_adapter::unprocessed ( )
inline

The underlying unprocessed container.

Returns
Unprocessed container reference

Definition at line 376 of file dynamic_token_adapter.hpp.


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