//*********************************************************** //* Process a node that has the <noteresourceattribute> //*********************************************************** void ImportData::processResourceAttributes(ResourceAttributes &attributes) { bool atEnd = false; while(!atEnd) { if (reader->isStartElement()) { QString name = reader->name().toString().toLower(); if (name == "cameramake") { attributes.cameraMake = textValue().toStdString(); attributes.__isset.cameraMake = true; } if (name == "cameramodel") { attributes.cameraModel = textValue().toStdString(); attributes.__isset.cameraModel =true; } if (name == "filename") { attributes.fileName = textValue().toStdString(); attributes.__isset.fileName = true; } if (name == "recotype") { attributes.recoType = textValue().toStdString(); attributes.__isset.fileName = true; } if (name == "sourceurl") { attributes.sourceURL = textValue().toStdString(); attributes.__isset.sourceURL = true; } if (name == "altitude") { attributes.altitude = doubleValue(); attributes.__isset.altitude = true; } if (name == "longitude") { attributes.longitude = doubleValue(); attributes.__isset.longitude = true; } if (name == "altitude") { attributes.latitude = doubleValue(); attributes.__isset.latitude = true; } if (name == "timestamp") { attributes.timestamp = longValue(); attributes.__isset.timestamp = true; } if (name == "attachment") { attributes.attachment = booleanValue(); attributes.__isset.attachment = true; } if (name == "clientwillindex") { attributes.clientWillIndex = booleanValue(); attributes.__isset.clientWillIndex =true; } } reader->readNext(); QString endName = reader->name().toString().toLower(); if (endName == "noteresourceattribute" && reader->isEndElement()) atEnd = true; } }
void NPVariantData::encode(CoreIPC::ArgumentEncoder* encoder) const { encoder->encode(m_type); switch (type()) { case NPVariantData::Void: case NPVariantData::Null: break; case NPVariantData::Bool: encoder->encode(boolValue()); break; case NPVariantData::Int32: encoder->encode(int32Value()); break; case NPVariantData::Double: encoder->encode(doubleValue()); break; case NPVariantData::String: encoder->encode(stringValue()); break; case NPVariantData::LocalNPObjectID: encoder->encode(localNPObjectIDValue()); break; case NPVariantData::RemoteNPObjectID: encoder->encode(remoteNPObjectIDValue()); break; } }
void NPVariantData::encode(CoreIPC::ArgumentEncoder& encoder) const { encoder << m_type; switch (type()) { case NPVariantData::Void: case NPVariantData::Null: break; case NPVariantData::Bool: encoder << boolValue(); break; case NPVariantData::Int32: encoder << int32Value(); break; case NPVariantData::Double: encoder << doubleValue(); break; case NPVariantData::String: encoder << stringValue(); break; case NPVariantData::LocalNPObjectID: encoder << localNPObjectIDValue(); break; case NPVariantData::RemoteNPObjectID: encoder << remoteNPObjectIDValue(); break; } }
int CMessageHandler::print() { if (callback_) { int messageNumber = currentMessage().externalNumber(); if (currentSource() != "Clp") messageNumber += 1000000; int i; int nDouble = numberDoubleFields(); assert (nDouble <= 10); double vDouble[10]; for (i = 0; i < nDouble; i++) vDouble[i] = doubleValue(i); int nInt = numberIntFields(); assert (nInt <= 10); int vInt[10]; for (i = 0; i < nInt; i++) vInt[i] = intValue(i); int nString = numberStringFields(); assert (nString <= 10); char * vString[10]; for (i = 0; i < nString; i++) { std::string value = stringValue(i); vString[i] = CoinStrdup(value.c_str()); } callback_(model_, messageNumber, nDouble, vDouble, nInt, vInt, nString, vString); for (i = 0; i < nString; i++) free(vString[i]); } return CoinMessageHandler::print(); }
UString JSImmediate::toString(JSValuePtr v) { ASSERT(isImmediate(v)); if (isIntegerNumber(v)) return UString::from(getTruncatedInt32(v)); #if USE(ALTERNATE_JSIMMEDIATE) if (isNumber(v)) { ASSERT(isDoubleNumber(v)); double value = doubleValue(v); if (value == 0.0) // +0.0 or -0.0 return "0"; return UString::from(value); } #else ASSERT(!isNumber(v)); #endif if (jsBoolean(false) == v) return "false"; if (jsBoolean(true) == v) return "true"; if (v.isNull()) return "null"; ASSERT(v.isUndefined()); return "undefined"; }
// computes an interval comprising a pair of doubles // Note: // // This function returns are two consecutive representable binary // IEEE double values whichs contain the real value, but when you print out // them, you might be confused by the decimal represention due to round. // void Expr::doubleInterval(double & lb, double & ub) const { double d = doubleValue(); if (!finite(d)) { // if overflow, underflow or NaN lb = ub = d; return; } int sign = ((* this) -Expr(d)).sign(); // Seems like doubleValue() always give a lower bound, // so sign = 0 or 1 (never -1). //std::cout << "Sign = " << sign << std::endl; if (sign == 0) { lb = ub = d; return; } int exp; frexp(d, & exp); // get the exponent of d exp--; // the exp from frexp satisfies // 2^{exp-1} <= d < 2^{exp} // But, we want exp to satisfy // 2^{exp} <= d < 2^{exp+1} if (sign > 0) { lb = d; ub = d + ldexp(1.0, -52+exp); return; } else { ub = d; lb = d - ldexp(1.0, -52+exp); return; } }
//*********************************************************** //* Process an <attributes> node //*********************************************************** void ImportData::processNoteAttributes(NoteAttributes &attributes) { bool atEnd = false; while(!atEnd) { if (reader->isStartElement()) { QString name = reader->name().toString().toLower(); if (name == "author" && !reader->isEndElement()) { attributes.author = textValue().toStdString(); attributes.__isset.author = true; } if (name == "sourceurl" && !reader->isEndElement()) { attributes.sourceURL = textValue().toStdString(); attributes.__isset.sourceURL = true; } if (name == "source" && !reader->isEndElement()) { attributes.source = textValue().toStdString(); attributes.__isset.source = true; } if (name == "sourceapplication" && !reader->isEndElement()) { attributes.sourceApplication = textValue().toStdString(); attributes.__isset.sourceApplication = true; } if (name == "altitude" && !reader->isEndElement()) { attributes.altitude = doubleValue(); attributes.__isset.altitude = true; } if (name == "longitude" && !reader->isEndElement()) { attributes.longitude = doubleValue(); attributes.__isset.longitude = true; } if (name == "latitude" && !reader->isEndElement()) { attributes.latitude = doubleValue(); attributes.__isset.latitude = true; } if (name == "subjectdate" && !reader->isEndElement()) { attributes.subjectDate = longLongValue(); attributes.__isset.subjectDate = true; } } reader->readNext(); QString endName = reader->name().toString().toLower(); if (endName == "noteattributes" && reader->isEndElement()) atEnd = true; } return; }
void QrAbstractSpinBox::mouseReleaseEvent( QMouseEvent *event) { if( !dragged_) { QrCalculator::Instance().setValue( doubleValue()); connect( &(QrCalculator::Instance()), SIGNAL( valueChanged( double)), this, SLOT( calculatorSetValue( double))); QrCalculator::Instance().show( gpush_x_, gpush_y_); }
Value* ValueKey::materialize(Procedure& proc, Origin origin) const { switch (opcode()) { case FramePointer: return proc.add<Value>(opcode(), type(), origin); case Identity: case Sqrt: case SExt8: case SExt16: case SExt32: case ZExt32: case Clz: case Trunc: case IToD: case IToF: case FloatToDouble: case DoubleToFloat: case Check: return proc.add<Value>(opcode(), type(), origin, child(proc, 0)); case Add: case Sub: case Mul: case ChillDiv: case Mod: case BitAnd: case BitOr: case BitXor: case Shl: case SShr: case ZShr: case Equal: case NotEqual: case LessThan: case GreaterThan: case Above: case Below: case AboveEqual: case BelowEqual: case Div: return proc.add<Value>(opcode(), type(), origin, child(proc, 0), child(proc, 1)); case Select: return proc.add<Value>(opcode(), type(), origin, child(proc, 0), child(proc, 1), child(proc, 2)); case Const32: return proc.add<Const32Value>(origin, static_cast<int32_t>(value())); case Const64: return proc.add<Const64Value>(origin, value()); case ConstDouble: return proc.add<ConstDoubleValue>(origin, doubleValue()); case ConstFloat: return proc.add<ConstFloatValue>(origin, floatValue()); case ArgumentReg: return proc.add<ArgumentRegValue>(origin, Reg::fromIndex(static_cast<unsigned>(value()))); case SlotBase: return proc.add<SlotBaseValue>(origin, proc.stackSlots()[value()]); default: return nullptr; } }
//*********************************************************** //* Process a node that has the <noteresourceattribute> //*********************************************************** void ImportEnex::processResourceAttributes(ResourceAttributes &attributes) { bool atEnd = false; while(!atEnd) { if (reader->isStartElement()) { QString name = reader->name().toString().toLower(); if (name == "camera-make") { attributes.cameraMake = textValue(); } if (name == "camera-model") { attributes.cameraModel = textValue(); } if (name == "file-name") { attributes.fileName = textValue(); } if (name == "reco-type") { attributes.recoType = textValue(); } if (name == "source-url") { attributes.sourceURL = textValue(); } if (name == "altitude") { attributes.altitude = doubleValue(); } if (name == "longitude") { attributes.longitude = doubleValue(); } if (name == "altitude") { attributes.latitude = doubleValue(); } if (name == "timestamp") { attributes.timestamp = longValue(); } if (name == "attachment") { attributes.attachment = booleanValue(); } } reader->readNext(); QString endName = reader->name().toString().toLower(); if (endName == "resource-attributes" && reader->isEndElement()) atEnd = true; } }
void StyleReader::startElementHandler(const char *tag, const char **attributes) { static const std::string BASE = "base"; static const std::string STYLE = "style"; if (BASE == tag) { myCollection.myBaseStyle = new BaseTextStyle(attributeValue(attributes, "family"), intValue(attributes, "fontSize")); } else if (STYLE == tag) { const char *idString = attributeValue(attributes, "id"); const char *name = attributeValue(attributes, "name"); if ((idString != 0) && (name != 0)) { TextKind id = (TextKind)atoi(idString); TextStyleDecoration *decoration; int fontSizeDelta = intValue(attributes, "fontSizeDelta"); Boolean3 bold = b3Value(attributes, "bold"); Boolean3 italic = b3Value(attributes, "italic"); int verticalShift = intValue(attributes, "vShift"); Boolean3 allowHyphenations = b3Value(attributes, "allowHyphenations"); bool isHyperlink = booleanValue(attributes, "isHyperlink"); if (booleanValue(attributes, "partial")) { decoration = new TextStyleDecoration(name, fontSizeDelta, bold, italic, verticalShift, allowHyphenations); } else { int spaceBefore = intValue(attributes, "spaceBefore"); int spaceAfter = intValue(attributes, "spaceAfter"); int leftIndent = intValue(attributes, "leftIndent"); int rightIndent = intValue(attributes, "rightIndent"); int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta"); AlignmentType alignment = ALIGN_UNDEFINED; const char *alignmentString = attributeValue(attributes, "alignment"); if (alignmentString != 0) { if (strcmp(alignmentString, "left") == 0) { alignment = ALIGN_LEFT; } else if (strcmp(alignmentString, "rigth") == 0) { alignment = ALIGN_RIGHT; } else if (strcmp(alignmentString, "center") == 0) { alignment = ALIGN_CENTER; } else if (strcmp(alignmentString, "justify") == 0) { alignment = ALIGN_JUSTIFY; } } double lineSpace = doubleValue(attributes, "lineSpace"); decoration = new FullTextStyleDecoration(name, fontSizeDelta, bold, italic, spaceBefore, spaceAfter, leftIndent, rightIndent, firstLineIndentDelta, verticalShift, alignment, lineSpace, allowHyphenations); } if (isHyperlink) { decoration->setHyperlinkStyle(); } myCollection.myDecorationMap.insert(std::pair<TextKind,TextStyleDecoration*>(id, decoration)); } } }
virtual bool isZero() const { return !doubleValue(); }
bool isZero() const override { return !doubleValue(); }
Number *Reader::parseNumber() { auto numberString = this->accumulateWhile(&is_number); return make<Number>(numberString->doubleValue()); }
TEST(JsonValuesTest, JsonValuesToStringDoubleTest){ double value = 12.34; json_handler::Value<double> doubleValue(value); ASSERT_EQ("12.34", doubleValue.toString()); }
TEST(JsonValuesTest, JsonValuesDoubleTest){ double value = 12.34; json_handler::Value<double> doubleValue(value); ASSERT_EQ(12.34, doubleValue.getValue()); }