Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Variant.toUtf8

Moderators: larsivi kris

Posted: 08/15/07 17:32:33

What is this supposed to do? Comment says that it currently returns the name of the contained type. Anyway, why the special cases are commented out? I thought it would be logical to return formatted text (like the class/structure .toUtf8 property).

http://www.dsource.org/projects/tango/browser/trunk/tango/core/Variant.d

Author Message

Posted: 08/15/07 18:49:35

They are commented out so that you don't need to link in the formatter to use Variant. We hope to provide a different solution for formatting Variant that don't require Variant to depend on the formatter.

Posted: 08/16/07 17:06:47

Ah, I see now. Thanks for your reply.

Posted: 08/16/07 17:46:17 -- Modified: 08/16/07 17:51:49 by
Linker

Is there a way to construct a Variant out of char[] string and TypeInfo? for basic type, so that "1" will be Variant of type int? I see the following solution:

TypeInfo? type = typeid( int ); // say it's an integer

// ...some code...

if ( type is typeid( int ) ) {

// use tango.text.convert.Integer to parse integer out of string

} else if ( type is typeid( float ) ) {

// ...

} // etc...

Is this okay? Are there better ways?