Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtpaths.cpp File Reference
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QStandardPaths>
#include <QHash>
#include <QLibraryInfo>
#include <algorithm>
#include <stdio.h>
+ Include dependency graph for qtpaths.cpp:

Go to the source code of this file.

Classes

class  StringEnum
 

Functions

static QT_USE_NAMESPACE void message (const QString &string)
 
static Q_NORETURN void error (const QString &message)
 
static QStringList types ()
 
static const StringEnumparseLocationOrError (const QString &locationString)
 
static QString searchStringOrError (QCommandLineParser *parser)
 
int main (int argc, char **argv)
 [0]
 

Variables

static const StringEnum lookupTableData []
 

Function Documentation

◆ error()

static Q_NORETURN void error ( const QString message)
static

Writes error message and exits 1

Parameters
messageto write

Definition at line 36 of file qtpaths.cpp.

References qPrintable.

◆ main()

int main ( int  argc,
char **  argv 
)

[0]

[0]

[0]

[6]

[0]

[0]

[1]

[1]

[2]

[2]

[3]

[3]

[0]

[0]

[1]

[1]

[0]

[0]

[0]

[0]

Definition at line 124 of file qtpaths.cpp.

References QCommandLineParser::addHelpOption(), QCommandLineParser::addOption(), QCommandLineParser::addPositionalArgument(), QCommandLineParser::addVersionOption(), app, QLibraryInfo::BinariesPath, QStandardPaths::displayName(), error, errorMessage(), QStandardPaths::findExecutable(), QList< T >::first(), QString::fromLatin1(), QCommandLineOption::HiddenFromHelp, QList< T >::isEmpty(), QCommandLineParser::isSet(), item, QStandardPaths::locate(), QStandardPaths::locateAll(), QStandardPaths::LocateDirectory, QStandardPaths::LocateFile, QCommandLineParser::ParseAsLongOptions, parseLocationOrError(), QLibraryInfo::path(), QLibraryInfo::PluginsPath, QCommandLineParser::positionalArguments(), QLibraryInfo::PrefixPath, QCommandLineParser::process(), QStringLiteral, QT_WARNING_DISABLE_GCC, QT_WARNING_POP, QT_WARNING_PUSH, results, searchStringOrError(), QCommandLineParser::setApplicationDescription(), QCoreApplication::setApplicationVersion(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setFlags(), QCommandLineParser::setSingleDashWordOptionMode(), QStandardPaths::setTestModeEnabled(), QCommandLineParser::showHelp(), QList< T >::size(), QStandardPaths::standardLocations(), text, types(), QCommandLineParser::value(), and QStandardPaths::writableLocation().

+ Here is the call graph for this function:

◆ message()

static QT_USE_NAMESPACE void message ( const QString string)
static

Prints the string on stdout and appends a newline

Parameters
stringprintable string

Definition at line 27 of file qtpaths.cpp.

References qPrintable.

◆ parseLocationOrError()

static const StringEnum & parseLocationOrError ( const QString locationString)
static

Tries to parse the location string into a reference to a StringEnum entry or alternatively calls error with a error message

Definition at line 100 of file qtpaths.cpp.

References error, lookupTableData, and QStringLiteral.

Referenced by main().

+ Here is the caller graph for this function:

◆ searchStringOrError()

static QString searchStringOrError ( QCommandLineParser parser)
static

searches for exactly one remaining argument and returns it. If not found, error is called with a error message.

Parameters
parserto ask for remaining arguments
Returns
one extra argument

Definition at line 116 of file qtpaths.cpp.

References error, QCommandLineParser::positionalArguments(), and QStringLiteral.

Referenced by main().

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

◆ types()

static QStringList types ( )
static
Returns
available types as a QStringList.

Definition at line 87 of file qtpaths.cpp.

References QString::fromLatin1(), and lookupTableData.

Referenced by main().

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

Variable Documentation

◆ lookupTableData

const StringEnum lookupTableData[]
static
Initial value:
= {
{ "AppConfigLocation", QStandardPaths::AppConfigLocation, true },
{ "AppDataLocation", QStandardPaths::AppDataLocation, true },
{ "AppLocalDataLocation", QStandardPaths::AppLocalDataLocation, true },
{ "ApplicationsLocation", QStandardPaths::ApplicationsLocation, false },
{ "CacheLocation", QStandardPaths::CacheLocation, true },
{ "ConfigLocation", QStandardPaths::ConfigLocation, false },
{ "DesktopLocation", QStandardPaths::DesktopLocation, false },
{ "DocumentsLocation", QStandardPaths::DocumentsLocation, false },
{ "DownloadLocation", QStandardPaths::DownloadLocation, false },
{ "FontsLocation", QStandardPaths::FontsLocation, false },
{ "GenericCacheLocation", QStandardPaths::GenericCacheLocation, false },
{ "GenericConfigLocation", QStandardPaths::GenericConfigLocation, false },
{ "GenericDataLocation", QStandardPaths::GenericDataLocation, false },
{ "HomeLocation", QStandardPaths::HomeLocation, false },
{ "MoviesLocation", QStandardPaths::MoviesLocation, false },
{ "MusicLocation", QStandardPaths::MusicLocation, false },
{ "PicturesLocation", QStandardPaths::PicturesLocation, false },
{ "PublicShareLocation", QStandardPaths::PublicShareLocation, false },
{ "RuntimeLocation", QStandardPaths::RuntimeLocation, false },
{ "TemplatesLocation", QStandardPaths::TemplatesLocation, false },
{ "TempLocation", QStandardPaths::TempLocation, false }
}

Definition at line 57 of file qtpaths.cpp.

Referenced by parseLocationOrError(), and types().