//--------------------------------------------------------------------------- void WCUpdateComboBox(TComboBox* cmb,TTypeKeyVoc tkey) { cmb->Clear(); MYSQL_RES *result; MYSQL_ROW row; AnsiString myquery; if (tkey==GROUPS) myquery="SELECT title, num FROM "+opts.DBVocTable+" WHERE vkey="+ToStr(keys[tkey])+" AND deleted=0 ORDER BY title"; else myquery="SELECT title, num FROM "+opts.DBVocTable+" WHERE vkey="+ToStr(keys[tkey])+" AND deleted=0 ORDER BY num"; mysql_query(mysql,myquery.c_str()); if (mysql_field_count(mysql)) { result=mysql_store_result(mysql); if (result && mysql_num_rows(result)) { while (row = mysql_fetch_row(result)) { cmb->Items->Add(AnsiString(row[0])); } } mysql_free_result(result); } }
tinyxml2::XMLElement* AudioComponent::VGenerateXml(tinyxml2::XMLDocument* pDoc) { tinyxml2::XMLElement* pBaseElement = pDoc->NewElement(VGetName()); tinyxml2::XMLElement* pSoundNode = pDoc->NewElement("Sound"); tinyxml2::XMLText* pSoundText = pDoc->NewText(m_audioResource.c_str()); pSoundNode->LinkEndChild(pSoundText); pBaseElement->LinkEndChild(pSoundNode); tinyxml2::XMLElement* pLoopingNode = pDoc->NewElement("Looping"); tinyxml2::XMLText* pLoopingText = pDoc->NewText(m_looping ? "1" : "0"); pLoopingNode->LinkEndChild(pLoopingText); pBaseElement->LinkEndChild(pLoopingNode); tinyxml2::XMLElement* pFadeInNode = pDoc->NewElement("FadeIn"); tinyxml2::XMLText* pFadeInText = pDoc->NewText(ToStr(m_fadeInTime).c_str()); pFadeInNode->LinkEndChild(pFadeInText); pBaseElement->LinkEndChild(pFadeInNode); tinyxml2::XMLElement* pVolumeNode = pDoc->NewElement("Volume"); tinyxml2::XMLText* pVolumeText = pDoc->NewText(ToStr(m_volume).c_str()); pVolumeNode->LinkEndChild(pVolumeText); pBaseElement->LinkEndChild(pVolumeNode); return pBaseElement; }
vector<size_t> CbirGVT::FindCache(size_t in, size_t n, bool& hit) { string msg = "FindCache("+ToStr(in)+","+ToStr(n)+") : "; bool debugx = debug>1; if (false && debugx) cout << msg << endl; pair<cache_t::iterator,cache_t::iterator> r = cache.equal_range(in); for (cache_t::iterator i = r.first; i!=r.second; i++) if (i->second.first>=n) { hit = true; vector<size_t> ret; for (size_t j=0; j<n&&j<i->second.second.size(); j++) ret.push_back(i->second.second[j]); if (debugx) cout << msg << "returning " << ret.size() << "/" << i->second.second.size() << " images" << endl; return ret; } hit = false; if (debugx) cout << msg << " not found" << endl; return vector<size_t>(); }
string numstr::ToUnitStr(MPO_UINT64 u) { string result; double d; // if less than 1 k if (u < 1024) { result = ToStr(u) + " B"; } // less than 1 meg else if (u < 1048576) { d = u * 0.0009765625; // same as dividing by 1024 result = ToStr(d, 0, 1, 2) + " KiB"; } // less than 1 gig else if (u < 1073741824) { d = u / (1048576.0); // convert to megs result = ToStr(d, 0, 1, 2) + " MiB"; } // else leave it as gigs, we won't go any higher for now else { d = u / (1073741824.0); // convert to gigs result = ToStr(d, 0, 1, 2) + " GiB"; } return result; }
bool EventManager::RemoveListener(const EventListenerDelegate& eventDelegate, const EventType& type) { CB_LOG("Events", "Attempting to remove delegate listener from event type: " + ToStr(type, 16)); bool success = false; // iterate the map looking this event type auto findIt = m_EventListeners.find(type); if (findIt != m_EventListeners.end()) { // get the list of listeners for this event type EventListenerList& listeners = findIt->second; for (auto it = listeners.begin(); it != listeners.end(); ++it) { // if the delegate listener is found, remove it if (eventDelegate == (*it)) { listeners.erase(it); CB_LOG("Events", "Successfully removed delegate listener from event type: " + ToStr(type, 16)); success = true; // break because there cannot be duplicate delegates for an event type break; } } } return success; }
void CbirGVT::AddCache(size_t in, size_t n, size_t out) { string msg = "AddCache("+ToStr(in)+","+ToStr(n)+","+ToStr(out)+") : "; bool debugx = debug>1; if (false && debugx) cout << msg << endl; pair<cache_t::iterator,cache_t::iterator> r = cache.equal_range(in); for (cache_t::iterator i = r.first; i!=r.second; i++) if (i->second.first==n) { i->second.second.push_back(out); if (debugx) cout << msg << " added in old " << i->second.second.size() << "/" << i->second.first << endl; return; } vector<size_t> v; v.push_back(out); cache.insert(make_pair(in, make_pair(n, v))); if (debugx) cout << msg << "added new entry, total " << cache.size() << endl; }
TiXmlElement* Vec2::GernerateXML( void ) const { TiXmlElement* pRetNode = ENG_NEW TiXmlElement( "Vector2" ); pRetNode->SetAttribute( "x", ToStr( x ).c_str() ); pRetNode->SetAttribute( "y", ToStr( y ).c_str() ); return pRetNode; }
void SphereRenderComponent::CreateInheritedXmlElements(TiXmlElement* pBaseElement) { TiXmlElement* pMesh = CB_NEW TiXmlElement("Sphere"); pMesh->SetAttribute("radius", ToStr(m_Radius).c_str()); pMesh->SetAttribute("segments", ToStr(m_Segments).c_str()); pBaseElement->LinkEndChild(pMesh); }
void StatsView::Refresh(){ Glib::ustring cur; cur = "Red Bases: "; cur += ToStr(ps->red_bases); rbl.set_label(cur); cur = "Blue Bases: "; cur += ToStr(ps->blue_bases); bbl.set_label(cur); }
TiXmlElement* Color::GenerateXML( void ) { TiXmlElement* pRetNode = ENG_NEW TiXmlElement( "Color" ); pRetNode->SetAttribute( "r", ToStr( m_Component.r ).c_str() ); pRetNode->SetAttribute( "g", ToStr( m_Component.g ).c_str() ); pRetNode->SetAttribute( "b", ToStr( m_Component.b ).c_str() ); pRetNode->SetAttribute( "a", ToStr( m_Component.a ).c_str() ); return pRetNode; }
WCHAR* ChmDoc::GetProperty(DocumentProperty prop) { AutoFreeW result; if (DocumentProperty::Title == prop && title) result.Set(ToStr(title)); else if (DocumentProperty::CreatorApp == prop && creator) result.Set(ToStr(creator)); // TODO: shouldn't it be up to the front-end to normalize whitespace? if (result) { // TODO: original code called str::RemoveChars(result, "\n\r\t") str::NormalizeWS(result); } return result.StealData(); }
std::string Variant::ToString() const { switch (Type()) { case Types::Bool: return Bool() ? "true" : "false"; case Types::Int: return ToStr(Int()); case Types::Float: return ToStr(Float()); } return ""; }
uint32_t JoinFlowHandler::WriteKeyNickSession(NE::Model::Capabilities& capabilities, Address32 address32, WHartUniqueID uniqueID, Address32 parentAddress32, const NE::Model::SecurityKey& networkKey, const NE::Model::SecurityKey& key) { C963_WriteSession_Req writeSessionLocal; { // write the session locally writeSessionLocal.m_ulPeerNonceCounterValue = 0; writeSessionLocal.m_unPeerNickname = (address32 & 0xFFFF); memcpy(writeSessionLocal.m_aPeerUniqueID, uniqueID.bytes, 5); //TODO check if it is ok memcpy(writeSessionLocal.m_aKeyValue, key.value, key.LENGTH); writeSessionLocal.m_eSessionType = WHartSessionKey::sessionKeyed; writeSessionLocal.m_ucReserved = 0; memset(writeSessionLocal.m_tExecutionTime, 0, 5); } C2009_NM_WriteUniqueIdNickname_Req localAddressNick; { localAddressNick.nickname = (uint16_t) address32 & 0xFFFF; localAddressNick.uniqueId = uniqueID; localAddressNick.isTR = device.isBackbone; } WHartCommand arrayLocal[] = { { CMDID_C963_WriteSession, 0, &writeSessionLocal }, { CMDID_C2009_NM_WriteUniqueIdNickname, 0, &localAddressNick } }; WHartCommandList listReqLocal = { sizeof(arrayLocal) / sizeof(arrayLocal[0]), arrayLocal }; //COULD trigger TransmitConfirm if there is a package in the stack for the peer address. TransmitRequest(NetworkManager_Nickname(), listReqLocal, WHartSessionKey::joinKeyed); try { keyNickSessionOperations.reset(new NE::Model::Operations::EngineOperations()); commonData.networkEngine.initJoinDevice(*keyNickSessionOperations, capabilities, address32, uniqueID, parentAddress32, networkKey, key); std::ostringstream stream; stream << "Write session " << ToStr(address32) << ", parent=" << ToStr(parentAddress32); keyNickSessionOperations->reasonOfOperations = stream.str(); SMState::SMStateLog::logOperations(keyNickSessionOperations->reasonOfOperations, *keyNickSessionOperations); SendOperations(keyNickSessionOperations, keyNickSessionHandle, true); } catch (std::exception& ex) { LOG_ERROR("Error:" << ex.what()); } return keyNickSessionHandle; }
int DmetEngine::parseArgv( const char * const * const argv, int start ){ vector<string> argvStrings; for (const char* const * arg=argv;*arg!=NULL;arg++) { argvStrings.push_back(*arg); } int argc = argvStrings.size(); // Parse DmetEngine Options int argvPos = Options::parseArgv(argv, start); vector<string> celFiles; for(vector<const char *>::size_type i = 0; i < getArgCount(); i++) celFiles.push_back(getArg(i)); setOpt("cels",celFiles); // Allow user to override APS defaults if(argc > argvPos) { ProbesetSummarizeEngine pse; int newArgvPos = pse.parseArgv(argv, argvPos+1); Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for ProbesetSummarizeEngine!"); m_ArgvPosAPS = argvPos + 1; argvPos = newArgvPos; } else { m_ArgvPosAPS = -1; } // Allow user to override CN defaults if(argc > argvPos) { DmetCopyNumberEngine cde; int newArgvPos = cde.parseArgv(argv,argvPos+1); Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for DmetCopyNumberEngine!"); m_ArgvPosCN = argvPos + 1; argvPos = newArgvPos; } else { m_ArgvPosCN = -1; } // Allow user to override APG defaults if(argc > argvPos) { ProbesetGenotypeEngine pge; int newArgvPos = pge.parseArgv(argv,argvPos+1); Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for ProbesetGenotypeEngine!"); m_ArgvPosAPG = argvPos + 1; argvPos = newArgvPos; } else { m_ArgvPosAPG = -1; } m_argv = argv; return argvPos; }
// checks to see if the special lsrowimage.dat file exists in the experiment directory. If it does, // this image is used to generate custom channel correction coefficients. If not, the method silently // returns (and subsequent analysis uses the default correction). void ImageTransformer::CalibrateChannelXTCorrection ( const char *exp_dir,const char *filename, bool wait_for_prerun ) { // only allow this to be done once if ( custom_correction_data != NULL ) return; // LSRowImageProcessor can generate a correction for the 314, but application of the correction is much more // difficult than for 316/318, and the expected benefit is not as high, so for now...we're skipping the 314 if ( ( ChipIdDecoder::GetGlobalChipId() != ChipId316 ) && ( ChipIdDecoder::GetGlobalChipId() != ChipId318 ) && ( ChipIdDecoder::GetGlobalChipId() != ChipId316v2 ) ) return; int len = strlen ( exp_dir ) +strlen ( filename ) + 2; char full_fname[len]; sprintf ( full_fname,"%s/%s",exp_dir,filename ); if ( wait_for_prerun ) { std::string preRun = exp_dir; preRun = preRun + "/prerun_0000.dat"; std::string acq0 = exp_dir; acq0 = acq0 + "/acq_0000.dat"; uint32_t waitTime = RETRY_INTERVAL; int32_t timeOut = TOTAL_TIMEOUT; //--- Wait up to 3600 seconds for a file to be available bool okToProceed = false; while ( timeOut > 0 ) { //--- do our checkpoint files exist? if ( isFile ( preRun.c_str() ) || isFile ( acq0.c_str() ) ) { okToProceed = true; break; } fprintf ( stdout, "Waiting to load crosstalk params in %s\n", full_fname ); sleep ( waitTime ); timeOut -= waitTime; } if ( !okToProceed ) { ION_ABORT ( "Couldn't find gateway files for: " + ToStr ( full_fname ) ); } // We got the files we expected so if the xtalk file isn't there then warn. if ( !isFile ( full_fname ) ) { ION_WARN ( "Didn't find xtalk file: " + ToStr ( full_fname ) ); } } LSRowImageProcessor lsrowproc; custom_correction_data = lsrowproc.GenerateCorrection ( full_fname ); if ( custom_correction_data != NULL ) selected_chip_xt_vectors = custom_correction_data->GetCorrectionDescriptor(); }
/** * Go thru GC contrast values and find the mean and stdev * go thru AT contrast values and count how many are within 2stdev of GC mean * calculate the fraction of non-overlap * @param ATcontrast Values * @param GCcontrast Values * @param GCstats vector to fill in with stats */ double MultiChannelNonOverlapCelListener::calcNonOverlap(const std::vector<double> &ATcontrastValues, const std::vector<double> &GCcontrastValues, CumulativeStats<double> &GCstats) { for(int gcIx = 0; gcIx < GCcontrastValues.size(); gcIx++) { float intensity = GCcontrastValues[gcIx]; GCstats.addData(intensity); } float gc_mean = GCstats.getMean(); float gc_stdev = GCstats.getStdev(); float gcthreshold = gc_mean + 2*gc_stdev; int inGC = 0; for (int atIx = 0; atIx< ATcontrastValues.size(); atIx++){ if (ATcontrastValues[atIx] < gcthreshold){ inGC++; } } double result = (double) inGC / int(ATcontrastValues.size()); Verbose::out(4, "in GC fraction is " + ToStr(result)); result = 1.0-result; return result; }
// Search an entry IPTABLES_ENTRY *SearchIpTables(IPTABLES_STATE *s, char *chain, IP *src_ip, IP *dest_ip, UINT mark) { char ip_str1[64]; char ip_str2[64]; char mark_str1[64]; char mark_str2[64]; UINT i; if (s == NULL || chain == NULL || src_ip == NULL || dest_ip == NULL || mark == 0) { return NULL; } IPToStr(ip_str1, sizeof(ip_str1), src_ip); IPToStr(ip_str2, sizeof(ip_str2), dest_ip); ToStr(mark_str1, mark); Format(mark_str2, sizeof(mark_str2), "%x", mark); for (i = 0;i < LIST_NUM(s->EntryList);i++) { IPTABLES_ENTRY *e = LIST_DATA(s->EntryList, i); if (StrCmpi(e->Chain, chain) == 0) { if (InStr(e->ConditionAndArgs, ip_str1) && InStr(e->ConditionAndArgs, ip_str2) && (InStr(e->ConditionAndArgs, mark_str1) || InStr(e->ConditionAndArgs, mark_str2))) { return e; } } } return NULL; }
bool Print(string & mode , int count_inst , int ret_inst, string Inst , bool & be) { string tmp=""; char input[100];input[0]=0; strcpy(input,mode.c_str()); if (mode == "m") { cout << "\tLast microinstruction : "<< Inst <<"\n"; Disp.AllRegisterValues(RG, PC, SP, AC, OP); SelectOperations(mode,be); } else if (ret_inst == 0 && mode == "i") { cout << "Last Instruction : " << Mem.Memory[PageID][count_inst]<<"\n"; Disp.AllRegisterValues(RG, PC, SP, AC, OP); SelectOperations(mode,be); } else if (be == true && breaks.find(count_inst)!=breaks.end()) { breaks.erase(count_inst); cout << "Break-point at address : "<< toHexS(ToStr(count_inst))<<"\n"; SelectOperations(mode,be); } return true; }
Str Join(It beg, It end, StrC &del) { VStr tmp; for (It it = beg; it != end; ++it) { tmp.push_back(ToStr(*it, 7)); } return Join(tmp, del); }
vector<string> ExtractArgs(const vector<string> &all_args, int args_count) { AssertMsg(all_args.size() >= args_count, string("Expected at least ") + ToStr(args_count) + " args, instead had " + ToStr(all_args.size())); vector<string> args(args_count); args.assign(all_args.begin() + (all_args.size() - args_count), all_args.end()); return args; }
Str Join(double* str, int len) { VStr tmp; for (int i = 0; i < len; i++) { tmp.push_back(ToStr(str[i])); } return Join(tmp, " "); }
//--------------------------------------------------------------------------- int __fastcall TFormInsertVoc::GetCountRecForKey(AnsiString vkey) { int resCount=0; MYSQL_RES *result; MYSQL_ROW row; AnsiString myquery="SELECT MAX(num) FROM "+TabVocName+" WHERE vkey="+ToStr(vkey)+" AND deleted=0"; mysql_query(mysql,myquery.c_str()); Memo1->Lines->Add(mysql_error(mysql)); if (mysql_field_count(mysql)) { Memo1->Lines->Add(mysql_error(mysql)); result=mysql_store_result(mysql); Memo1->Lines->Add(mysql_error(mysql)); if (result && mysql_num_rows(result)) { Memo1->Lines->Add(mysql_error(mysql)); row = mysql_fetch_row(result); if (row[0]) resCount=AnsiString(row[0]).ToInt(); else resCount=0; Memo1->Lines->Add(mysql_error(mysql)); } mysql_free_result(result); Memo1->Lines->Add(mysql_error(mysql)); } return resCount; }
//--------------------------------------------------------------------------- bool __fastcall TFormInsertVoc::IsExistsTitleForKey(AnsiString vkey,AnsiString title) { bool status=false; MYSQL_RES *result; MYSQL_ROW row; AnsiString myquery="SELECT title FROM "+TabVocName+" WHERE vkey="+ToStr(vkey)+" AND title="+ToStr(title)+" AND deleted=0"; mysql_query(mysql,myquery.c_str()); Memo1->Lines->Add(mysql_error(mysql)); if (mysql_field_count(mysql)) { Memo1->Lines->Add(mysql_error(mysql)); result=mysql_store_result(mysql); Memo1->Lines->Add(mysql_error(mysql)); if (result && mysql_num_rows(result)) { Memo1->Lines->Add(mysql_error(mysql)); status=true; } mysql_free_result(result); Memo1->Lines->Add(mysql_error(mysql)); } return status; }
//--------------------------------------------------------------------------- AnsiString WCGetTitleForKeyNum(TTypeKeyVoc tkey,int num, AnsiString* tag) { MYSQL_RES *result; MYSQL_ROW row; AnsiString resStr=""; AnsiString myquery; myquery="SELECT title, tag FROM "+opts.DBVocTable+" WHERE deleted=0 AND vkey="+ToStr(keys[tkey])+" AND num="+ToStr(AnsiString(num)); mysql_query(mysql,myquery.c_str()); if (mysql_field_count(mysql)) { result=mysql_store_result(mysql); if (result && mysql_num_rows(result)) { row = mysql_fetch_row(result); resStr=AnsiString(row[0]); if (tag) *tag = AnsiString(row[1]); } mysql_free_result(result); } return resStr; }
void USwFMOD::DumpDrivers() { guard(USwFMOD::DumpDrivers); FMOD_RESULT result; if( !System ) return; // Enumerate drivers INT numdrivers; SWF_FMOD_CALL( System->getNumDrivers(&numdrivers) ); // Print drivers for( INT i=0; i<numdrivers; ++i ) { // Name char drivername[1024]; SWF_FMOD_CALL( System->getDriverName(i, drivername, 1024) ); SWF_LOG( SWF_NAME, TEXT("Driver[%d] %s"), i, *ToStr(appFromAnsi(drivername)) ); // Caps FMOD_CAPS caps; INT minfreq, maxfreq; FMOD_SPEAKERMODE smode; SWF_FMOD_CALL( System->getDriverCaps( i, &caps, &minfreq, &maxfreq, &smode ) ); SWF_LOG( SWF_NAME, TEXT("Driver[%d] Frequency: %d - %d"), i, minfreq, maxfreq ); SWF_LOG( SWF_NAME, TEXT("Driver[%d] Caps: %s"), i, *FMOD_CAPSToStr(caps) ); SWF_LOG( SWF_NAME, TEXT("Driver[%d] Speaker Mode: %s"), i, *FMOD_SPEAKERMODEToStr(smode) ); } unguard; }
// Convert an integer list to a string void IntListToStr(char *str, UINT str_size, LIST *o, char *separate_str) { UINT i; ClearStr(str, str_size); // Validate arguments if (o == NULL) { return; } if (IsEmptyStr(separate_str)) { separate_str = ", "; } for (i = 0;i < LIST_NUM(o);i++) { char tmp[MAX_SIZE]; UINT *v = LIST_DATA(o, i); ToStr(tmp, *v); StrCat(str, str_size, tmp); if (i != (LIST_NUM(o) - 1)) { StrCat(str, str_size, separate_str); } } }
IDeckLinkDisplayMode *Player::GetDisplayModeByIndex(int selectedIndex) { // Populate the display mode combo with a list of display modes supported by the installed DeckLink card IDeckLinkDisplayModeIterator *displayModeIterator; IDeckLinkDisplayMode *deckLinkDisplayMode; IDeckLinkDisplayMode *selectedMode = NULL; int index = 0; if (m_deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) != S_OK) goto bail; while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK) { BMDProbeString str; if (deckLinkDisplayMode->GetName(&str) == S_OK) { if (index == selectedIndex) { printf("Selected mode: %s\n\n\n", ToStr(str)); selectedMode = deckLinkDisplayMode; FreeStr(str); goto bail; } } index++; } bail: displayModeIterator->Release(); return selectedMode; }
bool Actor::Init(TiXmlElement* pData) { GCC_LOG("Actor", std::string("Initializing Actor ") + ToStr(m_id)); m_type = pData->Attribute("type"); m_resource = pData->Attribute("resource"); return true; }
void Ipc() { int t=SignedValue(counter); t++; string res = ToStr(t); strncpy(counter,res.c_str(),WIDTH); return ; }
TiXmlElement* BaseRenderComponent::GenerateXml() { TiXmlElement* pBaseElement = CreateBaseElement(); // generate color TiXmlElement* pColor = CB_NEW TiXmlElement("Color"); pColor->SetAttribute("r", ToStr(m_Color.r).c_str()); pColor->SetAttribute("g", ToStr(m_Color.g).c_str()); pColor->SetAttribute("b", ToStr(m_Color.b).c_str()); pColor->SetAttribute("a", ToStr(m_Color.a).c_str()); pBaseElement->LinkEndChild(pColor); // create XML for inherited classes CreateInheritedXmlElements(pBaseElement); return pBaseElement; }