2019-06-17 17:47:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/JsonValue.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
2019-06-17 19:34:12 +00:00
|
|
|
namespace AK {
|
|
|
|
|
2019-06-17 17:47:35 +00:00
|
|
|
class JsonArray {
|
|
|
|
public:
|
|
|
|
JsonArray() {}
|
|
|
|
~JsonArray() {}
|
|
|
|
|
|
|
|
int size() const { return m_values.size(); }
|
|
|
|
bool is_empty() const { return m_values.is_empty(); }
|
|
|
|
|
|
|
|
const JsonValue& at(int index) const { return m_values.at(index); }
|
|
|
|
const JsonValue& operator[](int index) const { return at(index); }
|
|
|
|
|
|
|
|
void clear() { m_values.clear(); }
|
|
|
|
void append(const JsonValue& value) { m_values.append(value); }
|
|
|
|
|
2019-06-18 07:37:47 +00:00
|
|
|
String serialized() const;
|
|
|
|
void serialize(StringBuilder&) const;
|
2019-06-17 17:47:35 +00:00
|
|
|
|
2019-06-24 10:02:31 +00:00
|
|
|
template<typename Callback>
|
|
|
|
void for_each(Callback callback) const
|
|
|
|
{
|
|
|
|
for (auto& value : m_values)
|
|
|
|
callback(value);
|
|
|
|
}
|
|
|
|
|
2019-08-04 08:05:02 +00:00
|
|
|
const Vector<JsonValue>& values() const { return m_values; }
|
|
|
|
|
2019-06-17 17:47:35 +00:00
|
|
|
private:
|
|
|
|
Vector<JsonValue> m_values;
|
|
|
|
};
|
2019-06-17 19:34:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using AK::JsonArray;
|