bool
GetItemAtIndexAsInteger(size_t idx, IntType &result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- if (auto int_value = value->GetAsInteger())
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get())
{
- result = static_cast<IntType>(int_value->GetValue());
- return true;
+ if (auto int_value = value_sp->GetAsInteger())
+ {
+ result = static_cast<IntType>(int_value->GetValue());
+ return true;
+ }
}
return false;
}
bool
GetItemAtIndexAsString(size_t idx, std::string &result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- if (auto string_value = value->GetAsString())
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get())
{
- result = string_value->GetValue();
- return true;
+ if (auto string_value = value_sp->GetAsString())
+ {
+ result = string_value->GetValue();
+ return true;
+ }
}
return false;
}
bool
GetItemAtIndexAsString(size_t idx, ConstString &result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- if (!value)
- return false;
- if (auto string_value = value->GetAsString())
- {
- result = ConstString(string_value->GetValue());
- return true;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString())
+ {
+ result = ConstString(string_value->GetValue());
+ return true;
+ }
}
return false;
}
bool
GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- result = value->GetAsDictionary();
- return (result != nullptr);
+ result = nullptr;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get())
+ {
+ result = value_sp->GetAsDictionary();
+ return (result != nullptr);
+ }
+ return false;
}
bool
GetItemAtIndexAsArray(size_t idx, Array *&result) const
{
- ObjectSP value = GetItemAtIndex(idx);
- result = value->GetAsArray();
- return (result != nullptr);
+ result = nullptr;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get())
+ {
+ result = value_sp->GetAsArray();
+ return (result != nullptr);
+ }
+ return false;
}
void
bool
GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
{
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- if (auto int_value = value->GetAsInteger())
- {
- result = static_cast<IntType>(int_value->GetValue());
- return true;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp) {
+ if (auto int_value = value_sp->GetAsInteger())
+ {
+ result = static_cast<IntType>(int_value->GetValue());
+ return true;
+ }
}
return false;
}
bool
GetValueForKeyAsString(llvm::StringRef key, std::string &result) const
{
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- if (auto string_value = value->GetAsString())
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get())
{
- result = string_value->GetValue();
- return true;
+ if (auto string_value = value_sp->GetAsString())
+ {
+ result = string_value->GetValue();
+ return true;
+ }
}
return false;
}
bool
GetValueForKeyAsString(llvm::StringRef key, ConstString &result) const
{
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- if (auto string_value = value->GetAsString())
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get())
{
- result = ConstString(string_value->GetValue());
- return true;
+ if (auto string_value = value_sp->GetAsString())
+ {
+ result = ConstString(string_value->GetValue());
+ return true;
+ }
}
return false;
}
GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
{
result = nullptr;
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- result = value->GetAsDictionary();
- return true;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get())
+ {
+ result = value_sp->GetAsDictionary();
+ return (result != nullptr);
+ }
+ return false;
}
bool
GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
{
result = nullptr;
- ObjectSP value = GetValueForKey(key);
- if (!value)
- return false;
- result = value->GetAsArray();
- return true;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get())
+ {
+ result = value_sp->GetAsArray();
+ return (result != nullptr);
+ }
+ return false;
}
bool
}
void
- AddItem (llvm::StringRef key, ObjectSP value)
+ AddItem (llvm::StringRef key, ObjectSP value_sp)
{
ConstString key_cs(key);
- m_dict[key_cs] = value;
+ m_dict[key_cs] = value_sp;
}
void