type conversion...

Frank Fock Frank.Fock____t-online.de
Sat Aug 18 15:42:31 CEST 2001


Hi Sean,

What about

TimeTicks tt;
tt = (unsigned long)1;
unsigned long ul = (unsigned long)tt;

All SNMP++ classes have these type of cast operators.

Best regards,
Frank


Sean wrote:

>  Im a little confused about the class design
> it does not seem to provide any easy method of
> converting result get's from one type to another..
>
>  If i request the uptime from an snmp device the
> TimeTicks class is used to hold the value. If I want
> the data from here i can only seem to be able
> to access it via get_printable() this returns nice
> data for a human to read but not very good for a program
> to digest.. Is there any easy way to get values
> from this class as a unsigned long etc..
>
> currently i would use
> vbl[0].get_printable
> accessing any private members is no good so i cant
> do
> (long)vbl[0].iv_vb_value->smival.value.uNumber
> any ideas would be appreciated.. I realy dont
> want to spoil the classes by addeing members
> if its not needed but it seems to me that
> there needs to be some common overide class
> involved where we can do something like.
>
> (long)vbl[0].get_cast()
> (int)vbl[0].get_cast()
> (char *)vbl[0].get_cast()
>
>  etc where if its actual a long value the (char *) cast
> would covert it to a string via an ltoa...
>
> --
>  Regards
>   Sean Mathews Nu Tech CTO
>
> struct SoftwareProfessional {
>    double salary;
>    long   lunches;
>    float  jobs;
>    char   unstable;
>    void   work;
>    short  tempers;
> };
> --




More information about the AGENTPP mailing list