Code::Blocks  SVN r11506
compileroptions.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  *
5  * $Revision: 9819 $
6  * $Id: compileroptions.cpp 9819 2014-06-22 13:37:24Z mortenmacfly $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/sdk/compileroptions.cpp $
8  */
9 
10 #include "sdk_precomp.h"
11 #include "compileroptions.h"
12 
14 {
15 }
16 
18 {
19  // copy ctor
20  *this = other;
21 }
22 
24 {
25  ClearOptions();
26  for (unsigned int i = 0; i < other.m_Options.GetCount(); ++i)
27  {
28  CompOption* coption = new CompOption(*(other.m_Options[i]));
29  AddOption(coption);
30  }
31  return *this;
32 }
33 
35 {
36  ClearOptions();
37 }
38 
40 {
41  for (unsigned int i = 0; i < m_Options.GetCount(); ++i)
42  {
43  CompOption* coption = m_Options.Item(i);
44  delete coption;
45  }
46  m_Options.Clear();
47 }
48 
49 void CompilerOptions::AddOption(CompOption* coption, int index)
50 {
51  if (index == -1)
52  m_Options.Add(coption);
53  else
54  m_Options.Insert(coption, index);
55 }
56 
58  const wxString& option,
59  const wxString& category,
60  const wxString& additionalLibs,
61  const wxString& checkAgainst,
62  const wxString& checkMessage,
63  const wxString& supersedes,
64  bool exclusive,
65  int index)
66 {
67  if (name.IsEmpty() || (option.IsEmpty() && additionalLibs.IsEmpty()))
68  return;
69  CompOption* coption = new CompOption;
70 
71  wxString listboxname = name + _T(" [");
72  if (option.IsEmpty())
73  listboxname += additionalLibs;
74  else
75  listboxname += option;
76  listboxname += _T("]");
77 
78  coption->name = listboxname;
79  coption->option = option;
80  coption->additionalLibs = additionalLibs;
81  coption->enabled = false;
82  coption->category = category;
83  coption->checkAgainst = checkAgainst;
84  coption->checkMessage = checkMessage;
85  coption->supersedes = supersedes;
86  coption->exclusive = exclusive;
87  AddOption(coption, index);
88 }
89 
91 {
92  CompOption* coption = m_Options.Item(index);
93  delete coption;
94  m_Options.RemoveAt(index);
95 }
96 
98 {
99  for (unsigned int i = 0; i < m_Options.GetCount(); ++i)
100  {
101  CompOption* coption = m_Options.Item(i);
102  if (coption->name == name)
103  return coption;
104  }
105  return nullptr;
106 }
107 
109 {
110  if (option.IsEmpty()) return nullptr;
111 
112  for (unsigned int i = 0; i < m_Options.GetCount(); ++i)
113  {
114  CompOption* coption = m_Options.Item(i);
115  if (coption->option == option)
116  return coption;
117  }
118  return nullptr;
119 }
120 
122 {
123  if (libs.IsEmpty()) return nullptr;
124 
125  for (unsigned int i = 0; i < m_Options.GetCount(); ++i)
126  {
127  CompOption* coption = m_Options.Item(i);
128  if (coption->additionalLibs == libs)
129  return coption;
130  }
131  return nullptr;
132 }
wxString additionalLibs
CompilerOptions & operator=(const CompilerOptions &other)
wxString supersedes
#define _T(string)
OptionsArray m_Options
wxString name
CompOption * GetOptionByName(const wxString &name)
wxString option
wxString category
wxString checkMessage
bool IsEmpty() const
void AddOption(CompOption *coption, int index=-1)
CompOption * GetOptionByAdditionalLibs(const wxString &libs)
wxString checkAgainst
void RemoveOption(int index)
CompOption * GetOptionByOption(const wxString &option)