Base: apply clang format
This commit is contained in:
@@ -33,10 +33,15 @@ std::unique_ptr<XMLTranscoder> XMLTools::transcoder;
|
||||
void XMLTools::initialize()
|
||||
{
|
||||
if (!transcoder.get()) {
|
||||
XMLTransService::Codes res{};
|
||||
transcoder.reset(XMLPlatformUtils::fgTransService->makeNewTranscoderFor(XMLRecognizer::UTF_8, res, 4096, XMLPlatformUtils::fgMemoryManager));
|
||||
if (res != XMLTransService::Ok)
|
||||
XMLTransService::Codes res {};
|
||||
transcoder.reset(XMLPlatformUtils::fgTransService->makeNewTranscoderFor(
|
||||
XMLRecognizer::UTF_8,
|
||||
res,
|
||||
4096,
|
||||
XMLPlatformUtils::fgMemoryManager));
|
||||
if (res != XMLTransService::Ok) {
|
||||
throw Base::UnicodeError("Can\'t create transcoder");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,23 +51,28 @@ std::string XMLTools::toStdString(const XMLCh* const toTranscode)
|
||||
|
||||
initialize();
|
||||
|
||||
//char outBuff[128];
|
||||
// char outBuff[128];
|
||||
static XMLByte outBuff[128];
|
||||
XMLSize_t outputLength = 0;
|
||||
XMLSize_t eaten = 0;
|
||||
XMLSize_t offset = 0;
|
||||
XMLSize_t inputLength = XMLString::stringLen(toTranscode);
|
||||
|
||||
while (inputLength)
|
||||
{
|
||||
outputLength = transcoder->transcodeTo(toTranscode + offset, inputLength, outBuff, 128, eaten, XMLTranscoder::UnRep_RepChar);
|
||||
while (inputLength) {
|
||||
outputLength = transcoder->transcodeTo(toTranscode + offset,
|
||||
inputLength,
|
||||
outBuff,
|
||||
128,
|
||||
eaten,
|
||||
XMLTranscoder::UnRep_RepChar);
|
||||
str.append(reinterpret_cast<const char*>(outBuff), outputLength);
|
||||
offset += eaten;
|
||||
inputLength -= eaten;
|
||||
|
||||
// Bail out if nothing more was produced
|
||||
if (outputLength == 0)
|
||||
if (outputLength == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
@@ -71,8 +81,9 @@ std::string XMLTools::toStdString(const XMLCh* const toTranscode)
|
||||
std::basic_string<XMLCh> XMLTools::toXMLString(const char* const fromTranscode)
|
||||
{
|
||||
std::basic_string<XMLCh> str;
|
||||
if (!fromTranscode)
|
||||
if (!fromTranscode) {
|
||||
return str;
|
||||
}
|
||||
|
||||
initialize();
|
||||
|
||||
@@ -84,16 +95,21 @@ std::basic_string<XMLCh> XMLTools::toXMLString(const char* const fromTranscode)
|
||||
XMLSize_t inputLength = std::string(fromTranscode).size();
|
||||
|
||||
unsigned char* charSizes = new unsigned char[inputLength];
|
||||
while (inputLength)
|
||||
{
|
||||
outputLength = transcoder->transcodeFrom(xmlBytes + offset, inputLength, outBuff, 128, eaten, charSizes);
|
||||
while (inputLength) {
|
||||
outputLength = transcoder->transcodeFrom(xmlBytes + offset,
|
||||
inputLength,
|
||||
outBuff,
|
||||
128,
|
||||
eaten,
|
||||
charSizes);
|
||||
str.append(outBuff, outputLength);
|
||||
offset += eaten;
|
||||
inputLength -= eaten;
|
||||
|
||||
// Bail out if nothing more was produced
|
||||
if (outputLength == 0)
|
||||
if (outputLength == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] charSizes;
|
||||
|
||||
Reference in New Issue
Block a user