void GlobalStatistics<panzer::Traits::Residual, panzer::Traits>::postprocess(std::ostream& os)
{
  Teuchos::reduceAll(*comm, Teuchos::REDUCE_SUM, static_cast<int>(1), &total_volume, &global_total_volume);
  Teuchos::reduceAll(*comm, Teuchos::REDUCE_SUM, static_cast<int>(averages.size()), &averages[0], &global_averages[0]);
  Teuchos::reduceAll(*comm, Teuchos::REDUCE_MAX, static_cast<int>(maxs.size()), &maxs[0], &global_maxs[0]);
  Teuchos::reduceAll(*comm, Teuchos::REDUCE_MIN, static_cast<int>(mins.size()), &mins[0], &global_mins[0]);

  for (std::vector<ScalarT>::size_type i = 0; i < field_values.size(); ++i)
    global_averages[i] /= global_total_volume;

  if (comm->getRank() == 0) {
    
    boost::io::ios_all_saver saver(os);
    
    std::size_t precision = 8;
    os << std::scientific << std::showpoint << std::setprecision(precision) << std::left;
    
    std::size_t name_width = 0;
    for (std::vector<ScalarT>::size_type i = 0; i < field_values.size(); ++i)
      name_width = std::max(name_width,field_values[i].fieldTag().name().size());
    
    std::size_t value_width = precision + 7;
    
    os << std::setw(name_width) << "Field" 
       << " " << std::setw(value_width) << "Average" 
       << " " << std::setw(value_width) << "Maximum (@IP)" 
       << " " << std::setw(value_width) << "Minimum (@IP)" 
       << std::endl;
    
    for (std::vector<ScalarT>::size_type i = 0; i < field_values.size(); ++i) {
      os << std::setw(name_width) <<  field_values[i].fieldTag().name() 
         << " " << std::setw(value_width) << global_averages[i]
         << " " << std::setw(value_width) << global_maxs[i]
         << " " << std::setw(value_width) << global_mins[i] << std::endl;
    }

  }

}
QDebug operator<<(QDebug dbg, const QSurfaceFormat &f)
{
    const QSurfaceFormatPrivate * const d = f.d;
    QDebugStateSaver saver(dbg);

    dbg.nospace() << "QSurfaceFormat("
                  << "version " << d->major << '.' << d->minor
                  << ", options " << d->opts
                  << ", depthBufferSize " << d->depthSize
                  << ", redBufferSize " << d->redBufferSize
                  << ", greenBufferSize " << d->greenBufferSize
                  << ", blueBufferSize " << d->blueBufferSize
                  << ", alphaBufferSize " << d->alphaBufferSize
                  << ", stencilBufferSize " << d->stencilSize
                  << ", samples " << d->numSamples
                  << ", swapBehavior " << d->swapBehavior
                  << ", swapInterval " << d->swapInterval
                  << ", profile  " << d->profile
                  << ')';

    return dbg;
}
   log_t(log_levels_t lvl)
      :lvl_(lvl)
   {
      struct timeval tv = {0, 0};
      (void) gettimeofday(&tv, nullptr);
      
      ss_
         << ((lvl) == log_levels_t::eee ? "eee" : "iii")
         << ","
         << tv.tv_sec
         << ".";
      {
         stream_saver_t saver(ss_);
         ss_.width(6);
         ss_.fill('0');
         ss_
            << tv.tv_usec;
      }

      ss_
         << ",";
   }
