dbTalk Databases Forums  

Direct access to field values via pointer

sybase.public.sqlanywhere.ultralite sybase.public.sqlanywhere.ultralite


Discuss Direct access to field values via pointer in the sybase.public.sqlanywhere.ultralite forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Timothy Dean
 
Posts: n/a

Default Direct access to field values via pointer - 07-28-2004 , 12:55 PM






When I do a Get(columnID) it returns the column data in a ULValue object.
Does ULValue contain a copy of the data in the actual underlying pdb
database? Is there a way to get a pointer to the underlying data? I want
to avoid loading a copy of the underlying data to local member variables
which eats up dynamic memory. I want to be able to read the data "in place"
to minimize the use of dynamic memory. Thanks.

Timothy Dean
MobileDataforce



Reply With Quote
  #2  
Old   
Tim McClements
 
Posts: n/a

Default Re: Direct access to field values via pointer - 07-30-2004 , 08:22 AM






The ULValue object does _not_ copy any data until you call a Get method,
when it is copied to your variable/buffer. The ULValue object _does_ point
directly to the value in the underlying cursor structures. This means that
if you hang on to a ULValue object and call Next (i.e., fetch another row),
the ULValue object will subsequently return the new row's value.

- Tim

"Timothy Dean" <tim.dean (AT) mobiledataforce (DOT) com> wrote

Quote:
When I do a Get(columnID) it returns the column data in a ULValue object.
Does ULValue contain a copy of the data in the actual underlying pdb
database? Is there a way to get a pointer to the underlying data? I want
to avoid loading a copy of the underlying data to local member variables
which eats up dynamic memory. I want to be able to read the data "in
place"
to minimize the use of dynamic memory. Thanks.

Timothy Dean
MobileDataforce





Reply With Quote
  #3  
Old   
Timothy Dean
 
Posts: n/a

Default Re: Direct access to field values via pointer - 07-30-2004 , 10:10 AM



So the pResultSet->Get(columnID) will return a ULValue which points to the
value. No copy has been made at this point, right? When you call
ulvalue.GetString(buffer, bufferLength), a copy is made. Another way a copy
is made is through casting, right? If I do something like:

UInt16 nTest=ulvValue;

a copy is made in nTest. Is there any way to get at the pointer directly so
I could do something like:

char *pTest=ulvValue;

The above returns a compiler error. I wan't to be able to read the string
in place (which means I could also modify it which is probably why you don't
allow it).

Timothy Dean
MobileDataforce


"Tim McClements" <mcclemenXnospam (AT) sybase (DOT) com> wrote

Quote:
The ULValue object does _not_ copy any data until you call a Get method,
when it is copied to your variable/buffer. The ULValue object _does_ point
directly to the value in the underlying cursor structures. This means that
if you hang on to a ULValue object and call Next (i.e., fetch another
row),
the ULValue object will subsequently return the new row's value.

- Tim

"Timothy Dean" <tim.dean (AT) mobiledataforce (DOT) com> wrote in message
news:4107e88f$1 (AT) forums-1-dub (DOT) ..
When I do a Get(columnID) it returns the column data in a ULValue
object.
Does ULValue contain a copy of the data in the actual underlying pdb
database? Is there a way to get a pointer to the underlying data? I
want
to avoid loading a copy of the underlying data to local member variables
which eats up dynamic memory. I want to be able to read the data "in
place"
to minimize the use of dynamic memory. Thanks.

Timothy Dean
MobileDataforce







Reply With Quote
  #4  
Old   
Tim McClements
 
Posts: n/a

Default Re: Direct access to field values via pointer - 08-03-2004 , 09:21 AM



Everything you say is correct, including the reason why we don't just give
you the pointer. Another reason it's necessary to hide the pointer is that
the data in the cursor isn't always in the exact format you want: strings
are not null terminated, for example, and ULValue will also cast types
automatically as required (you can fetch everything as a string, say).

- Tim

"Timothy Dean" <tim.dean (AT) mobiledataforce (DOT) com> wrote

Quote:
So the pResultSet->Get(columnID) will return a ULValue which points to the
value. No copy has been made at this point, right? When you call
ulvalue.GetString(buffer, bufferLength), a copy is made. Another way a
copy
is made is through casting, right? If I do something like:

UInt16 nTest=ulvValue;

a copy is made in nTest. Is there any way to get at the pointer directly
so
I could do something like:

char *pTest=ulvValue;

The above returns a compiler error. I wan't to be able to read the string
in place (which means I could also modify it which is probably why you
don't
allow it).

Timothy Dean
MobileDataforce


"Tim McClements" <mcclemenXnospam (AT) sybase (DOT) com> wrote in message
news:410a4cae$1 (AT) forums-2-dub (DOT) ..
The ULValue object does _not_ copy any data until you call a Get method,
when it is copied to your variable/buffer. The ULValue object _does_
point
directly to the value in the underlying cursor structures. This means
that
if you hang on to a ULValue object and call Next (i.e., fetch another
row),
the ULValue object will subsequently return the new row's value.

- Tim

"Timothy Dean" <tim.dean (AT) mobiledataforce (DOT) com> wrote in message
news:4107e88f$1 (AT) forums-1-dub (DOT) ..
When I do a Get(columnID) it returns the column data in a ULValue
object.
Does ULValue contain a copy of the data in the actual underlying pdb
database? Is there a way to get a pointer to the underlying data? I
want
to avoid loading a copy of the underlying data to local member
variables
which eats up dynamic memory. I want to be able to read the data "in
place"
to minimize the use of dynamic memory. Thanks.

Timothy Dean
MobileDataforce









Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.