bool TOptsParser::ParseUnknownShortOptWithinArg(size_t pos, size_t sop) { YASSERT(pos < Argc_); const TStringBuf arg(Argv_[pos]); YASSERT(sop > 0); YASSERT(sop < arg.length()); YASSERT(EIO_NONE != IsOpt(arg)); if (!Opts_->AllowUnknownCharOptions_) ythrow TUsageException() << "unknown option '" << EscapeC(arg[sop]) << "' in '" << arg << "'"; TempCurrentOpt_.Reset(new TOpt); TempCurrentOpt_->AddShortName(arg[sop]); sop += 1; // mimic behavior of Opt: unknown option has arg only if char is last within arg if (sop < arg.length()) { return Commit(TempCurrentOpt_.Get(), 0, pos, sop); } pos += 1; sop = 0; if (pos == Argc_ || EIO_NONE != IsOpt(Argv_[pos])) { return Commit(TempCurrentOpt_.Get(), 0, pos, 0); } return Commit(TempCurrentOpt_.Get(), Argv_[pos], pos + 1, 0); }
Commit Object::toCommit() const { if(isCommit()) { return Commit(*this); } else return Commit(); }
void Manager::CloseAll() { _MANAGER(CleverSysLog clv(L"Manager::CloseAll()")); while(!m_modalWindows.empty()) { DeleteWindow(m_modalWindows.back()); Commit(); } while(!m_windows.empty()) { DeleteWindow(m_windows.back()); Commit(); } m_windows.clear(); }
status_t Inode::Write(OpenFileCookie* cookie, off_t pos, const void* _buffer, size_t* _length) { ASSERT(cookie != NULL); ASSERT(_buffer != NULL); ASSERT(_length != NULL); if (pos < 0) pos = 0; if ((cookie->fMode & O_RWMASK) == O_RDONLY) return B_NOT_ALLOWED; if ((cookie->fMode & O_APPEND) != 0) pos = fMaxFileSize; uint64 fileSize = pos + *_length; if (fileSize > fMaxFileSize) { status_t result = file_cache_set_size(fFileCache, fileSize); if (result != B_OK) return result; fMaxFileSize = fileSize; fMetaCache.GrowFile(fMaxFileSize); } if ((cookie->fMode & O_NOCACHE) != 0) { WriteDirect(cookie, pos, _buffer, _length); Commit(); } return file_cache_write(fFileCache, cookie, pos, _buffer, _length); }
void BillboardSet::SetNumBillboards(unsigned num) { // Prevent negative value being assigned from the editor if (num > M_MAX_INT) num = 0; if (num > MAX_BILLBOARDS) num = MAX_BILLBOARDS; unsigned oldNum = billboards_.Size(); billboards_.Resize(num); // Set default values to new billboards for (unsigned i = oldNum; i < num; ++i) { SharedPtr<Billboard> bb(new Billboard()); bb->position_ = Vector3::ZERO; bb->size_ = Vector2::ONE; bb->uv_ = Rect::POSITIVE; bb->color_ = Color(1.0f, 1.0f, 1.0f); bb->rotation_ = 0.0f; bb->enabled_ = false; billboards_[i] = bb; } bufferSizeDirty_ = true; Commit(); }
STDMETHODIMP CStreamSwitcherAllocator::GetBuffer( IMediaSample** ppBuffer, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags) { HRESULT hr = VFW_E_NOT_COMMITTED; if (!m_bCommitted) { return hr; } /* TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() + %x\n"), this); m_pPin->m_evBlock.Wait(); TRACE(_T("CStreamSwitcherAllocator::GetBuffer m_pPin->m_evBlock.Wait() - %x\n"), this); */ if (m_fMediaTypeChanged) { if (!m_pPin || !m_pPin->m_pFilter) { return hr; } CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pPin->m_pFilter))->GetOutputPin(); if (!pOut || !pOut->CurrentAllocator()) { return hr; } ALLOCATOR_PROPERTIES Properties, Actual; if (FAILED(pOut->CurrentAllocator()->GetProperties(&Actual))) { return hr; } if (FAILED(GetProperties(&Properties))) { return hr; } if (!m_bCommitted || Properties.cbBuffer < Actual.cbBuffer) { Properties.cbBuffer = Actual.cbBuffer; if (FAILED(Decommit())) { return hr; } if (FAILED(SetProperties(&Properties, &Actual))) { return hr; } if (FAILED(Commit())) { return hr; } ASSERT(Actual.cbBuffer >= Properties.cbBuffer); if (Actual.cbBuffer < Properties.cbBuffer) { return hr; } } } hr = CMemAllocator::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags); if (m_fMediaTypeChanged && SUCCEEDED(hr)) { (*ppBuffer)->SetMediaType(&m_mt); m_fMediaTypeChanged = false; } return hr; }
/// <summary>Commits the document</summary> /// <param name="title">Revision title</param> /// <returns></returns> BOOL ScriptDocument::OnCommitDocument(const wstring& title) { WorkerData data(Operation::LoadSaveDocument); try { // Feedback Console << Cons::UserAction << "Committing script: " << FullPath << ENDL; data.SendFeedback(ProgressType::Operation, 0, VString(L"Committing script '%s'", FullPath.c_str())); // Get project auto proj = ProjectDocument::GetActive(); // Verify document is part of project if (!proj) throw InvalidOperationException(HERE, L"No current project"); else if (!proj->Contains(FullPath)) throw InvalidOperationException(HERE, L"Document is not a member of current project"); // Commit if (proj->Commit(*this, title)) data.SendFeedback(Cons::Success, ProgressType::Succcess, 0, L"Script committed successfully"); else data.SendFeedback(Cons::Error, ProgressType::Failure, 0, L"Script commit aborted"); return TRUE; } catch (ExceptionBase& e) { Console.Log(HERE, e, VString(L"Failed to commit script '%s'", FullPath.c_str())); data.SendFeedback(Cons::Error, ProgressType::Failure, 0, L"Failed to commit script"); return FALSE; } }
ResultType Clipboard::Set(LPCTSTR aBuf, UINT_PTR aLength) // Returns OK or FAIL. { // It was already open for writing from a prior call. Return failure because callers that do this // are probably handling things wrong: if (IsReadyForWrite()) return FAIL; if (!aBuf) { aBuf = _T(""); aLength = 0; } else if (aLength == UINT_MAX) // Caller wants us to determine the length. aLength = (UINT)_tcslen(aBuf); if (aLength) { if (!PrepareForWrite(aLength + 1)) return FAIL; // It already displayed the error. tcslcpy(mClipMemNewLocked, aBuf, aLength + 1); // Copy only a substring, if aLength specifies such. } // else just do the below to empty the clipboard, which is different than setting // the clipboard equal to the empty string: it's not truly empty then, as reported // by IsClipboardFormatAvailable(CF_TEXT) -- and we want to be able to make it truly // empty for use with functions such as ClipWait: return Commit(); // It will display any errors. }
bool TMuseumClipboard::AddItem( BMessage *theItem ) { if ( Lock() ) { // Clear clipboard data Clear(); // Get pointer to clipboard data BMessage *clipData = Data(); // Determine type of data being placed on clipboard switch( theItem->what) { case CUE_LIST_MSG: { clipData->AddPointer("CueList", theItem); } break; default: break; } // Inform clipboard to save data Commit(); Unlock(); } return true; }
void Manager::RefreshFrame(Frame *Refreshed) { _MANAGER(CleverSysLog clv(L"Manager::RefreshFrame(Frame *Refreshed)")); _MANAGER(SysLog(L"Refreshed=%p",Refreshed)); if (ActivatedFrame) return; if (Refreshed) { RefreshedFrame=Refreshed; } else { RefreshedFrame=CurrentFrame; } if (IndexOf(Refreshed)==-1 && IndexOfStack(Refreshed)==-1) return; /* $ 13.04.2002 KM - Вызываем принудительный Commit() для фрейма имеющего члена NextModal, это означает что активным сейчас является VMenu, а значит Commit() сам не будет вызван после возврата из функции. Устраняет ещё один момент неперерисовки, когда один над другим находится несколько объектов VMenu. Пример: настройка цветов. Теперь AltF9 в диалоге настройки цветов корректно перерисовывает меню. */ if (RefreshedFrame && RefreshedFrame->NextModal) Commit(); }
bool TOptsParser::ParseOptParam(const TOpt* opt, size_t pos) { YASSERT(opt); if (opt->HasArg_ == NO_ARGUMENT) { return Commit(opt, 0, pos, 0); } if (pos == Argc_) { if (opt->HasArg_ == REQUIRED_ARGUMENT) ythrow TUsageException() << "option " << opt->ToShortString() << " must have arg"; return Commit(opt, 0, pos, 0); } const TStringBuf arg(Argv_[pos]); if (!arg.has_prefix("-") || opt->HasArg_ == REQUIRED_ARGUMENT) { return Commit(opt, arg, pos + 1, 0); } return Commit(opt, 0, pos, 0); }
bool TOptsParser::ParseOptArg(size_t pos) { YASSERT(pos < Argc_); TStringBuf arg(Argv_[pos]); const EIsOpt eio = IsOpt(arg); YASSERT(EIO_NONE != eio); if (EIO_DDASH == eio || EIO_PLUS == eio || (Opts_->AllowSingleDashForLong_ || !Opts_->HasAnyShortOption())) { // long option bool singleCharPrefix = EIO_DDASH != eio; arg.Skip(singleCharPrefix ? 1 : 2); TStringBuf optionName = arg.NextTok('='); const TOpt* option = Opts_->FindLongOption(optionName); if (!option) { if (singleCharPrefix && !arg.IsInited()) { return ParseShortOptArg(pos); } else { ythrow TUsageException() << "unknown option '" << optionName << "' in '" << Argv_[pos] << "'"; } } if (arg.IsInited()) { if (option->HasArg_ == NO_ARGUMENT) ythrow TUsageException() << "option " << optionName << " must have no arg"; return Commit(option, arg, pos + 1, 0); } ++pos; return ParseOptParam(option, pos); } else { return ParseShortOptArg(pos); } }
void CLogger::Log(ELogLevel a_level, const std::string& a_message) { if((m_minLogLevel & (int)a_level) == 0) { return; } boost::posix_time::time_duration l_timestamp = (boost::posix_time::microsec_clock::local_time() - m_startTime); std::string l_entry = boost::str( boost::format("%08d [%08x] ") % l_timestamp.total_milliseconds() % boost::this_thread::get_id()) + a_message; m_lock.lock(); uint64_t l_logId = (m_logEntryId++); m_queue.push(boost::str(boost::format("%08d ") % l_logId) + l_entry); if(a_level == LL_CRITICAL) { Commit(); } m_lock.unlock(); }
/// <summary>Commits changes</summary> void PreferencesPage::OnOK() { // Save Commit(); __super::OnOK(); }
status_t Inode::Write(OpenFileCookie* cookie, off_t pos, const void* _buffer, size_t* _length) { ASSERT(cookie != NULL); ASSERT(_buffer != NULL); ASSERT(_length != NULL); struct stat st; status_t result = Stat(&st); if (result != B_OK) return result; if ((cookie->fMode & O_APPEND) != 0) pos = st.st_size; uint64 fileSize = max_c(st.st_size, pos + *_length); fMaxFileSize = max_c(fMaxFileSize, fileSize); if ((cookie->fMode & O_NOCACHE) != 0) { WriteDirect(cookie, pos, _buffer, _length); Commit(); } result = file_cache_set_size(fFileCache, fileSize); if (result != B_OK) return result; return file_cache_write(fFileCache, cookie, pos, _buffer, _length); }
BOOL CHashDatabase::StoreED2K(DWORD nIndex, CED2K* pSet) { CSingleLock pLock( &m_pSection, TRUE ); if ( m_bOpen == FALSE ) return FALSE; DWORD nLength = pSet->GetSerialSize(); HASHDB_INDEX* pIndex = PrepareToStore( nIndex, HASH_ED2K, nLength ); if ( pIndex == NULL ) return FALSE; try { m_pFile.Seek( pIndex->nOffset, 0 ); CArchive ar( &m_pFile, CArchive::store ); pSet->Serialize( ar ); } catch ( CException* pException ) { pException->Delete(); } Commit(); return TRUE; }
void BillboardSet::SetNumBillboards(unsigned num) { // Prevent negative value being assigned from the editor if (num > M_MAX_INT) num = 0; unsigned oldNum = billboards_.Size(); if (num == oldNum) return; billboards_.Resize(num); // Set default values to new billboards for (unsigned i = oldNum; i < num; ++i) { billboards_[i].position_ = Vector3::ZERO; billboards_[i].size_ = Vector2::ONE; billboards_[i].uv_ = Rect::POSITIVE; billboards_[i].color_ = Color(1.0f, 1.0f, 1.0f); billboards_[i].rotation_ = 0.0f; billboards_[i].direction_ = Vector3::UP; billboards_[i].enabled_ = false; billboards_[i].screenScaleFactor_ = 1.0f; } bufferSizeDirty_ = true; Commit(); }
BaseFormat& BaseFormat::Put(LPCWSTR Data, size_t Length) { if (MaxWidth == fmt::MaxWidth::GetDefault()) { MaxWidth = Length; } string OutStr(Data, std::min(MaxWidth, Length)); if (OutStr.size() < MinWidth) { if (Align == fmt::A_RIGHT) { OutStr.insert(0, MinWidth - OutStr.size(), FillChar); } else { OutStr.append(MinWidth - OutStr.size(), FillChar); } } Commit(OutStr); Reset(); return *this; }
BaseFormat& BaseFormat::Put(LPCWSTR Data, size_t Length) { if (Precision == fmt::Precision::GetDefault()) { Precision = Length; } string OutStr(Data, Min(Precision, Length)); if (Align == fmt::A_RIGHT) { while (OutStr.GetLength() < Width) { OutStr.Insert(0, FillChar); } } else { while (OutStr.GetLength() < Width) { OutStr.Append(FillChar); } } Commit(OutStr); Reset(); return *this; }
ResultType Clipboard::Set(LPCTSTR aBuf, UINT_PTR aLength) //, bool aTrimIt) // Returns OK or FAIL. { // It was already open for writing from a prior call. Return failure because callers that do this // are probably handling things wrong: if (IsReadyForWrite()) return FAIL; if (!aBuf) { aBuf = _T(""); aLength = 0; } else if (aLength == UINT_MAX) // Caller wants us to determine the length. aLength = (UINT)_tcslen(aBuf); if (aLength) { if (!PrepareForWrite(aLength + 1)) return FAIL; // It already displayed the error. tcslcpy(mClipMemNewLocked, aBuf, aLength + 1); // Copy only a substring, if aLength specifies such. // Only trim when the caller told us to, rather than always if g_script.mIsAutoIt2 // is true, since AutoIt2 doesn't always trim things (e.g. FileReadLine probably // does not trim the line that was read into its output var). UPDATE: This is // no longer needed because I think AutoIt2 only auto-trims when SetEnv is used: //if (aTrimIt) // trim(mClipMemNewLocked); } // else just do the below to empty the clipboard, which is different than setting // the clipboard equal to the empty string: it's not truly empty then, as reported // by IsClipboardFormatAvailable(CF_TEXT) -- and we want to be able to make it truly // empty for use with functions such as ClipWait: return Commit(); // It will display any errors. }
DatabaseManager::~DatabaseManager() { Commit(); mdatabase.close(); if (mptableModel != NULL){ mptableModel->deleteLater(); mptableModel = NULL; } if (mptableModelStr != NULL){ mptableModelStr->deleteLater(); mptableModelStr = NULL; } if (mptableModelRes != NULL){ mptableModelRes->deleteLater(); mptableModelRes = NULL; } if (mptableModelPak != NULL){ mptableModelPak->deleteLater(); mptableModelPak = NULL; } if (mptableModelAppPak != NULL){ mptableModelAppPak->deleteLater(); mptableModelAppPak = NULL; } }
void RGB_Tlc5940::CycleSpectrum() { byte rgbColour[3]; // Start off with red. rgbColour[0] = 255; rgbColour[1] = 0; rgbColour[2] = 0; // Choose the colours to increment and decrement. for (byte decColour = 0; decColour < 3; decColour++) { int incColour = decColour == 2 ? 0 : decColour + 1; // cross-fade the two colours. for(byte i = 0; i < 255; i++) { rgbColour[decColour] -= 1; rgbColour[incColour] += 1; for(byte j=0; j<_numLeds; j++) { WriteRGB(j, rgbColour[0], rgbColour[1], rgbColour[2], false); } Commit(); delay(15); } } }
void YCTaskDB2::UpdateTaskRequest(TaskReqInfo& task_req) throw(base::Exception) { XDBO2::CRecordset rs(&m_CDB); rs.EnableWarning(true); std::string sql = "UPDATE " + m_tabTaskReq + " SET TASK_STATUS = ?, STATUS_DESC = ?, TASK_FINISHTIME = ?, TASK_DESC = ? WHERE SEQ_ID = ?"; m_pLog->Output("[DB2] Update task request [%d]", task_req.seq_id); try { rs.Prepare(sql.c_str(), XDBO2::CRecordset::forwardOnly); int index = 1; rs.Parameter(index++) = task_req.status.c_str(); rs.Parameter(index++) = task_req.status_desc.c_str(); rs.Parameter(index++) = task_req.finishtime.c_str(); rs.Parameter(index++) = task_req.desc.c_str(); rs.Parameter(index++) = task_req.seq_id; rs.Execute(); Commit(); rs.Close(); } catch ( const XDBO2::CDBException& ex ) { throw base::Exception(TDB_ERR_UPD_TASK_REQ, "[DB2] Update task request to table '%s' failed! [SEQ:%d, KPI_ID:%s] [CDBException] %s [FILE:%s, LINE:%d]", m_tabTaskReq.c_str(), task_req.seq_id, task_req.kpi_id.c_str(), ex.what(), __FILE__, __LINE__); } }
CAutoTrans::~CAutoTrans(void) { try { const int curr_TranCount = GetTranCount(); if (curr_TranCount >= m_TranCount) { if (curr_TranCount > m_TranCount) { // A nested transaction is started and not finished yet ... ERR_POST_X(1, Warning << "A nested transaction was started and " "it is not finished yet."); } // Assume that we are on the same level of transaction nesting. if(m_Abort) { Rollback(); } else { Commit(); } } // Skip commit/rollback if this transaction was previously // explicitly finished ... } NCBI_CATCH_ALL_X( 10, NCBI_CURRENT_FUNCTION ) }
void CustomGeometry::SetGeometryDataAttr(const PODVector<unsigned char>& value) { if (value.Empty()) return; MemoryBuffer buffer(value); SetNumGeometries(buffer.ReadVLE()); elementMask_ = buffer.ReadUInt(); for (unsigned i = 0; i < geometries_.Size(); ++i) { unsigned numVertices = buffer.ReadVLE(); vertices_[i].Resize(numVertices); primitiveTypes_[i] = (PrimitiveType)buffer.ReadUByte(); for (unsigned j = 0; j < numVertices; ++j) { if (elementMask_ & MASK_POSITION) vertices_[i][j].position_ = buffer.ReadVector3(); if (elementMask_ & MASK_NORMAL) vertices_[i][j].normal_ = buffer.ReadVector3(); if (elementMask_ & MASK_COLOR) vertices_[i][j].color_ = buffer.ReadUInt(); if (elementMask_ & MASK_TEXCOORD1) vertices_[i][j].texCoord_ = buffer.ReadVector2(); if (elementMask_ & MASK_TANGENT) vertices_[i][j].tangent_ = buffer.ReadVector4(); } } Commit(); }
std::string SvgDeviceContext::GetStringSVG( bool xml_tag ) { if (!m_committed) Commit( xml_tag ); return m_outdata.str(); }
//--------------------------------------------------------------------------- TSessionAction::~TSessionAction() { if (FRecord != nullptr) { Commit(); } }
void RefactoringStorage::StoreTokens(const wxString& filename, const CppToken::List_t& tokens, bool startTx) { if ( !IsCacheReady() ) { return; } if ( !m_db.IsOpen() ) return; try { if ( startTx ) { Begin(); } DoDeleteFile(filename); CppToken::List_t::const_iterator iter = tokens.begin(); for(; iter != tokens.end(); ++iter ) { iter->store( &m_db ); } DoUpdateFileTimestamp(filename); if ( startTx ) { Commit(); } } catch (wxSQLite3Exception &e) { if ( startTx ) { Rollback(); } wxUnusedVar(e); } }
void Manager::ExecuteModal(window_ptr_ref Executed) { _MANAGER(CleverSysLog clv(L"Manager::ExecuteModal (window *Executed)")); _MANAGER(SysLog(L"Executed=%p",Executed)); bool stop=false; auto& stop_ref=m_Executed[Executed]; if (stop_ref) return; stop_ref=&stop; auto OriginalStartManager = StartManager; StartManager = true; for (;;) { Commit(); if (stop) { break; } ProcessMainLoop(); } StartManager = OriginalStartManager; return;// GetModalExitCode(); }
TaskResult Char(const KeyInfo& info) override{ auto handleKeyPress = [&](){ m_autoComplete.Forget(); return handle_key_press(info.key, m_textObject->GetTextBuffer()) ? TaskResult::DRAW : TaskResult::NONE; }; if (is_exit_key(info.key)){ return Commit(info.layerType); } else if (info.key.Is(key::tab) && m_settings.Get(ts_ParseExpressions)){ return handle_completion(m_autoComplete, m_textObject->GetTextBuffer()) ? TaskResult::DRAW : handleKeyPress(); } return handle_command_key(info.key, m_textObject).Visit( [&](TextChange& cmd){ m_autoComplete.Forget(); // Fixme: Need to support undo cmd.Do(); m_states.Did(cmd); return TaskResult::DRAW; }, handleKeyPress); }