Item AbstractFloatMathematician<isDouble>::calculate(const Item &o1, const Operator op, const Item &o2, const QExplicitlySharedDataPointer<DynamicContext> &context) const { const Numeric *const num1 = o1.template as<Numeric>(); const Numeric *const num2 = o2.template as<Numeric>(); switch(op) { case Div: return toItem(AbstractFloat<isDouble>::fromValue(num1->toDouble() / num2->toDouble())); case IDiv: { if(num1->isNaN() || num2->isNaN()) { context->error(QtXmlPatterns::tr("No operand in an integer division, %1, can be %2.") .arg(formatKeyword("idiv")) .arg(formatData("NaN")), ReportContext::FOAR0002, this); } else if(num1->isInf()) { context->error(QtXmlPatterns::tr("The first operand in an integer division, %1, cannot be infinity (%2).") .arg(formatKeyword("idiv")) .arg(formatData("INF")), ReportContext::FOAR0002, this); } else if(num2->toInteger() == 0) context->error(QtXmlPatterns::tr("The second operand in a division, %1, cannot be zero (%2).") .arg(formatKeyword("idiv")) .arg(formatData("0")), ReportContext::FOAR0001, this); return Integer::fromValue(static_cast<xsInteger>(num1->toDouble() / num2->toDouble())); } case Substract: return toItem(AbstractFloat<isDouble>::fromValue(num1->toDouble() - num2->toDouble())); case Mod: return toItem(AbstractFloat<isDouble>::fromValue(::fmod(num1->toDouble(), num2->toDouble()))); case Multiply: return toItem(AbstractFloat<isDouble>::fromValue(num1->toDouble() * num2->toDouble())); case Add: return toItem(AbstractFloat<isDouble>::fromValue(num1->toDouble() + num2->toDouble())); } Q_ASSERT(false); return Item(); /* GCC unbarfer. */ }
jschar * Statistics::formatJSON(uint64_t timestamp) { StatisticsSerializer ss(StatisticsSerializer::AsJSON); formatData(ss, timestamp); return ss.finishJSString(); }
/* * Encrypt the given Payload, update sender context and output * decryption in ciphermessage. * * ciphermessage pointer output array with size >= payload + MAC_LENGTH * ENC_sender_ctx pointer to the encoding sender context * Payload pointer to the plaintext to send * Plen the length of Payload in bytes max size = MAX_MESSAGE_LENGTH - MAC_LENGTH */ void CCM_encrypt(message_ctx *ciphermessage, ENC_ctx *ENC_sender_ctx, const void *Payloadin, const unsigned int Plen) { const unsigned char *Payload = Payloadin; unsigned char TEMP[((MAX_MESSAGE_LENGTH*2 - MAC_LENGTH-1)/BLOCK_LENGTH + 1 + 2)*BLOCK_LENGTH]; unsigned char MAC[MAC_LENGTH]; unsigned int * temp = (unsigned int *) (ENC_sender_ctx->nonce+2); //increase counter part of Nonce, the counter part is written small endian (ENC_sender_ctx->counter)++; *temp = ENC_sender_ctx->counter; formatData(TEMP, ENC_sender_ctx->nonce ,Payload, Plen); generateMAC(MAC, ENC_sender_ctx->key,TEMP,(Plen-1)/BLOCK_LENGTH + 1 +2); create_cyphered_counter_block(TEMP, ENC_sender_ctx->key, ENC_sender_ctx->nonce, (Plen-1)/BLOCK_LENGTH + 2); XOR(MAC, MAC, TEMP, MAC_LENGTH); XOR(ciphermessage->data, Payload, TEMP+BLOCK_LENGTH, Plen); ciphermessage->seq_number = ENC_sender_ctx->counter; ciphermessage->length = Plen + MAC_LENGTH; memcpy(((unsigned char *) (ciphermessage->data)) + Plen,MAC,MAC_LENGTH); }
jschar * Statistics::formatMessage() { StatisticsSerializer ss(StatisticsSerializer::AsText); formatData(ss, 0); return ss.finishJSString(); }
void CastingPlatform<TSubClass, issueError>::issueCastError(const Item &validationError, const Item &sourceValue, const ReportContext::Ptr &context) const { Q_ASSERT(validationError); Q_ASSERT(context); Q_ASSERT(validationError.isAtomicValue()); Q_ASSERT(validationError.template as<AtomicValue>()->hasError()); const ValidationError::Ptr err(validationError.template as<ValidationError>()); QString msg(err->message()); if(msg.isNull()) { msg = QtXmlPatterns::tr("It's not possible to cast the value %1 of type %2 to %3") .arg(formatData(sourceValue.stringValue())) .arg(formatType(context->namePool(), sourceValue.type())) .arg(formatType(context->namePool(), targetType())); } else { Q_ASSERT(!msg.isEmpty()); msg = QtXmlPatterns::tr("Failure when casting from %1 to %2: %3") .arg(formatType(context->namePool(), sourceValue.type())) .arg(formatType(context->namePool(), targetType())) .arg(msg); } /* If m_errorCode is FORG0001, we assume our sub-classer doesn't have a * special wish about error code, so then we use the error object's code. */ context->error(msg, m_errorCode == ReportContext::FORG0001 ? err->errorCode() : m_errorCode, static_cast<const TSubClass*>(this)); }
/* * Decrypt the given ciphermessage, update receiver context and output * decryption in payload. * * payload pointer to output array with size >= ciphermessage - MAC_LENGTH * payload_size size of the output payload * ENC_receiver_ctx pointer to the encoding receiver context * ciphermessage pointer to the encrypted input message */ void CCM_decrypt(void *payloadin, unsigned int *payload_size, ENC_ctx *ENC_receiver_ctx, const message_ctx *ciphermessage){ unsigned char *payload = payloadin; unsigned char MAC[MAC_LENGTH], MAC_check[MAC_LENGTH]; unsigned char temp[ (1+((MAX_MESSAGE_LENGTH*2 - MAC_LENGTH-1)/BLOCK_LENGTH)+2)*BLOCK_LENGTH]; unsigned char temp_payload[MAX_MESSAGE_LENGTH*2 - MAC_LENGTH]; //check of message is not sended again: if (ENC_receiver_ctx->counter>=ciphermessage->seq_number){ if (PRINT_errors == 1){ printf("\n"); printf("resending of message"); printf("\n \n");}; *payload_size = 0; return; }; if (ciphermessage->length <= MAC_LENGTH){ if (PRINT_errors == 1){ printf("\n"); printf("invalid1\n"); printf("\n \n");}; *payload_size = 0; return; }; // set Nonce counter part to the received counter part (small endian) memcpy(ENC_receiver_ctx->nonce+2, &ciphermessage->seq_number, 4); create_cyphered_counter_block(temp, ENC_receiver_ctx->key, ENC_receiver_ctx->nonce, (ciphermessage->length -MAC_LENGTH-1)/BLOCK_LENGTH + 2); XOR(MAC, ((unsigned char *) (ciphermessage->data)) + ciphermessage->length-MAC_LENGTH,temp, MAC_LENGTH); XOR(temp_payload, ciphermessage->data, temp+BLOCK_LENGTH, ciphermessage->length - MAC_LENGTH); formatData(temp, ENC_receiver_ctx->nonce ,temp_payload, ciphermessage->length - MAC_LENGTH); generateMAC(MAC_check, ENC_receiver_ctx->key,temp,2+(ciphermessage->length - MAC_LENGTH-1)/BLOCK_LENGTH + 1); if (memcmp(MAC, MAC_check, MAC_LENGTH) != 0){ if (PRINT_errors == 1){ printf("\n"); printf("invalid2\n"); printf("\n \n");}; *payload_size = 0; return; }; ENC_receiver_ctx->counter = ciphermessage->seq_number; *payload_size = ciphermessage->length - MAC_LENGTH; memcpy(payload,temp_payload, *payload_size); }
void DataFileExporter::exportDataLine(double timeData, QList <double> dataValues) { /* QList correspond with activeGraphList */ if (_pSettingsModel->writeDuringLog()) { // Use buffering _dataExportBuffer.append(formatData(timeData, dataValues)); if ((QDateTime::currentMSecsSinceEpoch() - lastLogTime) > _cLogBufferTimeout) { flushExportBuffer(); } } }
void Statistics::printStats() { if (fullFormat) { fprintf(fp, "GC(T+%.3fs) %s\n", t(slices[0].start - startupTime) / 1000.0, formatData()); } else { fprintf(fp, "%f %f %f\n", t(gcDuration()), t(phaseTimes[PHASE_MARK]), t(phaseTimes[PHASE_SWEEP])); } fflush(fp); }
void MainWindow::reload(){ cout<<"glv "<<this->path<<" "<<logStart<<" "<<logLength<<endl; cout<<"dir:"<<this->path<<" start:"<<logStart<<" length:"<<logLength<<endl; this->setWindowTitle("glv"+(this->path==""?"":" "+this->path)); QString split = "*********GLV***xiaozhuai***GLV*********"; QString result; QString cmd; cmd= "git"; QStringList argv; argv<<"-C"<<this->path<<"log"<<"--pretty=format:%H*********GLV***xiaozhuai***GLV*********%an*********GLV***xiaozhuai***GLV*********%ae*********GLV***xiaozhuai***GLV*********%ct*********GLV***xiaozhuai***GLV*********%cr*********GLV***xiaozhuai***GLV*********%s"; //s = "(git -C '"+this->path+"' log --pretty=format:'%H %an %ae %d %s %ct %cr' --abbrev-commit) | (awk 'NR>="+QString::number(this->logStart)+"&&NR<="+QString::number(this->logLength+1)+"')"; result = this->runCmd(cmd,argv,this->logStart,this->logLength); formatData(result); render(); }
void Statistics::printStats() { if (fullFormat) { StatisticsSerializer ss(StatisticsSerializer::AsText); formatData(ss, 0); char *msg = ss.finishCString(); if (msg) { fprintf(fp, "GC(T+%.3fs) %s\n", t(slices[0].start - startupTime) / 1000.0, msg); js_free(msg); } } else { fprintf(fp, "%f %f %f\n", t(gcDuration()), t(phaseTimes[PHASE_MARK]), t(phaseTimes[PHASE_SWEEP])); } fflush(fp); }
void Statistics::endSlice() { slices.back().end = PRMJ_Now(); if (JSAccumulateTelemetryDataCallback cb = runtime->telemetryCallback) (*cb)(JS_TELEMETRY_GC_SLICE_MS, t(slices.back().end - slices.back().start)); bool last = runtime->gcIncrementalState == gc::NO_INCREMENTAL; if (last) endGC(); if (GCSliceCallback cb = runtime->gcSliceCallback) { if (last) (*cb)(runtime, GC_CYCLE_END, GCDescription(formatData(), !!compartment)); else (*cb)(runtime, GC_SLICE_END, GCDescription(NULL, !!compartment)); } }
void DataFileExporter::exportDataFile(QString dataFile) { if (_pGraphDataModel->activeCount() != 0) { const QList<double> keyList = _pGraphView->graphTimeData(); QList<QCPDataMap *> dataList; QStringList logData; // Create header logData.append(constructDataHeader(false)); // Create label row logData.append(createLabelRow()); QList<quint16> activeGraphIndexes; _pGraphDataModel->activeGraphIndexList(&activeGraphIndexes); for(qint32 idx = 0; idx < activeGraphIndexes.size(); idx++) { // Save data lists dataList.append(_pGraphDataModel->dataMap(activeGraphIndexes[idx])); } // Add data lines for(qint32 i = 0; i < keyList.size(); i++) { QList<double> dataRowValues; for(qint32 d = 0; d < dataList.size(); d++) { dataRowValues.append(dataList[d]->value(keyList[i]).value); } logData.append(formatData(keyList[i], dataRowValues)); } // Clean file clearFile(dataFile); // Export data writeToFile(dataFile, logData); } }
void AccelTreeBuilder<FromDocument>::attribute(const QXmlName &name, const QStringRef &value) { /* Attributes adds a namespace binding, so lets synthesize one. * * We optimize by checking whether we have a namespace for which a binding would * be generated. Happens relatively rarely. */ if(name.hasPrefix()) namespaceBinding(QXmlName(name.namespaceURI(), 0, name.prefix())); m_document->basicData.append(AccelTree::BasicNodeData(currentDepth(), currentParent(), QXmlNodeModelIndex::Attribute, 0, name)); ++m_preNumber; ++m_size.top(); m_isPreviousAtomic = false; if(name.namespaceURI() == StandardNamespaces::xml && name.localName() == StandardLocalNames::id) { const QString normalized(value.toString().simplified()); if(QXmlUtils::isNCName(normalized)) { const QXmlName::LocalNameCode id = m_namePool->allocateLocalName(normalized); const int oldSize = m_document->m_IDs.count(); m_document->m_IDs.insert(id, currentParent()); /* We don't run the value through m_attributeCompress here, because * the likelyhood of it deing identical to another attribute is * very small. */ m_document->data.insert(m_preNumber, normalized); /** * In the case that we're called for doc-available(), m_context is * null, and we need to flag somehow that we failed to load this * document. */ if(oldSize == m_document->m_IDs.count() && m_context) // TODO { Q_ASSERT(m_context); m_context->error(QtXmlPatterns::tr("An %1-attribute with value %2 has already been declared.") .arg(formatKeyword("xml:id"), formatData(normalized)), FromDocument ? ReportContext::FODC0002 : ReportContext::XQDY0091, this); } } else if(m_context) // TODO { Q_ASSERT(m_context); /* If we're building from an XML Document(e.g, we're fed from QXmlStreamReader, we raise FODC0002, * otherwise XQDY0091. */ m_context->error(QtXmlPatterns::tr("An %1-attribute must have a " "valid %2 as value, which %3 isn't.").arg(formatKeyword("xml:id"), formatType(m_namePool, BuiltinTypes::xsNCName), formatData(value.toString())), FromDocument ? ReportContext::FODC0002 : ReportContext::XQDY0091, this); } } else m_document->data.insert(m_preNumber, *m_attributeCompress.insert(value.toString())); }
DataRetrieval :: DataRetrieval(string file) { vector<string> lines = dataExtraction(file); //particle = new ArrayList<ParticleInformation>(); formatData(lines); }