当前位置: 首页>>代码示例>>C++>>正文


C++ Q3CString::sprintf方法代码示例

本文整理汇总了C++中Q3CString::sprintf方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3CString::sprintf方法的具体用法?C++ Q3CString::sprintf怎么用?C++ Q3CString::sprintf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Q3CString的用法示例。


在下文中一共展示了Q3CString::sprintf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: importIt

void UmlUseCase::importIt(FileIn & in, Token & token, UmlItem * where)
{
  where = where->container(anUseCase, token, in);
    
  if (where != 0) {
    Q3CString s = token.valueOf("name");
    
    if (s.isEmpty()) {
      static unsigned n = 0;
      
      s.sprintf("anonymous_usecase_%u", ++n);
    }
    
    UmlUseCase * uc = create(where, s);
    
    if (uc == 0)
      in.error("cannot create use case '" + s +
	       "' in '" + where->name() + "'");
    
    uc->addItem(token.xmiId(), in);
    
    if (! token.closed()) {
      Q3CString k = token.what();
      const char * kstr = k;
      
      while (in.read(), !token.close(kstr))
	uc->UmlItem::import(in, token);
    }

    uc->unload(TRUE, FALSE);
  }
}
开发者ID:SciBoy,项目名称:douml,代码行数:32,代码来源:UmlUseCase.cpp

示例2: QCOMPARE

void tst_Q3CString::sprintf()
{
    Q3CString a;
    a.sprintf("COMPARE");
    QCOMPARE(a,(Q3CString)"COMPARE");
    a.sprintf("%%%d",1);
    QCOMPARE(a,(Q3CString)"%1");
    QCOMPARE(a.sprintf("X%dY",2),(Q3CString)"X2Y");
    //QCOMPARE(a.sprintf("X%sY",(Q3CString)"hello"),"XhelloY");
    // QCOMPARE(a.sprintf("X%9sY","hello"),(Q3CString)"X    helloY");
    QCOMPARE(a.sprintf("X%9iY", 50000 ),(Q3CString)"X    50000Y");
    QCOMPARE(a.sprintf("X%-9sY","hello"),(Q3CString)"Xhello    Y");
    QCOMPARE(a.sprintf("X%-9iY", 50000 ),(Q3CString)"X50000    Y");
    //Q3CString fmt("X%-10SY");
    //Q3CString txt("hello");
    //QCOMPARE(a.sprintf(fmt,(Q3CString)&txt),"X     helloY");
}
开发者ID:mpvader,项目名称:qt,代码行数:17,代码来源:tst_q3cstring.cpp

示例3: QVERIFY

void tst_Q3CString::isNull()
{
    Q3CString a;
    QVERIFY( a.isNull() );

    const char *str = "foo";
    a.sprintf( str );
    QVERIFY( !a.isNull() );
}
开发者ID:mpvader,项目名称:qt,代码行数:9,代码来源:tst_q3cstring.cpp

示例4: importIt

void UmlArtifact::importIt(FileIn & in, Token & token, UmlItem * where)
{
  where = where->container(anArtifact, token, in);
  
  if (where == 0)
    return;
    
  Q3CString s = token.valueOf("name");
  
  if (s.isEmpty()) {
    static unsigned n = 0;
    
    s.sprintf("anonymous_artifact_%u", ++n);
  }
    
  UmlArtifact * artifact = create((UmlDeploymentView *) where, s);
  
  if (artifact == 0)
    in.error("cannot create artifact '" + s +
	     "' in '" + where->name() + "'");
  
  artifact->addItem(token.xmiId(), in);

  if (! token.closed()) {
    Q3CString k = token.what();
    const char * kstr = k;
    
    while (in.read(), !token.close(kstr)) {
      if (token.what() == "manifestation")
	Manifestation::import(in, token, artifact);
      else
	artifact->UmlItem::import(in, token);
    }
  }

  artifact->unload(TRUE, FALSE);
}
开发者ID:SciBoy,项目名称:douml,代码行数:37,代码来源:UmlArtifact.cpp

