Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
OutputDirectory Class Reference

Represents an output directory that has been verified to exist. More...

#include <outputdirectory.h>

Collaboration diagram for OutputDirectory:

Public Member Functions

 OutputDirectory (QString path) noexcept
 Constructs an OutputDirectory for the given path.
 OutputDirectory (const OutputDirectory &)=default
 OutputDirectory (OutputDirectory &&) noexcept=default
OutputDirectoryoperator= (const OutputDirectory &)=default
OutputDirectoryoperator= (OutputDirectory &&) noexcept=default
 ~OutputDirectory ()=default
OutputDirectory ensureSubdir (QStringView subdirName, const Location &location) const
 Ensures that a subdirectory named subdirName exists within this output directory, creating it if necessary.
const QStringpath () const noexcept
QString absoluteFilePath (QStringView fileName) const
 Returns the absolute file path for a file named fileName within this output directory.
QDir toQDir () const

Static Public Member Functions

static OutputDirectory ensure (QStringView path, const Location &location)
 Ensures that an output directory exists at path and creates it if necessary.

Friends

bool operator== (const OutputDirectory &lhs, const OutputDirectory &rhs) noexcept
bool operator!= (const OutputDirectory &lhs, const OutputDirectory &rhs) noexcept

Detailed Description

Represents an output directory that has been verified to exist.

OutputDirectory is a simple value type that wraps a QString representing a filesystem path to a directory. Instances are created via OutputDirectory::ensure() and OutputDirectory::ensureSubdir() after ensuring the directory exists.

This class provides a type-safe way to pass around directory paths that are known to be valid. This reduces the need for repeated existence checks.

Instances created via ensure() or ensureSubdir() provide the following guarantees:

\list

Note
The public constructor doesn't perform existence checks and is intended primarily for internal use by the factory methods. Avoid direct construction in favor of ensure() or ensureSubdir().
These methods are designed for single-threaded use during QDoc's generation phase and are not synchronized.
See also
OutputDirectory::ensure(), OutputDirectory::ensureSubdir()

Definition at line 15 of file outputdirectory.h.

Constructor & Destructor Documentation

◆ OutputDirectory() [1/3]

OutputDirectory::OutputDirectory ( QString path)
explicitnoexcept

Constructs an OutputDirectory for the given path.

The path is normalized using QDir::cleanPath() and moved into the object. This constructor is intentionally public to allow the static factory methods to create instances, but users should not construct OutputDirectory instances directly—they should use OutputDirectory::ensure() or ensureSubdir() instead.

Definition at line 63 of file outputdirectory.cpp.

References OutputDirectory().

Referenced by OutputDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OutputDirectory() [2/3]

OutputDirectory::OutputDirectory ( const OutputDirectory & )
default

◆ OutputDirectory() [3/3]

OutputDirectory::OutputDirectory ( OutputDirectory && )
defaultnoexcept

◆ ~OutputDirectory()

OutputDirectory::~OutputDirectory ( )
default

Member Function Documentation

◆ absoluteFilePath()

QString OutputDirectory::absoluteFilePath ( QStringView fileName) const
nodiscard

Returns the absolute file path for a file named fileName within this output directory.

For example, if the output directory is "/tmp/doc" and fileName is "index.html", this returns "/tmp/doc/index.html".

Definition at line 75 of file outputdirectory.cpp.

◆ ensure()

OutputDirectory OutputDirectory::ensure ( QStringView path,
const Location & location )
staticnodiscard

Ensures that an output directory exists at path and creates it if necessary.

If path exists but is not a directory, or if the directory cannot be created, reports a fatal error using location and terminates QDoc execution.

Returns an OutputDirectory representing the created or existing directory.

See also
ensureSubdir()

Definition at line 92 of file outputdirectory.cpp.

◆ ensureSubdir()

OutputDirectory OutputDirectory::ensureSubdir ( QStringView subdirName,
const Location & location ) const
nodiscard

Ensures that a subdirectory named subdirName exists within this output directory, creating it if necessary.

The subdirName must be a relative path. Absolute paths and paths that traverse outside the parent directory using ".." are rejected with a fatal error to prevent accidental writes outside the output tree.

If the directory cannot be created, reports a fatal error using location and terminates QDoc execution.

Returns an OutputDirectory representing the created or existing subdirectory.

See also
ensure()

Definition at line 122 of file outputdirectory.cpp.

◆ operator=() [1/2]

OutputDirectory & OutputDirectory::operator= ( const OutputDirectory & )
default

◆ operator=() [2/2]

OutputDirectory & OutputDirectory::operator= ( OutputDirectory && )
defaultnoexcept

◆ path()

const QString & OutputDirectory::path ( ) const
inlinenodiscardnoexcept

Definition at line 30 of file outputdirectory.h.

Referenced by Generator::addImageToCopy().

Here is the caller graph for this function:

◆ toQDir()

QDir OutputDirectory::toQDir ( ) const
inlinenodiscard

Definition at line 32 of file outputdirectory.h.

◆ operator!=

bool operator!= ( const OutputDirectory & lhs,
const OutputDirectory & rhs )
friend

Definition at line 39 of file outputdirectory.h.

References operator==.

◆ operator==

bool operator== ( const OutputDirectory & lhs,
const OutputDirectory & rhs )
friend

Definition at line 34 of file outputdirectory.h.

Referenced by operator!=.


The documentation for this class was generated from the following files: