JNIEXPORT void JNICALL NAME(nativeSetDataSource)(JNIEnv *env, jobject thiz, jstring path) { libvlc_instance_t *instance = (libvlc_instance_t *) getIntValue(env, thiz, "mLibVlcInstance"); libvlc_media_player_t *mp = (libvlc_media_player_t *) getIntValue(env, thiz, "mLibVlcMediaPlayer"); const char *str = (*env)->GetStringUTFChars(env, path, 0); if (!str) { /* XXX: throw */ return; } libvlc_media_t *media = (*str == '/') ? libvlc_media_new_path(instance, str) : libvlc_media_new_location(instance, str); if (media) { libvlc_event_manager_t *em = libvlc_media_event_manager(media); for (int i = 0; i < sizeof(md_listening) / sizeof(*md_listening); i++) { libvlc_event_attach(em, md_listening[i], vlc_event_callback, thiz); } /* this will cancel current input and start a new one */ libvlc_media_player_set_media(mp, media); setIntValue(env, thiz, "mNativeMediaBufferingCount", 0); } (*env)->ReleaseStringUTFChars(env, path, str); setIntValue(env, thiz, "mLibVlcMedia", (jint) media); }
void CStateDB::restoreCollection(CSession * const session) { if(m_db == 0) throw(CApiMisuseException("Calling restoreCollection(), but DB not opened.")); bool found; int minRev = getIntValue("CollectionRevMin", found); assert(found); int maxRev = getIntValue("CollectionRevMax", found); assert(found); session->setMinCollectionRevision( minRev ); for(int rev = minRev; rev <= maxRev; rev++) { CCollection<CCollectionItem>* collection = new CCollection<CCollectionItem>(rev); CCollectionItem* item; int pos = 0; do { item = getCollectionItemByPos(pos, rev); pos++; if(item) { collection->insert(item); } } while(item != 0); session->addCollectionRev(collection); } }
static QVariant fcnSubstr( const QVariantList& values, QgsFeature* , QgsExpression* parent ) { QString str = getStringValue( values.at( 0 ), parent ); int from = getIntValue( values.at( 1 ), parent ); int len = getIntValue( values.at( 2 ), parent ); return QVariant( str.mid( from -1, len ) ); }
void CStateDB::restoreNextlists(CSession * const session) { if(m_db == 0) throw(CApiMisuseException("Calling restoreNextlists(), but DB not opened.")); bool found; int minRev = getIntValue("NextlistRevMin", found); assert(found); int maxRev = getIntValue("NextlistRevMax", found); assert(found); session->setMinNextlistRevision( minRev ); for(int rev = minRev; rev < maxRev; rev++) { CCollection<CPlaylistItem>* nextlist = new CCollection<CPlaylistItem>(rev); CPlaylistItem* item; int pos = 0; do { item = getNextlistItemByPos(pos, rev); pos++; if(item) { nextlist->insert(item); } } while(item != 0); session->addNextlistRev(nextlist); } }
bool ECLlocation::extractLocationAttr(const IHqlExpression * location) { if (!location) { clear(); return false; } if (location->isAttribute()) { if (location->queryName() != _location_Atom) return false; IHqlExpression * sourceExpr = location->queryChild(3); if (sourceExpr) sourcePath = static_cast<ISourcePath *>(sourceExpr->queryUnknownExtra()); else sourcePath = NULL; lineno = (int)getIntValue(location->queryChild(0)); column = (int)getIntValue(location->queryChild(1)); position = (int)getIntValue(location->queryChild(2)); return true; } IHqlExpression * annotation = queryLocation(const_cast<IHqlExpression *>(location)); if (annotation) { sourcePath = annotation->querySourcePath(); lineno = annotation->getStartLine(); column = annotation->getStartColumn(); position = 0; return true; } return false; }
IHqlExpression * CMemberInfo::addDatasetLimits(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * _value) { LinkedHqlExpr value = _value; IHqlExpression * choosen = column->queryAttribute(choosenAtom); if (choosen) { LinkedHqlExpr choosenValue = choosen->queryChild(0); if (!choosenValue->queryValue()) { OwnedHqlExpr self = container->getRelativeSelf(); OwnedHqlExpr absoluteExpr = replaceSelector(choosenValue, querySelfReference(), self); choosenValue.setown(selector->queryRootRow()->bindToRow(absoluteExpr, querySelfReference())); } else { if (hasNoMoreRowsThan(value, getIntValue(choosenValue))) choosenValue.clear(); } if (choosenValue) value.setown(createDataset(no_choosen, LINK(value), LINK(choosenValue))); } IHqlExpression * maxCount = queryAttributeChild(column, maxCountAtom, 0); if (maxCount && !hasNoMoreRowsThan(value, getIntValue(maxCount))) { //Generate a limit test if there isn't a limit that ensures it is small enough StringBuffer failText, columnText; expandSelectPathText(columnText, true).toLowerCase(); failText.appendf("Too many rows assigned to field %s", columnText.str()); OwnedHqlExpr fail = translator.createFailAction(failText.str(), maxCount, NULL, translator.queryCurrentActivityId(ctx)); value.setown(createDataset(no_limit, LINK(value), createComma(LINK(maxCount), LINK(fail)))); } return value.getClear(); }
bool EnabledModuleList::doesModuleHaveHigherCppStandardThanProject (const String& moduleID) { auto projectCppStandard = project.getCppStandardValue().toString(); if (projectCppStandard == "latest") return false; auto moduleCppStandard = getModuleInfo (moduleID).getMinimumCppStandard(); return (moduleCppStandard.getIntValue() > projectCppStandard.getIntValue()); }
JNIEXPORT void JNICALL NAME(nativePrepareAsync)(JNIEnv *env, jobject thiz) { libvlc_media_t *media = (libvlc_media_t *) getIntValue(env, thiz, "mLibVlcMedia"); char *mrl = libvlc_media_get_mrl(media); if (strncmp(mrl, "file://", 7) == 0) libvlc_media_parse_async(media); else { libvlc_media_player_t *mp = (libvlc_media_player_t *) getIntValue(env, thiz, "mLibVlcMediaPlayer"); libvlc_media_player_play(mp); } free(mrl); }
bool CBigStashPaser::parseGoldAndPageSize( CBigStash& ar_oBigStash ) { if( m_nIndex >= m_nDataLength ) { return false; } BYTE* lo_pByteData = &m_pBigStashDatas[m_nIndex]; int lo_nNextPageIndex = findNextPageHeader(); if( lo_nNextPageIndex < 0 ) { return false; } int lo_nDataLength = lo_nNextPageIndex - m_nIndex; unsigned int lo_nGold = 0; unsigned int lo_nPageSize = 0; switch( lo_nDataLength ) { case 4: lo_nPageSize = getIntValue( m_pBigStashDatas, m_nDataLength, m_nIndex ); break; case 8: lo_nGold = getIntValue( m_pBigStashDatas, m_nDataLength, m_nIndex ); lo_nPageSize = getIntValue( m_pBigStashDatas, m_nDataLength, m_nIndex+4 ); break; default: return false; } if( lo_nPageSize <= 0 ) { return false; } ar_oBigStash.Gold(lo_nGold); ar_oBigStash.PageSize(lo_nPageSize); m_nIndex = lo_nNextPageIndex; return true; }
void ofXml::deserialize(ofAbstractParameter & parameter){ if(!parameter.isSerializable()) return; string name = parameter.getEscapedName(); if(parameter.type()==typeid(ofParameterGroup).name()){ ofParameterGroup & group = static_cast<ofParameterGroup&>(parameter); if(setTo(name)){ for(int i=0;i<group.size();i++){ deserialize(group.get(i)); } setToParent(); } }else{ if(exists(name)){ if(parameter.type()==typeid(ofParameter<int>).name()){ parameter.cast<int>() = getIntValue(name); }else if(parameter.type()==typeid(ofParameter<float>).name()){ parameter.cast<float>() = getFloatValue(name); }else if(parameter.type()==typeid(ofParameter<bool>).name()){ parameter.cast<bool>() = getBoolValue(name); }else if(parameter.type()==typeid(ofParameter<int64_t>).name()){ parameter.cast<int64_t>() = getInt64Value(name); }else if(parameter.type()==typeid(ofParameter<string>).name()){ parameter.cast<string>() = getValue(name); }else{ parameter.fromString(getValue(name)); } } } }
void binary_operation(VarType type, R (*binaryFunction)(T const &, T const &)) { auto left = popVariable(); auto right = popVariable(); T leftValue, rightValue; if (type == VT_DOUBLE) { leftValue = left.getDoubleValue(); rightValue = right.getDoubleValue(); } else { leftValue = left.getIntValue(); rightValue = right.getIntValue(); } pushVariable(binaryFunction(leftValue, rightValue)); }
// ---------------------------------------------------------------------------- // LPCSTR ChannelControllerField::getLabel() { CString name; CString addresses; CString range; // Figure out which channel text to show for ( Fixture *pf : m_venue->resolveActorFixtures( &m_actor ) ) { if ( pf->getNumChannels() > m_channel ) { Channel* ch = pf->getChannel(m_channel); if ( name.GetLength() == 0 ) name = ch->getName(); if ( addresses.GetLength() > 0 ) addresses += ","; addresses.AppendFormat( "%u", pf->getChannelAddress(m_channel) ); ChannelValueRange* rangep = ch->getRange( getIntValue() ); if ( rangep && range.Find( rangep->getName() ) == - 1 ) { if ( range.GetLength() > 0 ) range += ","; range += rangep->getName(); } } } if ( range.GetLength() > 0 ) range = " \"" + range + "\" "; m_label.Format( "%d: %s (@%s)%s", m_channel+1, (LPCTSTR)name, (LPCTSTR)addresses, (LPCTSTR)range ); return m_label; }
string Object::getValue() { if (isArray == 1) { getMapValue(); } if (value=="") return ""; if (type=="bool") { return to_string(getBoolValue()); } else if (type=="int") { return to_string(getIntValue()); } else if (type=="double") { std::ostringstream os; os << getDoubleValue(); return os.str(); } return getStringValue(); }
string Options::getValueString(OptionId id) { Value value = getValue(id); switch (id) { case OptionId::HINTS: case OptionId::ASCII: case OptionId::FULLSCREEN: case OptionId::AUTOSAVE: case OptionId::WASD_SCROLLING: case OptionId::SOUND: case OptionId::MUSIC: return getOnOff(value); case OptionId::KEEP_SAVEFILES: case OptionId::SHOW_MAP: case OptionId::FAST_IMMIGRATION: case OptionId::STARTING_RESOURCE: case OptionId::ONLINE: case OptionId::ZOOM_UI: case OptionId::START_WITH_NIGHT: return getYesNo(value); case OptionId::ADVENTURER_NAME: case OptionId::KEEPER_SEED: case OptionId::KEEPER_NAME: { string val = boost::get<string>(value); if (val.empty()) return defaultStrings[id]; else return val; } case OptionId::FULLSCREEN_RESOLUTION: return choices[id][boost::get<int>(value)]; case OptionId::MAIN_VILLAINS: case OptionId::LESSER_VILLAINS: case OptionId::RETIRED_VILLAINS: case OptionId::INFLUENCE_SIZE: case OptionId::ALLIES: return toString(getIntValue(id)); } }
std::string MROMInstaller::checkVersion() const { int min_ver = getIntValue("min_mrom_ver", -1); if(min_ver == -1) return std::string(); char cmd[256]; sprintf(cmd, "rm /tmp/ver; sh -c \"%s/multirom -v > /tmp/ver\"", MultiROM::getPath().c_str()); system(cmd); FILE *f = fopen("/tmp/ver", "r"); if(!f) return "Failed to check MultiROM version!"; fgets(cmd, sizeof(cmd), f); fclose(f); int ver = atoi(cmd); if(ver < min_ver) { sprintf(cmd, "Required ver: %d, curr ver: %d", min_ver, ver); return std::string(cmd); } return std::string(); }
int getFebNumProcess(char* pname, xmlDoc* doc) { int val; int idpm; int idp; char str1[256]; char str2[256]; char action[256]; xmlXPathObjectPtr result; xmlNodePtr node; char tmp[256]; val = -1; idpm = -1; idp = -1; getStringFromEpicsName(pname,str1,1); getStringFromEpicsName(pname,str2,2); if(strcmp(str1,"daq")==0 && strcmp(str2,"dpm")==0) { idpm = getIntFromEpicsName(pname,3); idp = getIntFromEpicsName(pname,4); getStringFromEpicsName(pname,action,5); if(DEBUG>2) printf("[ getFebNumProcess ] : get %s from dpm xml\n", action); if(strcmp(action,"febnum_sub")==0) { sprintf(tmp,"/system/status/DataDpm/RceCore/DataPath[@index=\"%d\"]/FebNum",idp); } else if( strcmp(action,"hybnum_sub")==0) { sprintf(tmp,"/system/status/DataDpm/RceCore/DataPath[@index=\"%d\"]/HybridNum",idp); } else { strcpy(tmp,""); } if(strcmp(tmp,"")!=0) { if(DEBUG>2) printf("[ getFebNumProcess ] : xpath \"%s\"\n",tmp); result = getnodeset(doc, (xmlChar*) tmp); if(result!=NULL) { if(DEBUG>2) printf("[ getFebNumProcess ] : got %d nodes\n", result->nodesetval->nodeNr); if(result->nodesetval->nodeNr==1) { node = result->nodesetval->nodeTab[0]; if(node!=NULL) { val = getIntValue(doc, node); if(DEBUG>0) printf("[ getFebNumProcess ]: got val %d.\n",val); } else { printf("[ getFebNumProcess ] : [ WARNING ] no FebNum nodes found\n"); } } else { printf("[ getFebNumProcess ] : [ WARNING ] %d FebNum nodes found, should be exactly 1\n", result->nodesetval->nodeNr); } } else { printf("[ getFebNumProcess ] : [ WARNING ] no results found\n"); } } else { printf("[ getFebNumProcess ] : [ WARNING ] wrong action (%s) \n",action); } } else { printf("[ getFebNumProcess ]: [ ERROR ]: wrong record name? \"%s\"!\n",pname); } return val; }
JNIEXPORT void JNICALL NAME(nativeRelease)(JNIEnv *env, jobject thiz) { vlc_mutex_t *parse_lock = (vlc_mutex_t *) getIntValue(env, thiz, "mNativeMediaParseLock"); vlc_cond_t *parse_cond = (vlc_cond_t *) getIntValue(env, thiz, "mNativeMediaParseCond"); /* wake up threads that waiting on prepare */ vlc_mutex_lock(parse_lock); setIntValue(env, thiz, "mNativeMediaParsed", 4); vlc_cond_broadcast(parse_cond); vlc_mutex_unlock(parse_lock); jint mLibVlcMediaPlayer = getIntValue(env, thiz, "mLibVlcMediaPlayer"); if (mLibVlcMediaPlayer != 0) { libvlc_event_manager_t *em; libvlc_media_player_t *mp = (libvlc_media_player_t*) mLibVlcMediaPlayer; libvlc_media_t *md = libvlc_media_player_get_media(mp); if (md) { em = libvlc_media_event_manager(md); for (int i = 0; i < sizeof(md_listening) / sizeof(*md_listening); i++) { libvlc_event_detach(em, md_listening[i], vlc_event_callback, thiz); } } em = libvlc_media_player_event_manager(mp); for (int i = 0; i < sizeof(mp_listening) / sizeof(*mp_listening); i++) { libvlc_event_detach(em, mp_listening[i], vlc_event_callback, thiz); } libvlc_media_player_stop(mp); libvlc_media_player_release(mp); setIntValue(env, thiz, "mLibVlcMediaPlayer", 0); } jint mLibVlcInstance = getIntValue(env, thiz, "mLibVlcInstance"); if (mLibVlcInstance != 0) { libvlc_instance_t *instance = (libvlc_instance_t*) mLibVlcInstance; libvlc_release(instance); setIntValue(env, thiz, "mLibVlcInstance", 0); } setIntValue(env, thiz, "mNativeMediaBufferingCount", 0); vlc_mutex_destroy(parse_lock); free(parse_lock); setIntValue(env, thiz, "mNativeMediaParseLock", 0); vlc_cond_destroy(parse_cond); free(parse_cond); setIntValue(env, thiz, "mNativeMediaParseCond", 0); freeClasses(env, thiz); }
// ---------------------------------------------------------------------------- // bool ChannelControllerField::setValue( LPCSTR value ) { if ( !IntegerField::setValue( value ) ) return false; setFixtureValues( (BYTE)getIntValue() ); return true; }
//! //! Change function for the MaxRecords parameter. //! void TextDelimiterSourceNode::maxRecordsChanged () { int maxRecords = getIntValue("MaxRecords"); if (!m_dtxt) return; m_dtxt->SetMaxRecords(maxRecords); updateTable(); }
JNIEXPORT void JNICALL NAME(nativePrepare)(JNIEnv *env, jobject thiz) { libvlc_media_t *media = (libvlc_media_t *) getIntValue(env, thiz, "mLibVlcMedia"); char *mrl = libvlc_media_get_mrl(media); if (strncmp(mrl, "file://", 7) == 0) libvlc_media_parse(media); else { vlc_mutex_t *parse_lock = (vlc_mutex_t *) getIntValue(env, thiz, "mNativeMediaParseLock"); vlc_cond_t *parse_cond = (vlc_cond_t *) getIntValue(env, thiz, "mNativeMediaParseCond"); libvlc_media_player_t *mp = (libvlc_media_player_t *) getIntValue(env, thiz, "mLibVlcMediaPlayer"); libvlc_media_player_play(mp); vlc_mutex_lock(parse_lock); while (!getIntValue(env, thiz, "mNativeMediaParsed")) vlc_cond_wait(parse_cond, parse_lock); vlc_mutex_unlock(parse_lock); } free(mrl); }
PCRetCode ReaderRecvBody(PacketConnection* pPacketConnection, AMUInt8* pHead, AMUInt8** ppBodyBuffer, AMInt32* pBodyLength) { AMInt32 length = 0; #ifdef AMOS_DEBUG AMPrintf("noble:ReaderRecvBody <<<<.\n"); #endif *pBodyLength = getIntValue(pHead, 12); if(*pBodyLength <0 /*|| *pBodyLength > PC_MAX_PROTOCOL_LEN */) { #ifdef AMOS_DEBUG AMPrintf("noble:reader: bodyLength exceed limited(0~20000) = %d\n", *pBodyLength); #endif //send a body exceed exception to up-layer. ReaderExceedExceptionHandler(pPacketConnection->pProtocolEngine, *pBodyLength); return eContinue; } // 分配Body空间并填充 *ppBodyBuffer = (AMUInt8*)AMMalloc(*pBodyLength); if(*ppBodyBuffer == NULL) { #ifdef AMOS_DEBUG AMPrintf("noble:malloc pBodyBuffer error = %d.\n", *pBodyLength); AMAssert(0); #endif return eJumpWhile; } memset(*ppBodyBuffer, 0, *pBodyLength); length = PCContextGetInstance()->recv( pPacketConnection->pProtocolEngine->pPCCore->socketFd, *ppBodyBuffer, *pBodyLength); if( length != *pBodyLength) { #ifdef AMOS_DEBUG AMPrintf("noble:recv = %d != bodyLength = %d\n", length, *pBodyLength); #endif //first free memory AMFree(*ppBodyBuffer); *ppBodyBuffer = NULL; //send exception to up. if(ReaderRecvExceptionHandler(pPacketConnection,*pBodyLength,length) == eContinue) return eContinue; else return eJumpWhile; } #ifdef AMOS_DEBUG AMPrintf("noble:ReaderRecvBody >>>>>.\n"); #endif return eOK; }
JNIEXPORT jint JNICALL NAME(nativeGetDuration)(JNIEnv *env, jobject thiz) { libvlc_media_player_t *mp = (libvlc_media_player_t *) getIntValue(env, thiz, "mLibVlcMediaPlayer"); int64_t duration = libvlc_media_player_get_length(mp); if (duration < 0) { return -1; } return (jint) (duration / 1000); }
JNIEXPORT jint JNICALL NAME(nativeGetCurrentPosition)(JNIEnv *env, jobject thiz) { libvlc_media_player_t *mp = (libvlc_media_player_t *) getIntValue(env, thiz, "mLibVlcMediaPlayer"); int64_t position = libvlc_media_player_get_time(mp); if (position < 0) { return -1; } return (jint) (position / 1000); }
void ConeTreeLayouterNode::setCompression () { double compression = getIntValue(m_CompressionNameParameter); if (m_Compression == compression) return; m_Compression = compression; M_LAYOUT->SetCompression(m_Compression); }
void ClusteringLayouterNode::setMaxNumberOfIterations () { int maxIterations = getIntValue("Set Max Number Of Iterations"); if (m_maxIterations == maxIterations) return; m_maxIterations = maxIterations; M_LAYOUT->SetMaxNumberOfIterations(m_maxIterations); }
//! //! Set the layout properties //! void ClusteringLayouterNode::setRandomSeed () { int randomSeed = getIntValue("Set Random Seed"); if (randomSeed == m_randomSeed) return; m_randomSeed = randomSeed; M_LAYOUT->SetRandomSeed(m_randomSeed); }
void ClusteringLayouterNode::setCoolDownRate () { int coolDownRate = getIntValue("Set Cool Down Rate"); if (m_coolDownRate == coolDownRate) return; m_coolDownRate = coolDownRate; M_LAYOUT->SetCoolDownRate(m_coolDownRate); }
void ClusteringLayouterNode::setIterationsPerLayout () { int layoutIterations = getIntValue("Set Iterations Per Layout"); if (m_layoutIterations == layoutIterations) return; m_layoutIterations = layoutIterations; M_LAYOUT->SetIterationsPerLayout(m_layoutIterations); }
bool getIntValue(ahm::Properties* pProperties, iop::int32 id, iop::int32 &iresult) { if(pProperties) { ahm::Property *pProperty = pProperties->findProperty(id); if(pProperty) return getIntValue(pProperty->value(), iresult); } return false; }
int RegElement::getPreconfigureIntValue(const QString& name) { bool exists; int ret = getIntValue( HKEY_CURRENT_USER, softwareSeafile(), name, &exists); if (exists) { return ret; } return RegElement::getIntValue( HKEY_LOCAL_MACHINE, softwareSeafile(), name); }