sqlite3_column_text returns a const unsigned char*, how do I convert this to a std::string? I've tried std::string(), but I get an error.
temp_doc.uuid = std::string(sqlite3_column_text(this->stmts.read_documents, 0));
1>.\storage_manager.cpp(109) : error C2440: '<function-style-cast>' : cannot convert from 'const unsigned char *' to 'std::string' 1> No constructor could take the source type, or constructor overload resolution was ambiguous
You could try:
temp_doc.uuid = std::string(reinterpret_cast<const char*>( sqlite3_column_text(this->stmts.read_documents, 0) ));
std::string could have a constructor that takes
const unsigned char*, apparently it does not.
Why not, then? You could have a look at this somewhat related question: Why do C++ streams use char instead of unsigned char?
On the off-chance you actually want a string of unsigned characters, you could create your own type:
typedef std::basic_string <unsigned char> ustring;
You should then be able to say things like:
ustring s = sqlite3_column_text(this->stmts.read_documents, 0);