void JXFSBindingTable::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsAddButton && message.Is(JXButton::kPushed)) { AddPattern(); } else if (sender == itsRemoveButton && message.Is(JXButton::kPushed)) { RemovePattern(); } else if (sender == itsDuplicateButton && message.Is(JXButton::kPushed)) { DuplicatePattern(); } else if (sender == itsTypeMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdateTypeMenu(); } else if (sender == itsTypeMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast(const JXMenu::ItemSelected*, &message); assert( selection != NULL ); HandleTypeMenu(selection->GetIndex()); } else { if (sender == &(GetTableSelection()))
/** Add a window name to a group. */ void AddGroupName(GroupType *gp, const char *pattern) { Assert(gp); if(JLIKELY(pattern)) { AddPattern(&gp->patterns, pattern, MATCH_NAME); } else { Warning(_("invalid group name")); } }
/** Add a window class to a group. */ void AddGroupClass(GroupType *gp, const char *pattern) { Assert(gp); if(JLIKELY(pattern)) { AddPattern(&gp->patterns, pattern, MATCH_CLASS); } else { Warning(_("invalid group class")); } }
void FastSearchFormat::AddPattern(vector<OBMol>& patternMols, OBMol patternMol, int idx) { //Recursive function to generate all combinations of aromatic/single bonds for each tilde bond //Copying an OBMol, which happens when adding it to a vector, kekulizes it, // changing aromatic (bo=5) bonds. So set order after adding. Should work here, // but is dangerous if the vector needs to be reallocated. if(idx>=patternMol.NumBonds()) return; if(patternMol.GetBond(idx)->GetBO()==4) { patternMol.GetBond(idx)->SetBO(1); patternMols.push_back(patternMol); AddPattern(patternMols, patternMol,idx+1); patternMols.push_back(patternMol); patternMols.back().GetBond(idx)->SetBO(5); } AddPattern(patternMols, patternMol,idx+1); }
void CanvasMessage::AddDrawState(const DrawState& drawState) { Add(drawState.PenSize()); Add(drawState.SubPixelPrecise()); Add(drawState.GetDrawingMode()); Add(drawState.AlphaSrcMode()); Add(drawState.AlphaFncMode()); AddPattern(drawState.GetPattern()); Add(drawState.LineCapMode()); Add(drawState.LineJoinMode()); Add(drawState.MiterLimit()); Add(drawState.HighColor()); Add(drawState.LowColor()); }
void CsxManager<IndexType, ValueType>:: DoRow(typename SparsePartition<IndexType, ValueType>::iterator &rbegin, typename SparsePartition<IndexType, ValueType>::iterator &rend, IndexType row) { vector<IndexType> cols; span_ = 0; last_col_ = 1; typename SparsePartition<IndexType, ValueType>::iterator &ri = rbegin; for (; ri != rend; ++ri) { // LOG_DEBUG << "\t" << *ri << "\n"; // Check if this element contains a pattern. if ((*ri).IsPattern()) { UpdateRowSpan(*ri); PreparePat(cols); assert(cols.size() == 0); AddPattern(*ri); const ValueType *elem_vals = &(*ri).GetValues(); copy(elem_vals, elem_vals + (*ri).GetSize(), values_ + values_idx_); values_idx_ += (*ri).GetSize(); continue; } // Check if we exceeded the maximum size for a unit. assert(cols.size() <= CTL_SIZE_MAX); if (cols.size() == CTL_SIZE_MAX) AddCols(cols); cols.push_back((*ri).GetCol()); values_[values_idx_++] = (*ri).GetValue(); } if (cols.size() > 0) AddCols(cols); }
Compiler::Compiler(wxXmlNode* node, Compiler::eRegexType regexType) : m_objectNameIdenticalToFileName(false) , m_isDefault(false) { // ensure all relevant entries exist in switches map (makes sure they show up in build settings dlg) SetSwitch("Include", ""); SetSwitch("Debug", ""); SetSwitch("Preprocessor", ""); SetSwitch("Library", ""); SetSwitch("LibraryPath", ""); SetSwitch("Source", ""); SetSwitch("Output", ""); SetSwitch("Object", ""); SetSwitch("ArchiveOutput", ""); SetSwitch("PreprocessOnly", ""); // ensure all relevant entries exist in tools map (makes sure they show up in build settings dlg) SetTool("LinkerName", ""); SetTool("SharedObjectLinkerName", ""); SetTool("CXX", ""); SetTool("CC", ""); SetTool("AR", ""); SetTool("ResourceCompiler", ""); SetTool("MAKE", ""); SetTool("AS", "as"); // Assembler, default to as m_fileTypes.clear(); if(node) { m_name = XmlUtils::ReadString(node, wxT("Name")); m_compilerFamily = XmlUtils::ReadString(node, "CompilerFamily"); if(m_compilerFamily == "GNU GCC") { // fix wrong name m_compilerFamily = COMPILER_FAMILY_GCC; } m_isDefault = XmlUtils::ReadBool(node, "IsDefault"); if(!node->HasProp(wxT("GenerateDependenciesFiles"))) { if(m_name == wxT("gnu g++") || m_name == wxT("gnu gcc")) { m_generateDependeciesFile = true; } else m_generateDependeciesFile = false; } else { m_generateDependeciesFile = XmlUtils::ReadBool(node, wxT("GenerateDependenciesFiles")); } if(!node->HasProp(wxT("ReadObjectsListFromFile"))) { m_readObjectFilesFromList = true; } else { m_readObjectFilesFromList = XmlUtils::ReadBool(node, wxT("ReadObjectsListFromFile")); } m_objectNameIdenticalToFileName = XmlUtils::ReadBool(node, wxT("ObjectNameIdenticalToFileName")); wxXmlNode* child = node->GetChildren(); while(child) { if(child->GetName() == wxT("Switch")) { m_switches[XmlUtils::ReadString(child, wxT("Name"))] = XmlUtils::ReadString(child, wxT("Value")); } else if(child->GetName() == wxT("Tool")) { m_tools[XmlUtils::ReadString(child, wxT("Name"))] = XmlUtils::ReadString(child, wxT("Value")); } else if(child->GetName() == wxT("Option")) { wxString name = XmlUtils::ReadString(child, wxT("Name")); if(name == wxT("ObjectSuffix")) { m_objectSuffix = XmlUtils::ReadString(child, wxT("Value")); } else if(name == wxT("DependSuffix")) { m_dependSuffix = XmlUtils::ReadString(child, wxT("Value")); } else if(name == wxT("PreprocessSuffix")) { m_preprocessSuffix = XmlUtils::ReadString(child, wxT("Value")); } } else if(child->GetName() == wxT("File")) { Compiler::CmpFileTypeInfo ft; ft.compilation_line = XmlUtils::ReadString(child, wxT("CompilationLine")); ft.extension = XmlUtils::ReadString(child, wxT("Extension")).Lower(); long kind = (long)CmpFileKindSource; if(XmlUtils::ReadLong(child, wxT("Kind"), kind) == CmpFileKindSource) { ft.kind = CmpFileKindSource; } else { ft.kind = CmpFileKindResource; } m_fileTypes[ft.extension] = ft; } else if(child->GetName() == wxT("Pattern")) { if(XmlUtils::ReadString(child, wxT("Name")) == wxT("Error")) { // found an error description CmpInfoPattern errPattern; errPattern.fileNameIndex = XmlUtils::ReadString(child, wxT("FileNameIndex")); errPattern.lineNumberIndex = XmlUtils::ReadString(child, wxT("LineNumberIndex")); errPattern.columnIndex = XmlUtils::ReadString(child, "ColumnIndex", "-1"); errPattern.pattern = child->GetNodeContent(); m_errorPatterns.push_back(errPattern); } else if(XmlUtils::ReadString(child, wxT("Name")) == wxT("Warning")) { // found a warning description CmpInfoPattern warnPattern; warnPattern.fileNameIndex = XmlUtils::ReadString(child, wxT("FileNameIndex")); warnPattern.lineNumberIndex = XmlUtils::ReadString(child, wxT("LineNumberIndex")); warnPattern.columnIndex = XmlUtils::ReadString(child, "ColumnIndex", "-1"); warnPattern.pattern = child->GetNodeContent(); m_warningPatterns.push_back(warnPattern); } } else if(child->GetName() == wxT("GlobalIncludePath")) { m_globalIncludePath = child->GetNodeContent(); } else if(child->GetName() == wxT("GlobalLibPath")) { m_globalLibPath = child->GetNodeContent(); } else if(child->GetName() == wxT("PathVariable")) { m_pathVariable = child->GetNodeContent(); } else if(child->GetName() == wxT("CompilerOption")) { CmpCmdLineOption cmpOption; cmpOption.name = XmlUtils::ReadString(child, wxT("Name")); cmpOption.help = child->GetNodeContent(); m_compilerOptions[cmpOption.name] = cmpOption; } else if(child->GetName() == wxT("LinkerOption")) { CmpCmdLineOption cmpOption; cmpOption.name = XmlUtils::ReadString(child, wxT("Name")); cmpOption.help = child->GetNodeContent(); m_linkerOptions[cmpOption.name] = cmpOption; } else if(child->GetName() == wxT("InstallationPath")) { m_installationPath = child->GetNodeContent(); } child = child->GetNext(); } if(GetTool("MAKE").IsEmpty()) { BuilderConfigPtr bldr = BuildSettingsConfigST::Get()->GetBuilderConfig(""); if(bldr) { SetTool("MAKE", wxString() << bldr->GetToolPath() << " -j " << bldr->GetToolJobs()); } } // Default values for the assembler if(GetTool("AS").IsEmpty() && GetName().CmpNoCase("vc++") == 0) { SetTool("AS", "nasm"); } else if(GetTool("AS").IsEmpty()) { SetTool("AS", "as"); } // For backward compatibility, if the compiler / linker options are empty - add them if(IsGnuCompatibleCompiler() && m_compilerOptions.empty()) { AddDefaultGnuComplierOptions(); } if(IsGnuCompatibleCompiler() && m_linkerOptions.empty()) { AddDefaultGnuLinkerOptions(); } } else { // Create a default compiler: g++ m_name = ""; m_compilerFamily = COMPILER_FAMILY_GCC; m_isDefault = false; SetSwitch("Include", "-I"); SetSwitch("Debug", "-g "); SetSwitch("Preprocessor", "-D"); SetSwitch("Library", "-l"); SetSwitch("LibraryPath", "-L"); SetSwitch("Source", "-c "); SetSwitch("Output", "-o "); SetSwitch("Object", "-o "); SetSwitch("ArchiveOutput", " "); SetSwitch("PreprocessOnly", "-E"); m_objectSuffix = ".o"; m_preprocessSuffix = ".i"; if(regexType == kRegexGNU) { AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]*)([:0-9]*)(: )((fatal " "error)|(error)|(undefined reference))", 1, 3, 4); AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ " "*)(:)(\\(\\.text\\+[0-9a-fx]*\\))", 3, 1, -1); AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ " "*)(:)([0-9]+)(:)", 3, 1, -1); AddPattern(eErrorPattern, "undefined reference to", -1, -1, -1); AddPattern(eErrorPattern, "\\*\\*\\* \\[[a-zA-Z\\-_0-9 ]+\\] (Error)", -1, -1, -1); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?( warning)", 1, 3, 4); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?( note)", 1, 3, -1); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?([ ]+instantiated)", 1, 3, -1); AddPattern(eWarningPattern, "(In file included from *)([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?", 2, 4, -1); AddDefaultGnuComplierOptions(); AddDefaultGnuLinkerOptions(); } else { AddPattern( eErrorPattern, "^windres: ([a-zA-Z:]{0,2}[ a-zA-Z\\\\.0-9_/\\+\\-]+) *:([0-9]+): syntax error", 1, 2); AddPattern(eErrorPattern, "(^[a-zA-Z\\\\.0-9 _/\\:\\+\\-]+ *)(\\()([0-9]+)(\\))( \\: )(error)", 1, 3); AddPattern(eErrorPattern, "(LINK : fatal error)", 1, 1); AddPattern(eErrorPattern, "(NMAKE : fatal error)", 1, 1); AddPattern(eWarningPattern, "(^[a-zA-Z\\\\.0-9 _/\\:\\+\\-]+ *)(\\()([0-9]+)(\\))( \\: )(warning)", 1, 3); AddPattern(eWarningPattern, "([a-z_A-Z]*\\.obj)( : warning)", 1, 1); AddPattern(eWarningPattern, "(cl : Command line warning)", 1, 1); } SetTool("LinkerName", "g++"); #ifdef __WXMAC__ SetTool("SharedObjectLinkerName", "g++ -dynamiclib -fPIC"); #else SetTool("SharedObjectLinkerName", "g++ -shared -fPIC"); #endif SetTool("CXX", "g++"); SetTool("CC", "gcc"); SetTool("AR", "ar rcu"); SetTool("ResourceCompiler", "windres"); SetTool("AS", "as"); #ifdef __WXMSW__ SetTool("MAKE", "mingw32-make"); #else SetTool("MAKE", "make"); #endif m_globalIncludePath = wxEmptyString; m_globalLibPath = wxEmptyString; m_pathVariable = wxEmptyString; m_generateDependeciesFile = false; m_readObjectFilesFromList = true; m_objectNameIdenticalToFileName = false; } if(m_generateDependeciesFile && m_dependSuffix.IsEmpty()) { m_dependSuffix = m_objectSuffix + wxT(".d"); } if(!m_switches[wxT("PreprocessOnly")].IsEmpty() && m_preprocessSuffix.IsEmpty()) { m_preprocessSuffix = m_objectSuffix + wxT(".i"); } if(m_fileTypes.empty()) { AddCmpFileType("cpp", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("cxx", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("c++", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("c", CmpFileKindSource, "$(CC) $(SourceSwitch) \"$(FileFullPath)\" $(CFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("cc", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("m", CmpFileKindSource, "$(CXX) -x objective-c $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("mm", CmpFileKindSource, "$(CXX) -x objective-c++ $(SourceSwitch) \"$(FileFullPath)\" " "$(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("s", CmpFileKindSource, "$(AS) \"$(FileFullPath)\" $(ASFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "-I$(IncludePath)"); AddCmpFileType("rc", CmpFileKindResource, "$(RcCompilerName) -i \"$(FileFullPath)\" $(RcCmpOptions) " "$(ObjectSwitch)$(IntermediateDirectory)/" "$(ObjectName)$(ObjectSuffix) $(RcIncludePath)"); } // Add support for assembler file if(m_fileTypes.count("s") == 0) { AddCmpFileType("s", CmpFileKindSource, "$(AS) \"$(FileFullPath)\" $(ASFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "-I$(IncludePath)"); } }
bool FastSearchFormat::ObtainTarget(OBConversion* pConv, vector<OBMol>& patternMols, const string& indexname) { //Obtains an OBMol from: // the filename in the -s option or // the SMARTS string in the -s option or // by converting the file in the -S or -aS options (deprecated). // If there is no -s -S or -aS option, information on the index file is displayed. OBMol patternMol; patternMol.SetIsPatternStructure(); const char* p = pConv->IsOption("s",OBConversion::GENOPTIONS); bool OldSOption=false; //If no -s option, make OBMol from file in -S option or -aS option (both deprecated) if(!p) { p = pConv->IsOption("S",OBConversion::GENOPTIONS); if(!p) p = pConv->IsOption("S",OBConversion::INOPTIONS);//for GUI mainly OldSOption = true; } if(p) { vector<string> vec; tokenize(vec, p); //ignore leading ~ (not relevant to fastsearch) if(vec[0][0]=='~') vec[0].erase(0,1); if(vec.size()>1 && vec[1]=="exact") pConv->AddOption("e", OBConversion::INOPTIONS); OBConversion patternConv; OBFormat* pFormat; //Interpret as a filename if possible string& txt =vec [0]; if( txt.empty() || txt.find('.')==string::npos || !(pFormat = patternConv.FormatFromExt(txt.c_str())) || !patternConv.SetInFormat(pFormat) || !patternConv.ReadFile(&patternMol, txt) || patternMol.NumAtoms()==0) //if false, have a valid patternMol from a file { //is SMARTS/SMILES //Replace e.g. [#6] in SMARTS by C so that it can be converted as SMILES //for the fingerprint phase, but allow more generality in the SMARTS phase. for(;;) { string::size_type pos1, pos2; pos1 = txt.find("[#"); if(pos1==string::npos) break; pos2 = txt.find(']'); int atno; if(pos2!=string::npos && (atno = atoi(txt.substr(pos1+2, pos2-pos1-2).c_str())) && atno>0) txt.replace(pos1, pos2-pos1+1, etab.GetSymbol(atno)); else { obErrorLog.ThrowError(__FUNCTION__,"Ill-formed [#n] atom in SMARTS", obError); return false; } } bool hasTildeBond; if( (hasTildeBond = (txt.find('~')!=string::npos)) ) // extra parens to indicate truth value { //Find ~ bonds and make versions of query molecule with a single and aromatic bonds //To avoid having to parse the SMILES here, replace ~ by $ (quadruple bond) //and then replace this in patternMol. Check first that there are no $ already //Sadly, isocynanides may have $ bonds. if(txt.find('$')!=string::npos) { obErrorLog.ThrowError(__FUNCTION__, "Cannot use ~ bonds in patterns with $ (quadruple) bonds.)", obError); return false; } replace(txt.begin(),txt.end(), '~' , '$'); } //read as standard SMILES patternConv.SetInFormat("smi"); if(!patternConv.ReadString(&patternMol, vec[0])) { obErrorLog.ThrowError(__FUNCTION__,"Cannot read the SMILES string",obError); return false; } if(hasTildeBond) { AddPattern(patternMols, patternMol, 0); //recursively add all combinations of tilde bond values return true; } } else { // target(s) are in a file patternMols.push_back(patternMol); while(patternConv.Read(&patternMol)) patternMols.push_back(patternMol); return true; } } if(OldSOption) //only when using deprecated -S and -aS options { //make -s option for later SMARTS test OBConversion conv; if(conv.SetOutFormat("smi")) { string optiontext = conv.WriteString(&patternMol, true); pConv->AddOption("s", OBConversion::GENOPTIONS, optiontext.c_str()); } } if(!p) { //neither -s or -S options provided. Output info rather than doing search const FptIndexHeader& header = fs.GetIndexHeader(); string id(header.fpid); if(id.empty()) id = "default"; clog << indexname << " is an index of\n " << header.datafilename << ".\n It contains " << header.nEntries << " molecules. The fingerprint type is " << id << " with " << OBFingerprint::Getbitsperint() * header.words << " bits.\n" << "Typical usage for a substructure search:\n" << "obabel indexfile.fs -osmi -sSMILES\n" << "(-s option in GUI is 'Convert only if match SMARTS or mols in file')" << endl; return false; } patternMols.push_back(patternMol); return true; }
static int AddPatternFromFile(char* fileName, int mark) { int cflags; int eflags; char pattern[MAX_PATTERN_LEN] = {0}; char line[MAX_LINE_LEN] = {0}; char proto[MAX_PROTO_LEN] = {0}; char* preprocessed = NULL; int rc = 0; char* pos = pattern; int protoLen = 0; int patternLen = 0; enum{protocol, kpattern/*, userspace*/} state = protocol; FILE* theFile = fopen(fileName, "r"); if (theFile == NULL) { fprintf(stderr, "Could't read the file: %s\n", fileName); return 0; } cflags = REG_EXTENDED | REG_ICASE | REG_NOSUB; eflags = 0; while (fgets(line, MAX_LINE_LEN, theFile)) { if (IsComment(line)) { continue; } if (state == protocol) { memcpy(proto, line, strlen(line) -1); state = kpattern; continue; } if (state == kpattern) { memcpy(pattern, line, strlen(line) - 1); continue; } } protoLen = strlen(proto); patternLen = strlen(pattern); struct Pattern* newPattern = (struct Pattern*)malloc(sizeof(struct Pattern)); newPattern->cflags = cflags; newPattern->eflags = eflags; newPattern->mark = mark; newPattern->name = (char*)malloc(protoLen + 1); memset(newPattern->name, 0, protoLen + 1); strcpy(newPattern->name, proto); newPattern->pattern_string = (char*)malloc(patternLen + 1); memset(newPattern->pattern_string, 0, patternLen + 1); strcpy(newPattern->pattern_string, pattern); preprocessed = PreprocessRegex(newPattern->pattern_string); rc = regcomp(&newPattern->preg, preprocessed, newPattern->cflags); if (rc != 0) { fprintf(stderr, "error compiling %s -- %s", newPattern->name, newPattern->pattern_string); exit(1); } AddPattern(newPattern); return 1; }