Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qcommandlineoption.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | class QCommandLineOptionPrivate : public QSharedData | - | ||||||
6 | { | - | ||||||
7 | public: | - | ||||||
8 | __attribute__((noinline)) | - | ||||||
9 | explicit QCommandLineOptionPrivate(const QString &name) | - | ||||||
10 | : names(removeInvalidNames(QStringList(name))), | - | ||||||
11 | hidden(false) | - | ||||||
12 | { } executed 167 times by 2 tests: end of block Executed by:
| 167 | ||||||
13 | - | |||||||
14 | __attribute__((noinline)) | - | ||||||
15 | explicit QCommandLineOptionPrivate(const QStringList &names) | - | ||||||
16 | : names(removeInvalidNames(names)), | - | ||||||
17 | hidden(false) | - | ||||||
18 | { } executed 1110 times by 2 tests: end of block Executed by:
| 1110 | ||||||
19 | - | |||||||
20 | static QStringList removeInvalidNames(QStringList nameList); | - | ||||||
21 | - | |||||||
22 | - | |||||||
23 | QStringList names; | - | ||||||
24 | - | |||||||
25 | - | |||||||
26 | - | |||||||
27 | QString valueName; | - | ||||||
28 | - | |||||||
29 | - | |||||||
30 | QString description; | - | ||||||
31 | - | |||||||
32 | - | |||||||
33 | QStringList defaultValues; | - | ||||||
34 | - | |||||||
35 | - | |||||||
36 | bool hidden; | - | ||||||
37 | }; | - | ||||||
38 | QCommandLineOption::QCommandLineOption(const QString &name) | - | ||||||
39 | : d(new QCommandLineOptionPrivate(name)) | - | ||||||
40 | { | - | ||||||
41 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
42 | QCommandLineOption::QCommandLineOption(const QStringList &names) | - | ||||||
43 | : d(new QCommandLineOptionPrivate(names)) | - | ||||||
44 | { | - | ||||||
45 | } never executed: end of block | 0 | ||||||
46 | QCommandLineOption::QCommandLineOption(const QString &name, const QString &description, | - | ||||||
47 | const QString &valueName, | - | ||||||
48 | const QString &defaultValue) | - | ||||||
49 | : d(new QCommandLineOptionPrivate(name)) | - | ||||||
50 | { | - | ||||||
51 | setValueName(valueName); | - | ||||||
52 | setDescription(description); | - | ||||||
53 | setDefaultValue(defaultValue); | - | ||||||
54 | } executed 165 times by 2 tests: end of block Executed by:
| 165 | ||||||
55 | QCommandLineOption::QCommandLineOption(const QStringList &names, const QString &description, | - | ||||||
56 | const QString &valueName, | - | ||||||
57 | const QString &defaultValue) | - | ||||||
58 | : d(new QCommandLineOptionPrivate(names)) | - | ||||||
59 | { | - | ||||||
60 | setValueName(valueName); | - | ||||||
61 | setDescription(description); | - | ||||||
62 | setDefaultValue(defaultValue); | - | ||||||
63 | } executed 1110 times by 2 tests: end of block Executed by:
| 1110 | ||||||
64 | - | |||||||
65 | - | |||||||
66 | - | |||||||
67 | - | |||||||
68 | - | |||||||
69 | - | |||||||
70 | - | |||||||
71 | QCommandLineOption::QCommandLineOption(const QCommandLineOption &other) | - | ||||||
72 | : d(other.d) | - | ||||||
73 | { | - | ||||||
74 | } executed 1278 times by 2 tests: end of block Executed by:
| 1278 | ||||||
75 | - | |||||||
76 | - | |||||||
77 | - | |||||||
78 | - | |||||||
79 | QCommandLineOption::~QCommandLineOption() | - | ||||||
80 | { | - | ||||||
81 | } | - | ||||||
82 | - | |||||||
83 | - | |||||||
84 | - | |||||||
85 | - | |||||||
86 | - | |||||||
87 | QCommandLineOption &QCommandLineOption::operator=(const QCommandLineOption &other) | - | ||||||
88 | { | - | ||||||
89 | d = other.d; | - | ||||||
90 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||
91 | } | - | ||||||
92 | QStringList QCommandLineOption::names() const | - | ||||||
93 | { | - | ||||||
94 | return executed 2763 times by 2 tests: d->names;return d->names; Executed by:
executed 2763 times by 2 tests: return d->names; Executed by:
| 2763 | ||||||
95 | } | - | ||||||
96 | - | |||||||
97 | namespace { | - | ||||||
98 | struct IsInvalidName | - | ||||||
99 | { | - | ||||||
100 | typedef bool result_type; | - | ||||||
101 | typedef QString argument_type; | - | ||||||
102 | - | |||||||
103 | __attribute__((noinline)) | - | ||||||
104 | result_type operator()(const QString &name) const noexcept | - | ||||||
105 | { | - | ||||||
106 | if (__builtin_expect(!!(name.isEmpty()), false)
| 0-2387 | ||||||
107 | return never executed: warn("be empty");return warn("be empty"); never executed: return warn("be empty"); | 0 | ||||||
108 | - | |||||||
109 | const QChar c = name.at(0); | - | ||||||
110 | if (__builtin_expect(!!(c == QLatin1Char('-')), false)
| 1-2386 | ||||||
111 | return executed 1 time by 1 test: warn("start with a '-'");return warn("start with a '-'"); Executed by:
executed 1 time by 1 test: return warn("start with a '-'"); Executed by:
| 1 | ||||||
112 | if (__builtin_expect(!!(c == QLatin1Char('/')), false)
| 0-2386 | ||||||
113 | return never executed: warn("start with a '/'");return warn("start with a '/'"); never executed: return warn("start with a '/'"); | 0 | ||||||
114 | if (__builtin_expect(!!(name.contains(QLatin1Char('='))), false)
| 0-2386 | ||||||
115 | return never executed: warn("contain a '='");return warn("contain a '='"); never executed: return warn("contain a '='"); | 0 | ||||||
116 | - | |||||||
117 | return executed 2386 times by 2 tests: false;return false; Executed by:
executed 2386 times by 2 tests: return false; Executed by:
| 2386 | ||||||
118 | } | - | ||||||
119 | - | |||||||
120 | __attribute__((noinline)) | - | ||||||
121 | static bool warn(const char *what) noexcept | - | ||||||
122 | { | - | ||||||
123 | QMessageLogger(__FILE__, 279, __PRETTY_FUNCTION__).warning("QCommandLineOption: Option names cannot %s", what); | - | ||||||
124 | return executed 1 time by 1 test: true;return true; Executed by:
executed 1 time by 1 test: return true; Executed by:
| 1 | ||||||
125 | } | - | ||||||
126 | }; | - | ||||||
127 | } | - | ||||||
128 | - | |||||||
129 | - | |||||||
130 | QStringList QCommandLineOptionPrivate::removeInvalidNames(QStringList nameList) | - | ||||||
131 | { | - | ||||||
132 | if (__builtin_expect(!!(nameList.isEmpty()), false)
| 0-1277 | ||||||
133 | QMessageLogger(__FILE__, 289, __PRETTY_FUNCTION__).warning("QCommandLineOption: Options must have at least one name"); never executed: QMessageLogger(__FILE__, 289, __PRETTY_FUNCTION__).warning("QCommandLineOption: Options must have at least one name"); | 0 | ||||||
134 | else | - | ||||||
135 | nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()), executed 1277 times by 2 tests: nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()), nameList.end()); Executed by:
| 1277 | ||||||
136 | nameList.end()); executed 1277 times by 2 tests: nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()), nameList.end()); Executed by:
| 1277 | ||||||
137 | return executed 1277 times by 2 tests: nameList;return nameList; Executed by:
executed 1277 times by 2 tests: return nameList; Executed by:
| 1277 | ||||||
138 | } | - | ||||||
139 | void QCommandLineOption::setValueName(const QString &valueName) | - | ||||||
140 | { | - | ||||||
141 | d->valueName = valueName; | - | ||||||
142 | } executed 1277 times by 2 tests: end of block Executed by:
| 1277 | ||||||
143 | QString QCommandLineOption::valueName() const | - | ||||||
144 | { | - | ||||||
145 | return executed 541 times by 2 tests: d->valueName;return d->valueName; Executed by:
executed 541 times by 2 tests: return d->valueName; Executed by:
| 541 | ||||||
146 | } | - | ||||||
147 | void QCommandLineOption::setDescription(const QString &description) | - | ||||||
148 | { | - | ||||||
149 | d->description = description; | - | ||||||
150 | } executed 1275 times by 2 tests: end of block Executed by:
| 1275 | ||||||
151 | - | |||||||
152 | - | |||||||
153 | - | |||||||
154 | - | |||||||
155 | - | |||||||
156 | - | |||||||
157 | QString QCommandLineOption::description() const | - | ||||||
158 | { | - | ||||||
159 | return executed 1 time by 1 test: d->description;return d->description; Executed by:
executed 1 time by 1 test: return d->description; Executed by:
| 1 | ||||||
160 | } | - | ||||||
161 | void QCommandLineOption::setDefaultValue(const QString &defaultValue) | - | ||||||
162 | { | - | ||||||
163 | QStringList newDefaultValues; | - | ||||||
164 | if (!defaultValue.isEmpty()
| 2-1275 | ||||||
165 | newDefaultValues.reserve(1); | - | ||||||
166 | newDefaultValues << defaultValue; | - | ||||||
167 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
168 | - | |||||||
169 | d->defaultValues.swap(newDefaultValues); | - | ||||||
170 | } executed 1277 times by 2 tests: end of block Executed by:
| 1277 | ||||||
171 | void QCommandLineOption::setDefaultValues(const QStringList &defaultValues) | - | ||||||
172 | { | - | ||||||
173 | d->defaultValues = defaultValues; | - | ||||||
174 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
175 | - | |||||||
176 | - | |||||||
177 | - | |||||||
178 | - | |||||||
179 | - | |||||||
180 | - | |||||||
181 | QStringList QCommandLineOption::defaultValues() const | - | ||||||
182 | { | - | ||||||
183 | return executed 513 times by 2 tests: d->defaultValues;return d->defaultValues; Executed by:
executed 513 times by 2 tests: return d->defaultValues; Executed by:
| 513 | ||||||
184 | } | - | ||||||
185 | void QCommandLineOption::setHidden(bool hide) | - | ||||||
186 | { | - | ||||||
187 | d->hidden = hide; | - | ||||||
188 | } never executed: end of block | 0 | ||||||
189 | bool QCommandLineOption::isHidden() const | - | ||||||
190 | { | - | ||||||
191 | return executed 2 times by 1 test: d->hidden;return d->hidden; Executed by:
executed 2 times by 1 test: return d->hidden; Executed by:
| 2 | ||||||
192 | } | - | ||||||
193 | - | |||||||
194 | - | |||||||
Switch to Source code | Preprocessed file |