std::string valueToString( LargestUInt value ) { UIntToStringBuffer buffer; char *current = buffer + sizeof(buffer); uintToString( value, current ); assert( current >= buffer ); return current; }
std::string valueToString( UInt value ) { char buffer[32]; char *current = buffer + sizeof(buffer); uintToString( value, current ); assert( current >= buffer ); return current; }
std::string valueToString(LargestInt value) { UIntToStringBuffer buffer; char* current = buffer + sizeof(buffer); bool isNegative = value < 0; if (isNegative) value = -value; uintToString(LargestUInt(value), current); if (isNegative) *--current = '-'; assert(current >= buffer); return current; }
std::string valueToString( Value::Int value ) { char buffer[32]; char *current = buffer + sizeof(buffer); bool isNegative = value < 0; if ( isNegative ) value = -value; uintToString( Value::UInt(value), current ); if ( isNegative ) *--current = '-'; assert( current >= buffer ); return current; }
unsigned char * fixedPointToString(unsigned short valor, unsigned char exp, unsigned char minCantDigitos, unsigned char * str){ unsigned char * p; p = uintToString(valor, minCantDigitos, str); p++; str = p; for (minCantDigitos = 0; minCantDigitos <= exp; minCantDigitos++) *(--str + 1) = *str; *str = '.'; return p; }
// Build Recent File menu entries from given generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename) { generic_string strTemp; if (pos < 9) { strTemp.push_back('&'); strTemp.push_back('1' + (TCHAR)pos); } else if (pos == 9) { strTemp.append(TEXT("1&0")); } else { strTemp.append(uintToString(pos + 1)); } strTemp.append(TEXT(": ")); if (filenameLen > 0) { std::vector<TCHAR> vt(filenameLen + 1); //--FLS: W removed from PathCompactPathExW due to compiler errors for ANSI version. PathCompactPathEx(&vt[0], filename.c_str(), filenameLen + 1, 0); strTemp.append(convertFileName(vt.begin(), vt.begin() + lstrlen(&vt[0]))); } else { // (filenameLen < 0) generic_string::const_iterator it = filename.begin(); if (filenameLen == 0) it += PathFindFileName(filename.c_str()) - filename.c_str(); // MAX_PATH is still here to keep old trimming behaviour. if (filename.end() - it < MAX_PATH) { strTemp.append(convertFileName(it, filename.end())); } else { strTemp.append(convertFileName(it, it + MAX_PATH / 2 - 3)); strTemp.append(TEXT("...")); strTemp.append(convertFileName(filename.end() - MAX_PATH / 2, filename.end())); } } return strTemp; }
static void aggvStringifyGpFx(char **words, struct gpFx *effect, struct lm *lm) // turn gpFx structure into array of words { int count = 0; words[count++] = lmCloneString(lm, effect->allele); words[count++] = lmCloneString(lm, blankIfNull(effect->transcript)); words[count++] = uintToString(lm, effect->soNumber); words[count++] = uintToString(lm, effect->detailType); int gpFxNumCols = 4; if (effect->detailType == intron) words[count++] = uintToString(lm, effect->details.intron.intronNumber); else if (effect->detailType == nonCodingExon) { words[count++] = uintToString(lm, effect->details.nonCodingExon.exonNumber); words[count++] = uintToString(lm, effect->details.nonCodingExon.cDnaPosition); } else if (effect->detailType == codingChange) { struct codingChange *cc = &(effect->details.codingChange); words[count++] = uintToString(lm, cc->exonNumber); words[count++] = uintToString(lm, cc->cDnaPosition); words[count++] = uintToString(lm, cc->cdsPosition); words[count++] = uintToString(lm, cc->pepPosition); words[count++] = strUpper(lmCloneString(lm, blankIfNull(cc->aaOld))); words[count++] = strUpper(lmCloneString(lm, blankIfNull(cc->aaNew))); words[count++] = strUpper(lmCloneString(lm, blankIfNull(cc->codonOld))); words[count++] = strUpper(lmCloneString(lm, blankIfNull(cc->codonNew))); } else if (effect->detailType != none) errAbort("annoGratorGpVar: unknown effect type %d", effect->detailType); // Add max number of columns added in any if clause above gpFxNumCols += 8; while (count < gpFxNumCols) words[count++] = ""; }
PMSource::PMSource(const PrivateMessage& pm) { const std::string uid_string = uintToString(pm.getFromUserID()); const std::string::size_type origLen = pm.getDatestamp().length()+1 +pm.getTitle().length()+1 +pm.getFromUser().length()+1 +uid_string.length()+1 +pm.getToUser().length()+1 +pm.getMessage().length()+1; m_PaddingBuffer = new uint8_t[origLen]; //copy datestamp uint64_t done = pm.getDatestamp().length()+1; memcpy(&m_PaddingBuffer[0], pm.getDatestamp().c_str(), done); //copy title memcpy(&m_PaddingBuffer[done], pm.getTitle().c_str(), pm.getTitle().length()+1); done = done + pm.getTitle().length()+1; //copy fromUser memcpy(&m_PaddingBuffer[done], pm.getFromUser().c_str(), pm.getFromUser().length()+1); done = done + pm.getFromUser().length()+1; //copy fromUserID memcpy(&m_PaddingBuffer[done], uid_string.c_str(), uid_string.length()+1); done = done + uid_string.length()+1; //copy toUser memcpy(&m_PaddingBuffer[done], pm.getToUser().c_str(), pm.getToUser().length()+1); done = done + pm.getToUser().length()+1; //copy message memcpy(&m_PaddingBuffer[done], pm.getMessage().c_str(), pm.getMessage().length()+1); done = done + pm.getMessage().length()+1; #ifdef DEBUG if (done!=origLen) { std::cout << "Number of written bytes does not match expected number!\n"; throw std::runtime_error("PMSource::PMSource(): Number of written bytes does not match expected number!"); } #endif m_BufStream.buffer((const char*) m_PaddingBuffer, origLen); m_BitsRead = 0; //BufferStream takes care of pointer, so we set it to NULL here to avoid conflicts m_PaddingBuffer = NULL; }
String ChannelsBufferClass::getValueAsString(unsigned short id){ //If CFG file was loaded if (channelsConfig.isValid()){ //Search the channel int index = channelsConfig.getChannelIndex(id); //If channel config found if (index != -1){ Channel* c = channelsConfig.getChannelByIndex(index); //Convert to arduino String obj switch (c->getDataType()){ case Channel::BIT_FLAG: return buffer[index].toBinString(MSBFIRST); case Channel::DECIMAL: //If size <= is float //Need this difference because conversion is a copy 'n paste of memory if (c->getSize() <= 4){ return String(buffer[index].as<float>(), 6); } return String(buffer[index].as<double>(), 10); case Channel::INTEGER: return intToString(c, buffer[index].data()); case Channel::U_INTEGER: return uintToString(c, buffer[index].data()); case Channel::STRING: return buffer[index].toString(); default: Log.e(CHBUF_TAG) << F("in getValueAsString\t Unknown conversion type channel ") << id << F(" to type ") << c->getDataType() << Endl; } } } //Error return F("nil"); }