blob: 1983d77bbd49eca5c4e512d7872a567632db5960 [file] [log] [blame]
void Config::RecordInspect(inspect::Node* node) {
{{#each fields}}
{{#if (is_string_vector type_)}}
auto {{ident}}_array_ = node->CreateStringArray("{{ident}}", this->{{ident}}().size());
for (size_t i = 0; i < this->{{ident}}().size(); i++) {
auto ref = std::string_view(this->{{ident}}()[i].data());
{{ident}}_array_.Set(i, ref);
}
node->Record(std::move({{ident}}_array_));
{{else}}
{{#if (is_vector type_)}}
auto {{ident}}_array_ =
node->Create{{(inspect_type type_)}}Array("{{ident}}", this->{{ident}}().size());
for (size_t i = 0; i < this->{{ident}}().size(); i++) {
{{ident}}_array_.Set(i, this->{{ident}}()[i]);
}
node->Record(std::move({{ident}}_array_));
{{else}}
node->Record{{(inspect_type type_)}}("{{ident}}", this->{{ident}}());
{{/if}}
{{/if}}
{{/each}}
}
std::ostream& operator<<(std::ostream& os, const Config& c) {
{{#each fields}}
{{#if (is_vector type_)}}
os << " {{ident}}: [" << std::endl;
for (auto value : c.{{ident}}()) {
os << " " << value << "," << std::endl;
}
os << "]" << std::endl;
{{else}}
os << " {{ident}}: " << c.{{ident}}() << std::endl;
{{/if}}
{{~/each~}}
return os;
}
template <class T>
std::vector<T> from_vector_view(fidl::VectorView<T> v) {
size_t count = v.count();
std::vector<T> data(count);
for (size_t i = 0; i < count; i++) {
data[i] = v[i];
}
return data;
}
std::vector<std::string> from_vector_string_view(fidl::VectorView<fidl::StringView> v) {
size_t count = v.count();
std::vector<std::string> data(count);
for (size_t i = 0; i < count; i++) {
data[i] = std::string(v[i].get());
}
return data;
}