Forum Navigation
Conversions (tango.text.convert.Integer.toInt etc and std.conv.to)
Posted: 10/17/07 17:24:07 Modified: 02/11/08 18:10:43Well, I've been writing a file-parsing library, and wanted to provide an easy way to convert text into most data-types. I found the tango.text.convert.Integer.toInt and Float.toFloat routines to be slightly inconsistant (see http://www.dsource.org/projects/tango/ticket/672) and not really optimal for conversions to any (integer or floating point) type and wanted support for some other conversions, so I decided to write my own.
What I now have is this:
Code removed since it's obsolete and makes the post overly long.(This still needs a bit more work such as making the documentation more consistent. Most notably it lacks support for wchar, dchar, cent, ucent, imaginary and complex types, and only takes input from chars.)
I noticed that phobos now has templated to!(type)(...) and parse!(type)(...) functions in std.conv, and wondered if something similar, either based on the phobos functions or my own, would be a useful addition to tango. I have no idea what the phobos functions support, how accurate they are etc (tbh I only just noticed they exist and can't be bothered to try them out right now).
Basically I'm offering the above code and to do a bit of work making it more complete and use more tango-like conventions if you'd like to use it. Otherwise I'll probably just keep my own code more-or-less as is and use that, and make it publically available along with more of my project later.
btw I'm also wanting conversions from various types to strings; I've yet to investigate what's available for this but I could end up doing something in similar style (although I expect tango already provides well enough for this).
Diggory Hardy / Cyborg16