MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / initialize

Method initialize

source/fbe.cpp:211–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211void Package::initialize()
212{
213 if (body)
214 {
215 for (const auto& child_s : body->structs)
216 {
217 // Add offset to all structs in the package
218 if (!child_s->fixed)
219 child_s->type += offset;
220
221 // Find structs with id & key flags
222 if (child_s->body)
223 {
224 std::vector<std::shared_ptr<StructField>> fields;
225 for (const auto& field : child_s->body->fields)
226 {
227 if (field->id)
228 {
229 if (child_s->id)
230 yyerror("Struct " + *child_s->name.get() + " must have only one [id] field!");
231 child_s->id = true;
232 field->keys = true;
233 }
234 if (field->keys)
235 child_s->keys = true;
236 if (field->reseter)
237 field->optional = true;
238 fields.push_back(field);
239 if (field->reseter)
240 {
241 auto reseter = std::make_shared<StructField>();
242 reseter->name = std::make_shared<std::string>(*field->name + "Reset");
243 reseter->type = std::make_shared<std::string>("bool");
244 fields.push_back(reseter);
245 }
246 }
247 child_s->body->fields = fields;
248 }
249 }
250 }
251}
252
253} // namespace FBE

Callers

nothing calls this directly

Calls 2

push_backMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected