Witam.
Zmagam się od jakiegoś czasu z problemem zrobienia czegoś takiego:
[code] unsigned char* tmpChar = (unsigned char*)msg.getOutputBuffer();
std::string dane((char*)&tmpChar[2]);
packetsMap[(OTSYS_TIME()-startTime)] = dane;
[/code]
Chodzi o to żeby tmpChar zmienić do stringa, lecz nie ważne co dam otrzymuje stringa o długości 3 lub 1...
Obecnie mam funkcje
[code] char* tmpChar = (char*)msg.getOutputBuffer();
std::string dane;
for(int32_t i = 0; i < messageLength; i++)
dane += tmpChar[i];
packetsMap[(OTSYS_TIME()-startTime)] = dane;
[/code]
Ale ona chyba nie jest odpowiednio wydajna...
getOutputBuffer() wygląda tak
[code]
char* getOutputBuffer() {return (char*)&m_buffer[m_outputBufferStart];}
[/code]
Co mam zrobić aby w jak najbardziej optymalny sposób zamienić to na string?
Pozdrawiam.