9#ifndef LLDB_UTILITY_ARGS_H
10#define LLDB_UTILITY_ARGS_H
15#include "llvm/ADT/ArrayRef.h"
16#include "llvm/ADT/StringExtras.h"
17#include "llvm/ADT/StringRef.h"
39 std::unique_ptr<char[]>
ptr;
50 llvm::StringRef
ref()
const {
return c_str(); }
51 const char *
c_str()
const {
return ptr.get(); }
67 Args(llvm::StringRef command = llvm::StringRef());
71 explicit Args(llvm::ArrayRef<llvm::StringRef> args);
95 void Dump(
Stream &s,
const char *label_name =
"argv")
const;
174 return llvm::ArrayRef(
m_argv).drop_back();
184 void AppendArgument(llvm::StringRef arg_str,
char quote_char =
'\0');
201 char quote_char =
'\0');
215 char quote_char =
'\0');
256 void Unshift(llvm::StringRef arg_str,
char quote_char =
'\0');
270 llvm::StringRef unsafe_arg);
A command line argument class.
std::vector< ArgEntry >::const_iterator const_iterator
char ** GetArgumentVector()
Gets the argument vector.
void Dump(Stream &s, const char *label_name="argv") const
Dump all entries to the stream s using label label_name.
static std::string EscapeLLDBCommandArgument(const std::string &arg, char quote_char)
void Unshift(llvm::StringRef arg_str, char quote_char='\0')
Inserts a class owned copy of arg_str at the beginning of the argument vector.
llvm::ArrayRef< const char * > GetArgumentArrayRef() const
Gets the argument as an ArrayRef.
void Shift()
Shifts the first argument C string value of the array off the argument array.
void DeleteArgumentAtIndex(size_t idx)
Deletes the argument value at index if idx is a valid argument index.
static void ExpandEscapedCharacters(const char *src, std::string &dst)
ExpandEscapeSequences will change a string of possibly non-printable characters and expand them into ...
void SetArguments(size_t argc, const char **argv)
Sets the argument vector value, optionally copying all arguments into an internal buffer.
void AppendArguments(const Args &rhs)
const ArgEntry & operator[](size_t n) const
static lldb::Encoding StringToEncoding(llvm::StringRef s, lldb::Encoding fail_value=lldb::eEncodingInvalid)
static uint32_t StringToGenericRegister(llvm::StringRef s)
const_iterator begin() const
Args(const Environment &env)
Args & operator=(const Args &rhs)
std::vector< ArgEntry > m_entries
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
void SetCommandString(llvm::StringRef command)
Sets the command string contained by this object.
static void EncodeEscapeSequences(const char *src, std::string &dst)
EncodeEscapeSequences will change the textual representation of common escape sequences like "\n" (tw...
void ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str, char quote_char='\0')
Replaces the argument value at index idx to arg_str if idx is a valid argument index.
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
llvm::ArrayRef< ArgEntry > entries() const
std::vector< char * > m_argv
The arguments as C strings with a trailing nullptr element.
static std::string GetShellSafeArgument(const FileSpec &shell, llvm::StringRef unsafe_arg)
const_iterator end() const
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
bool GetCommandString(std::string &command) const
void InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str, char quote_char='\0')
Insert the argument value at index idx to arg_str.
const char ** GetConstArgumentVector() const
Gets the argument vector.
bool GetQuotedCommandString(std::string &command) const
void Clear()
Clear the arguments.
char *const * get() const
A pair of an option list with a 'raw' string as a suffix.
bool HasArgs() const
Returns true if there are any arguments before the raw suffix.
Args & GetArgs()
Returns the list of arguments.
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.
bool m_has_args
Keeps track if we have parsed and stored any arguments.
void SetFromString(llvm::StringRef arg_string)
const Args & GetArgs() 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 m_arg_string
llvm::StringRef m_arg_string_with_delimiter
A stream class that can stream formatted output to a file.
A class that represents a running process on the host machine.
Encoding
Register encoding definitions.
const char * c_str() const
llvm::StringRef ref() const
std::optional< uint16_t > column
The position of the argument in the original argument string.
std::unique_ptr< char[]> ptr
bool IsQuoted() const
Returns true if this argument was quoted in any way.
char GetQuoteChar() const
std::optional< uint16_t > GetPos() const