Exemple #4
0
Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action)
{
    QDebugStateSaver saver(d);
    d.nospace();
    d << "QAction(" << static_cast<const void *>(action);
    if (action) {
        d << " text=" << action->text();
        if (!action->toolTip().isEmpty())
            d << " toolTip=" << action->toolTip();
        if (action->isCheckable())
            d << " checked=" << action->isChecked();
        if (!action->shortcut().isEmpty())
            d << " shortcut=" << action->shortcut();
        d << " menuRole=";
        QtDebugUtils::formatQEnum(d, action->menuRole());
        d << " visible=" << action->isVisible();
    } else {
        d << '0';
    }
    d << ')';
    return d;
}
Exemple #5
0
void TailsAdvData::save(std::string& data) {
  
  /* A VERY LONG SEQUENCE OF SAVES GOES HERE */
  
  SaveHelper saver(data,
                   DataChunkIDs::fileStart,
                   0);
  
  standardPalettes_.save(data);
  paletteCycles_.save(data);
  levelEffectsHeaders_.save(data);
  levelPaletteHeaders_.save(data);
  levelGraphicsData_.save(data);
  tileMaps_.save(data);
  leafGraphicsTable_.save(data);
  waterSplashGraphicTable_.save(data);
  smokePuffGraphicTable_.save(data);
  spriteMappings_.save(data);
  musicAssignments_.save(data);
  radioMusic_.save(data);
  powerUpData_.save(data);
  emeraldHealthRefills_.save(data);
  metatileWidthMaps_.save(data);
  metatileHeightMaps_.save(data);
  slopeSpeedValues_.save(data);
  metatileBehaviors_.save(data);
  spawnPoints_.save(data);
  warpDestinations_.save(data);
  levelObjectEntryGroups_.save(data);
  mapData_.save(data);
  
  SaveHelper saver2(data,
                   DataChunkIDs::fileEnd,
                   0);
  
  saver2.finalize();
  
  saver.finalize();
}
bool GeneratedFile::write(QString *errorMessage) const
{
    // Ensure the directory
    const QFileInfo info(m_d->path);
    const QDir dir = info.absoluteDir();
    if (!dir.exists()) {
        if (!dir.mkpath(dir.absolutePath())) {
            *errorMessage = QCoreApplication::translate("BaseFileWizard", "Unable to create the directory %1.").arg(
                        QDir::toNativeSeparators(dir.absolutePath()));
            return false;
        }
    }

    // Write out
    QIODevice::OpenMode flags = QIODevice::WriteOnly|QIODevice::Truncate;
    if (!isBinary())
        flags |= QIODevice::Text;

    Utils::FileSaver saver(m_d->path, flags);
    saver.write(m_d->contents);
    return saver.finalize(errorMessage);
}
Exemple #7
0
QDebug operator<<(QDebug dbg, const QPageLayout &layout)
{
    QDebugStateSaver saver(dbg);
    if (layout.isValid()) {
        QString output = QStringLiteral("QPageLayout(%1, %2, l:%3 r:%4 t:%5 b:%6 %7)");
        QString units;
        switch (layout.units()) {
        case QPageLayout::Millimeter:
            units = QStringLiteral("mm");
            break;
        case QPageLayout::Point:
            units = QStringLiteral("pt");
            break;
        case QPageLayout::Inch:
            units = QStringLiteral("in");
            break;
        case QPageLayout::Pica:
            units = QStringLiteral("pc");
            break;
        case QPageLayout::Didot:
            units = QStringLiteral("DD");
            break;
        case QPageLayout::Cicero:
            units = QStringLiteral("CC");
            break;
        }
        output = output.arg(layout.pageSize().name())
                       .arg(layout.orientation() == QPageLayout::Portrait ? QStringLiteral("Portrait") : QStringLiteral("Landscape"))
                       .arg(layout.margins().left())
                       .arg(layout.margins().right())
                       .arg(layout.margins().top())
                       .arg(layout.margins().bottom())
                       .arg(units);
        dbg.nospace() << output;
    } else {
        dbg.nospace() << "QPageLayout()";
    }
    return dbg;
}
Exemple #8
0
    virtual void demothread(int argc, char ** argv) {
        string scenefilename = "data/lab1.env.xml";
        penv->Load(scenefilename);
        vector<RobotBasePtr> vrobots;
        penv->GetRobots(vrobots);
        RobotBasePtr probot = vrobots.at(0);
        std::vector<dReal> q;

        while(IsOk()) {
            {
                EnvironmentMutex::scoped_lock lock(penv->GetMutex()); // lock environment

                TrajectoryBasePtr traj = RaveCreateTrajectory(penv,"");
                traj->Init(probot->GetActiveConfigurationSpecification());
                probot->GetActiveDOFValues(q); // get current values
                traj->Insert(0,q);
                q[RaveRandomInt()%probot->GetDOF()] += RaveRandomFloat()-0.5; // move a random axis

                // check for collisions
                {
                    RobotBase::RobotStateSaver saver(probot); // add a state saver so robot is not moved permenantly
                    probot->SetDOFValues(q);
                    if( penv->CheckCollision(RobotBaseConstPtr(probot)) ) {
                        continue; // robot in collision at final point, so reject
                    }
                }

                traj->Insert(1,q);
                planningutils::SmoothActiveDOFTrajectory(traj,probot);
                probot->GetController()->SetPath(traj);
                // setting through the robot is also possible: probot->SetMotion(traj);
            }
            // unlock the environment and wait for the robot to finish
            while(!probot->GetController()->IsDone() && IsOk()) {
                boost::this_thread::sleep(boost::posix_time::milliseconds(1));
            }
        }
    }
Exemple #9
0
void KLocaleConfigNumber::save()
{
    // temperary use of our locale as the global locale
    KLocale *lsave = KGlobal::_locale;
    KGlobal::_locale = m_locale;

    KConfig *config = KGlobal::config();
    KConfigGroupSaver saver(config, "Locale");

    KSimpleConfig ent(locate("locale", QString::fromLatin1("l10n/%1/entry.desktop").arg(m_locale->country())), true);
    ent.setGroup("KCM Locale");

    QString str;

    str = ent.readEntry("DecimalSymbol", QString::fromLatin1("."));
    config->deleteEntry("DecimalSymbol", false, true);
    if(str != m_locale->decimalSymbol())
        config->writeEntry("DecimalSymbol", m_locale->decimalSymbol(), true, true);

    str = ent.readEntry("ThousandsSeparator", QString::fromLatin1(","));
    config->deleteEntry("ThousandsSeparator", false, true);
    str.replace(QString::fromLatin1("$0"), QString::null);
    if(str != m_locale->thousandsSeparator())
        config->writeEntry("ThousandsSeparator", QString::fromLatin1("$0%1$0").arg(m_locale->thousandsSeparator()), true, true);

    str = ent.readEntry("PositiveSign");
    config->deleteEntry("PositiveSign", false, true);
    if(str != m_locale->positiveSign())
        config->writeEntry("PositiveSign", m_locale->positiveSign(), true, true);

    str = ent.readEntry("NegativeSign", QString::fromLatin1("-"));
    config->deleteEntry("NegativeSign", false, true);
    if(str != m_locale->negativeSign())
        config->writeEntry("NegativeSign", m_locale->negativeSign(), true, true);

    // restore the old global locale
    KGlobal::_locale = lsave;
}
Exemple #10
0
/** Initialize the accelerator @p id by checking if it is overridden
    in the configuration file (and if it isn't, use the default).
*/
static void initialize(StdAccel id)
{
    KConfigGroupSaver saver(KGlobal::config(), "Shortcuts");
    KStdAccelInfo *pInfo = infoPtr(id);

    if(!pInfo)
    {
        kdWarning(125) << "KStdAccel: id not found!" << endl; // -- ellis
        return;
    }

    if(saver.config()->hasKey(pInfo->psName))
    {
        QString s = saver.config()->readEntry(pInfo->psName);
        if(s != "none")
            pInfo->cut.init(s);
        else
            pInfo->cut.clear();
    }
    else
        pInfo->cut = shortcutDefault(id);
    pInfo->bInitialized = true;
}
void EditableSlopeSpeedValues::save(std::string& data) {
  // Output buffer
  Tbyte buffer[ByteSizes::uint32Size];
  SaveHelper saver(data,
                   DataChunkIDs::slopeSpeedValues,
                   0);

  // Write base address
  ByteConversion::toBytes(baseAddress_,
                          buffer,
                          ByteSizes::uint32Size,
                          EndiannessTypes::little,
                          SignednessTypes::nosign);
  data += std::string((char*)buffer, ByteSizes::uint32Size);

  // Write number of entries
  ByteConversion::toBytes(speedValues_.size(),
                          buffer,
                          ByteSizes::uint16Size,
                          EndiannessTypes::little,
                          SignednessTypes::nosign);
  data += std::string((char*)buffer, ByteSizes::uint16Size);
  
  // Write each entry
  for (SlopeSpeedValueCollection::iterator it = speedValues_.begin();
       it != speedValues_.end();
       ++it) {
    ByteConversion::toBytes(*it,
                            buffer,
                            ByteSizes::int16Size,
                            EndiannessTypes::little,
                            SignednessTypes::sign);
    data += std::string((char*)buffer, ByteSizes::int16Size);
  }
  
  saver.finalize();
}
void BaseTreeView::saveLayout(KConfig *config, const QString &group)
{
  KListView::saveLayout(config, group);
  if (! m_saveOpenFolder || ! qConfig.saveTrees)
    return;

  KConfigGroupSaver saver(config, group);
  BaseTreeBranch *btb;
  int i = 0;
  KFileTreeBranchIterator it( branches() );
  for ( ; it.current(); ++it)
  {
    btb = dynamic_cast<BaseTreeBranch *>( (*it) );
    if (btb && btb->rootUrl().isLocalFile()) {
      ++i;
      QStringList folderList;
      // remember the root url so that I find the branch on restore
      folderList.append(btb->rootUrl().url());
      btb->addOpenFolder(&folderList);
      config->writePathEntry("OpenFolderList" + QString::number(i), folderList);
    }
  }
  config->writeEntry("NumOpenFolderList", i);
}
/* ---------------------------------------------------------------------- */
int Phreeqc::
advection(void)
/* ---------------------------------------------------------------------- */
{
	int i;
	LDBLE kin_time;
/*
 *   Calculate advection
 */
	state = ADVECTION;
/*	mass_water_switch = TRUE; */
/*
 *   Check existence of all solutions
 */
	for (i = 0; i <= count_ad_cells; i++)
	{
		if (Utilities::Rxn_find(Rxn_solution_map, i) == NULL)
		//if (solution_bsearch(i, &n, TRUE) == NULL)
		{
			input_error++;
			error_string = sformatf(
					"Solution %d is needed for advection, but is not defined.",
					i);
			error_msg(error_string, CONTINUE);
		}
	}
/*
 *   Check kinetics logic
 */
	kin_time = advection_kin_time;
	if (kin_time <= 0.0)
	{
		for (i = 1; i <= count_ad_cells; i++)
		{
			if (Utilities::Rxn_find(Rxn_kinetics_map, i) != NULL)
			{
				input_error++;
				error_string = sformatf(
						"KINETIC reaction(s) defined, but time_step is not defined in ADVECTION keyword.");
				error_msg(error_string, CONTINUE);
				break;
			}
		}
	}
/*
 *   Quit on error
 */
	if (get_input_errors() > 0)
	{
		error_msg("Program terminating due to input errors.", STOP);
	}
/*
 *   Equilibrate solutions with phases, exchangers, surfaces
 */
	last_model.force_prep = TRUE;
	rate_sim_time_start = 0;
	for (advection_step = 1; advection_step <= count_ad_shifts;
		 advection_step++)
	{
		log_msg(sformatf(
				   "\nBeginning of advection time step %d, cumulative pore volumes %f.\n",
				   advection_step,
				   (double) (((LDBLE) advection_step) /
							 ((LDBLE) count_ad_cells))));
		if (pr.use == TRUE && pr.all == TRUE)
		{
			output_msg(sformatf(
					   "Beginning of advection time step %d, cumulative pore volumes %f.\n",
					   advection_step,
					   (double) (((LDBLE) advection_step) /
								 ((LDBLE) count_ad_cells))));
		}
/*
 *  Advect
 */
		for (i = count_ad_cells; i > 0; i--)
		{
			//solution_duplicate(i - 1, i);
			Utilities::Rxn_copy(Rxn_solution_map, i -1, i);
		}
/*
 *  Equilibrate and (or) mix
 */
		for (i = 1; i <= count_ad_cells; i++)
		{
			set_initial_moles(i);
			cell_no = i;
			set_advection(i, TRUE, TRUE, i);
			run_reactions(i, kin_time, TRUE, 1.0);
			if (advection_kin_time_defined == TRUE)
			{
				rate_sim_time = rate_sim_time_start + kin_time;
			}
			log_msg(sformatf( "\nCell %d.\n\n", i));
			if (pr.use == TRUE && pr.all == TRUE &&
				advection_step % print_ad_modulus == 0 &&
				advection_print[i - 1] == TRUE)
			{
				output_msg(sformatf( "\nCell %d.\n\n", i));
			}
			if (advection_step % punch_ad_modulus == 0 &&
				advection_punch[i - 1] == TRUE)
			{
				punch_all();
			}
			if (advection_step % print_ad_modulus == 0 &&
				advection_print[i - 1] == TRUE)
			{
				print_all();
			}
			if (i > 1)
				Utilities::Rxn_copy(Rxn_solution_map, -2, i - 1);
				//solution_duplicate(-2, i - 1);
			saver();
		}
		Utilities::Rxn_copy(Rxn_solution_map, -2, count_ad_cells);
		//solution_duplicate(-2, count_ad_cells);
		rate_sim_time_start += kin_time;
	}
	initial_total_time += rate_sim_time_start;
	/* free_model_allocs(); */
	mass_water_switch = FALSE;
	return (OK);
}
Exemple #14
0
QDebug operator<<(QDebug dbg, const WrapperStr& str)
{
    QDebugStateSaver saver(dbg);
    dbg << str.wrappedString;
    return dbg;
}
Exemple #15
0
void window_loop(
	const x11::Window& window,
	AppData& app_data,
	CommonData& common,
	RaytracerTarget& rt_target,
	std::size_t n_threads
)
{
	Context gl;
	Renderer renderer(app_data, rt_target.tex_unit);
	renderer.Use(app_data);
	Saver saver(app_data);

	window.SelectInput(StructureNotifyMask| PointerMotionMask| KeyPressMask);
	::XEvent event;

	while(!common.Done())
	{
		if(app_data.verbosity > 0)
		{
			app_data.logstr()
				<< "Rendering cube face "
				<< common.Face()
				<< std::endl;
		}

		// clear the raytrace target
		rt_target.Clear(app_data);
		renderer.InitFrame(app_data, common.Face());
		renderer.Render(app_data);
		common.context.SwapBuffers(window);

		// setup logging period
		std::chrono::system_clock::duration log_period;
		if(app_data.verbosity > 4)
		{
			log_period = std::chrono::seconds(1);
		}
		else if(app_data.verbosity > 3)
		{
			log_period = std::chrono::seconds(5);
		}
		else if(app_data.verbosity > 2)
		{
			log_period = std::chrono::seconds(15);
		}
		else if(app_data.verbosity > 1)
		{
			log_period = std::chrono::minutes(1);
		}

		auto log_time = std::chrono::system_clock::now();

		// signal all threads that they can start raytracing tiles
		common.master_ready.Signal(n_threads);

		while(!common.FaceDone())
		{
			unsigned slot = 0;
			while(common.display.NextEvent(event))
			{
				switch(event.type)
				{
					case ClientMessage:
					case DestroyNotify:
						common.Stop();
						break;
					case ConfigureNotify:
						app_data.render_width = event.xconfigure.width;
						app_data.render_height = event.xconfigure.height;
						break;
					case MotionNotify:
						break;
					case KeyPress:
						if(::XLookupKeysym(&event.xkey, 0) == XK_Escape)
							common.Stop();
						break;
					default:;
				}
			}

			if(common.Done()) break;

			if((slot++ % 5) == 0)
			{
				auto lock = common.Lock();
				renderer.Render(app_data);
				gl.Finish();
				lock.unlock();

				common.context.SwapBuffers(window);
			}

			if(app_data.verbosity > 1)
			{
				auto now = std::chrono::system_clock::now();
				if(log_time + log_period < now)
				{
					common.LogProgress(app_data);
					log_time = now;
				}
			}
			std::chrono::milliseconds period(5);
			std::this_thread::sleep_for(period);
		}

		if(common.Done()) break;

		// wait for all raytracer threads to finish
		common.thread_ready.Wait(n_threads);

		renderer.Render(app_data);
		common.context.SwapBuffers(window);

		if(app_data.verbosity > 1)
		{
			app_data.logstr()
				<< "Finished cube face "
				<< common.Face()
				<< std::endl;
		}

		// save the face image
		saver.SaveFrame(app_data, rt_target, common.Face());
		// switch the face
		common.NextFace(app_data);

		// signal that the master is ready to render
		// the next face
		common.master_ready.Signal(n_threads);
	}
}
Exemple #16
0
void pbuffer_loop(
	const glx::Pbuffer& pbuffer,
	AppData& app_data,
	CommonData& common,
	RaytracerTarget& rt_target,
	std::size_t n_threads
)
{
	Context gl;
	Renderer renderer(app_data, rt_target.tex_unit);
	renderer.Use(app_data);
	Saver saver(app_data);

	while(!common.Done())
	{
		if(app_data.verbosity > 0)
		{
			app_data.logstr()
				<< "Rendering cube face "
				<< common.Face()
				<< std::endl;
		}

		// clear the raytrace target
		rt_target.Clear(app_data);

		renderer.InitFrame(app_data, common.Face());
		renderer.Render(app_data);
		gl.Finish();

		// signal all threads that they can start raytracing tiles
		common.master_ready.Signal(n_threads);

		if(common.Done()) break;

		if(app_data.verbosity > 1)
		{
			// setup logging period
			std::chrono::system_clock::duration log_period;
			if(app_data.verbosity > 4)
			{
				log_period = std::chrono::seconds(1);
			}
			else if(app_data.verbosity > 3)
			{
				log_period = std::chrono::seconds(5);
			}
			else if(app_data.verbosity > 2)
			{
				log_period = std::chrono::seconds(10);
			}
			else if(app_data.verbosity > 1)
			{
				log_period = std::chrono::seconds(30);
			}

			auto log_time = std::chrono::system_clock::now();

			while(!common.thread_ready.Signalled())
			{
				auto now = std::chrono::system_clock::now();
				if(log_time + log_period < now)
				{
					common.LogProgress(app_data);
					log_time = now;
				}
				std::chrono::milliseconds period(50);
				std::this_thread::sleep_for(period);
			}
		}

		// wait for all raytracer threads to finish
		common.thread_ready.Wait(n_threads);

		for(unsigned b=0; b!=2; ++b)
		{
			renderer.Render(app_data);
			gl.Finish();
			common.context.SwapBuffers(pbuffer);
		}

		// save the face image
		saver.SaveFrame(app_data, rt_target, common.Face());
		// switch the face
		common.NextFace(app_data);

		// signal that the master is ready to render
		// the next face
		common.master_ready.Signal(n_threads);
	}
}
Exemple #17
0
bool PlaylistSaver::loadM3U(const KURL &file, int /*opt*/)
{
    kdDebug(66666) << k_funcinfo << "file='" << file.path() << endl;

    QString localFile;
    if(!KIO::NetAccess::download(file, localFile, 0L))
        return false;

    // if it's a PLS, transfer control, again (KIO bug?)
#if 0
    {
        KSimpleConfig list(local, true);
        list.setGroup("playlist");

        // some stupid Windows lusers like to be case insensitive
        QStringList groups=list.groupList().grep(QRegExp("^playlist$", false));
        if (groups.count())
        {
            KURL l;
            l.setPath(local);
            return loadPLS(l);
        }
    }
#endif

    QFile saver(localFile);
    saver.open(IO_ReadOnly);
    QTextStream t(&saver);

    bool isExt = false; // flag telling if we load an EXTM3U file
    QString filename;
    QString extinf;
    QMap<QString,QString> prop;
    reset();

    while (!t.eof())
    {
        if (isExt)
        {
            extinf = t.readLine();
            if (!extinf.startsWith("#EXTINF:"))
            {
//				kdDebug(66666) << "EXTM3U extinf line != extinf, assuming it's a filename." << endl;
                filename = extinf;
                extinf="";
            }
            else
            {
                filename = t.readLine(); // read in second line containing the filename
            }
            //kdDebug(66666) << "EXTM3U filename = '" << filename << "'" << endl;
        }
        else // old style m3u
        {
            filename = t.readLine();
        }

        if (filename == "#EXTM3U") // on first line
        {
//			kdDebug(66666) << "FOUND '#EXTM3U' @ " << saver.at() << "." << endl;
            isExt=true;
            continue; // skip parsing the first (i.e. this) line
        }

        if (filename.isEmpty())
            continue;

        if (filename.find(QRegExp("^[a-zA-Z0-9]+:/"))==0)
        {
            //kdDebug(66666) << k_funcinfo << "url filename = " << filename << endl;

            KURL protourl(filename);
            KMimeType::Ptr mimetype = KMimeType::findByURL(protourl);

            if (mimetype->name() != "application/octet-stream")
            {
                prop["url"] = filename;
            }
            else
            {
                prop["playObject"]="SplayPlayObject";
                // Default title, might be overwritten by #EXTINF later
                prop["title"] = i18n("Stream from %1").arg(protourl.host());

                if (!protourl.hasPath())
                    protourl.setPath("/");

                prop["url"] = protourl.url();
                prop["stream_"] = prop["url"];
            }
        }
        else // filename that is not of URL style (i.e. NOT "proto:/path/somefile")
        {
            KURL u1;
            // we have to deal with a relative path
            if (filename.find('/'))
            {
                u1.setPath(file.path(0));
                u1.setFileName(filename);
            }
            else
            {
                u1.setPath(filename);
            }
            prop["url"] = u1.url();
        }

        // parse line of the following format:
        //#EXTINF:length,displayed_title
        if (isExt)
        {
            extinf.remove(0,8); // remove "#EXTINF:"
            //kdDebug(66666) << "EXTM3U extinf = '" << extinf << "'" << endl;
            int timeTitleSep = extinf.find(',', 0);

            int length = (extinf.left(timeTitleSep)).toInt();
            if (length>0)
                prop["length"]=QString::number(length*1000);

            QString displayTitle=extinf.mid(timeTitleSep+1);
            if (!displayTitle.isEmpty())
            {
                int artistTitleSep = displayTitle.find(" - ",0);
                if (artistTitleSep == -1) // no "artist - title" like format, just set it as title
                {
                    prop["title"] = displayTitle;
                }
                else
                {
                    prop["author"] = displayTitle.left(artistTitleSep);
                    prop["title"] = displayTitle.mid(artistTitleSep+3);
                }
                /*kdDebug(66666) << "EXTM3U author/artist='" << prop["author"] <<
                	"', title='" << prop["title"] << "'" << endl;*/
            } // END !displayTitle.isEmpty()
        } // END if(isExt)

//		kdDebug(66666) << k_funcinfo << "adding file '" << prop["url"] << "' to playlist" << endl;
        readItem(prop);
        prop.clear();
    } // END while()

    KIO::NetAccess::removeTempFile(localFile);

//	kdDebug(66666) << k_funcinfo << "END" << endl;
    return true;
}
Exemple #18
0
/**
 *	Reads raw data into a buffer without advancing the stream's position
 */
void IDataStream::PeekBuf(void * buf, UInt32 inLength)
{
	IDataStream_PositionSaver	saver(this);

	ReadBuf(buf, inLength);
}
QDebug operator<<(QDebug debug, const Port &p)
{
    QDebugStateSaver saver(debug);
    debug.nospace() << QLatin1String("Port(") << p.number() << QLatin1Char(')');
    return debug;
}
Exemple #20
0
/**
 *	Reads and returns a 32-bit value from the stream without advancing the stream's position
 */
UInt64 IDataStream::Peek64(void)
{
	IDataStream_PositionSaver	saver(this);

	return Read64();
}
Exemple #21
0
/**
 *	Reads and returns a 32-bit value from the stream without advancing the stream's position
 */
UInt32 IDataStream::Peek32(void)
{
	IDataStream_PositionSaver	saver(this);

	return Read32();
}
Exemple #22
0
/**
 *	Reads and returns a 16-bit value from the stream without advancing the stream's position
 */
UInt16 IDataStream::Peek16(void)
{
	IDataStream_PositionSaver	saver(this);

	return Read16();
}
// basic_ostream::operator<<(const void*) is drunk.
static void PrintPointer(const void* ptr, std::ostream& os)
{
    StreamStateSaver saver(os);
    uintptr_t intPtr = reinterpret_cast<uintptr_t>(ptr);
    os << "0x" << std::setfill('0') << std::setw(sizeof(uintptr_t) * 2) << std::hex << intPtr;
}
Exemple #24
0
EXPORT int BinStateSave(CSystem *s, char *data, int length)
{
	NewStateExternalBuffer saver(data, length);
	s->SyncState<false>(&saver);
	return !saver.Overflow() && saver.GetLength() == length;
}
Exemple #25
0
Disp::~Disp()
{
    QImage saver((uchar *)&bitmap[0], bitx, bity, QImage::Format_RGB32);
    saver.save("out.png", "PNG");
}
Exemple #26
0
/**
 *	Reads and returns a 32-bit floating point value from the stream without advancing the stream's position
 */
float IDataStream::PeekFloat(void)
{
	IDataStream_PositionSaver	saver(this);

	return ReadFloat();
}
Exemple #27
0
EXPORT void TxtStateSave(CSystem *s, FPtrs *ff)
{
	NewStateExternalFunctions saver(ff);
	s->SyncState<false>(&saver);
}
Exemple #28
0
void jdlvFrame::CopyCLR()
{
  elMundo *world = (genNo && nextWorld) ? nextWorld : primeWorld;
  ClipSaver saver(*world);                      saver.save(true);
}
Exemple #29
0
void App_SaveInstallSettings( wxConfigBase* ini )
{
	IniSaver saver( ini );
	App_LoadSaveInstallSettings( saver );
}
Exemple #30
0
/**
 *	Reads and returns an 8-bit value from the stream without advancing the stream's position
 */
UInt8 IDataStream::Peek8(void)
{
	IDataStream_PositionSaver	saver(this);

	return Read8();
}