这篇教程C++ valueToString函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中valueToString函数的典型用法代码示例。如果您正苦于以下问题:C++ valueToString函数的具体用法?C++ valueToString怎么用?C++ valueToString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了valueToString函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: evaluateBoolExpr//.........这里部分代码省略......... u = stackiter->data; if (u->type != 'b') { v = evaluateValue(u); if (v == NULL) { freeList(stack); m++; for (p=0;p<m;p++) { free(n[p]); } free(n); return NULL; } if (v->type == 's') { t = v->data; } if (u->type != 'v') freeValue(v); } k = evaluateValueAsBool(stackiter->data); if (isnan(k)) { m++; for (p=0;p<m;p++) { free(n[p]); } free(n); freeList(stack); return NULL; } stackiter = stackiter->next; if (c[0] == '~') { if (w == NULL) { continue; } s = valueToString(w); t = valueToString(v); re = pcre_compile(t, 0, &err, &erroff, NULL); if (pcre_exec(re, NULL, s, strlen(s), 0, 0, ovec, PCREOVECCOUNT) > -1) *n[m] = 1; free(s); free(t); if (re) pcre_free(re); continue; } if (c[0] == '?') { if (w == NULL || v == NULL) continue; if (w->type == v->type) { if (v->type != 'l' || ((List*)v->data)->data == NULL) { *n[m] = 1; continue; } prop = ((List*)((List*)v->data)->data)->next; while (prop != NULL) { if (!findInTree(((List*)((List*)w->data)->data)->data, ((Variable*)prop->data)->name)) break; prop = prop->next; } if (prop == NULL) *n[m] = 1; } } if (t != NULL && s != NULL) { if (s == t && c[0] == '=') { *n[m] = 1; continue; }
开发者ID:uiri,项目名称:fffll,代码行数:67,
示例2: valueToStringJSONCPP_STRING valueToString(UInt value) { return valueToString(LargestUInt(value));}
开发者ID:151706061,项目名称:jsoncpp,代码行数:3,
示例3: throwvoid STF_AD_FAST::STF_AD_FAST_Device::parseDeviceEventsFPGA(const RawEventMap &eventsIn, SynchronousEventVector& eventsOut)throw(std::exception){ uInt16 intSamples; double numSamples; double oldNumSamples = 1; uInt32 channel; std::string errorMessage; double lastEventTime = 10*minimumEventSpacing*0 + triggerOffset; //cerr << "STF_AD_FAST_Device::parseDeviceEvents()" << endl;// int i = 1; RawEventMap::const_iterator events; for(events = eventsIn.begin(); events != eventsIn.end(); events++) { channel = events->second.at(0).channel(); //TODO: construct bit line commands from iter->second events numSamples = 1; // check what type of event it is if(events->second.at(0).getValueType() == MixedValue::Double) //one value given, number of samples to average { numSamples = events->second.at(0).value().getDouble(); //retrieve the number of samples to average } if(numSamples <= 32768.0 && numSamples >= 1.0) intSamples = static_cast<uInt16>(floor(numSamples-1)); // we write one less, because the FPGA will always take 1 data point, and this value is the number of additional samples to accumulate else throw EventParsingException(events->second.at(0), "The Analog-In only supports values between 1 and 32768. This integer is the number of A/D samples to average @ ~1MHz for this data point."); if(lastEventTime + (oldNumSamples)*minimumEventSpacing > events->first) { errorMessage = "The analog-in requires at least " + valueToString((oldNumSamples)*minimumEventSpacing) + " ns between these events to allow for averaging " + valueToString(oldNumSamples) + " samples first @ ~1MHz."; throw EventParsingException(events->second.at(0), errorMessage); } //with averaging// eventsOut.push_back( // (new AnalogInEvent(events->first - triggerOffset, this))// ->setBits(intSamples, 16, 31) //set the upper 16 bits to the number of samples to average// ->setBits(channel, 0, 15)// ); //original code if(events->second.at(0).channel() == 0) { eventsOut.push_back( (new AnalogInEvent(events->first - triggerOffset, this)) ->setBits(intSamples, 16, 31) //set the upper 16 bits to the number of samples to average ->setBits(channelCommand, 0, 15) );// eventsOut.push_back( // (new AnalogInEvent(events->first - triggerOffset, this)) // ->setBits(3) // ); } if(events->second.at(0).channel() == 1) { eventsOut.push_back( (new AnalogInEvent(events->first - triggerOffset, this)) ->setBits(channelCommand) ); }// std::cerr << "About to add measurement " << i << std::endl; eventsOut.back().addMeasurement( events->second.at(0) ); //temporary! (it should pick the right event) //set old event values to the current values before looping oldNumSamples = numSamples; lastEventTime = events->first;// std::cerr << "Parsed event number: " << i << std::endl; } events--;// throw EventParsingException(events->second.at(0), "Finished parsing"); // cerr << "STF_AD_FAST_Device::parseDeviceEvents() " << eventsOut.size() << endl;}
开发者ID:jasonhogan,项目名称:sti-devices,代码行数:80,
示例4: dbRequeststd::string CCatPage::buildContent() const{ CTemplateHelper* templateManager = CTemplateHelper::getInstance(); CDBManager* dbManager = CManagers::getInstance()->getDBManager(); std::shared_ptr<CDBRequest> dbRequest(dbManager->createDBRequest()); std::map<std::string, std::string> params; tmpString = ""; const CUser* user = dynamic_cast<const CUser*>(currRequest->getUser()); CConfigHelper* settingsManager = CConfigHelper::getInstance(); const CHTMLTemplate* contentTemplate = templateManager->findTemplate("content"); if(contentTemplate == NULL) return "Missing content template"; const CMenuCategory* currCategory = CMenu::getInstance()->findCategoryByName(getPageName()); if(currCategory == NULL) return "Cant find this category"; if(!user->getIsValid())return "User not valid"; const std::vector<int> threadsId = currCategory->getThreadsId(settingsManager->getIntParamValue("defaulThreadsCnt", 10)); const std::vector<int>* fixedThreadsId = user->getFixedThreads(); tmpString += "<input type='hidden' name='category_id' value='"; tmpString += valueToString(currCategory->getId()); tmpString += "' /> /n"; tmpString += "<input type='hidden' name='return_page' value='"; tmpString += getPageName(); tmpString += "' /> /n" ; tmpString += "<h1>/"; tmpString += htmlspecialchars(currCategory->getName()); tmpString += "/ — "; tmpString += htmlspecialchars(currCategory->getDescription()); tmpString += "</h1> /n"; if(currCategory->getThreadCreationAccessLevel() <= user->getUserType(currCategory->getId())) { tmpString += buildNewThreadForm(getPageName(), currCategory->getId(), user); tmpString += "/n"; } if(currCategory->getPostCreationAccessLevel() <= user->getUserType(currCategory->getId())) { tmpString += buildNewPostForm(getPageName(), user); tmpString += "/n"; } // GLOBAL FIXED THREADS int threadsCnt = 0; int hiddenthreadsCnt = 0; const CDBRequestResult* result = dbRequest->selectRequest(CDBValues("id"),"Threads", "`threadCatId` = "+valueToString(currCategory->getId())+" AND `isFixed` = 1"); if(dbRequest->getIsLastQuerySuccess() && result != NULL && result->getRowsCnt() > 0) { for(int i = 0; i < result->getRowsCnt(); i++) { int threadId = 0; threadId = result->getIntValue(i, 0); const CThread* currThread = new CThread(threadId); if(!currThread->getIsValid() || currThread->getIsHidden()) { if(currThread->getIsHidden()) hiddenthreadsCnt++; delete currThread; continue; } threadsCnt++; tmpString += buildThread(currThread, user); tmpString += "/n"; delete currThread; } } // USER FIXED THREADS for(unsigned int i = 0; i < fixedThreadsId->size(); i++) { const CThread* currThread = new CThread((*fixedThreadsId)[i]); if(!currThread->getIsValid() || currThread->getIsFixed() || currThread->getCatId() != currCategory->getId() || currThread->getIsHidden()) { delete currThread; continue; } threadsCnt++; tmpString += buildThread(currThread, user); tmpString += "/n"; delete currThread; } tmpString += "<br> /n"; // ALL OTHER THREADS int minThreadPosition = INT_MAX; for(unsigned int i = 0; i < threadsId.size(); i++) { const CThread* currThread = new CThread(threadsId[i]); if(currThread->getIsValid() && currThread->getIsHidden() && !currThread->getIsFixed()) hiddenthreadsCnt++; if(!currThread->getIsValid() || user->getIsThreadFixed(threadsId[i]) || currThread->getIsFixed() || currThread->getIsHidden()) { delete currThread;//.........这里部分代码省略.........
开发者ID:AntonBogomolov,项目名称:FastImageBoard,代码行数:101,
示例5: switchvoidFastWriter::writeValue ( const Value& value ){ switch ( value.type () ) { case nullValue: document_ += "null"; break; case intValue: document_ += valueToString ( value.asInt () ); break; case uintValue: document_ += valueToString ( value.asUInt () ); break; case realValue: document_ += valueToString ( value.asDouble () ); break; case stringValue: document_ += valueToQuotedString ( value.asCString () ); break; case booleanValue: document_ += valueToString ( value.asBool () ); break; case arrayValue: { document_ += "["; int size = value.size (); for ( int index = 0; index < size; ++index ) { if ( index > 0 ) document_ += ","; writeValue ( value[index] ); } document_ += "]"; } break; case objectValue: { Value::Members members ( value.getMemberNames () ); document_ += "{"; for ( Value::Members::iterator it = members.begin (); it != members.end (); ++it ) { std::string const& name = *it; if ( it != members.begin () ) document_ += ","; document_ += valueToQuotedString ( name.c_str () ); document_ += ":"; writeValue ( value[name] ); } document_ += "}"; } break; }}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:70,
示例6: write_valuevoidwrite_value (write_t write, Value const& value){ switch (value.type()) { case nullValue: write("null", 4); break; case intValue: write_string(write, valueToString(value.asInt())); break; case uintValue: write_string(write, valueToString(value.asUInt())); break; case realValue: write_string(write, valueToString(value.asDouble())); break; case stringValue: write_string(write, valueToQuotedString(value.asCString())); break; case booleanValue: write_string(write, valueToString(value.asBool())); break; case arrayValue: { write("[", 1); int const size = value.size(); for (int index = 0; index < size; ++index) { if (index > 0) write(",", 1); write_value(write, value[index]); } write("]", 1); break; } case objectValue: { Value::Members const members = value.getMemberNames(); write("{", 1); for (auto it = members.begin(); it != members.end(); ++it) { std::string const& name = *it; if (it != members.begin()) write(",", 1); write_string(write, valueToQuotedString(name.c_str())); write(":", 1); write_value(write, value[name]); } write("}", 1); break; } }}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:62,
示例7: throwvoid stf_output_device::parseDeviceEventsFPGA(const RawEventMap &eventsIn, SynchronousEventVector& eventsOut)throw(std::exception){ RawEventMap::const_iterator events; double eventTime; //time when the FPGA should trigger in order to have the output ready in time double previousTime; //time when the previous event occurred unsigned char bit; unsigned short channel; DigitalOutEvent* digitalEvent; for(events = eventsIn.begin(); events != eventsIn.end(); events++) { if(events != eventsIn.begin()) { events--; previousTime = events->first; events++; } else previousTime = minimumAbsoluteStartTime - minimumEventSpacing; eventTime = events->first - holdoff; //we can put events closer together than this, but they don't happen until 2*us later if( (events->first - minimumEventSpacing) < previousTime) { if(events != eventsIn.begin()) throw EventParsingException(events->second.at(0), "The Digital Out board needs " + valueToString(minimumEventSpacing) + " ns between events."); else throw EventParsingException(events->second.at(0), "The Digital Out board needs " + valueToString(minimumAbsoluteStartTime)+ " ns at the beginning of the timing file."); } digitalEvent = new DigitalOutEvent(eventTime, this); //eventsOut ptr_vector will handle deletion if it gets push_back'ed for(unsigned i = 0; i < events->second.size(); i++) { bit = static_cast<unsigned char>( events->second.at(i).numberValue() ); channel = events->second.at(i).channel(); if(bit == 0 || bit == 1) {//*******************Check the correct bit pattern**************** // bitState.at(static_cast<std::size_t>(channel)) = (bit == 0 ? false : true); bitState.set(channel, (bit == 0 ? false : true) ); // digitalEvent->setBits( bit, channel, channel + 1 ); } else { delete digitalEvent; //free memory before throwing exception throw EventParsingException(events->second.at(i), "The Digital Out board value must be either '1' or '0'."); } } for(unsigned j = 0; j < 24; j++) { digitalEvent->setBits( bitState.test(j), j, j ); } eventsOut.push_back( digitalEvent ); }}
开发者ID:jasonhogan,项目名称:sti-deprecated,代码行数:67,
示例8: throwExceptionvoid CEditListNumericEditor::outOfRangeException(double v) const { throwException(_T("%s out of range. Legal interval:%s") ,valueToString(v).cstr(), legalIntervalToString().cstr());}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:4,
示例9: switch void StyledWriter::writeValue( const Value& value ) { switch ( value.type() ) { case nullValue: pushValue( "null" ); break; case intValue: pushValue( valueToString( value.asLargestInt() ) ); break; case uintValue: pushValue( valueToString( value.asLargestUInt() ) ); break; case realValue: pushValue( valueToString( value.asDouble() ) ); break; case stringValue: pushValue( valueToQuotedString( value.asCString() ) ); break; case booleanValue: pushValue( valueToString( value.asBool() ) ); break; case arrayValue: writeArrayValue( value); break; case objectValue: { Value::Members members( value.getMemberNames() ); if ( members.empty() ) { pushValue( "{}" ); } else { writeWithIndent( "{" ); indent(); Value::Members::iterator it = members.begin(); for (;;) { const std::string& name = *it; const Value& childValue = value[name]; writeCommentBeforeValue( childValue ); writeWithIndent( valueToQuotedString( name.c_str() ) ); document_ += " : "; writeValue( childValue ); if ( ++it == members.end() ) { writeCommentAfterValueOnSameLine( childValue ); break; } document_ += ","; writeCommentAfterValueOnSameLine( childValue ); } unindent(); writeWithIndent( "}" ); } } break; } }
开发者ID:MutantEel,项目名称:Artemis-Cpp,代码行数:74,
示例10: reportValue inline void reportValue(signals::EType type, const void* value) const { Locker lock(st_screenLock); std::cout << m_prefix.c_str() << "/" << m_name.c_str() << ": " << valueToString(type, value).c_str() << std::endl; }
开发者ID:mstramb,项目名称:modHpsdr,代码行数:5,
示例11: switch void HTMLWriter::writeValue(std::string &document, const Value &value) { switch(value.type()) { case nullValue: break; case intValue: document += valueToString(value.asLargestInt()); break; case uintValue: document += valueToString(value.asLargestUInt()); break; case realValue: document += valueToString(value.asDouble()); break; case stringValue: document += valueToQuotedString(value.asString().c_str()); break; case booleanValue: document += value.asBool(); break; case arrayValue: { document += "<ol>"; for (uint8_t index = 0; index < value.size(); index++) { switch(value[index].type()) { case nullValue: case intValue: case uintValue: case realValue: case stringValue: case booleanValue: writeIndent(document); document += "<li>"; writeValue(document, value[index]); document += "</li>"; document += "/n"; break; case arrayValue: case objectValue: depth++; document += "<li>"; writeValue(document, value[index]); depth--; document += "</li>"; break; } } break; } case objectValue: { Value::Members members(value.getMemberNames()); if (depth == 0) { document += "<dl class='la_results'>"; } else { document += "<dl>"; } for (Value::Members::iterator it = members.begin(); it != members.end(); ++it) { const std::string &name = *it; writeIndent(document); document += "<dt>"; document += name; document += "</dt>/n"; writeIndent(document); document += "<dd>"; switch(value[name].type()) { case nullValue: case intValue: case uintValue: case realValue: case stringValue: case booleanValue: writeValue(document, value[name]); break; case arrayValue: case objectValue: depth++; writeValue(document, value[name]); depth--; } document += "</dd>/n"; } document += "</dl>/n"; break; } } }
开发者ID:gitter-badger,项目名称:dronekit-la,代码行数:86,
示例12: assertvoid TupleSchema::setColumnMetaData(uint16_t index, ValueType type, const int32_t length, bool allowNull, uint16_t &uninlinedObjectColumnIndex, bool inBytes){ assert(length <= COLUMN_MAX_VALUE_LENGTH); uint32_t offset = 0; // set the type ColumnInfo *columnInfo = getColumnInfo(index); columnInfo->type = static_cast<char>(type); columnInfo->allowNull = (char)(allowNull ? 1 : 0); columnInfo->length = length; columnInfo->inBytes = inBytes; if ((type == VALUE_TYPE_VARCHAR && inBytes) || type == VALUE_TYPE_VARBINARY) { if (length == 0) { throwFatalLogicErrorStreamed("Zero length for object type " << valueToString((ValueType)type)); } if (length < UNINLINEABLE_OBJECT_LENGTH) { /* * Inline the string if it is less then UNINLINEABLE_OBJECT_LENGTH bytes. */ columnInfo->inlined = true; // One byte to store the size offset = static_cast<uint32_t>(length + SHORT_OBJECT_LENGTHLENGTH); } else { /* * Set the length to the size of a String pointer since it won't be inlined. */ offset = static_cast<uint32_t>(NValue::getTupleStorageSize(type)); columnInfo->inlined = false; setUninlinedObjectColumnInfoIndex(uninlinedObjectColumnIndex++, index); } } else if (type == VALUE_TYPE_VARCHAR) { if (length == 0) { throwFatalLogicErrorStreamed("Zero length for object type " << valueToString((ValueType)type)); } if (length < UNINLINEABLE_CHARACTER_LENGTH) { /* * Inline the string if it is less then UNINLINEABLE_CHARACTER_LENGTH characters. */ columnInfo->inlined = true; // One byte to store the size offset = static_cast<uint32_t>(length * 4 + SHORT_OBJECT_LENGTHLENGTH); } else { /* * Set the length to the size of a String pointer since it won't be inlined. */ offset = static_cast<uint32_t>(NValue::getTupleStorageSize(type)); columnInfo->inlined = false; setUninlinedObjectColumnInfoIndex(uninlinedObjectColumnIndex++, index); } } else { // All values are inlined if they aren't strings. columnInfo->inlined = true; // don't trust the planner since it can be avoided offset = static_cast<uint32_t>(NValue::getTupleStorageSize(type)); } // make the column offsets right for all columns past this one int oldsize = columnLengthPrivate(index); ColumnInfo *nextColumnInfo = NULL; for (int i = index + 1; i <= m_columnCount; i++) { nextColumnInfo = getColumnInfo(i); nextColumnInfo->offset = static_cast<uint32_t>(nextColumnInfo->offset + offset - oldsize); } assert(index == 0 ? columnInfo->offset == 0 : true);}
开发者ID:AsherBond,项目名称:voltdb,代码行数:66,
示例13: getSelectorTokensQStringList jsonParser::get(QString selector, QString defaultValue){ QStringList result; QStringList tokens = getSelectorTokens(selector); QJsonObject root = jDoc.object(); state = OBJECT_STATE; QJsonObject currentObject = root; QJsonArray currentArray; QJsonValue currentValue; QList<QJsonObject> arrayObjects; QList<QJsonValue> arrayValues; foreach (const QString& token, tokens) { if (token == "") continue; if (token == ".") { if (state == VALUE_STATE) { currentObject = currentValue.toObject(); state = OBJECT_STATE; } else if (state == VALUES_ARRAY) { arrayObjects.clear(); for (int valIndex=0; valIndex<currentArray.count(); valIndex++) arrayObjects.append(currentArray.at(valIndex).toObject()); state = OBJECTS_ARRAY; } else return result; } else if (token == "[") { if (state == VALUE_STATE) { currentArray = currentValue.toArray(); state = ARRAY_STATE; } else return result; } else if (token == "]") { if (state == ARRAY_STATE) { arrayValues.clear(); for (int valIndex=0; valIndex<currentArray.count(); valIndex++) arrayValues.append(currentArray.at(valIndex)); state = VALUES_ARRAY; } else if (state == VALUE_STATE) { ; } else return result; } else { bool isInt = false; int index = token.toInt(&isInt); if (state == ARRAY_STATE) { if (isInt && index>=0 && index < currentArray.count()) { currentValue = currentArray.at(index); state = VALUE_STATE; } } else if (state == OBJECT_STATE) { currentValue = currentObject[token]; state = VALUE_STATE; } else if (state == OBJECTS_ARRAY) { for (int valIndex=0; valIndex<arrayObjects.count(); valIndex++) arrayValues.append(arrayObjects.at(valIndex)[token]); state = VALUES_ARRAY; } else return result; } } switch (state) { case VALUE_STATE: result.append(valueToString(currentValue, defaultValue)); break; case VALUES_ARRAY: for (int i=0; i<arrayValues.count(); ++i) result.append(valueToString(arrayValues.at(i), defaultValue)); break; default: break; } return result;}
开发者ID:SpaceWind,项目名称:cyber_jihad_bot_client,代码行数:98,
示例14: throwvoid stf_da_slow_device::parseDeviceEventsFPGA(const RawEventMap &eventsIn, SynchronousEventVector& eventsOut) throw(std::exception){ RawEventMap::const_iterator events; //RawEventMap::const_iterator previousEvents; //uInt32 voltageInt = 0; //uInt32 channel = 0; //uInt32 registerBits = 3; //bool update = false; //bool reset = false; double eventTime; //time when the FPGA should trigger in order to have the output ready in time double previousTime; //time when the previous event occurred for(events = eventsIn.begin(); events != eventsIn.end(); events++) { if(events != eventsIn.begin()) { events--; previousTime = events->first; events++; } else previousTime = minimumAbsoluteStartTime - minimumEventSpacing; eventTime = events->first - holdoff; //we can put events closer together than this, but they don't happen until 2*us later if( (events->first - minimumEventSpacing) < previousTime) { if(events != eventsIn.begin()) throw EventParsingException(events->second.at(0), "The Slow Analog Out board needs " + valueToString(minimumEventSpacing) + " ns between events."); else throw EventParsingException(events->second.at(0), "The Slow Analog Out board needs " + valueToString(minimumAbsoluteStartTime) + " ns at the beginning of the timing file."); } if(events->second.size() > 1) //we only want one event per time { throw EventConflictException(events->second.at(0), events->second.at(1), "The Slow Analog Out cannot currently have multiple events at the same time." ); } for(unsigned i = 0; i < events->second.size(); i++) { if(events->second.at(i).numberValue() > 10 || events->second.at(i).numberValue() < -10) { throw EventParsingException(events->second.at(i), "The Slow Analog Out board only supports voltages between -10 and 10 Volts."); } } //Old way of making an event //voltageInt = static_cast<int>((-1*(events->second.at(0).numberValue()) + 10.)*16383./20.); //channel = events->second.at(0).channel(); //registerBits = 3; //update = true; // //eventsOut.push_back( // new SlowAnalogOutEvent(eventTime, voltageInt, update, channel, registerBits, reset, this) ); eventsOut.push_back( new SlowAnalogOutEvent(eventTime, events->second, this) ); }}
开发者ID:jasonhogan,项目名称:sti-deprecated,代码行数:72,
示例15: validateValuevoid CEditListNumericEditor::setValue(double v) { validateValue(v); const String str = valueToString(v); setWindowText(this, str); SetSel(0, (int)str.length());}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:6,
示例16: stringToValuebool Novatech409B::updateAttribute(string key, string value){ double tempDouble; //the value entered, converted to a number int tempInt; bool successDouble = stringToValue(value, tempDouble); bool successInt = stringToValue(value, tempInt); bool success = successDouble || successInt; if(key.compare("Kp Value") == 0 && successInt) { success = true; int extraTerm; int writeValue; double referenceFrequency; if (referenceIsInternal) referenceFrequency = 28.6331153067; else referenceFrequency = externalRefFreq; writeValue = tempInt; if (!referenceIsInternal && (100 <= tempInt*referenceFrequency && tempInt*referenceFrequency <= 160) || (255 <= tempInt*referenceFrequency && tempInt*referenceFrequency <= 500)) { if(100 < tempInt*referenceFrequency && tempInt*referenceFrequency <160) { extraTerm = 64; } else if(255 < tempInt*referenceFrequency && tempInt*referenceFrequency <500) { extraTerm = 128; } writeValue += extraTerm; } else { std::cerr << "Warning: Kp is out of range w.r.t the external clock. Kp" << std::endl; }/* if((tempInt == 1||(3 < tempInt && tempInt <10)||tempInt == 15)&& ((100 < tempInt*referenceFrequency && tempInt*referenceFrequency < 160 || (255 < tempInt*referenceFrequency && tempInt*referenceFrequency <500))) { //frequencyString = "f" + valueToString(channel) + " " + valueToString(frequency, "", ios::dec, 10); //string firstDigit; //if (tempInt > 15) // firstDigit = ""; //else // firstDigit = "0"; //std::string KpString = "Kp " + firstDigit + valueToString(tempInt, "", ios::hex); int extraTerm; int writeValue; if(tempInt == 1||(3 < tempInt && tempInt <10)) { if(100 < tempInt*referenceFrequency && tempInt*referenceFrequency <160) { extraTerm = 64; } else if(255 < tempInt*referenceFrequency && tempInt*referenceFrequency <500) { extraTerm = 128; } writeValue = tempInt + extraTerm; } if(tempInt == 15) { if(100 < tempInt*referenceFrequency && tempInt*referenceFrequency <160) { writeValue = 85; } else if(255 < tempInt*referenceFrequency && tempInt*referenceFrequency <500) { writeValue = 149; } }*/ std::string KpString = "Kp " + valueToString(writeValue, "", ios::hex); std::string queryResult = serialController->queryDevice(KpString, 50, 30); if (queryResult.find("OK") == std::string::npos) { std::cerr << "Unable to set Kp of " << this->getDeviceName() << std::endl; success = false; } if(success) { KpValue = tempInt; } } else if (key.compare("External Reference Frequency (MHz)") == 0 && successDouble) {//.........这里部分代码省略.........
开发者ID:jasonhogan,项目名称:sti-devices,代码行数:101,
示例17: catchbool Novatech409B::writeChannel(unsigned short channel, const MixedValue& valuet){ std::string queryResult; MixedValueVector tempVec; enum error {TYPE, CHANNEL, RANGE}; std::string errorMessage; FrequencyChannel newFrequencyTriplet;// double frequency;// double amplitude;// double phase; int amplitudeN; int phaseN; try { if (channel >= 0 && channel < 4) { if (valuet.getType() == MixedValue::Vector) { tempVec = valuet.getVector(); if (tempVec.size() != 3) throw TYPE; newFrequencyTriplet.frequency = tempVec.at(0).getDouble(); newFrequencyTriplet.amplitude = tempVec.at(1).getDouble(); newFrequencyTriplet.phase = tempVec.at(2).getDouble(); amplitudeN = static_cast<int>( (newFrequencyTriplet.amplitude / 100.0) * amplitudeMaxVal ); phaseN = static_cast<int>( (newFrequencyTriplet.phase / 360.0) * phaseMaxVal ); if( !checkRanges(newFrequencyTriplet, errorMessage) ) { //Bad range found throw RANGE; } } else throw TYPE; } else throw CHANNEL; } catch (error e) { if (e == CHANNEL) std::cerr << this->getDeviceName() << " expects channel 0, 1, 2,or 3 for a write command" << std::endl; if (e == TYPE) std::cerr << this->getDeviceName() << " requires a triplet of doubles: (frequency, amplitude, phase)" << std::endl; if (e == RANGE) std::cerr << this->getDeviceName() << " allows ranges of (0-171.1276031 MHz, 0-100 percent, 0-360 degrees)" << std::endl; return false; } std::string frequencyString, amplitudeString, phaseString; //Set frequency if (frequencyChannels.at(channel).frequency != newFrequencyTriplet.frequency) { frequencyString = "f" + valueToString(channel) + " " + valueToString(newFrequencyTriplet.frequency, "", ios::dec, 10); queryResult = serialController->queryDevice(frequencyString, 50, 30); if (queryResult.find("OK") == std::string::npos) { std::cerr << "Unable to set frequency of " << this->getDeviceName() << " channel " << channel << std::endl; return false; } frequencyChannels.at(channel).frequency = newFrequencyTriplet.frequency; } //Set amplitude if (frequencyChannels.at(channel).amplitude != newFrequencyTriplet.amplitude) { amplitudeString = "v" + valueToString(channel) + " " + valueToString(amplitudeN); queryResult = serialController->queryDevice(amplitudeString); if (queryResult.find("OK") == std::string::npos) { std::cerr << "Unable to set amplitude of " << this->getDeviceName() << " channel " << channel << std::endl; return false; } frequencyChannels.at(channel).amplitude = newFrequencyTriplet.amplitude; } //Set phase if (frequencyChannels.at(channel).phase != newFrequencyTriplet.phase) { phaseString = "p" + valueToString(channel) + " " + valueToString(phaseN); queryResult = serialController->queryDevice(phaseString); if (queryResult.find("OK") == std::string::npos) { std::cerr << "Unable to set phase of " << this->getDeviceName() << " channel " << channel << std::endl; return false; } frequencyChannels.at(channel).phase = newFrequencyTriplet.phase; } return true;}
开发者ID:jasonhogan,项目名称:sti-devices,代码行数:100,
示例18: CThreadstd::string CEditPage::buildContent() const{ CTemplateHelper* templateManager = CTemplateHelper::getInstance(); std::map<std::string, std::string> params; std::string tmpStr = ""; const CUser* user = dynamic_cast<const CUser*>(currRequest->getUser()); if(!user->getIsValid() || !isValidId) return ""; const CHTMLTemplate* contentTemplate = templateManager->findTemplate("content"); const CHTMLTemplate* editPageTemplate = templateManager->findTemplate("editPage"); if(contentTemplate == NULL || editPageTemplate == NULL) return "Missing content template"; if(isThreadId) { const CThread* currThread = new CThread(id, false); if(!currThread->getIsValid() || (user->getUserId() != currThread->getUserId() && !user->getIsModerInAnyCategories())) { delete currThread; return ""; } params["{RETURNPAGE}"] = CMenu::getInstance()->findCategoryById(currThread->getCatId())->getName(); params["{EDITTYPE}"] = isThreadId ? "thread" : "post"; params["{ID}"] = idStr; params["{USERID}"] = valueToString(user->getUserId()); params["{TEXT}"] = currThread->getText(); params["{isHIDDEN}"] = currThread->getIsHidden() ? "true" : "false"; params["{isTHREAD}"] = "true"; //params["{ATTACHMENTS}"] = currThread->getAttachmentString(); tmpStr = editPageTemplate->getHTMLData(¶ms); delete currThread; } else { const CPost* currPost = new CPost(id); if(!currPost->getIsValid() || (user->getUserId() != currPost->getUserId() && !user->getIsModerInAnyCategories())) { delete currPost; return ""; } int catId = 0; CDBManager* dbManager = CManagers::getInstance()->getDBManager(); std::shared_ptr<CDBRequest> dbRequest(dbManager->createDBRequest()); const CDBRequestResult* result = dbRequest->selectRequest(CDBValues("threadCatId"), "Threads", "`id`="+valueToString(currPost->getThreadId()), "LIMIT 1"); //MYSQL_RES* result = DBRequest.createRequest("SELECT `threadCatId` FROM `Threads` WHERE `id`="+valueToString(currPost->getThreadId())+" LIMIT 1;"); if(dbRequest->getIsLastQuerySuccess() && result != NULL && result->getRowsCnt() > 0) { try{ catId = result->getIntValue(0,0); } catch(...){ catId = 0; } } const CMenuCategory* menuCat = CMenu::getInstance()->findCategoryById(catId); std::string returnPage = "index"; if(menuCat != NULL) returnPage = menuCat->getName(); params["{RETURNPAGE}"] = returnPage; params["{EDITTYPE}"] = isThreadId ? "thread" : "post"; params["{ID}"] = idStr; params["{USERID}"] = valueToString(user->getUserId()); params["{TEXT}"] = currPost->getText(); params["{isHIDDEN}"] = "false"; params["{isTHREAD}"] = "false"; //params["{ATTACHMENTS}"] = currPost->getAttachmentString(); tmpStr = editPageTemplate->getHTMLData(¶ms); delete currPost; } params.clear(); params["{LEFTPANEL}"] = buildLeftPanel(user); params["{UPMENU}"] = buildUpperMenu(user); params["{CONTENT}"] = tmpStr; return contentTemplate->getHTMLData(¶ms);}
开发者ID:AntonBogomolov,项目名称:FastImageBoard,代码行数:82,
示例19: throwvoid Novatech409B::parseDeviceEvents(const RawEventMap& eventsIn, SynchronousEventVector& eventsOut) throw(std::exception){ //Make sure the current state of all channels is up to date. refreshLocallyStoredFrequencyChannels(); cerr << endl << endl << "Table: " << endl; RawEventMap::const_iterator events; RawEventMap::const_iterator lastTableEvents; double holdoff = 0; double minimumEventSpacing = 0; double minimumAbsoluteStartTime = 0; double tableStartHoldoff_ns = 1000 * 1000; //1 ms bool goodFormat = true; bool holdEventFound = false; bool channelZeroOrOne = false; FrequencyChannel currentTriplet; FrequencyChannel currentTriplet0 = frequencyChannels.at(0); FrequencyChannel currentTriplet1 = frequencyChannels.at(1); unsigned tableAddress = 0; double tableDwellTime_ns = 0; //in ns double lastTableDwellTime_ns = 0; //in ns std::string errorMessage; double eventTime; double previousTime = minimumAbsoluteStartTime; for(events = eventsIn.begin(); events != eventsIn.end(); events++) { eventTime = events->first - holdoff; if( (events->first - minimumEventSpacing) < previousTime) { if(events != eventsIn.begin()) throw EventParsingException(events->second.at(0), "The Novatech needs " + valueToString(minimumEventSpacing) + " ns between events."); else throw EventParsingException(events->second.at(0), "The Novatech needs " + valueToString(minimumAbsoluteStartTime) + " ns at the beginning of the timing file."); } //Verify format. Parameter convention: (freq, amplitude, phase, [Hold]) for(unsigned i = 0; i < events->second.size(); i++) { goodFormat = events->second.at(i).value().getVector().size() == 3 || events->second.at(i).value().getVector().size() == 4; for(unsigned k = 0; k < 3; k++) { goodFormat &= events->second.at(i).value().getVector().at(k).getType() == MixedValue::Double; } if(!goodFormat) { throw EventParsingException(events->second.at(i), "Bad format. Novatech commands must be of the form (frequency, amplitude, phase, [Hold])."); } currentTriplet.frequency = events->second.at(i).value().getVector().at(0).getDouble(); currentTriplet.amplitude = events->second.at(i).value().getVector().at(1).getDouble(); currentTriplet.phase = events->second.at(i).value().getVector().at(2).getDouble(); //Check parameter range limits if( !checkRanges(currentTriplet, errorMessage) ) { throw EventParsingException(events->second.at(i), "Out of range. Allowed ranges are (0-171.1276031) MHz; (0-100) percent; (0-360) degrees."); } } //Check for trigger hold command if( isHoldEvent(events) ) { holdEventFound = true; //always True after 1st hold event is found (switches to Table Mode). } //As long as their is no "Hold" event found, assume the events are soft timing and use PsuedoSynchronousEvents if(!holdEventFound) { eventsOut.push_back( new STI_Device::PsuedoSynchronousEvent(events->first, events->second, this) ); //Update channel 0 and 1 triplets to most recent event. This allows for a dummy event at the start //of table mode. The dummy event will be whatever value was last played on the channel. for(unsigned j = 0; j < events->second.size(); j++) { if(events->second.at(j).channel() == 0) { getTriplet(events->second.at(j).value(), currentTriplet0); } if(events->second.at(j).channel() == 1) { getTriplet(events->second.at(j).value(), currentTriplet1); } }//.........这里部分代码省略.........
开发者ID:jasonhogan,项目名称:sti-devices,代码行数:101,
示例20: valueToStringstd::string CSettingsPage::buildContent() const{ const CUser* user = dynamic_cast<const CUser*>(currRequest->getUser()); CTemplateHelper* templateManager = CTemplateHelper::getInstance(); std::map<std::string, std::string> params; tmpString = ""; const CHTMLTemplate* contentTemplate = templateManager->findTemplate("content"); const CHTMLTemplate* settingsTemplate = templateManager->findTemplate("settingsPage"); if(contentTemplate == NULL || settingsTemplate == NULL) return "Missing content template"; params["{USERID}"] = valueToString(user->getUserId()); params["{USERKEY}"] = user->getUserKey(); const std::vector<int>* hiddenPosts = user->getHiddenPosts(); std::string hiddenPostsStr = ""; for(auto it = (*hiddenPosts).begin(); it != (*hiddenPosts).end(); ++it) { const int currPost = (*it); hiddenPostsStr += "<span class='settings_links' oncontextmenu='hideClick(/"p"+valueToString(currPost)+"/", true)'><span class='replyToLink reply_to_link'>p" + valueToString(currPost) + "</span></span> ; "; } params["{HIDDENPOSTS}"] = hiddenPostsStr; const std::vector<int>* hiddenThreads = user->getHiddenThreads(); std::string hiddenThreadsStr = ""; for(auto it = (*hiddenThreads).begin(); it != (*hiddenThreads).end(); ++it) { const int currThread = (*it); hiddenThreadsStr += "<span class='settings_links' oncontextmenu='hideClick(/"t"+valueToString(currThread)+"/", true)'><span class='replyToLink reply_to_link'>t" + valueToString(currThread) + "</span></span> ; "; } params["{HIDDENTHREADS}"] = hiddenThreadsStr; const std::vector<int>* favoritePosts = user->getFavoritePosts(); std::string favoritePostsStr = ""; for(auto it = (*favoritePosts).begin(); it != (*favoritePosts).end(); ++it) { const int currPost = (*it); favoritePostsStr += "<span class='settings_links' oncontextmenu='addToFavorite(/"p"+valueToString(currPost)+"/", true)'><span class='replyToLink reply_to_link'>p" + valueToString(currPost) + "</span></span> ; "; } params["{FAVORITEPOSTS}"] = favoritePostsStr; const std::vector<int>* favoriteThreads = user->getFavoriteThreads(); std::string favoriteThreadsStr = ""; for(auto it = (*favoriteThreads).begin(); it != (*favoriteThreads).end(); ++it) { const int currThread = (*it); favoriteThreadsStr += "<span class='settings_links' oncontextmenu='addToFavorite(/"t"+valueToString(currThread)+"/", true)'><span class='replyToLink reply_to_link'>t" + valueToString(currThread) + "</span></span> ; "; } params["{FAVORITETHREADS}"] = favoriteThreadsStr; const std::vector<int>* fixedThreads = user->getFixedThreads(); std::string fixedThreadsStr = ""; for(auto it = (*fixedThreads).begin(); it != (*fixedThreads).end(); ++it) { const int currThread = (*it); fixedThreadsStr += "<span class='settings_links' oncontextmenu='fixThread(/"t"+valueToString(currThread)+"/", true)'><span class='replyToLink reply_to_link'>t" + valueToString(currThread) + "</span></span> ; "; } params["{FIXEDTHREADS}"] = fixedThreadsStr; params["{RE}"] = user->getUserAgeRating() == 0 ? "selected" : ""; params["{RT}"] = user->getUserAgeRating() == 1 ? "selected" : ""; params["{RM}"] = user->getUserAgeRating() == 2 ? "selected" : ""; params["{RA}"] = user->getUserAgeRating() == 3 ? "selected" : ""; tmpString += settingsTemplate->getHTMLData(¶ms); params.clear(); params["{LEFTPANEL}"] = buildLeftPanel(user); params["{UPMENU}"] = buildUpperMenu(user); params["{CONTENT}"] = tmpString; return contentTemplate->getHTMLData(¶ms);}
开发者ID:AntonBogomolov,项目名称:FastImageBoard,代码行数:74,
示例21: valueToStringstd::string valueToString( UInt value ){ return valueToString( LargestUInt(value) );}
开发者ID:43501474,项目名称:QSanguosha,代码行数:4,
示例22: dbRequestvoid CBan::readFromDB(){ CDBManager* dbManager = CManagers::getInstance()->getDBManager(); //std::shared_ptr<CDBRequest> dbRequest(dbManager->createDBRequest()); std::shared_ptr<CDBRequest> dbRequest(dbManager->createDBRequest()); const CDBRequestResult* result = dbRequest->selectRequest(CDBValues("*"), "Bans", "`id` = "+valueToString(id)); if(dbRequest->getIsLastQuerySuccess() && result != NULL && result->getRowsCnt() > 0) { userId = result->getIntValue(0,1); roTime = result->getLongValue(0,2); isAccessClosed = result->getBoolValue(0,3); banCreationTime = result->getLongValue(0,4); }}
开发者ID:AntonBogomolov,项目名称:NovemberLib,代码行数:15,
注:本文中的valueToString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ value_as_address函数代码示例 C++ valueToQuotedString函数代码示例 |