Getting string value from Text field: my 2.5 code stopped working

Ruslan Zasukhin sunshine at public.kherson.ua
Fri May 16 01:15:30 CDT 2008


On 5/16/08 2:51 AM, "Matthew Jew" <mjew at icnc.com> wrote:

Hi Matthew, 

> Another follow up:
> 
> While the above fix worked for the quoted line, there are a few other
> cases
> where a dynamic_cast was used, but in a different way:
> 
> When adding:
> 
> FBL::I_ValueDate_Ptr pvd = fbl_dynamic_cast<I_ValueDate>
> ( anArticleTable->date->get_Value(forAdd) );
> pvd->put_Date( year, month, day );
> FBL::I_ValueTime_Ptr pvt = fbl_dynamic_cast<I_ValueTime>
> ( anArticleTable->time->get_Value(forAdd) );
> pvt->put_Time( hour, minute, second, 0 );
> 
> 
> Working with date values:
> 
> Const_I_Value_Ptr pv = anArticleTable->date->get_Value();
> Const_I_ValueDateTime_Ptr pvdt = fbl_dynamic_cast<const
> I_ValueDateTime>( pv );
> 
> 
> Working with a binary field:
> 
> FBL::Const_I_ValueBinary_Ptr pvfb = fbl_dynamic_cast<const
> I_ValueBinary>( anArticleTable->fingerPrint->get_Value() );
> pvfb->get_Data( (uchar*) fpBuffer, kBytesInFingerPrint );
> [aPVArticle setFingerPrint: (FingerPrint *) fpBuffer];
> 
> Getting a field pointer:
> 
> I_FldString_Ptr pStringField = fbl_dynamic_cast<I_FldString>
> ( anArticleTable->subjectByWordsUpper );
> 
> Updating:
> 
> I_ValueDateTime_Ptr pvdt1 = fbl_dynamic_cast<I_ValueDateTime>
> ( aNewsgroupTable->lastTimeIndexed->get_Value( forUpdate ) );
> pvdt1->put_DateTime( nowDateTimeRec.year, nowDateTimeRec.month,
> nowDateTimeRec.day, nowDateTimeRec.hour, nowDateTimeRec.minute,
> nowDateTimeRec.second, 0 );
> 
> It does not seem clear to me how I would accomplish the equivalent
> functionality, especially in the "forAdd" and "forUpdte" cases.

ForAdd and forUpdate  are not related at all here.

Your line

FBL::I_ValueDate_Ptr pvd = fbl_dynamic_cast<I_ValueDate>
                            ( anArticleTable->date->get_Value(forAdd) );


In fact contains two actions:

 I_Value_Ptr pv = anArticleTable->date->get_Value(forAdd);
 FBL::I_ValueDate_Ptr pvd = fbl_dynamic_cast<I_ValueDate>( pv );

Right?

So dynamic_cast<>() is just casting of POINT from one class to another.


    Class2 pClass2 = fbl_dynamic_cast<Class2>( pClass1 );

QueryInterface is its analog with syntax

    Class2 pClass2 = QI( pClass1, Class2 );

Easy?

** Just keep in mind that QueryInterface can be used only for
interface-classes of Valentina and its sub-classes.

For example:

    FIELD expose I_Field, I_Localizable, I_Encryptable interfaces.

So if you have 

    I_Field_Ptr pField = ...

    I_Encryptable pe = QI( pField, I_Encryptable  );

SEMANTIC of this operation is:

    you have object,
    you ask: Hey object, do you expose THIS interface?
    if yes -- you get pointer on the same object but casted to that
interface.
    if no -- you get NULL like with dynamic_cast<>() of C++


-- 
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 mailing list