1111#include < ROOT/RError.hxx>
1212
1313#include < deque>
14- #include < memory >
14+ #include < functional >
1515#include < iostream>
16+ #include < memory>
1617#include < string_view>
1718#include < typeinfo>
1819
@@ -24,12 +25,15 @@ namespace ROOT {
2425namespace Experimental {
2526
2627class RFile ;
27- struct RFileKeyInfo ;
2828
2929namespace Internal {
3030
3131ROOT::RLogChannel &RFileLog ();
3232
33+ // / Returns an **owning** pointer to the object referenced by `key`. The caller must delete this pointer.
34+ // / This method is meant to only be used by the pythonization.
35+ [[nodiscard]] void *RFile_GetObjectFromKey (RFile &file, const RKeyInfo &key);
36+
3337} // namespace Internal
3438
3539namespace Detail {
@@ -59,6 +63,7 @@ Querying this information can be done via RFile::ListKeys(). Reading an object's
5963doesn't deserialize the full object, so it's a relatively lightweight operation.
6064*/
6165class RKeyInfo final {
66+ friend class ROOT ::Experimental::RFile;
6267 friend class ROOT ::Experimental::RFileKeyIterable;
6368
6469public:
@@ -216,6 +221,8 @@ auto myObj = file->Get<TH1D>("h");
216221~~~
217222*/
218223class RFile final {
224+ friend void *Internal::RFile_GetObjectFromKey (RFile &file, const RKeyInfo &key);
225+
219226 // / Flags used in PutInternal()
220227 enum PutFlags {
221228 // / When encountering an object at the specified path, overwrite it with the new one instead of erroring out.
@@ -357,6 +364,9 @@ public:
357364 return RFileKeyIterable (fFile .get (), basePath, flags);
358365 }
359366
367+ // / Retrieves information about the key of object at `path`, if one exists.
368+ std::optional<RKeyInfo> GetKeyInfo (std::string_view path) const ;
369+
360370 // / Prints the internal structure of this RFile to the given stream.
361371 void Print (std::ostream &out = std::cout) const ;
362372};
0 commit comments