23#include <system_error>
24#include <unordered_map>
35 {
"Double_t",
"double"},
36 {
"string",
"std::string"},
38 {
"byte",
"std::byte"},
40 {
"int8_t",
"std::int8_t"},
41 {
"UChar_t",
"unsigned char"},
42 {
"uint8_t",
"std::uint8_t"},
45 {
"int16_t",
"std::int16_t"},
46 {
"UShort_t",
"unsigned short"},
47 {
"uint16_t",
"std::uint16_t"},
50 {
"int32_t",
"std::int32_t"},
51 {
"UInt_t",
"unsigned int"},
52 {
"unsigned",
"unsigned int"},
53 {
"uint32_t",
"std::uint32_t"},
58 {
"ULong_t",
"unsigned long"},
60 {
"Long64_t",
"long long"},
61 {
"int64_t",
"std::int64_t"},
62 {
"ULong64_t",
"unsigned long long"},
63 {
"uint64_t",
"std::uint64_t"}};
68 return typeName.rfind(
"std::", 0) != 0 && typeName.rfind(
"ROOT::VecOps::RVec<", 0) != 0;
76std::tuple<std::string, std::vector<std::size_t>>
ParseArrayType(
const std::string &typeName)
78 std::vector<std::size_t>
sizeVec;
81 std::string prefix{typeName};
82 while (prefix.back() ==
']') {
85 if (
posLBrace == std::string_view::npos) {
92 const std::size_t
size =
101 return std::make_tuple(prefix,
sizeVec);
110 typeName =
"std::array<" + typeName +
"," + std::to_string(*i) +
">";
121 if (std::isdigit(arg[0]) || arg[0] ==
'-') {
135 if (base.rfind(
"const ", 0) == 0 || base.rfind(
"volatile const ", 0) == 0 ||
136 base.find(
" const", base.length() - 6) != std::string::npos ||
137 base.find(
" const volatile", base.length() - 15) != std::string::npos) {
140 if (base.rfind(
"volatile ", 0) == 0 || base.rfind(
"const volatile ", 0) == 0 ||
141 base.find(
" volatile", base.length() - 9) != std::string::npos) {
147using AnglePos = std::pair<std::string::size_type, std::string::size_type>;
150 std::vector<AnglePos>
result;
154 if (
posOpen == std::string::npos) {
161 while (
posClose < typeName.size()) {
165 }
else if (
c ==
'>') {
178 if (
posClose < typeName.size() - 1) {
192 auto dst = typeName.begin();
193 auto end = typeName.end();
204 typeName.erase(
dst, end);
210 auto dst = typeName.begin();
211 auto end = typeName.end();
216 if (next != end && *next ==
' ') {
222 typeName.erase(
dst, end);
228 if (typeName.rfind(
"class ", 0) == 0) {
229 typeName.erase(0, 6);
230 }
else if (typeName.rfind(
"struct ", 0) == 0) {
231 typeName.erase(0, 7);
232 }
else if (typeName.rfind(
"enum ", 0) == 0) {
233 typeName.erase(0, 5);
240 if (typeName.rfind(
"const ", 0) == 0)
241 typeName.erase(0, 6);
242 if (typeName.rfind(
"volatile ", 0) == 0)
243 typeName.erase(0, 9);
244 if (typeName.find(
" volatile", typeName.length() - 9) != std::string::npos)
245 typeName.erase(typeName.length() - 9);
246 if (typeName.find(
" const", typeName.length() - 6) != std::string::npos)
247 typeName.erase(typeName.length() - 6);
253 if (typeName ==
"signed char") {
255 }
else if (typeName ==
"unsigned char") {
257 }
else if (typeName ==
"short" || typeName ==
"short int" || typeName ==
"signed short" ||
258 typeName ==
"signed short int") {
260 }
else if (typeName ==
"unsigned short" || typeName ==
"unsigned short int") {
262 }
else if (typeName ==
"int" || typeName ==
"signed" || typeName ==
"signed int") {
264 }
else if (typeName ==
"unsigned" || typeName ==
"unsigned int") {
266 }
else if (typeName ==
"long" || typeName ==
"long int" || typeName ==
"signed long" ||
267 typeName ==
"signed long int") {
269 }
else if (typeName ==
"unsigned long" || typeName ==
"unsigned long int") {
271 }
else if (typeName ==
"long long" || typeName ==
"long long int" || typeName ==
"signed long long" ||
272 typeName ==
"signed long long int") {
274 }
else if (typeName ==
"unsigned long long" || typeName ==
"unsigned long long int") {
279 if (typeName ==
"__int64") {
280 typeName =
"std::int64_t";
281 }
else if (typeName ==
"unsigned __int64") {
282 typeName =
"std::uint64_t";
319 static const std::vector<std::pair<const std::type_info &, std::string>>
gCandidates =
320 {{
typeid(std::vector<char>),
"std::vector<"},
321 {
typeid(std::array<char, 1>),
"std::array<"},
322 {
typeid(std::variant<char>),
"std::variant<"},
323 {
typeid(std::pair<char, char>),
"std::pair<"},
324 {
typeid(std::tuple<char>),
"std::tuple<"},
325 {
typeid(std::bitset<1>),
"std::bitset<"},
326 {
typeid(std::unique_ptr<char>),
"std::unique_ptr<"},
327 {
typeid(std::optional<char>),
"std::optional<"},
328 {
typeid(std::set<char>),
"std::set<"},
329 {
typeid(std::unordered_set<char>),
"std::unordered_set<"},
330 {
typeid(std::multiset<char>),
"std::multiset<"},
331 {
typeid(std::unordered_multiset<char>),
"std::unordered_multiset<"},
332 {
typeid(std::map<char, char>),
"std::map<"},
333 {
typeid(std::unordered_map<char, char>),
"std::unordered_map<"},
334 {
typeid(std::multimap<char, char>),
"std::multimap<"},
335 {
typeid(std::unordered_multimap<char, char>),
"std::unordered_multimap<"},
336 {
typeid(std::atomic<char>),
"std::atomic<"}};
339 std::vector<std::pair<std::string, std::string>>
result;
342 if (dm.rfind(prefix, 0) == std::string::npos)
343 result.push_back(std::make_pair(dm.substr(0, dm.find(
'<') + 1), prefix));
499 }
else if (
canonicalType.substr(0, 14) ==
"unordered_map<") {
501 }
else if (
canonicalType.substr(0, 19) ==
"unordered_multimap<") {
503 }
else if (
canonicalType.substr(0, 19) ==
"unordered_multiset<") {
505 }
else if (
canonicalType.substr(0, 14) ==
"unordered_set<") {
606 return std::to_string(val);
611 if (val > std::numeric_limits<std::int64_t>::max())
612 return std::to_string(val) +
"u";
613 return std::to_string(val);
669 if (!
am || !
am->HasKey(
"rntuple.streamerMode"))
670 return ERNTupleSerializationMode::kUnset;
672 std::string
value =
am->GetPropertyAsString(
"rntuple.streamerMode");
674 if (
value ==
"TRUE") {
675 return ERNTupleSerializationMode::kForceStreamerMode;
676 }
else if (
value ==
"FALSE") {
677 return ERNTupleSerializationMode::kForceNativeMode;
680 <<
am->GetPropertyAsString(
"rntuple.streamerMode");
681 return ERNTupleSerializationMode::kUnset;
687 std::vector<std::string>
result;
715 const std::type_info &
ti)
731 std::string fFieldName;
732 std::string fTypeName;
734 std::uint32_t fTypeVersion = 0;
735 std::optional<std::uint32_t> fTypeChecksum;
744 line +=
", type version: " + std::to_string(
fieldInfo.fTypeVersion);
746 line +=
", type checksum: " + std::to_string(*
fieldInfo.fTypeChecksum);
747 line +=
"] (id: " + std::to_string(
fieldInfo.fFieldId) +
")\n";
764 std::string
report =
"In-memory field/type hierarchy:\n";
768 fieldInfo.fFieldName = (*itr)->GetFieldName();
769 fieldInfo.fTypeName = (*itr)->GetTypeName();
770 fieldInfo.fFieldId = (*itr)->GetOnDiskId();
771 fieldInfo.fTypeVersion = (*itr)->GetTypeVersion();
772 if ((*itr)->GetTraits() & RFieldBase::kTraitTypeChecksum)
773 fieldInfo.fTypeChecksum = (*itr)->GetTypeChecksum();
778 report +=
"On-disk field/type hierarchy:\n";
782 fieldInfo.fFieldName = (*itr)->GetFieldName();
783 fieldInfo.fTypeName = (*itr)->GetTypeName();
785 fieldInfo.fTypeVersion = (*itr)->GetTypeVersion();
786 fieldInfo.fTypeChecksum = (*itr)->GetTypeChecksum();
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_WARNING(...)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Base class for all ROOT issued exceptions.
A field translates read and write calls from/to underlying columns to/from tree values.
static std::string TypeName()
The on-storage metadata of an RNTuple.
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
ROOT::DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level RNTuple data fields.
const_iterator begin() const
const_iterator end() const
TClass instances represent classes, structs and namespaces in the ROOT type system.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
TDictAttributeMap * GetAttributeMap() const
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....
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
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>.
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)
std::string GetDemangledTypeName(const std::type_info &t)
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr DescriptorId_t kInvalidDescriptorId
std::string CleanType(const char *typeDesc, int mode=0, const char **tail=nullptr)
Cleanup type description, redundant blanks removed and redundant tail ignored return *tail = pointer ...
char * DemangleName(const char *mangled_name, int &errorCode)