Proper method of appending QChar to QByteArray
Posted: Sat Dec 12 2020 6:03 pm
I'm having brain spasm porting (someone else's) debugger code to CopperSpice so I can have a debugger that lets me look at a CopperSpice QString. Porting by hand, not using the tool, because I don't want to be riding in that car if it goes off the rails. Well, that and this needs some restructuring, at least in the header files, so far.
There is a piece of code in this thing which works just fine in Qt land but CopperSpice land no likey.
I probably need to take a long break then come back and rewrite this entire section, I also probably need to dig into the INI and see what it is really storing. If it isn't much, convert to JSON/XML.
But for now...
What is the approved hack/method of stuffing a QChar into a byte array in correct byte order?
There is a piece of code in this thing which works just fine in Qt land but CopperSpice land no likey.
Code: Select all
/**
* @brief Fills in a entry from a ini-file string.
*/
int Ini::decodeValueString( IniEntry *entry, QString specialKind, QByteArray dataArray )
{
int rc = 0;
if ( specialKind == "ByteArray" )
{
QByteArray byteArray;
char hexStr[3];
enum {IDLE, ESC, FIRST_HEX, SECOND_HEX} state = IDLE;
QString valueStr = dataArray;
for ( int i = 0; i < valueStr.length(); i++ )
{
QChar c = valueStr[i];
switch ( state )
{
case IDLE:
{
if ( c == '\\' )
{
state = ESC;
}
else
{
byteArray += c;
}
};
break;
But for now...
What is the approved hack/method of stuffing a QChar into a byte array in correct byte order?