Exemplo n.º 1
0
Core::Core()
    : m_originalMangler(nullptr)
{
#if IDA_SDK_VERSION >= 670
    action_desc_t action = 
    {
        sizeof(action),
        "retypedef_open_name_subst_editor",
        "Edit name substitutions...",
        &m_optionsMenuItemClickedAction,
        &PLUGIN
    };

    register_action(action);
    attach_action_to_menu("Options/", "retypedef_open_name_subst_editor", 0);
#else
    add_menu_item("Options/", "Edit name substitutions...", nullptr, 0, 
        &Core::onOptionsMenuItemClicked, this);
#endif

    // First start? Initialize with default rules.
    Settings settings;
    if (settings.value(Settings::kFirstStart, true).toBool())
    {
        QSettings defaultRules(":/Misc/default_rules.ini", QSettings::IniFormat);
        SettingsImporterExporter importer(&m_substitutionManager, &defaultRules);
        importer.importRules();
        saveToSettings();
        settings.setValue(Settings::kFirstStart, false);
    }

    // Load rules from settings and subscribe to changes in the manager
    try
    {
        SettingsImporterExporter importer(&m_substitutionManager, &settings);
        importer.importRules();
    }
    catch (const SettingsImporterExporter::Error& e)
    {
        msg("[" PLUGIN_NAME "] Cannot load settings: %s\n", e.what());
    }
    connect(&m_substitutionManager, SIGNAL(entryAdded()), SLOT(saveToSettings()));
    connect(&m_substitutionManager, SIGNAL(entryDeleted()), SLOT(saveToSettings()));

    // Place demangler detour
    HMODULE hIdaWll = GetModuleHandleA("IDA.WLL");
    if (!hIdaWll)
        throw std::runtime_error("cannot find IDA.WLL");

    auto demangle = reinterpret_cast<demangler_t*>(GetProcAddress(hIdaWll, "demangle"));
    if (!demangle)
        throw std::runtime_error("cannot find exported function \"demangle\" in IDA.WLL");

    m_demanglerDetour.reset(new DemanglerDetour(demangle, &Core::demanglerHookCallback));
    m_demanglerDetour->attach(m_originalMangler);
}
//Imports a new pick from an xml - RK
bool LLPanelPick::importNewPick()
{
	LLFilePicker& file_picker = LLFilePicker::instance();

	if(!file_picker.getOpenFile(LLFilePicker::FFLOAD_XML)) return false;// User canceled load.
	else
	{
		std::string file = file_picker.getFirstFile();

		llifstream importer(file);
		LLSD data;
		LLSDSerialize::fromXMLDocument(data, importer);

		LLSD file_data = data["Data"];
		data = LLSD();

		mPickID.generate();

		mCreatorID = gAgent.getID();

		mPosGlobal = LLVector3d(file_data["globalPos"]);

		mNameEditor->setText(file_data["name"].asString());
		mDescEditor->setText(file_data["desc"].asString());
		mSnapshotCtrl->setImageAssetID(file_data["snapshotID"].asUUID());
		mParcelID = file_data["parcelID"].asUUID();
		mLocationText = file_data["locationText"].asString();
		mImporting = true;

		sendPickInfoUpdate();
		return true;
	}
}
Exemplo n.º 3
0
void ImportDialog::createDialog(const QString &importerName, QWidget *parent)
{
	Importer *importer(nullptr);

	if (importerName == QLatin1String("OperaBookmarks"))
	{
		importer = new OperaBookmarksImporter();
	}
	else if (importerName == QLatin1String("OperaNotes"))
	{
		importer = new OperaNotesImporter();
	}
	else if (importerName == QLatin1String("OperaSearchEngines"))
	{
		importer = new OperaSearchEnginesImporter();
	}
	else if (importerName == QLatin1String("OperaSession"))
	{
		importer = new OperaSessionImporter();
	}
	else if (importerName == QLatin1String("HtmlBookmarks"))
	{
		importer = new HtmlBookmarksImporter();
	}

	if (importer)
	{
		ImportDialog dialog(importer, parent);
		dialog.exec();
	}
	else
	{
		QMessageBox::critical(parent, tr("Error"), tr("Unable to import selected type."));
	}
}
Exemplo n.º 4
0
	bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
	{
		const std::string filename = upload_pick((void*)LLFilePicker::FFLOAD_XML);
	
		if (filename.empty())
			return true;
	
		llifstream importer(filename);
		LLSD data;
		LLSDSerialize::fromXMLDocument(data, importer);
	
		if (gImportTracker.getState() != ImportTracker::IDLE)
		{
			gImportTracker.clear();
			gImportTracker.cleargroups();
		}
		LLSD data2=data;
		LLSD header=data2["Header"];
		if(header.isDefined())
		{
			if(header["Version"].asInteger() == 2)
			{
				//LLSD obj_llsd=data["Objects"];
				//gImportTracker.prepare(obj_llsd);
				gImportTracker.importer(filename, NULL);
			}
			else
				gImportTracker.import(data);
		}
		else
			gImportTracker.import(data);
		return true;
	}
void lggHunSpell_Wrapper::addWordToCustomDictionary(std::string wordToAdd)
{
	if(!myHunspell)return;
	myHunspell->add(wordToAdd.c_str());
	std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "emerald_custom.dic"));
	std::vector<std::string> lines;
	if(gDirUtilp->fileExists(filename))
	{
		//get words already there..
		llifstream importer(filename);
		std::string line;
		if(getline( importer, line ))//ignored the size
		{
			while( getline( importer, line ) ) lines.push_back(line);
		}
		importer.close();
	}
	llofstream export_file;	
	export_file.open(filename);
	std::string sizePart(llformat("%i",(int)(lines.size()+1))+"\n");
	export_file.write(sizePart.c_str(),sizePart.length());
	for(int i=0;i<(int)lines.size();i++)
		export_file.write(std::string(lines[i]+"\n").c_str(),lines[i].length()+1);
	//LLStringUtil::toLower(wordToAdd);
	wordToAdd=wordToAdd+std::string("\n");
	export_file.write(wordToAdd.c_str(),wordToAdd.length());
	//export_file << std::hex << 10 ;
	export_file.close();
}
Exemplo n.º 6
0
bool Preferences_Load(PreferenceDictionary& preferences, const char* filename, const char *cmdline_prefix)
{
  bool ret = false;
  TextFileInputStream file(filename);
  if(!file.failed())
  {
    XMLStreamParser parser(file);
    XMLPreferenceDictionaryImporter importer(preferences, PREFERENCES_VERSION);
    parser.exportXML(importer);
    ret = true;
  }

  int l = strlen(cmdline_prefix);
  for(int i = 1; i < g_argc - 1; ++i)
  {
    if(g_argv[i][0] == '-')
    {
      if(!strncmp(g_argv[i]+1, cmdline_prefix, l))
        if(g_argv[i][l+1] == '-')
	  preferences.importPref(g_argv[i]+l+2, g_argv[i+1]);
      ++i;
    }
  } 

  return ret;
}
Exemplo n.º 7
0
void DeliciousTest::testMovies2() {
  QUrl url = QUrl::fromLocalFile(QFINDTESTDATA("data/delicious2_movies.xml"));
  Tellico::Import::DeliciousImporter importer(url);
  Tellico::Data::CollPtr coll = importer.collection();

  QVERIFY(coll);
  QCOMPARE(coll->type(), Tellico::Data::Collection::Video);
  QCOMPARE(coll->entryCount(), 4);

  Tellico::Data::EntryPtr entry = coll->entryById(2);
  QVERIFY(entry);
  QCOMPARE(entry->field("title"), QLatin1String("2001 - A Space Odyssey"));
  QCOMPARE(entry->field("certification"), QLatin1String("G (USA)"));
  QCOMPARE(entry->field("nationality"), QLatin1String("USA"));
  QCOMPARE(entry->field("aspect-ratio"), QLatin1String("2.35:1"));
  QCOMPARE(entry->field("audio-track"), QLatin1String("Dolby"));
  QCOMPARE(entry->field("widescreen"), QLatin1String("true"));
  QCOMPARE(entry->field("director"), QLatin1String("Stanley Kubrick"));
  QCOMPARE(entry->field("color"), QLatin1String("Color"));
  QCOMPARE(entry->field("format"), QLatin1String("NTSC"));
  QCOMPARE(entry->field("medium"), QLatin1String("DVD"));
  QCOMPARE(entry->field("running-time"), QLatin1String("148"));
  QCOMPARE(entry->field("rating"), QLatin1String("4"));
  QCOMPARE(entry->field("year"), QLatin1String("1968"));
  QCOMPARE(entry->field("pur_date"), QLatin1String("2007-12-19"));
  QCOMPARE(entry->field("cdate"), QLatin1String("2007-12-20"));
  QCOMPARE(entry->field("mdate"), QLatin1String("2009-06-11"));

  entry = coll->entryById(4);
  QVERIFY(entry);
  QCOMPARE(entry->field("region"), QLatin1String("Region 1"));
}
void LLPanelPick::importNewPick_continued(void (*callback)(void*, bool), void* data, AIFilePicker* filepicker)
{
	bool result = false;
	if (filepicker->hasFilename())
	{
		std::string file = filepicker->getFilename();

		llifstream importer(file);
		LLSD data;
		LLSDSerialize::fromXMLDocument(data, importer);

		LLSD file_data = data["Data"];
		data = LLSD();

		mPickID.generate();

		mCreatorID = gAgent.getID();

		mPosGlobal = LLVector3d(file_data["globalPos"]);

		mNameEditor->setText(file_data["name"].asString());
		mDescEditor->setText(file_data["desc"].asString());
		mSnapshotCtrl->setImageAssetID(file_data["snapshotID"].asUUID());
		mParcelID = file_data["parcelID"].asUUID();
		mLocationText = file_data["locationText"].asString();
		mImporting = true;

		sendPickInfoUpdate();
		result = true;
	}
	(*callback)(data, result);
}
Exemplo n.º 9
0
/*===========================================================================*/
bool VisualizationPipeline::import()
{
    if ( !this->hasObject() )
    {
        // Check filename.
        if ( m_filename.empty() )
        {
            kvsMessageError( "Input data is not specified." );
            return false;
        }

        // Import object.
        kvs::ObjectImporter importer( m_filename );
        kvs::ObjectBase* object = importer.import();
        if ( !object )
        {
            kvsMessageError( "Cannot import an object." );
            return false;
        }

        // Attache the imported object.
        m_object = object;

    }

    return true;
}
Exemplo n.º 10
0
void Map_Read( scene::Node& root, TextInputStream& in, EntityCreator& entityTable ){
	XMLStreamParser parser( in );

	MapDoom3Importer importer( root, entityTable );
	TreeXMLImporterStack stack( importer );
	parser.exportXML( stack );
}
Exemplo n.º 11
0
void QProtobufModel::checkSourceChange()
{
    if (m_metadata.isEmpty())
        return;

    if (m_message.isEmpty())
        return;

    if (m_source.isEmpty())
        return;

    QProtobufModelErrorCollector errorCollector(this);
    QProtobufModelSourceTree sourceTree(m_metadata, this);

    ::pb::compiler::Importer importer(&sourceTree, &errorCollector);

    auto fileDescriptor = importer.Import(m_metadata.toString().toStdString());

    auto descriptor = fileDescriptor->FindMessageTypeByName(m_message.toStdString());

    m_prototype = m_messageFactory.GetPrototype(descriptor);

    m_rootItem = m_prototype->New();

    LocalFileStream sourceStream(m_source);

    m_rootItem->ParseFromZeroCopyStream(&sourceStream);
}
Exemplo n.º 12
0
bool ModelImporter::ImportModel()
{

    LOGDEBUGF("Importing Model: %s", asset_->GetPath().CString());

    SharedPtr<OpenAssetImporter> importer(new OpenAssetImporter(context_));

    importer->SetVerboseLog(true);

    importer->SetScale(scale_);
    importer->SetExportAnimations(false);
    importer->SetImportNode(importNode_);

    if (importer->Load(asset_->GetPath()))
    {
        importer->ExportModel(asset_->GetCachePath());

        return true;
    }
    else
    {
        asset_->PostImportError(importer->GetErrorMessage());
    }

    return false;
}
Exemplo n.º 13
0
// ============================================================================
void
BorderingHelpers::
dissect(const Tpetra::MultiVector<double,int,int> & x,
        Tpetra::MultiVector<double,int,int> & xSmall,
        double * lambda
       )
{
#ifndef NDEBUG
  TEUCHOS_ASSERT_EQUALITY(x.NumVectors(), xSmall.NumVectors());
  // Make sure the maps are matching.
  std::shared_ptr<const Tpetra::Map<int,int>> extendedMap =
    nosh::BorderingHelpers::extendMapBy1(xSmall.getMap());
  TEUCHOS_ASSERT(x.getMap().SameAs(*extendedMap));
#endif

  Epetra_Import importer(xSmall.getMap(), x.getMap());

  // Strip off the phase constraint variable.
  xSmall.Import(x, importer, Insert);

  // TODO Check if we need lambda on all procs.
  if (x.getMap().Comm().MyPID() == 0) {
    const int n = x.MyLength();
    for (int k = 0; k < x.NumVectors(); k++)
      lambda[k] = (*(x(k)))[n - 1];
  }

  return;
}
Exemplo n.º 14
0
// ============================================================================
void
BorderingHelpers::
merge(const Tpetra::MultiVector<double,int,int> & x,
      const double * lambda,
      Tpetra::MultiVector<double,int,int> & out
    )
{
#ifndef NDEBUG
  // Check if the maps are matching.
  std::shared_ptr<const Tpetra::Map<int,int>> extendedMap =
    nosh::BorderingHelpers::extendMapBy1(x.getMap());
  TEUCHOS_ASSERT(out.getMap().SameAs(*extendedMap));
#endif

  Epetra_Import importer(out.getMap(), x.getMap());

  TEUCHOS_ASSERT_EQUALITY(0, out.Import(x, importer, Insert));

  // Set last entry on proc 0.
  if (x.getMap().Comm().MyPID() == 0) {
    const int numMyElems = x.getMap().NumMyElements();
    for (int k = 0; k < x.NumVectors(); k++)
      (*out(k))[numMyElems] = lambda[k];
  }

  return;
}
Exemplo n.º 15
0
bool BrushTokenImporter::importTokens (Tokeniser& tokeniser)
{
	while (1) {
		// check for end of brush
		const std::string token = tokeniser.getToken();
		if (token == "}")
			break;

		tokeniser.ungetToken();

		m_brush.push_back(FaceSmartPointer(new Face(&m_brush)));

		Face& face = *m_brush.back();

		UFOFaceTokenImporter importer(face);
		if (!importer.importTokens(tokeniser))
			return false;
		face.planeChanged();
	}

	m_brush.planeChanged();
	m_brush.shaderChanged();

	return true;
}
Exemplo n.º 16
0
void DeliciousTest::testBooks2() {
  QUrl url = QUrl::fromLocalFile(QFINDTESTDATA("data/delicious2_books.xml"));
  Tellico::Import::DeliciousImporter importer(url);
  Tellico::Data::CollPtr coll = importer.collection();

  QVERIFY(coll);
  QCOMPARE(coll->type(), Tellico::Data::Collection::Book);
  QCOMPARE(coll->entryCount(), 7);

  Tellico::Data::EntryPtr entry = coll->entryById(1);
  QVERIFY(entry);
  QCOMPARE(entry->field("title"), QLatin1String("The Restaurant at the End of the Universe"));
  QCOMPARE(entry->field("isbn"), QLatin1String("0517545357"));
  QCOMPARE(entry->field("cdate"), QLatin1String("2007-12-19"));
  QCOMPARE(entry->field("mdate"), QLatin1String("2009-06-11"));
  QCOMPARE(FIELDS(entry, "author").count(), 1);
  QCOMPARE(FIELDS(entry, "author").first(), QLatin1String("Douglas Adams"));
  QCOMPARE(entry->field("binding"), QLatin1String("Hardback"));
  QCOMPARE(entry->field("rating"), QLatin1String("4.5")); // visually, this gets shown as 4 stars
  QCOMPARE(entry->field("pages"), QLatin1String("250"));
  QCOMPARE(entry->field("pub_year"), QLatin1String("1982"));
  QCOMPARE(entry->field("publisher"), QLatin1String("Harmony"));
  QCOMPARE(entry->field("pur_date"), QLatin1String("2007-12-18"));
  QCOMPARE(entry->field("pur_price"), QLatin1String("$12.95"));
  QCOMPARE(entry->field("signed"), QLatin1String("true"));
  QCOMPARE(entry->field("condition"), QLatin1String("Used"));
}
PXR_NAMESPACE_OPEN_SCOPE


/* static */
MObject
UsdMayaTranslatorMaterial::Read(
        const TfToken& shadingMode,
        const UsdShadeMaterial& shadeMaterial,
        const UsdGeomGprim& boundPrim,
        UsdMayaPrimReaderContext* context)
{
    if (shadingMode == UsdMayaShadingModeTokens->none) {
        return MObject();
    }

    UsdMayaShadingModeImportContext c(shadeMaterial, boundPrim, context);

    MObject shadingEngine;

    if (c.GetCreatedObject(shadeMaterial.GetPrim(), &shadingEngine)) {
        return shadingEngine;
    }

    if (UsdMayaShadingModeImporter importer =
            UsdMayaShadingModeRegistry::GetImporter(shadingMode)) {
        shadingEngine = importer(&c);
    }

    if (!shadingEngine.isNull()) {
        c.AddCreatedObject(shadeMaterial.GetPrim(), shadingEngine);
    }

    return shadingEngine;
}
Exemplo n.º 18
0
int special_submap_import_test(Epetra_Comm& Comm)
{
  int localProc = Comm.MyPID();

  //set up ids_source and ids_target such that ids_source are only
  //a subset of ids_target, and furthermore that ids_target are ordered
  //such that the LIDs don't match up. In other words, even if gid 2 does
  //exist in both ids_source and ids_target, it will correspond to different
  //LIDs on at least 1 proc.
  //
  //This is to test a certain bug-fix in Epetra_Import where the 'RemoteLIDs'
  //array wasn't being calculated correctly on all procs.

  long long ids_source[1];
  ids_source[0] = localProc*2+2;

  long long ids_target[3];
  ids_target[0] = localProc*2+2;
  ids_target[1] = localProc*2+1;
  ids_target[2] = localProc*2+0;

  Epetra_Map map_source((long long) -1, 1, &ids_source[0], 0LL, Comm);
  Epetra_Map map_target((long long) -1, 3, &ids_target[0], 0LL, Comm);

  Epetra_Import importer(map_target, map_source);

  Epetra_LongLongVector vec_source(map_source);
  Epetra_LongLongVector vec_target(map_target);

  vec_target.PutValue(0);

  //set vec_source's contents so that entry[i] == GID[i].
  long long* GIDs = map_source.MyGlobalElements64();
  for(int i=0; i<map_source.NumMyElements(); ++i) {
    vec_source[i] = GIDs[i];
  }

  //Import vec_source into vec_target. This should result in the contents
  //of vec_target remaining 0 for the entries that don't exist in vec_source,
  //and other entries should be equal to the corresponding GID in the map.

  vec_target.Import(vec_source, importer, Insert);

  GIDs = map_target.MyGlobalElements64();
  int test_failed = 0;

  //the test passes if the i-th entry in vec_target equals either 0 or
  //GIDs[i].
  for(int i=0; i<vec_target.MyLength(); ++i) {
    if (vec_target[i] != GIDs[i] && vec_target[i] != 0) test_failed = 1;
  }

  int global_result;
  Comm.MaxAll(&test_failed, &global_result, 1);

  //If test didn't fail on any procs, global_result should be 0.
  //If test failed on any proc, global_result should be 1.
  return global_result;
}
Exemplo n.º 19
0
LLSD lggBeamMaps::getPic(const std::string& filename)
{
	LLSD data;
	llifstream importer(filename);
	LLSDSerialize::fromXMLDocument(data, importer);

	return data;
}
Exemplo n.º 20
0
void KFileBookmarkHandler::importOldBookmarks( const QString& path,
                                               KBookmarkManager *manager )
{
    KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( manager->root(), manager );
    KNSBookmarkImporter importer( path );
    builder->connectImporter( &importer );
    importer.parseNSBookmarks();
    delete builder;
    manager->save();
}
Exemplo n.º 21
0
void EpetraVector<T>::localize (NumericVector<T> & v_local_in) const
{
  EpetraVector<T> * v_local = cast_ptr<EpetraVector<T> *>(&v_local_in);

  Epetra_Map rootMap = Epetra_Util::Create_Root_Map( *_map, -1);
  v_local->_vec->ReplaceMap(rootMap);

  Epetra_Import importer(v_local->_vec->Map(), *_map);
  v_local->_vec->Import(*_vec, importer, Insert);
}
Exemplo n.º 22
0
int DynamicParser::init(const char* protoname, const char* protopath)
{
	DiskSourceTree sourceTree;
	// find proto file in current directory
	sourceTree.MapPath("", protopath);
	// import proto file
	Importer importer(&sourceTree, NULL);
	importer.Import(protoname);
	return 0;
}
Exemplo n.º 23
0
void importLegacyKeys(const std::string& legacyKeysFilename, const std::string& password, std::ostream& destination) {
  CryptoNote::AccountBase account;

  loadKeysFromFile(legacyKeysFilename, password, account);

  CryptoNote::WalletUserTransactionsCache transactionsCache;
  std::string cache;
  CryptoNote::WalletLegacySerializer importer(account, transactionsCache);
  importer.serialize(destination, password, false, cache);
}
Exemplo n.º 24
0
void KImportedBookmarkMenu::slotNSLoad()
{
    // qDebug()<<"**** slotNSLoad  ****"<<m_type<<"  "<<m_location;
    // only fill menu once
    parentMenu()->disconnect(SIGNAL(aboutToShow()));

    // not NSImporter, but kept old name for BC reasons
    KBookmarkMenuImporter importer(manager(), this);
    importer.openBookmarks(m_location, m_type);
}
Exemplo n.º 25
0
int RowMatrixToHandle(FILE * handle, const Epetra_RowMatrix & A) {

  Epetra_Map map = A.RowMatrixRowMap();
  const Epetra_Comm & comm = map.Comm();
  int numProc = comm.NumProc();

  if (numProc==1 || !A.Map().DistributedGlobal())
    writeRowMatrix(handle, A);
  else {
    int numRows = map.NumMyElements();
    
    Epetra_Map allGidsMap((int_type) -1, numRows, (int_type) 0,comm);
    
    typename Epetra_GIDTypeVector<int_type>::impl allGids(allGidsMap);
    for (int i=0; i<numRows; i++) allGids[i] = (int_type) map.GID64(i);
    
    // Now construct a RowMatrix on PE 0 by strip-mining the rows of the input matrix A.
    int numChunks = numProc;
    int stripSize = allGids.GlobalLength64()/numChunks;
    int remainder = allGids.GlobalLength64()%numChunks;
    int curStart = 0;
    int curStripSize = 0;
    typename Epetra_GIDTypeSerialDenseVector<int_type>::impl importGidList;
    if (comm.MyPID()==0) 
      importGidList.Size(stripSize+1); // Set size of vector to max needed
    for (int i=0; i<numChunks; i++) {
      if (comm.MyPID()==0) { // Only PE 0 does this part
	curStripSize = stripSize;
	if (i<remainder) curStripSize++; // handle leftovers
	for (int j=0; j<curStripSize; j++) importGidList[j] = j + curStart;
	curStart += curStripSize;
      }
      // The following import map will be non-trivial only on PE 0.
      if (comm.MyPID()>0) assert(curStripSize==0);
      Epetra_Map importGidMap(-1, curStripSize, importGidList.Values(), 0, comm);
      Epetra_Import gidImporter(importGidMap, allGidsMap);
      typename Epetra_GIDTypeVector<int_type>::impl importGids(importGidMap);
      if (importGids.Import(allGids, gidImporter, Insert)!=0) {EPETRA_CHK_ERR(-1); }

      // importGids now has a list of GIDs for the current strip of matrix rows.
      // Use these values to build another importer that will get rows of the matrix.

      // The following import map will be non-trivial only on PE 0.
      Epetra_Map importMap(-1, importGids.MyLength(), importGids.Values(), map.IndexBase64(), comm);
      Epetra_Import importer(importMap, map);
      Epetra_CrsMatrix importA(Copy, importMap, 0);
      if (importA.Import(A, importer, Insert)!=0) {EPETRA_CHK_ERR(-1); }
      if (importA.FillComplete(A.OperatorDomainMap(), importMap)!=0) {EPETRA_CHK_ERR(-1);}

      // Finally we are ready to write this strip of the matrix to ostream
      if (writeRowMatrix(handle, importA)!=0) {EPETRA_CHK_ERR(-1);}
    }
  }
  return(0);
}
void AspModel::initFromMemory(ByteArray fileContents, const uint32_t importFlags, std::string filename)
{
	dispose(); // Get rid of any existing import.

	AspImporter importer(*this, std::move(fileContents), importFlags, filename);
	srcFileName = std::move(filename);

	SiegeLog("AspModel \"" << srcFileName << "\" initialized. "
			<< subMeshes.size() << " sub-mesh(es), " << boneInfos.size()
			<< " bone(s), " << textureNames.size() << " texture(s).");
}
Exemplo n.º 27
0
void GeneralTransitTest::readGtfsDataTest()
{
    // Expects that the test is started from path build/engine/tests/,
    // sample-feed.zip is in the source corresponding directory
    const QString fileName( "../../../engine/tests/sample-feed.zip" );

    GtfsImporter importer( "sample_gtfs" );
    importer.startImport( fileName );
    importer.wait();

    QCOMPARE( importer.hasError(), false );
}
Exemplo n.º 28
0
TEST_F(TraceImporterTest, test_import_afa) {
    std::istringstream is(afa);
    TraceImporter importer(abc);
    std::pair<size_t, TraceVector> ret = importer.import(is, AFASTA);
    size_t& length = ret.first;
    TraceVector& trs = ret.second;
    ASSERT_EQ(traces.size(), trs.size());
    ASSERT_EQ((size_t) 17, length);
    for (size_t i = 0; i < traces.size(); ++i) {
        EXPECT_TRUE(traces[i] == trs[i]);
    }
}
nsresult
nsSeamonkeyProfileMigrator::CopyPasswords(PRBool aReplace)
{
  nsresult rv;

  nsCString signonsFileName;
  GetSignonFileName(aReplace, getter_Copies(signonsFileName));

  if (signonsFileName.IsEmpty())
    return NS_ERROR_FILE_NOT_FOUND;

  NS_ConvertASCIItoUTF16 fileName(signonsFileName);
  if (aReplace)
    rv = CopyFile(fileName, fileName);
  else {
    // Get the password manager, which is the destination for the passwords
    // being migrated. Also create a new instance of the legacy password
    // storage component, which we'll use to slurp in the signons from
    // Seamonkey's signons.txt.
    nsCOMPtr<nsILoginManager> pwmgr(
        do_GetService("@mozilla.org/login-manager;1"));
    nsCOMPtr<nsILoginManagerStorage> importer(
        do_CreateInstance("@mozilla.org/login-manager/storage/legacy;1"));

    nsCOMPtr<nsIFile> signonsFile;
    mSourceProfile->Clone(getter_AddRefs(signonsFile));
    signonsFile->Append(fileName);

    importer->InitWithFile(signonsFile, nsnull);

    PRUint32 count;
    nsILoginInfo **logins;

    rv = importer->GetAllLogins(&count, &logins);
    NS_ENSURE_SUCCESS(rv, rv);
    for (PRUint32 i = 0; i < count; i++) {
        pwmgr->AddLogin(logins[i]);
    }
    NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, logins);

    PRUnichar **hostnames;
    rv = importer->GetAllDisabledHosts(&count, &hostnames);
    NS_ENSURE_SUCCESS(rv, rv);
    for (PRUint32 i = 0; i < count; i++) {
        pwmgr->SetLoginSavingEnabled(nsDependentString(hostnames[i]),
                                     PR_FALSE);
    }
    NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, hostnames);
  }
  return rv;
}
Exemplo n.º 30
0
bool ModelImporter::ImportAnimation(const String& filename, const String& name, float startTime, float endTime)
{
    SharedPtr<OpenAssetImporter> importer(new OpenAssetImporter(context_));

    //importer->SetVerboseLog(true);

    importer->SetScale(scale_);
    importer->SetExportAnimations(true);
    importer->SetStartTime(startTime);
    importer->SetEndTime(endTime);

    if (importer->Load(filename))
    {
        importer->ExportModel(asset_->GetCachePath(), name, true);

        const Vector<OpenAssetImporter::AnimationInfo>& infos = importer->GetAnimationInfos();

        for (unsigned i = 0; i < infos.Size(); i++)
        {
            const OpenAssetImporter::AnimationInfo& info = infos.At(i);

            String pathName, fileName, extension;

            SplitPath(info.cacheFilename_, pathName, fileName, extension);

            ResourceCache* cache = GetSubsystem<ResourceCache>();

            AnimatedModel* animatedModel = importNode_->GetComponent<AnimatedModel>();

            if (animatedModel)
            {
                Model* model = animatedModel->GetModel();

                if (model)
                {
                    SharedPtr<Animation> animation = cache->GetTempResource<Animation>(fileName + extension);
                    if (animation)
                        model->AddAnimationResource(animation);
                }

            }

            LOGINFOF("Import Info: %s : %s", info.name_.CString(), fileName.CString());
        }

        return true;
    }

    return false;

}