API access to DateTime values
Ruslan Zasukhin
sunshine at public.kherson.ua
Wed Mar 8 10:36:59 CST 2006
On 3/8/06 4:01 AM, "Matthew Jew" <mjew at icnc.com> wrote:
>> I_Value_Ptr pv = fld->get_Value();
>> I_ValueDateTime_Ptr pdtv = fbl_dynamic_cast<I_ValueDateTime>
>> ( pv );
>>
>>
>
> I used the code above, but got the following compile-time error:
>
> error: invalid conversion from 'const fbl::I_Value*' to 'fbl::I_Value*'
>
> I changed the code to read:
>
> Const_I_Value_Ptr pv = fld->get_Value();
> Const_I_ValueDateTime_Ptr pdtv =
> fbl_dynamic_cast<I_ValueDateTime>( pv );
>
> and then I get the following compile-time error:
>
> error: cannot dynamic_cast '(+ p)->fbl::smart_ptr<T>::get [with T =
> const fbl::I_Value]()' (of type 'const struct fbl::I_Value*') to type
> 'struct fbl::I_ValueDateTime*' (conversion casts away constness)
>
> Do you have a solution for this?
Hi Mathew,
Okay I see.
** 1) ** exists 2 versions of get_Value() in I_Field interface:
virtual Const_I_Value_Ptr get_Value( void ) const throw() = 0;
virtual I_Value_Ptr get_Value( EValueAccess inValue ) throw()
= 0;
As you see first version returns you const value,
second returns you value which you can modify.
So if you want READ values you do:
Const_I_Value_ptr pv = fld->get_Value()
If you want do WRITE then you should do
I_Value_ptr pv = fld->get_Value(forAdd)
I_Value_ptr pv = fld->get_Value(forUpdate)
** 2) **
Please note that you can use native C++ dynamic_cast<>() only to native
pointers!
Valentina C++ SDK use heavily smart ptrs. For smart ptrs we have own
Simple template functions fbl_dynamic_cast<>()
** 3) **
Your code requires simple correction. Just should be added const
Const_I_Value_Ptr pv = fld->get_Value();
Const_I_ValueDateTime_Ptr pdtv = fbl_dynamic_cast<const
I_ValueDateTime>( pv );
Actually this is the same as in native dynamic_cast:
const my* p = dynamic_cast<const my*>( pp )
--
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