<commit_before>// @(#)root/tree:$Id$
// Author: <NAME>   12/01/96

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// A TLeaf for an 8 bit Integer data type.                              //
//////////////////////////////////////////////////////////////////////////

#include "TLeafB.h"
#include "TBranch.h"
#include "TClonesArray.h"
#include "Riostream.h"

ClassImp(TLeafB)

//______________________________________________________________________________
TLeafB::TLeafB()
: TLeaf()
, fMinimum(0)
, fMaximum(0)
, fValue(0)
, fPointer(0)
{
   // -- Default constructor.
}

//______________________________________________________________________________
TLeafB::TLeafB(TBranch *parent, const char* name, const char* type)
   : TLeaf(parent, name, type)
   , fMinimum(0)
   , fMaximum(0)
   , fValue(0)
   , fPointer(0)
{
   // -- Create a LeafB.
   fLenType = 1;
}

//______________________________________________________________________________
TLeafB::~TLeafB()
{
   // -- Destructor.
   if (ResetAddress(0, kTRUE)) {
      delete[] fValue;
      fValue = 0;
   }
   // Note: We do not own this, the user's object does.
   fPointer = 0;
}

//______________________________________________________________________________
void TLeafB::Export(TClonesArray* list, Int_t n)
{
   // -- Export element from local leaf buffer to a ClonesArray.

   for (Int_t i = 0, j = 0; i < n; i++, j += fLen) {
      memcpy(((char*) list->UncheckedAt(i)) + fOffset, &fValue[j], fLen);
   }
}

//______________________________________________________________________________
void TLeafB::FillBasket(TBuffer& b)
{
   // -- Pack leaf elements into Basket output buffer.

   Int_t len = GetLen();
   if (fPointer) {
      fValue = *fPointer;
   }
   if (IsRange()) {
      if (fValue[0] > fMaximum) {
         fMaximum = fValue[0];
      }
   }
   if (IsUnsigned()) {
      for (Int_t i = 0; i < len; i++) {
         b << (UChar_t) fValue[i];
      }
   } else {
      b.WriteFastArray(fValue, len);
   }
}

//______________________________________________________________________________
const char *TLeafB::GetTypeName() const
{
   // -- Returns name of leaf type.

   if (fIsUnsigned) {
      return "UChar_t";
   }
   return "Char_t";
}

//______________________________________________________________________________
void TLeafB::Import(TClonesArray *list, Int_t n)
{
   // -- Import element from ClonesArray into local leaf buffer.

   for (Int_t i = 0, j = 0; i < n; i++, j+= fLen) {
      memcpy(&fValue[j], ((char*) list->UncheckedAt(i)) + fOffset, fLen);
   }
}

//______________________________________________________________________________
void TLeafB::PrintValue(Int_t l) const
{
   // -- Prints leaf value.

   char* value = (char*) GetValuePointer();
   printf("%d", (Int_t) value[l]);
}

//______________________________________________________________________________
void TLeafB::ReadBasket(TBuffer &b)
{
   // -- Read leaf elements from Basket input buffer.

   if (!fLeafCount && (fNdata == 1)) {
      b >> fValue[0];
   } else {
      if (fLeafCount) {
         Int_t len = Int_t(fLeafCount->GetValue());
         if (len > fLeafCount->GetMaximum()) {
            Error("ReadBasket", "leaf: '%s' len: %d max: %d", GetName(), len, fLeafCount->GetMaximum());
            len = fLeafCount->GetMaximum();
         }
         fNdata = len * fLen;<commit_msg>Properly print an unsigned char (leaflist code b) This fixes Savannah 54641<commit_after>// @(#)root/tree:$Id$
// Author: <NAME>   12/01/96

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// A TLeaf for an 8 bit Integer data type.                              //
//////////////////////////////////////////////////////////////////////////

#include "TLeafB.h"
#include "TBranch.h"
#include "TClonesArray.h"
#include "Riostream.h"

ClassImp(TLeafB)

//______________________________________________________________________________
TLeafB::TLeafB()
: TLeaf()
, fMinimum(0)
, fMaximum(0)
, fValue(0)
, fPointer(0)
{
   // -- Default constructor.
}

//______________________________________________________________________________
TLeafB::TLeafB(TBranch *parent, const char* name, const char* type)
   : TLeaf(parent, name, type)
   , fMinimum(0)
   , fMaximum(0)
   , fValue(0)
   , fPointer(0)
{
   // -- Create a LeafB.
   fLenType = 1;
}

//______________________________________________________________________________
TLeafB::~TLeafB()
{
   // -- Destructor.
   if (ResetAddress(0, kTRUE)) {
      delete[] fValue;
      fValue = 0;
   }
   // Note: We do not own this, the user's object does.
   fPointer = 0;
}

//______________________________________________________________________________
void TLeafB::Export(TClonesArray* list, Int_t n)
{
   // -- Export element from local leaf buffer to a ClonesArray.

   for (Int_t i = 0, j = 0; i < n; i++, j += fLen) {
      memcpy(((char*) list->UncheckedAt(i)) + fOffset, &fValue[j], fLen);
   }
}

//______________________________________________________________________________
void TLeafB::FillBasket(TBuffer& b)
{
   // -- Pack leaf elements into Basket output buffer.

   Int_t len = GetLen();
   if (fPointer) {
      fValue = *fPointer;
   }
   if (IsRange()) {
      if (fValue[0] > fMaximum) {
         fMaximum = fValue[0];
      }
   }
   if (IsUnsigned()) {
      for (Int_t i = 0; i < len; i++) {
         b << (UChar_t) fValue[i];
      }
   } else {
      b.WriteFastArray(fValue, len);
   }
}

//______________________________________________________________________________
const char *TLeafB::GetTypeName() const
{
   // -- Returns name of leaf type.

   if (fIsUnsigned) {
      return "UChar_t";
   }
   return "Char_t";
}

//______________________________________________________________________________
void TLeafB::Import(TClonesArray *list, Int_t n)
{
   // -- Import element from ClonesArray into local leaf buffer.

   for (Int_t i = 0, j = 0; i < n; i++, j+= fLen) {
      memcpy(&fValue[j], ((char*) list->UncheckedAt(i)) + fOffset, fLen);
   }
}

//______________________________________________________________________________
void TLeafB::PrintValue(Int_t l) const
{
   // -- Prints leaf value.

   if (fIsUnsigned) {
      UChar_t *uvalue = (UChar_t*) GetValuePointer();
      printf("%u", uvalue[l]);
   } else {
      Char_t *value = (Char_t*) GetValuePointer();
      printf("%d", value[l]);
   }
}

//______________________________________________________________________________
void TLeafB::ReadBasket(TBuffer &b)
{
   // -- Read leaf elements from Basket input buffer.

   if (!fLeafCount && (fNdata == 1)) {
      b >> fValue[0];
   } else {
      if (fLeafCount) {
         Int_t len = Int_t(fLeafCount->GetValue());
         if (len > fLeafCount->GetMaximum()) {
            Error("ReadBasket", "leaf: '%s' len: %d max: %d", GetName(), len, fLeafCount->GetMaximum());
            len = fLeafCount->GetMaximum();
         }
         fNdata = len * fLen;
{'fraction_non_alphanumeric': 0.19387755102040816, 'fraction_numerical': 0.00946643717728055, 'mean_word_length': 2.30960130187144, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5867549', 'n_tokens_mistral': 2351, 'n_tokens_neox': 2249, 'n_words': 540}