Published2dArray

The Published2dArray class template allows to serialize 2-dimensional arrays.

A Serializer is not able to directly handle them but this class does the task automatically by merging the array and storing an additional property for the dimensions.

This class template can only be instantiated if T is a basic type. (see iz.types.BasicTypes).

final
class Published2dArray : PropertyPublisher (
T
) if (
isBasicRtType!T
) {
Array!uint _dimensions;
Array!T _content;
T[][]* _source;
uint _setCount;
uint _getCount;
}

Constructors

this
this()
this
this(T[][]* array)

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

Destructor

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

Members

Functions

fromArray
void fromArray(ref T[][] array)

Copies the content of the array to the internal container.

toArray
void toArray(ref T[][] array)

Resets then fills the array using the internal data.

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 alias Publisher = Published2dArray!uint;
2 Publisher pub = construct!Publisher;
3 scope(exit) destruct(pub);
4 
5 auto array = [[0u,1u],[2u,3u,4u],[5u,6u,7u,8u]];
6 pub.fromArray(array);
7 version (none) publisherToFile(pub, "backup.txt");
8 version (none) fileToPublisher("backup.txt", pub);
9 pub.toArray(array);
10 assert(array == [[0u,1u],[2u,3u,4u],[5u,6u,7u,8u]]);

Meta