summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qcommandlineoption.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qcommandlineoption.cpp')
-rw-r--r--src/corelib/tools/qcommandlineoption.cpp75
1 files changed, 57 insertions, 18 deletions
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp
index ccf9211b52..4ba8322dce 100644
--- a/src/corelib/tools/qcommandlineoption.cpp
+++ b/src/corelib/tools/qcommandlineoption.cpp
@@ -6,36 +6,28 @@
**
** This file is part of the QtCore module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
+** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -96,6 +88,41 @@ public:
*/
/*!
+ Constructs a command line option object with the name \a name.
+
+ The name can be either short or long. If the name is one character in
+ length, it is considered a short name. Option names must not be empty,
+ must not start with a dash or a slash character, must not contain a \c{=}
+ and cannot be repeated.
+
+ \sa setDescription(), setValueName(), setDefaultValues()
+*/
+QCommandLineOption::QCommandLineOption(const QString &name)
+ : d(new QCommandLineOptionPrivate)
+{
+ d->setNames(QStringList(name));
+}
+
+/*!
+ Constructs a command line option object with the names \a names.
+
+ This overload allows to set multiple names for the option, for instance
+ \c{o} and \c{output}.
+
+ The names can be either short or long. Any name in the list that is one
+ character in length is a short name. Option names must not be empty,
+ must not start with a dash or a slash character, must not contain a \c{=}
+ and cannot be repeated.
+
+ \sa setDescription(), setValueName(), setDefaultValues()
+*/
+QCommandLineOption::QCommandLineOption(const QStringList &names)
+ : d(new QCommandLineOptionPrivate)
+{
+ d->setNames(names);
+}
+
+/*!
Constructs a command line option object with the given arguments.
The name of the option is set to \a name.
@@ -110,6 +137,12 @@ public:
In addition, the \a valueName can be set if the option expects a value.
The default value for the option is set to \a defaultValue.
+ In Qt versions before 5.4, this constructor was \c explicit. In Qt 5.4
+ and later, it no longer is and can be used for C++11-style uniform
+ initialization:
+
+ \snippet code/src_corelib_tools_qcommandlineoption.cpp cxx11-init
+
\sa setDescription(), setValueName(), setDefaultValues()
*/
QCommandLineOption::QCommandLineOption(const QString &name, const QString &description,
@@ -141,6 +174,12 @@ QCommandLineOption::QCommandLineOption(const QString &name, const QString &descr
In addition, the \a valueName can be set if the option expects a value.
The default value for the option is set to \a defaultValue.
+ In Qt versions before 5.4, this constructor was \c explicit. In Qt 5.4
+ and later, it no longer is and can be used for C++11-style uniform
+ initialization:
+
+ \snippet code/src_corelib_tools_qcommandlineoption.cpp cxx11-init-list
+
\sa setDescription(), setValueName(), setDefaultValues()
*/
QCommandLineOption::QCommandLineOption(const QStringList &names, const QString &description,