[Issue 4266] New: add support for structs in std.format.doFormat

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 3 14:08:19 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4266

           Summary: add support for structs in std.format.doFormat
           Product: D
           Version: 2.000
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: mrmocool at gmx.de


--- Comment #0 from Trass3r <mrmocool at gmx.de> 2010-06-03 14:08:16 PDT ---
Currently there is a check if a struct has a toString member and it fails if
not.
It is really cumbersome to code a toString() by hand for every little struct.

if (tis.xtoString is null)
    throw new FormatError("Can't convert " ~ tis.toString() ~ " to string:
\"string toString()\" not defined");
s = tis.xtoString(argptr);


Especially if you are dealing with external headers (in my case Windows/DirectX
headers) you have to face lots of structures that don't have a toString method.


Please add support for a default struct toString that uses the "{membername:
value, member2:value, member3:{mm1:v, ....}}" style just like arrays are
formatted as "[a, b, c, d,...]" and AAs as "[k1:v1, k2:v2, ..]" by default.


==>


if (tis.xtoString is null)
    putStruct(....);
else
    s = tis.xtoString(argptr);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list