17#include "llvm/ADT/StringRef.h"
23 Stream &strm, uint32_t dump_mask) {
47 std::map<llvm::StringRef, OptionValue *> sorted_values;
49 sorted_values[value.first()] = value.second.get();
51 for (
const auto &value : sorted_values) {
70 option_value->
DumpValue(exe_ctx, strm, dump_mask | extra_dump_options);
98 llvm::json::Object dict;
100 dict.try_emplace(value.first(), value.second->ToJSON(exe_ctx));
107 for (
const auto &value :
m_values) {
109 strm.
Printf(
"%s=", value.first().data());
130 "assign operation takes one or more key=value arguments");
133 for (
const auto &entry : args) {
134 if (entry.ref().empty()) {
138 if (!entry.ref().contains(
'=')) {
140 "assign operation takes one or more key=value arguments");
144 llvm::StringRef key, value;
145 std::tie(key, value) = entry.ref().split(
'=');
146 bool key_valid =
false;
152 if (key.front() ==
'[') {
155 if ((key.size() > 2) && (key.back() ==
']')) {
157 key = key.substr(1, key.size() - 2);
158 const char quote_char = key.front();
159 if ((quote_char ==
'\'') || (quote_char ==
'"')) {
160 if ((key.size() > 2) && (key.back() == quote_char)) {
162 key = key.substr(1, key.size() - 2);
176 "invalid key \"%s\", the key must be a bare string or "
177 "surrounded by brackets with optional quotes: [<key>] or "
178 "['<key>'] or [\"<key>\"]",
186 error = enum_value->SetValueFromString(value);
201 "dictionaries that can contain multiple types "
202 "must subclass OptionValueArray");
210 for (
size_t i = 0; i < argc; ++i) {
211 llvm::StringRef key(args.GetArgumentAtIndex(i));
214 "no value found named '%s', aborting remove operation",
221 "remove operation takes one or more key arguments");
236 Args args(value.str());
250 llvm::StringRef left, temp;
251 std::tie(left, temp) = name.split(
'[');
252 if (left.size() == name.size()) {
254 "invalid value path '%s', %s values only "
255 "support '[<key>]' subvalues where <key> "
256 "a string value optionally delimited by "
257 "single or double quotes",
261 assert(!temp.empty());
263 llvm::StringRef key, quote_char;
265 if (temp[0] ==
'\"' || temp[0] ==
'\'') {
266 quote_char = temp.take_front();
267 temp = temp.drop_front();
270 llvm::StringRef sub_name;
271 std::tie(key, sub_name) = temp.split(
']');
273 if (!key.consume_back(quote_char) || key.empty()) {
275 "invalid value path '%s', "
276 "key names must be formatted as ['<key>'] where <key> "
277 "is a string that doesn't contain quotes and the quote"
286 "dictionary does not contain a value for the key name '%s'",
291 if (sub_name.empty())
293 return value_sp->GetSubValue(exe_ctx, sub_name,
error);
298 llvm::StringRef name,
299 llvm::StringRef value) {
303 error = value_sp->SetValueFromString(value, op);
305 if (
error.AsCString() ==
nullptr)
317 value_sp = pos->second;
326 if (value_sp && (
m_type_mask & value_sp->GetTypeAsMask())) {
355 for (
auto &value : dict_value_ptr->m_values)
356 value.second = value.second->DeepCopy(copy_sp);
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
void Clear()
Clear the arguments.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override
size_t GetArgs(Args &args) const
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
llvm::StringMap< lldb::OptionValueSP > m_values
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef name, llvm::StringRef value) override
OptionValueDictionary(uint32_t type_mask=UINT32_MAX, OptionEnumValues enum_values=OptionEnumValues(), bool raw_value_dump=true)
OptionEnumValues m_enum_values
Status SetArgs(const Args &args, VarSetOperationType op)
lldb::OptionValueSP GetValueForKey(llvm::StringRef key) const
bool DeleteValueForKey(llvm::StringRef key)
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, Status &error) const override
bool SetValueForKey(llvm::StringRef key, const lldb::OptionValueSP &value_sp, bool can_replace=true)
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
static lldb::OptionValueSP CreateValueFromCStringForTypeMask(const char *value_cstr, uint32_t type_mask, Status &error)
virtual void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)=0
static OptionValue::Type ConvertTypeMaskToType(uint32_t type_mask)
virtual lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const
static const char * GetBuiltinTypeAsCString(Type t)
void NotifyValueChanged()
virtual const char * GetTypeAsCString() const
@ eDumpOptionDefaultValue
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
@ eVarSetOperationReplace
@ eVarSetOperationInvalid
@ eVarSetOperationInsertBefore
@ eVarSetOperationInsertAfter
std::shared_ptr< lldb_private::OptionValue > OptionValueSP