void ICUServiceTest::testRBF() { // resource bundle factory. UErrorCode status = U_ZERO_ERROR; TestStringService service; service.registerFactory(new ICUResourceBundleFactory(), status); // list all of the resources { UErrorCode status = U_ZERO_ERROR; UVector ids(uprv_deleteUObject, uhash_compareUnicodeString, 0, status); service.getVisibleIDs(ids, status); logln("all visible ids:"); for (int i = 0; i < ids.size(); ++i) { const UnicodeString* id = (const UnicodeString*)ids[i]; logln(*id); } } // get all the display names of these resources // this should be fast since the display names were cached. { UErrorCode status = U_ZERO_ERROR; UVector names(status); service.getDisplayNames(names, Locale::getGermany(), status); logln("service display names for de_DE"); for (int i = 0; i < names.size(); ++i) { const StringPair* pair = (const StringPair*)names[i]; logln(" " + pair->displayName + " --> " + pair->id); } } service.registerFactory(new CalifornioLanguageFactory(), status); // get all the display names of these resources { logln("californio language factory:"); const char* idNames[] = { CalifornioLanguageFactory::californio, CalifornioLanguageFactory::valley, CalifornioLanguageFactory::surfer, CalifornioLanguageFactory::geek, }; int32_t count = sizeof(idNames)/sizeof(idNames[0]); for (int i = 0; i < count; ++i) { logln(UnicodeString("\n --- ") + idNames[i] + " ---"); { UErrorCode status = U_ZERO_ERROR; UVector names(status); service.getDisplayNames(names, idNames[i], status); for (int i = 0; i < names.size(); ++i) { const StringPair* pair = (const StringPair*)names[i]; logln(" " + pair->displayName + " --> " + pair->id); } } } } CalifornioLanguageFactory::cleanup(); }
bool moveRightArm ( const arm_navigation_msgs::MoveArmGoal * newArmGoal ) { actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> move_arm("move_right_arm",true); ROS_INFO("Waiting for server.."); move_arm.waitForServer(); ROS_INFO("Connected to server"); arm_navigation_msgs::MoveArmGoal armGoal; std::vector<std::string> names(7); names[0] = "r_shoulder_pan_joint"; names[1] = "r_shoulder_lift_joint"; names[2] = "r_upper_arm_roll_joint"; names[3] = "r_elbow_flex_joint"; names[4] = "r_forearm_roll_joint"; names[5] = "r_wrist_flex_joint"; names[6] = "r_wrist_roll_joint"; armGoal.motion_plan_request.group_name = "right_arm"; armGoal.motion_plan_request.num_planning_attempts = 1; armGoal.motion_plan_request.allowed_planning_time = ros::Duration(5.0); armGoal.motion_plan_request.planner_id= std::string(""); armGoal.planner_service_name = std::string("ompl_planning/plan_kinematic_path"); armGoal.motion_plan_request.goal_constraints.joint_constraints.resize(names.size()); for (unsigned int i = 0 ; i < armGoal.motion_plan_request.goal_constraints.joint_constraints.size(); ++i) { armGoal.motion_plan_request.goal_constraints.joint_constraints[i].joint_name = names[i]; armGoal.motion_plan_request.goal_constraints.joint_constraints[i].position = 0.0; armGoal.motion_plan_request.goal_constraints.joint_constraints[i].tolerance_below = 0.1; armGoal.motion_plan_request.goal_constraints.joint_constraints[i].tolerance_above = 0.1; // Set the joint values armGoal.motion_plan_request.goal_constraints.joint_constraints[i].position = newArmGoal->motion_plan_request.goal_constraints.joint_constraints[i].position; } bool result = true; bool success = true; if (nh_.ok()) { bool finished_within_time = false; ROS_INFO("Sending arm goal.."); move_arm.sendGoal(armGoal); finished_within_time = move_arm.waitForResult(ros::Duration(200.0)); if (!finished_within_time) { move_arm.cancelGoal(); ROS_INFO("Timed out achieving arm goal"); success = false; } else { actionlib::SimpleClientGoalState state = move_arm.getState(); success = (state == actionlib::SimpleClientGoalState::SUCCEEDED); if(success) ROS_INFO("Action finished: %s",state.toString().c_str()); else ROS_INFO("Action failed: %s",state.toString().c_str()); } } result = success; return result; }
int main (int argc, char** argv) { // Creates runtime and base app pI::Application app; pI::Runtime runtime(app.GetRuntime()); std::cerr << "Plugin dir: " << app.FindPIPluginDir() << std::endl; app.LoadPluginLibraries (app.FindPIPluginDir().c_str()); std::vector<std::string> names(GetPluginNames (runtime)); const pI_int count(names.size()); std::cout << "{" << std::endl; appendValue(std::cout, API_VERSION, runtime.GetRuntimeVersion()); appendValue(std::cout, PLUGIN_COUNT, count); std::cout << "\"" << PLUGINS << "\":" << std::endl << "[" << std::endl; for (pI_int lv = 0; lv < count; ++lv) { std::cout << "{" << std::endl; appendValue(std::cout, NAME, names[lv]); if (names[lv] == "CImg/Functions") { // special treatment for CImg META plugin try { pI::pInPtr p(runtime.SpawnPlugin ((const pI_str) names[lv].c_str())); pI::Arguments params(p->GetParameterSignature()); appendValue(std::cout, DESCRIPTION, p->GetDescription()); appendValue(std::cout, PLUGIN_VERSION, p->GetpInVersion()); appendValue(std::cout, API_VERSION, p->GetAPIVersion()); appendValue(std::cout, AUTHOR, p->GetAuthor()); appendValue(std::cout, COPYRIGHT, p->GetCopyright()); appendValue(std::cout, OPTIONAL_INIT, "false"); appendValue(std::cout, DEFAULT_INIT, "true"); std::cout << "\"parameters\":" << std::endl << "[" << std::endl; for (pI_size lv2 = 0; lv2 < params.size(); ++lv2) { std::cout << runtime.SerializeArgument (params[lv2]); if (lv2 < params.size() - 1) { std::cout << ","; } std::cout << std::endl; } std::cout << "]," << std::endl; pI::StringSelection sts(params[0]); std::cout << "\"CImg functions\":" << std::endl << "[" << std::endl; for (pI_size lv2 = 0; lv2 < sts.GetCount(); ++lv2) { sts.SetIndex (lv2); p->Initialize (params); std::cout << "{" << std::endl; appendValue(std::cout, NAME, sts.GetSymbols (lv2)); std::cout << "\"inputSignature\":" << std::endl << "[" << std::endl; pI::Arguments is(p->GetInputSignature()); for (pI_size lv3 = 0; lv3 < is.size(); ++lv3) { std::cout << runtime.SerializeArgument (is[lv3]); if (lv3 < is.size() - 1) std::cout << ","; } std::cout << std::endl << "]," << std::endl; std::cout << "\"outputSignature\":" << std::endl << "[" << std::endl; pI::Arguments os(p->GetOutputSignature()); for (pI_size lv3 = 0; lv3 < os.size(); ++lv3) { std::cout << runtime.SerializeArgument (os[lv3]); if (lv3 < os.size() - 1) std::cout << ","; } std::cout << std::endl << "]" << std::endl; std::cout << "}"; if (lv2 < sts.GetCount() - 1) std::cout << ","; std::cout << std::endl; } std::cout << "]" << std::endl; } catch (...) {} } else { try { pI::pInPtr p(runtime.SpawnPlugin ((const pI_str) names[lv].c_str())); appendValue(std::cout, DESCRIPTION, p->GetDescription()); appendValue(std::cout, PLUGIN_VERSION, p->GetpInVersion()); appendValue(std::cout, API_VERSION, p->GetAPIVersion()); appendValue(std::cout, AUTHOR, p->GetAuthor()); appendValue(std::cout, COPYRIGHT, p->GetCopyright()); bool optional_init((p->GetInputSignature().size() > 0) || (p->GetOutputSignature().size() > 0)); appendValue(std::cout, OPTIONAL_INIT, (optional_init ? "true" : "false")); std::cout << "\"" << PARAMETERS << "\":" << std::endl << "[" << std::endl; pI::Arguments params(p->GetParameterSignature()); for (pI_size lv2 = 0; lv2 < params.size(); ++lv2) { std::cout << runtime.SerializeArgument (params[lv2]); if (lv2 < params.size() - 1) { std::cout << ","; } std::cout << std::endl; } std::cout << "]," << std::endl; bool default_init; try { p->Initialize (params); default_init = true; } catch (...) { default_init = false; } appendValue(std::cout, DEFAULT_INIT, (default_init ? "true" : "false"), optional_init || default_init); if (optional_init || default_init) { std::cout << "\"" << INPUT_SIGNATURE << "\":" << std::endl << "[" << std::endl; pI::Arguments is(p->GetInputSignature()); for (pI_size lv2 = 0; lv2 < is.size(); ++lv2) { std::cout << runtime.SerializeArgument (is[lv2]); if (lv2 < is.size() - 1) std::cout << ","; } std::cout << std::endl << "]," << std::endl; std::cout << "\"" << OUTPUT_SIGNATURE << "\":" << std::endl << "[" << std::endl; pI::Arguments os(p->GetOutputSignature()); for (pI_size lv2 = 0; lv2 < os.size(); ++lv2) { std::cout << runtime.SerializeArgument (os[lv2]); if (lv2 < os.size() - 1) std::cout << ","; } std::cout << std::endl << "]" << std::endl; } else std::cout << std::endl; } catch (...) {} } std::cout << "}"; if (lv < count - 1) std::cout << ","; std::cout << std::endl; } std::cout << "]" << std::endl << "}" << std::endl; return 0; }
void GXCreateVectorPlotDialog::BuildWindow ( GRaggedFloatTableData* data, const JIndex startX, const JIndex startY, const JIndex startX2, const JIndex startY2 ) { // begin JXLayout JXWindow* window = jnew JXWindow(this, 380,160, ""); assert( window != NULL ); itsX1Menu = jnew JXTextMenu("X1", window, JXWidget::kHElastic, JXWidget::kVElastic, 10,40, 160,30); assert( itsX1Menu != NULL ); itsY1Menu = jnew JXTextMenu("Y1", window, JXWidget::kHElastic, JXWidget::kVElastic, 200,40, 170,30); assert( itsY1Menu != NULL ); itsX2Menu = jnew JXTextMenu("DX", window, JXWidget::kHElastic, JXWidget::kVElastic, 10,80, 160,30); assert( itsX2Menu != NULL ); itsY2Menu = jnew JXTextMenu("DY", window, JXWidget::kHElastic, JXWidget::kVElastic, 200,80, 170,30); assert( itsY2Menu != NULL ); JXTextButton* okButton = jnew JXTextButton("OK", window, JXWidget::kHElastic, JXWidget::kVElastic, 280,130, 70,20); assert( okButton != NULL ); okButton->SetShortcuts("^M"); JXTextButton* cancelButton = jnew JXTextButton("Cancel", window, JXWidget::kHElastic, JXWidget::kVElastic, 190,130, 70,20); assert( cancelButton != NULL ); cancelButton->SetShortcuts("^["); itsPlotsMenu = jnew JXTextMenu("Plot:", window, JXWidget::kHElastic, JXWidget::kVElastic, 10,120, 130,30); assert( itsPlotsMenu != NULL ); itsLabelInput = jnew JXInputField(window, JXWidget::kHElastic, JXWidget::kVElastic, 115,10, 200,20); assert( itsLabelInput != NULL ); JXStaticText* obj1 = jnew JXStaticText("Label:", window, JXWidget::kHElastic, JXWidget::kVElastic, 65,13, 45,15); assert( obj1 != NULL ); obj1->SetToLabel(); // end JXLayout window->SetTitle("Choose Vector Data Columns"); SetButtons(okButton, cancelButton); const JSize count = data->GetDataColCount(); for (JSize i = 1; i <= count; i++) { JString str(i); str.Prepend("Column "); itsX1Menu->AppendItem(str); itsX2Menu->AppendItem(str); itsY1Menu->AppendItem(str); itsY2Menu->AppendItem(str); } itsStartX1 = startX; if (startX == 0) { itsStartX1 = 1; } itsStartX2 = startX2; if (startX2 == 0) { itsStartX2 = 1; } itsStartY1 = startY; if (startY == 0) { itsStartY1 = 1; } itsStartY2 = startY2; if (startY2 == 0) { itsStartY2 = 1; } JPtrArray<JString> names(JPtrArrayT::kDeleteAll); itsTableDir->GetPlotNames(names); itsPlotsMenu->AppendItem("New Plot"); const JSize strCount = names.GetElementCount(); for (JSize i = 1; i <= strCount; i++) { itsPlotsMenu->AppendItem(*(names.NthElement(i))); } itsPlotsMenu->ShowSeparatorAfter(1, kJTrue); itsPlotIndex = 1; itsX1Menu->SetToPopupChoice(kJTrue, itsStartX1); itsX2Menu->SetToPopupChoice(kJTrue, itsStartX2); itsY1Menu->SetToPopupChoice(kJTrue, itsStartY1); itsY2Menu->SetToPopupChoice(kJTrue, itsStartY2); itsPlotsMenu->SetToPopupChoice(kJTrue, itsPlotIndex); itsX1Menu->SetUpdateAction(JXMenu::kDisableNone); itsX2Menu->SetUpdateAction(JXMenu::kDisableNone); itsY1Menu->SetUpdateAction(JXMenu::kDisableNone); itsY2Menu->SetUpdateAction(JXMenu::kDisableNone); itsPlotsMenu->SetUpdateAction(JXMenu::kDisableNone); ListenTo(itsX1Menu); ListenTo(itsX2Menu); ListenTo(itsY1Menu); ListenTo(itsY2Menu); ListenTo(itsPlotsMenu); itsLabelInput->SetText("Untitled"); }
SEXP rawSymmetricMatrixSubsetIndices(SEXP object_, SEXP i_, SEXP j_, SEXP drop_) { BEGIN_RCPP Rcpp::S4 object = object_; Rcpp::CharacterVector markers = object.slot("markers"); Rcpp::NumericVector levels = object.slot("levels"); Rcpp::RawVector data = object.slot("data"); Rcpp::IntegerVector i = i_; Rcpp::IntegerVector j = j_; bool drop = Rcpp::as<bool>(drop_); if(drop) { if(i.size() == 1 && j.size() == 1) { R_xlen_t i = Rcpp::as<int>(i_); R_xlen_t j = Rcpp::as<int>(j_); if(i > j) std::swap(i, j); Rbyte rawValue = data[(j*(j-(R_xlen_t)1))/(R_xlen_t)2 + i-(R_xlen_t)1]; if(rawValue == 0xff) return Rcpp::wrap(NA_REAL); return Rcpp::wrap(levels[rawValue]); } else if(i.size() == 1) { Rcpp::NumericVector result(j.size()); R_xlen_t i = Rcpp::as<int>(i_); Rcpp::CharacterVector names(j.size()); for(R_xlen_t jCounter = 0; jCounter < j.size(); jCounter++) { R_xlen_t iCopied = i; R_xlen_t jValue = j[jCounter]; names[jCounter] = markers[jValue-(R_xlen_t)1]; if(iCopied > jValue) std::swap(iCopied, jValue); Rbyte rawValue = data[(jValue*(jValue-(R_xlen_t)1))/(R_xlen_t)2 + iCopied-(R_xlen_t)1]; if(rawValue == 0xff) result[jCounter] = NA_REAL; else result[jCounter] = levels[rawValue]; } result.attr("names") = names; return result; } else if(j.size() == 1) { Rcpp::NumericVector result(i.size()); R_xlen_t j = Rcpp::as<int>(j_); Rcpp::CharacterVector names(i.size()); for(R_xlen_t iCounter = 0; iCounter < i.size(); iCounter++) { R_xlen_t jCopied = j; R_xlen_t iValue = i[iCounter]; names[iCounter] = markers[iValue-(R_xlen_t)1]; if(iValue > jCopied) std::swap(iValue, jCopied); Rbyte rawValue = data[(jCopied*(jCopied-(R_xlen_t)1))/(R_xlen_t)2 + iValue-(R_xlen_t)1]; if(rawValue == 0xff) result[iCounter] = NA_REAL; else result[iCounter] = levels[rawValue]; } result.attr("names") = names; return result; } } Rcpp::NumericMatrix result((int)i.size(), (int)j.size()); Rcpp::CharacterVector rownames(i.size()), colnames(j.size()); for(R_xlen_t iCounter = 0; iCounter < i.size(); iCounter++) { rownames[iCounter] = markers[i[iCounter]-(R_xlen_t)1]; for(R_xlen_t jCounter = 0; jCounter < j.size(); jCounter++) { R_xlen_t iCopied = i[iCounter], jCopied = j[jCounter]; if(iCopied > jCopied) std::swap(iCopied, jCopied); Rbyte rawValue = data[(jCopied*(jCopied-(R_xlen_t)1))/(R_xlen_t)2 + iCopied-(R_xlen_t)1]; if(rawValue == 0xff) result(iCounter, jCounter) = NA_REAL; else result(iCounter, jCounter) = levels[rawValue]; } } for(R_xlen_t jCounter = 0; jCounter < j.size(); jCounter++) { colnames[jCounter] = markers[j[jCounter]-(R_xlen_t)1]; } result.attr("dimnames") = Rcpp::List::create(rownames, colnames); return result; END_RCPP }
StructureConstPtr StandardField::createProperties(String id,FieldConstPtr field,String properties) { bool gotAlarm = false; bool gotTimeStamp = false; bool gotDisplay = false; bool gotControl = false; bool gotValueAlarm = false; int numProp = 0; if(properties.find("alarm")!=String::npos) { gotAlarm = true; numProp++; } if(properties.find("timeStamp")!=String::npos) { gotTimeStamp = true; numProp++; } if(properties.find("display")!=String::npos) { gotDisplay = true; numProp++; } if(properties.find("control")!=String::npos) { gotControl = true; numProp++; } if(properties.find("valueAlarm")!=String::npos) { gotValueAlarm = true; numProp++; } StructureConstPtr valueAlarm; Type type= field->getType(); while(gotValueAlarm) { if(type==epics::pvData::scalar || type==epics::pvData::scalarArray) { ScalarType scalarType = (type==epics::pvData::scalar) ? static_pointer_cast<const Scalar>(field)->getScalarType() : static_pointer_cast<const ScalarArray>(field)->getElementType(); switch(scalarType) { case pvBoolean: valueAlarm = booleanAlarmField; break; case pvByte: valueAlarm = byteAlarmField; break; case pvShort: valueAlarm = shortAlarmField; break; case pvInt: valueAlarm = intAlarmField; break; case pvLong: valueAlarm = longAlarmField; break; case pvUByte: valueAlarm = ubyteAlarmField; break; case pvUShort: valueAlarm = ushortAlarmField; break; case pvUInt: valueAlarm = uintAlarmField; break; case pvULong: valueAlarm = ulongAlarmField; break; case pvFloat: valueAlarm = floatAlarmField; break; case pvDouble: valueAlarm = doubleAlarmField; break; case pvString: throw std::logic_error(String("valueAlarm property not supported for pvString")); } break; } if(type==structure) { StructureConstPtr structurePtr = static_pointer_cast<const Structure>(field); StringArray names = structurePtr->getFieldNames(); if(names.size()==2) { FieldConstPtrArray fields = structurePtr->getFields(); FieldConstPtr first = fields[0]; FieldConstPtr second = fields[1]; String nameFirst = names[0]; String nameSecond = names[1]; int compareFirst = nameFirst.compare("index"); int compareSecond = nameSecond.compare("choices"); if(compareFirst==0 && compareSecond==0) { if(first->getType()==epics::pvData::scalar && second->getType()==epics::pvData::scalarArray) { ScalarConstPtr scalarFirst = static_pointer_cast<const Scalar>(first); ScalarArrayConstPtr scalarArraySecond = static_pointer_cast<const ScalarArray>(second); if(scalarFirst->getScalarType()==pvInt && scalarArraySecond->getElementType()==pvString) { valueAlarm = enumeratedAlarmField; break; } } } } } throw std::logic_error(String("valueAlarm property for illegal type")); } size_t numFields = numProp+1; FieldConstPtrArray fields(numFields); StringArray names(numFields); int next = 0; names[0] = "value"; fields[next++] = field; if(gotAlarm) { names[next] = "alarm"; fields[next++] = alarmField; } if(gotTimeStamp) { names[next] = "timeStamp"; fields[next++] = timeStampField; } if(gotDisplay) { names[next] = "display"; fields[next++] = displayField; } if(gotControl) { names[next] = "control"; fields[next++] = controlField; } if(gotValueAlarm) { names[next] = "valueAlarm"; fields[next++] = valueAlarm; } return fieldCreate->createStructure(id,names,fields); }
void DatabasePlugin::shutdown() { auto datbase_registry = Registry::registry("database"); for (auto& plugin : datbase_registry->names()) { datbase_registry->remove(plugin); } }
unsigned PackArmPe::processImports() // pass 1 { static const unsigned char kernel32dll[] = "COREDLL.dll"; static const char llgpa[] = "\x0\x0""LoadLibraryW\x0\x0" "GetProcAddressA\x0\x0\x0" "CacheSync"; //static const char exitp[] = "ExitProcess\x0\x0\x0"; unsigned dllnum = 0; import_desc *im = (import_desc*) (ibuf + IDADDR(PEDIR_IMPORT)); import_desc * const im_save = im; if (IDADDR(PEDIR_IMPORT)) { while (im->dllname) dllnum++, im++; im = im_save; } struct udll { const upx_byte *name; const upx_byte *shname; unsigned ordinal; unsigned iat; LE32 *lookupt; unsigned npos; unsigned original_position; bool isk32; static int __acc_cdecl_qsort compare(const void *p1, const void *p2) { const udll *u1 = * (const udll * const *) p1; const udll *u2 = * (const udll * const *) p2; if (u1->isk32) return -1; if (u2->isk32) return 1; if (!*u1->lookupt) return 1; if (!*u2->lookupt) return -1; int rc = strcasecmp(u1->name,u2->name); if (rc) return rc; if (u1->ordinal) return -1; if (u2->ordinal) return 1; if (!u1->shname) return 1; if (!u2->shname) return -1; return strlen(u1->shname) - strlen(u2->shname); } }; // +1 for dllnum=0 Array(struct udll, dlls, dllnum+1); Array(struct udll *, idlls, dllnum+1); soimport = 1024; // safety unsigned ic,k32o; for (ic = k32o = 0; dllnum && im->dllname; ic++, im++) { idlls[ic] = dlls + ic; dlls[ic].name = ibuf + im->dllname; dlls[ic].shname = NULL; dlls[ic].ordinal = 0; dlls[ic].iat = im->iat; dlls[ic].lookupt = (LE32*) (ibuf + (im->oft ? im->oft : im->iat)); dlls[ic].npos = 0; dlls[ic].original_position = ic; dlls[ic].isk32 = strcasecmp(kernel32dll,dlls[ic].name) == 0; soimport += strlen(dlls[ic].name) + 1 + 4; for (IPTR_I(LE32, tarr, dlls[ic].lookupt); *tarr; tarr += 1) { if (*tarr & 0x80000000) { importbyordinal = true; soimport += 2; // ordinal num: 2 bytes dlls[ic].ordinal = *tarr & 0xffff; //if (dlls[ic].isk32) // kernel32ordinal = true,k32o++; } else { IPTR_I(const upx_byte, n, ibuf + *tarr + 2); unsigned len = strlen(n); soimport += len + 1; if (dlls[ic].shname == NULL || len < strlen (dlls[ic].shname)) dlls[ic].shname = n; } soimport++; // separator } } oimport = new upx_byte[soimport]; memset(oimport,0,soimport); oimpdlls = new upx_byte[soimport]; memset(oimpdlls,0,soimport); qsort(idlls,dllnum,sizeof (udll*),udll::compare); unsigned dllnamelen = sizeof (kernel32dll); unsigned dllnum2 = 1; for (ic = 0; ic < dllnum; ic++) if (!idlls[ic]->isk32 && (ic == 0 || strcasecmp(idlls[ic - 1]->name,idlls[ic]->name))) { dllnum2++; dllnamelen += strlen(idlls[ic]->name) + 1; } //fprintf(stderr,"dllnum=%d dllnum2=%d soimport=%d\n",dllnum,dllnum2,soimport); // info("Processing imports: %d DLLs", dllnum); // create the new import table im = (import_desc*) oimpdlls; LE32 *ordinals = (LE32*) (oimpdlls + (dllnum2 + 1) * sizeof(import_desc)); LE32 *lookuptable = ordinals + 4;// + k32o + (isdll ? 0 : 1); upx_byte *dllnames = ((upx_byte*) lookuptable) + (dllnum2 - 1) * 8; upx_byte *importednames = dllnames + (dllnamelen &~ 1); unsigned k32namepos = ptr_diff(dllnames,oimpdlls); memcpy(importednames, llgpa, ALIGN_UP((unsigned) sizeof(llgpa), 2u)); strcpy(dllnames,kernel32dll); im->dllname = k32namepos; im->iat = ptr_diff(ordinals,oimpdlls); *ordinals++ = ptr_diff(importednames,oimpdlls); // LoadLibraryW *ordinals++ = ptr_diff(importednames,oimpdlls) + 14; // GetProcAddressA *ordinals++ = ptr_diff(importednames,oimpdlls) + 14 + 18; // CacheSync dllnames += sizeof(kernel32dll); importednames += sizeof(llgpa); im++; for (ic = 0; ic < dllnum; ic++) if (idlls[ic]->isk32) { idlls[ic]->npos = k32namepos; /* if (idlls[ic]->ordinal) for (LE32 *tarr = idlls[ic]->lookupt; *tarr; tarr++) if (*tarr & 0x80000000) *ordinals++ = *tarr; */ } else if (ic && strcasecmp(idlls[ic-1]->name,idlls[ic]->name) == 0) idlls[ic]->npos = idlls[ic-1]->npos; else { im->dllname = idlls[ic]->npos = ptr_diff(dllnames,oimpdlls); im->iat = ptr_diff(lookuptable,oimpdlls); strcpy(dllnames,idlls[ic]->name); dllnames += strlen(idlls[ic]->name)+1; if (idlls[ic]->ordinal) *lookuptable = idlls[ic]->ordinal + 0x80000000; else if (idlls[ic]->shname) { if (ptr_diff(importednames,oimpdlls) & 1) importednames--; *lookuptable = ptr_diff(importednames,oimpdlls); importednames += 2; strcpy(importednames,idlls[ic]->shname); importednames += strlen(idlls[ic]->shname) + 1; } lookuptable += 2; im++; } soimpdlls = ALIGN_UP(ptr_diff(importednames,oimpdlls),4); Interval names(ibuf),iats(ibuf),lookups(ibuf); // create the preprocessed data //ordinals -= k32o; upx_byte *ppi = oimport; // preprocessed imports for (ic = 0; ic < dllnum; ic++) { LE32 *tarr = idlls[ic]->lookupt; #if 0 && ENABLE_THIS_AND_UNCOMPRESSION_WILL_BREAK if (!*tarr) // no imports from this dll continue; #endif set_le32(ppi,idlls[ic]->npos); set_le32(ppi+4,idlls[ic]->iat - rvamin); ppi += 8; for (; *tarr; tarr++) if (*tarr & 0x80000000) { /*if (idlls[ic]->isk32) { *ppi++ = 0xfe; // signed + odd parity set_le32(ppi,ptr_diff(ordinals,oimpdlls)); ordinals++; ppi += 4; } else*/ { *ppi++ = 0xff; set_le16(ppi,*tarr & 0xffff); ppi += 2; } } else { *ppi++ = 1; unsigned len = strlen(ibuf + *tarr + 2) + 1; memcpy(ppi,ibuf + *tarr + 2,len); ppi += len; names.add(*tarr,len + 2 + 1); } ppi++; unsigned esize = ptr_diff((char *)tarr, (char *)idlls[ic]->lookupt); lookups.add(idlls[ic]->lookupt,esize); if (ptr_diff(ibuf + idlls[ic]->iat, (char *)idlls[ic]->lookupt)) { memcpy(ibuf + idlls[ic]->iat, idlls[ic]->lookupt, esize); iats.add(idlls[ic]->iat,esize); } names.add(idlls[ic]->name,strlen(idlls[ic]->name) + 1 + 1); } ppi += 4; assert(ppi < oimport+soimport); soimport = ptr_diff(ppi,oimport); if (soimport == 4) soimport = 0; //OutputFile::dump("x0.imp", oimport, soimport); //OutputFile::dump("x1.imp", oimpdlls, soimpdlls); unsigned ilen = 0; names.flatten(); if (names.ivnum > 1) { // The area occupied by the dll and imported names is not continuous // so to still support uncompression, I can't zero the iat area. // This decreases compression ratio, so FIXME somehow. infoWarning("can't remove unneeded imports"); ilen += sizeof(import_desc) * dllnum; #if defined(DEBUG) if (opt->verbose > 3) names.dump(); #endif // do some work for the unpacker im = im_save; for (ic = 0; ic < dllnum; ic++, im++) { memset(im,FILLVAL,sizeof(*im)); im->dllname = ptr_diff(dlls[idlls[ic]->original_position].name,ibuf); } } else { iats.add(im_save,sizeof(import_desc) * dllnum); // zero unneeded data iats.clear(); lookups.clear(); } names.clear(); iats.add(&names); iats.add(&lookups); iats.flatten(); for (ic = 0; ic < iats.ivnum; ic++) ilen += iats.ivarr[ic].len; info("Imports: original size: %u bytes, preprocessed size: %u bytes",ilen,soimport); return names.ivnum == 1 ? names.ivarr[0].start : 0; }
// LATER make read and write timeout parameters bool PfParser::parse(QIODevice *source, PfOptions options) { bool lazyBinaryFragments = options.shouldLazyLoadBinaryFragments(); if (!_handler) { qWarning() << "PfParser::parse called before setting a handler"; return false; } _handler->setErrorString(tr("unknown handler error")); int line = 1, column = 0, arrayColumn = 0; quint8 c, quote = 0, escapeshift = 0; quint16 escaped = 0; qint8 digit; State state = TopLevel; // current state State quotedState = TopLevel; // saved state for quotes and comments State escapedState = TopLevel; // saved state for escapes QByteArray content, comment, surface; QVector<Node> nodes; bool firstNode = true; PfArray array; if (!source->isOpen() && !source->open(QIODevice::ReadOnly)) { _handler->setErrorString(tr("cannot open document : %1") .arg(source->errorString())); goto error; } if (!_handler->startDocument(options)) { _handler->setErrorString(tr("cannot handle start of document")); goto error; } while (source->bytesAvailable() || source->waitForReadyRead(options.readTimeout()), source->getChar((char*)&c)) { ++column; switch(state) { case TopLevel: if (c == '(') { state = Name; } else if (c == '\n') { ++line; column = 0; } else if (pfisspace(c)) { } else if (c == '#') { state = Comment; quotedState = TopLevel; } else { _handler->setErrorString(tr("unexpected character '%1' " "(in TopLevel state)") .arg(pfquotechar(c))); goto error; } break; case Name: if (pfisendofname(c) && content.isEmpty()) { _handler->setErrorString(tr("anonymous node")); goto error; } else if (c == '(') { nodes.append(QString::fromUtf8(content)); content.clear(); if (!_handler->startNode(names(nodes))) { _handler->setErrorString(tr("cannot handle start of node")); goto error; } } else if (c == ')') { nodes.append(QString::fromUtf8(content)); content.clear(); QVector<QString> names = ::names(nodes); if (!_handler->startNode(names) || !_handler->endNode(names)) { _handler->setErrorString(tr("cannot handle end of node")); goto error; } nodes.removeLast(); state = nodes.size() ? Content : TopLevel; if (nodes.isEmpty()) { switch (options.rootNodesParsingPolicy()) { case StopAfterFirstRootNode: if (firstNode) goto stop_parsing; break; case FailAtSecondRootNode: if (!firstNode) { _handler->setErrorString(tr("only one root node is allowed " "(by option)")); goto error; } break; case ParseEveryRootNode: ; } } } else if (pfisspace(c)) { if (c == '\n') { ++line; column = 0; } nodes.append(QString::fromUtf8(content)); content.clear(); if (!_handler->startNode(names(nodes))) { _handler->setErrorString(tr("cannot handle start of node")); goto error; } state = Content; } else if (c == '#') { nodes.append(QString::fromUtf8(content)); content.clear(); if (!_handler->startNode(names(nodes))) { _handler->setErrorString(tr("cannot handle start of node")); goto error; } state = Comment; quotedState = Content; } else if (c == '|') { nodes.append(QString::fromUtf8(content)); content.clear(); if (!_handler->startNode(names(nodes))) { _handler->setErrorString(tr("cannot handle start of node")); goto error; } state = BinarySurfaceOrLength; } else if (c == ';') { nodes.append(QString::fromUtf8(content)); array.clear(); content.clear(); if (!_handler->startNode(names(nodes))) { _handler->setErrorString(tr("cannot handle start of node")); goto error; } array.appendHeader("0"); arrayColumn = 1; state = ArrayHeader; } else if (pfisquote(c)) { quote = c; state = Quote; quotedState = Name; } else if (c == '\\') { state = Escape; escapedState = Name; } else if (pfisspecial(c)) { _handler->setErrorString(tr("unexpected character '%1' (in Name state)") .arg(pfquotechar(c))); goto error; } else { content.append(c); } break; case SpaceInContent: if (pfisspace(c)) { if (c == '\n') { ++line; column = 0; } else { ++column; } break; } // otherwise process as Content by falling into Content: label case Content: if (c == ';') { // LATER warn if an array node has text or binary content array.clear(); if (!content.isEmpty()) { array.appendHeader(content); content.clear(); } else array.appendHeader("0"); arrayColumn = 1; state = ArrayHeader; } else if (c == '(') { if (content.size()) { if (!_handler->text(QString::fromUtf8(content))) { _handler->setErrorString(tr("cannot handle text fragment")); goto error; } content.clear(); nodes.last()._hasContent = true; } state = Name; } else if (c == ')') { if (content.size()) { if (!_handler->text(QString::fromUtf8(content))) { _handler->setErrorString(tr("cannot handle text fragment")); goto error; } content.clear(); nodes.last()._hasContent = true; } if (!_handler->endNode(names(nodes))) { _handler->setErrorString(tr("cannot handle end of node")); goto error; } nodes.removeLast(); state = nodes.size() ? Content : TopLevel; if (nodes.isEmpty()) { switch (options.rootNodesParsingPolicy()) { case StopAfterFirstRootNode: if (firstNode) goto stop_parsing; break; case FailAtSecondRootNode: if (!firstNode) { _handler->setErrorString(tr("only one root node is allowed " "(by option)")); goto error; } break; case ParseEveryRootNode: ; } } } else if (pfisspace(c)) { if (c == '\n') { ++line; column = 0; } else { ++column; } state = SpaceInContent; } else if (c == '#') { if (content.size()) { if (!_handler->text(QString::fromUtf8(content))) { _handler->setErrorString(tr("cannot handle text fragment")); goto error; } content.clear(); nodes.last()._hasContent = true; } state = Comment; quotedState = Content; } else if (c == '|') { if (content.size()) { if (!_handler->text(QString::fromUtf8(content))) { _handler->setErrorString(tr("cannot handle text fragment")); goto error; } content.clear(); nodes.last()._hasContent = true; } state = BinarySurfaceOrLength; } else if (pfisquote(c)) { if (state == SpaceInContent) content.append(' '); quote = c; state = Quote; quotedState = Content; } else if (c == '\\') { if (state == SpaceInContent) content.append(' '); state = Escape; escapedState = Content; } else if (pfisspecial(c)) { _handler->setErrorString(tr("unexpected character '%1' " "(in Content state)") .arg(pfquotechar(c))); goto error; } else { if (state == SpaceInContent) { if (!content.isEmpty() || nodes.last()._hasContent) content.append(' '); state = Content; } content.append(c); } break; case Comment: if (c == '\n') { if (!options.shouldIgnoreComment()) { if (!_handler->comment(comment)) { _handler->setErrorString(tr("cannot handle comment")); goto error; } } comment.clear(); ++line; column = 0; state = quotedState; } else { if (!options.shouldIgnoreComment()) comment.append(c); ++column; } break; case Quote: if (c == quote) { state = quotedState; ++column; } else if (c == '\\' && quote == '"') { state = Escape; escapedState = Quote; ++column; } else { if (c == '\n') { ++line; column = 0; } else ++column; content.append(c); } break; case BinarySurfaceOrLength: if (c == '\n') { if (content.size() == 0) { _handler->setErrorString(tr("binary fragment without length")); goto error; } bool ok; qint64 l = content.toLongLong(&ok); if (!ok) { _handler->setErrorString(tr("binary fragment with incorrect length")); goto error; } if (!readAndFinishBinaryFragment(source, &lazyBinaryFragments, "", l, options)) goto error; content.clear(); nodes.last()._hasContent = true; line = 10000000; // LATER hide line numbers after first binary fragment column = 0; state = Content; } else { if (std::isspace(c)) { // ignore whitespace, incl. \r } else if (c == '|') { surface = content; content.clear(); state = BinaryLength; } else if (std::isdigit(c) || std::islower(c) || std::isupper(c) || c == ':') { content.append(c); } else { _handler->setErrorString(tr("unexpected character '%1' " "(in BinarySurfaceOrLength state)") .arg(pfquotechar(c))); goto error; } ++column; } break; case BinaryLength: if (c == '\n') { if (content.size() == 0) { _handler->setErrorString(tr("binary fragment without length")); goto error; } bool ok; qint64 l = content.toLongLong(&ok); if (!ok) { _handler->setErrorString(tr("binary fragment with incorrect length")); goto error; } if (!readAndFinishBinaryFragment(source, &lazyBinaryFragments, surface, l, options)) goto error; content.clear(); nodes.last()._hasContent = true; line = 10000000; // LATER hide line numbers after first binary fragment column = 0; state = Content; } else { if (std::isspace(c)) { // ignore whitespace, incl. \r } else if (std::isdigit(c)) { content.append(c); } else { _handler->setErrorString(tr("unexpected character '%1' " "(in BinaryLength state)") .arg(pfquotechar(c))); goto error; } ++column; } break; case ArrayHeader: if (c == '\n') { if (!content.isEmpty()) { array.appendHeader(QString::fromUtf8(content)); content.clear(); } else array.appendHeader(QString::number(arrayColumn)); ++line; column = 0; state = ArrayBody; } else { if (c == ';') { if (!content.isEmpty()) { array.appendHeader(QString::fromUtf8(content)); content.clear(); } else array.appendHeader(QString::number(arrayColumn)); ++arrayColumn; } else if (c == ')') { content.clear(); if (!finishArray(_handler, &array, &nodes)) goto error; state = nodes.size() ? Content : TopLevel; if (nodes.isEmpty()) { switch (options.rootNodesParsingPolicy()) { case StopAfterFirstRootNode: if (firstNode) goto stop_parsing; break; case FailAtSecondRootNode: if (!firstNode) { _handler->setErrorString(tr("only one root node is allowed " "(by option)")); goto error; } break; case ParseEveryRootNode: ; } } } else if (c == '#') { if (!content.isEmpty()) { array.appendHeader(QString::fromUtf8(content)); content.clear(); } else array.appendHeader(QString::number(arrayColumn)); ++column; state = Comment; quotedState = ArrayBody; } else if (pfisspace(c)) { // ignore } else if (pfisquote(c)) { quote = c; state = Quote; quotedState = ArrayHeader; } else if (c == '\\') { state = Escape; escapedState = ArrayHeader; } else if (pfisspecial(c)) { _handler->setErrorString(tr("unexpected character '%1'" " (in ArrayHeader state)") .arg(pfquotechar(c))); goto error; } else { content.append(c); } ++column; } break; case ArrayBody: if (c == '\n') { array.appendCell(QString::fromUtf8(content)); content.clear(); array.appendRow(); ++line; column = 0; } else { if (c == ';') { array.appendCell(QString::fromUtf8(content)); content.clear(); } else if (c == ')') { if (content.size()) array.appendCell((QString::fromUtf8(content))); array.removeLastRowIfEmpty(); content.clear(); if (!finishArray(_handler, &array, &nodes)) goto error; state = nodes.size() ? Content : TopLevel; if (nodes.isEmpty()) { switch (options.rootNodesParsingPolicy()) { case StopAfterFirstRootNode: if (firstNode) goto stop_parsing; break; case FailAtSecondRootNode: if (!firstNode) { _handler->setErrorString(tr("only one root node is allowed " "(by option)")); goto error; } break; case ParseEveryRootNode: ; } } } else if (c == '#') { if (content.size()) array.appendCell((QString::fromUtf8(content))); content.clear(); ++column; state = Comment; quotedState = ArrayBody; } else if (pfisspace(c)) { // ignore } else if (pfisquote(c)) { quote = c; state = Quote; quotedState = ArrayBody; } else if (c == '\\') { state = Escape; escapedState = ArrayBody; } else if (pfisspecial(c)) { _handler->setErrorString(tr("unexpected character '%1'" " (in ArrayBody state)") .arg(pfquotechar(c))); goto error; } else { content.append(c); } ++column; } break; case Escape: if (c == '\n') { column = 0; ++line; } else { if (c == 'n') c = '\n'; else if (c == 'r') c = '\r'; else if (c == 't') c = '\t'; else if (c == '0') c = 0; else if (c == 'x') { state = EscapeHex; escapeshift = 4; escaped = 0; break; } else if (c == 'u') { state = EscapeHex; escapeshift = 12; escaped = 0; break; } ++column; } content.append(c); state = escapedState; break; case EscapeHex: digit = hexdigits[c]; if (digit < 0) { _handler->setErrorString("bad hexadecimal digit in escape sequence"); goto error; } if (escapeshift) { escaped |= digit << escapeshift; escapeshift -= 4; } else { if (escaped > 0x7f) content.append(QString(QChar(escaped|digit)).toUtf8()); else content.append(QChar(escaped|digit)); state = escapedState; } ++column; break; } } stop_parsing: if (state != TopLevel) { _handler->setErrorString(tr("unexpected end of document")); goto error; } if (!_handler->endDocument()) { _handler->setErrorString(tr("cannot handle end of document")); goto error; } return true; error: _handler->error(line, column); return false; }
int main() { //tokennizer Tokenizer tokenizer("../dataset/perloc/PerLoc.input", false); vector<Text_token> text_tokens = tokenizer.scan(); //测试 extract_regex /* create view cap as extract regex /[A-Z][a-z]* / on D.text return group 0 as Cap from Document D; */ View cap("cap"); vector<int> groups; groups.push_back(0); vector<string> column_names; column_names.push_back("Cap"); string text = tokenizer.text; cap.extract_regex("[A-Z][a-z]*", groups, column_names, text); cap.output(""); //测试 extract_regex /* create view loc as extract regex /Washington|Georgia|Virginia/ on D.text return group 0 as loc from Document D; */ View loc("loc"); groups.clear(); groups.push_back(0); column_names.clear(); column_names.push_back("loc"); loc.extract_regex("Washington|Georgia|Virginia", groups, column_names, text); loc.output(""); //测试 select /* create view perloc as select c.Cap as col1 from cap c; */ View perloc("perloc"); vector<string> column_names2; column_names2.push_back("col1"); vector<Column> columns2; columns2.push_back(cap.columns[0]); perloc.select(columns2, column_names2); perloc.output(""); //测试 extract_pattern /* create view pl as extract pattern (<c.cap>) /,/ (<l.loc>) return group 0 as Loc and group 1 as cap and group 2 as stt from cat c, loc l; */ View pl("pl"); vector<Atom> atoms; atoms.push_back(Atom( COLUMN, 0, 0, "", cap.columns[0] )); atoms.push_back(Atom( REG, 0, 0, ",", Column() )); atoms.push_back(Atom( COLUMN, 0, 0, "", loc.columns[0] )); vector<int> groups_; vector<string> names(1, "123"); groups_.push_back(0); groups_.push_back(atoms.size()); pl.extract_pattern(atoms, groups_, names, text_tokens, text ); pl.output(""); }
int main(int argc, char **argv) { #ifdef QUESO_HAS_MPI MPI_Init(&argc, &argv); #endif QUESO::EnvOptionsValues options; options.m_numSubEnvironments = 1; options.m_subDisplayFileName = "outputData/debug_output"; options.m_subDisplayAllowAll = 0; options.m_subDisplayAllowedSet.insert(0); options.m_seed = 1.0; options.m_checkingLevel = 1; options.m_displayVerbosity = 20; #ifdef QUESO_HAS_MPI QUESO::FullEnvironment *env = new QUESO::FullEnvironment(MPI_COMM_WORLD, "", "", &options); #else QUESO::FullEnvironment *env = new QUESO::FullEnvironment("", "", &options); #endif std::vector<std::string> names(1); names[0] = "my_name"; QUESO::VectorSpace<QUESO::GslVector, QUESO::GslMatrix> vec_space(*env, "vec_prefix", 1, &names); // 1x1 diagonal matrix containing the value 3.0 on the diagonal QUESO::GslMatrix * diag_matrix = vec_space.newDiagMatrix(3.0); if ((*diag_matrix)(0,0) != 3.0) { std::cerr << "newDiagMatrix test failed" << std::endl; return 1; } if (vec_space.globalIdOfFirstComponent() != 0) { std::cerr << "failed globalIdOfFirstComponent test" << std::endl; return 1; } // Create a vector QUESO::GslVector v1(vec_space.zeroVector()); v1.cwSet(2.0); // Now create a new vector QUESO::GslVector * v2 = vec_space.newVector(v1); if ((*v2)[0] != v1[0]) { std::cerr << "newVector test failed" << std::endl; return 1; } const QUESO::DistArray<std::string> *names_array = vec_space.componentsNamesArray(); std::cout << "Test print: componentsNamesArray: " << *names_array << std::endl; std::cout << "Test print: localComponentName: " << vec_space.localComponentName(0) << std::endl; std::cout << "Test print: printComponentsNames horizontally: "; vec_space.printComponentsNames(std::cout, true); std::cout << std::endl; std::cout << "Test print: printComponentsNames vertically: "; vec_space.printComponentsNames(std::cout, false); std::cout << std::endl; std::cout << "Test print: print: "; vec_space.print(std::cout); std::cout << std::endl; delete diag_matrix; #ifdef QUESO_HAS_MPI MPI_Finalize(); #endif return 0; }
bool operator==(const room_list &other) { return ids() == other.ids() && names() == other.names(); }
dbgTargetInfo::dbgTargetInfo( const wxString &target, dbgPgConn * conn, char targetType ) { wxString query = wxT("select t.*, ") wxT(" pg_catalog.oidvectortypes( t.argtypes ) as argtypenames, t.argtypes as argtypeoids,") wxT(" l.lanname, n.nspname, p.proretset, y.typname AS rettype") wxT(" from") wxT(" pldbg_get_target_info( '%s', '%c' ) t , pg_namespace n, pg_language l, pg_proc p, pg_type y") wxT(" where") wxT(" n.oid = t.schema and ") wxT(" l.oid = t.targetlang and " ) wxT(" p.oid = t.target and ") wxT(" y.oid = t.returntype"); dbgResultset *result = new dbgResultset(conn->waitForCommand(wxString::Format(query, target.c_str(), targetType))); if(result->getCommandStatus() != PGRES_TUPLES_OK) throw( std::runtime_error( result->getRawErrorMessage())); m_name = result->getString( wxString(COL_TARGET_NAME, wxConvUTF8)); m_schema = result->getString( wxString(COL_SCHEMA_NAME, wxConvUTF8)); m_language = result->getString( wxString(COL_LANGUAGE_NAME, wxConvUTF8)); m_argNames = result->getString( wxString(COL_ARG_NAMES, wxConvUTF8)); m_argModes = result->getString( wxString(COL_ARG_MODES, wxConvUTF8)); m_argTypes = result->getString( wxString(COL_ARG_TYPES, wxConvUTF8)); m_argTypeOids = result->getString( wxString(COL_ARG_TYPEOIDS, wxConvUTF8)); if (result->columnExists(wxString(COL_PACKAGE_OID, wxConvUTF8))) m_isFunction = result->getBool( wxString(COL_IS_FUNCTION, wxConvUTF8)); else m_isFunction = true; m_oid = result->getLong( wxString(COL_TARGET_OID, wxConvUTF8)); if (result->columnExists(wxString(COL_PACKAGE_OID, wxConvUTF8))) m_pkgOid = result->getLong( wxString(COL_PACKAGE_OID, wxConvUTF8)); else m_pkgOid = 0; m_fqName = result->getString( wxString(COL_FQ_NAME, wxConvUTF8)); m_returnsSet = result->getBool( wxString(COL_RETURNS_SET, wxConvUTF8)); m_returnType = result->getString( wxString(COL_RETURN_TYPE, wxConvUTF8)); // Parse out the argument types, names, and modes // By creating a tokenizer with wxTOKEN_STRTOK and a delimiter string // that contains ",{}", we can parse out PostgreSQL array strings like: // {int, varchar, numeric} wxStringTokenizer names(m_argNames, wxT( ",{}" ), wxTOKEN_STRTOK); wxStringTokenizer types(m_argTypes, wxT( ",{}" ), wxTOKEN_STRTOK); wxStringTokenizer typeOids(m_argTypeOids, wxT( ",{}" ), wxTOKEN_STRTOK); wxStringTokenizer modes(m_argModes, wxT( ",{}" ), wxTOKEN_STRTOK); // Create one wsArgInfo for each target argument m_argInCount = m_argOutCount = m_argInOutCount = 0; int argCount = 0; while( types.HasMoreTokens()) { argCount++; wxString argName = names.GetNextToken(); if( argName.IsEmpty()) argName.Printf( wxT( "$%d" ), argCount ); wsArgInfo argInfo( argName, types.GetNextToken(), modes.GetNextToken(), typeOids.GetNextToken()); if( argInfo.getMode() == wxT( "i" )) m_argInCount++; else if( argInfo.getMode() == wxT( "o" )) m_argOutCount++; else if( argInfo.getMode() == wxT( "b" )) m_argInOutCount++; m_argInfo.Add( argInfo ); } // Get the package initializer function OID. On 8.1 or below, this is // assumed to be the same as the package OID. On 8.2, we have an API :-) if (conn->EdbMinimumVersion(8, 2)) { PGresult *res; m_pkgInitOid = 0; res = conn->waitForCommand( wxT( "SELECT pldbg_get_pkg_cons(") + NumToStr(m_pkgOid) + wxT(");")); if (PQresultStatus(res) == PGRES_TUPLES_OK) { // Retrieve the query result and return it. m_pkgInitOid = StrToLong(wxString(PQgetvalue(res, 0, 0), wxConvUTF8)); // Cleanup & exit PQclear(res); } } else if (conn->GetIsEdb()) m_pkgInitOid = m_pkgOid; else m_pkgInitOid = 0; }
void WarningIncludeHeader(const Tokenizer &tokenizer, bool Progress, OutputFormat outputFormat, std::ostream &errout) { // A header is needed if: // * It contains some needed class declaration // * It contains some needed function declaration // * It contains some needed constant value // * It contains some needed variable // * It contains some needed enum // Extract all includes.. std::vector< std::list<IncludeInfo> > includes(tokenizer.ShortFileNames.size(), std::list< IncludeInfo >()); for (const Token *tok = tokenizer.tokens; tok; tok = tok->next) { if (strncmp(tok->str, "#include", 8) == 0) { // Get index of included file: unsigned int hfile; const char *includefile = tok->next->str; for (hfile = 0; hfile < tokenizer.ShortFileNames.size(); ++hfile) { if (SameFileName(tokenizer.ShortFileNames[hfile].c_str(), includefile)) break; } includes[tok->FileIndex].push_back(IncludeInfo(tok, hfile)); } } // System headers are checked differently.. std::vector<unsigned int> SystemHeaders(tokenizer.ShortFileNames.size(), 0); for (const Token *tok = tokenizer.tokens; tok; tok = tok->next) { if (strcmp(tok->str, "#include<>") == 0 || (SystemHeaders[tok->FileIndex] && strcmp(tok->str, "#include") == 0)) { // Get index of included file: const char *includefile = tok->next->str; for (unsigned int hfile = 0; hfile < tokenizer.ShortFileNames.size(); ++hfile) { if (SameFileName(tokenizer.ShortFileNames[hfile].c_str(), includefile)) { SystemHeaders[hfile] = 1; break; } } } } // extracted class names.. std::vector< std::set<std::string> > classes(tokenizer.ShortFileNames.size(), std::set<std::string>()); // extracted symbol names.. std::vector< std::set<std::string> > names(tokenizer.ShortFileNames.size(), std::set<std::string>()); // needed symbol/type names std::vector< std::set<std::string> > needed(tokenizer.ShortFileNames.size(), std::set<std::string>()); // symbol/type names that need at least a forward declaration std::vector< std::set<std::string> > needDeclaration(tokenizer.ShortFileNames.size(), std::set<std::string>()); // Extract symbols from the files.. { unsigned int indentlevel = 0; for (const Token *tok = tokenizer.tokens; tok; tok = tok->next) { // Don't extract symbols in the main source file if (tok->FileIndex == 0) continue; if (tok->next && tok->FileIndex != tok->next->FileIndex) indentlevel = 0; if (tok->str[0] == '{') indentlevel++; else if (indentlevel > 0 && tok->str[0] == '}') indentlevel--; if (indentlevel != 0) continue; // Class or namespace declaration.. // -------------------------------------- if (Match(tok,"class %var% {") || Match(tok,"class %var% :") || Match(tok,"struct %var% {")) classes[tok->FileIndex].insert(getstr(tok, 1)); else if (Match(tok, "namespace %var% {") || Match(tok, "extern %str% {")) { tok = gettok(tok,2); continue; } else if (Match(tok, "struct %var% ;") || Match(tok, "class %var% ;")) { // This type name is probably needed in any files that includes this file const std::string name(tok->next->str); for (unsigned int i = 0; i < tokenizer.ShortFileNames.size(); ++i) { if (i == tok->FileIndex) continue; for (std::list<IncludeInfo>::const_iterator it = includes[i].begin(); it != includes[i].end(); ++it) { if (it->hfile == tok->FileIndex) { needed[it->tok->FileIndex].insert(name); } } } continue; } // Variable declaration.. // -------------------------------------- else if (Match(tok, "%type% %var% ;") || Match(tok, "%type% %var% [") || Match(tok, "%type% %var% =")) names[tok->FileIndex].insert(getstr(tok, 1)); else if (Match(tok, "%type% * %var% ;") || Match(tok, "%type% * %var% [") || Match(tok, "%type% * %var% =")) names[tok->FileIndex].insert(getstr(tok, 2)); // enum.. // -------------------------------------- else if (strcmp(tok->str, "enum") == 0) { tok = tok->next; while (tok->next && tok->str[0]!=';') { if (IsName(tok->str)) names[tok->FileIndex].insert(tok->str); tok = tok->next; } } // function.. // -------------------------------------- else if (Match(tok,"%type% %var% (") || Match(tok,"%type% * %var% (")) { tok = tok->next; if (tok->str[0] == '*') tok = tok->next; names[tok->FileIndex].insert(tok->str); while (tok->next && tok->str[0] != ')') tok = tok->next; } // typedef.. // -------------------------------------- else if (strcmp(tok->str,"typedef")==0) { if (strcmp(getstr(tok,1),"enum")==0) continue; while (tok->str[0] != ';' && tok->next) { if (Match(tok, "%var% ;")) names[tok->FileIndex].insert(tok->str); tok = tok->next; } } // #define.. // -------------------------------------- else if (Match(tok, "#define %var%")) names[tok->FileIndex].insert(tok->next->str); } } // Get all needed symbols.. { // Which files contain implementation? std::vector<unsigned int> HasImplementation(tokenizer.ShortFileNames.size(), 0); int indentlevel = 0; for (const Token *tok1 = tokenizer.tokens; tok1; tok1 = tok1->next) { if (strncmp(tok1->str, "#include", 8) == 0) { tok1 = tok1->next; continue; } if (tok1->next && tok1->FileIndex != tok1->next->FileIndex) indentlevel = 0; // implementation begins.. else if (indentlevel == 0 && Match(tok1, ") {")) { // Go to the "{" while (tok1->str[0] != '{') tok1 = tok1->next; indentlevel = 1; HasImplementation[tok1->FileIndex] = 1; } else if (indentlevel >= 1) { if (tok1->str[0] == '{') ++indentlevel; else if (tok1->str[0] == '}') --indentlevel; } if (Match(tok1, ": %var% {") || Match(tok1, ": %type% %var% {")) { const std::string classname(getstr(tok1, (strcmp(getstr(tok1,2),"{")) ? 2 : 1)); needed[tok1->FileIndex].insert(classname); } if (indentlevel == 0 && Match(tok1, "%type% * %var%")) { if (Match(gettok(tok1,3), "[,;()[]")) { needDeclaration[tok1->FileIndex].insert(tok1->str); tok1 = gettok(tok1, 2); continue; } } if (Match(tok1, "struct") || Match(tok1, "class")) { continue; } if (IsName(tok1->str) && !Match(tok1->next, "{")) needed[tok1->FileIndex].insert(tok1->str); } // Move needDeclaration symbols to needed for all files that has // implementation.. for (unsigned int i = 0; i < HasImplementation.size(); ++i) { if (HasImplementation[i]) { needed[i].insert(needDeclaration[i].begin(), needDeclaration[i].end()); } } } // Remove keywords.. for (unsigned int i = 0; i < tokenizer.ShortFileNames.size(); ++i) { const char *keywords[] = { "defined", // preprocessor "void", "bool", "char", "short", "int", "long", "float", "double", "false", "true", "std", "if", "for", "while", NULL }; for (unsigned int k = 0; keywords[k]; ++k) { needed[i].erase(keywords[k]); needDeclaration[i].erase(keywords[k]); } } // Check if there are redundant includes.. for (unsigned int fileIndex = 0; fileIndex < tokenizer.ShortFileNames.size(); ++fileIndex) { // Is the current file a system header? If so don't check it. if (SystemHeaders[fileIndex]) continue; // Check if each include is needed.. for (std::list<IncludeInfo>::const_iterator include = includes[fileIndex].begin(); include != includes[fileIndex].end(); ++include) { // include not found if (include->hfile >= tokenizer.ShortFileNames.size()) continue; if (Progress) { std::cout << "progress: file " << tokenizer.ShortFileNames[fileIndex] << " checking include " << tokenizer.ShortFileNames[include->hfile] << std::endl; } // Get all includes std::set<unsigned int> AllIncludes; bool notfound = false; AllIncludes.insert(include->hfile); if (SystemHeaders[include->hfile]) getincludes(includes, include->hfile, AllIncludes, notfound); // match symbols: needed bool Needed(false); for (std::set<unsigned int>::const_iterator it = AllIncludes.begin(); it != AllIncludes.end(); ++it) { const std::string sym = matchSymbols(needed[fileIndex], classes[*it], names[*it]); if (!sym.empty()) { if (Progress) std::cout << "progress: needed symbol '" << sym << "'" << std::endl; Needed = true; break; } } // Check if local header is needed indirectly.. if (!Needed && !SystemHeaders[include->hfile]) { std::string needed_header; getincludes(includes, include->hfile, AllIncludes, notfound); for (std::set<unsigned int>::const_iterator it = AllIncludes.begin(); it != AllIncludes.end(); ++it) { const std::string sym = matchSymbols(needed[fileIndex], classes[*it], names[*it]); if (!sym.empty()) { needed_header = tokenizer.ShortFileNames[*it]; if (Progress) std::cout << "progress: needed symbol '" << sym << "'" << std::endl; Needed = true; break; } } if (Needed) { std::ostringstream errmsg; errmsg << "Inconclusive results: The included header '" << include->tok->next->str << "' is not needed. However it is needed indirectly because it includes '" << needed_header << "'. If it is included by intention use '--skip " << include->tok->next->str << "' to remove false positives."; ReportErr(tokenizer, outputFormat, include->tok, "HeaderNotNeeded", errmsg.str(), errout); } } if (!Needed) { if (!notfound) { bool NeedDeclaration(false); for (std::set<unsigned int>::const_iterator it = AllIncludes.begin(); it != AllIncludes.end(); ++it) { std::set<std::string> empty; const std::string sym = matchSymbols(needDeclaration[fileIndex], classes[*it], empty); if (!sym.empty()) { NeedDeclaration = true; break; } } std::ostringstream errmsg; errmsg << "The included header '" << include->tok->next->str << "' is not needed"; if (NeedDeclaration) errmsg << " (but forward declaration is needed)"; ReportErr(tokenizer, outputFormat, include->tok, "HeaderNotNeeded", errmsg.str(), errout); } else if (Progress) std::cout << "progress: bail out (header not found)" << std::endl; } } } }
int main(int argc, char **argv) { MPI_Init(&argc, &argv); QUESO::EnvOptionsValues options; options.m_numSubEnvironments = 1; options.m_subDisplayFileName = "outputData/testIntersectionSubsetContains"; options.m_subDisplayAllowAll = 0; options.m_subDisplayAllowedSet.insert(0); options.m_seed = 1.0; options.m_checkingLevel = 1; options.m_displayVerbosity = 55; QUESO::FullEnvironment *env = new QUESO::FullEnvironment(MPI_COMM_WORLD, "", "", &options); std::vector<std::string> names(1); names[0] = "my_name"; // Create a vector space QUESO::VectorSpace<QUESO::GslVector, QUESO::GslMatrix> vec_space(*env, "vec_prefix", 1, &names); // Create two vector sets QUESO::GslVector min1(vec_space.zeroVector()); min1[0] = 0.0; QUESO::GslVector max1(vec_space.zeroVector()); max1[0] = 1.0; QUESO::BoxSubset<QUESO::GslVector, QUESO::GslMatrix> set1("set1", vec_space, min1, max1); // Now for the second one QUESO::GslVector min2(vec_space.zeroVector()); min2[0] = 0.5; QUESO::GslVector max2(vec_space.zeroVector()); max2[0] = 1.5; QUESO::BoxSubset<QUESO::GslVector, QUESO::GslMatrix> set2("set1", vec_space, min2, max2); // Create their intersection QUESO::IntersectionSubset<QUESO::GslVector, QUESO::GslMatrix> intersection( "intersection", vec_space, 1.0, set1, set2); // Test the containment bool does_contain; QUESO::GslVector test_vec(vec_space.zeroVector()); // Should be true test_vec[0] = 0.75; does_contain = intersection.contains(test_vec); if (!does_contain) { std::cerr << "First IntersectionSubset contains test failed" << std::endl; return 1; } // Should be false test_vec[0] = 2.0; does_contain = intersection.contains(test_vec); if (does_contain) { std::cerr << "Second contains test failed" << std::endl; return 1; } // Print out some info intersection.print(std::cout); MPI_Finalize(); return 0; }
void main() { int sss,q,ll,gd=DETECT,p,gm,area,a=(450-(50*5)),d,cat=77,ch,dh,eh,t1,t2,t12,t22,len,cc,hh; char *str,*str1,*tim; initgraph(&gd,&gm,""); p=1; front(); dr: viewport(); q=menu(); if(q==3) { arun: hh=help(); if(hh==1) { how(); goto arun; } if(hh==2) { select(); goto arun; } if(hh==3) { credit(); goto arun; } if(hh==4) { design(); goto arun; } if(hh==5) goto dr; } if(q==2) { rr: ll=sivakumar(); if(ll==1) { p=m2(); goto rr; } if(ll==2) { a=speed(); viewport(); goto rr; } if(ll==3) { topscore(); goto rr; } if(ll==4) goto dr; } if(q==4) exit(0); if(q==1) { names(); hide(); viewport(); x[0]=85; x[1]=70; x[2]=55; x[3]=40; y[0]=y[1]=y[2]=y[3]=35; setcolor(4); rectangle(24,19,626,396); ra(); setcolor(15); setfillstyle(1,10); bar(32,32,43,43); area=imagesize(30,30,45,45); buff=malloc(area); getimage(30,30,45,45,buff); putimage(30,30,buff,XOR_PUT); setpos(0,0); setfillstyle(1,0); bar(100,100,500,350); prakash(p); level=p; putimage(40,35,buff,XOR_PUT); putimage(55,35,buff,XOR_PUT); putimage(70,35,buff,XOR_PUT); putimage(85,35,buff,XOR_PUT); textcolor(GREEN+BLINK); len=0; status("Game Play: Arrow keys Menu: Esc Pause (or) Play: Others key"); while(1) { sss=getpixel(5,5); if(sss!=0); { setfillstyle(SOLID_FILL,0); bar(0,0,15,15); } if(((i-4)%11==0)&&(bon==0)&&(len!=(i-4))) { len=(i-4); gettime(&t); bonous(); bon=1; t1=t.ti_sec; cc=10; } gettime(&t); if((t1!=t.ti_sec)&&(bon==1)) { cc--; t1=t.ti_sec; itoa(cc,tim,10); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); outtextxy(500,0,tim); } if((cc==0)&&(bon==1)) { putimage(xc1,yc1,f2,XOR_PUT); bar(470,0,530,18); bon=0; } gotoxy(68,1); setcolor(6); itoa(score,str,10); setfillstyle(1,0); settextstyle(3,0,1); if(strcmp(str,str1)!=0) { bar(80,400,350,450); outtextxy(100,420,"Score : "); outtextxy(180,420,str); strcpy(str1,str); } if(kbhit()) { // ch=getch(); dh=getch(); cat=dh; } else { arrange(x,y,i); if(set==0) food(); if(cat!=dupli) cat=lock(cat,dupli); switch(cat) { case 72: if(y[1]==20) y[0]=380; else y[0]=y[1]-15; x[0]=x[1]; d=getpixel(x[0]+8,y[0]+8); if((d==10)||(d==14)) doctor(); if((d==4)&&(bon==1)) { i++; sound(1000); delay(90); nosound(); bon=0; score+=(cc*10); putimage(xc1,yc1,f2,XOR_PUT); putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i],y[i],buff,XOR_PUT); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); } else if(d==15) { i++; set=0; sound(800); delay(40); score+=bb; nosound(); putimage(x[0],y[0],buff,XOR_PUT); } else { putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i-1],y[i-1],buff,XOR_PUT); } delay(a); break; case 80: if(y[1]==380) y[0]=20; else y[0]=y[1]+15; x[0]=x[1]; d=getpixel(x[0]+8,y[0]+8); if((d==10)||(d==14)) doctor(); if((d==4)&&(bon==1)) { i++; sound(1000); delay(90); nosound(); bon=0; score+=(cc*10); putimage(xc1,yc1,f2,XOR_PUT); putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i],y[i],buff,XOR_PUT); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); } else if(d==15) { i++; score+=bb; sound(800); delay(40); set=0; nosound(); putimage(x[0],y[0],buff,XOR_PUT); } else { putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i-1],y[i-1],buff,XOR_PUT); } delay(a); break; case 75: if(x[1]==25) x[0]=610; else x[0]=x[1]-15; y[0]=y[1]; d=getpixel(x[0]+8,y[0]+8); if((d==10)||(d==14)) doctor(); if((d==4)&&(bon==1)) { i++; sound(1000); delay(90); nosound(); bon=0; score+=(cc*10); putimage(xc1,yc1,f2,XOR_PUT); putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i],y[i],buff,XOR_PUT); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); } else if(d==15) { i++; sound(800); delay(40); set=0; nosound(); score+=bb; putimage(x[0],y[0],buff,XOR_PUT); } else { putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i-1],y[i-1],buff,XOR_PUT); } delay(a); break; case 77: if(x[1]==610) x[0]=25; else x[0]=x[1]+15; y[0]=y[1]; d=getpixel(x[0]+8,y[0]+8); if((d==10)||(d==14)) doctor(); if((d==4)&&(bon==1)) { i++; sound(1000); delay(90); nosound(); bon=0; score+=(cc*10); putimage(xc1,yc1,f2,XOR_PUT); putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i],y[i],buff,XOR_PUT); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); } else if(d==15) { i++; set=0; sound(800); delay(40); score+=bb; nosound(); putimage(x[0],y[0],buff,XOR_PUT); } else { putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i-1],y[i-1],buff,XOR_PUT); } delay(a); break; case 27: goto dx; // break; } dupli=cat; } } } dx: call(); }
Int_t GetNumberOfInputVariablesMultiClass( TDirectory *dir ){ std::vector<TString> names(GetInputVariableNames(dir)); return names.end() - names.begin(); }
wordList distributionFunctionObject::fileNames() { stringList onames(this->componentNames()); wordList names(onames.size()); forAll(names,i) { names[i]=this->baseName()+"_"+onames[i]; }
int main(int argc, char **argv){ ros::init (argc, argv, "move_arm_joint_goal_test"); ros::NodeHandle nh; actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> move_arm("move_arm",true); // planning_environment::CollisionModels* collisionModels; planning_models::KinematicState* kinematicState; collisionModels = new planning_environment::CollisionModels("robot_description"); kinematicState = new planning_models::KinematicState(collisionModels->getKinematicModel()); ros::service::waitForService(SET_PLANNING_SCENE_DIFF_NAME); ROS_INFO("Waiting for planning scene service"); ros::ServiceClient set_planning_scene_diff_client = nh.serviceClient<arm_navigation_msgs::SetPlanningSceneDiff>(SET_PLANNING_SCENE_DIFF_NAME); set_planning_scene_diff_client.waitForExistence(); ROS_INFO("Planning scene service is now available"); arm_navigation_msgs::SetPlanningSceneDiff::Request planning_scene_req; arm_navigation_msgs::SetPlanningSceneDiff::Response planning_scene_res; planning_environment::convertKinematicStateToRobotState(*kinematicState, ros::Time::now(), collisionModels->getWorldFrameId(), planning_scene_req.planning_scene_diff.robot_state); if(!set_planning_scene_diff_client.call(planning_scene_req, planning_scene_res)) { ROS_WARN("Can't get planning scene"); } ROS_INFO("Successfully set planning scene"); collisionModels->revertPlanningScene(kinematicState); collisionModels->setPlanningScene(planning_scene_res.planning_scene); // move_arm.waitForServer(); ROS_INFO("Connected to server"); arm_navigation_msgs::MoveArmGoal goalB; std::vector<std::string> names(9); names[0] = "body1"; names[1] = "body2"; names[2] = "body3"; names[3] = "body4"; names[4] = "body5"; names[5] = "body6"; names[6] = "body7"; names[7] = "body8"; names[8] = "body9"; goalB.motion_plan_request.group_name = "arm_cartesian"; goalB.motion_plan_request.num_planning_attempts = 1; goalB.motion_plan_request.allowed_planning_time = ros::Duration(5.0); goalB.motion_plan_request.planner_id= std::string(""); goalB.planner_service_name = std::string("ompl_planning/plan_kinematic_path"); goalB.motion_plan_request.goal_constraints.joint_constraints.resize(names.size()); for (unsigned int i = 0 ; i < goalB.motion_plan_request.goal_constraints.joint_constraints.size(); ++i) { goalB.motion_plan_request.goal_constraints.joint_constraints[i].joint_name = names[i]; goalB.motion_plan_request.goal_constraints.joint_constraints[i].position = 0.0; goalB.motion_plan_request.goal_constraints.joint_constraints[i].tolerance_below = 0.1; goalB.motion_plan_request.goal_constraints.joint_constraints[i].tolerance_above = 0.1; } goalB.motion_plan_request.goal_constraints.joint_constraints[1].position = -0.5; goalB.motion_plan_request.goal_constraints.joint_constraints[3].position = -0.2; goalB.motion_plan_request.goal_constraints.joint_constraints[5].position = -0.15; if (nh.ok()) { bool finished_within_time = false; move_arm.sendGoal(goalB); finished_within_time = move_arm.waitForResult(ros::Duration(200.0)); if (!finished_within_time) { move_arm.cancelGoal(); ROS_INFO("Timed out achieving goal A"); } else { actionlib::SimpleClientGoalState state = move_arm.getState(); bool success = (state == actionlib::SimpleClientGoalState::SUCCEEDED); if(success) ROS_INFO("Action finished: %s",state.toString().c_str()); else ROS_INFO("Action failed: %s",state.toString().c_str()); } } ros::shutdown(); }
void ColorGradientPreparation::configureProperty(reflectionzeug::AbstractProperty * property) const { property->setOption("pixmapSize", reflectionzeug::Variant::fromValue(iconSize())); property->setOption("choices", reflectionzeug::Variant::fromValue(names())); property->setOption("pixmaps", reflectionzeug::Variant::fromValue(pixmaps())); }
dbgTargetInfo::dbgTargetInfo( const wxString &target, dbgPgConn *conn, char targetType ) { wxString query = wxT("select t.*, ") wxT(" pg_catalog.oidvectortypes( t.argtypes ) as argtypenames, t.argtypes as argtypeoids,") wxT(" l.lanname, n.nspname, p.proretset, y.typname AS rettype") wxT(" from") wxT(" pldbg_get_target_info( '%s', '%c' ) t , pg_namespace n, pg_language l, pg_proc p, pg_type y") wxT(" where") wxT(" n.oid = t.schema and ") wxT(" l.oid = t.targetlang and " ) wxT(" p.oid = t.target and ") wxT(" y.oid = t.returntype"); dbgResultset *result = new dbgResultset(conn->waitForCommand(wxString::Format(query, target.c_str(), targetType))); if(result->getCommandStatus() != PGRES_TUPLES_OK) throw( std::runtime_error( result->getRawErrorMessage())); m_name = result->getString( wxString(COL_TARGET_NAME, wxConvUTF8)); m_schema = result->getString( wxString(COL_SCHEMA_NAME, wxConvUTF8)); m_language = result->getString( wxString(COL_LANGUAGE_NAME, wxConvUTF8)); m_argNames = result->getString( wxString(COL_ARG_NAMES, wxConvUTF8)); m_argModes = result->getString( wxString(COL_ARG_MODES, wxConvUTF8)); m_argTypes = result->getString( wxString(COL_ARG_TYPES, wxConvUTF8)); m_argTypeOids = result->getString( wxString(COL_ARG_TYPEOIDS, wxConvUTF8)); // get arg defvals if they exist if (result->columnExists(wxString(COL_ARG_DEFVALS, wxConvUTF8))) m_argDefVals = result->getString( wxString(COL_ARG_DEFVALS, wxConvUTF8)); if (result->columnExists(wxString(COL_IS_FUNCTION, wxConvUTF8))) m_isFunction = result->getBool( wxString(COL_IS_FUNCTION, wxConvUTF8)); else m_isFunction = true; m_oid = result->getLong( wxString(COL_TARGET_OID, wxConvUTF8)); if (result->columnExists(wxString(COL_PACKAGE_OID, wxConvUTF8))) m_pkgOid = result->getLong( wxString(COL_PACKAGE_OID, wxConvUTF8)); else m_pkgOid = 0; m_fqName = result->getString( wxString(COL_FQ_NAME, wxConvUTF8)); m_returnsSet = result->getBool( wxString(COL_RETURNS_SET, wxConvUTF8)); m_returnType = result->getString( wxString(COL_RETURN_TYPE, wxConvUTF8)); // Parse out the argument types, names, and modes // By creating a tokenizer with wxTOKEN_STRTOK and a delimiter string // that contains ",{}", we can parse out PostgreSQL array strings like: // {int, varchar, numeric} wxStringTokenizer names(m_argNames, wxT( ",{}" ), wxTOKEN_STRTOK); wxStringTokenizer types(m_argTypes, wxT( ",{}" ), wxTOKEN_STRTOK); wxStringTokenizer typeOids(m_argTypeOids, wxT( ",{}" ), wxTOKEN_STRTOK); wxStringTokenizer modes(m_argModes, wxT( ",{}" ), wxTOKEN_STRTOK); wxStringTokenizer defvals(m_argDefVals, wxT( ",{}" ), wxTOKEN_STRTOK); // Create one wsArgInfo for each target argument m_argInCount = m_argOutCount = m_argInOutCount = 0; int argCount = 0; while( types.HasMoreTokens()) { argCount++; wxString argName = names.GetNextToken(); wxString defVal; if( argName.IsEmpty()) argName.Printf( wxT( "$%d" ), argCount ); // In EDBAS 90, if an SPL-function has both an OUT-parameter // and a return value (which is not possible on PostgreSQL otherwise), // the return value is transformed into an extra OUT-parameter // named "_retval_" if (argName == wxT("_retval_") && conn->EdbMinimumVersion(9, 0)) { // this will be the return type for this object m_returnType = types.GetNextToken(); // consume uniformly, mode will definitely be "OUT" modes.GetNextToken(); // ignore OID also.. typeOids.GetNextToken(); continue; } wsArgInfo argInfo( argName, types.GetNextToken(), modes.GetNextToken(), typeOids.GetNextToken()); if( argInfo.getMode() == wxT( "i" )) m_argInCount++; else if( argInfo.getMode() == wxT( "o" )) m_argOutCount++; else if( argInfo.getMode() == wxT( "b" )) m_argInOutCount++; // see if this arg has a def value and add if so. If we see an empty // string "", what should we do? Infact "" might be a valid default // value in some cases, so for now store "" too. Note that we will // store the "" only if this is stringlike type and nothing otherwise.. defVal = (defvals.GetNextToken()).Strip ( wxString::both ); if (argInfo.isValidDefVal(defVal)) { // remove starting/trailing quotes defVal.Replace( wxT( "\"" ), wxT( "" )); argInfo.setValue(defVal); } m_argInfo.Add( argInfo ); } // Get the package initializer function OID. On 8.1 or below, this is // assumed to be the same as the package OID. On 8.2, we have an API :-) if (conn->EdbMinimumVersion(8, 2)) { PGresult *res; m_pkgInitOid = 0; res = conn->waitForCommand( wxT( "SELECT pldbg_get_pkg_cons(") + NumToStr(m_pkgOid) + wxT(");")); if (PQresultStatus(res) == PGRES_TUPLES_OK) { // Retrieve the query result and return it. m_pkgInitOid = StrToLong(wxString(PQgetvalue(res, 0, 0), wxConvUTF8)); // Cleanup & exit PQclear(res); } } else if (conn->GetIsEdb()) m_pkgInitOid = m_pkgOid; else m_pkgInitOid = 0; }
void Table::loadTuplesFrom(SerializeInputBE &serialize_io, Pool *stringPool, ReferenceSerializeOutput *uniqueViolationOutput, bool shouldDRStreamRow) { /* * directly receives a VoltTable buffer. * [00 01] [02 03] [04 .. 0x] * rowstart colcount colcount * 1 byte (column types) * * [0x+1 .. 0y] * colcount * strings (column names) * * [0y+1 0y+2 0y+3 0y+4] * rowcount * * [0y+5 .. end] * rowdata */ // todo: just skip ahead to this position serialize_io.readInt(); // rowstart serialize_io.readByte(); int16_t colcount = serialize_io.readShort(); assert(colcount >= 0); // Store the following information so that we can provide them to the user // on failure ValueType types[colcount]; boost::scoped_array<std::string> names(new std::string[colcount]); // skip the column types for (int i = 0; i < colcount; ++i) { types[i] = (ValueType) serialize_io.readEnumInSingleByte(); } // skip the column names for (int i = 0; i < colcount; ++i) { names[i] = serialize_io.readTextString(); } // Check if the column count matches what the temp table is expecting int16_t expectedColumnCount = static_cast<int16_t>(m_schema->columnCount() + m_schema->hiddenColumnCount()); if (colcount != expectedColumnCount) { std::stringstream message(std::stringstream::in | std::stringstream::out); message << "Column count mismatch. Expecting " << expectedColumnCount << ", but " << colcount << " given" << std::endl; message << "Expecting the following columns:" << std::endl; message << debug() << std::endl; message << "The following columns are given:" << std::endl; for (int i = 0; i < colcount; i++) { message << "column " << i << ": " << names[i] << ", type = " << getTypeName(types[i]) << std::endl; } throw SerializableEEException(VOLT_EE_EXCEPTION_TYPE_EEEXCEPTION, message.str().c_str()); } loadTuplesFromNoHeader(serialize_io, stringPool, uniqueViolationOutput, shouldDRStreamRow); }
void FunctionArguments::check() { if( m_args.size() > m_max_args ) { std::string msg = m_function_name; msg += "() takes exactly "; msg += int_to_string( m_max_args ); msg += " arguments ("; msg += int_to_string( m_args.size() ); msg += " given)"; throw Py::TypeError( msg ); } Py::Tuple::size_type t_i; // place all the positional args in the checked args dict for( t_i=0; t_i<m_args.size(); t_i++ ) { m_checked_args[ m_arg_desc[t_i].m_arg_name ] = m_args[t_i]; } // look for args by name in the kws dict for( t_i=0; t_i<m_max_args; t_i++ ) { const argument_description &arg_desc = m_arg_desc[t_i]; // check for duplicate if( m_kws.hasKey( arg_desc.m_arg_name ) ) { if( m_checked_args.hasKey( arg_desc.m_arg_name ) ) { std::string msg = m_function_name; msg += "() multiple values for keyword argument '"; msg += arg_desc.m_arg_name; msg += "'"; throw Py::TypeError( msg ); } m_checked_args[ arg_desc.m_arg_name ] = m_kws[ arg_desc.m_arg_name ]; } } // check for names we dont known about Py::List::size_type l_i; Py::List names( m_kws.keys() ); for( l_i=0; l_i< names.length(); l_i++ ) { bool found = false; Py::String py_name( names[l_i] ); std::string name( py_name.as_std_string( g_utf_8 ) ); for( t_i=0; t_i<m_max_args; t_i++ ) { if( name == m_arg_desc[t_i].m_arg_name ) { found = true; break; } } if( !found ) { std::string msg = m_function_name; msg += "() got an unexpected keyword argument '"; msg += name; msg += "'"; throw Py::TypeError( msg ); } } // check for min args for( t_i=0; t_i<m_min_args; t_i++ ) { const argument_description &arg_desc = m_arg_desc[t_i]; // check for duplicate if( !m_checked_args.hasKey( arg_desc.m_arg_name ) ) { std::string msg = m_function_name; msg += "() required argument '"; msg += arg_desc.m_arg_name; msg += "'"; throw Py::TypeError( msg ); } } }
folly::Future<int32_t> service_with_special_namesSvIf::future_names() { return apache::thrift::detail::si::future([&] { return names(); }); }
int main(int argc, char **argv) { // Init the ROS node ros::init (argc, argv, "move_right_arm_joint_goal_test"); // Precondition: Valid clock ros::NodeHandle nh; if (!ros::Time::waitForValid(ros::WallDuration(5.0))) // NOTE: Important when using simulated clock { ROS_FATAL("Timed-out waiting for valid time."); return EXIT_FAILURE; } // Action client for sending motion planing requests actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> move_arm("move_right_arm_torso", true); // Wait for the action client to be connected to the server ROS_INFO("Connecting to server..."); if (!move_arm.waitForServer(ros::Duration(5.0))) { ROS_ERROR("Timed-out waiting for the move_arm action server."); return EXIT_FAILURE; } ROS_INFO("Connected to server."); // Prepare motion plan request with joint-space goal arm_navigation_msgs::MoveArmGoal goal; std::vector<std::string> names(9); names[0] = "torso_1_joint"; names[1] = "torso_2_joint"; names[2] = "arm_right_1_joint"; names[3] = "arm_right_2_joint"; names[4] = "arm_right_3_joint"; names[5] = "arm_right_4_joint"; names[6] = "arm_right_5_joint"; names[7] = "arm_right_6_joint"; names[8] = "arm_right_7_joint"; goal.motion_plan_request.group_name = "right_arm_torso"; goal.motion_plan_request.num_planning_attempts = 1; goal.motion_plan_request.allowed_planning_time = ros::Duration(5.0); goal.motion_plan_request.planner_id= std::string(""); goal.planner_service_name = std::string("ompl_planning/plan_kinematic_path"); goal.motion_plan_request.goal_constraints.joint_constraints.resize(names.size()); for (unsigned int i = 0 ; i < goal.motion_plan_request.goal_constraints.joint_constraints.size(); ++i) { goal.motion_plan_request.goal_constraints.joint_constraints[i].joint_name = names[i]; goal.motion_plan_request.goal_constraints.joint_constraints[i].position = 0.0; goal.motion_plan_request.goal_constraints.joint_constraints[i].tolerance_below = 0.05; goal.motion_plan_request.goal_constraints.joint_constraints[i].tolerance_above = 0.05; } goal.motion_plan_request.goal_constraints.joint_constraints[0].position = 0.0; goal.motion_plan_request.goal_constraints.joint_constraints[1].position = 0.0; goal.motion_plan_request.goal_constraints.joint_constraints[2].position = 1.2; goal.motion_plan_request.goal_constraints.joint_constraints[3].position = 0.15; goal.motion_plan_request.goal_constraints.joint_constraints[4].position = -1.5708; goal.motion_plan_request.goal_constraints.joint_constraints[5].position = 1.3; goal.motion_plan_request.goal_constraints.joint_constraints[6].position = 0.0; goal.motion_plan_request.goal_constraints.joint_constraints[7].position = 0.0; goal.motion_plan_request.goal_constraints.joint_constraints[8].position = 0.0; // Send motion plan request if (nh.ok()) { bool finished_within_time = false; move_arm.sendGoal(goal); finished_within_time = move_arm.waitForResult(ros::Duration(15.0)); if (!finished_within_time) { move_arm.cancelGoal(); ROS_INFO("Timed out achieving joint-space goal."); } else { actionlib::SimpleClientGoalState state = move_arm.getState(); bool success = (state == actionlib::SimpleClientGoalState::SUCCEEDED); if(success) ROS_INFO("Action finished: %s",state.toString().c_str()); else ROS_INFO("Action failed: %s",state.toString().c_str()); } } ros::shutdown(); }
void ICUServiceTest::testAPI_Two() { UErrorCode status = U_ZERO_ERROR; TestStringService service; service.registerFactory(new AnonymousStringFactory(), status); // anonymous factory will still handle the id { UErrorCode status = U_ZERO_ERROR; const UnicodeString en_US = "en_US"; UnicodeString* result = (UnicodeString*)service.get(en_US, status); confirmEqual("21) locale", result, &en_US); delete result; } // still normalizes id { UErrorCode status = U_ZERO_ERROR; const UnicodeString en_US_BAR = "en_US_BAR"; UnicodeString resultID; UnicodeString* result = (UnicodeString*)service.get("EN_us_bar", &resultID, status); confirmEqual("22) locale", &resultID, &en_US_BAR); delete result; } // we can override for particular ids UnicodeString* singleton0 = new UnicodeString("Zero"); service.registerInstance(singleton0, "en_US_BAR", status); { UErrorCode status = U_ZERO_ERROR; UnicodeString* result = (UnicodeString*)service.get("en_US_BAR", status); confirmEqual("23) override super", result, singleton0); delete result; } // empty service should not recognize anything service.reset(); { UErrorCode status = U_ZERO_ERROR; UnicodeString* result = (UnicodeString*)service.get("en_US", status); confirmIdentical("24) empty", result, NULL); } // create a custom multiple key factory { UnicodeString xids[] = { "en_US_VALLEY_GIRL", "en_US_VALLEY_BOY", "en_US_SURFER_GAL", "en_US_SURFER_DUDE" }; int32_t count = sizeof(xids)/sizeof(UnicodeString); ICUServiceFactory* f = new TestMultipleKeyStringFactory(xids, count, "Later"); service.registerFactory(f, status); } // iterate over the visual ids returned by the multiple factory { UErrorCode status = U_ZERO_ERROR; UVector ids(uprv_deleteUObject, uhash_compareUnicodeString, 0, status); service.getVisibleIDs(ids, status); for (int i = 0; i < ids.size(); ++i) { const UnicodeString* id = (const UnicodeString*)ids[i]; UnicodeString* result = (UnicodeString*)service.get(*id, status); if (result) { logln(" " + *id + " --> " + *result); delete result; } else { errln("could not find " + *id); } } // four visible ids confirmIdentical("25) visible ids", ids.size(), 4); } // iterate over the display names { UErrorCode status = U_ZERO_ERROR; UVector names(status); service.getDisplayNames(names, status); for (int i = 0; i < names.size(); ++i) { const StringPair* pair = (const StringPair*)names[i]; logln(" " + pair->displayName + " --> " + pair->id); } confirmIdentical("26) display names", names.size(), 4); } // no valid display name { UnicodeString name; service.getDisplayName("en_US_VALLEY_GEEK", name); confirmBoolean("27) get display name", name.isBogus()); } { UnicodeString name; service.getDisplayName("en_US_SURFER_DUDE", name, Locale::getEnglish()); confirmStringsEqual("28) get display name", name, "English (United States, SURFER_DUDE)"); } // register another multiple factory { UnicodeString xids[] = { "en_US_SURFER", "en_US_SURFER_GAL", "en_US_SILICON", "en_US_SILICON_GEEK", }; int32_t count = sizeof(xids)/sizeof(UnicodeString); ICUServiceFactory* f = new TestMultipleKeyStringFactory(xids, count, "Rad dude"); service.registerFactory(f, status); } // this time, we have seven display names // Rad dude's surfer gal 'replaces' Later's surfer gal { UErrorCode status = U_ZERO_ERROR; UVector names(status); service.getDisplayNames(names, Locale("es"), status); for (int i = 0; i < names.size(); ++i) { const StringPair* pair = (const StringPair*)names[i]; logln(" " + pair->displayName + " --> " + pair->id); } confirmIdentical("29) display names", names.size(), 7); } // we should get the display name corresponding to the actual id // returned by the id we used. { UErrorCode status = U_ZERO_ERROR; UnicodeString actualID; UnicodeString id = "en_us_surfer_gal"; UnicodeString* gal = (UnicodeString*)service.get(id, &actualID, status); if (gal != NULL) { UnicodeString displayName; logln("actual id: " + actualID); service.getDisplayName(actualID, displayName, Locale::getEnglish()); logln("found actual: " + *gal + " with display name: " + displayName); confirmBoolean("30) found display name for actual", !displayName.isBogus()); service.getDisplayName(id, displayName, Locale::getEnglish()); logln("found actual: " + *gal + " with display name: " + displayName); confirmBoolean("31) found display name for query", displayName.isBogus()); delete gal; } else { errln("30) service could not find entry for " + id); } } // this should be handled by the 'dude' factory, since it overrides en_US_SURFER. { UErrorCode status = U_ZERO_ERROR; UnicodeString actualID; UnicodeString id = "en_US_SURFER_BOZO"; UnicodeString* bozo = (UnicodeString*)service.get(id, &actualID, status); if (bozo != NULL) { UnicodeString displayName; service.getDisplayName(actualID, displayName, Locale::getEnglish()); logln("found actual: " + *bozo + " with display name: " + displayName); confirmBoolean("32) found display name for actual", !displayName.isBogus()); service.getDisplayName(id, displayName, Locale::getEnglish()); logln("found actual: " + *bozo + " with display name: " + displayName); confirmBoolean("33) found display name for query", displayName.isBogus()); delete bozo; } else { errln("32) service could not find entry for " + id); } } // certainly not default... { confirmBoolean("34) is default ", !service.isDefault()); } { UErrorCode status = U_ZERO_ERROR; UVector ids(uprv_deleteUObject, uhash_compareUnicodeString, 0, status); service.getVisibleIDs(ids, status); for (int i = 0; i < ids.size(); ++i) { const UnicodeString* id = (const UnicodeString*)ids[i]; msgstr(*id + "? ", service.get(*id, status)); } logstr("valleygirl? ", service.get("en_US_VALLEY_GIRL", status)); logstr("valleyboy? ", service.get("en_US_VALLEY_BOY", status)); logstr("valleydude? ", service.get("en_US_VALLEY_DUDE", status)); logstr("surfergirl? ", service.get("en_US_SURFER_GIRL", status)); } }
UniValue name_filter (const UniValue& params, bool fHelp) { if (fHelp || params.size () > 5) throw std::runtime_error ( "name_filter (\"regexp\" (\"maxage\" (\"from\" (\"nb\" (\"stat\")))))\n" "\nScan and list names matching a regular expression.\n" "\nArguments:\n" "1. \"regexp\" (string, optional) filter names with this regexp\n" "2. \"maxage\" (numeric, optional, default=36000) only consider names updated in the last \"maxage\" blocks; 0 means all names\n" "3. \"from\" (numeric, optional, default=0) return from this position onward; index starts at 0\n" "4. \"nb\" (numeric, optional, default=0) return only \"nb\" entries; 0 means all\n" "5. \"stat\" (string, optional) if set to the string \"stat\", print statistics instead of returning the names\n" "\nResult:\n" "[\n" + getNameInfoHelp (" ", ",") + " ...\n" "]\n" "\nExamples:\n" + HelpExampleCli ("name_filter", "\"\" 5") + HelpExampleCli ("name_filter", "\"^id/\"") + HelpExampleCli ("name_filter", "\"^id/\" 36000 0 0 \"stat\"") + HelpExampleRpc ("name_scan", "\"^d/\"") ); if (IsInitialBlockDownload ()) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Namecoin is downloading blocks..."); /* ********************** */ /* Interpret parameters. */ bool haveRegexp(false); boost::xpressive::sregex regexp; int maxage(36000), from(0), nb(0); bool stats(false); if (params.size () >= 1) { haveRegexp = true; regexp = boost::xpressive::sregex::compile (params[0].get_str ()); } if (params.size () >= 2) maxage = params[1].get_int (); if (maxage < 0) throw JSONRPCError (RPC_INVALID_PARAMETER, "'maxage' should be non-negative"); if (params.size () >= 3) from = params[2].get_int (); if (from < 0) throw JSONRPCError (RPC_INVALID_PARAMETER, "'from' should be non-negative"); if (params.size () >= 4) nb = params[3].get_int (); if (nb < 0) throw JSONRPCError (RPC_INVALID_PARAMETER, "'nb' should be non-negative"); if (params.size () >= 5) { if (params[4].get_str () != "stat") throw JSONRPCError (RPC_INVALID_PARAMETER, "fifth argument must be the literal string 'stat'"); stats = true; } /* ******************************************* */ /* Iterate over names to build up the result. */ UniValue names(UniValue::VARR); unsigned count(0); LOCK (cs_main); valtype name; CNameData data; std::unique_ptr<CNameIterator> iter(pcoinsTip->IterateNames ()); while (iter->next (name, data)) { const int age = chainActive.Height () - data.getHeight (); assert (age >= 0); if (maxage != 0 && age >= maxage) continue; if (haveRegexp) { const std::string nameStr = ValtypeToString (name); boost::xpressive::smatch matches; if (!boost::xpressive::regex_search (nameStr, matches, regexp)) continue; } if (from > 0) { --from; continue; } assert (from == 0); if (stats) ++count; else names.push_back (getNameInfo (name, data)); if (nb > 0) { --nb; if (nb == 0) break; } } /* ********************************************************** */ /* Return the correct result (take stats mode into account). */ if (stats) { UniValue res(UniValue::VOBJ); res.push_back (Pair ("blocks", chainActive.Height ())); res.push_back (Pair ("count", static_cast<int> (count))); return res; } return names; }
void ZealDocsetsRegistry::_runQuery(const QString& rawQuery, int queryNum) { if(queryNum != lastQuery) return; // some other queries pending - ignore this one QList<ZealSearchResult> results; ZealSearchQuery query = ZealSearchQuery(rawQuery); QString docsetPrefix = query.getDocsetFilter(); QString preparedQuery = query.getSanitizedQuery(); for(QString name : names()) { if(!docsetPrefix.isEmpty() && !name.toLower().contains(docsetPrefix)) { // Filter out this docset as the names don't match the docset prefix continue; } QString qstr; QSqlQuery q; QList<QList<QVariant> > found; bool withSubStrings = false; while(found.size() < 100) { auto curQuery = preparedQuery; QString notQuery; // don't return the same result twice QString parentQuery; if(withSubStrings) { // if less than 100 found starting with query, search all substrings curQuery = "%"+preparedQuery; // don't return 'starting with' results twice if(types[name] == ZDASH) { notQuery = QString(" and not (ztokenname like '%1%' escape '\\' or ztokenname like '%.%1%' escape '\\') ").arg(preparedQuery); } else { notQuery = QString(" and not t.name like '%1%' escape '\\' ").arg(preparedQuery); if(types[name] == ZEAL) { parentQuery = QString(" or t2.name like '%1%' escape '\\' ").arg(preparedQuery); } } } int cols = 3; if(types[name] == ZEAL) { qstr = QString("select t.name, t2.name, t.path from things t left join things t2 on t2.id=t.parent where " "(t.name like '%1%' escape '\\' %3) %2 order by lower(t.name) asc, t.path asc limit 100").arg(curQuery, notQuery, parentQuery); } else if(types[name] == DASH) { qstr = QString("select t.name, null, t.path from searchIndex t where t.name " "like '%1%' escape '\\' %2 order by lower(t.name) asc, t.path asc limit 100").arg(curQuery, notQuery); } else if(types[name] == ZDASH) { cols = 4; qstr = QString("select ztokenname, null, zpath, zanchor from ztoken " "join ztokenmetainformation on ztoken.zmetainformation = ztokenmetainformation.z_pk " "join zfilepath on ztokenmetainformation.zfile = zfilepath.z_pk where (ztokenname " // %.%1% for long Django docset values like django.utils.http // (Might be not appropriate for other docsets, but I don't have any on hand to test) "like '%1%' escape '\\' or ztokenname like '%.%1%' escape '\\' ) %2 order by lower(ztokenname) asc, zpath asc, " "zanchor asc limit 100").arg(curQuery, notQuery); } q = db(name).exec(qstr); while(q.next()) { QList<QVariant> values; for(int i = 0; i < cols; ++i) { values.append(q.value(i)); } found.append(values); } if(withSubStrings) break; withSubStrings = true; // try again searching for substrings } for(auto &row : found) { QString parentName; if(!row[1].isNull()) { parentName = row[1].toString(); } auto path = row[2].toString(); // FIXME: refactoring to use common code in ZealListModel and ZealDocsetsRegistry if(types[name] == DASH || types[name] == ZDASH) { path = QDir(QDir(QDir("Contents").filePath("Resources")).filePath("Documents")).filePath(path); } if(types[name] == ZDASH) { path += "#" + row[3].toString(); } auto itemName = row[0].toString(); if(itemName.indexOf('.') != -1 && itemName.indexOf('.') != 0 && row[1].isNull()) { auto splitted = itemName.split("."); itemName = splitted.at(splitted.size()-1); parentName = splitted.at(splitted.size()-2); } results.append(ZealSearchResult(itemName, parentName, path, name, preparedQuery)); } } qSort(results); if(queryNum != lastQuery) return; // some other queries pending - ignore this one queryResults = results; emit queryCompleted(); }
/** * \brief find out whether a given name is known */ bool FITSKeywords::known(const std::string& name) { return (names().find(name) != names().end()); }