Fix BinaryReader::readMultibyteTerminatedStringXX methods
This commit is contained in:
parent
d6361e1cfd
commit
209a59106e
|
@ -178,10 +178,14 @@ string BinaryReader::readMultibyteTerminatedStringBE(uint16 termination)
|
||||||
ss.exceptions(ios_base::badbit | ios_base::failbit);
|
ss.exceptions(ios_base::badbit | ios_base::failbit);
|
||||||
char *delimChars = m_buffer, *buff = m_buffer + 2;
|
char *delimChars = m_buffer, *buff = m_buffer + 2;
|
||||||
ConversionUtilities::BE::getBytes(termination, delimChars);
|
ConversionUtilities::BE::getBytes(termination, delimChars);
|
||||||
do {
|
m_stream->get(buff[0]);
|
||||||
|
m_stream->get(buff[1]);
|
||||||
|
while (!((buff[0] == delimChars[0]) && (buff[1] == delimChars[1]))) {
|
||||||
|
ss.put(buff[0]);
|
||||||
|
ss.put(buff[1]);
|
||||||
m_stream->get(buff[0]);
|
m_stream->get(buff[0]);
|
||||||
m_stream->get(buff[1]);
|
m_stream->get(buff[1]);
|
||||||
} while (!((buff[0] == delimChars[0]) && (buff[1] == delimChars[1])));
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,10 +202,14 @@ string BinaryReader::readMultibyteTerminatedStringLE(uint16 termination)
|
||||||
ss.exceptions(ios_base::badbit | ios_base::failbit);
|
ss.exceptions(ios_base::badbit | ios_base::failbit);
|
||||||
char *delimChars = m_buffer, *buff = m_buffer + 2;
|
char *delimChars = m_buffer, *buff = m_buffer + 2;
|
||||||
ConversionUtilities::LE::getBytes(termination, delimChars);
|
ConversionUtilities::LE::getBytes(termination, delimChars);
|
||||||
do {
|
m_stream->get(buff[0]);
|
||||||
|
m_stream->get(buff[1]);
|
||||||
|
while (!((buff[0] == delimChars[0]) && (buff[1] == delimChars[1]))) {
|
||||||
|
ss.put(buff[0]);
|
||||||
|
ss.put(buff[1]);
|
||||||
m_stream->get(buff[0]);
|
m_stream->get(buff[0]);
|
||||||
m_stream->get(buff[1]);
|
m_stream->get(buff[1]);
|
||||||
} while (!((buff[0] == delimChars[0]) && (buff[1] == delimChars[1])));
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
bool readBool();
|
bool readBool();
|
||||||
std::string readLengthPrefixedString();
|
std::string readLengthPrefixedString();
|
||||||
std::string readString(std::size_t length);
|
std::string readString(std::size_t length);
|
||||||
|
// TODO: refactor methods for reading terminated strings in v5
|
||||||
std::string readTerminatedString(byte termination = 0);
|
std::string readTerminatedString(byte termination = 0);
|
||||||
std::string readTerminatedString(size_t maxBytesToRead, byte termination = 0);
|
std::string readTerminatedString(size_t maxBytesToRead, byte termination = 0);
|
||||||
std::string readMultibyteTerminatedStringBE(uint16 termination = 0);
|
std::string readMultibyteTerminatedStringBE(uint16 termination = 0);
|
||||||
|
|
Loading…
Reference in New Issue