void HTTPFormClass::saveFile(Stringp key, Stringp destPath) { string sKey(((StUTF8String) key).c_str()); for (std::vector<FormFile>::iterator it=sapi->files.begin(); it!=sapi->files.end(); it++) { if (sKey == (*it).name) { StUTF8String filenameUTF8(destPath); File* fp = Platform::GetInstance()->createFile(); if (!fp || !fp->open(filenameUTF8.c_str(), File::OPEN_WRITE)) { if(fp) { Platform::GetInstance()->destroyFile(fp); } toplevel()->throwError(kFileWriteError, destPath); } if ((int32_t)fp->write((*it).data.data(), (*it).data.length()) != (int32_t)(*it).data.length()) toplevel()->throwError(kFileWriteError, destPath); fp->close(); Platform::GetInstance()->destroyFile(fp); } } }
CString COXShortkeysOrganizer::GetAccelKeyString(ACCEL* pAccel) { ASSERT(pAccel!=NULL); CString sKey(_T("")); if(pAccel->fVirt&FSHIFT) sKey+=_T("Shift+"); if(pAccel->fVirt&FCONTROL) sKey+=_T("Ctrl+"); if(pAccel->fVirt&FALT) sKey+=_T("Alt+"); if(pAccel->fVirt&FVIRTKEY) { TCHAR szKeyName[10]; LPARAM lParam=MAKELPARAM(0,::MapVirtualKey(pAccel->key,0)) | (pAccel->key<0x0030 ? 0x01000000 : 0); if(pAccel->key!=0xbf) { ::GetKeyNameText(PtrToLong(lParam),szKeyName,10); } else { lstrcpy(szKeyName,_T("Slash")); } sKey+=szKeyName; } else { sKey+=(TCHAR)pAccel->key; } return sKey; }
void NamespaceIndex::kill_ns(const StringData& ns) { init(); if (!allocated()) { // that's ok, may dropping something that doesn't exist return; } if (!Lock::isWriteLocked(ns)) { throw RetryWithWriteLock(); } NamespaceDetailsMap::const_iterator it = _namespaces.find(ns); if (it != _namespaces.end()) { // Might not be in the _namespaces map if the ns exists but is closed. // Note this ns in the rollback, since we are about to modify its entry. NamespaceIndexRollback &rollback = cc().txn().nsIndexRollback(); rollback.noteNs(ns); shared_ptr<NamespaceDetails> d = it->second; const int r = _namespaces.erase(ns); verify(r == 1); d->close(); } BSONObj nsobj = BSON("ns" << ns); storage::Key sKey(nsobj, NULL); DBT ndbt = sKey.dbt(); DB *db = _nsdb->db(); int r = db->del(db, cc().txn().db_txn(), &ndbt, 0); if (r != 0) { storage::handle_ydb_error_fatal(r); } }
void CollectionMap::kill_ns(const StringData& ns) { init(); if (!allocated()) { // that's ok, may dropping something that doesn't exist return; } if (!Lock::isWriteLocked(ns)) { throw RetryWithWriteLock(); } // Must copy ns before we delete the collection, otherwise ns will be pointing to freed // memory. BSONObj nsobj = BSON("ns" << ns); CollectionStringMap::const_iterator it = _collections.find(ns); if (it != _collections.end()) { // Might not be in the _collections map if the ns exists but is closed. // Note this ns in the rollback, since we are about to modify its entry. CollectionMapRollback &rollback = cc().txn().collectionMapRollback(); rollback.noteNs(ns); shared_ptr<Collection> cl = it->second; const int r = _collections.erase(ns); verify(r == 1); cl->close(); } storage::Key sKey(nsobj, NULL); DBT ndbt = sKey.dbt(); DB *db = _metadb->db(); int r = db->del(db, cc().txn().db_txn(), &ndbt, 0); if (r != 0) { storage::handle_ydb_error_fatal(r); } }
void way(const shared_ptr<const OSM::Way> &way) { Osmium::OSM::TagList::const_iterator tagIt; for(tagIt = way->tags().begin(); tagIt != way->tags().end(); ++tagIt) { std::string sKey(tagIt->key()); std::string sVal(tagIt->value()); if(sKey.compare("natural") == 0) { if(sVal.compare("coastline") == 0) { Osmium::OSM::WayNodeList::const_iterator nodeIt; for(nodeIt = way->nodes().begin(); nodeIt != way->nodes().end(); ++nodeIt) { std::unordered_map<size_t,Node>::iterator findIt; size_t findId = nodeIt->ref(); findIt = m_listNodes.find(findId); if(findIt == m_listNodes.end()) { return; } // way pointing to node not in data set std::cout << std::fixed << std::setprecision(7) << findIt->second.lon << "," << std::fixed << std::setprecision(7) << findIt->second.lat << "," << 0 << "\n"; } } } } }
void CollectionMap::update_ns(const StringData& ns, const BSONObj &serialized, bool overwrite) { if (!Lock::isWriteLocked(ns)) { throw RetryWithWriteLock(); } init(); dassert(allocated()); // cannot update a non-existent metadb // Note this ns in the rollback, even though we aren't modifying // _collections directly. But we know this operation is part of // a scheme to create this namespace or change something about it. CollectionMapRollback &rollback = cc().txn().collectionMapRollback(); rollback.noteNs(ns); BSONObj nsobj = BSON("ns" << ns); storage::Key sKey(nsobj, NULL); DBT ndbt = sKey.dbt(); DBT ddbt = storage::dbt_make(serialized.objdata(), serialized.objsize()); DB *db = _metadb->db(); const int flags = overwrite ? 0 : DB_NOOVERWRITE; const int r = db->put(db, cc().txn().db_txn(), &ndbt, &ddbt, flags); if (r != 0) { storage::handle_ydb_error(r); } }
bool DekControl::unlock(string alias, Password *key) { printf("DekControl::unlock\n"); shared_ptr<SerializedItem> sKey(key->serialize()); sKey->dump("DekControl::unlock"); int sock = doConnect(); if(sock < 0) { printf("Cannot connect\n"); return false; } string cmd = "0 ctl " + std::to_string(CommandCode::CommandUnlock) + " " + alias + " " + sKey->toString(); printf("cmd :: %s\n", cmd.c_str()); write(sock, cmd.c_str(), cmd.size() + 1); shared_ptr<DaemonEvent> event(monitor(sock)); close(sock); if(event->code == ResponseCode::CommandOkay) { return true; } printf("Failed to unlock [%d]\n", event->code); return false; }
bool HTTPFormClass::isUploaded(Stringp key) { string sKey(((StUTF8String) key).c_str()); for (std::vector<FormFile>::iterator it=sapi->files.begin(); it!=sapi->files.end(); it++) if (sKey == (*it).name) return true; return false; }
void COXCustomizeShortkeysPage::OnButtonRemove() { // TODO: Add your control notification handler code here if(!UpdateData(TRUE)) return; ASSERT(m_nShortkeyIndex>=0 && m_nShortkeyIndex<m_listShortkeys.GetCount()); ASSERT(m_listShortkeys.GetItemData(m_nShortkeyIndex)==0); HTREEITEM hSelectedItem=m_treeCommands.GetSelectedItem(); ASSERT(hSelectedItem!=NULL); WORD nCommandID=(WORD)m_treeCommands.GetItemData(hSelectedItem); ASSERT(nCommandID!=(WORD)-1); CString sKey(_T("")); m_listShortkeys.GetText(m_nShortkeyIndex,sKey); ACCEL accel; VERIFY(m_shortkeysOrganizer.GetAccelKeyFromString(sKey,&accel)); accel.cmd=nCommandID; COXArrAccelTables* pAccelTables=m_shortkeysOrganizer.GetAccelTables(); ASSERT(pAccelTables!=NULL); ASSERT(m_nAccelTableIndex>=0 && m_nAccelTableIndex<pAccelTables->GetSize()); VERIFY(m_shortkeysOrganizer.RemoveAccelerator(&accel, pAccelTables->GetAt(m_nAccelTableIndex).m_docTemplate)); GetShortkeys(); ShowVars(); }
BOOL MetawallLicence::VerifyLicenseKey(BSTR bstrKey) { LOG_WS_FUNCTION_SCOPE(); _bstr_t sKey(bstrKey); _bstr_t sSecretKey(SECRET_CODE); return(0 == lstrcmpi(sKey, sSecretKey)); }
uint HTTPFormClass::getFileSize(Stringp key) { //AvmCore *core = this->core(); string sKey(((StUTF8String) key).c_str()); for (std::vector<FormFile>::iterator it=sapi->files.begin(); it!=sapi->files.end(); it++) if (sKey == (*it).name) return (*it).data.length(); return 0; }
std::string Scripts_GetStringForKey(const char *key) { hdAssert(stringsFileWasLoaded); std::string sKey(key); if (stringTable.count(sKey) == 0) return std::string(key); return stringTable[sKey]; }
Stringp HTTPFormClass::getFilename(Stringp key) { AvmCore *core = this->core(); string sKey(((StUTF8String) key).c_str()); for (std::vector<FormFile>::iterator it=sapi->files.begin(); it!=sapi->files.end(); it++) if (sKey == (*it).name) return core->newStringUTF8((*it).filename.data(), (*it).filename.length()); return NULL; }
EncKey *DekClient::encrypt(string alias, SymKey *key) { printf("DekClient::encrypt\n"); int sock = doConnect(); if(sock < 0) { printf("Cannot connect\n"); return false; } shared_ptr<SerializedItem> sKey(key->serialize()); sKey->dump("DekClient::encrypt"); string cmd = "0 enc " + std::to_string(CommandCode::CommandEncrypt) + " " + alias + " " + sKey->toString(); printf("cmd :: %s\n", cmd.c_str()); write(sock, cmd.c_str(), cmd.size() + 1); shared_ptr<DaemonEvent> event(monitor(sock)); close(sock); if(event == NULL) { printf("Failed to encrypt : %d\n", __LINE__); return NULL; } event->dump("encrypt return event"); if(event->code == ResponseCode::CommandOkay) { int alg = std::stoi(event->message[0]); shared_ptr<SerializedItem> sItem; switch(alg) { case CryptAlg::AES: sItem = shared_ptr<SerializedItem> ( new SerializedItem(alg, event->message[1].c_str(), event->message[2].c_str(), "?")); break; case CryptAlg::ECDH: sItem = shared_ptr<SerializedItem> ( new SerializedItem(alg, event->message[1].c_str(), event->message[2].c_str(), event->message[3].c_str())); break; default: printf("Failed to encrypt. unknown alg %d\n", alg); break; } return (EncKey *) sItem->deserialize(); } else { printf("Failed to encrypt [%d]\n", (event == NULL) ? ResponseCode::CommandFailed : event->code); return NULL; } return NULL; }
QString QxXmlWriter::writeBinaryData(const QString & qualifiedName, QxXmlWriter::type_byte_arr_ptr pData) { QString sKey(getNextKeyBinaryData()); m_mapBinaryData.insert(sKey, pData); writeStartElement(qualifiedName); writeAttribute(QX_XML_ATTRIBUTE_IS_BINARY_DATA, "1"); writeCharacters(sKey); writeEndElement(); return sKey; }
void QxSqlCompare::resolve(QSqlQuery & query) const { qAssert((m_lstKeys.count() == 1) && (m_lstValues.count() == 1)); QString sKey(m_lstKeys.at(0)); QVariant vValue(m_lstValues.at(0)); QString sWildCard = m_pSqlGenerator->getWildCard(); if (m_type == _starts_with) { vValue = QVariant(vValue.toString() + sWildCard); } else if (m_type == _ends_with) { vValue = QVariant(sWildCard + vValue.toString()); } else if (m_type == _contains_string) { vValue = QVariant(sWildCard + vValue.toString() + sWildCard); } bool bQuestionMark = (qx::QxSqlDatabase::getSingleton()->getSqlPlaceHolderStyle() == qx::QxSqlDatabase::ph_style_question_mark); if (bQuestionMark) { query.addBindValue(vValue); } else { query.bindValue(sKey, vValue); } }
void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, const std::string &hexin, const std::string &hexout) { std::vector<unsigned char> key = ParseHex(hexkey); std::vector<unsigned char> iv = ParseHex(hexiv); std::vector<unsigned char> in = ParseHex(hexin); std::vector<unsigned char> correctout = ParseHex(hexout); SecureString sKey(key.begin(), key.end()), sPlaintextIn(in.begin(), in.end()), sPlaintextOut, sPlaintextOutOld; std::string sIv(iv.begin(), iv.end()), sCiphertextIn(correctout.begin(), correctout.end()), sCiphertextOut, sCiphertextOutOld; BOOST_CHECK_MESSAGE(EncryptAES256(sKey, sPlaintextIn, sIv, sCiphertextOut), "EncryptAES256: " + HexStr(sCiphertextOut) + std::string(" != ") + hexout); BOOST_CHECK_MESSAGE(OldEncryptAES256(sKey, sPlaintextIn, sIv, sCiphertextOutOld), "OldEncryptAES256: " + HexStr(sCiphertextOutOld) + std::string(" != ") + hexout); BOOST_CHECK(sCiphertextOut == sCiphertextOutOld); BOOST_CHECK_MESSAGE(DecryptAES256(sKey, sCiphertextIn, sIv, sPlaintextOut), "DecryptAES256: " + HexStr(sPlaintextOut) + std::string(" != ") + hexin); BOOST_CHECK_MESSAGE(OldDecryptAES256(sKey, sCiphertextIn, sIv, sPlaintextOutOld), "OldDecryptAES256: " + HexStr(sPlaintextOutOld) + std::string(" != ") + hexin); BOOST_CHECK(sPlaintextOut == sPlaintextOutOld); }
void TestRegUtils::TestSetDWORDValue() { CStdString sKey(_T("SOFTWARE\\Workshare\\Testing\\TestKeyRegUtils")); assertMessage(RegUtils::CreateKey(HKEY_LOCAL_MACHINE, sKey),_T("Failed to create key for test")); HKEY hOpenedKey = RegUtils::OpenKey(HKEY_LOCAL_MACHINE, sKey); CStdString sValueName(_T("NewDWORDValue")); assertMessage(RegUtils::SetRegDWORDValue(HKEY_LOCAL_MACHINE, sKey, sValueName, 0),_T("Failed to set the DWORD value for the test key")); assertMessage(0 == RegUtils::GetDWORDFromRegistry(hOpenedKey, sValueName),_T("Failed to get the correct value from the registry")); assertMessage(RegUtils::SetRegDWORDValue(HKEY_LOCAL_MACHINE, sKey, sValueName, 1),_T("Failed to set the DWORD value for the test key")); assertMessage(1 == RegUtils::GetDWORDFromRegistry(hOpenedKey, sValueName),_T("Failed to get the correct value from the registry")); assertMessage( RegUtils::RecursiveDeleteKey(HKEY_LOCAL_MACHINE, sKey), _T("Unable to delete test key when cleaning up test")); }
void TestRegUtils::TestGetValueFromRegistryGetsDefaultValue() { CStdString sKey(_T("SOFTWARE\\Workshare\\Testing\\TestKeyRegUtils")); assertMessage(RegUtils::CreateKey(HKEY_LOCAL_MACHINE,sKey),_T("Failed to create key for test")); CStdString sExpectedValue(_T("DefaultValue")); assertMessage(RegUtils::SetRegStringValue(HKEY_LOCAL_MACHINE,sKey,_T(""),sExpectedValue),_T("Failed to set the default value for the test key")); HKEY hOpenedKey = RegUtils::OpenKey(HKEY_LOCAL_MACHINE,sKey); variant_t vValue; assertMessage(RegUtils::GetValueFromRegistry(hOpenedKey,_T(""),vValue),_T("Failed to get the default value from the registry")); CStdString sAcualValue(vValue.bstrVal); assertMessage(sExpectedValue.CompareNoCase(sAcualValue)==0,_T("Expected the set default value and the retrieved default value to be equal")); assertMessage( RegUtils::RecursiveDeleteKey(HKEY_LOCAL_MACHINE, sKey), _T("Unable to delete test key when cleaning up test")); }
//-------------------------------------------------------------------------------- bool CSettingsFile::Find(LPCTSTR pKey, CSettingsInfo& info) { CStringArray sTemp; CString sKey(pKey); sKey.MakeLower(); for(int i = 0; GetLine(i, sTemp); i++) { sTemp[0].MakeLower(); if(sTemp[0] == sKey) { info = sTemp; return true; } } return false; }
SymKey *DekClient::decrypt(string alias, EncKey *key) { printf("DekClient::decrypt\n"); int sock = doConnect(); if(sock < 0) { printf("Cannot connect\n"); return false; } shared_ptr<SerializedItem> sKey(key->serialize()); sKey->dump("DekClient::decrypt"); string cmd = "0 enc " + std::to_string(CommandCode::CommandDecrypt) + " " + alias + " " + sKey->toString(); printf("cmd :: %s\n", cmd.c_str()); write(sock, cmd.c_str(), cmd.size() + 1); shared_ptr<DaemonEvent> event(monitor(sock)); close(sock); if(event == NULL) { printf("Failed to encrypt : %d\n", __LINE__); return NULL; } if(event->code == ResponseCode::CommandOkay) { int alg = std::stoi(event->message[0]); if(alg != CryptAlg::PLAIN) { printf("Failed to decrypt : result is not plain text\n"); return NULL; } shared_ptr<SerializedItem> sItem( new SerializedItem(CryptAlg::PLAIN, event->message[1].c_str(), "?", "?")); return (SymKey *) sItem->deserialize(); } else { printf("Failed to decrypt [%d]\n", (event == NULL) ? ResponseCode::CommandFailed : event->code); return NULL; } return NULL; }
// on input, _initLock is held, so this can be called by only one thread at a time, // also, on input, the CollectionMap must be allocated Collection *CollectionMap::open_ns(const StringData& ns, const bool bulkLoad) { verify(allocated()); BSONObj serialized; BSONObj nsobj = BSON("ns" << ns); storage::Key sKey(nsobj, NULL); DBT ndbt = sKey.dbt(); // If this transaction is read only, then we cannot possible already // hold a lock in the metadb and we certainly don't need to hold one // for the duration of this operation. So we use an alternate txn stack. const bool needAltTxn = !cc().hasTxn() || cc().txn().readOnly(); scoped_ptr<Client::AlternateTransactionStack> altStack(!needAltTxn ? NULL : new Client::AlternateTransactionStack()); scoped_ptr<Client::Transaction> altTxn(!needAltTxn ? NULL : new Client::Transaction(0)); // Pass flags that get us a write lock on the metadb row // for the ns we'd like to open. DB *db = _metadb->db(); const int r = db->getf_set(db, cc().txn().db_txn(), DB_SERIALIZABLE | DB_RMW, &ndbt, getf_serialized, &serialized); if (r == 0) { // We found an entry for this ns and we have the row lock. // First check if someone got the lock before us and already // did the open. Collection *cl = find_ns(ns); if (cl != NULL) { return cl; } // No need to hold the openRWLock during Collection::make(), // the fact that we have the row lock ensures only one thread will // be here for a particular ns at a time. shared_ptr<Collection> details = Collection::make( serialized, bulkLoad ); SimpleRWLock::Exclusive lk(_openRWLock); verify(!_collections[ns]); _collections[ns] = details; return details.get(); } else if (r != DB_NOTFOUND) { storage::handle_ydb_error(r); } return NULL; }
int IndexCursor::cursor_getf(const DBT *key, const DBT *val, void *extra) { struct cursor_getf_extra *info = static_cast<struct cursor_getf_extra *>(extra); try { if (key != NULL) { RowBuffer *buffer = info->buffer; storage::Key sKey(key); buffer->append(sKey, val->size > 0 ? BSONObj(static_cast<const char *>(val->data)) : BSONObj()); // request more bulk fetching if we are allowed to fetch more rows // and the row buffer is not too full. if (++info->rows_fetched < info->rows_to_fetch && !buffer->isGorged()) { return TOKUDB_CURSOR_CONTINUE; } } return 0; } catch (const std::exception &ex) { info->saveException(ex); } return -1; }
BOOL CReg::GetValue(YCString& Value, LPCTSTR pKeyPath, LPCTSTR pKeyName) { // Retrieve the handle of the key name LPTSTR pKeyPathNext = PathFindNextComponent(pKeyPath); YCString sKey(pKeyPath, pKeyPathNext - pKeyPath - 1); // Convert to a numeric handle name HKEY hKey; if (sKey == _T("HKEY_CLASSES_ROOT")) hKey = HKEY_CLASSES_ROOT; else if (sKey == _T("HKEY_CURRENT_USER")) hKey = HKEY_CURRENT_USER; else if (sKey == _T("HKEY_LOCAL_MACHINE")) hKey = HKEY_LOCAL_MACHINE; else if (sKey == _T("HKEY_USERS")) hKey = HKEY_USERS; else if (sKey == _T("HKEY_CURRENT_CONFIG")) hKey = HKEY_CURRENT_CONFIG; else return FALSE; // Retrieve the name of the subkey LPCTSTR pKeyPathEnd = pKeyPath + lstrlen(pKeyPath); YCString sSubKey(pKeyPathNext, pKeyPathEnd - pKeyPathNext); HKEY hkResult; if (RegOpenKeyEx(hKey, sSubKey, 0, KEY_QUERY_VALUE, &hkResult) != 0) return FALSE; BYTE data[MAX_PATH]; DWORD cbData = sizeof(data); if (RegQueryValueEx(hkResult, pKeyName, nullptr, nullptr, data, &cbData) != 0) return FALSE; Value = reinterpret_cast<LPTSTR>(data); RegCloseKey(hkResult); return TRUE; }
void IndexCursor::setPosition(const BSONObj &key, const BSONObj &pk) { TOKULOG(3) << toString() << ": setPosition(): getf " << key << ", pk " << pk << ", direction " << _direction << endl; // Empty row buffer, reset fetch iteration, go get more rows. _buffer.empty(); _getf_iteration = 0; storage::Key sKey( key, !pk.isEmpty() ? &pk : NULL ); DBT key_dbt = sKey.dbt();; int r; const int rows_to_fetch = getf_fetch_count(); struct cursor_getf_extra extra(&_buffer, rows_to_fetch); DBC *cursor = _cursor.dbc(); if ( forward() ) { r = cursor->c_getf_set_range(cursor, getf_flags(), &key_dbt, cursor_getf, &extra); } else { r = cursor->c_getf_set_range_reverse(cursor, getf_flags(), &key_dbt, cursor_getf, &extra); } if ( extra.ex != NULL ) { throw *extra.ex; } if (r == TOKUDB_INTERRUPTED) { _interrupt_extra.throwException(); } if ( r != 0 && r != DB_NOTFOUND ) { extra.throwException(); storage::handle_ydb_error(r); } _getf_iteration++; _ok = extra.rows_fetched > 0 ? true : false; if ( ok() ) { getCurrentFromBuffer(); } TOKULOG(3) << "setPosition hit K, PK, Obj " << _currKey << _currPK << _currObj << endl; }
bool fsaFile::AddDirEntry(fsaDirEntry *pEntry) { bool bRtn = true; if(pEntry->GetDataRaw() == NULL) { bRtn = false; } else { RGString sKey(pEntry->MakeKey()); MapDirEntry::iterator itr = _mapDirEntry.find(sKey); if(itr != _mapDirEntry.end()) { bRtn = false; } else { _mapDirEntry.insert(MapDirEntry::value_type(sKey,pEntry)); _vecDirEntry.push_back(pEntry); } } return bRtn; }
void IndexCursor::_prelockRange(const BSONObj &startKey, const BSONObj &endKey) { const bool isSecondary = !_cl->isPKIndex(_idx); // The ydb requires that we only lock ranges such that the left // endpoint is less than or equal to the right endpoint. // Reverse cursors describe the start and end key as the two // keys where they start and end iteration, which is backwards // in the key space (because they iterate in reverse). const BSONObj &leftKey = forward() ? startKey : endKey; const BSONObj &rightKey = forward() ? endKey : startKey; dassert(leftKey.woCompare(rightKey, _ordering) <= 0); storage::Key sKey(leftKey, isSecondary ? &minKey : NULL); storage::Key eKey(rightKey, isSecondary ? &maxKey : NULL); DBT start = sKey.dbt(); DBT end = eKey.dbt(); DBC *cursor = _cursor.dbc(); const int r = cursor->c_set_bounds( cursor, &start, &end, true, 0 ); if ( r != 0 ) { storage::handle_ydb_error(r); } }
// moves the internal position to the next key/pk/obj and returns them // returns: // true, the buffer had more and key/pk/obj were set appropriately // false, the buffer has no more data. don't call current() until append() bool RowBuffer::next() { if (!ok()) { return false; } // the buffer has more, seek passed the current one. const char headerBits = *(_buf + _current_offset); dassert(headerBits >= 1 && headerBits <= 3); _current_offset += 1; storage::Key sKey(_buf + _current_offset, headerBits & HeaderBits::hasPK); _current_offset += sKey.size(); if (headerBits & HeaderBits::hasObj) { BSONObj obj(_buf + _current_offset); _current_offset += obj.objsize(); } // postcondition: we did not seek passed the end of the buffer. verify(_current_offset <= _end_offset); return ok(); }
bool CPlainTextImporter::InitConsts(BOOL bSilent, IPreferences* pPrefs, LPCTSTR szKey) { CString sKey(szKey); sKey += _T("\\PlainText"); WANTPROJECT = pPrefs->GetProfileInt(szKey, _T("IncludeProject"), FALSE); INDENT = pPrefs->GetProfileString(szKey, _T("Indent"), _T(" ")); if (!bSilent) { COptionsDlg dlg(TRUE, WANTPROJECT, INDENT); if (dlg.DoModal() != IDOK) return false; INDENT = dlg.GetIndent(); WANTPROJECT = dlg.GetWantProject(); pPrefs->WriteProfileInt(szKey, _T("IncludeProject"), WANTPROJECT); pPrefs->WriteProfileString(szKey, _T("Indent"), INDENT); } return true; }
QString QxSqlCompare::toString() const { qAssert((m_lstColumns.count() == 1) && (m_lstKeys.count() == 1)); QString sReturn, sColumn(m_lstColumns.at(0)), sKey(m_lstKeys.at(0)); qAssert(! sColumn.isEmpty() && ! sKey.isEmpty()); switch (m_type) { case _is_equal_to: sReturn = sColumn + " = " + sKey; break; case _is_not_equal_to: sReturn = sColumn + " <> " + sKey; break; case _is_greater_than: sReturn = sColumn + " > " + sKey; break; case _is_greater_than_or_equal_to: sReturn = sColumn + " >= " + sKey; break; case _is_less_than: sReturn = sColumn + " < " + sKey; break; case _is_less_than_or_equal_to: sReturn = sColumn + " <= " + sKey; break; case _like: sReturn = sColumn + " LIKE " + sKey; break; case _not_like: sReturn = sColumn + " NOT LIKE " + sKey; break; case _starts_with: sReturn = sColumn + " LIKE " + sKey; break; case _ends_with: sReturn = sColumn + " LIKE " + sKey; break; case _contains_string: sReturn = sColumn + " LIKE " + sKey; break; default: qAssert(false); } return sReturn; }