PublishedAA

The PublishedAA class template allows to serialize an associative array.

A Serializer is not able to directly handle AAs but this class does the task automatically by splitting keys and values in two arrays.

This class template can only be instantiated if the AA key and value type is basic (see iz.rtti.BasicRtTypes).

final
class PublishedAA : PropertyPublisher (
AA
) if (
isAssociativeArray!AA &&
isSerializable!(KeyType!AA)
&&
isSerializable!(ValueType!AA)
) {
AA* _source;
Array!(KeyType!AA) _keys;
Array!(ValueType!AA) _content;
uint _setCount;
uint _getCount;
}

Constructors

this
this()
this
this(AA* aa)

Constructs a new instance and sets a reference to the source AA. Using this constructor, toAA() and fromAA() don't need to be called manually.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

fromAA
void fromAA(ref AA aa)

Copies the content of an associative array to the internal containers.

toAA
void toAA(ref AA aa)

Resets then fills an associative array using the internal containers.

Inherited Members

From PropertyPublisher

publicationCount
size_t publicationCount()

Returns the count of descriptor this class publishes.

publicationFromName
GenericDescriptor* publicationFromName(const(char)[] name)

Returns a pointer to a descriptor according to its name. Similar to the publication() function template excepted that the result type has not to be specified.

publicationFromIndex
GenericDescriptor* publicationFromIndex(size_t index)

Returns a pointer the index-th descriptor. Index must be within the [0 .. publicationCount] range.

declarator
Object declarator()
void declarator(Object value)

Pointer to the object that has created the descriptor leading to this PropertyPublisher instance.

Examples

1 uint[char] aa = ['c' : 0u, 'x' : 12u];
2 auto serializableAA = construct!(PublishedAA!(uint[char]));
3 serializableAA.fromAA(aa);
4 aa = aa.init;
5 version(none) publisherToFile(serializableAA, "backup.txt");
6 version(none) fileToPublisher("backup.txt", serializableAA);
7 serializableAA.toAA(aa);
8 assert(aa == ['c' : 0u, 'x' : 12u]);
9 destruct(serializableAA);

Meta