ROSE 0.11.145.192
Public Types | Static Public Member Functions | Protected Member Functions | List of all members
Rose::Color::ColorizationParser Class Reference

Description

Parses an output color specification.

This parser is used by Sawyer::CommandLine when parsing command-line switches. For instance, many ROSE tools have a "--color" switch. The canonical documentation for this parser comes from its docString function. In short, it parses one or two words separated by a comma, the words being when to use colorized output ("off", "on", "auto") and the basic theme ("dark", or "light").

Definition at line 61 of file Color.h.

#include <Rose/Color.h>

Inheritance diagram for Rose::Color::ColorizationParser:
Inheritance graph
[legend]
Collaboration diagram for Rose::Color::ColorizationParser:
Collaboration graph
[legend]

Public Types

typedef Sawyer::SharedPointer< ColorizationParserPtr
 Shared ownership pointer to a ColorizationParser.
 
- Public Types inherited from Sawyer::CommandLine::ValueParser
typedef SharedPointer< ValueParserPtr
 Reference counting pointer for this class.
 

Static Public Member Functions

static Ptr instance ()
 Allocating constructor.
 
static Ptr instance (const Sawyer::CommandLine::ValueSaver::Ptr &valueSaver)
 Allocating constructor.
 
static std::string docString ()
 Documentation for parser.
 
static Colorization parse (const char *input, const char **rest)
 Parse a colorized output specification from a C string.
 
static Colorization parse (const std::string &input)
 Parse a colorized output specification from a C++ string.
 

Protected Member Functions

 ColorizationParser (const Sawyer::CommandLine::ValueSaver::Ptr &valueSaver)
 
- Protected Member Functions inherited from Sawyer::CommandLine::ValueParser
 ValueParser ()
 Constructor for derived classes.
 
 ValueParser (const ValueSaver::Ptr &valueSaver)
 Constructor for derived classes.
 

Additional Inherited Members

- Public Member Functions inherited from Sawyer::CommandLine::ValueParser
ParsedValue matchString (const std::string &)
 Parse the entire string and return a value.
 
ParsedValue match (Cursor &)
 Parse a value from the beginning of the specified string.
 
Ptr valueSaver (const ValueSaver::Ptr &f)
 Property: functor responsible for saving a parsed value in user storage.
 
const ValueSaver::Ptr valueSaver () const
 Property: functor responsible for saving a parsed value in user storage.
 
- Public Member Functions inherited from Sawyer::SharedObject
 SharedObject ()
 Default constructor.
 
 SharedObject (const SharedObject &)
 Copy constructor.
 
virtual ~SharedObject ()
 Virtual destructor.
 
SharedObjectoperator= (const SharedObject &)
 Assignment.
 
- Public Member Functions inherited from Sawyer::SharedFromThis< ValueParser >
SharedPointer< ValueParser > sharedFromThis ()
 Create a shared pointer from this.
 
SharedPointer< const ValueParser > sharedFromThis () const
 Create a shared pointer from this.
 

Member Typedef Documentation

◆ Ptr

Shared ownership pointer to a ColorizationParser.

See Shared ownership.

Definition at line 69 of file Color.h.

Constructor & Destructor Documentation

◆ ColorizationParser() [1/2]

Rose::Color::ColorizationParser::ColorizationParser ( )
inlineprotected

Definition at line 63 of file Color.h.

◆ ColorizationParser() [2/2]

Rose::Color::ColorizationParser::ColorizationParser ( const Sawyer::CommandLine::ValueSaver::Ptr valueSaver)
inlineprotected

Definition at line 64 of file Color.h.

Member Function Documentation

◆ instance() [1/2]

static Ptr Rose::Color::ColorizationParser::instance ( )
inlinestatic

Allocating constructor.

Definition at line 72 of file Color.h.

◆ instance() [2/2]

static Ptr Rose::Color::ColorizationParser::instance ( const Sawyer::CommandLine::ValueSaver::Ptr valueSaver)
inlinestatic

Allocating constructor.

Definition at line 77 of file Color.h.

References Sawyer::CommandLine::ValueParser::valueSaver().

◆ parse() [1/2]

static Colorization Rose::Color::ColorizationParser::parse ( const char *  input,
const char **  rest 
)
static

Parse a colorized output specification from a C string.

Tries to parse a colorized output specification from the input string, and if successful adjusts rest to point to the first character beyond what was parsed. If a syntax error occurs, then an std::runtime_error is thrown.

◆ parse() [2/2]

static Colorization Rose::Color::ColorizationParser::parse ( const std::string &  input)
static

Parse a colorized output specification from a C++ string.

Tries to parse a colorized output specification from the input string. The string may contain leading and trailing white space, but any extra characters will cause a syntax error. Syntax errors are reported by throwing std::runtime_error. Since the underlying parsing is done on C strings, this function is ill-defined when the input contains NUL bytes.


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