| 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 47 times by 1 test:  end of blockExecuted by: 
  | 47 | ||||||
| 13 | - | |||||||
| 14 | __attribute__((noinline)) | - | ||||||
| 15 | explicit QCommandLineOptionPrivate(const QStringList &names) | - | ||||||
| 16 | : names(removeInvalidNames(names)), | - | ||||||
| 17 | hidden(false) | - | ||||||
| 18 |     { } executed 30 times by 1 test:  end of blockExecuted by: 
  | 30 | ||||||
| 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 blockExecuted 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 45 times by 1 test:  end of blockExecuted by: 
  | 45 | ||||||
| 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 30 times by 1 test:  end of blockExecuted by: 
  | 30 | ||||||
| 64 | - | |||||||
| 65 | - | |||||||
| 66 | - | |||||||
| 67 | - | |||||||
| 68 | - | |||||||
| 69 | - | |||||||
| 70 | - | |||||||
| 71 | QCommandLineOption::QCommandLineOption(const QCommandLineOption &other) | - | ||||||
| 72 | : d(other.d) | - | ||||||
| 73 | { | - | ||||||
| 74 | } executed 78 times by 1 test:  end of blockExecuted by: 
  | 78 | ||||||
| 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 131 times by 1 test:   d->names;return d->names;Executed by: 
 executed 131 times by 1 test:  return d->names;Executed by: 
  | 131 | ||||||
| 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-107 | ||||||
| 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-106 | ||||||
| 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-106 | ||||||
| 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-106 | ||||||
| 115 |                 return never executed:   warn("contain a '='");return warn("contain a '='");never executed:  return warn("contain a '='"); | 0 | ||||||
| 116 | - | |||||||
| 117 |             return executed 106 times by 1 test:   false;return false;Executed by: 
 executed 106 times by 1 test:  return false;Executed by: 
  | 106 | ||||||
| 118 | } | - | ||||||
| 119 | - | |||||||
| 120 | __attribute__((noinline)) | - | ||||||
| 121 | static bool warn(const char *what) noexcept | - | ||||||
| 122 | { | - | ||||||
| 123 | QMessageLogger(__FILE__, 273, __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-77 | ||||||
| 133 |         QMessageLogger(__FILE__, 283, __PRETTY_FUNCTION__).warning("QCommandLineOption: Options must have at least one name"); never executed:  QMessageLogger(__FILE__, 283, __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 77 times by 1 test:  nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()), nameList.end());Executed by: 
  | 77 | ||||||
| 136 |                        nameList.end()); executed 77 times by 1 test:  nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()), nameList.end());Executed by: 
  | 77 | ||||||
| 137 |     return executed 77 times by 1 test:   nameList;return nameList;Executed by: 
 executed 77 times by 1 test:  return nameList;Executed by: 
  | 77 | ||||||
| 138 | } | - | ||||||
| 139 | void QCommandLineOption::setValueName(const QString &valueName) | - | ||||||
| 140 | { | - | ||||||
| 141 | d->valueName = valueName; | - | ||||||
| 142 | } executed 77 times by 1 test:  end of blockExecuted by: 
  | 77 | ||||||
| 143 | QString QCommandLineOption::valueName() const | - | ||||||
| 144 | { | - | ||||||
| 145 |     return executed 62 times by 1 test:   d->valueName;return d->valueName;Executed by: 
 executed 62 times by 1 test:  return d->valueName;Executed by: 
  | 62 | ||||||
| 146 | } | - | ||||||
| 147 | void QCommandLineOption::setDescription(const QString &description) | - | ||||||
| 148 | { | - | ||||||
| 149 | d->description = description; | - | ||||||
| 150 | } executed 75 times by 1 test:  end of blockExecuted by: 
  | 75 | ||||||
| 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-75 | ||||||
| 165 | newDefaultValues.reserve(1); | - | ||||||
| 166 | newDefaultValues << defaultValue; | - | ||||||
| 167 |     } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||
| 168 | - | |||||||
| 169 | d->defaultValues.swap(newDefaultValues); | - | ||||||
| 170 | } executed 77 times by 1 test:  end of blockExecuted by: 
  | 77 | ||||||
| 171 | void QCommandLineOption::setDefaultValues(const QStringList &defaultValues) | - | ||||||
| 172 | { | - | ||||||
| 173 | d->defaultValues = defaultValues; | - | ||||||
| 174 | } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||
| 175 | - | |||||||
| 176 | - | |||||||
| 177 | - | |||||||
| 178 | - | |||||||
| 179 | - | |||||||
| 180 | - | |||||||
| 181 | QStringList QCommandLineOption::defaultValues() const | - | ||||||
| 182 | { | - | ||||||
| 183 |     return executed 33 times by 1 test:   d->defaultValues;return d->defaultValues;Executed by: 
 executed 33 times by 1 test:  return d->defaultValues;Executed by: 
  | 33 | ||||||
| 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 1 time by 1 test:   d->hidden;return d->hidden;Executed by: 
 executed 1 time by 1 test:  return d->hidden;Executed by: 
  | 1 | ||||||
| 192 | } | - | ||||||
| 193 | - | |||||||
| 194 | - | |||||||
| Switch to Source code | Preprocessed file |