Dan... Yes the varint!
--- On Mon, 5/4/09, Dan wrote:
> From: Dan
> Subject: Re: [sqlite] OT: how best to convert sqlite3_int64 to and from
> string in a cross platform fashion?
> To: "General Discussion of SQLite Database"
On May 4, 2009, at 10:14 PM, Ken wrote:
>
> You could just pass the sqlite3_int64 value. It is portable between
> systems. Search through the sqlite3 code and there are routines that
> do the conversions from the sqlite3_int64 to a native int64 type.
> They basically perform bit shifting
Why would you want to convert something to a string that is already cross
platform compatible?
If you need to store the value in a different DB, then converting it locally to
a native int64 and then into whatever DB construct would be way more efficient
than hauling around string conversions.
Ken,
this is true, except that I might migrate the system to some other
database someday that wants to use something else as PK other than an
int or int64 (MS SQL is optimized for guid's not int), so passing around
the id's as strings keeps all the middle and front end code neutral :)
Sam
You could just pass the sqlite3_int64 value. It is portable between systems.
Search through the sqlite3 code and there are routines that do the conversions
from the sqlite3_int64 to a native int64 type. They basically perform bit
shifting and will be much faster than the string conversions.
Sorry, i forgot: my INT64 is the same as sqlite_int64
Martin Engelschalk wrote:
> Hi,
>
> This is what i do, works for me. No OSX hovever, sorry.
>
> #ifdef _WIN32
> #define INT64 __int64
> #else
> #define INT64 long long
> #endif
>
> // From INT64 to String
>
> INT64 iOther;
> char mBuffer[64];
Hi,
This is what i do, works for me. No OSX hovever, sorry.
#ifdef _WIN32
#define INT64 __int64
#else
#define INT64 long long
#endif
// From INT64 to String
INT64 iOther;
char mBuffer[64];
#ifdef _WIN32
sprintf(mBuffer, "%I64d", iOther);
#else
sprintf(mBuffer, "%lld", iOther);
I am current developing a system only on Windows, but I do plan to port it
to OSX someday. I am passing ID's as strings to keep maximum flexibility
between databases and the existing system. So how do I convert a
sqlite3_int64 to a string and a string to a sqlite3_int64 in a cross
platform
8 matches
Mail list logo