53std::pair<std::string_view, std::string_view>
DecomposePath(std::string_view path);
182 RIterator
begin()
const;
183 RIterator
end()
const;
267 explicit RFile(std::unique_ptr<TFile> file);
271 [[nodiscard]]
void *
GetUntyped(std::string_view path,
272 std::variant<
const char *, std::reference_wrapper<const std::type_info>>
type)
const;
275 void PutUntyped(std::string_view path,
const std::type_info &
type,
const void *obj, std::uint32_t flags);
278 template <
typename T>
279 void PutInternal(std::string_view path,
const T &obj, std::uint32_t flags)
311 static std::unique_ptr<RFile>
Open(std::string_view path);
321 static std::unique_ptr<RFile>
Update(std::string_view path);
332 template <
typename T>
333 std::unique_ptr<T>
Get(std::string_view path)
const
336 return std::unique_ptr<T>(
static_cast<T *
>(obj));
346 template <
typename T>
347 void Put(std::string_view path,
const T &obj)
360 template <
typename T>
361 void Overwrite(std::string_view path,
const T &obj,
bool backupPrevious =
true)
407 std::optional<RKeyInfo>
GetKeyInfo(std::string_view path)
const;
410 void Print(std::ostream &out = std::cout)
const;
const value_type & reference
bool operator==(const iterator &rh) const
const value_type * pointer
bool operator!=(const iterator &rh) const
std::input_iterator_tag iterator_category
std::uint16_t fRootDirNesting
std::deque< RIterStackElem > fIterStack
RIterator(TIterator *iter, Pattern_t pattern, std::uint32_t flags)
friend class RFileKeyIterable
std::ptrdiff_t difference_type
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
std::unique_ptr< TFile > fFile
size_t Flush()
Writes all objects and the file structure to disk.
static std::unique_ptr< RFile > Update(std::string_view path)
Opens the file for updating, creating a new one if it doesn't exist.
void Print(std::ostream &out=std::cout) const
Prints the internal structure of this RFile to the given stream.
void PutInternal(std::string_view path, const T &obj, std::uint32_t flags)
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...
std::optional< RKeyInfo > GetKeyInfo(std::string_view path) const
Retrieves information about the key of object at path, if one exists.
static std::unique_ptr< RFile > Open(std::string_view path)
Opens the file for reading.
std::unique_ptr< T > Get(std::string_view path) const
Retrieves an object from the file.
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.
void Overwrite(std::string_view path, const T &obj, bool backupPrevious=true)
Puts an object into the file, overwriting any previously-existing object at that path.
void PutUntyped(std::string_view path, const std::type_info &type, const void *obj, std::uint32_t flags)
Writes obj to file, without taking its ownership.
PutFlags
Flags used in PutInternal().
@ kPutOverwriteKeepCycle
When overwriting an object, preserve the existing one and create a new cycle, rather than removing it...
@ kPutAllowOverwrite
When encountering an object at the specified path, overwrite it with the new one instead of erroring ...
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 Put(std::string_view path, const T &obj)
Puts an object into the file.
RFile(std::unique_ptr< TFile > file)
Information about an RFile object's Key.
const std::string & GetClassName() const
std::uint64_t GetNBytesKey() const
Returns the on-disk size of this object's key.
const std::string & GetTitle() const
std::uint64_t fSeekParentDir
ECategory GetCategory() const
std::uint64_t GetSeekParentDir() const
Returns the on-disk offset of this object's parent directory key.
std::string GetBaseName() const
Returns the base name of this key, i.e. the name of the object without the directory part.
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 GetSeekKey() const
Returns the on-disk offset of this object's key.
std::uint64_t GetLenObj() const
Returns the in-memory size of the uncompressed object.
RKeyInfo(const TKey &key)
std::uint64_t GetNBytesObj() const
Returns the on-disk size of the (potentially compressed) object, excluding its key.
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.
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)
Namespace for ROOT features in testing.
bool operator==(const RIterStackElem &other) const
std::shared_ptr< TIterator > fIter
RIterStackElem(TIterator *it, const std::string &path="")
int fCompressionSettings
See core/zip/inc/Compression.h for the meaning of the compression argument.
@ kUseGeneralPurpose
Use the new recommended general-purpose setting; it is a best trade-off between compression ratio/dec...