Example #1
0
File: llvm.cpp Project: aptakhin/jt
FormattedOutput& FormattedOutput::print(const char* str, size_t len) {
	for (size_t i = 0; i < len; ++i) {
		if (str[i] == '{') {
			line_ << '{';
			++offset_;
			endl();
		}
		else if (str[i] == '}') {
			endl();
			--offset_;
			print_offset();
			line_ << '}';
			endl();
		}
		else {
			if (line_.str().empty() && !std::isspace(str[i])) {
				print_offset();
				line_ << str[i];
			}
			else if (!line_.str().empty())
				line_ << str[i];
		}
	}
	return *this;
}
status_t ArcHmbPlayerBinder::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
    ALOGE("ArcHmbPlayerBinder::onTransact(%i) %i", code, flags);
    /*
     * Before executing actual method, check whether the RPC are from expected client.
     * Client will write interface token, to identify interface to which those methods
     * belong.
     */
    if (!data.enforceInterface(ArcHmbPlayerInterface::DESCRIPTOR)) {
        ALOGE("failed to check Interface, you might call wrong service, this is for '%s'",
                String8(ArcHmbPlayerInterface::DESCRIPTOR).string());
        return BAD_TYPE;
    }
    data.print(aout);
    endl(aout);

    switch(code) {
    case ArcHmbPlayerInterface::PRINT: {
        String16 msg = data.readString16();
        print(String8(msg).string());
        return NO_ERROR;
    }
    case ArcHmbPlayerInterface::ADD: {
        int32_t a = data.readInt32();
        int32_t b = data.readInt32();
        int32_t sum = add(a, b);
        ALOGE("ArcHmbPlayerBinder:onTransact add(%i, %i) = %i", a, b, sum);
        reply->print(aout); endl(aout);
        reply->writeInt32(sum);
        return NO_ERROR;
    }
    default:
        ALOGE("ArcHmbPlayerBinder, bad requesting code, no match found");
    }
    return BBinder::onTransact(code, data, reply, flags);
}
Example #3
0
void ScribusQApp::showUsage()
{
	QFile f;
	f.open(stderr, QIODevice::WriteOnly);
	QTextStream ts(&f);
	ts << tr("Usage: scribus [option ... ] [file]") ; endl(ts);
	ts << tr("Options:") ; endl(ts);
	printArgLine(ts, ARG_FONTINFO_SHORT, ARG_FONTINFO, tr("Show information on the console when fonts are being loaded") );
	printArgLine(ts, ARG_HELP_SHORT, ARG_HELP, tr("Print help (this message) and exit") );
	printArgLine(ts, ARG_LANG_SHORT, ARG_LANG, tr("Uses xx as shortcut for a language, eg `en' or `de'") );
	printArgLine(ts, ARG_AVAILLANG_SHORT, ARG_AVAILLANG, tr("List the currently installed interface languages") );
	printArgLine(ts, ARG_NOSPLASH_SHORT, ARG_NOSPLASH, tr("Do not show the splashscreen on startup") );
	printArgLine(ts, ARG_NEVERSPLASH_SHORT, ARG_NEVERSPLASH, tr("Stop the showing of the splashscreen on startup. Writes an empty file called .neversplash in ~/.scribus.") );
	printArgLine(ts, ARG_PREFS_SHORT, QString(QString(ARG_PREFS) + QString(" ") + tr("filename")).toLocal8Bit().constData(), tr("Use filename as path for user given preferences") );
	printArgLine(ts, ARG_PROFILEINFO_SHORT, ARG_PROFILEINFO, tr("Show location ICC profile information on console while starting") );
	printArgLine(ts, ARG_SWAPDIABUTTONS_SHORT, ARG_SWAPDIABUTTONS, tr("Use right to left dialog button ordering (eg. Cancel/No/Yes instead of Yes/No/Cancel)") );
	printArgLine(ts, ARG_UPGRADECHECK_SHORT, ARG_UPGRADECHECK, tr("Download a file from the Scribus website and show the latest available version.") );
	printArgLine(ts, ARG_VERSION_SHORT, ARG_VERSION, tr("Output version information and exit") );
	
	
#if defined(_WIN32) && !defined(_CONSOLE)
	printArgLine(ts, ARG_CONSOLE_SHORT, ARG_CONSOLE, tr("Display a console window") );
#endif
/* Delete me?
	std::cout << "-file|-- name Open file 'name'" ; endl(ts);
	std::cout << "name          Open file 'name', the file name must not begin with '-'" ; endl(ts);
	std::cout << "QT specific options as -display ..." ; endl(ts);
*/
	endl(ts);
}
Example #4
0
void
ZDriver::writeParserUtilDecl( std::ostream &out )
{
	out << "    void popStack( void );" << endl();
	out << "    ParserAct findParserAction( int &newVal, int tok );"
		<< endl();
	out << "    void initTables( void );" << endl();
}
Example #5
0
void
ZDriver::emitFuncBreak( std::ostream &out )
{
	out << endl();
	out << endl();
	out << "////////////////////////////////////////" << endl();
	out << endl();
	out << endl();
}
Example #6
0
void LanguageManager::printInstalledList()
{
	QFile f;
	f.open(stderr, QIODevice::WriteOnly);
	QTextStream ts(&f);
	for (int i = 0; i < langTable.size(); ++i)
	{
		ts << "  " << langTable[i].m_priAbbrev.leftJustified(8) << ": " << langTable[i].m_name;
		endl(ts);
	}
	endl(ts);
	f.close();
}
Example #7
0
void
ZDriver::writeAcceptFuncDecl( std::ostream &out )
{
	const std::string &extraArg = getValue( "extra_argument" ).first;

	if ( isValueSet( "parse_accept" ) )
	{
		if ( extraArg.empty() )
			out << "    void accept( void );" << endl();
		else
			out << "    void accept( " << extraArg << " );" << endl();
	}
}
Example #8
0
void ScribusQApp::showAvailLangs()
{
	QFile f;
	f.open(stderr, QIODevice::WriteOnly);
	QTextStream ts(&f);
	ts << tr("Installed interface languages for Scribus are as follows:"); endl(ts);
	endl(ts);

	LanguageManager::instance()->printInstalledList();

	endl(ts);
	ts << tr("To override the default language choice:"); endl(ts);
	ts << tr("scribus -l xx or scribus --lang xx, where xx is the language of choice."); endl(ts);
}
Example #9
0
void
ZDriver::writeErrorRoutinesDecl( std::ostream &out )
{
	const std::string &extraArg = getValue( "extra_argument" ).first;

	out << "    void syntaxError( " << getParserName()
		<< "::Terminal tok, const Util::Any &data" << myExtraArg
		<< " );" << endl();

	if ( extraArg.empty() )
		out << "    void parseFailed( void );" << endl();
	else
		out << "    void parseFailed( " << extraArg << " );" << endl();
}
Example #10
0
void
ZDriver::writeStateTableDecl( std::ostream &out )
{
	out << endl() << endl();
	out << "    typedef std::pair<ParserAct,int> ActionEntry;" << endl();
	out << "    typedef std::map<int,ActionEntry> ActionMap;" << endl();
	out << "    typedef std::vector<ActionMap> StateList;" << endl();
	out << "    typedef std::vector<ActionEntry> StateDefaultList;" << endl();
	out << endl();
	out << "    StateList myStates;" << endl();
	out << "    StateDefaultList myStateDefaultActions;" << endl();
}
Example #11
0
void
ZDriver::emitLineInfo( const std::string	&srcFile,
					   size_t				 line,
					   std::ostream			&out )
{
	out << "#line " << line << " \"" << srcFile << "\"" << endl();
}
void LogBrowserDialog::save()
{
	QString saveFileName = QFileDialog::getSaveFileName(this, tr("Save Log Output"),
														tr("%1/logfile.txt").arg(QDir::homePath()),
														tr("Text Files (*.txt);;All Files (*)"));

	if (saveFileName.isEmpty()) {
		return;
	}

	QFile file(saveFileName);
	if (!file.open(QIODevice::WriteOnly)) {
		QMessageBox::warning(this, tr("Error"), QString(tr("<nobr>File '%1'<br/>cannot be opened for writing.<br/><br/>"
														   "The log output could <b>not</b> be saved!</nobr>")).arg(saveFileName));
		return;
	}

	QTextStream stream(&file);
	for (int row = 0; row < _browser->rowCount(); row++) {
		if (_browser->item(row, 0)) {
			stream << tr("Warning: ");
		}
		stream << _browser->item(row, 1)->text();
		endl(stream);
	}
	file.close();
}
Example #13
0
void
ZDriver::writeImplClassCtorDtor( std::ostream &out )
{
	emitFuncBreak( out );
	out << myPimplName << "::" << myPimplName
		<< "( void )" << endl();
	out << "    : myErrCount( -1 )" << endl();
	out << "{" << endl();
	out << "    initTables();" << endl();
	out << "}" << endl();

	emitFuncBreak( out );
	out << myPimplName << "::~" << myPimplName
		<< "( void )" << endl();
	out << "{" << endl();
	out << "    while ( ! myStack.empty() )" << endl();
	out << "        popStack();" << endl();
	out << "}" << endl();
}
Example #14
0
	void drawBar()
	{
		out << "[";
		const unsigned stop = value * width / max;
		for(unsigned i = 0; i < width; ++i) {
			out << (i <= stop? '*' : ' ');
		}
		out << "] " << std::min<int>(100, value * 100 / max + 1) << "\n";
		endl();
	}
Example #15
0
bool PythonHandler::exportData(regina::NPacket* data, const QString& fileName,
        QWidget* parentWidget) const {
    regina::NScript* script = dynamic_cast<regina::NScript*>(data);

    QFile f(fileName);
    if (! f.open(QIODevice::WriteOnly)) {
        ReginaSupport::warn(parentWidget,
            QObject::tr("The export failed."), 
            QObject::tr("<qt>I could not write to the file <tt>%1</tt>.</qt>").
                arg(fileName.toHtmlEscaped()));
        return false;
    }
    QTextStream out(&f);

    out.setCodec(ReginaPrefSet::importExportCodec());

    // Write the name of the script.
    out << "### " << scriptMarker << ' ';
    out << QString(script->label().c_str());
    endl(out);
    out << "###";
    endl(out);

    // Output the value of each variable.
    unsigned long i;
    regina::NPacket* value;
    for (i = 0; i < script->countVariables(); i++) {
        value = script->variableValue(i);
        out << "### " << varMarker
            << QString(script->variableName(i).c_str())
            << ": " << (value ? QString(value->label().c_str()) : "");
        endl(out);
    }

    out << "###";
    endl(out);
    out << "### " << endMetadataMarker;
    endl(out);
    out << script->text().c_str();

    // All done!
    return true;
}
Example #16
0
int main()
{
    {
        testbuf<char> sb;
        std::ostream os(&sb);
        endl(os);
        assert(sb.str() == "\n");
        assert(sync_called == 1);
        assert(os.good());
    }
    {
        testbuf<wchar_t> sb;
        std::wostream os(&sb);
        endl(os);
        assert(sb.str() == L"\n");
        assert(sync_called == 2);
        assert(os.good());
    }
}
Example #17
0
void
ZDriver::writeStateTable( std::ostream &out )
{
	size_t i, j, nState, nAct, nTotal;

	nState = StateTable::get()->getNumStates();

	// Count all actions
	nTotal = 0;
	for ( i = 0; i < nState; ++i )
	{
		State		*stp = StateTable::get()->getNthState(i);
		ActionList	&ap = stp->getActions();

		nAct = ap.getNumActions();
		for ( j = 0; j < nAct; ++j )
		{
			Action &act = ap.getNthAction( j );
			if ( ! act.isIgnoreType() )
				nTotal++;
			if ( act.getLookAhead() == SymbolTable::get()->getDefaultName() )
				nTotal++;
		}
	}

	out << "static int theStateTable[" << nTotal << "][4] =" << endl();
	out << "{" << endl();

	for ( i = 0; i < nState; ++i )
	{
		State		*stp = StateTable::get()->getNthState(i);
		ActionList	&ap = stp->getActions();

		nAct = ap.getNumActions();
		for ( j = 0; j < nAct; ++j )
		{
			Action &act = ap.getNthAction( j );

			if ( ! act.isIgnoreType() )
			{
				out << "    // State " << i << endl();
				out << "    { " << i << ", " << act.getLookAheadSymbol()->getIndex() << ", ";
				emitAction( act, out );
				out << " }," << endl();
			}

			if ( act.getLookAhead() == SymbolTable::get()->getDefaultName() )
			{
				out << "    // State " << i << " default action" << endl();
				out << "    { " << i << ", " << -1 << ", ";
				emitAction( act, out );
				out << " }," << endl();
			}
		}
	}
	out << "};" << endl();
}
Example #18
0
void
ZDriver::writeAcceptFunc( std::ostream &out )
{
	const std::string &extraArg = getValue( "extra_argument" ).first;

	if ( isValueSet( "parse_accept" ) )
	{
		emitFuncBreak( out );
		if ( extraArg.empty() )
			out << "void " << myPimplName << "::accept( void )" << endl();
		else
			out << "void " << myPimplName << "::accept( "
				<< extraArg << " )" << endl();
		out << "{" << endl();

		emitValue( getValue( "parse_accept" ), out );

		out << "}" << endl();
	}
}
Example #19
0
void ScribusQApp::showHeader()
{
	QFile f;
	f.open(stderr, QIODevice::WriteOnly);
	QTextStream ts(&f);
	endl(ts);
	QString heading( tr("Scribus, Open Source Desktop Publishing") );
	// Build a separator of ----s the same width as the heading
	QString separator = QString("").rightJustified(heading.length(),'-');
	// Then output the heading, separator, and docs/www/etc info in an aligned table
	const int urlwidth = 23;
	const int descwidth = -(heading.length() - urlwidth - 1);
	ts << heading; endl(ts);
	ts << separator; endl(ts);
	ts << QString("%1 %2").arg( tr("Homepage")+":",      descwidth).arg("http://www.scribus.net" ); endl(ts);
	ts << QString("%1 %2").arg( tr("Documentation")+":", descwidth).arg("http://docs.scribus.net"); endl(ts);
	ts << QString("%1 %2").arg( tr("Wiki")+":",          descwidth).arg("http://wiki.scribus.net"); endl(ts);
	ts << QString("%1 %2").arg( tr("Issues")+":",        descwidth).arg("http://bugs.scribus.net"); endl(ts);
	endl(ts);
}
Example #20
0
void
ZDriver::writeRuleTableDecl( std::ostream &out )
{
	out << endl() << endl();
	out << "    // first is LHS, second is number of RHS" << endl();
	out << "    typedef std::pair<int,int> RuleInfo;" << endl();
	out << "    typedef std::vector<RuleInfo> RuleList;" << endl();
	out << endl();
	out << "    RuleList myRules;" << endl();
}
Example #21
0
//-------------------------------------------------------------------------------------------------
// begin of new line
log& log::beginLine(int col, int style)
{
	if ( !isLineEnded )
	{
		*this << efont;
		endl( *this );
	}
	*this << font(col, style);
	isLineEnded = false;

	return *this;
}
Example #22
0
/*! \brief Format an arguments line for printing
Helper procedure */
static void printArgLine(QTextStream & ts, const char * smallArg,
						  const char* fullArg, const QString desc)
{
	const char* lineformat = "  %1, %2 %3";
	const int saw = 4;   // Short argument width
	const int aw = -18;   // Argument width (negative is left aligned)
	QString line = QString(lineformat)
		.arg(smallArg, saw)
		.arg(fullArg, aw)
		.arg(desc);
	ts << line;
	endl(ts);
}
Example #23
0
void LirchChannel::persist() const {
	if (stream) {
		int num_blocks = document->blockCount();
		QTextBlock block = document->begin();
		for (int i = 0; i < num_blocks; ++i) {
			endl(*stream << block.text());
			emit progress(i * 100 / num_blocks);
			block = block.next();
		}
		emit progress(100);
	}
	emit persisted();
}
Example #24
0
void ScribusQApp::showUsage()
{
	QFile f;
	f.open(stderr, QIODevice::WriteOnly);
	QTextStream ts(&f);
	ts << tr("Usage: scribus [options] [files]") ; endl(ts); endl(ts);
	ts << tr("Options:") ; endl(ts);
	printArgLine(ts, ARG_FONTINFO_SHORT, ARG_FONTINFO, tr("Show information on the console when fonts are being loaded") );
	printArgLine(ts, ARG_HELP_SHORT, ARG_HELP, tr("Print help (this message) and exit") );
	printArgLine(ts, ARG_LANG_SHORT, ARG_LANG, tr("Uses xx as shortcut for a language, eg `en' or `de'") );
	printArgLine(ts, ARG_AVAILLANG_SHORT, ARG_AVAILLANG, tr("List the currently installed interface languages") );
	printArgLine(ts, ARG_NOSPLASH_SHORT, ARG_NOSPLASH, tr("Do not show the splashscreen on startup") );
	printArgLine(ts, ARG_NEVERSPLASH_SHORT, ARG_NEVERSPLASH, tr("Stop showing the splashscreen on startup. Writes an empty file called .neversplash in ~/.scribus") );
	printArgLine(ts, ARG_PREFS_SHORT, qPrintable(QString("%1 <%2>").arg(ARG_PREFS).arg(tr("filename"))), tr("Use filename as path for user given preferences") );
	printArgLine(ts, ARG_PROFILEINFO_SHORT, ARG_PROFILEINFO, tr("Show location of ICC profile information on console while starting") );
	printArgLine(ts, ARG_UPGRADECHECK_SHORT, ARG_UPGRADECHECK, tr("Download a file from the Scribus website and show the latest available version") );
	printArgLine(ts, ARG_VERSION_SHORT, ARG_VERSION, tr("Output version information and exit") );
	printArgLine(ts, ARG_PYTHONSCRIPT_SHORT, qPrintable(QString("%1 <%2>").arg(ARG_PYTHONSCRIPT).arg(tr("filename"))), tr("Run filename in Python scripter") );
	printArgLine(ts, ARG_SCRIPTARG_SHORT, qPrintable(QString("%1 <%2> [%3]").arg(ARG_SCRIPTARG).arg(tr("argument")).arg(tr("value"))), tr("Argument passed on to python script, with an optional value, no effect without -py") );
	printArgLine(ts, ARG_NOGUI_SHORT, ARG_NOGUI, tr("Do not start GUI") );
	ts << (QString("     %1").arg(CMD_OPTIONS_END,-39)) << tr("Explicit end of command line options"); endl(ts);
 	
	
#if defined(_WIN32) && !defined(_CONSOLE)
	printArgLine(ts, ARG_CONSOLE_SHORT, ARG_CONSOLE, tr("Display a console window") );
#endif

#if WITH_TESTS
	printArgLine(ts, ARG_TESTS_SHORT, ARG_TESTS, tr("Run unit tests and exit") );
#endif

/* Delete me?
	std::cout << "-file|-- name Open file 'name'" ; endl(ts);
	std::cout << "name          Open file 'name', the file name must not begin with '-'" ; endl(ts);
	std::cout << "QT specific options as -display ..." ; endl(ts);
*/
	endl(ts);
	f.close();
}
Example #25
0
void
ZDriver::emitValue( const Producer::ValueSetting	&val,
					std::ostream					&out )
{
	if ( ! val.first.empty() )
	{
		emitLineInfo( getSourceFile(), val.second, out );
		out << val.first << endl();
		myCurLineNum += std::count_if( val.first.begin(), val.first.end(),
									   std::bind2nd( std::equal_to<char>(), '\n' ) );
		emitLineInfo( myFileName, getOutLine(), out );
	}
}
void BufferedFTPrinter::printOut(const size_t rows) {
  size_t row = rows;
  size_t column = 0;
  for (int lineType: _lines) {
	if (lineType < 0 && column > 0)
      FTPrinter::append(endl());
	switch(lineType) {
      case lineHeader:    FTPrinter::printHeader(); break;
      case lineFooter:    FTPrinter::printFooter();  break;
      case lineTableName: FTPrinter::printTableName(); break;
      default: //a data line
        if (row == 0) break;

		for (size_t i = 0; i < static_cast<size_t>(lineType); ++i) {
          FTPrinter::append( _columnFormats[column]).append(_columns[column]);
          ++column;
        }

		FTPrinter::append(endl());
	--row;
    }
  }
}
    // -----------------------------------------------------------------
    ValueReader(const core::ReaderInputPort& port)
    {
        assert( port.connectedOutput()->data() );

        _container = dynamic_cast<ValueContainerInterface<TValueType>* >(
                         port.data()
                     );
        if(!_container)
        {
            Debug::error() << "ValueReader<"
                           << types::str<ValueType>()
                           << ">::Constructor : "
                           << "enable to determine the Container type"
                           << endl();
        }
    }
