8#include <QtCore/qcompare.h>
9#include <QtCore/qstring.h>
10#include <QtCore/qdirlisting.h>
11#include <QtCore/qfile.h>
12#include <QtCore/qfileinfo.h>
13#include <QtCore/qstringlist.h>
14#include <QtCore/qshareddata.h>
24 enum Filter { Dirs = 0x001,
28 AllEntries = Dirs | Files | Drives,
34 PermissionMask = 0x070,
35#if QT_DEPRECATED_SINCE(6
, 11
)
36 Modified QT_DEPRECATED_VERSION_X_6_11(
"This flag is not handled in QDir; you can simply remove it from your code.") = 0x080,
44 CaseSensitive = 0x800,
47 NoDotAndDotDot = NoDot | NoDotDot,
51 Q_DECLARE_FLAGS(Filters, Filter)
53 enum SortFlag { Name = 0x00,
67 Q_DECLARE_FLAGS(SortFlags, SortFlag)
70 QDir(
const QString &path = QString());
71 QDir(
const QString &path,
const QString &nameFilter,
72 SortFlags sort = SortFlags(Name | IgnoreCase), Filters filter = AllEntries);
74 QDir(
const std::filesystem::path &path);
75 QDir(
const std::filesystem::path &path,
const QString &nameFilter,
76 SortFlags sort = SortFlags(Name | IgnoreCase), Filters filter = AllEntries);
77#elif QT_CONFIG(cxx17_filesystem)
78 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
79 QDir(
const T &path) : QDir(QtPrivate::fromFilesystemPath(path))
82 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
83 QDir(
const T &path,
const QString &nameFilter,
84 SortFlags sort = SortFlags(Name | IgnoreCase), Filters filter = AllEntries)
85 : QDir(QtPrivate::fromFilesystemPath(path), nameFilter, sort, filter)
91 QDir &operator=(
const QDir &);
92 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QDir)
94 void swap(QDir &other)
noexcept
95 { d_ptr.swap(other.d_ptr); }
97 void setPath(
const QString &path);
99 void setPath(
const std::filesystem::path &path);
100#elif QT_CONFIG(cxx17_filesystem)
101 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
102 void setPath(
const T &path)
104 setPath(QtPrivate::fromFilesystemPath(path));
107 QString path()
const;
108 QString absolutePath()
const;
109 QString canonicalPath()
const;
110#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
111 std::filesystem::path filesystemPath()
const
112 {
return QtPrivate::toFilesystemPath(path()); }
113 std::filesystem::path filesystemAbsolutePath()
const
114 {
return QtPrivate::toFilesystemPath(absolutePath()); }
115 std::filesystem::path filesystemCanonicalPath()
const
116 {
return QtPrivate::toFilesystemPath(canonicalPath()); }
119#ifndef QT_BOOTSTRAPPED
120 static void setSearchPaths(
const QString &prefix,
const QStringList &searchPaths);
121 static void addSearchPath(
const QString &prefix,
const QString &path);
123 static void addSearchPath(
const QString &prefix,
const std::filesystem::path &path);
124#elif QT_CONFIG(cxx17_filesystem)
125 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
126 static void addSearchPath(
const QString &prefix,
const T &path)
128 addSearchPath(prefix, QtPrivate::fromFilesystemPath(path));
131 static QStringList searchPaths(
const QString &prefix);
134 QString dirName()
const;
135 QString filePath(
const QString &fileName)
const;
136 QString absoluteFilePath(
const QString &fileName)
const;
137 QString relativeFilePath(
const QString &fileName)
const;
139 static QString toNativeSeparators(
const QString &pathName);
140 static QString fromNativeSeparators(
const QString &pathName);
142 bool cd(
const QString &dirName);
145 QStringList nameFilters()
const;
146 void setNameFilters(
const QStringList &nameFilters);
148 Filters filter()
const;
149 void setFilter(Filters filter);
150 SortFlags sorting()
const;
151 void setSorting(SortFlags sort);
153#if QT_CORE_REMOVED_SINCE(6
, 5
)
156 qsizetype count(QT6_DECL_NEW_OVERLOAD)
const;
157 bool isEmpty(Filters filters = Filters(AllEntries | NoDotAndDotDot))
const;
159#if QT_CORE_REMOVED_SINCE(6
, 5
) && QT_POINTER_SIZE != 4
160 QString operator[](
int)
const;
162 QString operator[](qsizetype)
const;
164 static QStringList nameFiltersFromString(
const QString &nameFilter);
166 QStringList entryList(Filters filters = NoFilter, SortFlags sort = NoSort)
const;
167 QStringList entryList(
const QStringList &nameFilters, Filters filters = NoFilter,
168 SortFlags sort = NoSort)
const;
170 QFileInfoList entryInfoList(Filters filters = NoFilter, SortFlags sort = NoSort)
const;
171 QFileInfoList entryInfoList(
const QStringList &nameFilters, Filters filters = NoFilter,
172 SortFlags sort = NoSort)
const;
174#if QT_CORE_REMOVED_SINCE(6
, 10
)
175 bool mkdir(
const QString &dirName)
const;
176 bool mkdir(
const QString &dirName, QFile::Permissions permissions)
const;
178 bool mkdir(
const QString &dirName, std::optional<QFile::Permissions> p = std::nullopt)
const;
179 bool rmdir(
const QString &dirName)
const;
180#if QT_CORE_REMOVED_SINCE(6
, 10
)
181 bool mkpath(
const QString &dirPath)
const;
183 bool mkpath(
const QString &dirPath, std::optional<QFile::Permissions> p = std::nullopt)
const;
184 bool rmpath(
const QString &dirPath)
const;
186 bool removeRecursively();
188 bool isReadable()
const;
192 static bool isRelativePath(
const QString &path);
193 inline static bool isAbsolutePath(
const QString &path) {
return !isRelativePath(path); }
194 bool isRelative()
const;
195 inline bool isAbsolute()
const {
return !isRelative(); }
198#if QT_CORE_REMOVED_SINCE(6
, 8
)
199 bool operator==(
const QDir &dir)
const;
200 inline bool operator!=(
const QDir &dir)
const {
return !operator==(dir); }
203 bool remove(
const QString &fileName);
204 bool rename(
const QString &oldName,
const QString &newName);
205 bool exists(
const QString &name)
const;
207 static QFileInfoList drives();
209 constexpr static inline QChar listSeparator()
noexcept
218 static QChar separator()
227 static bool setCurrent(
const QString &path);
228 static inline QDir current() {
return QDir(currentPath()); }
229 static QString currentPath();
231 static inline QDir home() {
return QDir(homePath()); }
232 static QString homePath();
233 static inline QDir root() {
return QDir(rootPath()); }
234 static QString rootPath();
235 static inline QDir temp() {
return QDir(tempPath()); }
236 static QString tempPath();
238#if QT_CONFIG(regularexpression)
239 static bool match(
const QStringList &filters,
const QString &fileName);
240 static bool match(
const QString &filter,
const QString &fileName);
243 static QString cleanPath(
const QString &path);
244 void refresh()
const;
247 explicit QDir(QDirPrivate &d);
249 QSharedDataPointer<QDirPrivate> d_ptr;
252 friend Q_CORE_EXPORT
bool comparesEqual(
const QDir &lhs,
const QDir &rhs);
253 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QDir)
254 friend class QDirIterator;
255 friend class QDirListing;
256 friend class QDirListingPrivate;
258 QDirPrivate *d_func();
259 const QDirPrivate *d_func()
const {
return d_ptr.constData(); }
263Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::Filters)
264Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::SortFlags)
266#ifndef QT_NO_DEBUG_STREAM
268Q_CORE_EXPORT
QDebug operator<<(QDebug debug, QDir::Filters filters);
269Q_CORE_EXPORT
QDebug operator<<(QDebug debug,
const QDir &dir);
bool testFunctionAttribute(Token tok, FunctionDef *def)
void parseEnumOrFlag(BaseDef *def, QtMocConstants::EnumFlags flags)
bool hasGlobalModuleFragment
void checkSuperClasses(ClassDef *def)
bool inPrivateModuleFragment
bool parseEnum(EnumDef *def, ClassDef *containingClass)
void parseProperty(ClassDef *def, PropertyMode mode)
QByteArray lexemUntil(Token)
EncounteredQmlMacro parseClassInfo(BaseDef *def)
QList< QByteArray > includeFiles
QList< QByteArray > moduleFragmentIncludes
bool requireCompleteTypes
QHash< QByteArray, QByteArray > knownQObjectClasses
void createPropertyDef(PropertyDef &def, int propertyIndex, PropertyMode mode)
void parseClassInfo(ClassDef *def)
QByteArrayView strippedFileName() const
bool parseClassHead(ClassDef *def)
void parsePrivateProperty(ClassDef *def, PropertyMode mode)
void parseFlag(BaseDef *def)
void parsePrivateModuleFragment(qsizetype rewind)
void parseSignals(ClassDef *def)
void parseDeclareMetatype()
void parsePropertyAttributes(PropertyDef &propDef)
void parseInterfaces(ClassDef *def)
bool testFunctionRevision(FunctionDef *def)
bool testFunctionAttribute(FunctionDef *def)
void prependNamespaces(BaseDef &def, const QList< NamespaceDef > &namespaceList) const
QHash< QByteArray, QByteArray > knownGadgets
QList< QByteArray > metaTypes
bool parseFunction(FunctionDef *def, bool inMacro=false)
QByteArray parsePropertyAccessor()
QMap< QString, QJsonArray > metaArgs
bool testForFunctionModifiers(FunctionDef *def)
const QByteArray & toFullyQualified(const QByteArray &name) const noexcept
void parseSlots(ClassDef *def, FunctionDef::Access access)
void parseDeclareInterface()
void checkListSizes(const ClassDef &def)
QTypeRevision parseRevision()
QList< QString > parsedPluginMetadataFiles
qsizetype firstSourceSymbolIndex
ModuleUnitKind moduleUnitKind
bool parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
void checkProperties(ClassDef *cdef)
void parseModuleDeclaration(qsizetype rewind, bool exported)
void parseFunctionArguments(FunctionDef *def)
void parseSlotInPrivate(ClassDef *def, FunctionDef::Access access)
bool inClass(const ClassDef *def) const
void parsePluginData(ClassDef *def)
QByteArray modulePartitionName
void generate(FILE *out, FILE *jsonOutput)
QMap< QByteArray, QByteArray > interface2IdMap
bool inNamespace(const NamespaceDef *def) const
QList< ClassDef > classList
QByteArray resolveIncludeNext(const QByteArray &filename, qsizetype startIndex, qsizetype *foundIndex=nullptr)
void setDebugIncludes(bool value)
void parseDefineArguments(Macro *m)
Symbols preprocessed(const QByteArray &filename, QFile *device)
void substituteUntilNewline(Symbols &substituted)
QList< QByteArray > frameworks
QHash< QByteArray, IncludeResolution > nonlocalIncludePathResolutionCache
static bool preprocessOnly
QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo, qsizetype *foundIndex=nullptr)
static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName)
static Symbols tokenize(const QByteArray &input, int lineNum=1, TokenizeMode mode=TokenizeCpp)
static void macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, qsizetype &index, int lineNum, bool one, const QSet< QByteArray > &excludeSymbols=QSet< QByteArray >())
@ PreparePreprocessorStatement
@ TokenizePreprocessorStatement
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
The QCommandLineParser class provides a means for handling the command line options.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
std::map< Key, T > toStdMap() const &
friend size_t qHash(const M &key, size_t seed=0) noexcept(QHashPrivate::noexceptPairHash< typename M::key_type, typename M::mapped_type >())
QMap(std::map< Key, T > &&other)
std::map< Key, T > toStdMap() &&
QMap(const std::map< Key, T > &other)
friend bool comparesEqual(const QMap &lhs, const QMap &rhs)
QMap(std::initializer_list< std::pair< Key, T > > list)
void swap(QMap< Key, T > &other) noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
constexpr Integer toEncodedVersion() const
Transforms the revision into an integer value, encoding the minor version into the least significant ...
constexpr QTypeRevision()=default
Produces an invalid revision.
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
Produces a QTypeRevision from the given majorVersion with an invalid minor version.
static constexpr bool isValidSegment(Integer segment)
Returns true if the given number can be used as either major or minor version in a QTypeRevision.
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
constexpr bool hasMajorVersion() const
Returns true if the major version is known, otherwise false.
static constexpr QTypeRevision fromMinorVersion(Minor minorVersion)
Produces a QTypeRevision from the given minorVersion with an invalid major version.
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
friend constexpr Qt::strong_ordering compareThreeWay(const QTypeRevision &lhs, const QTypeRevision &rhs) noexcept
constexpr quint8 minorVersion() const
Returns the minor version encoded in the revision.
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
friend constexpr bool comparesEqual(const QTypeRevision &lhs, const QTypeRevision &rhs) noexcept
constexpr bool hasMinorVersion() const
Returns true if the minor version is known, otherwise false.
QByteArray unquotedLexem()
const Symbol & symbol() const
bool dontReplaceSymbol(const QByteArray &name) const
const SafeSymbols & constTop() const
QT_BEGIN_NAMESPACE int collectJson(const QStringList &jsonFiles, const QString &outputFile, bool skipStdIn)
Q_DECLARE_TYPEINFO(EnumDef, Q_RELOCATABLE_TYPE)
QByteArray noRef(const QByteArray &type)
Q_DECLARE_TYPEINFO(PropertyDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(NamespaceDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassInfoDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassDef::Interface, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(SuperClass, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ArgumentDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(PrivateQPropertyDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(FunctionDef, Q_RELOCATABLE_TYPE)
std::conditional_t< std::is_same_v< HashKey, q20::remove_cvref_t< KeyArgument > >, KeyArgument, HashKey > HeterogenousConstructProxy
Combined button and popup list for selecting options.
constexpr PropertyFlags DefaultPropertyFlags
@ PropertyAccessInStaticMetaCall
@ RequiresVariantMetaObject
QString && asString(QString &&s)
constexpr QAnyStringArg qStringLikeToArg(QAnyStringView s) noexcept
const QString & asString(const QString &s)
std::is_same< Char, char32_t > IsCompatibleChar32TypeHelper
constexpr bool isLatin1(QLatin1StringView s) noexcept
QHash< MacroName, Macro > Macros
Q_DECLARE_TYPEINFO(QDateTime::Data, Q_RELOCATABLE_TYPE)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
#define QFILE_MAYBE_EXPLICIT
#define QFILEINFO_MAYBE_EXPLICIT
QList< QFileInfo > QFileInfoList
qsizetype erase_if(QMultiHash< Key, T > &hash, Predicate pred)
#define QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(Class)
#define QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH(Class, Arguments)
#define QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(Class)
#define QT_MK_QHASH_COMPAT(X)
QList< QVariant > QVariantList
QMultiMap< Key, T > operator+=(QMultiMap< Key, T > &lhs, const QMultiMap< Key, T > &rhs)
QSet(InputIterator, InputIterator) -> QSet< ValueType >
size_t qHash(const QSet< T > &key, size_t seed=0) noexcept(noexcept(qHashRangeCommutative(key.begin(), key.end(), seed)))
qsizetype erase_if(QSet< T > &set, Predicate pred)
QString operator+(const QString &s1, QChar s2)
QString operator+(QString &&lhs, const QString &rhs)
qsizetype erase_if(QString &s, Predicate pred)
#define QT_UNICODE_LITERAL(str)
#define qPrintable(string)
QString operator+(QString &&lhs, QChar rhs)
QString operator+(QChar s1, const QString &s2)
#define QStringLiteral(str)
QString operator+(const QString &s1, const QString &s2)
qsizetype erase(QString &s, const T &t)
static QByteArray combinePath(const QString &infile, const QString &outfile)
static bool hasNext(const Symbols &symbols, int i)
static const Symbol & next(const Symbols &symbols, int &i)
int runMoc(int argc, char **argv)
static auto openFileForWriting(const QString &name)
void error(const char *msg="Invalid argument")
static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments, bool &hasOptionFiles)
QByteArray composePreprocessorOutput(const Symbols &symbols)
Q_DECLARE_TYPEINFO(QTypeRevision, Q_RELOCATABLE_TYPE)
int main(int argc, char *argv[])
[ctor_close]
QByteArray normalizedType
QJsonObject toJson() const
QMap< QByteArray, QByteArray > flagAliases
QList< ClassInfoDef > classInfoList
QList< EnumDef > enumList
Interface(const QByteArray &_className)
QMap< QString, QJsonArray > metaArgs
QList< QList< Interface > > interfaceList
QList< FunctionDef > publicList
QList< FunctionDef > methodList
QList< PropertyDef > propertyList
QList< FunctionDef > constructorList
QList< SuperClass > superclassList
bool requireCompleteMethodTypes
QList< FunctionDef > slotList
QList< FunctionDef > signalList
QJsonObject toJson() const
QList< QByteArray > nonClassSignalList
QFlags< QtMocConstants::EnumFlags > flags
QByteArray qualifiedType(const ClassDef *cdef) const
QJsonObject toJson(const ClassDef &cdef) const
QList< QByteArray > values
QByteArray normalizedType
QJsonObject toJson(int index) const
static void accessToJson(QJsonObject *obj, Access acs)
QByteArray inPrivateClass
QList< ArgumentDef > arguments
bool returnTypeIsVolatile
Simple structure used by the Doc and DocParser classes.
QByteArray inPrivateClass
QJsonObject toJson() const
constexpr QAnyStringArg(QAnyStringView v) noexcept
constexpr QLatin1StringArg(QLatin1StringView v) noexcept
QLatin1StringArg()=default
constexpr QStringViewArg(QStringView v) noexcept
bool operator==(const SubArray &other) const
SubArray(const QByteArray &a)
SubArray(const QByteArray &a, qsizetype from, qsizetype len)
FunctionDef::Access access
QByteArrayView unquotedLexemView() const
Symbol(int lineNum, Token token)
operator SubArray() const
QByteArrayView lexemView() const
void mergeStringLiteral(const Symbol &next)
bool operator==(const Symbol &o) const
Symbol(int lineNum, Token token, const QByteArray &lexem, qsizetype from, qsizetype len)
QByteArray unquotedLexem() const
Symbol(int lineNum, Token token, const QByteArray &lexem)
size_t qHash(const SubArray &key, size_t seed=0)
Q_DECLARE_TYPEINFO(Symbol, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(SafeSymbols, Q_RELOCATABLE_TYPE)
#define FOR_ALL_TOKENS(F)