Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleUtils.cxx
Go to the documentation of this file.
1/// \file RNTupleUtils.cxx
2/// \author Jakob Blomer <jblomer@cern.ch> & Max Orok <maxwellorok@gmail.com>
3/// \date 2020-07-14
4/// \author Vincenzo Eduardo Padulano, CERN
5/// \date 2024-11-08
6
7/*************************************************************************
8 * Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
15#include <ROOT/RLogger.hxx>
16#include <ROOT/RNTupleUtils.hxx>
17
18#include <TError.h>
19
20#include <algorithm>
21#include <array>
22#include <cctype>
23#include <string>
24#include <utility>
25
27{
28 static RLogChannel sLog("ROOT.NTuple");
29 return sLog;
30}
31
33{
34 using codeAndRepr = std::pair<const char *, const char *>;
35 constexpr static std::array<codeAndRepr, 4> forbiddenChars{codeAndRepr{"\u002E", "."}, codeAndRepr{"\u002F", "/"},
36 codeAndRepr{"\u0020", "space"},
37 codeAndRepr{"\u005C", "\\"}};
38
39 for (auto &&[code, repr] : forbiddenChars) {
40 if (name.find(code) != std::string_view::npos)
41 return R__FAIL(std::string(where) + " name '" + std::string(name) + "' cannot contain character '" + repr +
42 "'.");
43 }
44
45 if (std::count_if(name.begin(), name.end(), [](unsigned char c) { return std::iscntrl(c); }))
46 return R__FAIL(std::string(where) + " name '" + std::string(name) +
47 "' cannot contain character classified as control character. These notably include newline, tab, "
48 "carriage return.");
49
51}
52
53const std::string *ROOT::Internal::RStringPool::Intern(std::string_view str)
54{
55 auto itr = std::lower_bound(fStrings.begin(), fStrings.end(), str, Less);
56
57 if (itr == fStrings.end() || **itr != str) {
59 itr = fStrings.insert(itr, std::make_unique<std::string>(str));
60 }
61
62 return itr->get();
63}
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:322
#define c(i)
Definition RSha256.hxx:101
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:130
char name[80]
Definition TGX11.cxx:142
const std::string * Intern(std::string_view str)
Searches for str in the pool.
static bool Less(const std::unique_ptr< std::string > &a, const std::string_view &b)
std::vector< std::unique_ptr< std::string > > fStrings
A log configuration for a channel, e.g.
Definition RLogger.hxx:97
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Definition RError.hxx:222
RResult< void > EnsureValidNameForRNTuple(std::string_view name, std::string_view where)
Check whether a given string is a valid name according to the RNTuple specification.
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.