[V4REV] Constants

Ruslan Zasukhin sunshine at public.kherson.ua
Sun Jun 19 08:59:51 CDT 2005


On 6/18/05 10:59 PM, "Robert Brenstein" <rjb at robelko.com> wrote:

>> Is it so problem to use style as Ivan suggest ?
>> It is very similar to REALBasic and Java enums
>> 
>> --
>> Best regards,
> 
> I just looked at your constants in detail and found only 5
> duplicates. Among them, 4 duplicates have the same value regardless
> of enum:
> 
> kCascade, kNoAction, kRestrict, kSetNull
> 
> Only one duplicate, kDefault, has different values
> 
>     EVOnDelete 4
>     EVOnUpdate 4
>     EVStorageType 0
>     EVColAttributeValue -1
> 
> Further, of those KDefault's only EVStorageType.kDefault seems to be
> referenced in the doc. I mean as parameters for methods. Others seem
> to be unused. At least not references. But then I found inEnumOS =
> kDefault without indication of enum group.
> 
> It seems to me that it is possible to skip the enum designation when
> typing in the constants.

Okay, I think I have got new idea how this can work.

----------------
Ivan, right now you have the single map of all constants.

Let's do next:

* you make MANY "maps", one for each Enum Type.
    technically better use not std::map
    but may just many small functions as

    EOnDelete ToEnumEVOnDelete( char* inStrValue )

* having this we are safe with conflict of constant names
    I think you see why.

* and we REMOVE them names of enums.
    
    OR more flexible way -- we support both way:

        foo( EVOnDelete.kCascade )
        foo( kCascade )

Easy and effective to implement!!!
For example Function ToEnumEVOnDelete()

EOnDelete ToEnumEVOnDelete( char* inStrValue )
{
    // if inStr starts on E -- then it has enum prefix
    if( *inStr == 'E' )
    {
        // read enum name and check that it is EVOnDelete
        // and nothing else:
    }

    // Now pointer shoud points to 'k'
    if( *inStr == 'k' )
    {
        if( inStr == "kCascade" ) return kCascade;
        if( inStr == "kSetNull" ) return kSetNull;
    }
    else
    {
        // error: unknown constant
    }   
}

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina-beta mailing list