Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RFieldUtils.hxx
Go to the documentation of this file.
1/// \file RFieldUtils.hxx
2/// \ingroup NTuple
3/// \author Jonas Hahnfeld <jonas.hahnfeld@cern.ch>
4/// \date 2024-11-19
5
6#ifndef ROOT_RFieldUtils
7#define ROOT_RFieldUtils
8
9#include <string>
10#include <string_view>
11#include <typeinfo>
12#include <tuple>
13#include <vector>
14
15class TClass;
16
17namespace ROOT {
18
19class RFieldBase;
20class RNTupleDescriptor;
21
22namespace Internal {
23
24/// Applies RNTuple specific type name normalization rules (see specs) that help the string parsing in
25/// RFieldBase::Create(). The normalization of templated types does not include full normalization of the
26/// template arguments (hence "Prefix").
27/// Furthermore, if the type is a C-style array, rules are applied to the base type and the C style array
28/// is then mapped to an std::array.
29std::string GetCanonicalTypePrefix(const std::string &typeName);
30
31/// Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
32std::string GetRenormalizedTypeName(const std::string &metaNormalizedName);
33
34/// Given a type info ask ROOT meta to demangle it, then renormalize the resulting type name for RNTuple. Useful to
35/// ensure that e.g. fundamental types are normalized to the type used by RNTuple (e.g. int -> std::int32_t).
36std::string GetRenormalizedTypeName(const std::type_info &ti);
37
38/// Applies all RNTuple type normalization rules except typedef resolution.
39std::string GetNormalizedUnresolvedTypeName(const std::string &origName);
40
41/// Appends 'll' or 'ull' to the where necessary and strips the suffix if not needed.
42std::string GetNormalizedInteger(const std::string &intTemplateArg);
43std::string GetNormalizedInteger(long long val);
44std::string GetNormalizedInteger(unsigned long long val);
45long long ParseIntTypeToken(const std::string &intToken);
46unsigned long long ParseUIntTypeToken(const std::string &uintToken);
47
48/// Possible settings for the "rntuple.streamerMode" class attribute in the dictionary.
54
56
57/// Used in RFieldBase::Create() in order to get the comma-separated list of template types
58/// E.g., gets {"int", "std::variant<double,int>"} from "int,std::variant<double,int>".
59/// If maxArgs > 0, stop tokenizing after the given number of tokens are found. Used to strip
60/// STL allocator and other optional arguments.
61/// TODO(jblomer): Try to merge with TClassEdit::TSplitType
62std::vector<std::string> TokenizeTypeList(std::string_view templateType, std::size_t maxArgs = 0);
63
64/// Helper to check if a given actualTypeName matches the expectedTypeName, either from RField<T>::TypeName() or
65/// GetRenormalizedTypeName(). Usually, this check can be done with a simple string comparison. The failure case,
66/// however, needs to additionally check for ROOT-specific special cases.
67bool IsMatchingFieldType(std::string_view actualTypeName, std::string_view expectedTypeName, const std::type_info &ti);
68
69/// Prints the hierarchy of types with their field names and field IDs for the given in-memory field and the
70/// on-disk hierarchy, matching the fields on-disk ID with the information of the descriptor.
71/// Useful information when the in-memory field cannot be matched to the the on-disk information.
72std::string GetTypeTraceReport(const RFieldBase &field, const RNTupleDescriptor &desc);
73
74} // namespace Internal
75} // namespace ROOT
76
77#endif
A field translates read and write calls from/to underlying columns to/from tree values.
The on-storage metadata of an RNTuple.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
ERNTupleSerializationMode
Possible settings for the "rntuple.streamerMode" class attribute in the dictionary.
std::vector< std::string > TokenizeTypeList(std::string_view templateType, std::size_t maxArgs=0)
Used in RFieldBase::Create() in order to get the comma-separated list of template types E....
unsigned long long ParseUIntTypeToken(const std::string &uintToken)
std::string GetNormalizedInteger(const std::string &intTemplateArg)
Appends 'll' or 'ull' to the where necessary and strips the suffix if not needed.
ERNTupleSerializationMode GetRNTupleSerializationMode(TClass *cl)
std::string GetTypeTraceReport(const RFieldBase &field, const RNTupleDescriptor &desc)
Prints the hierarchy of types with their field names and field IDs for the given in-memory field and ...
std::string GetCanonicalTypePrefix(const std::string &typeName)
Applies RNTuple specific type name normalization rules (see specs) that help the string parsing in RF...
std::string GetNormalizedUnresolvedTypeName(const std::string &origName)
Applies all RNTuple type normalization rules except typedef resolution.
bool IsMatchingFieldType(const std::string &actualTypeName)
Helper to check if a given type name is the one expected of Field<T>.
Definition RField.hxx:551
std::string GetRenormalizedTypeName(const std::string &metaNormalizedName)
Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
long long ParseIntTypeToken(const std::string &intToken)