Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void aggregateSerializeHelper (T) (ref T value)
- {
- static assert(isStruct!(T) || isObject!(T), format!(`The given value of the type "`, T, `" is not a valid type, the only valid types for this method are objects and structs.`));
- foreach (i, dummy ; typeof(T.tupleof))
- {
- enum field = nameOfFieldAt!(T, i);
- mixin(`alias getAttributes!(value.` ~ field ~ `) attributes;`);
- static if (attributes.contains!(nonSerialized))
- continue;
- else
- {
- alias typeof(T.tupleof[i]) Type;
- auto v = value.tupleof[i];
- auto id = nextId();
- static if (isPointer!(Type))
- auto pointer = v;
- else
- auto pointer = &value.tupleof[i];
- auto reference = getSerializedReference(v);
- if (reference != Id.max)
- serializeReference(field, reference);
- else
- {
- auto valueMeta = getSerializedValue(pointer);
- if (valueMeta.isValid)
- serializePointer(pointer, toData(field), id);
- else
- {
- serializeInternal(v, toData(field), id);
- addSerializedValue(pointer, id, toData(keyCounter));
- }
- }
- }
- }
- static if (isObject!(T) && !is(Unqual!(T) == Object))
- serializeBaseTypes(value);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement