[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-12 Thread Andy Ling
> Actualy (maybe I wrong) but it leads to the same result in that case
> that using `reinterpret_cast`
> 
> my problem about doing that is I don't know if it's safe...
> I mean, should I not get some mess with some char code
> (UTF8)?
> 

You could create a new unsigned string type

typedef std::basic_string  ustring;

ustring s = sqlite3_column_text(..);

Maybe that would do what you want and preserve any
odd UTF8 characters.

Regards

Andy Ling
---
This email has been scanned for email related threats and delivered safely by 
Mimecast.
For more information please visit http://www.mimecast.com
---



[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-12 Thread Nicolas Jäger
thx Andy,
I'll keep that one close. When my program will be ready to perform some
tests with UTF8 encoding, I'll try your solution.

regards,
Nicolas


Le Wed, 12 Aug 2015 16:02:54 +,
Andy Ling  a ?crit :

> > Actualy (maybe I wrong) but it leads to the same result in that case
> > that using `reinterpret_cast`
> > 
> > my problem about doing that is I don't know if it's safe...
> > I mean, should I not get some mess with some char code
> > (UTF8)?
> > 
> 
> You could create a new unsigned string type
> 
> typedef std::basic_string  ustring;
> 
> ustring s = sqlite3_column_text(..);
> 
> Maybe that would do what you want and preserve any
> odd UTF8 characters.
> 
> Regards
> 
> Andy Ling
> ---
> This email has been scanned for email related threats and delivered
> safely by Mimecast. For more information please visit
> http://www.mimecast.com
> ---
> 
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-12 Thread Nicolas Jäger
Hi,
Actualy (maybe I wrong) but it leads to the same result in that case
that using `reinterpret_cast`

my problem about doing that is I don't know if it's safe...
I mean, should I not get some mess with some char code
(UTF8)?

I was expecting some people already did a such cast in the
past and just tell me quickly what strategy I should  use.

Anyway, don't waste your time on that, I stay with my solution and I'll
see in the future if I get some issue.

thank you John.

regards,
Nicolas


Le Wed, 12 Aug 2015 08:50:26 -0500,
John McKown  a ?crit :

> On Tue, Aug 11, 2015 at 9:06 PM, Nicolas J?ger
>  wrote:
> 
> > Hi,
> > I have some basic problem, but I didn't found the solution so far...
> > maybe some people are using C++ and already deal with that problem :
> >
> > conversion from ?const unsigned char*? to non-scalar type
> > ?std::string
> >
> > I got the `const unsigned char*` from `sqlite3_column_text()` and I
> > want to pass the result as a `std::string` parameter to a C++
> > function
> >
> > regards,
> > Nicolas J.
> >
> 
> ?Hi! Idiot me again after a bit of sleep. Have you considered casting
> away the "unsigned"-ness?
> 
> const char *someVar = (const char *) sqlite3_column_text(...)?
> 
> ?;
> std::string some?String(someVar);
> 



[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-12 Thread John McKown
On Tue, Aug 11, 2015 at 9:06 PM, Nicolas J?ger 
wrote:

> Hi,
> I have some basic problem, but I didn't found the solution so far...
> maybe some people are using C++ and already deal with that problem :
>
> conversion from ?const unsigned char*? to non-scalar type ?std::string
>
> I got the `const unsigned char*` from `sqlite3_column_text()` and I
> want to pass the result as a `std::string` parameter to a C++ function
>
> regards,
> Nicolas J.
>

?Hi! Idiot me again after a bit of sleep. Have you considered casting away
the "unsigned"-ness?

const char *someVar = (const char *) sqlite3_column_text(...)?

?;
std::string some?String(someVar);

-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown


[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-11 Thread Nicolas Jäger
I may found a solution by using 'reinterpret_cast'. Not
sure that is a good solution...

nicolas


[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-11 Thread Nicolas Jäger
hi John,

actualy what you suggest it's the common solution. You
missed the fact that here, there is an unsigned... 

in

> http://stackoverflow.com/questions/1195675/convert-a-char-to-stdstring

you can read :

"It has taken me so long to realize that this constructor absolute
refuses to match with (unsigned char*) as an argument !"

anyway, thx for the try.

nicolas.


[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-11 Thread Nicolas Jäger
Hi,
I have some basic problem, but I didn't found the solution so far...
maybe some people are using C++ and already deal with that problem :

conversion from ?const unsigned char*? to non-scalar type ?std::string

I got the `const unsigned char*` from `sqlite3_column_text()` and I
want to pass the result as a `std::string` parameter to a C++ function

regards,
Nicolas J.


[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-11 Thread Nicolas Jäger
Hi,
I have some basic problem, but I didn't found the solution so far...
maybe some people are using C++ and already deal with that problem :

conversion from ?const unsigned char*? to non-scalar type ?std::string

I got the `const unsigned char*` from `sqlite3_column_text()` and I
want to pass the result as a `std::string` parameter to a C++ function

regards,
Nicolas J.


[sqlite] I don't know how to cast ‘const unsigned char*’ to a 'const std::string'

2015-08-11 Thread John McKown
Perhaps this will help:
http://stackoverflow.com/questions/1195675/convert-a-char-to-stdstring

IIRC, something ike

std::string return_string(pointer_to_const_unsigned_char_var);

return_string is an std::string initialized to the value pointed to my the
variable in the initializer. If you want the return_string to have more
space, say to append to it, then you can do:

std::string return_string(pointer_to_const_unsigned_char_var,) //
replace  with the size of the area to be allocated.

ref: http://en.cppreference.com/w/cpp/string/basic_string/basic_string for
the above, in the examples section.

FWIW, I am not a C++ programmer. I have read up a bit on it, but found the
above with a simple Google search.
https://www.google.com/webhp?ie=UTF-8#q=C%2B%2B+std%3A%3Astring+cast



On Tue, Aug 11, 2015 at 9:07 PM, Nicolas J?ger 
wrote:

> Hi,
> I have some basic problem, but I didn't found the solution so far...
> maybe some people are using C++ and already deal with that problem :
>
> conversion from ?const unsigned char*? to non-scalar type ?std::string
>
> I got the `const unsigned char*` from `sqlite3_column_text()` and I
> want to pass the result as a `std::string` parameter to a C++ function
>
> regards,
> Nicolas J.
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>



-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown