<commit_before>// @(#)root/xml:$Id$
// Author: <NAME>  10.05.2004

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

//________________________________________________________________________
//
// Class TXMLSetup is used as storage of xml file settings
// This class is used in TXMLFile and in TXmlBuffer classes.
// Xml settings can be coded via a string in following format
//
//   "2xoo"
//    ||| \ .
//    || \ usage of name spaces.
//    | \ usage of DTD;
//     \ storage of TStreamerInfo objects in file;
//      layout of xml file (= 2 - specialized (default), = 3 - generic)
//
// For last three boolean parameters "x" means true, "o" - false
//
// Such string can be set as argument of TXMLFile constructor. In that
// case new TXMLFile with such parameters will be created.
// These settings automatically stored in xml file.

//________________________________________________________________________

#include "TXMLSetup.h"

#include "TROOT.h"
#include "TClass.h"
#include "TStreamerElement.h"

#include "Riostream.h"
#include <stdlib.h>

ClassImp(TXMLSetup);

namespace xmlio {

const char *Root = "root";
const char *Setup = "setup";
const char *ClassVersion = "version";
const char *IOVersion = "version";
const char *OnlyVersion = "Version";
const char *Ptr = "ptr";
const char *Ref = "ref";
const char *Null = "null";
const char *IdBase = "id";
const char *Size = "size";
const char *Xmlobject = "XmlObject";
const char *Xmlkey = "XmlKey";
const char *Cycle = "cycle";
const char *XmlBlock = "XmlBlock";
const char *Zip = "zip";
const char *Object = "Object";
const char *ObjClass = "class";
const char *Class = "Class";
const char *Member = "Member";
const char *Item = "Item";
const char *Name = "name";
const char *Title = "title";
const char *CreateTm = "created";
const char *ModifyTm = "modified";
const char *ObjectUUID = "uuid";
const char *Type = "type";
const char *Value = "value";
const char *v = "v";
const char *cnt = "cnt";
const char *True = "true";
const char *False = "false";
const char *SInfos = "StreamerInfos";

const char *Array = "Array";
const char *Bool = "Bool_t";
const char *Char = "Char_t";
const char *Short = "Short_t";
const char *Int = "Int_t";
const char *Long = "Long_t";
const char *Long64 = "Long64_t";
const char *Float = "Float_t";
const char *Double = "Double_t";
const char *UChar = "UChar_t";
const char *UShort = "UShort_t";
const char *UInt = "UInt_t";
const char *ULong = "ULong_t";
const char *ULong64 = "ULong64_t";
const char *String = "string";
const char *CharStar = "CharStar";
};

TString TXMLSetup::fgNameSpaceBase = "http://root.cern.ch/root/htmldoc/";

////////////////////////////////////////////////////////////////////////////////
/// return default value for XML setup

TString TXMLSetup::DefaultXmlSetup()
{
   return TString("2xoo");
}

////////////////////////////////////////////////////////////////////////////////
/// set namespace base

void TXMLSetup::SetNameSpaceBase(const char *namespacebase)
{
   fgNameSpaceBase = namespacebase;
}

////////////////////////////////////////////////////////////////////////////////
/// creates TXMLSetup object getting values from string

TXMLSetup::TXMLSetup(const char *opt)
{
   ReadSetupFromStr(opt);
}

////////////////////////////////////////////////////////////////////////////////
/// copy constructor of TXMLSetup class

TXMLSetup::TXMLSetup(const TXMLSetup &src)
   : fXmlLayout(src.fXmlLayout), fStoreStreamerInfos(src.fStoreStreamerInfos), fUseDtd(src.fUseDtd),
     fUseNamespaces(src.fUseNamespaces)
{
}

////////////////////////////////////////////////////////////////////////////////
/// assign operator

TXMLSetup &TXMLSetup::operator=(const TXMLSetup &rhs)
{
   fXmlLayout = rhs.fXmlLayout;
   fStoreStreamerInfos = rhs.fStoreStreamerInfos;
   fUseDtd = rhs.fUseDtd;
   fUseNamespaces = rhs.fUseNamespaces;
}

////////////////////////////////////////////////////////////////////////////////
/// return setup values as string

TString TXMLSetup::GetSetupAsString()
{
   char setupstr[10] = "2xxx";

   setupstr[0] = char(48 + fXmlLayout);
   setupstr[1] = fStoreStreamerInfos ? 'x' : 'o';
   setupstr[2] = fUseDtd ? 'x' : 'o';
   setupstr[3] = fUseNamespaces ? 'x' : 'o';

   return TString(setupstr);
}

////////////////////////////////////////////////////////////////////////////////
/// checks if string is valid setup

