2010-09-26 05:29:23 +02:00
|
|
|
// Cppcheck - A tool for static C/C++ code analysis
|
2023-01-28 10:16:34 +01:00
|
|
|
// Copyright (C) 2007-2023 Cppcheck team.
|
2010-09-26 05:29:23 +02:00
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include "options.h"
|
|
|
|
|
2019-03-02 08:06:23 +01:00
|
|
|
options::options(int argc, const char* const argv[])
|
2021-08-07 20:51:18 +02:00
|
|
|
: mWhichTests(argv + 1, argv + argc)
|
2019-03-26 20:28:40 +01:00
|
|
|
,mQuiet(mWhichTests.count("-q") != 0)
|
|
|
|
,mHelp(mWhichTests.count("-h") != 0 || mWhichTests.count("--help"))
|
2021-07-08 21:21:35 +02:00
|
|
|
,mExe(argv[0])
|
2010-09-26 05:29:23 +02:00
|
|
|
{
|
2022-12-20 20:32:16 +01:00
|
|
|
for (std::set<std::string>::const_iterator it = mWhichTests.cbegin(); it != mWhichTests.cend();) {
|
2019-03-26 20:28:40 +01:00
|
|
|
if (!(*it).empty() && (((*it)[0] == '-') || ((*it).find("::") != std::string::npos && mWhichTests.count((*it).substr(0, (*it).find("::"))))))
|
|
|
|
it = mWhichTests.erase(it);
|
|
|
|
else
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mWhichTests.empty()) {
|
|
|
|
mWhichTests.insert("");
|
2010-09-26 08:52:30 +02:00
|
|
|
}
|
2010-09-26 05:29:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool options::quiet() const
|
|
|
|
{
|
2019-03-03 07:42:14 +01:00
|
|
|
return mQuiet;
|
2010-09-26 05:29:23 +02:00
|
|
|
}
|
|
|
|
|
2019-03-02 08:06:23 +01:00
|
|
|
bool options::help() const
|
|
|
|
{
|
2019-03-03 07:42:14 +01:00
|
|
|
return mHelp;
|
2019-03-02 08:06:23 +01:00
|
|
|
}
|
|
|
|
|
2019-03-26 20:28:40 +01:00
|
|
|
const std::set<std::string>& options::which_test() const
|
2010-09-26 05:29:23 +02:00
|
|
|
{
|
2019-03-26 20:28:40 +01:00
|
|
|
return mWhichTests;
|
2010-09-26 05:29:23 +02:00
|
|
|
}
|
2021-07-08 21:21:35 +02:00
|
|
|
|
|
|
|
const std::string& options::exe() const
|
|
|
|
{
|
|
|
|
return mExe;
|
|
|
|
}
|