StringPtr to std::string

This is in Aspose.Cells C++:
This may be a dumb question, but how does one convert a StringPtr (intrusive_ptr < Aspose::Cells::System::String >) to an std::string?

I need to integrate Aspose.Cells capabilities with an existing system that extensively uses std::strings.

Thanks!

@akerfonta,

You can code it as:

StringPtr testStr= NEW String("abc");
char* valCh = testStr->charValue();
std::string(valCh);

For releasing memory, you can use:

String::deleteCharValue(valCh);

Otherwise, if you want to construct a wstring you can use:

testStr->_wstr,which returns wchar_t*.
1 Like