本文整理汇总了C++中readValue函数的典型用法代码示例。如果您正苦于以下问题:C++ readValue函数的具体用法?C++ readValue怎么用?C++ readValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InputTemp
WebInputTemp::WebInputTemp(Params &p):
InputTemp(p)
{
ioDoc->friendlyNameSet("WebInputTemp");
ioDoc->descriptionSet(_("Temperature input read from a web document"));
ioDoc->paramAdd("url", _("URL where to download the document from.\n"
"If URL begins with file:// the data is read from the local file"),
IODoc::TYPE_STRING, true);
ioDoc->paramAdd("file_type",_("File type of the document. Values can be xml, json or text."),
IODoc::TYPE_STRING, true);
ioDoc->paramAdd("path",_("The path where to found the value. This value can take multiple values "
"depending on the file type. If file_type is JSON, the json file "
"downloaded will be read, and the informations will be extracted from "
"the path. for example weather[0]/description, try to read the "
"description value of the 1 element of the array of the weather object.\n"
"If file_type is XML, the path is an xpath expression; Look here for "
"syntax : http://www.w3schools.com/xsl/xpath_syntax.asp "
"If file_type is TEXT, the downloaded file is returned as "
"plain text file, and path must be in the form line/pos/separator "
"Line is read, and is split using separator as delimiters "
"The value returned is the value at pos in the split list. "
"If the separator is not found, the whole line is returned. "
"Example the file contains \n"
"10.0,10.1,10.2,10.3\n"
"20.0,20.1,20.2,20.3\n"
"If the path is 2/4/, the value returne wil be 20.3\n"),
IODoc::TYPE_STRING, true);
cInfoDom("input") << "WebInputTemp::WebInputTemp()";
Calaos::StartReadRules::Instance().addIO();
// Add input to WebCtrl instance
WebCtrl::Instance(p).Add(get_param("path"), readTime, [=]()
{
readValue();
Calaos::StartReadRules::Instance().ioRead();
});
}
示例2: pthread_mutex_lock
int IioSensorBase::readEvents(sensors_event_t* data, int count)
{
if (count < 1)
return -EINVAL;
pthread_mutex_lock(&mLock);
int numEventReceived = 0;
if (mHasPendingEvent) {
mHasPendingEvent = false;
if (mEnabled) {
mPendingEvent.timestamp = getTimestamp();
*data = mPendingEvent;
numEventReceived++;
}
goto done;
}
iio_event_data const* event;
while (count && mInputReader.readEvent(mDataFd, &event)) {
int value;
if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event->id) == mIioChanType) {
if (mEnabled && readValue(&value)) {
handleData(value);
mPendingEvent.timestamp = event->timestamp;
*data++ = mPendingEvent;
count--;
numEventReceived++;
}
}
mInputReader.next();
}
done:
pthread_mutex_unlock(&mLock);
return numEventReceived;
}
示例3: in
EnumMap<OptionId, Options::Value> Options::readValues() {
EnumMap<OptionId, Value> ret = defaults;
ifstream in(filename);
while (1) {
char buf[100];
in.getline(buf, 100);
if (!in)
break;
vector<string> p = split(string(buf), {','});
if (p.empty())
continue;
if (p.size() == 1)
p.push_back("");
OptionId optionId;
if (auto id = EnumInfo<OptionId>::fromStringSafe(p[0]))
optionId = *id;
else
continue;
if (auto val = readValue(optionId, p[1]))
ret[optionId] = *val;
}
return ret;
}
示例4: init
bool Reader::readArray(Token& tokenStart) {
Value init(arrayValue);
currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_);
skipSpaces();
if (*current_ == ']') // empty array
{
Token endArray;
readToken(endArray);
return true;
}
int index = 0;
for (;;) {
Value& value = currentValue()[index++];
nodes_.push(&value);
bool ok = readValue();
nodes_.pop();
if (!ok) // error already set
return recoverFromError(tokenArrayEnd);
Token token;
// Accept Comment after last item in the array.
ok = readToken(token);
while (token.type_ == tokenComment && ok) {
ok = readToken(token);
}
bool badTokenType =
(token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
if (!ok || badTokenType) {
return addErrorAndRecover(
"Missing ',' or ']' in array declaration", token, tokenArrayEnd);
}
if (token.type_ == tokenArrayEnd)
break;
}
return true;
}
示例5: parseStructure
bool parseStructure(VLXStructure* st)
{
std::string str;
// tag
if (!readString(str))
return false;
st->setTag(str.c_str());
// ID
if (!readString(str))
return false;
st->setID(str.c_str());
// read key/value count
long long count = 0;
if (!readInteger(count))
return false;
// values
for(int i=0; i<count; ++i)
{
VLXStructure::Value val;
// key
if (!readString(str))
return false;
val.setKey(str.c_str());
// value
if (!readValue(val.value()))
return false;
st->value().push_back(val);
}
return true;
}
示例6: Hash
Hash* Parser::readHash()
{
Tokenizer::TokenType tok = tokenizer->nextToken();
if (tok != Tokenizer::TokenBeginGroup)
{
tokenizer->pushBack();
return NULL;
}
Hash* hash = new Hash();
tok = tokenizer->nextToken();
while (tok != Tokenizer::TokenEndGroup)
{
if (tok != Tokenizer::TokenName)
{
tokenizer->pushBack();
delete hash;
return NULL;
}
string name = tokenizer->getNameValue();
Value* value = readValue();
if (value == NULL)
{
delete hash;
return NULL;
}
hash->addValue(name, *value);
tok = tokenizer->nextToken();
}
return hash;
}
示例7: QgsDebugMsg
void * QgsRasterNuller::readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
{
QgsDebugMsg( "Entered" );
if ( !mInput ) return 0;
//QgsRasterDataProvider *provider = dynamic_cast<QgsRasterDataProvider*>( mInput->srcInput() );
void * rasterData = mInput->block( bandNo, extent, width, height );
QgsRasterInterface::DataType dataType = mInput->dataType( bandNo );
int pixelSize = mInput->typeSize( dataType ) / 8;
double noDataValue = mInput->noDataValue ( bandNo );
for ( int i = 0; i < height; ++i )
{
for ( int j = 0; j < width; ++j )
{
int index = pixelSize * ( i * width + j );
double value = readValue( rasterData, dataType, index );
foreach ( NoData noData, mNoData )
{
if ( ( value >= noData.min && value <= noData.max ) ||
doubleNear( value, noData.min ) ||
doubleNear( value, noData.max ) )
{
writeValue( rasterData, dataType, index, noDataValue );
}
}
}
}
return rasterData;
}
示例8: while
void ConfigXml::readEntryElement(int *id)
{
QString type = reader.attributes().value("type").toString();
reader.readNext();
while (!reader.atEnd()) {
if (reader.isEndElement()) {
reader.readNext();
break;
}
if (reader.isStartElement()) {
if (reader.name() == "entry") {
readEntryElement(id);
} else if (reader.name() == "value") {
readValue(id, type);
} else {
skipUnknownElement();
}
} else {
reader.readNext();
}
}
}
示例9: readInstructionFromBuffer
size_t readInstructionFromBuffer(const char* buf, Instruction* instr)
{
size_t nRead = 0;
instr->iType = *buf;
buf += 2; nRead += 2;
int nCol = instr->table->nCol;
if (instr->iType == SQLITE_UPDATE) {
nCol *= 2;
}
for (int i=0; i < nCol; i++) {
sqlite_value* val_p = instr->values + i;
size_t read = readValue(buf, val_p);
if (read == 0) {
return 0;
}
buf += read;
nRead += read;
}
return nRead;
}
示例10: while
void VCalParser::readEvent()
{
//qDebug() << "[calendar] reading event";
//QTime time;
QString key, val;
TEvent event;
//time.start();
while( key != "END" && !atEnd ) {
key = readKey();
val = readValue();
if( key == "UID" ) event.setUid(val);
else if( key == "DESCRIPTION") event.setDescription(val);
else if( key == "SUMMARY") event.setSummary(val);
else if( key == "LOCATION") event.setLocation(val);
else if( key == "LAST-MODIFIED")event.setLastModified(decodeDate(val));
else if( key == "CLASS") event.setClass(val);
else if( key == "STATUS") event.setStatus(val);
else if( key == "DTSTART" ||
key == "DTSTART;VALUE=DATE") {
if( val.size() > 1 ) event.setStart(decodeDate(val));
} else if( key == "DTEND" ||
key == "DTEND;VALUE=DATE") {
if( val.size() > 1 ) event.setEnd(decodeDate(val));
}
// event is in the future
if(event.getStart() > QDateTime::currentDateTime()) {
if(event < nextEvent) nextEvent = event;
}
}
m_events.append(event);
}
示例11: while
bool
Reader::parse( const char *beginDoc, const char *endDoc,
Value &root,
bool collectComments )
{
begin_ = beginDoc;
end_ = endDoc;
collectComments_ = collectComments;
current_ = begin_;
lastValueEnd_ = 0;
lastValue_ = 0;
commentsBefore_ = "";
errors_.clear();
while ( !nodes_.empty() )
nodes_.pop();
nodes_.push( &root );
bool successful = readValue();
Token token;
skipCommentTokens( token );
if ( collectComments_ && !commentsBefore_.empty() )
root.setComment( commentsBefore_, commentAfter );
return successful;
}
示例12: isDeviceProperty
void MtpProperty::read(MtpDataPacket& packet) {
mCode = packet.getUInt16();
bool deviceProp = isDeviceProperty();
mType = packet.getUInt16();
mWriteable = (packet.getUInt8() == 1);
switch (mType) {
case MTP_TYPE_AINT8:
case MTP_TYPE_AUINT8:
case MTP_TYPE_AINT16:
case MTP_TYPE_AUINT16:
case MTP_TYPE_AINT32:
case MTP_TYPE_AUINT32:
case MTP_TYPE_AINT64:
case MTP_TYPE_AUINT64:
case MTP_TYPE_AINT128:
case MTP_TYPE_AUINT128:
mDefaultArrayValues = readArrayValues(packet, mDefaultArrayLength);
if (deviceProp)
mCurrentArrayValues = readArrayValues(packet, mCurrentArrayLength);
break;
default:
readValue(packet, mDefaultValue);
if (deviceProp)
readValue(packet, mCurrentValue);
}
if (!deviceProp)
mGroupCode = packet.getUInt32();
mFormFlag = packet.getUInt8();
if (mFormFlag == kFormRange) {
readValue(packet, mMinimumValue);
readValue(packet, mMaximumValue);
readValue(packet, mStepSize);
} else if (mFormFlag == kFormEnum) {
mEnumLength = packet.getUInt16();
mEnumValues = new MtpPropertyValue[mEnumLength];
for (int i = 0; i < mEnumLength; i++)
readValue(packet, mEnumValues[i]);
}
}
示例13: readValue
bool
SimpleProperties::Reader::next(){
return readValue();
}
示例14: readValue
int TestMain::readValue2(const int ver)
{
const int def = readValue(ver, 0);
log->log("value for %d = %d", ver, def);
return def;
}
示例15: main
int main(int argc, char *argv[])
{
char mdesc[2][MAXLEN] = {"#Motordescription (text)",""};
char pdesc[2][MAXLEN] = {"#Propellerdescription (text)",""};
char psdesc[2][MAXLEN] = {"#size [in] (eg. 8x4)",""};
char wbdesc[2][MAXLEN] = {"#weight battery [kg]",""};
char wrvdesc[2][MAXLEN] = {"#weight receiver + voltmeter [kg]",""};
char wmspdesc[2][MAXLEN] = {"#weight motor + speedcontroller + propeller [kg]",""};
char wcdesc[2][MAXLEN] = {"#weight camera [kg]",""};
char wfdesc[2][MAXLEN] = {"#weight fuselage (center piece) [kg]",""};
char wadesc[2][MAXLEN] = {"#weight arms [kg]",""};
char wtdesc[2][MAXLEN] = {"#weight tilt mechanism + servo [kg]",""};
char again[MAXLEN];
double bsize;
double I;
double m[7];
double mges;
int n;
int nmax;
if (argc < 2) {
fprintf(stderr, "Fehlender Dateiname! Aufruf des Programms:\ncopter.exe data.txt\n");
exit(1);
}
readFile(argv[1], mdesc[0], mdesc[1]);
readFile(argv[1], pdesc[0], pdesc[1]);
readFile(argv[1], psdesc[0], psdesc[1]);
readFile(argv[1], wbdesc[0], wbdesc[1]);
m[0] = readValue(wbdesc[1]);
readFile(argv[1], wrvdesc[0], wrvdesc[1]);
m[1] = readValue(wrvdesc[1]);
readFile(argv[1], wmspdesc[0], wmspdesc[1]);
m[2] = readValue(wmspdesc[1]);
readFile(argv[1], wcdesc[0], wcdesc[1]);
m[3] = readValue(wcdesc[1]);
readFile(argv[1], wfdesc[0], wfdesc[1]);
m[4] = readValue(wfdesc[1]);
readFile(argv[1], wadesc[0], wadesc[1]);
m[5] = readValue(wadesc[1]);
readFile(argv[1], wtdesc[0], wtdesc[1]);
m[6] = readValue(wtdesc[1]);
while(1) {
nmax = scanInt("\nMaximale Motorenanzahl: ");
bsize = scanDouble("Akkukapazitaet [mAh]:");
printf("\n");
printf("Anzahl | I(ges) | m(ges) | Schwebeflugdauer\n");
printf("-------------------------------------------\n");
for ( n = 1; n <= nmax; n++ ) {
if ( (n % 2) != 0) {
mges = m[0] + m[1] + n * (m[2] + m[5]) + m[3] + m[4] + 1 * m[6];
}
else {
mges = m[0] + m[1] + n * (m[2] + m[5]) + m[3] + m[4] + 0 * m[6];
}
I = copter_funktion(1,argv[1], mges/n);
printf("%6d |%6.1lfA |%6.0lfg |\t%5.1lfmin\n", n, I*n, mges*1000, ((0.8 * (bsize / 1000)) / (I*n) ) * 60 );
};
scanString("\nNochmal? (j/n) : ", again, MAXLEN);
if (strcasecmp(again, "n") == 0)
exit(1);
}
return 0;
}