File: clFileSystemWorkspaceConfig.hpp

package info (click to toggle)
codelite 17.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 136,204 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (168 lines) | stat: -rw-r--r-- 7,213 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef CLFILESYSTEMWORKSPACECONFIG_HPP
#define CLFILESYSTEMWORKSPACECONFIG_HPP

#include "JSON.h"
#include "clBacktickCache.hpp"
#include "cl_command_event.h"
#include "codelite_exports.h"
#include "macros.h"

#include <map>
#include <wx/arrstr.h>
#include <wx/sharedptr.h>
#include <wxStringHash.h>

class WXDLLIMPEXP_SDK clFileSystemWorkspaceConfig
{
public:
    enum {
        kUnused = (1 << 0),
        kEnableRemoteSync = (1 << 1),
        kRemoteBuild = (1 << 2),
    };

protected:
    size_t m_flags = 0;
    std::map<wxString, wxString> m_buildTargets;
    wxArrayString m_compileFlags;
    wxString m_fileExtensions;
    wxString m_name;
    wxString m_executable;
    wxString m_args;
    wxString m_environment;
    wxString m_compiler;
    wxString m_remoteFolder;
    wxString m_remoteAccount;
    wxString m_debugger;
    wxString m_excludeFilesPattern;
    wxString m_workingDirectory;
    wxString m_excludePaths;
    wxString m_debuggerPath;
    wxString m_debuggerCommands;
    wxArrayString m_lastExecutables;

public:
    typedef wxSharedPtr<clFileSystemWorkspaceConfig> Ptr_t;
    /**
     * @brief return 2 json nodes. The first should be stored in the shared configuration file and the other in the
     * local configuration file
     */
    std::pair<JSONItem, JSONItem> ToJSON() const;
    void FromJSONOld(const JSONItem& json);
    void FromLocalJSON(const JSONItem& json);
    void FromSharedJSON(const JSONItem& json);

    void SetExcludeFilesPattern(const wxString& excludeFilesPattern)
    {
        this->m_excludeFilesPattern = excludeFilesPattern;
    }
    const wxString& GetExcludeFilesPattern() const { return m_excludeFilesPattern; }
    void SetBuildTargets(const std::map<wxString, wxString>& buildTargets) { this->m_buildTargets = buildTargets; }
    void SetCompileFlags(const wxArrayString& compileFlags) { this->m_compileFlags = compileFlags; }
    void SetCompileFlags(const wxString& compileFlags);
    void SetFileExtensions(const wxString& fileExtensions) { this->m_fileExtensions = fileExtensions; }
    void SetFlags(size_t flags) { this->m_flags = flags; }
    void SetName(const wxString& name) { this->m_name = name; }
    const std::map<wxString, wxString>& GetBuildTargets() const { return m_buildTargets; }
    const wxArrayString& GetCompileFlags() const { return m_compileFlags; }
    wxString GetCompileFlagsAsString() const;
    const wxString& GetFileExtensions() const { return m_fileExtensions; }
    size_t GetFlags() const { return m_flags; }
    const wxString& GetName() const { return m_name; }
    void SetArgs(const wxString& args) { this->m_args = args; }
    void SetEnvironment(const wxString& environment) { this->m_environment = environment; }
    void SetExecutable(const wxString& executable) { this->m_executable = executable; }
    const wxString& GetArgs() const { return m_args; }
    const wxString& GetEnvironment() const { return m_environment; }
    const wxString& GetExecutable() const { return m_executable; }
    wxArrayString GetSearchPaths(const wxFileName& workspaceFile) const;
    bool IsRemoteEnabled() const { return m_flags & kEnableRemoteSync; }
    void SetRemoteEnabled(bool b)
    {
        if(b) {
            m_flags |= kEnableRemoteSync;
        } else {
            m_flags &= ~kEnableRemoteSync;
        }
    }
    void SetCompiler(const wxString& compiler) { this->m_compiler = compiler; }
    const wxString& GetCompiler() const { return m_compiler; }
    clFileSystemWorkspaceConfig();
    ~clFileSystemWorkspaceConfig() {}
    void SetRemoteFolder(const wxString& remoteFolder) { this->m_remoteFolder = remoteFolder; }
    const wxString& GetRemoteFolder() const { return m_remoteFolder; }
    void SetRemoteAccount(const wxString& remoteAccount) { this->m_remoteAccount = remoteAccount; }
    const wxString& GetRemoteAccount() const { return m_remoteAccount; }
    clFileSystemWorkspaceConfig::Ptr_t Clone() const;
    void SetDebugger(const wxString& debugger) { this->m_debugger = debugger; }
    const wxString& GetDebugger() const { return m_debugger; }
    void SetWorkingDirectory(const wxString& workingDirectory) { this->m_workingDirectory = workingDirectory; }
    const wxString& GetWorkingDirectory() const { return m_workingDirectory; }
    void SetExcludePaths(const wxString& paths) { m_excludePaths = paths; }
    const wxString& GetExecludePaths() const { return m_excludePaths; }
    bool IsRemoteBuild() const { return m_flags & kRemoteBuild; }
    void SetRemoteBuild(bool b)
    {
        if(b) {
            m_flags |= kRemoteBuild;
        } else {
            m_flags &= ~kRemoteBuild;
        }
    }

