I am using Rhapsody OMString and my code need to typecast OMstring to char *
reader.readStream((unsigned char *)MachineType,machineTypeDataSize); // MachineType is OMString
Is it possible to typecast OMString to char *
If you look at the documentation ( http://pic.dhe.ibm.com/infocenter/rhaphlp/v7r6/index.jsp?topic=%2Fcom.ibm.rhp.frameworks.doc%2Ftopics%2Frhp_r_fw_omstring_class.html ), you can always use operator [] to build yourself a small utility function that converts an OMString object to an std::string and then use std::string's c_str() method to get at it's const char* content:
#include <string>
#include <omstring.h>
std::string omStringToStdString( const OMString& in )
{
std::string result( in.GetLength(), '\0' );
for ( std::string::size_type i = 0; i < result.length(); ++i )
{
result[ i ] = in[ i ];
}
return result;
}
EDIT: Apparently OMString has an operator* that returns a const char* pointer to the string's content: ( http://pic.dhe.ibm.com/infocenter/rhaphlp/v7r6/index.jsp?topic=%2Fcom.ibm.rhp.frameworks.doc%2Ftopics%2Frhp_r_fw_operator_customize.html ), so you don't actually need the conversion function I posted above.
EDIT #2: Ok, on re-reading the OP's question, I'm now getting the impression that he doesn't want to read from an OMString but to write to one. In that case, the OMString::GetBuffer() method gives you direct access to the object's internal buffer. Be careful though, you can easily end up corrupting the OMString object's internal state if you write more characters than the buffer has space for (and possibly if you insert \0 chars before the actual end of the buffer).