示例5: main

int main(int argc, char ** argv)
{
  int port_index;
  
  if (argc == 2)
    port_index = 1;
  else if (argc == 3) {
    set_verbose();
    port_index = 2;
  }
  else
    return 0;
  
  if (UmlCom::connect(Q3CString(argv[port_index]).toUInt())) {
    try {
      UmlCom::trace("<b>IDL generator</b> release 2.15<br>");
      
      UmlCom::targetItem()->generate();
      
      Q3CString s;
      
      s.sprintf("<hr><font face=helvetica>Generation done : %d warnings, %d errors</font><br>",
		n_warnings(), n_errors());
      UmlCom::trace(s);
      
      UmlCom::message("");
    
      UmlCom::bye(n_errors());
    }
    catch (...) {
    }
  }
  
  UmlCom::close();
  return 0;
}
开发者ID:SciBoy,项目名称:douml,代码行数:36,代码来源:main.cpp

示例6: importIt

void UmlState::importIt(FileIn & in, Token & token, UmlItem * where)
{
  where = where->container(aState, token, in);
    
  if (where != 0) {
    bool machine = ((token.xmiType() == "uml:StateMachine") ||
		    (token.valueOf("issubmachinestate") == "true") ||
		    (token.what() == "ownedstatemachine")); // andromda emf
    Q3CString s = token.valueOf("name");
    
    if (s.isEmpty()) {
      static unsigned n = 0;
      
      s.sprintf((machine) ? "anonymous_state_machine_%u" 
			  : "anonymous_state_%u",
		++n);
    }
    
    UmlState * st = create(where, s);
    
    if (st == 0)
      in.error((machine) ? "cannot create state machine '"
			 : "cannot create state '"
	       + s + "' in '" + where->name() + "'");
    
    st->addItem(token.xmiId(), in);

    if (token.valueOf("isactive") == "true")
      st->set_isActive(TRUE);
    
    Q3CString ref = token.valueOf("submachine");
    Q3CString spec = token.valueOf("specification");
    
    if (! token.closed()) {
      Q3CString k = token.what();
      const char * kstr = k;
      
      while (in.read(), !token.close(kstr)) {
	s = token.what();
	
	if ((s == "entry") || (s == "doactivity") || (s == "exit"))
	  st->importActivity(in, token);
	else if (s == "specification") {
	  spec = token.xmiIdref();
	  if (! token.closed())
	    in.finish(s);
	}
	else
	  st->UmlItem::import(in, token);
      }
    }
    
    if (machine)
      st->set_Stereotype("machine");
    
    if (! ref.isEmpty()) {
      QMap<Q3CString, UmlItem *>::Iterator it = All.find(ref);
      
      if (it == All.end())
	UnresolvedWithContext::add(st, ref, 4);
      else if ((*it)->kind() == aState)
	st->set_Reference((UmlState *) *it);
    }
    
    if (! spec.isEmpty()) {
      QMap<Q3CString, UmlItem *>::Iterator it = All.find(spec);
      
      if (it == All.end())
	UnresolvedWithContext::add(st, spec, 3);
      else if ((*it)->kind() == anOperation)
	st->set_Specification((UmlOperation *) *it);
    }

    st->unload(TRUE, FALSE);
  }
}
开发者ID:SciBoy,项目名称:douml,代码行数:76,代码来源:UmlState.cpp

示例7: main


