@@ -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
0 commit comments