Cppcheck
filesettings.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2024 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef fileSettingsH
20 #define fileSettingsH
21 
22 #include "config.h"
23 #include "platform.h"
24 
25 #include <list>
26 #include <set>
27 #include <string>
28 #include <utility>
29 
31 {
32 public:
33  explicit FileWithDetails(std::string path)
34  : FileWithDetails(std::move(path), 0)
35  {}
36 
37  FileWithDetails(std::string path, std::size_t size)
38  : mPath(std::move(path))
39  , mSize(size)
40  {}
41 
42  const std::string& path() const
43  {
44  return mPath;
45  }
46 
47  std::size_t size() const
48  {
49  return mSize;
50  }
51 private:
52  std::string mPath;
53  std::size_t mSize;
54 };
55 
56 /** File settings. Multiple configurations for a file is allowed. */
58  explicit FileSettings(std::string path)
59  : file(std::move(path))
60  {}
61 
62  FileSettings(std::string path, std::size_t size)
63  : file(std::move(path), size)
64  {}
65 
66  std::string cfg;
68  const std::string& filename() const
69  {
70  return file.path();
71  }
72  std::string defines;
73  // TODO: handle differently
74  std::string cppcheckDefines() const {
75  return defines + (msc ? ";_MSC_VER=1900" : "") + (useMfc ? ";__AFXWIN_H__=1" : "");
76  }
77  std::set<std::string> undefs;
78  std::list<std::string> includePaths;
79  // only used by clang mode
80  std::list<std::string> systemIncludePaths;
81  std::string standard;
82  Platform::Type platformType = Platform::Type::Unspecified;
83  // TODO: get rid of these
84  bool msc{};
85  bool useMfc{};
86 };
87 
88 #endif // fileSettingsH
std::size_t size() const
Definition: filesettings.h:47
FileWithDetails(std::string path, std::size_t size)
Definition: filesettings.h:37
const std::string & path() const
Definition: filesettings.h:42
std::string mPath
Definition: filesettings.h:52
std::size_t mSize
Definition: filesettings.h:53
FileWithDetails(std::string path)
Definition: filesettings.h:33
#define CPPCHECKLIB
Definition: config.h:35
File settings.
Definition: filesettings.h:57
std::string cppcheckDefines() const
Definition: filesettings.h:74
FileSettings(std::string path, std::size_t size)
Definition: filesettings.h:62
std::string defines
Definition: filesettings.h:72
FileWithDetails file
Definition: filesettings.h:67
const std::string & filename() const
Definition: filesettings.h:68
std::set< std::string > undefs
Definition: filesettings.h:77
std::string cfg
Definition: filesettings.h:66
FileSettings(std::string path)
Definition: filesettings.h:58
std::string standard
Definition: filesettings.h:81
std::list< std::string > includePaths
Definition: filesettings.h:78
std::list< std::string > systemIncludePaths
Definition: filesettings.h:80