本文整理汇总了C++中kode::Code::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Code::clear方法的具体用法?C++ Code::clear怎么用?C++ Code::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kode::Code
的用法示例。
在下文中一共展示了Code::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createQtTransport
void Converter::createQtTransport()
{
KODE::Class transport( "Transport" );
transport.addBaseClass( mQObject );
transport.addHeaderInclude( "QBuffer" );
transport.addHeaderInclude( "QByteArray" );
transport.addHeaderInclude( "QObject" );
transport.addHeaderInclude( "QHttp" );
transport.addHeaderInclude( "QUrl" );
// member variables
KODE::MemberVariable bufferVar( "buffer", "QBuffer" );
transport.addMemberVariable( bufferVar );
KODE::MemberVariable dataVar( "data", "QByteArray" );
transport.addMemberVariable( dataVar );
KODE::MemberVariable httpVar( "http", "QHttp*" );
transport.addMemberVariable( httpVar );
KODE::MemberVariable urlVar( "url", "QUrl" );
transport.addMemberVariable( urlVar );
KODE::MemberVariable idVar( "id", "int" );
transport.addMemberVariable( idVar );
// functions
KODE::Function ctor( "Transport" );
ctor.addArgument( "const QString &url" );
ctor.addInitializer( "QObject( 0 )" );
ctor.addInitializer( urlVar.name() + "( url )" );
KODE::Function query( "query", "void" );
query.addArgument( "const QString &message" );
query.addArgument( "const QString &headerStr" );
KODE::Function resultSignal( "result", "void", KODE::Function::Signal );
resultSignal.addArgument( "const QString &result" );
KODE::Function errorSignal( "error", "void", KODE::Function::Signal );
errorSignal.addArgument( "const QString &msg" );
KODE::Function finishedSlot( "finished", "void", KODE::Function::Slot | KODE::Function::Private );
finishedSlot.addArgument( "int id" );
finishedSlot.addArgument( "bool errorOccurred" );
// codes
KODE::Code code;
code += "QUrl server( url );";
code.newLine();
code += httpVar.name() + " = new QHttp( this );";
code += httpVar.name() + "->setHost( server.host(), server.port( 80 ) );";
code.newLine();
code += "connect( " + httpVar.name() + ", SIGNAL( requestFinished( int, bool ) ), this, SLOT( " + finishedSlot.name() + "( int, bool ) ) );";
ctor.setBody( code );
code.clear();
code += dataVar.name() + ".clear();";
code += bufferVar.name() + ".setBuffer( &" + dataVar.name() + " );";
code.newLine();
code += "QHttpRequestHeader header;";
code += "header.setRequest( \"POST\", " + urlVar.name() + ".path() );";
code += "header.addValue( \"Connection\", \"Keep-Alive\" );";
code += "header.addValue( \"Content-Type\", \"application/xml; charset=utf-8\" );";
code += "header.addValue( \"Host\", QUrl( " + urlVar.name() + " ).host() );";
code.newLine();
code += "if ( !headerStr.isEmpty() )";
code.indent();
code += "header.addValue( \"SOAPAction\", headerStr );";
code.unindent();
code.newLine();
code += "QUrl server( " + urlVar.name() + " );";
code += "if ( server.port( 80 ) != 80 )";
code.indent();
code += "header.setValue( \"Host\", server.host() + \":\" + QString::number( server.port() ) );";
code.unindent();
code += "else";
code.indent();
code += "header.setValue( \"Host\", server.host() );";
code.unindent();
code.newLine();
code += idVar.name() + " = " + httpVar.name() + "->request( header, message.toUtf8(), &" + bufferVar.name() + " );";
query.setBody( code );
code.clear();
code += "if ( id != " + idVar.name() + " )";
code.indent();
code += "return;";
code.unindent();
code.newLine();
code += "if ( errorOccurred )";
code.indent();
code += "emit " + errorSignal.name() + "( " + httpVar.name() + "->errorString() );";
code.unindent();
code += "else";
code.indent();
code += "emit " + resultSignal.name() + "( QString::fromUtf8( " + dataVar.name() + " ) );";
code.unindent();
finishedSlot.setBody( code );
//.........这里部分代码省略.........
示例2: create
//.........这里部分代码省略.........
if(!authorEmail.isEmpty())
{
file.addCopyright(QDate::currentDate().year(), authorName, authorEmail);
}
KODE::License l;
if(args->isSet("gpl")) l = KODE::License(KODE::License::GPL);
if(args->isSet("lgpl")) l = KODE::License(KODE::License::LGPL);
l.setQtException(args->isSet("qt-exception"));
file.setLicense(l);
file.setNameSpace(args->getOption("namespace"));
if(createMain)
{
file.addInclude("kaboutdata.h");
file.addInclude("kapplication.h");
file.addInclude("kdebug");
file.addInclude("klocale");
file.addInclude("kcmdlineargs");
KODE::Code code;
code += "static const KCmdLineOptions options[] =";
code += "{";
code += " { \"verbose\", \"Verbose output\", 0 },";
code += " KCmdLineLastOption";
code += "};";
file.addFileCode(code);
KODE::Function main("main", "int");
main.addArgument("int argc");
main.addArgument("char **argv");
code.clear();
code += "KAboutData aboutData(\"test\",\"Test\",\"0.1\");";
code += "KCmdLineArgs::init(argc,argv,&aboutData);";
code += "KCmdLineArgs::addCmdLineOptions( options );";
code += "";
code += "KApplication app;";
code += "";
code += "KCmdLineArgs *args = KCmdLineArgs::parsedArgs();";
code += "";
code += "Q_UNUSED( args );";
main.setBody(code);
file.addFileFunction(main);
file.setFilename(filename);
p.printImplementation(file, false);
return 0;
}
KODE::Class c(className);
if(args->isSet("create-dialog"))
{
c.addBaseClass(KODE::Class("KDialogBase"));
c.addInclude("kdialogbase.h");
}
else if(createKioslave)
{
c.setDocs("This class implements a kioslave for ...");
c.addBaseClass(KODE::Class("SlaveBase", "KIO"));