MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / sequence_helper

Function sequence_helper

dds/idl/value_reader_generator.cpp:110–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 }
109
110 void sequence_helper(const std::string& expression, AST_Sequence* sequence,
111 const std::string& idx, int level, FieldFilter filter_kind)
112 {
113 // TODO: Take advantage of the size.
114 const bool use_cxx11 = be_global->language_mapping() == BE_GlobalData::LANGMAP_CXX11;
115 const std::string indent(size_t(level) * 2, ' ');
116 const std::string elem_tk = type_kind(sequence->base_type());
117 be_global->impl_ <<
118 indent << "if (!value_reader.begin_sequence(" << elem_tk << ")) return false;\n" <<
119 indent << "for (" << (use_cxx11 ? "size_t " : "unsigned int ") << idx << " = 0; "
120 "value_reader.elements_remaining(); ++" << idx << ") {\n";
121 if (use_cxx11) {
122 be_global->impl_ << indent << " " << expression << ".resize(" << expression << ".size() + 1);\n";
123 } else {
124 if (!sequence->unbounded()) {
125 be_global->impl_ << indent << " if (" << idx << " >= " << expression << ".maximum()) return false;\n";
126 be_global->impl_ << indent << " " << expression << ".length(" << expression << ".length() + 1);\n";
127 } else {
128 be_global->impl_ << indent << " OpenDDS::DCPS::grow(" << expression << ");\n";
129 }
130 }
131 be_global->impl_ <<
132 indent << " if (!value_reader.begin_element()) return false;\n";
133 generate_read(expression + "[" + idx + "]", "", "elem", sequence->base_type(),
134 idx + "i", level + 1, nested(filter_kind));
135 be_global->impl_ <<
136 indent << " if (!value_reader.end_element()) return false;\n" <<
137 indent << "}\n" <<
138 indent << "if (!value_reader.end_sequence()) return false;\n";
139 }
140
141 void map_helper(const std::string& expression, const AST_Map* map, int level, FieldFilter filter_kind)
142 {

Callers 1

generate_readFunction · 0.70

Calls 4

type_kindFunction · 0.85
generate_readFunction · 0.85
language_mappingMethod · 0.80
nestedFunction · 0.70

Tested by

no test coverage detected