Parsnip
parsing library
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends
Parsnip::ArgumentVector Class Reference

This class lexically analyzes a string, splitting it up into tokens, which are accessed as a vector. More...

#include <parsnip_argv.h>

Inheritance diagram for Parsnip::ArgumentVector:

Public Types

using StringType = value_type
 

Public Member Functions

 ArgumentVector (const StringType &command_line)
 Construct an argument vector by splitting up a string into tokens.
 
StringType remainder (size_type index) const
 Retrieve the raw, untokenized remainder of the string.
 

Friends

class ArgvCursor
 

Detailed Description

This class lexically analyzes a string, splitting it up into tokens, which are accessed as a vector.

This involves splitting at spaces, or better quoted strings. At any token, the untokenized, original remainder can also be retrieved.

Constructor & Destructor Documentation

◆ ArgumentVector()

Parsnip::ArgumentVector::ArgumentVector ( const StringType &  cmd)

Construct an argument vector by splitting up a string into tokens.

  • An empty/whitespace-filled string results in an empty vector.
  • Strings may be quoted with single (apostrophe) or double quotes. The quote characters are omitted from their tokens.
  • A literal of of the quote character may be inserted by doubling within the quoted region.
  • A mismatched quote is not treated as an error; the token is taken from the character after the open quote to end of string.

Member Function Documentation

◆ remainder()

StringType Parsnip::ArgumentVector::remainder ( size_type  index) const
inline

Retrieve the raw, untokenized remainder of the string.

Parameters
indexThe index of the token to start retrieval.
Returns
The remainder of the command line, with original spaces and quoting.

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