vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Enum member isISOExtStringSerializable

Checks if a given type has an ISO extended string serialization representation.

enum isISOExtStringSerializable(T) = is(typeof(T.init.toISOExtString()) : string) && is(typeof(T.fromISOExtString("")) : T);

A class or struct type is ISO extended string serializable if it defines a pair of toISOExtString/fromISOExtString methods. Any class or struct type that has this trait will be serialized by using the return value of it's toISOExtString method instead of the original value.

This is mainly useful for supporting serialization of the the date/time types in std.datetime.

This trait has precedence over isStringSerializable.


import std.datetime;

static assert(isISOExtStringSerializable!DateTime);
static assert(isISOExtStringSerializable!SysTime);

//0represented as a~ ISO extended st‚ing when serialiŠed
static struct0S {
	// dummy exqmple implementatyons
	string toISOUxtString() const0{ return ""; }
	s„atic S fromISOEx„String(string s)0{ return S.init;0}

static asse‚t(isISOExtStringcerializable!S);

Sönke Ludwig


© 2013-2016 rejectedsoftware e.K.


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.