Example #28
0
int main()
{
    std::cout << "Test\n"; // There is no operator<< in global namespace, but ADL
                           // examines std namespace because the left argument is in
                           // std and finds std::operator<<(std::ostream&, const char*)
    operator<<(std::cout, "Test\n"); // same, using function call notation
 
    // however,
    std::cout << std::endl; // Error: 'endl' is not declared in this namespace.
                       // This is not a function call to endl(), so ADL does not apply
 
    endl(std::cout); // OK: this is a function call: ADL examines std namespace
                     // because the argument of endl is in std, and finds std::endl
 
    (endl)(std::cout); // Error: 'endl' is not declared in this namespace.
                       // The sub-expression (endl) is not a function call expression
}
Example #29
0
//-------------------------------------------------------------------------------------------------
// удаление лога
void log::destroy()
{
	if (0 != instance)
	{
		#ifdef _DEBUG
		endl( get() ); 
//		get() << "</strong>\n";
		get().logFile	<< "</font>\n"
						<< "</body></html>\n";
		if ( get().logFile.is_open() )
		{
			get().logFile.close();
		}
		#endif

		delete instance;
	}
}
/** Export one playlist at a time. */
void PlaylistDialog::exportSelectedPlaylist()
{
	QString exportedPlaylistLocation;
	SettingsPrivate *settings = SettingsPrivate::instance();
	if (settings->value("locationForExportedPlaylist").isNull()) {
		exportedPlaylistLocation = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
	} else {
		exportedPlaylistLocation = settings->value("locationForExportedPlaylist").toString();
	}
	auto indexes = savedPlaylists->selectionModel()->selectedIndexes();
	if (indexes.isEmpty()) {
		return;
	}

	QStandardItem *item = _savedPlaylistModel->itemFromIndex(indexes.first());
	uint playlistId = item->data(PlaylistID).toUInt();
	auto db = SqlDatabase::instance();
	PlaylistDAO dao = db->selectPlaylist(playlistId);
	QString title = this->convertNameToValidFileName(dao.title());

	// Open a file dialog and ask the user to choose a location
	QString newName = QFileDialog::getSaveFileName(this, tr("Export playlist"), exportedPlaylistLocation + QDir::separator() + title, tr("Playlist (*.m3u8)"));
	if (QFile::exists(newName)) {
		QFile removePreviousOne(newName);
		if (!removePreviousOne.remove()) {
			qDebug() << Q_FUNC_INFO << "Cannot remove" << newName;
		}
	}
	if (newName.isEmpty()) {
		return;
	} else {
		QFile f(newName);
		if (f.open(QIODevice::ReadWrite | QIODevice::Text)) {
			QTextStream stream(&f);
			QList<TrackDAO> tracks = db->selectPlaylistTracks(playlistId);
			for (TrackDAO t : tracks) {
				stream << t.uri();
				endl(stream);
			}
		}
		f.close();
	}
}