MKoD - D Programming Language

Variant datatype - D Project

Variant in the Red-Orbs font

On the 7th of May 2005 I decided to go ahead and start this project, mainly because, I've always wanted (felt I had a need) to have a variant datatype for use in D that was more Visual Basic-like for use in some areas of my code. A variant datatype should allow me the option to write more generalized functions with more a flexible datatype parameter passing ability. A sort-of a coded "Black-Box" container / business object (comes to the fore-front in my mind), that'll take almost any kind of basic data, and then just work with it.

11.May.05 Canned v0.1 and rewrote most of it in v0.2, then added Operator Overloading... which is still a work-in-process, after all it's my first time I've ever done this in D, so it's currently workable, but not perfect.

21.May.05: Now starting with v0.3 I've added support for variants within std.math functions, and even added seven new math functions not currently in std.math or std.math2.

24.May.05: In v0.4 added String concatenations, slice operators, and added most of the std.string functions as wrappers to variants. Also now Numerical strings can be in a math formula... which is a very kool thing to see in action. :))

// NumStrMath.d
// Updated to VariantStruct.d v0.69 / D v1.007
// Example of "Numerical Strings" used in math with regular numerics.
// Must use a variant first in the argument to convert to right-side to a variant, 
// then strings will work correctly without an error in the math operations.
// examples: v = 0; v = (v + "200"c) / 23L - "23"w;
//           v = 0; v = (v + 255) * "2"w / "12.5"c;
//                         or
//           v = toVariant(255) * "2.0"w / "12.5"c;
// Note: Strings can't have postfix character before being converted to a variant
// To Compile: dmd numstrmath.d variantstruct.d innumrange.d
private import std.stdio;
private import std.conv;
private import variantstruct;
private import innumrange;

alias std.stdio io;
alias std.conv  sc;

int main()
{
    //variant v = toVariant(200.5);
    variant v = "200.5"c; 
             
    // implicit conversion
    v = (v + 25 + "100"c) / "3"w - 15.5;
    writefln("(implicit conversion) v.toReal=%g", v.toReal);
    
    // explicit conversion 
    v = 200.5;
    v = (cast(variant)25 + sc.toReal("100") + v) / sc.toReal("3") - 15.5;
    writefln("(explicit conversion) v.toReal=%g", v.toReal);
    writefln();

    v  = "200.5"w;
    v += 25;
    v += "100"d;
    v /= "3"c;
    v -= 15.5;
    writefln("an extra example v.toInt=%d, v.toCharA=\"%s\", v.toULong=%d, v.toReal=%g", 
             v.toInt, v.toCharA, v.toULong, v.toReal);
    writefln();
     
    v = (toVariant("200.5"w) + "25"d + "100"c) / "3"w - "15.5"c;
    writefln("v = (toVariant(\"200.5\"w) + \"25\"d + \"100\"c) / \"3\"w - \"15.5\"c; (ans=%g)", 
             v.toReal);
             
    return 0;
}
C:\dmd>dmd numstrmath.d variantstruct.d innumrange.d
C:\dmd\bin\..\..\dm\bin\link.exe numstrmath+variantstruct+innumrange,,,user32+kernel32/noi;

C:\dmd>numstrmath
(implicit conversion) v.toReal=93
(explicit conversion) v.toReal=93

an extra example v.toInt=93, v.toCharA="93", v.toULong=93, v.toReal=93

v = (toVariant("200.5"w) + "25"d + "100"c) / "3"w - "15.5"c; (ans=93)

C:\dmd>

Of course it's always better to conversion to a basic datatype to do actions on them, but it's also nice to have a different option. Added string unittests.

