本文整理汇总了C++中wxArrayString::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ wxArrayString::Add方法的具体用法?C++ wxArrayString::Add怎么用?C++ wxArrayString::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxArrayString
的用法示例。
在下文中一共展示了wxArrayString::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessFile
void HeadersDetectorDlg::ProcessFile( ProjectFile* file, wxArrayString& includes )
{
// We do not care about proper encoding right now.
// Libraries should never use any native characters in names
// of their includes and in case of any multibyte encoding
// multibyte charcters shouldn't hurt us
// Encoding detector tends to work really slow in some cases
wxString Ext = file->file.GetExt();
Ext.MakeLower();
static const wxChar* Exts[] =
{
_T("h"), _T("hxx"), _T("hpp"),
_T("c"), _T("cpp"), _T("cxx"),
0
};
bool validExt = false;
for ( const wxChar** ptr = Exts; *ptr; ptr++ )
{
if ( Ext == *ptr )
{
validExt = true;
break;
}
}
if ( !validExt )
return;
wxFile fl( file->file.GetFullPath() );
if ( !fl.IsOpened() ) return;
wxFileOffset contentLength = fl.Length();
if ( contentLength <= 0 )
return;
char* content = new char[contentLength+1];
char* line = new char[contentLength+1];
if ( fl.Read(content,contentLength) != contentLength )
{
delete[] line;
delete[] content;
return;
}
content[contentLength] = 0;
bool blockComment = false;
for ( size_t pos = 0; pos < static_cast<size_t>(contentLength); )
{
// Fetching next line
char last = 0;
bool lineEnd = false;
int lineLength = 0;
bool lineComment = false;
bool inStr = false;
bool inChar = false;
bool lastCharAdded = false;
do
{
char ch = content[pos++];
bool thisCharAdded = false;
switch ( ch )
{
case '\n':
if ( content[pos] == '\r' )
pos++;
// Continue to \r
case '\r':
if ( last != '\\' )
{
lineEnd = true;
break;
}
else if ( lastCharAdded )
{
// Removing last char since it was '\'
// which is removed in the
// preprocessor level
lineLength--;
}
break;
case '*':
if ( blockComment )
{
if ( content[pos] == '/' )
{
pos++;
blockComment = false;
break;
}
}
else if ( !lineComment )
{
thisCharAdded = true;
line[lineLength++] = ch;
}
break;
//.........这里部分代码省略.........
示例2: CreateListControl
bool CFilterConditionsDialog::CreateListControl(int conditions /*=common*/)
{
wxScrolledWindow* wnd = XRCCTRL(*this, "ID_CONDITIONS", wxScrolledWindow);
if (!wnd)
return false;
m_pListCtrl = new wxCustomHeightListCtrl(this, wxID_ANY, wxDefaultPosition, wnd->GetSize(), wxVSCROLL|wxSUNKEN_BORDER|wxTAB_TRAVERSAL);
if (!m_pListCtrl)
return false;
m_pListCtrl->AllowSelection(false);
ReplaceControl(wnd, m_pListCtrl);
CalcMinListWidth();
if (stringConditionTypes.IsEmpty())
{
stringConditionTypes.Add(_("contains"));
stringConditionTypes.Add(_("is equal to"));
stringConditionTypes.Add(_("begins with"));
stringConditionTypes.Add(_("ends with"));
stringConditionTypes.Add(_("matches regex"));
stringConditionTypes.Add(_("does not contain"));
sizeConditionTypes.Add(_("greater than"));
sizeConditionTypes.Add(_("equals"));
sizeConditionTypes.Add(_("does not equal"));
sizeConditionTypes.Add(_("less than"));
attributeSetTypes.Add(_("is set"));
attributeSetTypes.Add(_("is unset"));
attributeConditionTypes.Add(_("Archive"));
attributeConditionTypes.Add(_("Compressed"));
attributeConditionTypes.Add(_("Encrypted"));
attributeConditionTypes.Add(_("Hidden"));
attributeConditionTypes.Add(_("Read-only"));
attributeConditionTypes.Add(_("System"));
permissionConditionTypes.Add(_("owner readable"));
permissionConditionTypes.Add(_("owner writeable"));
permissionConditionTypes.Add(_("owner executable"));
permissionConditionTypes.Add(_("group readable"));
permissionConditionTypes.Add(_("group writeable"));
permissionConditionTypes.Add(_("group executable"));
permissionConditionTypes.Add(_("world readable"));
permissionConditionTypes.Add(_("world writeable"));
permissionConditionTypes.Add(_("world executable"));
dateConditionTypes.Add(_("before"));
dateConditionTypes.Add(_("equals"));
dateConditionTypes.Add(_("does not equal"));
dateConditionTypes.Add(_("after"));
}
if (conditions & filter_name)
{
filterTypes.Add(_("Filename"));
filter_type_map.push_back(filter_name);
}
if (conditions & filter_size)
{
filterTypes.Add(_("Filesize"));
filter_type_map.push_back(filter_size);
}
if (conditions & filter_attributes)
{
filterTypes.Add(_("Attribute"));
filter_type_map.push_back(filter_attributes);
}
if (conditions & filter_permissions)
{
filterTypes.Add(_("Permission"));
filter_type_map.push_back(filter_permissions);
}
if (conditions & filter_path)
{
filterTypes.Add(_("Path"));
filter_type_map.push_back(filter_path);
}
if (conditions & filter_date)
{
filterTypes.Add(_("Date"));
filter_type_map.push_back(filter_date);
}
SetFilterCtrlState(true);
m_pListCtrl->Connect(wxEVT_SIZE, wxSizeEventHandler(CFilterConditionsDialog::OnListSize), 0, this);
m_pListCtrl->MoveAfterInTabOrder(XRCCTRL(*this, "ID_MATCHTYPE", wxChoice));
return true;
}
示例3: Locate
void IncludePathLocator::Locate(wxArrayString& paths, wxArrayString &excludePaths, bool thirdPartyLibs, const wxString &tool) {
// Common compiler paths - should be placed at top of the include path!
wxString tmpfile1 = wxFileName::CreateTempFileName(wxT("codelite"));
wxString command;
wxString tmpfile = tmpfile1;
tmpfile += wxT(".cpp");
wxString bin = tool;
if(bin.IsEmpty()) {
bin = wxT("gcc");
}
wxRenameFile(tmpfile1, tmpfile);
// GCC prints parts of its output to stdout and some to stderr
// redirect all output to stdout
#if defined(__WXMAC__) || defined(__WXGTK__)
// Mac does not like the standard command
command = wxString::Format(wxT("%s -v -x c++ /dev/null -fsyntax-only"), bin.c_str());
#else
command = wxString::Format(wxT("%s -v -x c++ %s -fsyntax-only"), bin.c_str(), tmpfile.c_str());
#endif
wxString outputStr = wxShellExec(command, wxEmptyString);
wxRemoveFile( tmpfile );
wxArrayString outputArr = wxStringTokenize(outputStr, wxT("\n\r"), wxTOKEN_STRTOK);
// Analyze the output
bool collect(false);
for(size_t i=0; i<outputArr.GetCount(); i++) {
if(outputArr[i].Contains(wxT("#include <...> search starts here:"))) {
collect = true;
continue;
}
if(outputArr[i].Contains(wxT("End of search list."))) {
break;
}
if(collect) {
wxString file = outputArr.Item(i).Trim().Trim(false);
// on Mac, (framework directory) appears also,
// but it is harmless to use it under all OSs
file.Replace(wxT("(framework directory)"), wxT(""));
file.Trim().Trim(false);
wxFileName includePath(file, wxT(""));
includePath.Normalize();
paths.Add( includePath.GetPath() );
}
}
if(thirdPartyLibs) {
// try to locate QMAKE
wxFileConfig qmakeConf(wxEmptyString, wxEmptyString, m_mgr->GetStartupDirectory() + wxT("/config/qmake.ini"));
wxString groupName;
long index(0);
wxArrayString out;
wxString qmake(wxT("qmake"));
if (qmakeConf.GetFirstGroup(groupName, index)) {
// we got qmake configuration, use it instead of the default qmake command
qmake = qmakeConf.Read(groupName + wxT("/qmake"));
}
// Run: qmake -query QT_INSTALL_PREFIX
wxString cmd;
cmd << qmake << wxT(" -query QT_INSTALL_PREFIX");
#ifdef __WXGTK__
cmd << wxT(" 2>/dev/null");
#endif
out = ExecCommand(cmd);
if (out.IsEmpty() == false ) {
wxString qt_output (out.Item(0));
qt_output.Trim().Trim(false);
#if defined(__WXGTK__)||defined(__WXMAC__)
wxString pathQt4, pathQt3, pathQt;
pathQt4 << qt_output << wxFileName::GetPathSeparator() << wxT("include") << wxFileName::GetPathSeparator() << wxT("qt4");
pathQt3 << qt_output << wxFileName::GetPathSeparator() << wxT("include") << wxFileName::GetPathSeparator() << wxT("qt3");
pathQt << qt_output << wxFileName::GetPathSeparator() << wxT("include");
if (wxDir::Exists( pathQt4 )) {
wxString tmpPath;
tmpPath = pathQt4 + wxT("/QtCore");
if(wxFileName::DirExists(tmpPath))
paths.Add( tmpPath );
tmpPath = pathQt4 + wxT("/QtGui");
if(wxFileName::DirExists(tmpPath))
paths.Add( tmpPath );
//.........这里部分代码省略.........
示例4: GetIncludeFile
void ListCtrlWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/listctrl.h>")); }
示例5: Execute
/*! \brief Run the dialogue.
*
* \param aItems wxArrayString&
* \return bool
*
*/
bool wxsImageComboEditorDlg::Execute(wxArrayString &aItems)
{
int i,n;
int j,k;
long ll;
wxString ss, tt;
wxTreeItemId root;
wxTreeItemId item;
wxTreeItemIdValue cookie;
wxBitmap bmp;
wxsImageList *ilist;
// get name of combo-box and image-list
n = aItems.GetCount();
if(n == 0){
m_ComboName = _("<unknown>");
m_ImageName = _("<none>");
}
else if(n == 1){
m_ComboName = aItems.Item(0);
m_ImageName = _("<none>");
}
else{
m_ComboName = aItems.Item(0);
m_ImageName = aItems.Item(1);
}
// show the names
ss = _("Combo Box: ") + m_ComboName;
StaticText1->SetLabel(ss);
ss = _("Image List: ") + m_ImageName;
StaticText9->SetLabel(ss);
// a valid image-list given?
m_ImageList.RemoveAll();
ilist = (wxsImageList *) wxsImageListEditorDlg::FindTool(NULL, m_ImageName);
if(ilist == NULL){
m_pCmbImage->Enable(false);
}
else{
m_pCmbImage->Enable(true);
ilist->GetImageList(m_ImageList);
}
// setup the combo-box image selector
m_pCmbImage->Clear();
m_pCmbImage->Append(_("<none>"));
n = m_ImageList.GetImageCount();
for(i=0; i<n; i++){
ss.Printf(_T("%3d"), i);
bmp = m_ImageList.GetBitmap(i);
m_pCmbImage->Append(ss, bmp);
}
m_pCmbImage->SetSelection(0);
// clear old junk
m_pTree->DeleteAllItems();
// make a root item
root = m_pTree->AddRoot(_("root"));
// make sure we are using the image list -- even if it is empty
m_pTree->SetImageList(&m_ImageList);
// add all the new items
n = aItems.GetCount();
for(i = 2;i < n;i++){
ss = aItems.Item(i);
j = ss.Find(_T(","));
k = -1;
if(j != wxNOT_FOUND){
tt = ss.Left(j);
ss.erase(0, j + 1);
if(tt.ToLong(&ll)) k = ll;
}
item = m_pTree->AppendItem(root, ss, k);
}
// show the dialog and wait for a response
n = ShowModal();
// save all new stuff?
if(n == wxOK){
// must save combo-box name and image-list name
aItems.Clear();
aItems.Add(m_ComboName);
aItems.Add(m_ImageName);
// fetch the actual root item, it might have been recreated or
//.........这里部分代码省略.........
示例6: GetFootprintLibraryList
bool GITHUB_GETLIBLIST::GetFootprintLibraryList( wxArrayString& aList )
{
std::string fullURLCommand;
int page = 1;
int itemCountMax = 99; // Do not use a valu > 100, it does not work
strcpy( m_option_string, "application/json" );
// Github max items returned is 100 per page
if( !repoURL2listURL( m_repoURL, &fullURLCommand, itemCountMax, page ) )
{
wxString msg = wxString::Format( _( "malformed URL:\n'%s'" ), GetChars( m_repoURL ) );
wxMessageBox( msg );
return false;
}
// The URL lib names are relative to the server name.
// so add the server name to them.
wxURI repo( m_repoURL );
wxString urlPrefix = repo.GetScheme() + wxT( "://" ) + repo.GetServer() + wxT( "/" );
wxString errorMsg;
const char sep = ','; // Separator fields, in json returned file
wxString tmp;
int items_count_per_page = 0;
std::string& json_image = GetBuffer();
while( 1 )
{
bool success = remoteGetJSON( fullURLCommand, &errorMsg );
if( !success )
{
wxMessageBox( errorMsg );
return false;
}
for( unsigned ii = 0; ii < json_image.size(); ii++ )
{
if( json_image[ii] == sep || ii == json_image.size() - 1 )
{
if( tmp.StartsWith( wxT( "\"full_name\"" ) ) )
{
#define QUOTE '\"'
// Remove useless quotes:
if( tmp[tmp.Length() - 1] == QUOTE )
tmp.RemoveLast();
if( tmp.EndsWith( m_libs_ext ) )
{
aList.Add( tmp.AfterLast( ':' ) );
int idx = aList.GetCount() - 1;
if( aList[idx][0] == QUOTE )
aList[idx].Remove( 0, 1 );
aList[idx].Prepend( urlPrefix );
}
items_count_per_page++;
}
tmp.Clear();
}
else
tmp << json_image[ii];
}
if( items_count_per_page >= itemCountMax )
{
page++;
repoURL2listURL( m_repoURL, &fullURLCommand, itemCountMax, page );
items_count_per_page = 0;
ClearBuffer();
}
else
break;
}
aList.Sort();
return true;
}
示例7: GetRecents
void eSettings::GetRecents(const wxJSONValue& jarray, wxArrayString& recents) const {
for (int i = 0; i < jarray.Size(); ++i) {
recents.Add(jarray.ItemAt(i).AsString());
}
}
示例8: GetIncludeFile
void ChoiceBookWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/choicebk.h>")); }
示例9: FindFunctions
void wxsEventsEditor::FindFunctions(const wxString& ArgType,wxArrayString& Array)
{
wxString Code = wxsCoder::Get()->GetCode(m_Header,
wxsCodeMarks::Beg(m_Language,_T("Handlers"),m_Class),
wxsCodeMarks::End(m_Language),
false,false);
switch ( m_Language )
{
case wxsCPP:
{
// Basic parsing
for(;;)
{
// Searching for void statement - it may begin new fuunction declaration
int Pos = Code.Find(_T("void"));
if ( Pos == -1 ) break;
// Removing all before function name
Code.Remove(0,Pos+4).Trim(false);
// Getting function name
Pos = 0;
while ( (int)Code.Length() > Pos )
{
wxChar First = Code.GetChar(Pos);
if ( ( First<_T('A') || First>_T('Z') ) &&
( First<_T('a') || First>_T('z') ) &&
( First<_T('0') || First>_T('9') ) &&
( First!=_T('_') ) )
{
break;
}
Pos++;
}
wxString NewFunctionName = Code.Mid(0,Pos);
Code.Remove(0,Pos).Trim(false);
if ( !Code.Length() ) break;
// Parsing arguments
if ( Code.GetChar(0) != _T('(') ) continue;
Code.Remove(0,1).Trim(false);
if ( !Code.Length() ) break;
// Getting argument type
Pos = 0;
while ( (int)Code.Length() > Pos )
{
wxChar First = Code.GetChar(Pos);
if ( ( First<_T('A') || First>_T('Z') ) &&
( First<_T('a') || First>_T('z') ) &&
( First<_T('0') || First>_T('9') ) &&
( First!=_T('_') ) )
{
break;
}
Pos++;
}
wxString NewEventType = Code.Mid(0,Pos);
Code.Remove(0,Pos).Trim(false);
if ( !Code.Length() ) break;
// Checking if the rest of declaratin is valid
if ( Code.GetChar(0) != _T('&') ) continue;
Code.Remove(0,1).Trim(false);
if ( !Code.Length() ) break;
// Skipping argument name
Pos = 0;
while ( (int)Code.Length() > Pos )
{
wxChar First = Code.GetChar(Pos);
if ( ( First<_T('A') || First>_T('Z') ) &&
( First<_T('a') || First>_T('z') ) &&
( First<_T('0') || First>_T('9') ) &&
( First!=_T('_') ) )
{
break;
}
Pos++;
}
Code.Remove(0,Pos).Trim(false);
if ( !Code.Length() ) break;
if ( Code.GetChar(0) != _T(')') ) continue;
Code.Remove(0,1).Trim(false);
if ( !Code.Length() ) break;
if ( Code.GetChar(0) != _T(';') ) continue;
Code.Remove(0,1).Trim(false);
if ( NewFunctionName.Length() == 0 || NewEventType.Length() == 0 ) continue;
// We got new function, checking event type and adding to array
if ( !ArgType.Length() || ArgType == NewEventType )
{
Array.Add(NewFunctionName);
//.........这里部分代码省略.........
示例10: wxGetAvailableDrives
size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids)
{
#ifdef wxHAS_FILESYSTEM_VOLUMES
#ifdef __WXWINCE__
// No logical drives; return "\"
paths.Add(wxT("\\"));
names.Add(wxT("\\"));
icon_ids.Add(wxFileIconsTable::computer);
#elif defined(__WIN32__) && wxUSE_FSVOLUME
// TODO: this code (using wxFSVolumeBase) should be used for all platforms
// but unfortunately wxFSVolumeBase is not implemented everywhere
const wxArrayString as = wxFSVolumeBase::GetVolumes();
for (size_t i = 0; i < as.GetCount(); i++)
{
wxString path = as[i];
wxFSVolume vol(path);
int imageId;
switch (vol.GetKind())
{
case wxFS_VOL_FLOPPY:
if ( (path == wxT("a:\\")) || (path == wxT("b:\\")) )
imageId = wxFileIconsTable::floppy;
else
imageId = wxFileIconsTable::removeable;
break;
case wxFS_VOL_DVDROM:
case wxFS_VOL_CDROM:
imageId = wxFileIconsTable::cdrom;
break;
case wxFS_VOL_NETWORK:
if (path[0] == wxT('\\'))
continue; // skip "\\computer\folder"
imageId = wxFileIconsTable::drive;
break;
case wxFS_VOL_DISK:
case wxFS_VOL_OTHER:
default:
imageId = wxFileIconsTable::drive;
break;
}
paths.Add(path);
names.Add(vol.GetDisplayName());
icon_ids.Add(imageId);
}
#elif defined(__OS2__)
APIRET rc;
ULONG ulDriveNum = 0;
ULONG ulDriveMap = 0;
rc = ::DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);
if ( rc == 0)
{
size_t i = 0;
while (i < 26)
{
if (ulDriveMap & ( 1 << i ))
{
const wxString path = wxFileName::GetVolumeString(
'A' + i, wxPATH_GET_SEPARATOR);
const wxString name = wxFileName::GetVolumeString(
'A' + i, wxPATH_NO_SEPARATOR);
// Note: If _filesys is unsupported by some compilers,
// we can always replace it by DosQueryFSAttach
char filesysname[20];
#ifdef __WATCOMC__
ULONG cbBuffer = sizeof(filesysname);
PFSQBUFFER2 pfsqBuffer = (PFSQBUFFER2)filesysname;
APIRET rc = ::DosQueryFSAttach(name.fn_str(),0,FSAIL_QUERYNAME,pfsqBuffer,&cbBuffer);
if (rc != NO_ERROR)
{
filesysname[0] = '\0';
}
#else
_filesys(name.fn_str(), filesysname, sizeof(filesysname));
#endif
/* FAT, LAN, HPFS, CDFS, NFS */
int imageId;
if (path == wxT("A:\\") || path == wxT("B:\\"))
imageId = wxFileIconsTable::floppy;
else if (!strcmp(filesysname, "CDFS"))
imageId = wxFileIconsTable::cdrom;
else if (!strcmp(filesysname, "LAN") ||
!strcmp(filesysname, "NFS"))
imageId = wxFileIconsTable::drive;
else
imageId = wxFileIconsTable::drive;
paths.Add(path);
names.Add(name);
icon_ids.Add(imageId);
}
i ++;
}
}
#else // !__WIN32__, !__OS2__
/* If we can switch to the drive, it exists. */
for ( char drive = 'A'; drive <= 'Z'; drive++ )
{
const wxString
//.........这里部分代码省略.........
示例11: GetIncludeFile
void DataViewListCtrlWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/dataview.h>"); }
示例12: GetIncludeFile
void GLCanvasWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/glcanvas.h>"); }
示例13: wxLogMessage
// ----------------------------------------------------------------------------
// Initialize importer
bool
GStreamerImportFileHandle::Init()
{
// Create a URI from the filename
mUri = g_strdup_printf("file:///%s", mFilename.ToUTF8().data());
if (!mUri)
{
wxLogMessage(wxT("GStreamerImport couldn't create URI"));
return false;
}
// Create the stream context array
mStreams = g_ptr_array_new();
if (!mStreams)
{
wxLogMessage(wxT("GStreamerImport couldn't create context array"));
return false;
}
// Create a pipeline
mPipeline = gst_pipeline_new("pipeline");
// Get its bus
mBus = gst_pipeline_get_bus(GST_PIPELINE(mPipeline));
// Create uridecodebin and set up signal handlers
mDec = gst_element_factory_make("uridecodebin", "decoder");
g_signal_connect(mDec, "autoplug-select", G_CALLBACK(GStreamerAutoplugSelectCallback), (gpointer) this);
g_signal_connect(mDec, "pad-added", G_CALLBACK(GStreamerPadAddedCallback), (gpointer) this);
g_signal_connect(mDec, "pad-removed", G_CALLBACK(GStreamerPadRemovedCallback), (gpointer) this);
// Set the URI
g_object_set(G_OBJECT(mDec), "uri", mUri, NULL);
// Add the decoder to the pipeline
if (!gst_bin_add(GST_BIN(mPipeline), mDec))
{
wxMessageBox(wxT("Unable to add decoder to pipeline"),
wxT("GStreamer Importer"));
// Cleanup expected to occur in destructor
return false;
}
// Run the pipeline
GstStateChangeReturn state = gst_element_set_state(mPipeline, GST_STATE_PAUSED);
if (state == GST_STATE_CHANGE_FAILURE)
{
wxMessageBox(wxT("Unable to set stream state to paused."),
wxT("GStreamer Importer"));
return false;
}
// Collect info while the stream is prerolled
//
// Unfortunately, for some files this may cause a slight "pause" in the GUI
// without a progress dialog appearing. Not much can be done about it other
// than throwing up an additional progress dialog and displaying two dialogs
// may be confusing to the users.
// Process messages until we get an error or the ASYNC_DONE message is received
bool success;
while (ProcessBusMessage(success) && success)
{
// Give wxWidgets a chance to do housekeeping
wxSafeYield();
}
// Build the stream info array
g_mutex_lock(&mStreamsLock);
for (guint i = 0; i < mStreams->len; i++)
{
GStreamContext *c = (GStreamContext *) g_ptr_array_index(mStreams, i);
// Create stream info string
wxString strinfo;
strinfo.Printf(wxT("Index[%02d], Type[%s], Channels[%d], Rate[%d]"),
(unsigned int) i,
wxString::FromUTF8(c->mType).c_str(),
(int) c->mNumChannels,
(int) c->mSampleRate);
mStreamInfo.Add(strinfo);
}
g_mutex_unlock(&mStreamsLock);
return success;
}
示例14: GetDefinitionsAndSearchPaths
bool CodeCompletionManager::GetDefinitionsAndSearchPaths(clEditor* editor, wxArrayString& searchPaths,
wxArrayString& definitions)
{
// Sanity
CHECK_PTR_RET_FALSE(editor);
if(editor->GetProjectName().IsEmpty()) return false;
if(!clCxxWorkspaceST::Get()->IsOpen()) return false;
// Support only C/C++ files
if(!FileExtManager::IsCxxFile(editor->GetFileName().GetFullName())) return false;
// Get the file's project and get the build configuration settings
// for it
ProjectPtr proj = clCxxWorkspaceST::Get()->GetProject(editor->GetProjectName());
CHECK_PTR_RET_FALSE(proj);
BuildConfigPtr buildConf = proj->GetBuildConfiguration();
CHECK_PTR_RET_FALSE(buildConf);
CompilerPtr compiler = buildConf->GetCompiler();
CHECK_PTR_RET_FALSE(compiler);
#if 0
if(buildConf->IsCustomBuild()) {
definitions = proj->GetPreProcessors();
CL_DEBUG("CxxPreProcessor will use the following macros:");
CL_DEBUG_ARR(definitions);
// Custom builds are handled differently
CompilationDatabase compileDb;
compileDb.Open();
if(compileDb.IsOpened()) {
// we have compilation database for this workspace
wxString compileLine, cwd;
compileDb.CompilationLine(editor->GetFileName().GetFullPath(), compileLine, cwd);
CL_DEBUG("Pre Processor dimming: %s\n", compileLine);
CompilerCommandLineParser cclp(compileLine, cwd);
searchPaths = cclp.GetIncludes();
// get the mcros
definitions << cclp.GetMacros();
}
}
#endif
// get the include paths based on the project settings (this is per build configuration)
searchPaths = proj->GetIncludePaths();
CL_DEBUG("CxxPreProcessor will use the following include paths:");
CL_DEBUG_ARR(searchPaths);
// get the compiler include paths
// wxArrayString compileIncludePaths = compiler->GetDefaultIncludePaths();
// includePaths.insert(includePaths.end(), compileIncludePaths.begin(), compileIncludePaths.end());
definitions = proj->GetPreProcessors();
// get macros out of workspace
wxString strWorkspaceMacros = clCxxWorkspaceST::Get()->GetParserMacros();
wxArrayString workspaceMacros = wxStringTokenize(strWorkspaceMacros, wxT("\n\r"), wxTOKEN_STRTOK);
for(size_t i = 0; i < workspaceMacros.GetCount(); i++)
definitions.Add(workspaceMacros.Item(i).Trim().Trim(false).c_str());
CL_DEBUG("CxxPreProcessor will use the following macros:");
CL_DEBUG_ARR(definitions);
// Append the compiler builtin macros
wxArrayString builtinMacros = compiler->GetBuiltinMacros();
definitions.insert(definitions.end(), builtinMacros.begin(), builtinMacros.end());
return true;
}
示例15: ProcessLinkerLibs
void ProjectOptionsManipulator::ProcessLinkerLibs(cbProject* prj, const wxString& lib, const wxString& lib_new, wxArrayString& result)
{
ProjectOptionsManipulatorDlg::EProjectScanOption scan_opt = m_Dlg->GetScanOption();
switch (scan_opt)
{
case ProjectOptionsManipulatorDlg::eSearch:
case ProjectOptionsManipulatorDlg::eSearchNot:
{
if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eProject) )
{
bool has_opt = HasOption(prj->GetLinkLibs(), lib);
if (has_opt && scan_opt==ProjectOptionsManipulatorDlg::eSearch)
{
result.Add(wxString::Format(_("Project '%s': Contains linker lib '%s'."),
prj->GetTitle().wx_str(), lib.wx_str()));
}
else if (!has_opt && scan_opt==ProjectOptionsManipulatorDlg::eSearchNot)
{
result.Add(wxString::Format(_("Project '%s': Does not contain linker lib '%s'."),
prj->GetTitle().wx_str(), lib.wx_str()));
}
}
if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eTarget) )
{
for (int i=0; i<prj->GetBuildTargetsCount(); ++i)
{
ProjectBuildTarget* tgt = prj->GetBuildTarget(i);
if (tgt)
{
bool has_opt = HasOption(tgt->GetLinkLibs(), lib);
if (has_opt && scan_opt==ProjectOptionsManipulatorDlg::eSearch)
{
result.Add(wxString::Format(_("Project '%s', target '%s': Contains linker lib '%s'."),
prj->GetTitle().wx_str(), tgt->GetTitle().wx_str(), lib.wx_str()));
}
else if (!has_opt && scan_opt==ProjectOptionsManipulatorDlg::eSearchNot)
{
result.Add(wxString::Format(_("Project '%s', target '%s': Does not contain linker lib '%s'."),
prj->GetTitle().wx_str(), tgt->GetTitle().wx_str(), lib.wx_str()));
}
}
}
}
}
break;
case ProjectOptionsManipulatorDlg::eRemove:
{
wxString full_lib;
if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eProject) )
{
if ( HasOption(prj->GetLinkLibs(), lib, full_lib) )
prj->RemoveLinkLib(full_lib);
}
if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eTarget) )
{
for (int i=0; i<prj->GetBuildTargetsCount(); ++i)
{
ProjectBuildTarget* tgt = prj->GetBuildTarget(i);
if (tgt && HasOption(tgt->GetLinkLibs(), lib, full_lib))
tgt->RemoveLinkLib(lib);
}
}
}
break;
case ProjectOptionsManipulatorDlg::eAdd:
{
if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eProject) )
{
if ( !HasOption(prj->GetLinkLibs(), lib) )
prj->AddLinkLib(lib);
}
if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eTarget) )
{
for (int i=0; i<prj->GetBuildTargetsCount(); ++i)
{
ProjectBuildTarget* tgt = prj->GetBuildTarget(i);
if (tgt && !HasOption(tgt->GetLinkLibs(), lib))
tgt->AddLinkLib(lib);
}
}
}
break;
case ProjectOptionsManipulatorDlg::eReplace:
{
wxString full_lib;
if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eProject) )
{
if ( HasOption(prj->GetLinkLibs(), lib, full_lib) )
prj->ReplaceLinkLib(full_lib, ManipulateOption(full_lib, lib, lib_new));
}
if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eTarget) )
{
for (int i=0; i<prj->GetBuildTargetsCount(); ++i)
//.........这里部分代码省略.........