|
|
|||
File indexing completed on 2025-12-16 10:29:58
0001 /// \file RFieldUtils.hxx 0002 /// \ingroup NTuple 0003 /// \author Jonas Hahnfeld <jonas.hahnfeld@cern.ch> 0004 /// \date 2024-11-19 0005 0006 #ifndef ROOT_RFieldUtils 0007 #define ROOT_RFieldUtils 0008 0009 #include <string> 0010 #include <string_view> 0011 #include <typeinfo> 0012 #include <tuple> 0013 #include <vector> 0014 0015 class TClass; 0016 0017 namespace ROOT { 0018 0019 class RFieldBase; 0020 class RNTupleDescriptor; 0021 0022 namespace Internal { 0023 0024 /// Applies RNTuple specific type name normalization rules (see specs) that help the string parsing in 0025 /// RFieldBase::Create(). The normalization of templated types does not include full normalization of the 0026 /// template arguments (hence "Prefix"). 0027 /// Furthermore, if the type is a C-style array, rules are applied to the base type and the C style array 0028 /// is then mapped to an std::array. 0029 std::string GetCanonicalTypePrefix(const std::string &typeName); 0030 0031 /// Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix. 0032 std::string GetRenormalizedTypeName(const std::string &metaNormalizedName); 0033 0034 /// Given a type info ask ROOT meta to demangle it, then renormalize the resulting type name for RNTuple. Useful to 0035 /// ensure that e.g. fundamental types are normalized to the type used by RNTuple (e.g. int -> std::int32_t). 0036 std::string GetRenormalizedTypeName(const std::type_info &ti); 0037 0038 /// Applies all RNTuple type normalization rules except typedef resolution. 0039 std::string GetNormalizedUnresolvedTypeName(const std::string &origName); 0040 0041 /// Appends 'll' or 'ull' to the where necessary and strips the suffix if not needed. 0042 std::string GetNormalizedInteger(const std::string &intTemplateArg); 0043 std::string GetNormalizedInteger(long long val); 0044 std::string GetNormalizedInteger(unsigned long long val); 0045 long long ParseIntTypeToken(const std::string &intToken); 0046 unsigned long long ParseUIntTypeToken(const std::string &uintToken); 0047 0048 /// Possible settings for the "rntuple.streamerMode" class attribute in the dictionary. 0049 enum class ERNTupleSerializationMode { 0050 kForceNativeMode, 0051 kForceStreamerMode, 0052 kUnset 0053 }; 0054 0055 ERNTupleSerializationMode GetRNTupleSerializationMode(TClass *cl); 0056 0057 /// Used in RFieldBase::Create() in order to get the comma-separated list of template types 0058 /// E.g., gets {"int", "std::variant<double,int>"} from "int,std::variant<double,int>". 0059 /// If maxArgs > 0, stop tokenizing after the given number of tokens are found. Used to strip 0060 /// STL allocator and other optional arguments. 0061 /// TODO(jblomer): Try to merge with TClassEdit::TSplitType 0062 std::vector<std::string> TokenizeTypeList(std::string_view templateType, std::size_t maxArgs = 0); 0063 0064 /// Helper to check if a given actualTypeName matches the expectedTypeName, either from RField<T>::TypeName() or 0065 /// GetRenormalizedTypeName(). Usually, this check can be done with a simple string comparison. The failure case, 0066 /// however, needs to additionally check for ROOT-specific special cases. 0067 bool IsMatchingFieldType(std::string_view actualTypeName, std::string_view expectedTypeName, const std::type_info &ti); 0068 0069 /// Prints the hierarchy of types with their field names and field IDs for the given in-memory field and the 0070 /// on-disk hierarchy, matching the fields on-disk ID with the information of the descriptor. 0071 /// Useful information when the in-memory field cannot be matched to the the on-disk information. 0072 std::string GetTypeTraceReport(const RFieldBase &field, const RNTupleDescriptor &desc); 0073 0074 } // namespace Internal 0075 } // namespace ROOT 0076 0077 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|