LLDB mainline
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lldb_private::OptionsWithRaw Class Reference

A pair of an option list with a 'raw' string as a suffix. More...

#include "lldb/Utility/Args.h"

Public Member Functions

 OptionsWithRaw (llvm::StringRef argument_string)
 Parse the given string as a list of optional arguments with a raw suffix.
 
bool HasArgs () const
 Returns true if there are any arguments before the raw suffix.
 
ArgsGetArgs ()
 Returns the list of arguments.
 
const ArgsGetArgs () const
 Returns the list of arguments.
 
llvm::StringRef GetArgStringWithDelimiter () const
 Returns the part of the input string that was used for parsing the argument list.
 
llvm::StringRef GetArgString () const
 Returns the part of the input string that was used for parsing the argument list.
 
const std::string & GetRawPart () const
 Returns the raw suffix part of the parsed string.
 

Private Member Functions

void SetFromString (llvm::StringRef arg_string)
 

Private Attributes

bool m_has_args = false
 Keeps track if we have parsed and stored any arguments.
 
Args m_args
 
llvm::StringRef m_arg_string
 
llvm::StringRef m_arg_string_with_delimiter
 
std::string m_suffix
 

Detailed Description

A pair of an option list with a 'raw' string as a suffix.

This class works similar to Args, but handles the case where we have a trailing string that shouldn't be interpreted as a list of arguments but preserved as is. It is also only useful for handling command line options (e.g. '-foo bar -i0') that start with a dash.

The leading option list is optional. If the first non-space character in the string starts with a dash, and the string contains an argument that is an unquoted double dash (' – '), then everything up to the double dash is parsed as a list of arguments. Everything after the double dash is interpreted as the raw suffix string. Note that the space behind the double dash is not part of the raw suffix.

All strings not matching the above format as considered to be just a raw string without any options.

See also
Args

Definition at line 319 of file Args.h.

Constructor & Destructor Documentation

◆ OptionsWithRaw()

OptionsWithRaw::OptionsWithRaw ( llvm::StringRef  argument_string)
explicit

Parse the given string as a list of optional arguments with a raw suffix.

See the class description for a description of the input format.

Parameters
[in]argument_stringThe string that should be parsed.

Definition at line 641 of file Args.cpp.

References SetFromString().

Member Function Documentation

◆ GetArgs() [1/2]

Args & lldb_private::OptionsWithRaw::GetArgs ( )
inline

Returns the list of arguments.

You can only call this method if HasArgs returns true.

Definition at line 335 of file Args.h.

References m_args, and m_has_args.

Referenced by CommandObjectScriptingRun::DoExecute(), and CommandObjectPlatformShell::DoExecute().

◆ GetArgs() [2/2]

const Args & lldb_private::OptionsWithRaw::GetArgs ( ) const
inline

Returns the list of arguments.

You can only call this method if HasArgs returns true.

Definition at line 343 of file Args.h.

References m_args, and m_has_args.

◆ GetArgString()

llvm::StringRef lldb_private::OptionsWithRaw::GetArgString ( ) const
inline

Returns the part of the input string that was used for parsing the argument list.

You can only call this method if HasArgs returns true.

Definition at line 362 of file Args.h.

References m_arg_string, and m_has_args.

◆ GetArgStringWithDelimiter()

llvm::StringRef lldb_private::OptionsWithRaw::GetArgStringWithDelimiter ( ) const
inline

Returns the part of the input string that was used for parsing the argument list.

This string also includes the double dash that is used for separating the argument list from the suffix.

You can only call this method if HasArgs returns true.

Definition at line 353 of file Args.h.

References m_arg_string_with_delimiter, and m_has_args.

◆ GetRawPart()

const std::string & lldb_private::OptionsWithRaw::GetRawPart ( ) const
inline

Returns the raw suffix part of the parsed string.

Definition at line 368 of file Args.h.

References m_suffix.

Referenced by lldb_private::CommandObjectDWIMPrint::DoExecute(), CommandObjectScriptingRun::DoExecute(), and CommandObjectPlatformShell::DoExecute().

◆ HasArgs()

bool lldb_private::OptionsWithRaw::HasArgs ( ) const
inline

Returns true if there are any arguments before the raw suffix.

Definition at line 330 of file Args.h.

References m_has_args.

Referenced by CommandObjectScriptingRun::DoExecute(), and CommandObjectPlatformShell::DoExecute().

◆ SetFromString()

void OptionsWithRaw::SetFromString ( llvm::StringRef  arg_string)
private

Member Data Documentation

◆ m_arg_string

llvm::StringRef lldb_private::OptionsWithRaw::m_arg_string
private

Definition at line 376 of file Args.h.

Referenced by GetArgString(), and SetFromString().

◆ m_arg_string_with_delimiter

llvm::StringRef lldb_private::OptionsWithRaw::m_arg_string_with_delimiter
private

Definition at line 377 of file Args.h.

Referenced by GetArgStringWithDelimiter(), and SetFromString().

◆ m_args

Args lldb_private::OptionsWithRaw::m_args
private

Definition at line 375 of file Args.h.

Referenced by GetArgs(), and SetFromString().

◆ m_has_args

bool lldb_private::OptionsWithRaw::m_has_args = false
private

Keeps track if we have parsed and stored any arguments.

Definition at line 374 of file Args.h.

Referenced by GetArgs(), GetArgString(), GetArgStringWithDelimiter(), HasArgs(), and SetFromString().

◆ m_suffix

std::string lldb_private::OptionsWithRaw::m_suffix
private

Definition at line 381 of file Args.h.

Referenced by GetRawPart(), and SetFromString().


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