-
Notifications
You must be signed in to change notification settings - Fork 1
/
dynamic-list-builder.cpp
45 lines (35 loc) · 1.26 KB
/
dynamic-list-builder.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "dynamic-list-builder.h"
#include "dynamic-value-converter.h"
namespace capnp_php {
DynamicListBuilder::DynamicListBuilder(capnp::DynamicList::Builder builder,
Php::Object messageBuilder)
: Php::Base(),
messageBuilder(messageBuilder),
builder(builder)
{
}
Php::Value DynamicListBuilder::getByIndex(int64_t index) {
return DynamicValueConverter::convertFromCapnp(builder[index], this);
}
long DynamicListBuilder::count() {
return static_cast<long>(builder.size());
}
bool DynamicListBuilder::offsetExists(const Php::Value &key) {
int64_t index = key;
return index < static_cast<int64_t>(builder.size());
}
Php::Value DynamicListBuilder::offsetGet(const Php::Value &key) {
return getByIndex(key);
}
void DynamicListBuilder::offsetSet(const Php::Value &key, const Php::Value &value) {
int64_t index = key;
DynamicValueConverter::convertToCapnp(builder, index, value);
}
void DynamicListBuilder::offsetUnset(const Php::Value &key) {
//throw Php::NotImplemented();
}
Php::Iterator *DynamicListBuilder::getIterator() {
throw Php::Exception("getIterator not implemented");
return nullptr;
}
}