22#include <system_error>
23#include <unordered_map>
34 {
"Double_t",
"double"},
35 {
"string",
"std::string"},
37 {
"byte",
"std::byte"},
39 {
"int8_t",
"std::int8_t"},
40 {
"UChar_t",
"unsigned char"},
41 {
"uint8_t",
"std::uint8_t"},
44 {
"int16_t",
"std::int16_t"},
45 {
"UShort_t",
"unsigned short"},
46 {
"uint16_t",
"std::uint16_t"},
49 {
"int32_t",
"std::int32_t"},
50 {
"UInt_t",
"unsigned int"},
51 {
"unsigned",
"unsigned int"},
52 {
"uint32_t",
"std::uint32_t"},
57 {
"ULong_t",
"unsigned long"},
59 {
"Long64_t",
"long long"},
60 {
"int64_t",
"std::int64_t"},
61 {
"ULong64_t",
"unsigned long long"},
62 {
"uint64_t",
"std::uint64_t"}};
67 return typeName.rfind(
"std::", 0) != 0 && typeName.rfind(
"ROOT::VecOps::RVec<", 0) != 0;
75std::tuple<std::string, std::vector<std::size_t>>
ParseArrayType(
const std::string &typeName)
77 std::vector<std::size_t>
sizeVec;
80 std::string prefix{typeName};
81 while (prefix.back() ==
']') {
84 if (
posLBrace == std::string_view::npos) {
91 const std::size_t
size =
100 return std::make_tuple(prefix,
sizeVec);
109 typeName =
"std::array<" + typeName +
"," + std::to_string(*i) +
">";
120 if (std::isdigit(arg[0]) || arg[0] ==
'-') {
134 if (base.rfind(
"const ", 0) == 0 || base.rfind(
"volatile const ", 0) == 0 ||
135 base.find(
" const", base.length() - 6) != std::string::npos ||
136 base.find(
" const volatile", base.length() - 15) != std::string::npos) {
139 if (base.rfind(
"volatile ", 0) == 0 || base.rfind(
"const volatile ", 0) == 0 ||
140 base.find(
" volatile", base.length() - 9) != std::string::npos) {
146using AnglePos = std::pair<std::string::size_type, std::string::size_type>;
149 std::vector<AnglePos>
result;
153 if (
posOpen == std::string::npos) {
160 while (
posClose < typeName.size()) {
164 }
else if (
c ==
'>') {
177 if (
posClose < typeName.size() - 1) {
191 auto dst = typeName.begin();
192 auto end = typeName.end();
203 typeName.erase(
dst, end);
209 auto dst = typeName.begin();
210 auto end = typeName.end();
215 if (next != end && *next ==
' ') {
221 typeName.erase(
dst, end);
227 if (typeName.rfind(
"class ", 0) == 0) {
228 typeName.erase(0, 6);
229 }
else if (typeName.rfind(
"struct ", 0) == 0) {
230 typeName.erase(0, 7);
231 }
else if (typeName.rfind(
"enum ", 0) == 0) {
232 typeName.erase(0, 5);
239 if (typeName.rfind(
"const ", 0) == 0)
240 typeName.erase(0, 6);
241 if (typeName.rfind(
"volatile ", 0) == 0)
242 typeName.erase(0, 9);
243 if (typeName.find(
" volatile", typeName.length() - 9) != std::string::npos)
244 typeName.erase(typeName.length() - 9);
245 if (typeName.find(
" const", typeName.length() - 6) != std::string::npos)
246 typeName.erase(typeName.length() - 6);
252 if (typeName ==
"signed char") {
254 }
else if (typeName ==
"unsigned char") {
256 }
else if (typeName ==
"short" || typeName ==
"short int" || typeName ==
"signed short" ||
257 typeName ==
"signed short int") {
259 }
else if (typeName ==
"unsigned short" || typeName ==
"unsigned short int") {
261 }
else if (typeName ==
"int" || typeName ==
"signed" || typeName ==
"signed int") {
263 }
else if (typeName ==
"unsigned" || typeName ==
"unsigned int") {
265 }
else if (typeName ==
"long" || typeName ==
"long int" || typeName ==
"signed long" ||
266 typeName ==
"signed long int") {
268 }
else if (typeName ==
"unsigned long" || typeName ==
"unsigned long int") {
270 }
else if (typeName ==
"long long" || typeName ==
"long long int" || typeName ==
"signed long long" ||
271 typeName ==
"signed long long int") {
273 }
else if (typeName ==
"unsigned long long" || typeName ==
"unsigned long long int") {
278 if (typeName ==
"__int64") {
279 typeName =
"std::int64_t";
280 }
else if (typeName ==
"unsigned __int64") {
281 typeName =
"std::uint64_t";
318 static const std::vector<std::pair<const std::type_info &, std::string>>
gCandidates =
319 {{
typeid(std::vector<char>),
"std::vector<"},
320 {
typeid(std::array<char, 1>),
"std::array<"},
321 {
typeid(std::variant<char>),
"std::variant<"},
322 {
typeid(std::pair<char, char>),
"std::pair<"},
323 {
typeid(std::tuple<char>),
"std::tuple<"},
324 {
typeid(std::bitset<1>),
"std::bitset<"},
325 {
typeid(std::unique_ptr<char>),
"std::unique_ptr<"},
326 {
typeid(std::optional<char>),
"std::optional<"},
327 {
typeid(std::set<char>),
"std::set<"},
328 {
typeid(std::unordered_set<char>),
"std::unordered_set<"},
329 {
typeid(std::multiset<char>),
"std::multiset<"},
330 {
typeid(std::unordered_multiset<char>),
"std::unordered_multiset<"},
331 {
typeid(std::map<char, char>),
"std::map<"},
332 {
typeid(std::unordered_map<char, char>),
"std::unordered_map<"},
333 {
typeid(std::multimap<char, char>),
"std::multimap<"},
334 {
typeid(std::unordered_multimap<char, char>),
"std::unordered_multimap<"},
335 {
typeid(std::atomic<char>),
"std::atomic<"}};
338 std::vector<std::pair<std::string, std::string>>
result;
341 if (dm.rfind(prefix, 0) == std::string::npos)
342 result.push_back(std::make_pair(dm.substr(0, dm.find(
'<') + 1), prefix));
498 }
else if (
canonicalType.substr(0, 14) ==
"unordered_map<") {
500 }
else if (
canonicalType.substr(0, 19) ==
"unordered_multimap<") {
502 }
else if (
canonicalType.substr(0, 19) ==
"unordered_multiset<") {
504 }
else if (
canonicalType.substr(0, 14) ==
"unordered_set<") {
605 return std::to_string(val);
610 if (val > std::numeric_limits<std::int64_t>::max())
611 return std::to_string(val) +
"u";
612 return std::to_string(val);
668 if (!
am || !
am->HasKey(
"rntuple.streamerMode"))
669 return ERNTupleSerializationMode::kUnset;
671 std::string
value =
am->GetPropertyAsString(
"rntuple.streamerMode");
673 if (
value ==
"TRUE") {
674 return ERNTupleSerializationMode::kForceStreamerMode;
675 }
else if (
value ==
"FALSE") {
676 return ERNTupleSerializationMode::kForceNativeMode;
679 <<
am->GetPropertyAsString(
"rntuple.streamerMode");
680 return ERNTupleSerializationMode::kUnset;
686 std::vector<std::string>
result;
714 const std::type_info &
ti)
#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.
static std::string TypeName()
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 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::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)