1/*
2 * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#ifndef SYSTEMCONSTS_H
18#define SYSTEMCONSTS_H
19
20#include <QStringList>
21
22#define APP_SETTSINGS_FILENAME "redpandacpp.ini"
23#ifdef Q_OS_WIN
24#define GCC_PROGRAM "gcc.exe"
25#define GPP_PROGRAM "g++.exe"
26#define GDB_PROGRAM "gdb.exe"
27#define GDB_SERVER_PROGRAM "gdbserver.exe"
28#define GDB32_PROGRAM "gdb32.exe"
29#define MAKE_PROGRAM "mingw32-make.exe"
30#define WINDRES_PROGRAM "windres.exe"
31#define GPROF_PROGRAM "gprof.exe"
32#define CLEAN_PROGRAM "del /q /f"
33#define CPP_PROGRAM "cpp.exe"
34#define GIT_PROGRAM "git.exe"
35#define CLANG_PROGRAM "clang.exe"
36#define CLANG_CPP_PROGRAM "clang++.exe"
37#define LLDB_MI_PROGRAM "lldb-mi.exe"
38#elif defined(Q_OS_LINUX)
39#define GCC_PROGRAM "gcc"
40#define GPP_PROGRAM "g++"
41#define GDB_PROGRAM "gdb"
42#define GDB_SERVER_PROGRAM "gdbserver"
43#define GDB32_PROGRAM "gdb32"
44#define MAKE_PROGRAM "make"
45#define WINDRES_PROGRAM ""
46#define GPROF_PROGRAM "gprof"
47#define CLEAN_PROGRAM "rm -rf"
48#define CPP_PROGRAM "cpp"
49#define GIT_PROGRAM "git"
50#define CLANG_PROGRAM "clang"
51#define CLANG_CPP_PROGRAM "clang++"
52#define LLDB_MI_PROGRAM "lldb-mi"
53#elif defined(Q_OS_MACOS)
54#define GCC_PROGRAM "gcc"
55#define GPP_PROGRAM "g++"
56#define GDB_PROGRAM "gdb"
57#define GDB_SERVER_PROGRAM "gdbserver"
58#define GDB32_PROGRAM "gdb32"
59#define MAKE_PROGRAM "make"
60#define WINDRES_PROGRAM ""
61#define GPROF_PROGRAM "gprof"
62#define CLEAN_PROGRAM "rm -rf"
63#define CPP_PROGRAM "cpp"
64#define GIT_PROGRAM "git"
65#define CLANG_PROGRAM "clang"
66#define CLANG_CPP_PROGRAM "clang++"
67#define LLDB_MI_PROGRAM "lldb-mi"
68#else
69#error "Only support windows and linux now!"
70#endif
71
72#define DEV_PROJECT_EXT "dev"
73#define RC_EXT "rc"
74#define RES_EXT "res"
75#define H_EXT "h"
76#define OBJ_EXT "o"
77#define DEF_EXT "def"
78#define LIB_EXT "a"
79#define GCH_EXT "gch"
80#define TEMPLATE_EXT "template"
81#define TEMPLATE_INFO_FILE "info.template"
82#define DEV_INTERNAL_OPEN "$__DEV_INTERNAL_OPEN"
83#define DEV_LASTOPENS_FILE "lastopens.ini"
84#define DEV_SYMBOLUSAGE_FILE "symbolusage.json"
85#define DEV_CODESNIPPET_FILE "codesnippets.json"
86#define DEV_NEWFILETEMPLATES_FILE "newfiletemplate.txt"
87#define DEV_AUTOLINK_FILE "autolink.json"
88#define DEV_SHORTCUT_FILE "shortcuts.json"
89#define DEV_TOOLS_FILE "tools.json"
90#define DEV_BOOKMARK_FILE "bookmarks.json"
91#define DEV_BREAKPOINTS_FILE "breakpoints.json"
92#define DEV_WATCH_FILE "watch.json"
93
94#ifdef Q_OS_WIN
95# define PATH_SENSITIVITY Qt::CaseInsensitive
96# define PATH_SEPARATOR ";"
97# define LINE_BREAKER "\r\n"
98# define NULL_FILE "NUL"
99# define EXECUTABLE_EXT "exe"
100# define STATIC_LIB_EXT "a"
101# define DYNAMIC_LIB_EXT "dll"
102# define MAKEFILE_NAME "makefile.win"
103# define ALL_FILE_WILDCARD "*.*"
104#elif defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
105# define PATH_SENSITIVITY Qt::CaseSensitive
106# define PATH_SEPARATOR ":"
107# define LINE_BREAKER "\n"
108# define NULL_FILE "/dev/null"
109# define EXECUTABLE_EXT ""
110# define STATIC_LIB_EXT "a"
111# define DYNAMIC_LIB_EXT "d"
112# define MAKEFILE_NAME "makefile"
113# define ALL_FILE_WILDCARD "*"
114#else
115#error "Only support windows and linux now!"
116#endif
117
118class SystemConsts
119{
120public:
121 SystemConsts();
122 const QStringList& defaultFileFilters() const noexcept;
123 const QString& defaultCFileFilter() const noexcept;
124 const QString& defaultCPPFileFilter() const noexcept;
125 const QString& defaultAllFileFilter() const noexcept;
126 void addDefaultFileFilter(const QString& name, const QString& fileExtensions);
127 const QStringList &iconFileFilters() const;
128 const QString& iconFileFilter() const;
129 void setIconFileFilters(const QStringList &newIconFileFilters);
130
131 const QStringList &codecNames() const;
132
133 const QStringList &defaultFileNameFilters() const;
134
135private:
136 void addFileFilter(QStringList& filters, const QString& name, const QString& fileExtensions);
137 QStringList mDefaultFileFilters;
138 QStringList mIconFileFilters;
139 QStringList mDefaultFileNameFilters;
140 QStringList mCodecNames;
141};
142
143extern SystemConsts* pSystemConsts;
144#endif // SYSTEMCONSTS_H
145