[VSDK ] Access to cursor fields
Ruslan Zasukhin
sunshine at public.kherson.ua
Fri Jan 24 10:57:27 CST 2003
on 1/24/03 12:07 AM, Eric Forget at forgete at cafederic.com wrote:
> Yep it is possible. I don't remember the name of this method which I read 2
> years ago in Modern C++ Design (from Andrei Alexandrescu).
>
> What we want is this:
>
> short myShort = curs->GetValue("Field1");
> char *myCharPtr = curs->GetValue("Field2");
> long myLong = curs->GetValue("Field3");
>
> For this to work there is a simple trick. You cannot have overloading of
> functions which differ only by return code. However, you can return a
> temporary object instead:
Excellent idea, Eric !
I love it.
Now we need pointers on void.
Template can wrap this and get pointers from parameters
template<class T>
Find( T v1 )
{
Find( &v1 );
}
template<class T>
Find_i_i( T v1, Tv2 )
{
Find( true, &v1, &v2, true );
}
template<class T>
Find_i_e( T v1, Tv2 )
{
Find( true, &v1, &v2, false );
}
Here I - include, e - exclude.
To specify range.
Also, back to your idea, I wonder now on next 2 points
1) may be we should allow usage of GetValue() on left side also?
curs->Value("Field1") = (short) 5;
2) may be even shorter?
curs("Field1") = (short) 5;
--
Best regards,
Ruslan Zasukhin [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com
To subscribe to the Valentina mail list go to:
http://listserv.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
More information about the Valentina
mailing list