mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 08:37:36 +00:00
AK+Everywhere: Change int to size_t in JsonObject and JsonArray
This commit is contained in:
parent
66526cbbaf
commit
f45273649f
9 changed files with 14 additions and 14 deletions
|
@ -48,7 +48,7 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size() const { return m_values.size(); }
|
size_t size() const { return m_values.size(); }
|
||||||
bool is_empty() const { return m_values.is_empty(); }
|
bool is_empty() const { return m_values.is_empty(); }
|
||||||
|
|
||||||
JsonValue const& at(size_t index) const { return m_values.at(index); }
|
JsonValue const& at(size_t index) const { return m_values.at(index); }
|
||||||
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
void clear() { m_values.clear(); }
|
void clear() { m_values.clear(); }
|
||||||
void append(JsonValue value) { m_values.append(move(value)); }
|
void append(JsonValue value) { m_values.append(move(value)); }
|
||||||
void set(int index, JsonValue value) { m_values[index] = move(value); }
|
void set(size_t index, JsonValue value) { m_values[index] = move(value); }
|
||||||
|
|
||||||
template<typename Builder>
|
template<typename Builder>
|
||||||
typename Builder::OutputType serialized() const;
|
typename Builder::OutputType serialized() const;
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
|
|
||||||
Vector<JsonValue> const& values() const { return m_values; }
|
Vector<JsonValue> const& values() const { return m_values; }
|
||||||
|
|
||||||
void ensure_capacity(int capacity) { m_values.ensure_capacity(capacity); }
|
void ensure_capacity(size_t capacity) { m_values.ensure_capacity(capacity); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<JsonValue> m_values;
|
Vector<JsonValue> m_values;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size() const { return m_members.size(); }
|
size_t size() const { return m_members.size(); }
|
||||||
bool is_empty() const { return m_members.is_empty(); }
|
bool is_empty() const { return m_members.is_empty(); }
|
||||||
|
|
||||||
JsonValue const& get(String const& key) const
|
JsonValue const& get(String const& key) const
|
||||||
|
|
|
@ -90,7 +90,7 @@ bool JsonValue::equals(const JsonValue& other) const
|
||||||
|
|
||||||
if (is_array() && other.is_array() && as_array().size() == other.as_array().size()) {
|
if (is_array() && other.is_array() && as_array().size() == other.as_array().size()) {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
for (int i = 0; i < as_array().size(); ++i) {
|
for (size_t i = 0; i < as_array().size(); ++i) {
|
||||||
result &= as_array().at(i).equals(other.as_array().at(i));
|
result &= as_array().at(i).equals(other.as_array().at(i));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -22,7 +22,7 @@ int RemoteObjectPropertyModel::row_count(const GUI::ModelIndex& index) const
|
||||||
return value.as_array().size();
|
return value.as_array().size();
|
||||||
else if (value.is_object())
|
else if (value.is_object())
|
||||||
return value.as_object().size();
|
return value.as_object().size();
|
||||||
return 0;
|
return (size_t)0;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (index.is_valid()) {
|
if (index.is_valid()) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ void CommonLocationsProvider::load_from_json(const String& json_path)
|
||||||
|
|
||||||
s_common_locations.clear();
|
s_common_locations.clear();
|
||||||
auto contents = json.value().as_array();
|
auto contents = json.value().as_array();
|
||||||
for (auto i = 0; i < contents.size(); ++i) {
|
for (size_t i = 0; i < contents.size(); ++i) {
|
||||||
auto entry_value = contents.at(i);
|
auto entry_value = contents.at(i);
|
||||||
if (!entry_value.is_object())
|
if (!entry_value.is_object())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -59,7 +59,7 @@ bool JsonArrayModel::set(int row, Vector<JsonValue>&& values)
|
||||||
{
|
{
|
||||||
VERIFY(values.size() == m_fields.size());
|
VERIFY(values.size() == m_fields.size());
|
||||||
|
|
||||||
if (row >= m_array.size())
|
if ((size_t)row >= m_array.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JsonObject obj;
|
JsonObject obj;
|
||||||
|
@ -76,12 +76,12 @@ bool JsonArrayModel::set(int row, Vector<JsonValue>&& values)
|
||||||
|
|
||||||
bool JsonArrayModel::remove(int row)
|
bool JsonArrayModel::remove(int row)
|
||||||
{
|
{
|
||||||
if (row >= m_array.size())
|
if ((size_t)row >= m_array.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JsonArray new_array;
|
JsonArray new_array;
|
||||||
for (int i = 0; i < m_array.size(); ++i)
|
for (size_t i = 0; i < m_array.size(); ++i)
|
||||||
if (i != row)
|
if (i != (size_t)row)
|
||||||
new_array.append(m_array.at(i));
|
new_array.append(m_array.at(i));
|
||||||
|
|
||||||
m_array = new_array;
|
m_array = new_array;
|
||||||
|
|
|
@ -74,7 +74,7 @@ Vector<u32> CharacterMapFile::read_map(const JsonObject& json, const String& nam
|
||||||
buffer.resize(CHAR_MAP_SIZE);
|
buffer.resize(CHAR_MAP_SIZE);
|
||||||
|
|
||||||
auto map_arr = json.get(name).as_array();
|
auto map_arr = json.get(name).as_array();
|
||||||
for (int i = 0; i < map_arr.size(); i++) {
|
for (size_t i = 0; i < map_arr.size(); i++) {
|
||||||
auto key_value = map_arr.at(i).as_string();
|
auto key_value = map_arr.at(i).as_string();
|
||||||
if (key_value.length() == 0) {
|
if (key_value.length() == 0) {
|
||||||
buffer[i] = 0;
|
buffer[i] = 0;
|
||||||
|
|
|
@ -59,7 +59,7 @@ private:
|
||||||
static Vector<Quote> parse_all(const JsonArray& array)
|
static Vector<Quote> parse_all(const JsonArray& array)
|
||||||
{
|
{
|
||||||
Vector<Quote> quotes;
|
Vector<Quote> quotes;
|
||||||
for (int i = 0; i < array.size(); ++i) {
|
for (size_t i = 0; i < array.size(); ++i) {
|
||||||
Optional<Quote> q = Quote::try_parse(array[i]);
|
Optional<Quote> q = Quote::try_parse(array[i]);
|
||||||
if (!q.has_value()) {
|
if (!q.has_value()) {
|
||||||
warnln("WARNING: Could not parse quote #{}!", i);
|
warnln("WARNING: Could not parse quote #{}!", i);
|
||||||
|
|
|
@ -112,7 +112,7 @@ static void print(const String& name, const JsonValue& value, Vector<String>& tr
|
||||||
if (value.is_array()) {
|
if (value.is_array()) {
|
||||||
outln("{}[]{};", color_brace, color_off);
|
outln("{}[]{};", color_brace, color_off);
|
||||||
trail.append(String::formatted("{}{}{}", color_name, name, color_off));
|
trail.append(String::formatted("{}{}{}", color_name, name, color_off));
|
||||||
for (int i = 0; i < value.as_array().size(); ++i) {
|
for (size_t i = 0; i < value.as_array().size(); ++i) {
|
||||||
auto element_name = String::formatted("{}{}[{}{}{}{}{}]{}", color_off, color_brace, color_off, color_index, i, color_off, color_brace, color_off);
|
auto element_name = String::formatted("{}{}[{}{}{}{}{}]{}", color_off, color_brace, color_off, color_index, i, color_off, color_brace, color_off);
|
||||||
print(element_name, value.as_array()[i], trail);
|
print(element_name, value.as_array()[i], trail);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue