int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args(argc, argv) != 0) return 1; try { ACE_Argv_Type_Converter converter(argc, argv); CORBA::ORB_var orb = CORBA::ORB_init(converter.get_argc(), converter.get_ASCII_argv(), ""); CORBA::Object_var tmp = orb->string_to_object (ACE_TEXT_ALWAYS_CHAR(ior)); OpenDDS::DCPS::DCPSInfo_var info = OpenDDS::DCPS::DCPSInfo::_narrow (tmp.in ()); if (CORBA::is_nil(info.in()) ) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil OpenDDS::DCPS::DCPSInfo reference <%s>\n", ior), 1); } OPENDDS_STRING state = info->dump_to_string(); std::cout << state.c_str() << std::endl; // clean up the orb orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught in publisher.cpp:"); return 1; } return 0; }
bool AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest, const mozilla::fallible_t& ) { nsACString::const_iterator source_start, source_end; CalculateUTF8Length calculator; copy_string(aSource.BeginReading(source_start), aSource.EndReading(source_end), calculator); uint32_t count = calculator.Length(); // Avoid making the string mutable if we're appending an empty string if (count) { uint32_t old_dest_length = aDest.Length(); // Grow the buffer if we need to. if (!aDest.SetLength(old_dest_length + count, mozilla::fallible_t())) { return false; } // All ready? Time to convert ConvertUTF8toUTF16 converter(aDest.BeginWriting() + old_dest_length); copy_string(aSource.BeginReading(source_start), aSource.EndReading(source_end), converter); NS_ASSERTION(converter.ErrorEncountered() || converter.Length() == count, "CalculateUTF8Length produced the wrong length"); if (converter.ErrorEncountered()) { NS_ERROR("Input wasn't UTF8 or incorrect length was calculated"); aDest.SetLength(old_dest_length); } } return true; }
int OpenDDS::DCPS::TransportImpl::add_pending_association( RepoId local_id, const AssociationInfo& info) { DBG_ENTRY_LVL("TransportImpl","add_pending_association",6); GuardType guard(this->lock_); // Cache the Association data so it can be used for the callback // to notify datawriter on_publication_matched. PendingAssociationsMap::iterator iter = pending_association_sub_map_.find(local_id); if (iter != pending_association_sub_map_.end()) iter->second->push_back(info); else { AssociationInfoList* infos = new AssociationInfoList; infos->push_back(info); if (OpenDDS::DCPS::bind(pending_association_sub_map_, local_id, infos) == -1) { OpenDDS::DCPS::RepoIdConverter converter(local_id); ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: TransportImpl::add_pending_association: ") ACE_TEXT("failed to add pending associations for pub %C\n"), std::string(converter).c_str()),-1); } } // Acks for this new pending association may arrive at this time. // If check for individual association, it needs remove the association // from pending_association_sub_map_ so the fully_associated won't be // called multiple times. To simplify, check by pub id since the // check_fully_association overloaded function clean the pending list // after calling fully_associated. check_fully_association(local_id); return 0; }
nsresult nsGopherChannel::PushStreamConverters(nsIStreamListener *listener, nsIStreamListener **result) { nsresult rv; nsCOMPtr<nsIStreamListener> converterListener; nsCOMPtr<nsIStreamConverterService> StreamConvService = do_GetService(kStreamConverterServiceCID, &rv); if (NS_FAILED(rv)) return rv; // What we now do depends on what type of file we have if (mType=='1' || mType=='7') { // Send the directory format back for a directory rv = StreamConvService->AsyncConvertData("text/gopher-dir", APPLICATION_HTTP_INDEX_FORMAT, listener, mUrl, getter_AddRefs(converterListener)); if (NS_FAILED(rv)) return rv; } else if (mType=='0') { // Convert general file rv = StreamConvService->AsyncConvertData("text/plain", "text/html", listener, mListenerContext, getter_AddRefs(converterListener)); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsITXTToHTMLConv> converter(do_QueryInterface(converterListener)); if (converter) { nsCAutoString spec; rv = mUrl->GetSpec(spec); converter->SetTitle(NS_ConvertUTF8toUCS2(spec).get()); converter->PreFormatHTML(PR_TRUE); } } NS_IF_ADDREF(*result = converterListener); return NS_OK; }
// This test covers the case when the hdf5 file contains more than 3 variables void TestMeshalyzerConversionLotsOfVariables() throw(Exception) { std::string output_dir = "TestHdf5Converters_TestMeshalyzerConversionLotsOfVariables"; /* * Firstly, copy the .h5 file to CHASTE_TEST_OUTPUT/TestHdf5ToMeshalyzerConverter, * as that is where the reader reads from. */ CopyToTestOutputDirectory("heart/test/data/many_variables/many_variables.h5", output_dir); TrianglesMeshReader<1,1> mesh_reader("heart/test/data/many_variables/1D_65_elements"); TetrahedralMesh<1,1> mesh; mesh.ConstructFromMeshReader(mesh_reader); // Convert Hdf5ToMeshalyzerConverter<1,1> converter(FileFinder(output_dir, RelativeTo::ChasteTestOutput), "many_variables", &mesh, true); std::vector<std::string> variable_names; variable_names.push_back("V"); variable_names.push_back("I_ks"); variable_names.push_back("I_kr"); variable_names.push_back("I_Ca_tot"); variable_names.push_back("I_tot"); variable_names.push_back("I_Na_tot"); std::string test_output_directory = OutputFileHandler::GetChasteTestOutputDirectory(); for (unsigned i=0; i<variable_names.size(); i++) { // Compare the results files FileComparison(test_output_directory + "/" + output_dir + "/output/many_variables_" + variable_names[i] + ".dat", "heart/test/data/many_variables/many_variables_" + variable_names[i] + ".dat").CompareFiles(); } // Compare the time information file FileComparison(test_output_directory + output_dir + "/output/many_variables_times.info", "heart/test/data/many_variables/many_variables_times.info").CompareFiles(); }
static unsigned pcmreader_error_read(struct PCMReader *self, unsigned pcm_frames, int *pcm_data) { if (self->input.error.total_pcm_frames) { const register unsigned bytes_per_sample = self->bits_per_sample / 8; pcm_to_int_f converter = self->input.error.converter; const unsigned pcm_frames_to_read = MIN(pcm_frames, self->input.error.total_pcm_frames); const unsigned bytes_to_read = pcm_frames_to_read * bytes_per_sample * self->channels; unsigned char buffer[bytes_to_read]; const size_t bytes_read = fread(buffer, sizeof(unsigned char), bytes_to_read, self->input.error.file); const unsigned pcm_frames_read = bytes_read / bytes_per_sample / self->channels; /*cull partial PCM frames*/ const unsigned samples_read = pcm_frames_read * self->channels; converter(samples_read, buffer , pcm_data); self->input.error.total_pcm_frames -= pcm_frames_to_read; return pcm_frames_read; } else { self->status = PCM_READ_ERROR; return 0; } }
/** * Loads the specified save. * @param action Pointer to an action. */ void ListLoadOriginalState::btnSlotClick(Action *action) { int n = 0; for (int i = 0; i < SaveConverter::NUM_SAVES; ++i) { if (action->getSender() == _btnSlot[i]) { n = i; break; } } if (_saves[n].id > 0) { if (_saves[n].tactical) { std::wostringstream error; error << tr("STR_LOAD_UNSUCCESSFUL") << L'\x02' << L"Battlescape saves aren't supported yet."; _game->pushState(new ErrorMessageState(error.str(), _palette, Palette::blockOffset(8) + 10, "BACK01.SCR", 6)); } else { SaveConverter converter(_saves[n].id, _game->getRuleset()); _game->setSavedGame(converter.loadXcom1()); Options::baseXResolution = Options::baseXGeoscape; Options::baseYResolution = Options::baseYGeoscape; _game->getScreen()->resetDisplay(false); _game->setState(new GeoscapeState); if (_game->getSavedGame()->getSavedBattle() != 0) { _game->getSavedGame()->getSavedBattle()->loadMapResources(_game); Options::baseXResolution = Options::baseXBattlescape; Options::baseYResolution = Options::baseYBattlescape; _game->getScreen()->resetDisplay(false); BattlescapeState *bs = new BattlescapeState; _game->pushState(bs); _game->getSavedGame()->getSavedBattle()->setBattleState(bs); } } } }
void KisColorPatches::paintEvent(QPaintEvent* e) { QPainter painter(this); if(m_allowScrolling) { if(m_direction == Vertical) painter.translate(0, m_scrollValue); else painter.translate(m_scrollValue, 0); } int widgetWidth = width(); int numPatchesInARow = widgetWidth/m_patchWidth; int widgetHeight = height(); int numPatchesInACol = widgetHeight/m_patchHeight; for(int i=m_buttonList.size(); i<qMin(fieldCount(), m_colors.size()+m_buttonList.size()); i++) { int row; int col; if(m_direction==Vertical) { row= i/numPatchesInARow; col = i%numPatchesInARow; } else { row= i%numPatchesInACol; col = i/numPatchesInACol; } QColor qcolor = converter()->toQColor(m_colors.at(i-m_buttonList.size())); painter.fillRect(col*m_patchWidth, row*m_patchHeight, m_patchWidth, m_patchHeight, qcolor); } QWidget::paintEvent(e); }
int DCPS_IR_Domain::add_participant(DCPS_IR_Participant* participant) { OpenDDS::DCPS::RepoId participantId = participant->get_id(); OpenDDS::DCPS::RepoIdConverter converter(participantId); DCPS_IR_Participant_Map::iterator where = this->participants_.find(participantId); if (where == this->participants_.end()) { this->participants_.insert( DCPS_IR_Participant_Map::value_type(participantId, participant)); // Publish the BIT information publish_participant_bit(participant); if (OpenDDS::DCPS::DCPS_debug_level > 0) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Domain::add_participant: ") ACE_TEXT("added participant %C in domain %d ") ACE_TEXT("at 0x%x.\n"), std::string(converter).c_str(), id_, participant)); } } else { if (OpenDDS::DCPS::DCPS_debug_level > 0) { ACE_DEBUG((LM_NOTICE, ACE_TEXT("(%P|%t) NOTICE: DCPS_IR_Domain::add_participant: ") ACE_TEXT("attempt to add already existing participant %C in domain %d.\n"), std::string(converter).c_str(), id_)); } return 1; } return 0; }
VSysLogOutput::VSysLogOutput( const VString& inIdentifier) : fFilter((1<<EML_Trace) | (1<<EML_Information) | (1<<EML_Warning) | (1<<EML_Error) | (1<<EML_Fatal)) , fIdentifier( NULL) { if (!inIdentifier.IsEmpty()) { // SysLog retain the identifier buffer pointer until closelog() is called StStringConverter<char> converter( inIdentifier, VTC_StdLib_char); if (converter.GetSize() > 0) { fIdentifier = VMemory::NewPtrClear( converter.GetSize() + 1, 'SYSL'); if (fIdentifier != NULL) { VMemory::CopyBlock( converter.GetCPointer(), fIdentifier, converter.GetSize()); } } } // the facility may have to be changed according to the context (user process, daemon...) openlog( fIdentifier, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); }
bool wxWebUpdateActionMkfile::Run() const { wxArrayString orig, output; wxLogUsrMsg(_("wxWebUpdateActionMkfile::Run - going to make the file [%s]"), m_strTarget.c_str()); // do we have to create a folder ? wxFileName f(m_strTarget); if (f.FileExists()) { if (m_bOverwrite) wxLogAdvMsg(wxS("wxWebUpdateActionMkfile::Run - the file \"") + m_strTarget + wxS("\" already exist... proceeding anyway (overwrite=1)")); else return TRUE; // exit } // create it ! wxFileOutputStream out(f.GetFullPath()); // do the encoding conversion wxCSConv converter(m_strEncoding); wxCharBuffer buf = m_strContent.mb_str(converter); const char *data = (const char*) buf; size_t bytes = strlen(data)*sizeof(char); // write if (out.Write(data, bytes).LastWrite() != bytes) { wxLogUsrMsg(_("wxWebUpdateActionMkfile::Run - could not create the [%s] file"), f.GetFullPath().c_str()); //wxDELETEA(data); return FALSE; } //wxDELETEA(data); wxLogUsrMsg(_("wxWebUpdateActionMkfile::Run - created the [%1$s] file with content [%2$s]..."), f.GetFullPath().c_str(), m_strContent.c_str()); return TRUE; }
void TestMonodomainMeshalyzerConversion() throw(Exception) { // Firstly, copy ./heart/test/data/MonoDg01d/*.h5 to CHASTE_TEST_OUTPUT/TestHdf5ToMeshalyzerConverter, // as that is where the reader reads from. std::string output_folder("TestHdf5Converters_TestMonodomainMeshalyzerConversion"); CopyToTestOutputDirectory("heart/test/data/Monodomain1d/MonodomainLR91_1d.h5", output_folder); TrianglesMeshReader<1,1> mesh_reader("mesh/test/data/1D_0_to_1_100_elements"); TetrahedralMesh<1,1> mesh; mesh.ConstructFromMeshReader(mesh_reader); // Convert Hdf5ToMeshalyzerConverter<1,1> converter(FileFinder(output_folder,RelativeTo::ChasteTestOutput), "MonodomainLR91_1d", &mesh, true, 10 /* precision specified for coverage */); // Compare the voltage file with a correct version std::string test_output_directory = OutputFileHandler::GetChasteTestOutputDirectory(); FileComparison(test_output_directory + output_folder + "/output/MonodomainLR91_1d_V.dat", "heart/test/data/Monodomain1d/MonodomainLR91_1d_V.dat").CompareFiles(); FileComparison(test_output_directory + output_folder + "/output/MonodomainLR91_1d_times.info", "heart/test/data/Monodomain1d/MonodomainLR91_1d_times.info").CompareFiles(); }
int main(void) { float c; int temp_type; printf("---------------------------------------------------\n"); printf("celciusconv.c\n"); printf("Convert Celcius temperature to Reamur or Fahrenheit\n"); printf("Coded By slac3dork\n"); printf("---------------------------------------------------\n\n"); printf("Celcius temperature: "); scanf("%f", &c); printf("Convert to Reamur/Fahrenheit (1 / 2): "); scanf("%d", &temp_type); if ((temp_type == 1) || (temp_type == 2)) { converter(c, temp_type); } else { printf("\nUnknown...Plase input 1 or 2"); } return 0; }
bool FbxSerializer::load(const String &path, void *&pData) { if (mFbxManager == nullptr) { T3D_LOG_ERROR("FBX Manager haven't been initialized !"); return false; } // Create an importer FbxImporter *pFbxImporter = FbxImporter::Create(mFbxManager, ""); // Initialize the importer by providing a filename. bool bImportStatus = pFbxImporter->Initialize(path.c_str(), -1, mFbxManager->GetIOSettings()); if (!bImportStatus) { T3D_LOG_ERROR("Unable to initialize FBX importer !"); return false; } // Import the scene bool bStatus = pFbxImporter->Import(mFbxScene); // Destroy the importer pFbxImporter->Destroy(); // 统一切换成OpenGL的右手坐标系和以米为单位的坐标系 FbxAxisSystem::OpenGL.ConvertScene(mFbxScene); // 统一以1米为单位 FbxSystemUnit::m.ConvertScene(mFbxScene); // 不是三角形为面的mesh,统一转换成三角形为面的mesh FbxGeometryConverter converter(mFbxManager); converter.Triangulate(mFbxScene, true); pData = mFbxScene; return bStatus; }
int main(int argc, const char * argv []) { if (argc < 2) { std::cout << "Specify path to mapcss and correction parameters" << std::endl; return -1; } try { std::string const file = argv[1]; std::cout << "Input mapcss project: " << file << std::endl; TCoefficientTable table; InitCoefficientTable(table, argc, argv); for (auto const & kv : table) std::cout << "Correction: " << kv.first << " x " << kv.second << std::endl; MapcssConverter converter(move(table)); mapcss::ReadProject(file, std::bind(&MapcssConverter::Process, &converter, std::placeholders::_1, std::placeholders::_2)); auto const & affectedFiles = converter.GetAffectedFiles(); std::cout << affectedFiles.size() << " files has been affected" << (affectedFiles.empty() ? "" : ":") << std::endl; for (auto const & f : affectedFiles) std::cout << " " << f << std::endl; converter.Flush(); std::cout << "Done." << std::endl; } catch (std::exception & e) { std::cout << "Something went wrong. " << e.what() << std::endl; } return 0; }
char* ToNewUTF8String( const nsAString& aSource, uint32_t *aUTF8Count ) { nsAString::const_iterator start, end; CalculateUTF8Size calculator; copy_string(aSource.BeginReading(start), aSource.EndReading(end), calculator); if (aUTF8Count) *aUTF8Count = calculator.Size(); char *result = static_cast<char*> (nsMemory::Alloc(calculator.Size() + 1)); if (!result) return nullptr; ConvertUTF16toUTF8 converter(result); copy_string(aSource.BeginReading(start), aSource.EndReading(end), converter).write_terminator(); NS_ASSERTION(calculator.Size() == converter.Size(), "length mismatch"); return result; }
/** * Construct the converter object with the given Python object * @param p :: A boost::python object is either a wrapped Kernel::Matrix * or 2D numpy array * Throws std::invalid_argument if not * if that is not the case. */ PyObjectToMatrix::PyObjectToMatrix(const boost::python::object &p) : m_obj(p), m_alreadyMatrix(false) { // Is it an already wrapped V3D ? extract<Kernel::Matrix<double>> converter(p); if (converter.check()) { m_alreadyMatrix = true; return; } // Is it a 2D numpy array if (!NumPy::NdArray::check(p)) { std::ostringstream msg; msg << "Cannot convert object to Matrix. Expected numpy array, found " << p.ptr()->ob_type->tp_name; throw std::invalid_argument(msg.str()); } const auto ndim = PyArray_NDIM((PyArrayObject *)p.ptr()); if (ndim != 2) { std::ostringstream msg; msg << "Error converting numpy array to Matrix. Expected ndim=2, found " "ndim=" << ndim << " dimensions."; throw std::invalid_argument(msg.str()); } }
PRUnichar* UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16Count ) { nsACString::const_iterator start, end; CalculateUTF8Length calculator; copy_string(aSource.BeginReading(start), aSource.EndReading(end), calculator); if (aUTF16Count) *aUTF16Count = calculator.Length(); PRUnichar *result = static_cast<PRUnichar*> (nsMemory::Alloc(sizeof(PRUnichar) * (calculator.Length() + 1))); if (!result) return nsnull; ConvertUTF8toUTF16 converter(result); copy_string(aSource.BeginReading(start), aSource.EndReading(end), converter).write_terminator(); NS_ASSERTION(calculator.Length() == converter.Length(), "length mismatch"); return result; }
QUndoCommand* PythonTool::wheelEvent(GLWidget *widget, QWheelEvent *event) { PythonThread pt; if (!PyObject_HasAttrString(m_instance.ptr(), "wheelEvent")) return 0; try { prepareToCatchError(); boost::python::reference_existing_object::apply<GLWidget*>::type converter; PyObject *obj = converter(widget); object real_obj = object(handle<>(obj)); boost::python::return_by_value::apply<QWheelEvent*>::type qconverter; PyObject *qobj = qconverter(event); object real_qobj = object(handle<>(qobj)); return extract<QUndoCommand*>(m_instance.attr("wheelEvent")(real_obj, real_qobj)); } catch(error_already_set const &) { catchError(); } return 0; }
void DkBatchProcessing::init() { batchItems.clear(); QStringList fileList = batchConfig.getFileList(); for (int idx = 0; idx < fileList.size(); idx++) { QFileInfo cFileInfo = QFileInfo(fileList.at(idx)); QString outDir = batchConfig.inputDirIsOutputDir() ? cFileInfo.absolutePath() : batchConfig.getOutputDirPath(); DkFileNameConverter converter(cFileInfo.fileName(), batchConfig.getFileNamePattern(), idx); QFileInfo newFileInfo(outDir, converter.getConvertedFileName()); DkBatchProcess cProcess(fileList.at(idx), newFileInfo.absoluteFilePath()); cProcess.setMode(batchConfig.getMode()); cProcess.setDeleteOriginal(batchConfig.getDeleteOriginal()); cProcess.setProcessChain(batchConfig.getProcessFunctions()); cProcess.setCompression(batchConfig.getCompression()); batchItems.push_back(cProcess); } }
double computeConditionNumber (const Teuchos::RCP<const Thyra_LinearOp>& lop) { #ifdef ALBANY_EPETRA // Allow failure, since we don't know what the underlying linear algebra is auto tmat = getConstTpetraMatrix(lop,false); if (!tmat.is_null()) { Petra::Converter converter(tmat->getComm()); auto emat = Petra::TpetraCrsMatrix_To_EpetraCrsMatrix(tmat,converter.commE_); AztecOOConditionNumber conditionEstimator; conditionEstimator.initialize(*emat); int maxIters = 40000; double tol = 1e-10; int status = conditionEstimator.computeConditionNumber(maxIters, tol); if (status != 0) { auto out = Teuchos::VerboseObjectBase::getDefaultOStream(); *out << "WARNING: AztecOO::ConditionNumber::computeConditionNumber returned " << "non-zero status = " << status << ". Condition number estimate may be wrong!\n"; } double condest = conditionEstimator.getConditionNumber(); return condest; } // TODO: add epetra // If all the tries above are not successful, throw an error. TEUCHOS_TEST_FOR_EXCEPTION (true, std::runtime_error, "Error! Could not cast Thyra_LinearOp to any of the supported concrete types.\n"); #else TEUCHOS_TEST_FOR_EXCEPTION (true, std::runtime_error, "Error! Condition number estimation requires ALBANY_EPETRA.\n"); // Suppress compiler warning for unused argument (void) lop; #endif // Dummy return value to silence compiler warning return 0.0; }
int main(int argc, char *argv[]) { if( PIN_Init(argc,argv) ) { return Usage(); } string fileName = KnobOutputFile.Value(); if (!fileName.empty()) { IDAInsLogFile = fopen(fileName.c_str(), "wb+"); } else { std::cerr << "Need an outfile file dingus." << endl; return -1; } if (!KnobLogStart.Value().empty()) { stringstream converter(KnobLogStart.Value()); converter >> hex >> gLogStart; gLogging = false; }
OpenDDS::DCPS::DataReaderImpl* OpenDDS::DCPS::TransportImpl::find_subscription(OpenDDS::DCPS::RepoId sub_id, bool safe_cpy) { DBG_ENTRY_LVL("TransportImpl","find_subscription",6); GuardType guard(this->lock_); SubscriptionObjectMap::iterator iter = dr_map_.find(sub_id); if (iter == dr_map_.end()) { if (OpenDDS::DCPS::Transport_debug_level > 8) { OpenDDS::DCPS::RepoIdConverter converter(sub_id); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) TransportImpl::find_subscription: ") ACE_TEXT("subscription %C not found.\n"), std::string(converter).c_str())); } return 0; } else if (safe_cpy && iter->second != 0) { iter->second->_add_ref(); } return iter->second; }
void CIRTranslator::Visit( const CWhileStatement * whileStatement ) { whileStatement->Expression()->Accept( this ); IIRExp* condition = exps.top(); exps.pop(); whileStatement->Statement()->Accept( this ); IIRStm* statements = stms.top(); stms.pop(); CLabel* beforeLabelTemp = new CLabel(); CLabel* inLoopLabelTemp = new CLabel(); CLabel* endLabelTemp = new CLabel(); CIRLabel* beforeLabel = new CIRLabel( beforeLabelTemp ); CIRLabel* inLoopLabel = new CIRLabel( inLoopLabelTemp ); CIRLabel* endLabel = new CIRLabel( endLabelTemp ); CConditionalWrapper converter( condition ); IIRStm* whileStm = converter.ToConditional( inLoopLabelTemp, endLabelTemp ); IIRStm* conditionStm = new CIRSeq( beforeLabel, new CIRSeq( whileStm, inLoopLabel ) ); stms.push( new CIRSeq( conditionStm, new CIRSeq( statements, new CIRSeq( new CIRJump( beforeLabelTemp ), endLabel ) ) ) ); }
int main(int argc, char** argv) { if(argc < 3) { std::cout << "usage: " << std::endl << " video2log <videofile> <outfile>" << std::endl; } else { std::string fileName(argv[1]); std::string outFile(argv[2]); std::cout << "opening \"" << fileName << "\"" << std::endl; Video2Log converter(fileName, outFile); if(g_file_test(fileName.c_str(), G_FILE_TEST_IS_DIR)) { converter.generateLogFromImageDir(); } else { converter.generateLogFromVideoFile(); } } return 0; }
void DCPS_IR_Participant::takeOwnership() { /// Publish an update with our ownership. if (this->um_ && (this->isBitPublisher() == false)) { this->um_->create( Update::OwnershipData( this->domain_->get_id(), this->id_, this->federationId_.id())); if (OpenDDS::DCPS::DCPS_debug_level > 4) { OpenDDS::DCPS::RepoIdConverter converter(id_); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::take_ownership: ") ACE_TEXT("pushing ownership %C in domain %d.\n"), std::string(converter).c_str(), this->domain_->get_id())); } } // And now handle our internal ownership processing. this->changeOwner(this->federationId_.id(), this->federationId_.id()); }
void CMakeAviDlg::OnButtonMakeAVI() { if(m_nameArray.isEmpty()) return; const String &first = m_nameArray[0]; String dir = FileNameSplitter(first).getDir(); if((dir.length() > 0) && (dir[dir.length()-1] == '\\')) { dir = substr(dir,0,dir.length()-1); } String outFileName = FileNameSplitter(dir).getFileName(); if(outFileName.length() == 0) { outFileName = _T("MakeAVIOut"); } String outName = FileNameSplitter(first).setFileName(outFileName).setExtension(_T("avi")).getFullPath(); FileNameSplitter nameInfo(outName); String initialDir = nameInfo.getDrive() + nameInfo.getDir(); String extensions = format(_T("Avi files%c*.avi%c%c"),0, 0, 0); CFileDialog dlg(FALSE, _T("avi"), outFileName.cstr()); dlg.m_ofn.lpstrFilter = extensions.cstr(); if(initialDir.length() > 0) { dlg.m_ofn.lpstrInitialDir = initialDir.cstr(); } if(dlg.DoModal() == IDOK) { outName = dlg.m_ofn.lpstrFile; } else { return; } AviConverter converter(outName, m_nameArray, m_framePerSecond, m_useEvery); ProgressWindow(this, converter); if(!converter.isOk()) { showWarning(converter.getMessage()); } }
bool AppendASCIItoUTF16(const nsACString& aSource, nsAString& aDest, const mozilla::fallible_t&) { uint32_t old_dest_length = aDest.Length(); if (!aDest.SetLength(old_dest_length + aSource.Length(), mozilla::fallible_t())) { return false; } nsACString::const_iterator fromBegin, fromEnd; nsAString::iterator dest; aDest.BeginWriting(dest); dest.advance(old_dest_length); // right now, this won't work on multi-fragment destinations LossyConvertEncoding8to16 converter(dest.get()); copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter); return true; }
Z3_ast_vector Z3_API Z3_polynomial_subresultants(Z3_context c, Z3_ast p, Z3_ast q, Z3_ast x) { Z3_TRY; LOG_Z3_polynomial_subresultants(c, p, q, x); RESET_ERROR_CODE(); polynomial::manager & pm = mk_c(c)->pm(); polynomial_ref _p(pm), _q(pm); polynomial::scoped_numeral d(pm.m()); default_expr2polynomial converter(mk_c(c)->m(), pm); if (!converter.to_polynomial(to_expr(p), _p, d) || !converter.to_polynomial(to_expr(q), _q, d)) { SET_ERROR_CODE(Z3_INVALID_ARG); return 0; } Z3_ast_vector_ref* result = alloc(Z3_ast_vector_ref, mk_c(c)->m()); mk_c(c)->save_object(result); if (converter.is_var(to_expr(x))) { expr2var const & mapping = converter.get_mapping(); unsigned v_x = mapping.to_var(to_expr(x)); polynomial_ref_vector rs(pm); polynomial_ref r(pm); expr_ref _r(mk_c(c)->m()); { cancel_eh<polynomial::manager> eh(pm); api::context::set_interruptable si(*(mk_c(c)), eh); scoped_timer timer(mk_c(c)->params().m_timeout, &eh); pm.psc_chain(_p, _q, v_x, rs); } for (unsigned i = 0; i < rs.size(); i++) { r = rs.get(i); converter.to_expr(r, true, _r); result->m_ast_vector.push_back(_r); } } RETURN_Z3(of_ast_vector(result)); Z3_CATCH_RETURN(0); }
void GenerateCells() throw (Exception) { // Do the conversions preserving generated sources CellMLToSharedLibraryConverter converter(true); std::string dirname = "TestGeneralizedRushLarsen"; std::string model = "LuoRudy1991"; boost::shared_ptr<AbstractIvpOdeSolver> p_solver; boost::shared_ptr<ZeroStimulus> p_stimulus(new ZeroStimulus()); std::vector<std::string> args; args.push_back("--grl1"); { // No opt // Copy CellML file into output dir OutputFileHandler handler(dirname + "/normal"); FileFinder cellml_file("heart/src/odes/cellml/" + model + ".cellml", RelativeTo::ChasteSourceRoot); FileFinder copied_file = handler.CopyFileTo(cellml_file); // Create options file & convert converter.CreateOptionsFile(handler, model, args); DynamicCellModelLoaderPtr p_loader = converter.Convert(copied_file); mpGeneralizedRushLarsenCell = dynamic_cast<AbstractCardiacCell*>(p_loader->CreateCell(p_solver, p_stimulus)); } }