    wxArrayString ExpandUserCompletionFlags(const wxString& workingDirectory, clBacktickCache::ptr_t backticks,
                                            bool withPrefix = false) const;
    wxArrayString GetCompilerOptions(clBacktickCache::ptr_t backticks) const;
    /**
     * @brief based on the workspace directory, return list of all folders that contain
     * C/C++ header file
     */
    wxArrayString GetWorkspaceIncludes(bool withPrefix = false) const;
    void SetDebuggerCommands(const wxString& debuggerCommands) { this->m_debuggerCommands = debuggerCommands; }
    void SetDebuggerPath(const wxString& debuggerPath) { this->m_debuggerPath = debuggerPath; }
    const wxString& GetDebuggerCommands() const { return m_debuggerCommands; }
    const wxString& GetDebuggerPath() const { return m_debuggerPath; }
    void SetLastExecutables(const wxArrayString& lastExecutables);
    const wxArrayString& GetLastExecutables() const;
};

class WXDLLIMPEXP_SDK clFileSystemWorkspaceSettings
{
    // Workspace settings
    // we use map to keep the entries sorted
    std::map<wxString, clFileSystemWorkspaceConfig::Ptr_t> m_configsMap;
    wxString m_selectedConfig;
    wxString m_workspaceType;
    wxString m_name;

protected:
    void ToJSON(JSONItem& shared, JSONItem& local) const;
    void FromJSON(const JSONItem& shared, const JSONItem& local);

public:
    clFileSystemWorkspaceSettings();
    virtual ~clFileSystemWorkspaceSettings();

    bool Save(const wxFileName& filename, const wxFileName& localSettings = {});
    bool Load(const wxFileName& filename, const wxFileName& localSettings = {});

    bool AddConfig(const wxString& name, const wxString& copyfrom = wxEmptyString);
    bool DeleteConfig(const wxString& name);
    bool SetSelectedConfig(const wxString& name);
    clFileSystemWorkspaceConfig::Ptr_t GetSelectedConfig() const;
    clFileSystemWorkspaceConfig::Ptr_t GetConfig(const wxString& name) const;
    const std::map<wxString, clFileSystemWorkspaceConfig::Ptr_t>& GetConfigsMap() const { return m_configsMap; }
    wxArrayString GetConfigs() const;
    const wxString& GetName() const { return m_name; }
    void SetName(const wxString& name) { this->m_name = name; }
    void Clear();

    /**
     * @brief check if the file is a valid workspace
     */
    static bool IsOk(const wxFileName& filename);
};

wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_FSW_SETTINGS_SAVED, clCommandEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_SDK, wxEVT_FSW_SETTINGS_LOADED, clCommandEvent);
#endif // CLFILESYSTEMWORKSPACECONFIG_HPP