Erc Strpack::unpack(uint64_t* val) { uint64_t r=0; while (is_digit(peek()) && hasData()) { r *= 10; r += to_digit(read()); } *val = r; return E_OK; }
T RingBuffer<T>::get() { if (hasData()) { T data = buf[head]; head = (head+1) % bufSize; return data; } return 0; }
void VCFreader::repositionIterator(string chrName,int start,int end){ if(!tabixMode){ cerr<<"The subroutine repositionIterator can only be called on objects constructed using tabix " <<endl; exit(1); } //re-initializing variables needToPopulateQueue =true; fullQueue =false; endQueue =false; numberOfTimesHasDataWasCalled=0; #ifdef DEBUG cout<<"deleteRepo "<<svcfToReturn<<endl; #endif delete svcfToReturn; svcfToReturn=0; indexInQueueOfIndels=-1; indexOfLastIndel=0; previouslyFoundIndel=false; while(!queueOfVCFs.empty()){ #ifdef DEBUG cout<<"deleteQue "<<svcfToReturn<<endl; #endif delete( queueOfVCFs.front() ); queueOfVCFs.pop_front(); } queueOfVCFs.clear(); //if(bp //we need to jump a bit behind to detect CpG and indels int coordinatePrior=max(readAhead,1); rt->repositionIterator(chrName,start-coordinatePrior,end); //need to reposition the queue to the desired coord while(hasData()){ SimpleVCF * current=queueOfVCFs.front(); //SimpleVCF * current=getData(); //cout<<current->getPosition()<<endl; //when the current position is found, we set the flag repoCalledHasData //such that hasData will return true and the first element of the queue will be returned if(int(current->getPosition()) >= start){ repoCalledHasData=true; break; } current=getData(); } }
void BiomeView::reload() { if (!hasData()) { return; } m_Cache.reload(); redraw(); }
String8 AaptFile::getPrintableSource() const { if (hasData()) { String8 name(mGroupEntry.locale.string()); name.appendPath(mGroupEntry.vendor.string()); name.appendPath(mPath); name.append(" #generated"); return name; } return mSourceFile; }
Grib * DataManager::get_grib(int dataType,int levelType, int levelValue) { switch(hasData(dataType,levelType,levelValue)) { case GRIB_GRIB: return grib; case GRIB_CURRENT: return gribCurrent; default: return NULL; } }
void BuildingDataHolder::addData(const BuildingData &data) { BuildingType buildingType = data.getType(); if (hasData(buildingType)) { THROW("Building is already set " << data.getName()); } _mapDataByName.insert(std::make_pair(buildingType, data)); }
void getBuffer() { int8_t i; for( i=0; i<BUF_MAX ; i++) { RF_24G_Buffer[i] = getByte(); } BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); //wait for DR1 to go low while(hasData()); BIT_SET(RF_24G_CE_PORT, RF_24G_CE_BIT); }
/** * This function will add CacheData to list. * * @param cache the cache pointer * @param name the name of CacheData * @param length the value length * @param value the value point * @param valueChangedListener the changed value's callback function * * @return error code */ static CacheErrCode addData(pCache const cache, const char* name, uint8_t length, uint16_t* value, void* (*valueChangedListener)(void *arg)) { CacheErrCode errorCode = CACHE_NO_ERR; pCacheData data; /* lock the thread pool synchronized lock */ cache->pool->lock(cache->pool); data = (pCacheData) malloc(sizeof(CacheData)); assert(data != NULL); if (hasData(cache, name) != NULL) {/* the data must not exist in list */ log_d("the name of %s data is already exist in cache data list", name); errorCode = CACHE_NAME_ERROR; } else { strcpy(data->name, name); } if (errorCode == CACHE_NO_ERR) { if (length > CACHE_LENGTH_MAX) { log_d("the name %s is too long,can't add to list", name); errorCode = CACHE_LENGTH_ERROR; } else { data->length = length; } } if (errorCode == CACHE_NO_ERR) { /* malloc data value space */ data->value = (uint16_t*) malloc(length * sizeof(uint16_t)); assert(data->value != NULL); memcpy(data->value, value, length * sizeof(uint16_t)); data->valueChangedListener = valueChangedListener; data->next = NULL; /* if list is NULL ,then head node is equal of tail node*/ if (cache->dataHead == NULL) { cache->dataHead = cache->dataTail = data; } else if ((cache->dataHead == cache->dataTail) /* the list has one node */ && (cache->dataHead != NULL)) { cache->dataHead->next = data; cache->dataTail = data; } else { /* the list has more than one node*/ cache->dataTail->next = data; cache->dataTail = data; } log_d("add %s to data list is success", name); } else if (errorCode != CACHE_NO_ERR) { free(data); data = NULL; } /* unlock the thread pool synchronized lock */ cache->pool->unlock(cache->pool); return errorCode; }
void BuildingDataHolder::addData(const BuildingData &data) { BuildingType buildingType = data.getType(); if (hasData(buildingType)) { StringHelper::debug( 0xff, "Building is already set %s", data.getName().c_str() ); return; } _d->buildings.insert(std::make_pair(buildingType, data)); }
void ProfiledState::setInputRecordedType(int input_index, RecordedType new_type) { AvmAssert (hasData()); AvmAssert (input_index < input_count_); RecordedType previous_type = profiled_types_[input_index]; if ((new_type != previous_type) && (previous_type != kUNINITIALIZED)) { new_type = kVARIADIC; } profiled_types_[input_index] = new_type; }
void OSLineEdit2::focusInEvent(QFocusEvent * e) { if (e->reason() == Qt::MouseFocusReason && m_hasClickFocus) { QString style("QLineEdit { background: #ffc627; }"); setStyleSheet(style); emit inFocus(true, hasData()); } QLineEdit::focusInEvent(e); }
/** * Registers a new Dataset with data and identifier id. * * If a Dataset with identifier id already exists, a runtime_error is thrown. * (Check with DataConnector::hasData when necessary.) * * @param data simulation data to store in the Dataset * @param id new identifier for the Dataset */ void registerData(ISimulationData &data, uint32_t id) { if (hasData(id)) throw std::runtime_error(getExceptionStringForID("DataConnector dataset ID already exists", id)); Dataset::DatasetStatus status = Dataset::AUTO_INVALID; Dataset * dataset = new Dataset(data, status); datasets.mapping[id] = dataset; datasets.sorter->add(id); }
/* MemChunk::fillData * Overwrites all data bytes with [val] (basically is memset). * Returns false if no data exists, true otherwise *******************************************************************/ bool MemChunk::fillData(uint8_t val) { // Check data exists if (!hasData()) return false; // Fill data with value memset(data, val, size); // Success return true; }
ISC_STATUS StatusVector::ImplStatusVector::copyTo(IStatus* dest) const throw() { if (hasData()) { dest->set(length() + 1u, value()); } else { ISC_STATUS t[3] = {isc_arg_gds, FB_SUCCESS, isc_arg_end}; dest->set(3, t); } return dest->get()[1]; }
void BiomeView::paintEvent(QPaintEvent * a_Event) { QPainter p(this); if (hasData()) { p.drawImage(QPoint(0, 0), m_Image); } else { p.drawText(a_Event->rect(), Qt::AlignCenter, "No chunk source selected"); } p.end(); }
virtual const CompoundPtr hasSomethingToSend() const { CompoundPtr it; if(preferACK()) { it = hasACK(); if(!it) { it = hasData(); } } else { it = hasData(); if(!it) { it = hasACK(); } } return it; } // hasSomethingToSend()
/* MemChunk::clear * Deletes the memory chunk. * Returns false if no data exists, true otherwise. *******************************************************************/ bool MemChunk::clear() { if (hasData()) { delete[] data; data = NULL; size = 0; cur_ptr = 0; return true; } return false; }
ISC_STATUS StatusVector::ImplStatusVector::copyTo(ISC_STATUS* dest) const throw() { if (hasData()) { fb_utils::copyStatus(dest, ISC_STATUS_LENGTH, value(), length() + 1u); } else { dest[0] = isc_arg_gds; dest[1] = FB_SUCCESS; dest[2] = isc_arg_end; } return dest[1]; }
/** * Update content of texture from message */ bool srs_ui_but::CRosDepthTexture::convertDepth(const sensor_msgs::ImageConstPtr& raw_msg) { CDepthImageConvertor::convertDepth( raw_msg ); // std::cerr << "...Depth: Converting image. M_COUNTER: " << m_counter << std::endl; if( hasData() ) { // std::cerr << "...Depth: Converting image..." << std::endl; return m_texture_converter.convert( m_depth_msg, false ); } return false; }
ISC_STATUS StatusVector::ImplStatusVector::copyTo(ISC_STATUS* dest) const throw() { if (hasData()) { memcpy(dest, value(), (length() + 1u) * sizeof(ISC_STATUS)); } else { dest[0] = isc_arg_gds; dest[1] = FB_SUCCESS; dest[2] = isc_arg_end; } return dest[1]; }
void GeometryPort::saveData(const std::string& path) const throw (VoreenException) { if (!hasData()) throw VoreenException("Port is empty"); tgtAssert(!path.empty(), "empty path"); // append .xml if no extension specified std::string filename = path; if (tgt::FileSystem::fileExtension(filename).empty()) filename += ".xml"; // serialize workspace XmlSerializer s(filename); s.setUseAttributes(true); s.serialize("Geometry", getData()); // write serialization data to temporary string stream std::ostringstream textStream; try { s.write(textStream); if (textStream.fail()) throw SerializationException("Failed to write serialization data to string stream."); } catch (std::exception& e) { throw SerializationException("Failed to write serialization data to string stream: " + std::string(e.what())); } catch (...) { throw SerializationException("Failed to write serialization data to string stream (unknown exception)."); } // Now we have a valid StringStream containing the serialization data. // => Open output file and write it to the file. std::fstream fileStream(filename.c_str(), std::ios_base::out); if (fileStream.fail()) throw SerializationException("Failed to open file '" + filename + "' for writing."); try { fileStream << textStream.str(); } catch (std::exception& e) { throw SerializationException("Failed to write serialization data stream to file '" + filename + "': " + std::string(e.what())); } catch (...) { throw SerializationException("Failed to write serialization data stream to file '" + filename + "' (unknown exception)."); } fileStream.close(); }
unsigned int CYSFEcho::readData(unsigned char* data) { if (!hasData()) return 0U; unsigned char len; m_buffer.getData(&len, 1U); m_buffer.getData(data, len); // If the FICH is valid, regenerate the sync if ((data[1U] & 0x01U) == 0x01U) { data[2U] = YSF_SYNC_BYTES[0U]; data[3U] = YSF_SYNC_BYTES[1U]; data[4U] = YSF_SYNC_BYTES[2U]; data[5U] = YSF_SYNC_BYTES[3U]; data[6U] = YSF_SYNC_BYTES[4U]; } if (!hasData()) m_timer.stop(); return len; }
void Configuration::addProperty(const string &fileName, const string &key, const string &value) { Data data(key,value); if(files.find(fileName) == files.end()) { //cout << "call addsource first " << endl; return; } if(true == hasData(fileName, data)) { return; } files[fileName].insert(data); }
std::string GeometryPort::getHash() const { if (!hasData()) return ""; std::string hashes; std::vector<const Geometry*> geometries = getAllData(); if (geometries.size() == 1) return geometries.front()->getHash(); else { for (size_t i=0; i<geometries.size(); i++) hashes += geometries.at(i)->getHash(); return VoreenHash::getHash(hashes); } }
MockSupport* MockSupport::getMockSupportScope(const SimpleString& name) { SimpleString mockingSupportName = MOCK_SUPPORT_SCOPE_PREFIX; mockingSupportName += name; if (hasData(mockingSupportName)) { STRCMP_EQUAL("MockSupport", getData(mockingSupportName).getType().asCharString()); return (MockSupport*) getData(mockingSupportName).getObjectPointer(); } MockSupport *newMock = clone(name); setDataObject(mockingSupportName, "MockSupport", newMock); return newMock; }
void OSComboBox2::onCurrentIndexChanged(const QString & text) { emit inFocus(true, hasData()); OS_ASSERT(m_modelObject); if( m_choiceConcept ) { std::string value = text.toStdString(); this->blockSignals(true); m_choiceConcept->set(value); onModelObjectChanged(); // will be sure to display actual value this->blockSignals(false); } }
void OSLineEdit2::onEditingFinished() { if(m_modelObject && m_set) { if (m_text != this->text().toStdString()) { m_text = this->text().toStdString(); bool result = (*m_set)(m_text); if (!result) { //restore onModelObjectChange(); } else { emit inFocus(true, hasData()); adjustWidth(); } } } }
Erc Strpack::unpack(bool* pv) { char line[10]; int i=0; while (hasData() && i < 6) { line[i++] = read(); } line[i] = '\0'; if (strcmp(line, "true") == 0) { *pv = true; return E_OK; }; if (strcmp(line, "false") == 0) { *pv = false; return E_OK; }; return E_INVAL; }
void ODBCStatementImpl::makeInternalExtractors() { if (hasData() && !extractions().size()) { try { fillColumns(); } catch (DataFormatException&) { if (isStoredProcedure()) return; throw; } makeExtractors(columnsReturned()); fixupExtraction(); } }