25.May.05 In v0.41 added a set of toVariant() functions to convert most of the other basic datatypes to a variant. And even though, the variant struct already does conversion back and fro with its internal functions, these addtional functions are very handly to use in initializing a variant with non-variant datatypes (variant v = toVariant("1002");). (I still haven't figured out how to use the opCast() operator at this point.) Added more string unittests.

26.May.05 In v0.42 I've added the toVariantArray(...) function that stores arguments into a variant array ("variant[]") which can be pretty handy in passing different datatype values around from function to function as needed. Also I found a bug in the s(in real r) function that has been corrected.

// VarArr1.d
// Updated to VariantStruct.d v0.69 / D v1.007
// To Compile: dmd vararr1.d variantstruct.d innumrange.d
private import std.stdio;
private import variantstruct;

int main()
{
    variant[] vprms;
    variant   va = toVariant("Zzz..."c);
    
    writefln("An toVariantArray() example"d);
    writefln();

    vprms = toVariantArray(-123, "456"c, 3.52, "abc"d, 0b11001101, "x"w, 
                           va, -45.678e+20L, -float.nan, real.infinity,
                           0xFF, 0.1e-128, "\t1) \"Tabbed\""c, va ~ "gnite!"d);
    
    for (uint ui = 0; ui < vprms.length; ui++)
        writefln("vprms[%d]=\"%s\" (%s)"c, ui, 
            vprms[ui].toCharA, formatMsg(vprms[ui])); 

    return 0;
}

char[] formatMsg(in variant v)
{
    char[] sMsg = "That's stored as a "c;

    if (v.type == 0x0A)
        if (v.isNeg)
            if (v.isInt)
                sMsg ~= "neg whole number."c;
            else
                sMsg ~= "neg floating-point number."c;
        else
            if (v.isInt)
                sMsg ~= "pos whole number."c;
            else
                sMsg ~= "pos floating-point number."c;
    else 
        sMsg ~= "string."c;  
     
    return sMsg;       
}
C:\dmd>dmd vararr1.d variantstruct.d innumrange.d
C:\dmd\bin\..\..\dm\bin\link.exe vararr1+variantstruct+innumrange,,,user32+kernel32/noi;

C:\dmd>vararr1
An toVariantArray() example

vprms[0]="-123" (That's stored as a neg whole number.)
vprms[1]="456" (That's stored as a string.)
vprms[2]="3.52" (That's stored as a pos floating-point number.)
vprms[3]="abc" (That's stored as a string.)
vprms[4]="205" (That's stored as a pos whole number.)
vprms[5]="x" (That's stored as a string.)
vprms[6]="Zzz..." (That's stored as a string.)
vprms[7]="-4.5678e+21" (That's stored as a neg floating-point number.)
vprms[8]="-nan" (That's stored as a neg floating-point number.)
vprms[9]="inf" (That's stored as a pos floating-point number.)
vprms[10]="255" (That's stored as a pos whole number.)
vprms[11]="1e-129" (That's stored as a pos floating-point number.)
vprms[12]="     1) "Tabbed"" (That's stored as a string.)
vprms[13]="Zzz...gnite!" (That's stored as a string.)

C:\dmd>

28.May.05 In v0.43 I've corrected a problem found in both the opCat(in char[]) and the opCat(in Variant) functions.

30.May.05 In v0.5 Expanded the toVariantArray(...) function to accept a single dimension array as an input, which in turn transfers the array's entries into the newly created variant single dimension array. Corrected a minor bug in both the opEquals(in variant) and opEquals(in char[]) functions, plus added more of the std.string functions to now support a variant as a parameter / return value, and added more to the unittest for these functions.

// VarArr2.d
// Updated to VariantStruct.d v0.69 / D v1.007
// To Compile: dmd vararr2.d variantstruct.d innumrange.d
private import std.stdio;  // for writefln()
private import variantstruct;

int main()
{
    variant  vx[]  = toVariantArray("123"c, "456"c, "789"c);
    real[]   rArr  = [70_000.0L, 12_000.0L, 13_455.0L, 18_123.0L, 21_099.0L];
    long[]   lArr  = [-3_997L, 98_675L, 231_756L, long.max, long.min];
    ulong[]  ulArr = [3_997UL, 98_675UL, 231_756UL, ulong.max, ulong.min];
    int[]    iArr  = [-3_997, 98_675, 231_756, int.max, int.min];
    uint[]   uiArr = [3_997U, 98_675U, 231_756U, uint.max, uint.min];
    char[][] sa    = ["ABC"c, "CDE"c];
    variant vs[]   = toVariantArray("one."c, "two."c, "three."c);
    variant va[];

    va.length = 0;
    va = toVariantArray(sa[], vs[], "123.45", rArr[], lArr[], vx[], ulArr[], 
                        56_999UL, "Zzz...", iArr[], uiArr[], "last item.");

    writefln("va[] now has %d items, below is a list of the items.", va.length);
    writefln();
    for (int i = 0; i < va.length; i++)
        writefln("va[%02d]=\"%s\"", i, va[i].toCharA);

    return 0;
}
C:\dmd>dmd vararr2.d variantstruct.d innumrange.d
C:\dmd\bin\..\..\dm\bin\link.exe vararr2+variantstruct+innumrange,,,user32+kernel32/noi;

C:\dmd>vararr2
va[] now has 37 items, below is a list of the items.

va[00]="ABC"
va[01]="CDE"
va[02]="one."
va[03]="two."
va[04]="three."
va[05]="123.45"
va[06]="70000"
va[07]="12000"
va[08]="13455"
va[09]="18123"
va[10]="21099"
va[11]="-3997"
va[12]="98675"
va[13]="231756"
va[14]="9223372036854775808"
va[15]="-9223372036854775808"
va[16]="123"
va[17]="456"
va[18]="789"
va[19]="3997"
va[20]="98675"
va[21]="231756"
va[22]="1.84467e+19"
va[23]="0"
va[24]="56999"
va[25]="Zzz..."
va[26]="-3997"
va[27]="98675"
va[28]="231756"
va[29]="2147483647"
va[30]="-2147483648"
va[31]="3997"
va[32]="98675"
va[33]="231756"
va[34]="4294967295"
va[35]="0"
va[36]="last item."

C:\dmd>

04.Jun.05 In v0.52 I've added the isVariantNumeric(in variant, in bool = false) and isVariantNumeric(in char[], in bool = false) functions, both of which call upon the isNumeric() functions in my new isnumeric.d module. These functions are designed to check a variant that's a string, or a regular string for a proper D numerical datatype literal; like byte, ubyte, short, ushort, int, uint, long, ulong, float, double, real, ifloat, idouble, ireal, cfloat, cdouble, and creal values.

14.Jun.05 In v0.55 I've incorporated using the isNumeric() function to check if a string is a numerical string, also added the ability have a default value used in the numeric conversion functions (like: v.toInt(), v.toFloat(), and etc.) in case the string is not numeric, which otherwise would cause an error. Plus I rewrote the private convertArray() functions into one template convertArrayT(in T) function...which helps a little to make this file smaller and cleaner (my very first template ever).

// DefaultNum.d
// Uses VariantStruct v0.67 / D v1.007
// To Compile: dmd defaultnum.d variantstruct.d innumrange.d
private import std.stdio;  // for writefln()
private import variantstruct;

int main()
{
    variant v;

    v = "ABC"c;
    writefln("(original value)    v=\"%s\"", v.toCharA);
    writefln("(with a default)    v.toInt(1234)=%d", v.toInt(1234));

    writef("(without a default) v.toInt()=");
    writefln("v.toInt()=%d", v.toInt);

    return 0;
}
C:\dmd>dmd defaultnum.d variantstruct.d innumrange.d
C:\dmd\bin\..\..\dm\bin\link.exe defaultnum+variantstruct+innumrange,,,user32+kernel32/noi;

C:\dmd>defaultnum
(original value)    v="ABC"
(with a default)    v.toInt(1234)=1234
(without a default) v.toInt()=Error: variantstruct.d(436)  Not a valid numerical string.

C:\dmd>

  • Variant : A general use variant datatype - VariantStruct.d

    NOTE: The purpose of this variant struct, is to allow for storing of most D's basic datatypes for use a parameters passed into more generic type functions, which includes: byte, ubyte, int, uint, short, ushort, long, ulong, float, double, real, char[], wchar[], and dchar[] plus char is stored as an int; excluding bit, ifloat, idouble, ireal, cfloat, cdouble, and creal. The core of the struct has one union that maps a 'char[]', a 'real' and a 'ulong' datatypes together into the same memory space, mainly using the 'char[]' (string) for all character arrays data that's converted with the toUTF8() function, and with the 'real' used to pull in all the numeric datatypes. The 'ulong' is used in special cases to extract 'ulong' values out correctly and other issues. I've also added "Operator Overloading" for variants which is workable, but it's far from perfect and still needs to be better refined and tested.

    -= Public variant struct functions =-
    • void s( in char[] ) - 100% Done.
    • void sw( in wchar[] ) - 100% Done.
    • void sd( in dchar[] ) - 100% Done.
    • void s( in real ) - 100% Done.
    • void s( in variant ) - 100% Done.
    • char toChar() - 100% Done.
    • wchar toWChar() - 100% Done.
    • dchar toDChar() - 100% Done.
    • byte toByte() - 100% Done.
    • byte toByte( in byte ) - 100% Done.
    • ubyte toUByte() - 100% Done.
    • ubyte toUByte( in ubyte ) - 100% Done.
    • short toShort() - 100% Done.
    • short toShort( in short ) - 100% Done.
    • ushort toUShort() - 100% Done.
    • ushort toUShort( in ushort ) - 100% Done.
    • int toInt() - 100% Done.
    • int toInt( in int ) - 100% Done.
    • uint toUInt() - 100% Done.
    • uint toUInt( in uint ) - 100% Done.
    • long toLong() - 100% Done.
    • long toLong( in long ) - 100% Done.
    • ulong toULong() - 100% Done.
    • ulong toULong( in ulong ) - 100% Done.
    • float toFloat() - 100% Done.
    • float toFloat( in float ) - 100% Done.
    • double toDouble() - 100% Done.
    • double toDouble( in double ) - 100% Done.
    • real toReal() - 100% Done.
    • real toReal( in real ) - 100% Done.
    • char[] toCharA() - 100% Done.
    • wchar[] toWCharA() - 100% Done.
    • dchar[] toDCharA() - 100% Done.
    • byte type() - 100% Done.
    • bool isNeg() - 100% Done.
    • bool isInt() - 100% Done.

    -= Private variant struct functions =-
    • bool isInt( in char[] ) - 100% Done.

    -= Operator overloading functions (other datatypes to a variant) =-
    • variant opAdd( in char[] ) - 100% Done.
    • variant opAdd( in real ) - 100% Done.
    • variant opAdd_r( in real ) - 100% Done.
    • variant opSub( in char[] ) - 100% Done.
    • variant opSub( in real ) - 100% Done.
    • variant opSub_r( in real ) - 100% Done.
    • variant opMul( in char[] ) - 100% Done.
    • variant opMul( in real ) - 100% Done.
    • variant opMul_r( in real ) - 100% Done.
    • variant opDiv( in char[] ) - 100% Done.
    • variant opDiv( in real ) - 100% Done.
    • variant opMod( in char[] ) - 100% Done.
    • variant opMod( in real ) - 100% Done.
    • variant opMod_r( in real ) - 100% Done.
    • variant opAnd( in ulong ) - 100% Done.
    • variant opAnd_r( in ulong ) - 100% Done.
    • variant opOr( in ulong ) - 100% Done.
    • variant opOr_r( in ulong ) - 100% Done.
    • variant opXor( in ulong ) - 100% Done.
    • variant opXor_r( in ulong ) - 100% Done.
    • variant opShl( in int ) - 100% Done.
    • variant opShl_r( in int ) - 100% Done.
    • variant opShr( in int ) - 100% Done.
    • variant opShr_r( in int ) - 100% Done.
    • int opEquals( in real r ) - 100% Done.
    • variant opAddAssign( in char[] ) - 100% Done.
    • variant opAddAssign( in real ) - 100% Done.
    • variant opSubAssign( in char[] ) - 100% Done.
    • variant opSubAssign( in real ) - 100% Done.
    • variant opMulAssign( in char[] ) - 100% Done.
    • variant opMulAssign( in real ) - 100% Done.
    • variant opDivAssign( in char[] ) - 100% Done.
    • variant opDivAssign( in real ) - 100% Done.
    • variant opModAssign( in char[] ) - 100% Done.
    • variant opModAssign( in real ) - 100% Done.
    • variant opAndAssign( in ulong ) - 100% Done.
    • variant opOrAssign( in ulong ) - 100% Done.
    • variant opXorAssign( in ulong ) - 100% Done.
    • variant opShlAssign( in int ) - 100% Done.
    • variant opShrAssign( in int ) - 100% Done.
    • variant opCat( in char[] ) - 100% Done.
    • variant opCat_r( in char[] ) - 100% Done.
    • variant opCatAssign( in char[] ) - 100% Done.

    -= Operator overloading functions (variant to a variant) =-
    • variant opAdd( in variant ) - 100% Done.
    • variant opSub( in variant ) - 100% Done.
    • variant opMul( in variant ) - 100% Done.
    • variant opDiv( in variant ) - 100% Done.
    • variant opMod( in variant ) - 100% Done.
    • variant opAnd( in variant ) - 100% Done.
    • variant opOr( in variant ) - 100% Done.
    • variant opAddAssign( in variant ) - 100% Done.
    • variant opSubAssign( in variant ) - 100% Done.
    • variant opMulAssign( in variant ) - 100% Done.
    • variant opDivAssign( in variant ) - 100% Done.
    • variant opModAssign( in variant ) - 100% Done.
    • variant opAndAssign( in variant ) - 100% Done.
    • variant opOrAssign( in variant ) - 100% Done.
    • variant opXorAssign( in variant ) - 100% Done.
    • variant opShlAssign( in variant ) - 100% Done.
    • variant opShrAssign( in variant ) - 100% Done.
    • int opEquals( in variant ) - 100% Done.
    • variant opPostInc() - 100% Done.
    • variant opPostDec() - 100% Done.
    • variant opCat( in variant ) - 100% Done.
    • variant opCatAssign( in variant ) - 100% Done.
    • variant opSlice() - 100% Done.
    • variant opSlice( int, int ) - 100% Done.

    -= std.math variant wrapper functions =-
    • variant pow( in variant, in variant ) - 100% Done.
    • variant pow( in variant, in uint ) - 100% Done.
    • variant pow( in real, in variant ) - 100% Done.
    • variant cos( in variant ) - 100% Done.
    • variant cos( in real ) - 100% Done.
    • variant sin( in variant ) - 100% Done.
    • variant sin( in real ) - 100% Done.
    • variant fabs( in variant ) - 100% Done.
    • variant fabs( in real ) - 100% Done.
    • variant rint( in variant ) - 100% Done.
    • variant rint( in real ) - 100% Done.
    • variant rndtol( in variant ) - 100% Done.
    • variant rndtol( in long ) - 100% Done.
    • variant sqrt( in variant ) - 100% Done.
    • variant sqrt( in real ) - 100% Done.
    • variant acos( in variant ) - 100% Done.
    • variant acos( in real ) - 100% Done.
    • variant asin( in variant ) - 100% Done.
    • variant asin( in real ) - 100% Done.
    • variant atan( in variant ) - 100% Done.
    • variant atan( in real ) - 100% Done.
    • variant atan2( in variant, in variant ) - 100% Done.
    • variant atan2( in real, in variant ) - 100% Done.
    • variant atan2( in variant, in real ) - 100% Done.
    • variant atan2( in real, in real ) - 100% Done.
    • variant cosh( in variant ) - 100% Done.
    • variant cosh( in real ) - 100% Done.
    • variant sinh( in variant ) - 100% Done.
    • variant sinh( in real ) - 100% Done.
    • variant tanh( in variant ) - 100% Done.
    • variant tanh( in real ) - 100% Done.
    • variant exp( in variant ) - 100% Done.
    • variant exp( in real ) - 100% Done.
    • variant exp2( in variant ) - 100% Done.
    • variant exp2( in real ) - 100% Done.
    • variant expm1( in variant ) - 100% Done.
    • variant expm1( in real ) - 100% Done.
    • variant ilogb( in variant ) - 100% Done.
    • variant ilogb( in real ) - 100% Done.
    • variant log( in variant ) - 100% Done.
    • variant log( in real ) - 100% Done.
    • variant log10( in variant ) - 100% Done.
    • variant log10( in real ) - 100% Done.
    • variant log1p( in variant ) - 100% Done.
    • variant log1p( in real ) - 100% Done.
    • variant log2( in variant ) - 100% Done.
    • variant log2( in real ) - 100% Done.
    • variant opOr( in variant ) - 100% Done.
    • variant logb( in variant ) - 100% Done.
    • variant logb( in real ) - 100% Done.
    • variant cbrt( in variant ) - 100% Done.
    • variant cbrt( in real ) - 100% Done.
    • variant erf( in variant ) - 100% Done.
    • variant erf( in real ) - 100% Done.
    • variant erfc( in variant ) - 100% Done.
    • variant erfc( in real ) - 100% Done.
    • variant ceil( in variant ) - 100% Done.
    • variant ceil( in real ) - 100% Done.
    • variant floor( in variant ) - 100% Done.
    • variant floor( in real ) - 100% Done.
    • int isnan( in variant ) - 100% Done.
    • int isfinite( in variant ) - 100% Done.
    • int isnormal( in variant ) - 100% Done.
    • int issubnormal( in variant ) - 100% Done.
    • int isinf( in variant ) - 100% Done.
    • int signbit( in variant ) - 100% Done.
    • variant copysign( in variant, in variant ) - 100% Done.
    • variant copysign( in real, in variant ) - 100% Done.
    • variant copysign( in variant, in real ) - 100% Done.
    • variant copysign( in real, in real ) - 100% Done.
    • variant tan( in variant ) - 100% Done.
    • variant tan( in real ) - 100% Done.
    • variant hypot( in variant, in variant ) - 100% Done.
    • variant hypot( in real, in variant ) - 100% Done.
    • variant hypot( in variant, in real ) - 100% Done.
    • variant hypot( in real, in real ) - 100% Done.
    • variant frexp( in variant, out int ) - 100% Done.
    • variant frexp( in real, out int ) - 100% Done.
    • variant lgamma( in real ) - Needs unittests.
    • variant lgamma( in variant ) - Needs uittests.
    • variant nearbyint( in real ) - Needs uittests.
    • variant nearbyint( in variant ) - Needs uittests.
    • variant lrint( in real ) - Needs unittests.
    • variant lrint( in variant ) - Needs uittests.
    • variant round( in real ) - Needs uittests.
    • variant round( in variant ) - Needs uittests.
    • variant lround( in real ) - Needs unittests.
    • variant lround( in variant ) - Needs uittests.
    • variant trunc( in real ) - Needs uittests.
    • variant trunc( in variant ) - Needs uittests.
    • variant remainder( in variant, in variant ) - Needs unittests.
    • variant remainder( in real, in variant ) - Needs uittests.
    • variant remainder( in variant, in real ) - Needs uittests.
    • variant remainder( in real, in real ) - Needs uittests.
    • variant fdim( in variant, in variant ) - Needs unittests.
    • variant fdim( in real, in variant ) - Needs uittests.
    • variant fdim( in variant, in real ) - Needs uittests.
    • variant fdim( in real, in real ) - Needs uittests.
    • variant fmax( in variant, in variant ) - Needs unittests.
    • variant fmax( in real, in variant ) - Needs uittests.
    • variant fmax( in variant, in real ) - Needs uittests.
    • variant fmax( in real, in real ) - Needs uittests.
    • variant fmin( in variant, in variant ) - Needs unittests.
    • variant fmin( in real, in variant ) - Needs uittests.
    • variant fmin( in variant, in real ) - Needs uittests.
    • variant fmin( in real, in real ) - Needs uittests.
    • variant remquo( in variant, in variant, out variant ) - Needs unittests.
    • variant remquo( in variant, in variant, out int ) - Needs unittests.
    • variant remquo( in variant, in real, out int ) - Needs unittests.
    • variant remquo( in real, in variant, out variant ) - Needs uittests.
    • variant remquo( in real, in real, out variant ) - Needs uittests.
    • variant remquo( in real, in real, out int ) - Needs uittests.
    • variant remquo( in variant, in real, out variant ) - Needs uittests.
    • variant remquo( in real, in variant, out int ) - Needs uittests.
    • variant fma( in variant, in variant, in variant ) - Needs unittests.
    • variant fma( in variant, in variant, in real ) - Needs unittests.
    • variant fma( in variant, in real, in real ) - Needs unittests.
    • variant fma( in real, in variant, in variant ) - Needs uittests.
    • variant fma( in real, in real, in variant ) - Needs uittests.
    • variant fma( in real, in real, in real ) - Needs uittests.
    • variant fma( in variant, in real, in variant ) - Needs uittests.
    • variant fma( in real, in variant, in real ) - Needs uittests.
    • variant feqrel( in variant, in variant ) - Needs unittests.
    • variant feqrel( in real, in variant ) - Needs uittests.
    • variant feqrel( in variant, in real ) - Needs uittests.
    • variant feqrel( in real, in real ) - Needs uittests.
    • bool isPosZero( in variant ) - Needs uittests.
    • bool isNegZero( in variant ) - Needs uittests.

    -= new math variant functions =-
    • variant gcd( in ulong, in ulong ) - 100% Done.
    • variant gcd( in variant, in ulong ) - 100% Done.
    • variant gcd( in ulong, in variant ) - 100% Done.
    • variant gcd( in variant, in variant ) - 100% Done.
    • bool isprime( in variant ) - 100% Done.
    • bool isprimepower( in variant ) - 100% Done.
    • variant factorial( in ulong ) - 100% Done.
    • variant factorial( in variant ) - 100% Done.
    • variant fib( in ulong ) - 100% Done.
    • variant fib( in variant ) - 100% Done.
    • variant gcf( in ulong, in ulong ) - 100% Done.
    • variant gcf( in variant, in ulong ) - 100% Done.
    • variant gcf( in ulong, in variant ) - 100% Done.
    • variant gcf( in variant, in variant ) - 100% Done.
    • variant lcm( in ulong, in ulong ) - 100% Done.
    • variant lcm( in variant, in ulong ) - 100% Done.
    • variant lcm( in ulong, in variant ) - 100% Done.
    • variant lcm( in variant, in variant ) - 100% Done.

    -= std.string templated wrapper functions =-
    -= (char, wchar, dchar, char[], void[], wchar[], dchar[], and variant) =-
    • int cmp( in T1, in T2 ) - 100% Done.
    • int icmp( in T1, in T2 ) - 100% Done.
    • int find( in T1, in T2 ) - 100% Done.
    • int ifind( in T1, in T2 ) - 100% Done.
    • int rfind( in T1, in T2 ) - 100% Done.
    • int irfind( in T1, in T2 ) - 100% Done.

    -= std.string variant wrapper functions =-
    • variant tolower( in variant ) - 100% Done.
    • variant tolower( in char[] ) - 100% Done.
    • variant toupper( in variant ) - 100% Done.
    • variant toupper( in char[] ) - 100% Done.
    • variant capitalize( in variant ) - 100% Done.
    • variant capitalize( in char[] ) - 100% Done.
    • variant capwords( in variant ) - 100% Done.
    • variant capwords( in char[] ) - 100% Done.
    • variant repeat( in variant, in variant ) - 100% Done.
    • variant repeat( in variant, in size_t ) - 100% Done.
    • variant repeat( in char[], in size_t ) - 100% Done.
    • variant repeat( in char[], in variant ) - 100% Done.
    • variant stripl( in variant ) - 100% Done.
    • variant stripl( in char[] ) - 100% Done.
    • variant stripr( in variant ) - 100% Done.
    • variant stripr( in char[] ) - 100% Done.
    • variant strip( in variant ) - 100% Done.
    • variant strip( in char[] ) - 100% Done.
    • variant ljustify( in variant, in variant ) - 100% Done.
    • variant ljustify( in variant, in int ) - 100% Done.
    • variant ljustify( in char[], in variant ) - 100% Done.
    • variant ljustify( in char[], int ) - 100% Done.
    • variant rjustify( in variant, in variant ) - 100% Done.
    • variant rjustify( in variant, in int ) - 100% Done.
    • variant rjustify( in char[], in variant ) - 100% Done.
    • variant rjustify( in char[], int ) - 100% Done.
    • variant center( in variant, in variant ) - 100% Done.
    • variant center( in variant, in int ) - 100% Done.
    • variant center( in char[], in variant ) - 100% Done.
    • variant center( in char[], int ) - 100% Done.
    • variant zfill( in variant, in variant ) - 100% Done.
    • variant zfill( in variant, in int ) - 100% Done.
    • variant zfill( in char[], in variant ) - 100% Done.
    • variant zfill( in char[], int ) - 100% Done.
    • variant replace( in variant, in variant, in variant ) - 100% Done.
    • variant replace( in variant, in variant, in char[] ) - 100% Done.
    • variant replace( in variant, in char[], in variant ) - 100% Done.
    • variant replace( in variant, in char[], in char[] ) - 100% Done.
    • variant replace( in char[], in variant, in variant ) - 100% Done.
    • variant replace( in char[], in variant, in char[] ) - 100% Done.
    • variant replace( in char[], in char[], in variant ) - 100% Done.
    • size_t count( in variant, in variant ) - 100% Done.
    • size_t count( in char[], in variant ) - 100% Done.
    • size_t count( in variant, in char[] ) - 100% Done.
    • variant insert( in variant, in variant, in variant ) - 100% Done.
    • variant insert( in variant, in variant, in char[] ) - 100% Done.
    • variant insert( in variant, in int, in variant ) - 100% Done.
    • variant insert( in variant, in int, in char[] ) - 100% Done.
    • variant insert( in char[], in int, in char[] ) - 100% Done.
    • variant insert( in char[], in variant, in char[] ) - 100% Done.
    • variant insert( in char[], in int, in variant ) - 100% Done.
    • variant join( in variant[], in variant ) - 100% Done.
    • variant join( in variant[], in char[] ) - 100% Done.
    • variant join( in char[][], in variant ) - 100% Done.
    • variant join( in char[][], in char[] ) - 100% Done.
    • variant[] split( in variant ) - 100% Done.
    • variant[] split( in char[] ) - 100% Done.
    • variant[] split( in variant, in variant ) - 100% Done.
    • variant[] split( in variant, in char[] ) - 100% Done.
    • variant[] split( in char[], in variant ) - 100% Done.
    • variant[] split( in char[]s, in char[] ) - 100% Done.
    • variant[] splitlines( in variant ) - 100% Done.
    • variant[] splitlines( in char[] ) - 100% Done.
    • variant chomp( in variant ) - 100% Done.
    • variant chomp( in char[] ) - 100% Done.
    • variant chomp( in variant, in variant ) - 100% Done.
    • variant chomp( in variant, in char[] ) - 100% Done.
    • variant chomp( in char[], in variant ) - 100% Done.
    • variant chomp( in char[], in char[] ) - 100% Done.
    • variant replaceSlice( in variant, in variant, in variant ) - 100% Done.
    • variant replaceSlice( in variant, in variant, in char[] ) - 100% Done.
    • variant replaceSlice( in variant, in char[], in variant ) - 100% Done.
    • variant replaceSlice( in variant, in char[], in char[] ) - 100% Done.
    • variant replaceSlice( in char[], in variant, in variant ) - 100% Done.
    • variant replaceSlice( in char[], in variant, in char[] ) - 100% Done.
    • variant replaceSlice( in char[], in char[], in variant ) - 100% Done.
    • variant replaceSlice( in char[], in char[], in char[] ) - 100% Done.
    • variant expandtabs( in variant, in variant ) - 100% Done.
    • variant expandtabs( in variant, in int ) - 100% Done.
    • variant expandtabs( in char[], in variant ) - 100% Done.
    • variant expandtabs( in char[], in int ) - 100% Done.
    • variant maketrans( in variant, in variant ) - 100% Done.
    • variant maketrans( in variant, in char[] ) - 100% Done.
    • variant maketrans( in char[], in variant ) - 100% Done.
    • variant maketrans( in char[], in char[] ) - 100% Done.
    • variant translate( in variant, in variant, in variant ) - 100% Done.
    • variant translate( in variant, in variant, in char[] ) - 100% Done.
    • variant translate( in variant, in char[], in variant ) - 100% Done.
    • variant translate( in variant, in char[], in char[] ) - 100% Done.
    • variant translate( in char[], in variant, in variant ) - 100% Done.
    • variant translate( in char[], in variant, in char[] ) - 100% Done.
    • variant translate( in char[], in char[], in variant ) - 100% Done.
    • variant translate( in char[], in char[], in char[] ) - 100% Done.

    -= External conversion functions =-
    • char[] toString( in variant ) - 100% Done.
    • variant toVariant( in byte ) - 100% Done.
    • variant toVariant( in ubyte ) - 100% Done.
    • variant toVariant( in char[] ) - 100% Done.
    • variant toVariant( in short ) - 100% Done.
    • variant toVariant( in ushort ) - 100% Done.
    • variant toVariant( in int ) - 100% Done.
    • variant toVariant( in uint ) - 100% Done.
    • variant toVariant( in long ) - 100% Done.
    • variant toVariant( in ulong ) - 100% Done.
    • variant toVariant( in float ) - 100% Done.
    • variant toVariant( in double ) - 100% Done.
    • variant toVariant( in real ) - 100% Done.
    • variant toVariant( in char *, in bool ) - 100% Done.
    • variant[] toVariantArray( ... ) - 100% Done.
    • variant[] toVariantArray( in TypeInfo[], in va_list ) - 100% Done.

    -= Private external conversion helper functions =-
    • variant[] convertArrayT( in T[] ) - 100% Done.
    • variant[] convertArrayW( in wchar[][] ) - 100% Done.
    • variant[] convertArrayD( in dchar[][] ) - 100% Done.

    -= Public functions =-
    • bool isNumeric( in variant, in bool = false ) - 100% Done.

    Note: The isNumeric() function in isNumeric.d (which validates whether a string is a valid numeric string or not)...is no longer needed as a separate file, because it's now included in std.string as of D v0.130, thanks Walter!

Discover Mars Magik