void MovieRecorderImpl::setupOnlineModeRecording() { timeBarConnections.disconnect(); isBeforeFirstFrameCapture = true; nextFrameTime = startTime; if(timeBar->isDoingPlayback()){ startOnlineModeRecording(); } else { timeBarConnections.add( timeBar->sigPlaybackStarted().connect( std::bind(&MovieRecorderImpl::onPlaybackStarted, this, std::placeholders::_1))); mv->putln(format(_("The online mode recording for %1% is ready.")) % targetView->name()); } }
void firstExtent(const Extent &e) { const ExtentType::Ptr type = e.getTypePtr(); if (type->versionCompatible(0,0) || type->versionCompatible(1,0)) { reqtime.setFieldName("packet-at"); is_request.setFieldName("is-request"); transaction_id.setFieldName("transaction-id"); op_id.setFieldName("op-id"); } else if (type->versionCompatible(2,0)) { reqtime.setFieldName("packet_at"); is_request.setFieldName("is_request"); transaction_id.setFieldName("transaction_id"); op_id.setFieldName("op_id"); } else { FATAL_ERROR(format("can only handle v[0,1,2].*; not %d.%d") % type->majorVersion() % type->minorVersion()); } }
object require::load_relative_module(std::string id) { fs::path module(current_id().substr(sizeof("file://")-1)); module = io::fs_base::canonicalize( module.parent_path() / (id + ".js") ); id = module.string(); fs::path dso_path = make_dsoname(module.string()); id = "file://" + id; std::string const dso_id = "file://" + dso_path.string(); // If either of the JS or DSO is already cached then just return it if (module_cache.has_own_property(id) ) return module_cache.get_property_object(id); else if (module_cache.has_own_property(dso_id) ) return module_cache.get_property_object(dso_id); bool js = false, dso = false; security &sec = security::get(); if (sec.check_path(module.string(), security::READ) && fs::exists(module)) { js = true; } if (sec.check_path(dso_path.string(), security::READ) && fs::exists(dso_path)) { dso = true; } if (!js && !dso) throw exception(format(load_error_fmt) % id % "file not found"); else if (!js) id = dso_id; ExportsScopeGuard scope_guard(module_cache, id); // The object we store in module_cache object cache = create_cache_entry(id); if (dso) load_native_module(dso_path, cache.get_property_object("exports")); if (js) require_js(module, id, cache); scope_guard.exit_cleanly(); return cache; }
void LintelLog::debugMessagesInitial() { static Category help("help"); if (wouldDebug(help)) { vector<string> debug_names; instance->mutex.lock(); for(HashMap<string, uint32_t>::iterator i = instance->category2id.begin(); i != instance->category2id.end(); ++i) { debug_names.push_back(i->first); } instance->mutex.unlock(); sort(debug_names.begin(), debug_names.end()); LintelLogDebugLevelVariable(help, 1, format("known debugging options: %s") % join(", ", debug_names)); } }
BamWriter::BamWriter(std::string const& path, bam_header_t const* header, bool sam /*= false*/) : out_(samopen(path.c_str(), sam ? "wh" : "wb", header)) { if (!out_) { throw std::runtime_error(str(format( "Failed to open output file %1%" ) % path)); } /* if (sam && (fwrite(header->text, 1, header->l_text, out_->x.tamw) != header->l_text)) { throw std::runtime_error(str(format( "Failed to write sam header to file %1%" ) % path)); } */ }
object base_parser::parse(value source) { if (source.is_object()) { object o = source.get_object(); if (is_native<io::stream>(o)) { io::stream &s = flusspferd::get_native<io::stream>(o); // TODO: Work out if the stream is readable or not! std::ifstream stream; dynamic_cast<std::ios&>(stream).rdbuf( s.streambuf() ); sax_source is; is.setByteStream(stream); return parse_source(is); } /*else if (is_native<binary>(o)) { // Couldn't get this working. Compile errors binary &b = flusspferd::get_native<flusspferd::binary>(o); call_context c; c.arg.push_back(b); create<io::binary_stream>(c); root_object s(b_s); std::ifstream stream; dynamic_cast<std::ios&>(stream).rdbuf( b_s.streambuf() ); sax_source is; is.setByteStream(stream); return parse_source(is); }*/ } std::string str = source.to_std_string(); security &sec = security::get(); if (!sec.check_path(str, security::READ)) { throw exception( format("xml.Parser#parse: could not open file: 'denied by security' (%s)") % str ); } sax_source is; is.setSystemId(str); return parse_source(is); }
void MovieRecorderImpl::startOnlineModeRecording() { timeBarConnections.disconnect(); timeBarConnections.add( timeBar->sigTimeChanged().connect( std::bind(&MovieRecorderImpl::onTimeChanged, this, std::placeholders::_1))); timeBarConnections.add( timeBar->sigPlaybackStopped().connect( std::bind(&MovieRecorderImpl::onPlaybackStopped, this, std::placeholders::_2))); isRecording = true; startImageOutput(); mv->putln(format(startMessage) % targetView->name() % recordingMode.selectedLabel()); }
static void WINAPI service_main(DWORD argc, LPWSTR *wargv) { auto status_handle = RegisterServiceCtrlHandlerEx(DESPOOF_WIDE_SERVICE_NAME, control_handler, NULL); if(!status_handle) { throw_windows_error("RegisterServiceCtrlHandlerEx"); } SERVICE_STATUS status = {0}; status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; status.dwCurrentState = SERVICE_RUNNING; status.dwControlsAccepted = 0; SetServiceStatus(status_handle, &status); bool start; try { utf_argv uargv(argc, wargv); if(!despoof::init(argc, uargv.argv(), ctx)) { return; } } catch(exception &ex) { // PANIC status.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR; status.dwServiceSpecificExitCode = 1; status.dwCurrentState = SERVICE_STOPPED; SetServiceStatus(status_handle, &status); } status.dwControlsAccepted = accepted_controls; SetServiceStatus(status_handle, &status); try { list<adapter_address> addresses = ctx->reload(); while(keep_running) { ctx->iterate(addresses); } } catch(exception &ex) { ctx->log().fail(format("%1%: %2%") % typeid(ex).name() % ex.what()); status.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR; status.dwServiceSpecificExitCode = 1; } status.dwCurrentState = SERVICE_STOPPED; SetServiceStatus(status_handle, &status); }
void Neurons::set(size_t n, unsigned nargs, const float args[]) { using boost::format; if(nargs != m_param.size() + m_state.size()) { throw nemo::exception(NEMO_INVALID_INPUT, str(format("Unexpected number of parameters/state variables when modifying neuron. Expected %u, found %u") % (m_param.size() + m_state.size()) % nargs)); } for(unsigned i=0; i < m_param.size(); ++i) { m_param[i][n] = *args++; } for(unsigned i=0; i < m_state.size(); ++i) { m_state[i][n] = *args++; } }
virtual void printResult() { cout << format("Begin-%s\n") % __PRETTY_FUNCTION__; cout << "common bytes:"; for (int i=0;i<max_seen_fh_size;++i) { if (commonbytes[i]) { cout << format("%d ") % i; } } cout << "\n"; for (int i=0;i<max_seen_fh_size/4;++i) { cout << format("quad %d: ") % i; if (used_ints[i].size() >= max_used_count) { cout << format("> %d used\n") % used_ints[i].size(); } else { cout << format("%d used: ") % used_ints[i].size(); if (used_ints[i].size() < 50) { for (map<uint32_t,bool>::iterator j = used_ints[i].begin(); j != used_ints[i].end();++j) { cout << format("%08x, ") % j->first; } } cout << "\n"; } } cout << format("%d mount entries\n") % fh2mount.size(); for (fh2mountT::iterator i = fh2mount.begin(); i != fh2mount.end();++i) { if (i->common_bytes_seen_count > 0) { INVARIANT(i->fullfh.size() >= 32,("unhandled")); const ExtentType::int32 *v = (const ExtentType::int32 *)i->fullfh.data(); cout << format("mount %13s:%s seen %4d times; quads(0,1,6,7): %08x %08x %08x %08x\n") % ipv4tostring(i->server) % maybehexstring(i->pathname) % i->common_bytes_seen_count % v[0] % v[1] % v[6] % v[7]; } } cout << format("End-%s\n") % __PRETTY_FUNCTION__; }
std::string& PrintScopeVariableInfo(const D3D10_SHADER_DEBUG_INFO* pDebugInfo, UINT nVariable, std::string& strVariableInfo) { if (nVariable >= pDebugInfo->Variables) { strVariableInfo = ""; return strVariableInfo; } char* pszDebugInfo = (char*) pDebugInfo; char* pszDebugDataOffset = pszDebugInfo + pDebugInfo->Size; // char* pszStringTable = pszDebugDataOffset + pDebugInfo->StringOffset; D3D10_SHADER_DEBUG_SCOPEVAR_INFO* pVariableInfo = (D3D10_SHADER_DEBUG_SCOPEVAR_INFO*)(pszDebugDataOffset + pDebugInfo->ScopeVariableInfo + (nVariable * sizeof(D3D10_SHADER_DEBUG_SCOPEVAR_INFO))); std::string strTokenInfo; strVariableInfo = str(format("%s (%s, %s)") % PrintTokenInfo(pDebugInfo, pVariableInfo->TokenId, strTokenInfo) % pszDebugVarType[pVariableInfo->VarType] % pszVarClass[pVariableInfo->Class]); return strVariableInfo; }
int main( ) { try { format f("There are %1% ways %2% %3% %4%"); f % 3; f % "to" % "do" % "this."; cout << f << endl; f.clear( ); // Clear buffers to format something else f.parse("Those cost $%d."); f % 50; cout << f << endl; int x = 11256099; string strx = str(format("%x") % x); cout << strx << endl; } catch (format_error &e) { cout << e.what( ) << endl; } }
void MJPFileComparator::printEntriesMissingInCustomFiles() const { auto missingEntries = getEntriesMissingInCustomFiles(); if (!missingEntries.empty()) { printTitle((format("Verifying whether all entries from file %s are present in the custom files.")%foxBeleidFile.getPath().filename()).str()); for (auto& entry : missingEntries) { cout << "Could not find following key in custom mjp file: " << entry.getKey() << "\n"; auto possibleMatches = findPossibleMatches(foxBeleidFile, entry); printPossibleMatches(possibleMatches, entry); } } else { printTitle("All entries from the foxbeleid file are present in the custom files!"); } }
void rotate_stores() { std::cout << "Rotating store " << store_file << "..." << std::endl; std::cout << "Rotating store call flush " << store_file << "..." << std::endl; fflush(stdout); try { store->flush(true); } catch (klio::StoreException const& ex) { std::cout << "Failed to flush the buffers : " << ex.what() << std::endl; } std::cout << "Rotating store flushed " << store_file << "..." << std::endl; fflush(stdout); std::cout << "Reopening store" << std::endl; const boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); std::string s; s= str( format("%04d%02d%02d-%02d%02d") % now.date().year_month_day().year % now.date().year_month_day().month.as_number() % now.date().year_month_day().day.as_number() % now.time_of_day().hours() % now.time_of_day().minutes()); std::string name(store_file.string()); name+="."; name+=s; bfs::path dbname(name); std::cout << "===> renaming to: "<< name<<std::endl; fflush(stdout); try { store->rotate(dbname); } catch (klio::StoreException const& ex) { std::cout << "Failed to rotate the klio-databse : " << ex.what() << std::endl; } #if KLIO_AUTOCOMMIT store->start_transaction(); #endif std::cout << "Rotation done" << std::endl; }
bool SubProjectItemImpl::loadSubProject(const std::string& filename) { if(projectFilesBeingLoaded.find(filename) != projectFilesBeingLoaded.end()){ MessageView::instance()->putln( format(_("Sub projects to load \"%1%\" are recursively specified.")) % filename, MessageView::ERROR); return false; } if(self->isConnectedToRoot()){ doLoadSubProject(filename); return true; } else { projectFileToLoad = filename; return true; } return false; }
void updateDuplicateRequest(TidData *t) { // this check is here in case we are somehow getting duplicate // packets delivered by the monitoring process, and we want to // catch this and not think that we have realy lots of // duplicate requests. Tried 50ms, but found a case about 5ms // apart, so dropped to 2ms // inter arrival time int64_t request_iat = reqtime.valRaw() - t->last_reqtime_raw; if (request_iat < duplicate_request_min_retry_raw) { cerr << format("warning: duplicate requests unexpectedly close together %s - %s = %s >= %s\n") % reqtime.valStrSecNano() % reqtime.rawToStrSecNano(t->last_reqtime_raw) % reqtime.rawToStrSecNano(request_iat) % reqtime.rawToStrSecNano(duplicate_request_min_retry_raw); } ++t->duplicate_count; duplicate_request_delay.add(request_iat/(1000.0*1000.0)); t->last_reqtime_raw = reqtime.valRaw(); }
std::string& PrintScopeInfo(const D3D10_SHADER_DEBUG_INFO* pDebugInfo, UINT nScope, std::string& strScopeInfo) { if (nScope >= pDebugInfo->Scopes) { strScopeInfo = ""; return strScopeInfo; } char* pszDebugInfo = (char*) pDebugInfo; char* pszDebugDataOffset = pszDebugInfo + pDebugInfo->Size; char* pszStringTable = pszDebugDataOffset + pDebugInfo->StringOffset; D3D10_SHADER_DEBUG_SCOPE_INFO* pScopeInfo = (D3D10_SHADER_DEBUG_SCOPE_INFO*)(pszDebugDataOffset + pDebugInfo->ScopeInfo + (nScope * sizeof(D3D10_SHADER_DEBUG_SCOPE_INFO))); std::string strScopeName((pszStringTable + pScopeInfo->Name), pScopeInfo->uNameLen); strScopeInfo = str(format("%s (%s, %i Variables)") % strScopeName % pszScopeType[pScopeInfo->ScopeType] % pScopeInfo->uVariables); return strScopeInfo; }
type formatini ( std::string in, boost::property_tree::ptree pt ) { std::vector<int> findvec; int find = 0; while ( find != -1 ) { find = in.find( "$", find+1 ); if ( find != -1 ) { findvec.push_back ( find ); } else { break; } } std::vector<std::string> valvec; for ( size_t x = 0; x != findvec.size ( ) - 1; x++ ) { if ( x == findvec.size ( ) ) { break; } int y = findvec [ x ]; std::string buff = misc::getSubStr ( in, y, '}' ); misc::remove( buff, "$" ); misc::remove( buff, "{" ); misc::remove( buff, "}" ); valvec.push_back ( buff ); } misc::removechar ( in, '"' ); misc::removechar ( in, '"' ); for ( size_t x = 0; x != valvec.size ( ); x++ ) { std::string y = valvec [ x ]; type buff = pt.get<type> ( y ); misc::removechar ( buff, '"' ); misc::removechar ( buff, '"' ); std::string valrep = str ( format( "${%1%}" ) % y ); in.replace ( in.find( valrep ), valrep.length ( ), buff ); } return in; }
bool mmfile::resize(size_t new_size) { // Resize underlying file. if (ftruncate(file_handle_, new_size) == -1) { handle_error("resize", filename_); return false; } const auto message = format("Resizing: %1% [%2%]") % filename_ % new_size; log::debug(LOG_DATABASE) << message.str(); // Readjust memory map. #ifdef MREMAP_MAYMOVE return remap(new_size); #else return (unmap() && map(new_size)); #endif }
void UserRulesEditorFrame::OnRuleCreate(wxCommandEvent& event) { try { Rule newRule = GetRuleFromForm(); RulesList->AppendRule(newRule); } catch (boss_error &e) { wxMessageBox( FromUTF8(format(loc::translate("Rule Syntax Error: %1% Please correct the mistake before continuing.")) % e.getString()), translate("BOSS: Error"), wxOK | wxICON_ERROR, NULL); } if (!game.userlist.Rules().empty()) { SaveEditedRuleButton->Enable(); DeleteRuleButton->Enable(); MoveRuleUpButton->Enable(); MoveRuleDownButton->Enable(); } }
void VBri::updateRating() { if (!masklist.size()) return; if (w_view1->layers.size()==2) w_view1->layers.pop_back(); w_view1->SetMask(*(cubemap[maskptr->imgname])); // scroll img to correct location for this lesion w_view1->NewXSlice(maskptr->xslice); w_view1->NewYSlice(maskptr->yslice); w_view1->NewZSlice(maskptr->zslice); // make sure the vbview origin is set to the lesion origin w_view1->base_origin[0]=cubemap[maskptr->imgname]->origin[0]; w_view1->base_origin[1]=cubemap[maskptr->imgname]->origin[1]; w_view1->base_origin[2]=cubemap[maskptr->imgname]->origin[2]; w_rating->setSliderPosition(maskptr->rating); w_ratingnotes->setText(maskptr->notes.c_str()); string tmp=(format("mask %d of %d")%currentindex%masklist.size()).str(); w_maskname->setText(tmp.c_str()); }
size_t Neurons::add(unsigned gidx, unsigned nargs, const float args[]) { using boost::format; if(nargs != m_param.size() + m_state.size()) { throw nemo::exception(NEMO_INVALID_INPUT, str(format("Unexpected number of parameters/state variables when adding neuron. Expected %u, found %u") % (m_param.size() + m_state.size()) % nargs)); } for(unsigned i=0; i < m_param.size(); ++i) { m_param[i].push_back(*args++); } for(unsigned i=0; i < m_state.size(); ++i) { m_state[i].push_back(*args++); } m_gidx.push_back(gidx); return m_size++; }
static std::string format_setting(const parameter& value, const std::string& name) { // A required argument may only be preceeded by required arguments. // Requiredness may be in error if the metadata is inconsistent. auto required = value.get_required(); // In terms of formatting we also treat multivalued as not required. auto optional = value.get_args_limit() == 1; std::string formatter; if (required) formatter = BC_PRINTER_SETTING_REQUIRED_FORMAT; else if (optional) formatter = BC_PRINTER_SETTING_OPTIONAL_FORMAT; else formatter = BC_PRINTER_SETTING_MULTIPLE_FORMAT; return (format(formatter) % name % BC_PRINTER_VALUE_TEXT).str(); }
bool ParametricPathProcessorImpl::replaceDirectoryVariable (string& io_pathString, const string& varname, int pos, int len) { Listing* paths = variables->findListing(varname); if(paths){ for(int i=0; i < paths->size(); ++i){ string vpath; string replaced(io_pathString); replaced.replace(pos, len, paths->at(i)->toString()); filesystem::file_status fstatus = filesystem::status(filesystem::path(replaced)); if(filesystem::is_directory(fstatus) || filesystem::exists(fstatus)) { io_pathString = replaced; return true; } } } errorMessage = str(format(_("%1% of \"%2%\" cannot be expanded.")) % varname % io_pathString); return false; }
int showcruft(const shared_ptr<EncFS_Root> &rootInfo, const char *dirName) { int found = 0; DirTraverse dt = rootInfo->root->openDir(dirName); if (dt.valid()) { bool showedDir = false; for (string name = dt.nextInvalid(); !name.empty(); name = dt.nextInvalid()) { string cpath = rootInfo->root->cipherPath(dirName); cpath += '/'; cpath += name; if (!showedDir) { // just before showing a list of files in a directory cout << format(_("In directory %s: \n")) % dirName; showedDir = true; } ++found; cout << cpath << "\n"; } // now go back and look for directories to recurse into.. dt = rootInfo->root->openDir(dirName); if (dt.valid()) { for (string name = dt.nextPlaintextName(); !name.empty(); name = dt.nextPlaintextName()) { if (name == "." || name == "..") continue; string plainPath = dirName; plainPath += '/'; plainPath += name; string cpath = rootInfo->root->cipherPath(plainPath.c_str()); if (isDirectory(cpath.c_str())) found += showcruft(rootInfo, plainPath.c_str()); } } } return found; }
bool MovieRecorderImpl::setupViewAndFilenameFormat() { if(!targetView){ showWarningDialog(_("Target view is not specified.")); return false; } filesystem::path directory(dialog->directoryEntry.string()); filesystem::path basename(dialog->basenameEntry.string() + "%08u.png"); if(directory.empty()){ showWarningDialog(_("Please set a directory to output image files.")); return false; } else { if(filesystem::exists(directory)){ if(!filesystem::is_directory(directory)){ showWarningDialog(fmt(_("%1% is not a directory.")) % directory); return false; } } else { filesystem::create_directories(directory); } } filenameFormat = format((directory / basename).string()); if(dialog->imageSizeCheck.isChecked()){ int width = dialog->imageWidthSpin.value(); int height = dialog->imageHeightSpin.value(); QSize s = targetView->size(); int x = (s.width() - width) / 2; int y = (s.height() - height) / 2; targetView->setGeometry(x, y, width, height); } std::lock_guard<std::mutex> lock(imageQueueMutex); capturedImages.clear(); return true; }
void TaskViewImpl::addTask(Task* task) { taskCombo.blockSignals(true); if(tasks.empty()){ taskCombo.clear(); } tasks.push_back(TaskInfo(task)); taskCombo.addItem(task->name().c_str()); taskCombo.blockSignals(false); sigTaskAdded(task); if(tasks.size() == 1){ setCurrentTask(0, true); } os << format(_("Task \"%1%\" has been added.")) % task->name() << endl; }
void ChunkedFile::open(string const& filename, string const& mode) { // Check if file is already open if (file_) throw BagIOException((format("File already open: %1%") % filename_.c_str()).str()); // Open the file if (mode == "r+b") { // check if file already exists #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) fopen_s( &file_, filename.c_str(), "r" ); #else file_ = fopen(filename.c_str(), "r"); #endif if (file_ == NULL) // create an empty file and open it for update #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) fopen_s( &file_, filename.c_str(), "w+b" ); #else file_ = fopen(filename.c_str(), "w+b"); #endif else {
int wmain(int argc, wchar_t **wargv) { bool success; try { utf_argv uargv(argc, wargv); if(!despoof::init(argc, uargv.argv(), ctx)) { return 0; } } catch(exception &e) { fprintf(stderr, "Error (%s): %s\n", typeid(e).name(), e.what()); throw; } try { run(); return 0; } catch(exception &e) { ctx->log().fail(format("%1%: %2%") % typeid(e).name() % e.what()); throw; } }
void UserRulesEditorFrame::OnRuleEdit(wxCommandEvent& event) { wxMessageDialog *dlg = new wxMessageDialog(this, translate("Are you sure you want to save your changes to the selected rule?"), translate("BOSS: User Rules Manager"), wxYES_NO); if (dlg->ShowModal() != wxID_YES) //User has chosen not to save. return; else { //User has chosen to save. try { Rule newRule = GetRuleFromForm(); RulesList->SaveEditedRule(newRule); } catch (boss_error &e) { wxMessageBox( FromUTF8(format(loc::translate("Rule Syntax Error: %1% Please correct the mistake before continuing.")) % e.getString()), translate("BOSS: Error"), wxOK | wxICON_ERROR, NULL); } } }