diff options
author | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-03 08:43:37 +0000 |
---|---|---|
committer | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-03 08:43:37 +0000 |
commit | 5d30f92bf4e9f055d44ea0db2327b036ae41eef6 (patch) | |
tree | e4237d83ef224e420140e6411ac84f60216555d1 /base/values.cc | |
parent | 4ccaee6820cb8ac79581141a4f2463a2abb38442 (diff) | |
download | chromium_src-5d30f92bf4e9f055d44ea0db2327b036ae41eef6.zip chromium_src-5d30f92bf4e9f055d44ea0db2327b036ae41eef6.tar.gz chromium_src-5d30f92bf4e9f055d44ea0db2327b036ae41eef6.tar.bz2 |
Correct const accessors in base/values.(h|cc), Part II (ListValue)
For problem description and other info please see the BUG page.
This is for ListValue.
BUG=138946
TEST=N/A (no fix & no new feature)
TBR=jar,zelidrag,scottbyer,mpcomplete,darin,achuith,sky,estade,atwilson,grt,thakis,jamesr,hans,sadrul,pastarmovj
Review URL: https://chromiumcodereview.appspot.com/10837044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.cc')
-rw-r--r-- | base/values.cc | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/base/values.cc b/base/values.cc index 08fab89..1ccc9ec 100644 --- a/base/values.cc +++ b/base/values.cc @@ -820,7 +820,7 @@ bool ListValue::Set(size_t index, Value* in_value) { return true; } -bool ListValue::Get(size_t index, Value** out_value) const { +bool ListValue::Get(size_t index, const Value** out_value) const { if (index >= list_.size()) return false; @@ -830,8 +830,14 @@ bool ListValue::Get(size_t index, Value** out_value) const { return true; } +bool ListValue::Get(size_t index, Value** out_value) { + return static_cast<const ListValue&>(*this).Get( + index, + const_cast<const Value**>(out_value)); +} + bool ListValue::GetBoolean(size_t index, bool* bool_value) const { - Value* value; + const Value* value; if (!Get(index, &value)) return false; @@ -839,7 +845,7 @@ bool ListValue::GetBoolean(size_t index, bool* bool_value) const { } bool ListValue::GetInteger(size_t index, int* out_value) const { - Value* value; + const Value* value; if (!Get(index, &value)) return false; @@ -847,7 +853,7 @@ bool ListValue::GetInteger(size_t index, int* out_value) const { } bool ListValue::GetDouble(size_t index, double* out_value) const { - Value* value; + const Value* value; if (!Get(index, &value)) return false; @@ -855,7 +861,7 @@ bool ListValue::GetDouble(size_t index, double* out_value) const { } bool ListValue::GetString(size_t index, std::string* out_value) const { - Value* value; + const Value* value; if (!Get(index, &value)) return false; @@ -863,49 +869,68 @@ bool ListValue::GetString(size_t index, std::string* out_value) const { } bool ListValue::GetString(size_t index, string16* out_value) const { - Value* value; + const Value* value; if (!Get(index, &value)) return false; return value->GetAsString(out_value); } -bool ListValue::GetBinary(size_t index, BinaryValue** out_value) const { - Value* value; +bool ListValue::GetBinary(size_t index, const BinaryValue** out_value) const { + const Value* value; bool result = Get(index, &value); if (!result || !value->IsType(TYPE_BINARY)) return false; if (out_value) - *out_value = static_cast<BinaryValue*>(value); + *out_value = static_cast<const BinaryValue*>(value); return true; } -bool ListValue::GetDictionary(size_t index, DictionaryValue** out_value) const { - Value* value; +bool ListValue::GetBinary(size_t index, BinaryValue** out_value) { + return static_cast<const ListValue&>(*this).GetBinary( + index, + const_cast<const BinaryValue**>(out_value)); +} + +bool ListValue::GetDictionary(size_t index, + const DictionaryValue** out_value) const { + const Value* value; bool result = Get(index, &value); if (!result || !value->IsType(TYPE_DICTIONARY)) return false; if (out_value) - *out_value = static_cast<DictionaryValue*>(value); + *out_value = static_cast<const DictionaryValue*>(value); return true; } -bool ListValue::GetList(size_t index, ListValue** out_value) const { - Value* value; +bool ListValue::GetDictionary(size_t index, DictionaryValue** out_value) { + return static_cast<const ListValue&>(*this).GetDictionary( + index, + const_cast<const DictionaryValue**>(out_value)); +} + +bool ListValue::GetList(size_t index, const ListValue** out_value) const { + const Value* value; bool result = Get(index, &value); if (!result || !value->IsType(TYPE_LIST)) return false; if (out_value) - *out_value = static_cast<ListValue*>(value); + *out_value = static_cast<const ListValue*>(value); return true; } +bool ListValue::GetList(size_t index, ListValue** out_value) { + return static_cast<const ListValue&>(*this).GetList( + index, + const_cast<const ListValue**>(out_value)); +} + bool ListValue::Remove(size_t index, Value** out_value) { if (index >= list_.size()) return false; |