55std::pair<std::string_view, std::string_view>
DecomposePath(std::string_view path);
59class RFileKeyIterable;
184 RIterator
begin()
const;
185 RIterator
end()
const;
269 explicit RFile(std::unique_ptr<TFile> file);
273 [[nodiscard]]
void *
GetUntyped(std::string_view path,
274 std::variant<
const char *, std::reference_wrapper<const std::type_info>>
type)
const;
277 void PutUntyped(std::string_view path,
const std::type_info &
type,
const void *obj, std::uint32_t flags,
278 std::string_view title);
281 template <
typename T>
282 void PutInternal(std::string_view path,
const T &obj, std::uint32_t flags, std::string_view title =
"")
284 PutUntyped(path,
typeid(T), &obj, flags, title);
357 template <
typename T>
358 std::unique_ptr<T>
Get(std::string_view path)
const
361 return std::unique_ptr<T>(
static_cast<T *
>(obj));
374 template <
typename T>
375 void Put(std::string_view path,
const T &obj, std::string_view title =
"")
377 static_assert(!std::is_base_of_v<TTree, T>,
"Writing TTree with RFile is unsupported.");
392 template <
typename T>
393 void Overwrite(std::string_view path,
const T &obj, std::uint32_t overwriteFlags = 0)
395 static_assert(!std::is_base_of_v<TTree, T>,
"Writing TTree with RFile is unsupported.");
396 Overwrite(path, obj,
"", overwriteFlags);
400 template <
typename T>
401 void Overwrite(std::string_view path,
const T &obj, std::string_view title, std::uint32_t overwriteFlags = 0)
451 std::optional<RKeyInfo>
GetKeyInfo(std::string_view path)
const;
454 void Print(std::ostream &out = std::cout)
const;
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
RIterator(TIterator *iter, Pattern_t pattern, std::uint32_t flags)
std::uint16_t fRootDirNesting
std::ptrdiff_t difference_type
bool operator!=(const iterator &rh) const
bool operator==(const iterator &rh) const
std::deque< RIterStackElem > fIterStack
std::input_iterator_tag iterator_category
The iterable returned by RFile::ListKeys()
RFileKeyIterable(TFile *file, std::string_view rootDir, std::uint32_t flags)
An interface to read from, or write to, a ROOT file, as well as performing other common operations.
void Close()
Flushes the RFile if needed and closes it, disallowing any further reading or writing.
static constexpr int kMaxPathNesting
static std::unique_ptr< RFile > Open(std::string_view path, const ROpenOptions &opts=ROpenOptions())
Opens the file for reading.
void PutUntyped(std::string_view path, const std::type_info &type, const void *obj, std::uint32_t flags, std::string_view title)
Writes obj to file, without taking its ownership.
std::unique_ptr< TFile > fFile
void Overwrite(std::string_view path, const T &obj, std::uint32_t overwriteFlags=0)
Puts an object into the file, overwriting any previously-existing object at that path.
size_t Flush()
Writes all objects and the file structure to disk.
void Print(std::ostream &out=std::cout) const
Prints the internal structure of this RFile to the given stream.
TKey * GetTKey(std::string_view path) const
Given path, returns the TKey corresponding to the object at that path (assuming the path is fully spl...
RFileKeyIterable ListKeys(std::string_view basePath="", std::uint32_t flags=kListObjects|kListRecursive) const
Returns an iterable over all keys of objects and/or directories written into this RFile starting at p...
void Overwrite(std::string_view path, const T &obj, std::string_view title, std::uint32_t overwriteFlags=0)
Like Overwrite(std::string_view, const T&, bool) but allows giving a title to the object.
void * GetUntyped(std::string_view path, std::variant< const char *, std::reference_wrapper< const std::type_info > > type) const
Gets object path from the file and returns an owning pointer to it.
static std::unique_ptr< RFile > Recreate(std::string_view path, const RRecreateOptions &opts=RRecreateOptions())
Opens the file for reading/writing, overwriting it if it already exists.
std::unique_ptr< T > Get(std::string_view path) const
Retrieves an object from the file.
void Put(std::string_view path, const T &obj, std::string_view title="")
Puts object obj into the file, optionally giving it a title.
EPutFlags
Flags used in PutInternal()
@ kPutFlag_AllowOverwrite
When encountering an object at the specified path, overwrite it with the new one instead of erroring ...
@ kPutFlag_OverwriteKeepCycle
When overwriting an object, preserve the existing one and create a new cycle, rather than removing it...
std::optional< RKeyInfo > GetKeyInfo(std::string_view path) const
Retrieves information about the key of object at path, if one exists.
void PutInternal(std::string_view path, const T &obj, std::uint32_t flags, std::string_view title="")
RFile(std::unique_ptr< TFile > file)
static std::unique_ptr< RFile > Update(std::string_view path, const RUpdateOptions &opts=RUpdateOptions())
Opens the file for updating, creating a new one if it doesn't exist.
Information about an RFile object's Key.
std::uint64_t GetNBytesKey() const
Returns the on-disk size of this object's key.
std::uint64_t fSeekParentDir
std::uint16_t GetCycle() const
const std::string & GetPath() const
Returns the absolute path of this key, i.e. the directory part plus the object name.
std::uint64_t GetSeekParentDir() const
Returns the on-disk offset of this object's parent directory key.
const std::string & GetClassName() const
ECategory GetCategory() const
std::uint64_t GetSeekKey() const
Returns the on-disk offset of this object's key.
std::string GetBaseName() const
Returns the base name of this key, i.e. the name of the object without the directory part.
std::uint64_t GetNBytesObj() const
Returns the on-disk size of the (potentially compressed) object, excluding its key.
const std::string & GetTitle() const
std::uint64_t GetLenObj() const
Returns the in-memory size of the uncompressed object.
A log configuration for a channel, e.g.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Iterator abstract base class.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
A TTree represents a columnar dataset.
std::pair< std::string_view, std::string_view > DecomposePath(std::string_view path)
Given a "path-like" string (like foo/bar/baz), returns a pair { dirName, baseName }.
ROOT::RLogChannel & RFileLog()
void * RFile_GetObjectFromKey(RFile &file, const RKeyInfo &key)
Returns an owning pointer to the object referenced by key.
TFile * GetRFileTFile(RFile &rfile)
@ kUseGeneralPurpose
Use the new recommended general-purpose setting; it is a best trade-off between compression ratio/dec...
std::shared_ptr< TIterator > fIter
RIterStackElem(TIterator *it, const std::string &path="")
bool operator==(const RIterStackElem &other) const
bool fEnableBrowsability
If true the RFile will show up in the TBrowser window.
int fCompressionSettings
See core/zip/inc/Compression.h for the meaning of the compression argument.
bool fEnableBrowsability
If true the RFile will show up in the TBrowser window.
bool fEnableBrowsability
If true the RFile will show up in the TBrowser window.