Skip to content

Commit 224a485

Browse files
committed
[xml] remove unreachable TBufferXML::Xml[Read|Write]Block()
The documentation of XmlWriteBlock() says "This data can be produced only by direct call of TBuffer::WriteBuf() functions.". The WriteBuf() abstract method is implemented in the TBufferText parent class and emits an Error().
1 parent b7ce888 commit 224a485

File tree

3 files changed

+0
-137
lines changed

3 files changed

+0
-137
lines changed

io/xml/inc/TBufferXML.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,8 @@ class TBufferXML final : public TBufferText, public TXMLSetup {
228228
void SetCompressionSettings(Int_t settings = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
229229
void SetXML(TXMLEngine *xml) { fXML = xml; }
230230

231-
void XmlWriteBlock(XMLNodePointer_t node);
232231
XMLNodePointer_t XmlWriteAny(const void *obj, const TClass *cl);
233232

234-
void XmlReadBlock(XMLNodePointer_t node);
235233
void *XmlReadAny(XMLNodePointer_t node, void *obj, TClass **cl);
236234

237235
TXMLStackObj *PushStack(XMLNodePointer_t current, Bool_t simple = kFALSE);

io/xml/src/TBufferXML.cxx

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -383,138 +383,6 @@ void TBufferXML::SetCompressionSettings(Int_t settings)
383383
fCompressLevel = settings;
384384
}
385385

386-
////////////////////////////////////////////////////////////////////////////////
387-
/// Write binary data block from buffer to xml.
388-
/// This data can be produced only by direct call of TBuffer::WriteBuf() functions.
389-
390-
void TBufferXML::XmlWriteBlock(XMLNodePointer_t node)
391-
{
392-
if (!node || (Length() == 0))
393-
return;
394-
395-
const char *src = Buffer();
396-
int srcSize = Length();
397-
398-
char *fZipBuffer = nullptr;
399-
400-
Int_t compressionLevel = GetCompressionLevel();
401-
ROOT::RCompressionSetting::EAlgorithm::EValues compressionAlgorithm =
402-
static_cast<ROOT::RCompressionSetting::EAlgorithm::EValues>(GetCompressionAlgorithm());
403-
404-
if ((Length() > 512) && (compressionLevel > 0)) {
405-
int zipBufferSize = Length();
406-
fZipBuffer = new char[zipBufferSize + 9];
407-
int dataSize = Length();
408-
int compressedSize = 0;
409-
R__zipMultipleAlgorithm(compressionLevel, &dataSize, Buffer(), &zipBufferSize, fZipBuffer, &compressedSize,
410-
compressionAlgorithm);
411-
if (compressedSize > 0) {
412-
src = fZipBuffer;
413-
srcSize = compressedSize;
414-
} else {
415-
delete[] fZipBuffer;
416-
fZipBuffer = nullptr;
417-
}
418-
}
419-
420-
TString res;
421-
constexpr std::size_t sbufSize = 500;
422-
char sbuf[sbufSize];
423-
int block = 0;
424-
char *tgt = sbuf;
425-
int srcCnt = 0;
426-
427-
while (srcCnt++ < srcSize) {
428-
tgt += snprintf(tgt, sbufSize - (tgt - sbuf), " %02x", (unsigned char)*src);
429-
src++;
430-
if (block++ == 100) {
431-
res += sbuf;
432-
block = 0;
433-
tgt = sbuf;
434-
}
435-
}
436-
437-
if (block > 0)
438-
res += sbuf;
439-
440-
XMLNodePointer_t blocknode = fXML->NewChild(node, nullptr, xmlio::XmlBlock, res);
441-
fXML->NewIntAttr(blocknode, xmlio::Size, Length());
442-
443-
if (fZipBuffer) {
444-
fXML->NewIntAttr(blocknode, xmlio::Zip, srcSize);
445-
delete[] fZipBuffer;
446-
}
447-
}
448-
449-
////////////////////////////////////////////////////////////////////////////////
450-
/// Read binary block of data from xml.
451-
452-
void TBufferXML::XmlReadBlock(XMLNodePointer_t blocknode)
453-
{
454-
if (!blocknode)
455-
return;
456-
457-
Int_t blockSize = fXML->GetIntAttr(blocknode, xmlio::Size);
458-
Bool_t blockCompressed = fXML->HasAttr(blocknode, xmlio::Zip);
459-
char *fUnzipBuffer = nullptr;
460-
461-
if (gDebug > 2)
462-
Info("XmlReadBlock", "Block size = %d, Length = %d, Compressed = %d", blockSize, Length(), blockCompressed);
463-
464-
if (blockSize > BufferSize())
465-
Expand(blockSize);
466-
467-
char *tgt = Buffer();
468-
Int_t readSize = blockSize;
469-
470-
TString content = fXML->GetNodeContent(blocknode);
471-
472-
if (blockCompressed) {
473-
Int_t zipSize = fXML->GetIntAttr(blocknode, xmlio::Zip);
474-
fUnzipBuffer = new char[zipSize];
475-
476-
tgt = fUnzipBuffer;
477-
readSize = zipSize;
478-
}
479-
480-
char *ptr = (char *)content.Data();
481-
482-
if (gDebug > 3)
483-
Info("XmlReadBlock", "Content %s", ptr);
484-
485-
for (int i = 0; i < readSize; i++) {
486-
while ((*ptr < 48) || ((*ptr > 57) && (*ptr < 97)) || (*ptr > 102))
487-
ptr++;
488-
489-
int b_hi = (*ptr > 57) ? *ptr - 87 : *ptr - 48;
490-
ptr++;
491-
int b_lo = (*ptr > 57) ? *ptr - 87 : *ptr - 48;
492-
ptr++;
493-
494-
*tgt = b_hi * 16 + b_lo;
495-
tgt++;
496-
497-
if (gDebug > 4)
498-
Info("XmlReadBlock", " Buf[%d] = %d", i, b_hi * 16 + b_lo);
499-
}
500-
501-
if (fUnzipBuffer) {
502-
503-
int srcsize(0), tgtsize(0), unzipRes(0);
504-
int status = R__unzip_header(&srcsize, (UChar_t *)fUnzipBuffer, &tgtsize);
505-
506-
if (status == 0)
507-
R__unzip(&readSize, (unsigned char *)fUnzipBuffer, &blockSize, (unsigned char *)Buffer(), &unzipRes);
508-
509-
if (status != 0 || unzipRes != blockSize)
510-
Error("XmlReadBlock", "Decompression error %d", unzipRes);
511-
else if (gDebug > 2)
512-
Info("XmlReadBlock", "Unzip ok");
513-
514-
delete[] fUnzipBuffer;
515-
}
516-
}
517-
518386
////////////////////////////////////////////////////////////////////////////////
519387
/// Add "ptr" attribute to node, if ptr is null or
520388
/// if ptr is pointer on object, which is already saved in buffer

io/xml/src/TKeyXML.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ void TKeyXML::StoreObject(const void *obj, const TClass *cl, Bool_t check_tobj)
190190
if (node)
191191
xml->AddChildFirst(fKeyNode, node);
192192

193-
buffer.XmlWriteBlock(fKeyNode);
194-
195193
if (cl)
196194
fClassName = cl->GetName();
197195
}
@@ -352,7 +350,6 @@ void *TKeyXML::XmlReadAny(void *obj, const TClass *expectedClass)
352350
break;
353351
xml->ShiftToNext(blocknode);
354352
}
355-
buffer.XmlReadBlock(blocknode);
356353

357354
XMLNodePointer_t objnode = xml->GetChild(fKeyNode);
358355
xml->SkipEmpty(objnode);

0 commit comments

Comments
 (0)