//.........这里部分代码省略.........
    // Static querying and setting of a single string option
    static const char* s_groupName = "Debug";
    static const char* s_entryName = "log-file";
    Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName );
    if ( entry ) {
      assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_Path );
      QString val = entry->stringValue();
      cout << "Log-file initially: " << val.toLocal8Bit().constData() << endl;

      // Test setting the option, sync'ing, then querying again
      entry->setStringValue( QString::fromUtf8( "/tmp/test:%e5ä" ) );
      assert( entry->isDirty() );
      config->sync( true );

      // Let's see how it prints it
      system( "gpgconf --list-options dirmngr | grep log-file" );

      // Clear cached values!
      config->clear();

      // Check new value
      Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName );
      assert( entry );
      assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_Path );
      cout << "Log-file now: " << entry->stringValue().toLocal8Bit().constData() << endl;
      assert( entry->stringValue() == QString::fromUtf8( "/tmp/test:%e5ä" ) ); // (or even with %e5 decoded)

      // Reset old value
#if 0
      QString arg( val );
      if ( !arg.isEmpty() )
        arg.prepend( '"' );
      Q3CString sys;
      sys.sprintf( "echo 'log-file:%s' | gpgconf --change-options dirmngr", arg.local8Bit().data() );
      system( sys.data() );
#endif
      entry->setStringValue( val );
      assert( entry->isDirty() );
      config->sync( true );

      cout << "Log-file reset to initial " << val.toLocal8Bit().constData() << endl;
    }
    else
      cout << "Entry 'dirmngr/" << s_groupName << "/" << s_entryName << "' not found" << endl;
  }

  {
    // Static querying and setting of the LDAP URL list option
    static const char* s_groupName = "LDAP";
    static const char* s_entryName = "LDAP Server";
    Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName );
    if ( entry ) {
      assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_LDAPURL );
      assert( entry->isList() );
      KUrl::List val = entry->urlValueList();
      cout << "URL list initially: " << val.toStringList().join(", ").toLocal8Bit().constData() << endl;

      // Test setting the option, sync'ing, then querying again
      KUrl::List lst;
      // We use non-empty paths to workaround a bug in KUrl (kdelibs-3.2)
      lst << KUrl( "ldap://a:389/?b" );
      // Test with query containing a literal ':' (KUrl supports this)
      // and a ' ' (KUrl will escape it, see issue119)
      lst << KUrl( "ldap://foo:389/?a:b c" );
      lst << KUrl( "ldap://server:389/?a%3db,c=DE" ); // the query contains a literal ','
      //cout << " trying to set: " << lst.toStringList().join(", ").local8Bit() << endl;
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:67,代码来源:test_cryptoconfig.cpp

示例8: cpp

Q3CString UmlParameter::cpp(unsigned rank) const
{
    Q3CString s;
    int index;

    if ((type.type != 0) &&
        (CppSettings::classStereotype(type.type->stereotype()) == "enum")) {
        switch (dir) {
        case InputDirection:
            s = CppSettings::enumIn();
            break;

        case OutputDirection:
            s = CppSettings::enumOut();
            break;

        default:
            // can't be return
            s = CppSettings::enumInout();
            break;
        }
    }
    else {
        switch (dir) {
        case InputDirection:
            if (!type.explicit_type.isEmpty())
                s = CppSettings::builtinIn(type.explicit_type);

            if (s.isEmpty())
                s = CppSettings::in();

        case OutputDirection:
            if (!type.explicit_type.isEmpty())
                s = CppSettings::builtinOut(type.explicit_type);

            if (s.isEmpty())
                s = CppSettings::out();

            break;

        default:

            // can't be return
            if (!type.explicit_type.isEmpty())
                s = CppSettings::builtinInout(type.explicit_type);

            if (s.isEmpty())
                s = CppSettings::inout();
        }
    }

    if ((index = s.find("${type}")) != -1) {
        Q3CString t;

        t.sprintf("${t%u}", rank);
        s.replace(index, 7, t);
    }

    Q3CString p;

    p.sprintf(" ${p%u}${v%u}", rank, rank);
    return s + p;
}
开发者ID:bleakxanadu,项目名称:douml,代码行数:63,代码来源:UmlParameter.cpp


注:本文中的Q3CString::sprintf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。