-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson-array.cc
More file actions
31 lines (28 loc) · 864 Bytes
/
json-array.cc
File metadata and controls
31 lines (28 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include "json-array.h"
#include "json-value.h"
namespace json {
json_array::json_array() : _Impl_array() {}
json_array::json_array(const json_array &rvalue) : _Impl_array(rvalue._Impl_array) {}
json_array::json_array(json_array &&rvalue) : _Impl_array(std::move(rvalue._Impl_array)) {}
json_array::json_array(const json_array::value_type &var) : _Impl_array()
{
if (var.typeof() == "JSON_ARRAY") {
*this = var.value._M_json_array;
} else {
std::cerr << "Can't convert '" << var
<< "' from `" << var.typeof() << "` to `JSON_ARRAY`\n";
}
}
std::ostream &operator<<(std::ostream &out, const json_array &array)
{
out << "[";
for (auto it = array.begin(); it != array.end(); it++) {
out << *it;
if (std::next(it) != array.end())
out << ',';
}
out << "]";
return out;
}
}