-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExporterBase.cpp
123 lines (100 loc) · 2.56 KB
/
ExporterBase.cpp
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
// System include files
#include <wx/regex.h>
#include <wx/textfile.h>
// CB include files
#include <sdk.h> // Code::Blocks SDK
// ProjectExporter include files
#include "ExporterBase.h"
ExporterBase::ExporterBase()
{
//ctor
}
ExporterBase::~ExporterBase()
{
//dtor
}
wxString ExporterBase::ConvertSlash(const wxString & source)
{
wxString output = source;
output.Replace("\\", "/");
return output;
}
wxArrayString ExporterBase::IncludeFilesArray()
{
wxArrayString output;
wxRegEx findInclude("^[[:blank:]]*#[[:blank:]]*include[[:blank:]]*<([^\">]+)>");
for (FilesList::iterator i = m_project->GetFilesList().begin(); i != m_project->GetFilesList().end(); i++)
{
ProjectFile * pf = *i;
//bufferString << "\", \"" << ConvertSlash(pf->relativeFilename);
wxTextFile file(pf->relativeFilename);
if (file.Open())
{
for (unsigned int j = 0; j < file.GetLineCount(); j++)
{
wxString bufferString = file.GetLine(j);
if (findInclude.Matches(bufferString))
{
bufferString = findInclude.GetMatch(bufferString, 1);
if (output.Index(bufferString) == wxNOT_FOUND)
{
output.Add(bufferString);
}
}
}
}
file.Close();
}
output.Sort();
return output;
}
wxArrayString ExporterBase::AppendOptionsArray(const wxArrayString & proj, const wxArrayString & targ, const OptionsRelation relation)
{
wxArrayString output = proj;
switch (relation)
{
case orUseTargetOptionsOnly:
{
output = targ;
break;
}
case orPrependToParentOptions:
{
WX_PREPEND_ARRAY(output, targ);
break;
}
case orAppendToParentOptions:
{
WX_APPEND_ARRAY(output, targ);
}
default:
;
}
return output;
}
wxString ExporterBase::ReplSpace(const wxString & source)
{
wxString output = source;
output.Replace("&", "and");
output.Replace(" ", "_");
return output;
}
wxString ExporterBase::RemLib(const wxString & source)
{
if ("lib" == source.Left(3))
{
return source.Mid(3);
}
return source;
}
bool ExporterBase::StringExists(const wxArrayString & source, wxString target)
{
for (unsigned int i = 0; i < source.Count(); i++)
{
if (source[i] == target)
{
return true;
}
}
return false;
}