예제 #1
0
파일: Lex.cpp 프로젝트: SciBoy/douml
bool nequal(const Q3CString & s1, const Q3CString & s2)
{
  // don't take into account first and last white spaces (like a stripWhiteSpace())
  const char * p1 = (s1.isNull()) ? "" : (const char *) s1;
  const char * p2 = (s2.isNull()) ? "" : (const char *) s2;
  const char * e1 = p1 + s1.length();
  const char * e2 = p2 + s2.length();
  
  while ((p1 != e1) && is_white_space(p1[0]))
    p1 += 1;
  
  while ((p2 != e2) && is_white_space(p2[0]))
    p2 += 1;
  
  while ((e1 != p1) && is_white_space(e1[-1]))
    e1 -= 1;
  
   while ((e2 != p2) && is_white_space(e2[-1]))
    e2 -= 1;
  
  for (;;) {
    if (p1 >= e1)
      return (p2 < e2);
    if (*p1 != *p2)
      return TRUE;
    
    while (*++p1 == '\r') ;
    while (*++p2 == '\r') ;
  }
}
예제 #2
0
void tst_Q3CString::isNull()
{
    Q3CString a;
    QVERIFY( a.isNull() );

    const char *str = "foo";
    a.sprintf( str );
    QVERIFY( !a.isNull() );
}
예제 #3
0
void tst_Q3CString::constructor()
{
    Q3CString a;
    Q3CString b; //b(10);
    Q3CString c("String C");
    char tmp[10];
    tmp[0] = 'S';
    tmp[1] = 't';
    tmp[2] = 'r';
    tmp[3] = 'i';
    tmp[4] = 'n';
    tmp[5] = 'g';
    tmp[6] = ' ';
    tmp[7] = 'D';
    tmp[8] = 'X';
    tmp[9] = '\0';
    Q3CString d(tmp,9);
    Q3CString ca(a);
    Q3CString cb(b);
    Q3CString cc(c);

    QCOMPARE(a,ca);
    QVERIFY(a.isNull());
    QVERIFY(a == Q3CString(""));
    QCOMPARE(b,cb);
    QCOMPARE(c,cc);
    QCOMPARE(d,(Q3CString)"String D");

    Q3CString null(0);
    QVERIFY( null.isNull() );
    QVERIFY( null.isEmpty() );
    Q3CString empty("");
    QVERIFY( !empty.isNull() );
    QVERIFY( empty.isEmpty() );
}
예제 #4
0
파일: Lex.cpp 프로젝트: SciBoy/douml
bool neq(const Q3CString & s1, const Q3CString & s2)
{
  const char * p1 = (s1.isNull()) ? "" : (const char *) s1;
  const char * p2 = (s2.isNull()) ? "" : (const char *) s2;
  
  for (;;) {
    while (*p1 == '\r') p1 += 1;
    while (*p2 == '\r') p2 += 1;
    
    if (*p1 == 0)
      return (*p2 != 0);
    if (*p1 != *p2)
      return TRUE;
    
    p1 += 1;
    p2 += 1;
  }
}
예제 #5
0
void UmlReplyAction::solve(Q3CString idref) {
  Q3CString tr = Trigger::get(idref);
  
  if (tr.isNull()) {
    if (!FileIn::isBypassedId(idref))
      UmlCom::trace("reply activity action : unknown trigger reference '" + idref + "'<br>");
  }
  else
    set_ReplyToCall(tr);
}
예제 #6
0
void UmlAcceptEventAction::solve(Q3CString idref) {
  Q3CString tr = Trigger::get(idref);
  
  if (tr.isNull()) {
    if (!FileIn::isBypassedId(idref))
      UmlCom::trace("accept event activity action : unknown trigger reference '" + idref + "'<br>");
  }
  else
    set_Trigger(tr);
}
예제 #7
0
void UmlAcceptCallAction::importIt(FileIn & in, Token & token, UmlItem * where)
{
  where = where->container(anAcceptCallAction, token, in);
    
  if (where != 0) {
    Q3CString s = token.valueOf("name");
    UmlAcceptCallAction * a = create(where, s);
    
    if (a == 0)
      in.error("cannot create accept call action '"
	       + s + "' in '" + where->name() + "'");
    
    a->addItem(token.xmiId(), in);
    
    if (!(s = token.valueOf("trigger")).isEmpty()) {
      Q3CString tr = Trigger::get(s);
      
      if (!tr.isNull())
	a->set_Trigger(tr);
      else
	Unresolved::addRef(a, s);
    }
    
    if (! token.closed()) {
      Q3CString k = token.what();
      const char * kstr = k;
      
      while (in.read(), !token.close(kstr)) {
	if (token.what() == "trigger") {
	  Q3CString tr_name;
	  Q3CString tr_ref;
	  
	  Trigger::add(in, token, tr_name, tr_ref);
      
	  if (!tr_name.isNull())
	    a->set_Trigger(tr_name);
	  else
	    Unresolved::addRef(a, tr_ref);
	}
	else if (token.what() == "isunmarshall") {
	  // not memorized : always true
	  if (! token.closed())
	    in.finish(token.what());
	}
	else
	  a->import(in, token);
      }
    }
  }
}
예제 #8
0
void tst_Q3CString::acc_01()
{
    Q3CString a;
    Q3CString b; //b(10);
    Q3CString bb; //bb((int)0);
    Q3CString c("String C");
    char tmp[10];
    tmp[0] = 'S';
    tmp[1] = 't';
    tmp[2] = 'r';
    tmp[3] = 'i';
    tmp[4] = 'n';
    tmp[5] = 'g';
    tmp[6] = ' ';
    tmp[7] = 'D';
    tmp[8] = 'X';
    tmp[9] = '\0';
    Q3CString d(tmp,8);
    Q3CString ca(a);
    Q3CString cb(b);
    Q3CString cc(c);
    Q3CString n;
    Q3CString e("String E");
    Q3CString f;
    f = e;
    f.detach();
    f[7]='F';
    QCOMPARE(e,(Q3CString)"String E");
    char text[]="String f";
    f = text;
    text[7]='!';
    QCOMPARE(f,(Q3CString)"String f");
    f[7]='F';
    QCOMPARE(text[7],'!');

#if 0
    a="";
    a[0]='A';
    Q3CString res = "A";
    QCOMPARE(a,res);
    QCOMPARE(a.length(),(uint)1);
    compare(a.length(),(uint)1);
    a[1]='B';
    QCOMPARE(a,(Q3CString)"AB");
    QCOMPARE(a.length(),(uint)2);
    a[2]='C';
    QCOMPARE(a,(Q3CString)"ABC");
    QCOMPARE(a.length(),(uint)3);
    a = Q3CString();
    QVERIFY(a.isNull());
    a[0]='A';
    QCOMPARE(a,(Q3CString)"A");
    QCOMPARE(a.length(),(uint)1);
    a[1]='B';
    QCOMPARE(a,(Q3CString)"AB");
    QCOMPARE(a.length(),(uint)2);
    a[2]='C';
    QCOMPARE(a,(Q3CString)"ABC");
    QCOMPARE(a.length(),(uint)3);
#endif
    a="123";
    b="456";
    a[0]=a[1];
    QCOMPARE(a,(Q3CString)"223");
    a[1]=b[1];
    QCOMPARE(b,(Q3CString)"456");
    QCOMPARE(a,(Q3CString)"253");

    char t[]="TEXT";
    a="A";
    a=t;
    QCOMPARE(a,(Q3CString)"TEXT");
    QCOMPARE(a,(Q3CString)t);
    a[0]='X';
    QCOMPARE(a,(Q3CString)"XEXT");
    QCOMPARE(t[0],'T');
    t[0]='Z';
    QCOMPARE(a,(Q3CString)"XEXT");

    a="ABC";
    QCOMPARE(((const char*)a)[1],'B');
    QCOMPARE(strcmp(a,(Q3CString)"ABC"),0);
    a += "DEF";
    QCOMPARE(a, (Q3CString)"ABCDEF");
    a += 'G';
    QCOMPARE(a, (Q3CString)"ABCDEFG");
    a += ((const char*)(0));
    QCOMPARE(a, (Q3CString)"ABCDEFG");

    // non-member operators

    a="ABC";
    b="ABC";
    c="ACB";
    d="ABCD";
    QVERIFY(a==b);
    QVERIFY(!(a==d));
    QVERIFY(!(a!=b));
    QVERIFY(a!=d);
    QVERIFY(!(a<b));
    QVERIFY(a<c);
    QVERIFY(a<d);
    QVERIFY(!(d<a));
    QVERIFY(!(c<a));
    QVERIFY(a<=b);
    QVERIFY(a<=d);
    QVERIFY(a<=c);
    QVERIFY(!(c<=a));
    QVERIFY(!(d<=a));
    QCOMPARE(a+b,(Q3CString)"ABCABC");
    QCOMPARE(a	+"XXXX",(Q3CString)"ABCXXXX");
    QCOMPARE(a+'X',(Q3CString)"ABCX");
    QCOMPARE("XXXX"+a,(Q3CString)"XXXXABC");
    QCOMPARE('X'+a,(Q3CString)"XABC");
    a = (const char*)0;
    QVERIFY(a.isNull());
    QVERIFY(*((const char *)a) == 0);

    {
	QFile f("COMPARE.txt");
	f.open( QIODevice::WriteOnly );
	QTextStream ts( &f );
	ts.setEncoding(QTextStream::Unicode);
	ts << "Abc";
    }
}
예제 #9
0
static void parse( MetaTranslator *tor, const char *initialContext,
                   const char *defaultContext )
{
    QMap<Q3CString, Q3CString> qualifiedContexts;
    QStringList namespaces;
    Q3CString context;
    Q3CString ext;
    Q3CString text;
    Q3CString comment;
    Q3CString functionContext = initialContext;
    Q3CString prefix;
    bool utf8 = FALSE;

    yyTok = getToken();
    while ( yyTok != Tok_Eof ) {
        switch ( yyTok ) {
            case Tok_i18n:
                utf8 = FALSE;
                yyTok = getToken();
                if ( match( Tok_LeftParen ) &&
                     ( matchString( &context ) || matchSString( &context ) ) &&
                     match( Tok_Comma ) &&
                     ( matchString( &text ) || matchSString( &text ) ) )
                {
                    if ( ( match( Tok_Comma ) &&
                           ( matchString( &comment ) || matchSString( &comment ) ) &&
                           match( Tok_RightParen ) ) == false )
                    {
                        comment = "";
                    }
                    tor->insert( MetaTranslatorMessage( context, text, comment, QString::null, utf8 ) );
                }
//                 else
//                     qDebug( " --- token failed ------------" );
                break;
            case Tok_x18n:
                utf8 = FALSE;
                yyTok = getToken();
                if ( match( Tok_LeftParen ) &&
                     ( matchString( &ext ) || matchSString( &ext ) ) &&
                     match( Tok_Comma ) &&
                     ( matchString( &context ) || matchSString( &context ) ) &&
                     match( Tok_Comma ) &&
                     ( matchString( &text ) || matchSString( &text ) ) )
                {
                    if ( ( match( Tok_Comma ) &&
                           ( matchString( &comment ) || matchSString( &comment ) ) &&
                           match( Tok_RightParen ) ) == false )
                    {
                        comment = "";
                    }
                    tor->insert( MetaTranslatorMessage( context, text, comment, QString::null, utf8 ) );
                }
//                 else
//                     qDebug( " --- token failed ------------" );
                break;
            case Tok_Ident:
                if ( !prefix.isNull() )
                    prefix += "::";
                prefix += yyIdent;
                yyTok = getToken();
                if ( yyTok != Tok_Gulbrandsen )
                    prefix = (const char *) 0;
                break;
            case Tok_Comment:
                comment = yyComment;
                comment = comment.simplifyWhiteSpace();
                yyTok = getToken();
                break;
            case Tok_Gulbrandsen:
                // at top level?
                if ( yyBraceDepth == (int) namespaces.count() && yyParenDepth == 0 )
                    functionContext = prefix;
                yyTok = getToken();
                break;
            case Tok_RightBrace:
            case Tok_Semicolon:
                if ( yyBraceDepth >= 0 &&
                     yyBraceDepth + 1 == (int) namespaces.count() )
                    namespaces.remove( namespaces.fromLast() );
                if ( yyBraceDepth == (int) namespaces.count() ) {
                    functionContext = defaultContext;
                }
                yyTok = getToken();
                break;
            default:
                yyTok = getToken();
        }
    }

//     if ( yyBraceDepth != 0 )
//         qWarning( "%s: Unbalanced braces in PHP code", (const char *) yyFileName );
//     if ( yyParenDepth != 0 )
//         qWarning( "%s: Unbalanced parentheses in PHP code", (const char *) yyFileName );
}