StatusWith<std::tuple<bool, std::string>> SASLPlainServerMechanism::stepImpl( OperationContext* opCtx, StringData inputData) { if (_authenticationDatabase == "$external") { return Status(ErrorCodes::AuthenticationFailed, "PLAIN mechanism must be used with internal users"); } AuthorizationManager* authManager = AuthorizationManager::get(opCtx->getServiceContext()); // Expecting user input on the form: [authz-id]\0authn-id\0pwd std::string input = inputData.toString(); SecureAllocatorAuthDomain::SecureString pwd = ""; try { size_t firstNull = inputData.find('\0'); if (firstNull == std::string::npos) { return Status( ErrorCodes::AuthenticationFailed, str::stream() << "Incorrectly formatted PLAIN client message, missing first NULL delimiter"); } size_t secondNull = inputData.find('\0', firstNull + 1); if (secondNull == std::string::npos) { return Status( ErrorCodes::AuthenticationFailed, str::stream() << "Incorrectly formatted PLAIN client message, missing second NULL delimiter"); } std::string authorizationIdentity = input.substr(0, firstNull); ServerMechanismBase::_principalName = input.substr(firstNull + 1, (secondNull - firstNull) - 1); if (ServerMechanismBase::_principalName.empty()) { return Status(ErrorCodes::AuthenticationFailed, str::stream() << "Incorrectly formatted PLAIN client message, empty username"); } else if (!authorizationIdentity.empty() && authorizationIdentity != ServerMechanismBase::_principalName) { return Status(ErrorCodes::AuthenticationFailed, str::stream() << "SASL authorization identity must match authentication identity"); } pwd = SecureAllocatorAuthDomain::SecureString(input.substr(secondNull + 1).c_str()); if (pwd->empty()) { return Status(ErrorCodes::AuthenticationFailed, str::stream() << "Incorrectly formatted PLAIN client message, empty password"); } } catch (std::out_of_range&) { return Status(ErrorCodes::AuthenticationFailed, str::stream() << "Incorrectly formatted PLAIN client message"); } // The authentication database is also the source database for the user. auto swUser = authManager->acquireUser( opCtx, UserName(ServerMechanismBase::_principalName, _authenticationDatabase)); if (!swUser.isOK()) { return swUser.getStatus(); } auto userObj = std::move(swUser.getValue()); const auto creds = userObj->getCredentials(); const auto sha256Status = trySCRAM<SHA256Block>(creds, pwd->c_str()); if (!sha256Status.isOK()) { return sha256Status.getStatus(); } if (sha256Status.getValue()) { return std::make_tuple(true, std::string()); } const auto authDigest = createPasswordDigest(ServerMechanismBase::_principalName, pwd->c_str()); const auto sha1Status = trySCRAM<SHA1Block>(creds, authDigest); if (!sha1Status.isOK()) { return sha1Status.getStatus(); } if (sha1Status.getValue()) { return std::make_tuple(true, std::string()); } return Status(ErrorCodes::AuthenticationFailed, str::stream() << "No credentials available."); return std::make_tuple(true, std::string()); }
bool CGUISpinBox::OnEvent(const SEvent& event) { if (IsEnabled) { bool changeEvent = false; bool eatEvent = false; switch(event.EventType) { case EET_MOUSE_INPUT_EVENT: switch(event.MouseInput.Event) { case EMIE_MOUSE_WHEEL: { f32 val = getValue() + (StepSize * (event.MouseInput.Wheel < 0 ? -1.f : 1.f)); setValue(val); changeEvent = true; eatEvent = true; } break; default: break; } break; case EET_GUI_EVENT: if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) { if (event.GUIEvent.Caller == ButtonSpinUp) { f32 val = getValue(); val += StepSize; setValue(val); changeEvent = true; } else if ( event.GUIEvent.Caller == ButtonSpinDown) { f32 val = getValue(); val -= StepSize; setValue(val); changeEvent = true; } } if (event.GUIEvent.Caller == EditBox) { if ( (event.GUIEvent.EventType == EGET_EDITBOX_CHANGED && ValidateOn & EGUI_SBV_CHANGE) || (event.GUIEvent.EventType == EGET_EDITBOX_ENTER && ValidateOn & EGUI_SBV_ENTER) || (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST && ValidateOn & EGUI_SBV_LOSE_FOCUS) ) { verifyValueRange(); changeEvent = true; } } break; default: break; } if ( changeEvent ) { SEvent e; e.EventType = EET_GUI_EVENT; e.GUIEvent.Caller = this; e.GUIEvent.Element = 0; e.GUIEvent.EventType = EGET_SPINBOX_CHANGED; if ( Parent ) Parent->OnEvent(e); if ( eatEvent ) return true; } } return IGUIElement::OnEvent(event); }
int main(int argc, char **argv) { int g,rep,i,addr=-1, page=4, type = -1; unsigned char bytes[0x10000]; char byte; char *arg; int offset = 0x4000; int size = 0x4000; FILE *fp = 0; int idx = 0, rw = -1, length = -1; i = 0; char *v; // Set up gpi pointer for direct register access setup_io(); MSX_SET_OUTPUT(MSX_A0_PIN); MSX_SET_OUTPUT(MSX_A1_PIN); MSX_SET_OUTPUT(MSX_CS_PIN); MSX_SET_OUTPUT(MSX_CLK_PIN); MSX_SET_OUTPUT(MSX_W_PIN); GPIO_SET = MSX_CS | MSX_CLK | MSX_W; while (argc > ++idx) { arg = argv[idx]; if (type == -1) { switch (*arg) { case 'i': type = IO; if (*(arg+1) == 'w') rw = WRITE; else rw = READ; continue; case 'm': type = MEM; if (*(arg+1) == 'w') rw = WRITE; else rw = READ; continue; case 'w': type = MEM; rw = WRITE; continue; default: type = MEM; rw = READ; } } if (addr == -1) { addr = getValue(arg); continue; } if (rw == WRITE && bytes[i] == -1) { bytes[i++] = getValue(arg); continue; } if (rw == READ && length == -1) { length = getValue(arg); continue; } } if (i > 0) length = i; if (addr < 0) addr = 0; if (length < 0) length = 1; //printf("Type:%s,RW:%s, addr=0x%04x, size=%d\n", type ? "IO" : "MEM", rw ? "WRITE" : "READ", addr, length); //clock_ena(1, 2*7); if (type == MEM) { if (rw == READ) { for(i = 0; i < length; i++) { byte = msxread(addr+i); printf("0x%04x > 0x%02x\n", addr+i, byte); } } else { for(i = 0; i < length; i++) { msxwrite(addr, bytes[i]); printf("0x%04x < 0x%02x\n", addr+i, bytes[i]); } } } else { addr = addr & 0xff; if (rw == READ) { for(i = 0; i < length; i++) { byte = msxinp(addr+i); printf("IO0x%02x > 0x%02x\n", addr+i, byte); } } else { for(i = 0; i < length; i++) { msxout(addr, bytes[i]); printf("IO0x%02x < 0x%02x\n", addr+i, bytes[i]); } } } clear_io(); return 0; } // main
/** * Runs a query using the following steps: * 1) Parsing. * 2) Acquire locks. * 3) Plan query, obtaining an executor that can run it. * 4) Setup a cursor for the query, which may be used on subsequent getMores. * 5) Generate the first batch. * 6) Save state for getMore. * 7) Generate response to send to the client. */ bool run(OperationContext* txn, const std::string& dbname, BSONObj& cmdObj, int options, std::string& errmsg, BSONObjBuilder& result) override { const std::string fullns = parseNs(dbname, cmdObj); const NamespaceString nss(fullns); if (!nss.isValid() || nss.isCommand() || nss.isSpecialCommand()) { return appendCommandStatus(result, {ErrorCodes::InvalidNamespace, str::stream() << "Invalid collection name: " << nss.ns()}); } // Although it is a command, a find command gets counted as a query. globalOpCounters.gotQuery(); if (txn->getClient()->isInDirectClient()) { return appendCommandStatus( result, Status(ErrorCodes::IllegalOperation, "Cannot run find command from eval()")); } // 1a) Parse the command BSON to a LiteParsedQuery. const bool isExplain = false; auto lpqStatus = LiteParsedQuery::makeFromFindCommand(nss, cmdObj, isExplain); if (!lpqStatus.isOK()) { return appendCommandStatus(result, lpqStatus.getStatus()); } auto& lpq = lpqStatus.getValue(); // Validate term, if provided. if (auto term = lpq->getReplicationTerm()) { auto replCoord = repl::ReplicationCoordinator::get(txn); Status status = replCoord->updateTerm(*term); // Note: updateTerm returns ok if term stayed the same. if (!status.isOK()) { return appendCommandStatus(result, status); } } // Fill out curop information. // // We pass negative values for 'ntoreturn' and 'ntoskip' to indicate that these values // should be omitted from the log line. Limit and skip information is already present in the // find command parameters, so these fields are redundant. const int ntoreturn = -1; const int ntoskip = -1; beginQueryOp(txn, nss, cmdObj, ntoreturn, ntoskip); // 1b) Finish the parsing step by using the LiteParsedQuery to create a CanonicalQuery. WhereCallbackReal whereCallback(txn, nss.db()); auto statusWithCQ = CanonicalQuery::canonicalize(lpq.release(), whereCallback); if (!statusWithCQ.isOK()) { return appendCommandStatus(result, statusWithCQ.getStatus()); } std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue()); ShardingState* const shardingState = ShardingState::get(txn); if (OperationShardVersion::get(txn).hasShardVersion() && shardingState->enabled()) { ChunkVersion receivedVersion = OperationShardVersion::get(txn).getShardVersion(nss); ChunkVersion latestVersion; // Wait for migration completion to get the correct chunk version. const int maxTimeoutSec = 30; int timeoutSec = cq->getParsed().getMaxTimeMS() / 1000; if (!timeoutSec || timeoutSec > maxTimeoutSec) { timeoutSec = maxTimeoutSec; } if (!shardingState->waitTillNotInCriticalSection(timeoutSec)) { uasserted(ErrorCodes::LockTimeout, "Timeout while waiting for migration commit"); } // If the received version is newer than the version cached in 'shardingState', then we // have to refresh 'shardingState' from the config servers. We do this before acquiring // locks so that we don't hold locks while waiting on the network. uassertStatusOK(shardingState->refreshMetadataIfNeeded( txn, nss.ns(), receivedVersion, &latestVersion)); } // 2) Acquire locks. AutoGetCollectionForRead ctx(txn, nss); Collection* collection = ctx.getCollection(); const int dbProfilingLevel = ctx.getDb() ? ctx.getDb()->getProfilingLevel() : serverGlobalParams.defaultProfile; // It is possible that the sharding version will change during yield while we are // retrieving a plan executor. If this happens we will throw an error and mongos will // retry. const ChunkVersion shardingVersionAtStart = shardingState->getVersion(nss.ns()); // 3) Get the execution plan for the query. auto statusWithPlanExecutor = getExecutorFind(txn, collection, nss, std::move(cq), PlanExecutor::YIELD_AUTO); if (!statusWithPlanExecutor.isOK()) { return appendCommandStatus(result, statusWithPlanExecutor.getStatus()); } std::unique_ptr<PlanExecutor> exec = std::move(statusWithPlanExecutor.getValue()); // TODO: Currently, chunk ranges are kept around until all ClientCursors created while // the chunk belonged on this node are gone. Separating chunk lifetime management from // ClientCursor should allow this check to go away. if (!shardingState->getVersion(nss.ns()).isWriteCompatibleWith(shardingVersionAtStart)) { // Version changed while retrieving a PlanExecutor. Terminate the operation, // signaling that mongos should retry. throw SendStaleConfigException(nss.ns(), "version changed during find command", shardingVersionAtStart, shardingState->getVersion(nss.ns())); } if (!collection) { // No collection. Just fill out curop indicating that there were zero results and // there is no ClientCursor id, and then return. const long long numResults = 0; const CursorId cursorId = 0; endQueryOp(txn, collection, *exec, dbProfilingLevel, numResults, cursorId); appendCursorResponseObject(cursorId, nss.ns(), BSONArray(), &result); return true; } const LiteParsedQuery& pq = exec->getCanonicalQuery()->getParsed(); // 4) If possible, register the execution plan inside a ClientCursor, and pin that // cursor. In this case, ownership of the PlanExecutor is transferred to the // ClientCursor, and 'exec' becomes null. // // First unregister the PlanExecutor so it can be re-registered with ClientCursor. exec->deregisterExec(); // Create a ClientCursor containing this plan executor. We don't have to worry // about leaking it as it's inserted into a global map by its ctor. ClientCursor* cursor = new ClientCursor(collection->getCursorManager(), exec.release(), nss.ns(), txn->recoveryUnit()->isReadingFromMajorityCommittedSnapshot(), pq.getOptions(), pq.getFilter()); CursorId cursorId = cursor->cursorid(); ClientCursorPin ccPin(collection->getCursorManager(), cursorId); // On early return, get rid of the the cursor. ScopeGuard cursorFreer = MakeGuard(&ClientCursorPin::deleteUnderlying, ccPin); invariant(!exec); PlanExecutor* cursorExec = cursor->getExecutor(); // 5) Stream query results, adding them to a BSONArray as we go. BSONArrayBuilder firstBatch; BSONObj obj; PlanExecutor::ExecState state = PlanExecutor::ADVANCED; long long numResults = 0; while (!FindCommon::enoughForFirstBatch(pq, numResults, firstBatch.len()) && PlanExecutor::ADVANCED == (state = cursorExec->getNext(&obj, NULL))) { // If adding this object will cause us to exceed the BSON size limit, then we stash // it for later. if (firstBatch.len() + obj.objsize() > BSONObjMaxUserSize && numResults > 0) { cursorExec->enqueue(obj); break; } // Add result to output buffer. firstBatch.append(obj); numResults++; } // Throw an assertion if query execution fails for any reason. if (PlanExecutor::FAILURE == state || PlanExecutor::DEAD == state) { const std::unique_ptr<PlanStageStats> stats(cursorExec->getStats()); error() << "Plan executor error during find command: " << PlanExecutor::statestr(state) << ", stats: " << Explain::statsToBSON(*stats); return appendCommandStatus(result, Status(ErrorCodes::OperationFailed, str::stream() << "Executor error during find command: " << WorkingSetCommon::toStatusString(obj))); } // 6) Set up the cursor for getMore. if (shouldSaveCursor(txn, collection, state, cursorExec)) { // State will be restored on getMore. cursorExec->saveState(); cursorExec->detachFromOperationContext(); cursor->setLeftoverMaxTimeMicros(CurOp::get(txn)->getRemainingMaxTimeMicros()); cursor->setPos(numResults); } else { cursorId = 0; } // Fill out curop based on the results. endQueryOp(txn, collection, *cursorExec, dbProfilingLevel, numResults, cursorId); // 7) Generate the response object to send to the client. appendCursorResponseObject(cursorId, nss.ns(), firstBatch.arr(), &result); if (cursorId) { cursorFreer.Dismiss(); } return true; }
bool CharBuffer::strEqual(const char *buf_str, const char *str) const { return (!strcmp(getValue(buf_str),str)); }
/** * Returns the unique device ID if the Id property was included in the required * list of properties when the Provider was constructed. */ string Match::getDeviceId() { return getValue("Id"); }
/** * Returns a string representation of the value associated with the required * property name. If the property name is not valid an empty string is * returned.If the property relates to a list with more than one value then * values are separated by | characters. * @param propertyName string containing the property name * @returns a string representation of the value for the property */ string Match::getValue(const string &propertyName) { return getValue(propertyName.c_str()); }
char Solver::getValueAsChar(std::string key) { return getValue(key).convert<char>(); }
unsigned char Solver::getValueAsUChar(std::string key) { return getValue(key).convert<unsigned char>(); }
float Solver::getValueAsFloat(std::string key) { return getValue(key).convert<float>(); }
double Solver::getValueAsDouble(std::string key) { return getValue(key).convert<double>(); }
unsigned long Solver::getValueAsULong(std::string key) { return getValue(key).convert<unsigned long>(); }
unsigned int Solver::getValueAsUInt(std::string key) { return getValue(key).convert<unsigned int>(); }
//---------------------------------------------------- void ofxSimpleSlider::draw() { ofPushStyle(); ofEnableAlphaBlending(); ofDisableSmoothing(); ofPushMatrix(); ofTranslate(x, y, 0); // Use different alphas if we're actively maniupulating me. float sliderAlpha = (bHasFocus) ? 128 : 64; float spineAlpha = (bHasFocus) ? 192 : 128; float thumbAlpha = (bHasFocus) ? 255 : 160; // draw box outline ofNoFill(); ofSetLineWidth(1.0); ofSetColor(164, 164, 164, sliderAlpha); ofRect(0, 0, width, height); // draw spine ofSetLineWidth(1.0); ofSetColor(205, 205, 205, spineAlpha); if (bVertical) { ofLine(width / 2, 0, width / 2, height); } else { ofLine(0, height / 2, width, height / 2); } // draw thumb ofSetLineWidth(5.0); ofSetColor(250,250, 250, thumbAlpha); if (bVertical) { float thumbY = ofMap(percent, 0, 1, height, 0, true); ofLine(0, thumbY, width, thumbY); } else { float thumbX = ofMap(percent, 0, 1, 0, width, true); ofLine(thumbX, 0, thumbX, height); } // draw numeric value if (bHasFocus) { ofSetColor(255); } else { ofSetColor(128); } if (bVertical) { ofDrawBitmapString(ofToString(getValue(), numberDisplayPrecision), width + 5, height); } else { ofDrawBitmapString(ofToString(getValue(), numberDisplayPrecision), width + 5, height / 2 + 4); //DRAW ABOVE USE TYPE float labelStringWidth = labelString.size(); //ofDrawBitmapString( labelString, 0-labelStringWidth*8-5, height/2 + 4); ofDrawBitmapString(labelString, 0, height + 10); } ofPopMatrix(); ofPopStyle(); }
LLSD LLRadioGroup::getSelectedValue() { return getValue(); }
std::string Solver::getValueAsString(std::string key) { return getValue(key).convert<std::string>(); }
void Calculator::solve() { setProposition::iterator it; it = charSet.begin(); while (it != charSet.end()) { cout << *it << '\t'; it++; } cout << formula; puts(""); int sum = pow(2, propositionNumber)-1; for (int i = 0; i <= sum; i++) { values.clear(); it = charSet.begin(); int table = i; while (it != charSet.end()) { values[*it] = table % 2; cout << values[*it] << '\t'; table >>= 1; it++; } cout << getValue(); puts(""); if (getValue()) { DNF = DNF + '('; it = charSet.begin(); while (it != charSet.end()) { if (values[*it]) { DNF = DNF + *it + '&'; } else { DNF = DNF + '!' + *it + '&'; } it++; } DNF[DNF.size() - 1] = ')'; DNF = DNF + '|'; } else { CNF = CNF + '('; it = charSet.begin(); while (it != charSet.end()) { if (values[*it]) { CNF = CNF+ '!' + *it + '|'; } else { CNF = CNF + *it + '|'; } it++; } CNF[CNF.size() - 1] = ')'; CNF = CNF + '&'; } } CNF = CNF.substr(0, CNF.size() - 1); DNF = DNF.substr(0, DNF.size() - 1); }
bool Solver::getValueAsBool(std::string key) { return getValue(key).convert<bool>(); }
/** * Returns a string representation of the value associated with the required * property name. If the property name is not valid an empty string is * returned.If the property relates to a list with more than one value then * values are separated by | characters. * @param propertyName pointer to a string containing the property name * @returns a string representation of the value for the property */ string Match::getValue(const char* propertyName) { return getValue( fiftyoneDegreesGetRequiredPropertyIndex( offsets->active->dataSet, propertyName)); }
const Variant::TypeId Solver::getType(std::string key) { return getValue(key).type(); }
void print(llvm::raw_ostream& out) { out << "\n\nCodeGen:\n"; //llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences; out << " WeakRefReferences (llvm::SmallPtrSet<llvm::GlobalValue*, 10>) @"; out << " " << &Builder->WeakRefReferences << "\n"; for(auto I = Builder->WeakRefReferences.begin(), E = Builder->WeakRefReferences.end(); I != E; ++I) { (*I)->print(out); out << "\n"; } //llvm::StringMap<GlobalDecl> DeferredDecls; out << " DeferredDecls (llvm::StringMap<GlobalDecl>) @ "; out << &Builder->DeferredDecls << "\n"; for(auto I = Builder->DeferredDecls.begin(), E = Builder->DeferredDecls.end(); I != E; ++I) { out << I->first.str().c_str(); I->second.getDecl()->print(out); out << "\n"; } //std::vector<DeferredGlobal> DeferredDeclsToEmit; out << " DeferredDeclsToEmit (std::vector<DeferredGlobal>) @ "; out << &Builder->DeferredDeclsToEmit << "\n"; for(auto I = Builder->DeferredDeclsToEmit.begin(), E = Builder->DeferredDeclsToEmit.end(); I != E; ++I) { I->GD.getDecl()->print(out); I->GV->print(out); out << "\n"; } //std::vector<GlobalDecl> Aliases; out << " Aliases (std::vector<GlobalDecl>) @ "; out << &Builder->Aliases << "\n"; for(auto I = Builder->Aliases.begin(), E = Builder->Aliases.end(); I != E; ++I) { I->getDecl()->print(out); out << "\n"; } //typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > // ReplacementsTy; //ReplacementsTy Replacements; out << " Replacements (llvm::StringMap<llvm::TrackingVH<llvm::Constant> >"; out << " @" << &Builder->Replacements << "\n"; for(auto I = Builder->Replacements.begin(), E = Builder->Replacements.end(); I != E; ++I) { out << I->getKey().str().c_str(); (*I->getValue()).print(out); out << "\n"; } //std::vector<const CXXRecordDecl*> DeferredVTables; out << " DeferredVTables (std::vector<const CXXRecordDecl*> @ "; out << &Builder->DeferredVTables << "\n"; for(auto I = Builder->DeferredVTables.begin(), E = Builder->DeferredVTables.end(); I != E; ++I) { (*I)->print(out); out << "\n"; } //std::vector<llvm::WeakVH> LLVMUsed; out << " LLVMUsed (std::vector<llvm::WeakVH> > @ "; out << &Builder->LLVMUsed << "\n"; for(auto I = Builder->LLVMUsed.begin(), E = Builder->LLVMUsed.end(); I != E; ++I) { (*I)->print(out); out << "\n"; } // typedef std::vector<std::pair<llvm::Constant*, int> > CtorList; //CtorList GlobalCtors; out << " GlobalCtors (std::vector<std::pair<llvm::Constant*, int> > @ "; out << &Builder->GlobalCtors << "\n"; for(auto I = Builder->GlobalCtors.begin(), E = Builder->GlobalCtors.end(); I != E; ++I) { out << I->Initializer << " : " << I->AssociatedData; out << "\n"; } //CtorList GlobalDtors; out << " GlobalDtors (std::vector<std::pair<llvm::Constant*, int> > @ "; out << &Builder->GlobalDtors << "\n"; for(auto I = Builder->GlobalDtors.begin(), E = Builder->GlobalDtors.end(); I != E; ++I) { out << I->Initializer << " : " << I->AssociatedData; out << "\n"; } //llvm::DenseMap<GlobalDecl, StringRef> MangledDeclNames; //std::vector<llvm::Constant*> Annotations; //llvm::StringMap<llvm::Constant*> AnnotationStrings; //llvm::StringMap<llvm::Constant*> CFConstantStringMap; //llvm::StringMap<llvm::GlobalVariable*> ConstantStringMap; out << " ConstantStringMap (llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *>) @ "; out << &Builder->ConstantStringMap << "\n"; for(auto I = Builder->ConstantStringMap.begin(), E = Builder->ConstantStringMap.end(); I != E; ++I) { I->first->print(out); I->second->print(out); out << "\n"; } //llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap; //llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap; //llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap; //llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap; //llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap; //llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap; //StaticExternCMap StaticExternCValues; //std::vector<std::pair<const VarDecl *, llvm::GlobalVariable *> > // CXXThreadLocals; //std::vector<llvm::Constant*> CXXThreadLocalInits; //std::vector<llvm::Constant*> CXXGlobalInits; //llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition; //SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits; //std::vector<std::pair<llvm::WeakVH,llvm::Constant*> > CXXGlobalDtors; //llvm::SetVector<clang::Module *> ImportedModules; //SmallVector<llvm::Value *, 16> LinkerOptionsMetadata; // out.flush(); }
int Solver::getValueAsInt(std::string key) { return getValue(key).convert<int>(); }
bool GConfLayer::value(Handle handle, const QString &subPath, QVariant *data) { QMutexLocker locker(&m_mutex); return getValue(handle, subPath, data); }
StatusWith<Message> downconvertFindCommandRequest(const RemoteCommandRequest& request) { const auto& cmdObj = request.cmdObj; const NamespaceString nss(request.dbname, cmdObj.firstElement().String()); if (!nss.isValid()) { return {ErrorCodes::InvalidNamespace, str::stream() << "Invalid collection name: " << nss.ns()}; } const std::string& ns = nss.ns(); // It is a little heavy handed to use QueryRequest to convert the command object to // query() arguments but we get validation and consistent behavior with the find // command implementation on the remote server. auto qrStatus = QueryRequest::makeFromFindCommand(nss, cmdObj, false); if (!qrStatus.isOK()) { return qrStatus.getStatus(); } auto qr = std::move(qrStatus.getValue()); // We are downconverting a find command, and find command can only have ntoreturn // if it was generated by mongos. invariant(!qr->getNToReturn()); Query query(qr->getFilter()); if (!qr->getSort().isEmpty()) { query.sort(qr->getSort()); } if (!qr->getHint().isEmpty()) { query.hint(qr->getHint()); } if (!qr->getMin().isEmpty()) { query.minKey(qr->getMin()); } if (!qr->getMax().isEmpty()) { query.minKey(qr->getMax()); } if (qr->isExplain()) { query.explain(); } if (qr->isSnapshot()) { query.snapshot(); } const int nToReturn = qr->getLimit().value_or(0) * -1; const int nToSkip = qr->getSkip().value_or(0); const BSONObj* fieldsToReturn = &qr->getProj(); int queryOptions = qr->getOptions(); // non-const so we can set slaveOk if we need to const int batchSize = qr->getBatchSize().value_or(0); const int nextBatchSize = [batchSize, nToReturn]() { if (nToReturn == 0) return batchSize; if (batchSize == 0) return nToReturn; return batchSize < nToReturn ? batchSize : nToReturn; }(); // We can't downconvert all metadata, since we aren't sending a command, but we do need to // downconvert $secondaryOk to the slaveOK bit. auto ssm = rpc::ServerSelectionMetadata::readFromMetadata( request.metadata.getField(rpc::ServerSelectionMetadata::fieldName())); if (!ssm.isOK()) { return ssm.getStatus(); } if (ssm.getValue().isSecondaryOk()) { queryOptions |= mongo::QueryOption_SlaveOk; } Message message; assembleQueryRequest( ns, query.obj, nextBatchSize, nToSkip, fieldsToReturn, queryOptions, message); return {std::move(message)}; }
void ComplexCounter::setup() { auto parameter = mIo.mParameters[ 0 ]; auto outlet = mIo.mOutlets[ 0 ]; boost::get< _2Real::CustomDataItem >( outlet->getValue() ) = boost::get< _2Real::CustomDataItem >( parameter->getValue() ); }
StatusWith<RemoteCommandResponse> RemoteCommandRunnerImpl::runCommand( const RemoteCommandRequest& request) { try { const Date_t requestStartDate = Date_t::now(); const auto timeoutMillis = getTimeoutMillis(request.expirationDate, requestStartDate); if (!timeoutMillis.isOK()) { return StatusWith<RemoteCommandResponse>(timeoutMillis.getStatus()); } ConnectionPool::ConnectionPtr conn( &_connPool, request.target, requestStartDate, timeoutMillis.getValue()); BSONObj output; BSONObj metadata; // If remote server does not support either find or getMore commands, down convert // to using DBClientInterface::query()/getMore(). // Perform down conversion based on wire protocol version. // 'commandName' will be an empty string if the command object is an empty BSON // document. StringData commandName = request.cmdObj.firstElement().fieldNameStringData(); const auto isFindCmd = commandName == LiteParsedQuery::kFindCommandName; const auto isGetMoreCmd = commandName == GetMoreRequest::kGetMoreCommandName; const auto isFindOrGetMoreCmd = isFindCmd || isGetMoreCmd; // We are using the wire version to check if we need to downconverting find/getMore // requests because coincidentally, the find/getMore command is only supported by // servers that also accept OP_COMMAND. bool supportsFindAndGetMoreCommands = rpc::supportsWireVersionForOpCommandInMongod( conn.get()->getMinWireVersion(), conn.get()->getMaxWireVersion()); if (!isFindOrGetMoreCmd || supportsFindAndGetMoreCommands) { rpc::UniqueReply commandResponse = conn.get()->runCommandWithMetadata(request.dbname, request.cmdObj.firstElementFieldName(), request.metadata, request.cmdObj); output = commandResponse->getCommandReply().getOwned(); metadata = commandResponse->getMetadata().getOwned(); } else if (isFindCmd) { return runDownconvertedFindCommand(conn.get(), request); } else if (isGetMoreCmd) { return runDownconvertedGetMoreCommand(conn.get(), request); } const Date_t requestFinishDate = Date_t::now(); conn.done(requestFinishDate); return StatusWith<RemoteCommandResponse>( RemoteCommandResponse(std::move(output), std::move(metadata), Milliseconds(requestFinishDate - requestStartDate))); } catch (const DBException& ex) { return StatusWith<RemoteCommandResponse>(ex.toStatus()); } catch (const std::exception& ex) { return StatusWith<RemoteCommandResponse>( ErrorCodes::UnknownError, str::stream() << "Sending command " << request.cmdObj << " on database " << request.dbname << " over network to " << request.target.toString() << " received exception " << ex.what()); } }
//! Sets the new caption of the element void CGUISpinBox::setText(const wchar_t* text) { EditBox->setText(text); setValue(getValue()); verifyValueRange(); }
Status ShardingStateRecovery::recover(OperationContext* txn) { if (serverGlobalParams.clusterRole != ClusterRole::ShardServer) { return Status::OK(); } if (!recoverShardingState) { warning() << "Not checking for ShardingState recovery document because the recoverShardingState " "server parameter is set to false"; return Status::OK(); } BSONObj recoveryDocBSON; try { AutoGetCollection autoColl(txn, NamespaceString::kConfigCollectionNamespace, MODE_IS); if (!Helpers::findOne( txn, autoColl.getCollection(), RecoveryDocument::getQuery(), recoveryDocBSON)) { return Status::OK(); } } catch (const DBException& ex) { return ex.toStatus(); } const auto recoveryDocStatus = RecoveryDocument::fromBSON(recoveryDocBSON); if (!recoveryDocStatus.isOK()) return recoveryDocStatus.getStatus(); const auto recoveryDoc = std::move(recoveryDocStatus.getValue()); log() << "Sharding state recovery process found document " << recoveryDoc.toBSON(); // Make sure the sharding state is initialized ShardingState* const shardingState = ShardingState::get(txn); // For backwards compatibility. Shards added by v3.4 cluster should have been initialized by // the shard identity document. if (!shardingState->enabled()) { shardingState->initializeFromConfigConnString(txn, recoveryDoc.getConfigsvr().toString()); shardingState->setShardName(recoveryDoc.getShardName()); } if (!recoveryDoc.getMinOpTimeUpdaters()) { // Treat the minOpTime as up-to-date grid.advanceConfigOpTime(recoveryDoc.getMinOpTime()); return Status::OK(); } log() << "Sharding state recovery document indicates there were " << recoveryDoc.getMinOpTimeUpdaters() << " metadata change operations in flight. Contacting the config server primary in order " "to retrieve the most recent opTime."; // Need to fetch the latest uptime from the config server, so do a logging write Status status = grid.catalogManager(txn)->logChange(txn, "Sharding minOpTime recovery", NamespaceString::kConfigCollectionNamespace.ns(), recoveryDocBSON); if (!status.isOK()) return status; log() << "Sharding state recovered. New config server opTime is " << grid.configOpTime(); // Finally, clear the recovery document so next time we don't need to recover status = modifyRecoveryDocument(txn, RecoveryDocument::Clear, kMajorityWriteConcern); if (!status.isOK()) { warning() << "Failed to reset sharding state recovery document due to " << status; } return Status::OK(); }
bool HtmlCheckBox::getCheck() const { const String &value = getValue(); return value == _S("1") || value == _S("on"); }
void HttpParser::parseHeader() { // run the fsm. const int CR = 13; const int LF = 10; const int ANY = 256; enum Action { // make lower case LOWER = 0x1, // convert current character to null. NULLIFY = 0x2, // set the header index to the current position SET_HEADER_START = 0x4, // set the key index to the current position SET_KEY = 0x8, // set value index to the current position. SET_VALUE = 0x10, // store current key/value pair. STORE_KEY_VALUE = 0x20, // sets content start to current position + 1 SET_CONTENT_START = 0x40 }; static const struct FSM { State curState; int c; State nextState; unsigned actions; } fsm[] = { { p_request_line, CR, p_request_line_cr, NULLIFY }, { p_request_line, ANY, p_request_line, 0 }, { p_request_line_cr, LF, p_request_line_crlf, 0 }, { p_request_line_crlf, CR, p_request_line_crlfcr, 0 }, { p_request_line_crlf, ANY, p_key, SET_HEADER_START | SET_KEY | LOWER }, { p_request_line_crlfcr, LF, p_content, SET_CONTENT_START }, { p_key, ':', p_key_colon, NULLIFY }, { p_key, ANY, p_key, LOWER }, { p_key_colon, ' ', p_key_colon_sp, 0 }, { p_key_colon_sp, ANY, p_value, SET_VALUE }, { p_value, CR, p_value_cr, NULLIFY | STORE_KEY_VALUE }, { p_value, ANY, p_value, 0 }, { p_value_cr, LF, p_value_crlf, 0 }, { p_value_crlf, CR, p_value_crlfcr, 0 }, { p_value_crlf, ANY, p_key, SET_KEY | LOWER }, { p_value_crlfcr, LF, p_content, SET_CONTENT_START }, { p_error, ANY, p_error, 0 } }; for( unsigned i = _parsedTo; i < _data.length(); ++i) { char c = _data[i]; State nextState = p_error; for ( unsigned d = 0; d < sizeof(fsm) / sizeof(FSM); ++d ) { if ( fsm[d].curState == _state && ( c == fsm[d].c || fsm[d].c == ANY ) ) { nextState = fsm[d].nextState; if ( fsm[d].actions & LOWER ) { _data[i] = tolower( _data[i] ); } if ( fsm[d].actions & NULLIFY ) { _data[i] = 0; } if ( fsm[d].actions & SET_HEADER_START ) { _headerStart = i; } if ( fsm[d].actions & SET_KEY ) { _keyIndex = i; } if ( fsm[d].actions & SET_VALUE ) { _valueIndex = i; } if ( fsm[d].actions & SET_CONTENT_START ) { _contentStart = i + 1; } if ( fsm[d].actions & STORE_KEY_VALUE ) { // store position of first character of key. _keys.push_back( _keyIndex ); } break; } } _state = nextState; if ( _state == p_content ) { const char* str = getValue("content-length"); if ( str ) { _contentLength = atoi( str ); } break; } } _parsedTo = _data.length(); }