Bool_t TXMLSetup::IsValidXmlSetup(const char *setupstr)
{
   if (!setupstr || (strlen(setupstr) != 4))
      return kFALSE;
   TString str = setupstr;<commit_msg>[xml] add missing return statement<commit_after>// @(#)root/xml:$Id$
// Author: <NAME>  10.05.2004

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

//________________________________________________________________________
//
// Class TXMLSetup is used as storage of xml file settings
// This class is used in TXMLFile and in TXmlBuffer classes.
// Xml settings can be coded via a string in following format
//
//   "2xoo"
//    ||| \ .
//    || \ usage of name spaces.
//    | \ usage of DTD;
//     \ storage of TStreamerInfo objects in file;
//      layout of xml file (= 2 - specialized (default), = 3 - generic)
//
// For last three boolean parameters "x" means true, "o" - false
//
// Such string can be set as argument of TXMLFile constructor. In that
// case new TXMLFile with such parameters will be created.
// These settings automatically stored in xml file.

//________________________________________________________________________

#include "TXMLSetup.h"

#include "TROOT.h"
#include "TClass.h"
#include "TStreamerElement.h"

#include "Riostream.h"
#include <stdlib.h>

ClassImp(TXMLSetup);

namespace xmlio {

const char *Root = "root";
const char *Setup = "setup";
const char *ClassVersion = "version";
const char *IOVersion = "version";
const char *OnlyVersion = "Version";
const char *Ptr = "ptr";
const char *Ref = "ref";
const char *Null = "null";
const char *IdBase = "id";
const char *Size = "size";
const char *Xmlobject = "XmlObject";
const char *Xmlkey = "XmlKey";
const char *Cycle = "cycle";
const char *XmlBlock = "XmlBlock";
const char *Zip = "zip";
const char *Object = "Object";
const char *ObjClass = "class";
const char *Class = "Class";
const char *Member = "Member";
const char *Item = "Item";
const char *Name = "name";
const char *Title = "title";
const char *CreateTm = "created";
const char *ModifyTm = "modified";
const char *ObjectUUID = "uuid";
const char *Type = "type";
const char *Value = "value";
const char *v = "v";
const char *cnt = "cnt";
const char *True = "true";
const char *False = "false";
const char *SInfos = "StreamerInfos";

const char *Array = "Array";
const char *Bool = "Bool_t";
const char *Char = "Char_t";
const char *Short = "Short_t";
const char *Int = "Int_t";
const char *Long = "Long_t";
const char *Long64 = "Long64_t";
const char *Float = "Float_t";
const char *Double = "Double_t";
const char *UChar = "UChar_t";
const char *UShort = "UShort_t";
const char *UInt = "UInt_t";
const char *ULong = "ULong_t";
const char *ULong64 = "ULong64_t";
const char *String = "string";
const char *CharStar = "CharStar";
};

TString TXMLSetup::fgNameSpaceBase = "http://root.cern.ch/root/htmldoc/";

////////////////////////////////////////////////////////////////////////////////
/// return default value for XML setup

TString TXMLSetup::DefaultXmlSetup()
{
   return TString("2xoo");
}

////////////////////////////////////////////////////////////////////////////////
/// set namespace base

void TXMLSetup::SetNameSpaceBase(const char *namespacebase)
{
   fgNameSpaceBase = namespacebase;
}

////////////////////////////////////////////////////////////////////////////////
/// creates TXMLSetup object getting values from string

TXMLSetup::TXMLSetup(const char *opt)
{
   ReadSetupFromStr(opt);
}

////////////////////////////////////////////////////////////////////////////////
/// copy constructor of TXMLSetup class

TXMLSetup::TXMLSetup(const TXMLSetup &src)
   : fXmlLayout(src.fXmlLayout), fStoreStreamerInfos(src.fStoreStreamerInfos), fUseDtd(src.fUseDtd),
     fUseNamespaces(src.fUseNamespaces)
{
}

////////////////////////////////////////////////////////////////////////////////
/// assign operator

TXMLSetup &TXMLSetup::operator=(const TXMLSetup &rhs)
{
   fXmlLayout = rhs.fXmlLayout;
   fStoreStreamerInfos = rhs.fStoreStreamerInfos;
   fUseDtd = rhs.fUseDtd;
   fUseNamespaces = rhs.fUseNamespaces;
   return *this;
}

////////////////////////////////////////////////////////////////////////////////
/// return setup values as string

TString TXMLSetup::GetSetupAsString()
{
   char setupstr[10] = "2xxx";

   setupstr[0] = char(48 + fXmlLayout);
   setupstr[1] = fStoreStreamerInfos ? 'x' : 'o';
   setupstr[2] = fUseDtd ? 'x' : 'o';
   setupstr[3] = fUseNamespaces ? 'x' : 'o';

   return TString(setupstr);
}

////////////////////////////////////////////////////////////////////////////////
/// checks if string is valid setup

Bool_t TXMLSetup::IsValidXmlSetup(const char *setupstr)
{
   if (!setupstr || (strlen(setupstr) != 4))
      return kFALSE;
   TString str = setupstr;
{'fraction_non_alphanumeric': 0.255688622754491, 'fraction_numerical': 0.007584830339321357, 'mean_word_length': 2.2726975832789025, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 11}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4116881', 'n_tokens_mistral': 2861, 'n_tokens_neox': 2782, 'n_words': 867}