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


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

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


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

示例1: mimetype

QByteArray K3BookmarkDrag::encodedData( const char* mime ) const
{
    QByteArray a;
    Q3CString mimetype( mime );
    if ( mimetype == "text/uri-list" )
        return Q3UriDrag::encodedData( mime );
    else if ( mimetype == "application/x-xbel" )
    {
        a = m_doc.toByteArray();
        //kDebug(7043) << "K3BookmarkDrag::encodedData " << m_doc.toCString();
    }
    else if ( mimetype == "text/plain" )
    {
        KUrl::List m_lstDragURLs;
        if ( K3URLDrag::decode( this, m_lstDragURLs ) )
        {
            QStringList uris;
            KUrl::List::ConstIterator uit = m_lstDragURLs.constBegin();
            KUrl::List::ConstIterator uEnd = m_lstDragURLs.constEnd();
            for ( ; uit != uEnd ; ++uit )
                uris.append( (*uit).prettyUrl() );

            Q3CString s = uris.join( "\n" ).toLocal8Bit();
            a.resize( s.length() + 1 ); // trailing zero
            memcpy( a.data(), s.data(), s.length() + 1 );
        }
    }
    return a;
}
开发者ID:ssj-gz,项目名称:emscripten-kdelibs,代码行数:29,代码来源:k3bookmarkdrag.cpp

示例2: nequal

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') ;
  }
}
开发者ID:SciBoy,项目名称:douml,代码行数:30,代码来源:Lex.cpp

示例3: manage_decorators

static void manage_decorators(QTextOStream & f, const Q3CString & decorators,
			      QString indent, BooL & indent_needed)
{
  if (! decorators.isEmpty()) {
    int index = 0;
    int index2;
    
    while ((index2 = decorators.find("\n", index)) != -1){
      if (indent_needed)
	f << indent;
      else
	indent_needed = TRUE;
      f << decorators.mid(index, index2 + 1 - index);
      index = index2 + 1;
    }
    
    if (index != (int) decorators.length()) {
      if (indent_needed) {
	f << indent;
	indent_needed = FALSE;
      }
      f << decorators.mid(index);
    }
  }
}
开发者ID:SciBoy,项目名称:douml,代码行数:25,代码来源:UmlOperation.cpp

示例4: special

void Q3Url::encode( QString& url )
{
    if ( url.isEmpty() )
	return;

    Q3CString curl = url.utf8();
    int oldlen = curl.length();

    const Q3CString special( "+<>#@\"&%$:,;?={}|^~[]\'`\\ \n\t\r" );
    QString newUrl;
    int newlen = 0;

    for ( int i = 0; i < oldlen ;++i ) {
	uchar inCh = (uchar)curl[ i ];

	if ( inCh >= 128 || special.contains(inCh) ) {
	    newUrl[ newlen++ ] = QLatin1Char( '%' );

	    ushort c = inCh / 16;
	    c += c > 9 ? 'A' - 10 : '0';
	    newUrl[ newlen++ ] = c;

	    c = inCh % 16;
	    c += c > 9 ? 'A' - 10 : '0';
	    newUrl[ newlen++ ] = c;
	} else {
	    newUrl[ newlen++ ] = inCh;
	}
    }

    url = newUrl;
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例5: replaceType

bool UmlClass::replaceType(UmlTypeSpec & t, Q3CString & target_id, const Q3CString & ts)
{
  UmlClass * cl = (UmlClass *) findItem(target_id, aClass);
  bool result = FALSE;
  
  if (cl != 0) {
    int index = 0;
    const Q3CString & s = cl->name();
    unsigned ln1 = s.length();
    unsigned ln2 = ts.length();
    
    while ((index = t.explicit_type.find(s, index)) != -1) {
      if (((index == 0) || isSep(((const char *) t.explicit_type)[index - 1])) &&
	  isSep(((const char *) t.explicit_type)[index + (int) ln1])) {
	t.explicit_type.replace((unsigned) index, ln1, ts);
	index += ln2;
	result = TRUE;
      }
      else
	index += 1;
    }
  }

  if (result) {
    target_id = t.explicit_type;
    t.explicit_type = 0;
    t.type = cl;
  }

  return result;
}
开发者ID:SciBoy,项目名称:douml,代码行数:31,代码来源:UmlClass.cpp

示例6: replace_alias

void UmlItem::replace_alias(Q3CString & s) {
  int index = 0;
  
  while ((index = s.find("@{", index)) != -1) {
    int index2 = s.find('}', index + 2);
    
    if (index2 == -1)
      return;
    
    UmlBaseItem * obj = this;
    Q3CString key = s.mid(index + 2, index2 - index - 2);
    Q3CString value;
    
    for (;;) {
      if (obj->propertyValue(key, value)) {
	s.replace(index, index2 - index + 1, value);
	index += value.length();
	break;
      }
      else if ((obj = obj->parent()) == 0) {
	index = index2 + 1;
	break;
      }
    }
  }
}
开发者ID:SciBoy,项目名称:douml,代码行数:26,代码来源:UmlItem.cpp

示例7: internalWriteString

int XmlProtocol::internalWriteString(const QString &s, TrackItem::Type t, int id)
{
	QString out=ensureGTEncoded(s);
	Q3CString cs = s.utf8();
	QByteArray a(cs.length());
	memcpy(a.data(), cs.data(), a.size());
	return internalWriteData(a, t, id);
}
开发者ID:sapo,项目名称:sapo-messenger-for-mac,代码行数:8,代码来源:xmlprotocol.cpp

示例8: write

void UmlClass::write(QTextOStream & f, const UmlTypeSpec & t,
		     bool with_formals, BooL * is_template)
{
  if (t.type != 0)
    t.type->write(f, with_formals, is_template);
  else {
    Q3CString s = CppSettings::type(t.explicit_type);
    
    f << s;
    
    if (is_template != 0)
      *is_template = (!s.isEmpty() && (s.at(s.length() - 1) == '>'));
  }
	
}
开发者ID:SciBoy,项目名称:douml,代码行数:15,代码来源:UmlClass.cpp

示例9: simplify_comment

// remove first and last line in comment if non significant
Q3CString Lex::simplify_comment(Q3CString & comment)
{
  if (comment.isEmpty())
    return comment;
  
  const char * s = comment;
  const char * p = s;
  
  for (;;) {
    switch (*p) {
    case 0:
      return comment;
    case ' ':
    case '\t':
      p += 1;
      break;
    case '\n':
      comment.remove(0, p - s + 1);
      
      if (comment.isEmpty())
	return comment;
      
      s = comment;
      // no break
    default:
      p = s + comment.length() - 1;

      while (p != s) {
	switch(*p) {
	case ' ':
	case '\t':
	  p -= 1;
	  break;
	case '\n':
	  comment.resize(p - s + 1);
	  // no break
	default:
	  return comment;
	}
      }
      
      if (*p == '\n')
	comment = "";
      return comment;
    }
  }
}
开发者ID:SciBoy,项目名称:douml,代码行数:48,代码来源:Lex.cpp

示例10: manage_docstring

void UmlItem::manage_docstring(const char *& p, const char *& pp, BooL & indent_needed,
			       Q3CString & indent, Q3CString & saved_indent)
{
  static Q3CString the_comment;
  
  p += 12;
  
  the_comment = description();
  
  if ((pp != 0) || // comment contains ${description} !
      the_comment.isEmpty())
    return;
    
  int index = 0;
  
  while ((index = the_comment.find("\"\"\"", index)) != -1) {
    the_comment.insert(index, "\\");
    index += 2;
  }
  
  if (!indent.isEmpty()) {
    int len = indent.length() + 1;
    
    index = 0;
    
    while ((index = the_comment.find('\n', index)) != -1) {
      the_comment.insert(index + 1, (const char*)indent);
      index += len;
    }
  }
  
  the_comment = "\"\"\"" + the_comment + "\"\"\"\n";
  
  if (indent_needed) {
    indent_needed = FALSE;
    the_comment = indent + the_comment;
  }

  pp = p;
  p = the_comment;
  saved_indent =  indent;
  indent = "";
}
开发者ID:SciBoy,项目名称:douml,代码行数:43,代码来源:UmlItem.cpp

示例11: newUrl

void Q3Url::decode( QString& url )
{
    if ( url.isEmpty() )
	return;

    int newlen = 0;
    Q3CString curl = url.utf8();
    int oldlen = curl.length();

    Q3CString newUrl(oldlen);

    int i = 0;
    while ( i < oldlen ) {
	uchar c = (uchar)curl[ i++ ];
	if ( c == '%' && i <= oldlen - 2 ) {
	    c = hex_to_int( (uchar)curl[ i ] ) * 16 + hex_to_int( (uchar)curl[ i + 1 ] );
	    i += 2;
	}
	newUrl [ newlen++ ] = c;
    }
    newUrl.truncate( newlen );

    url = QString::fromUtf8(newUrl.data());
}
开发者ID:,项目名称:,代码行数:24,代码来源:

示例12: compute_type


//.........这里部分代码省略.........
      else if (!get_first_template_actual) {
	// has first actual
	typeform = tf1;
	type = t1;
	break;
      }
      else {
	typespec.explicit_type = type;
	return;
      }
    }
  }

  if (! tmplts.isEmpty()) {
    Q3ValueList<FormalParameterList>::ConstIterator it1;
    
    for (it1 = tmplts.begin(); it1 != tmplts.end(); ++it1) {
      FormalParameterList::ConstIterator it2;
    
      for (it2 = (*it1).begin(); it2 != (*it1).end(); ++it2) {
	if ((*it2).name() == type) {
	  typespec.type = 0;
	  typespec.explicit_type = type;
	  return;
	}
      }
    }
  }
  
  Q3CString normalized;
  
  if (typespec.type == 0) {
    normalized = Lex::normalize(type);
    
    if (!find_type(normalized, typespec) &&
	(Namespace::current().isEmpty() ||
	 (normalized.at(0) == ':') || 
	 !find_type("::" + normalized, typespec))) {
      typespec.explicit_type = CppSettings::umlType(type);
      if (typespec.explicit_type.isEmpty()) {
	// search for equivalent forms
	if (type == "long int")
	  typespec.explicit_type = CppSettings::umlType("long");
	else if (type == "long")
	  typespec.explicit_type = CppSettings::umlType("long int");
	else if (type == "unsigned long int")
	  typespec.explicit_type = CppSettings::umlType("unsigned long");
	else if (type == "unsigned long")
	  typespec.explicit_type = CppSettings::umlType("unsigned long int");
	else if (type == "unsigned")
	  typespec.explicit_type = CppSettings::umlType("unsigned int");
	else if (type == "unsigned int")
	  typespec.explicit_type = CppSettings::umlType("unsigned");
	else if ((type == "signed") || (type == "signed int"))
	  typespec.explicit_type = CppSettings::umlType("int");
      }
      
      if (typespec.explicit_type.isEmpty()) {
	typespec.explicit_type = type; /*
	if (!Lex::identifierp(type, TRUE))
	  typespec.explicit_type = type;
	else {
	  Q3CString t = type;
	  
	  while ((index = t.find(':')) == 0)
	    t = t.mid(1);
	  
	  ClassContainer * cc = Package::unknown();
	  
	  while (index != -1) {
	    if ((cc = cc->declare_if_needed(t.left(index))) == 0) {
	      typespec.explicit_type = type;
	      return;
	    }
	    
	    while (t[index] == ':')
	      index += 1;
	    t = t.mid(index);
	    index = t.find(':');
	  }
	  
	  if (((cc = cc->declare_if_needed(t)) == 0) ||
	      ((typespec.type = ((Class *) cc)->get_uml()) == 0))
	    typespec.explicit_type = type;
	}*/
      }
      typespec.type = 0;
    }
  }
  
  if ((typespec.type != 0) &&
      !typespec.type->formals().isEmpty() &&
      (type.at(type.length() - 1) == '>') &&
      (!typespec.type->inside_its_definition() ||
       !typespec.type->is_itself((normalized.isEmpty()) ? Lex::normalize(type)
							: normalized))) {
    typespec.type = 0;
    typespec.explicit_type = type;
  }
}
开发者ID:SciBoy,项目名称:douml,代码行数:101,代码来源:ClassContainer.cpp

示例13: compute_dependency

// Between template < and > I suppose that a type is not included
// because I cannot know how the type is used and I do not want to
// produce circular #include
bool UmlClassMember::compute_dependency(Q3PtrList<CppRefType> & dependencies,
                                        Q3CString decl, const UmlTypeSpec & t,
                                        bool force_incl)
{
    remove_comments(decl);
    remove_preprocessor(decl);
    remove_arrays(decl);

    int template_level = 0;
    bool have_type = FALSE;
    const char * p = decl;
    const char * dontsubstituteuntil = 0;

    for (;;) {
        UmlTypeSpec ts;
        char c;
        bool dontsearchend = FALSE;

        // search word beginning
        while ((c = *p) != 0) {
            if ((c == '_') ||
                    ((c >= 'a') && (c <= 'z')) ||
                    ((c >= 'A') && (c <= 'Z')))
                break;
            else if (dontsubstituteuntil != 0) {
                if (p >= dontsubstituteuntil)
                    dontsubstituteuntil = 0;
                else
                    p += 1;
            }
            else if (c == '=')
                // init, all is done
                return have_type;
            else if (!strncmp(p, "${type}", 7)) {
                p += 7;
                ts = t;
                if (ts.type != 0) {
                    dontsearchend = TRUE;
                    break;
                }
                else {
                    decl = ts.explicit_type + p;
                    p = decl;
                }
            }
            else {
                switch (c) {
                case '<':
                    template_level += 1;
                    break;
                case '>':
                    template_level -= 1;
                }
                p += 1;
            }
        }

        if (c == 0)
            return have_type;

        if (!dontsearchend) {
            // search word end
            const char * p2 = p;

            ts.type = 0;
            ts.explicit_type = p2;
            p += 1;

            while ((c = *p) != 0) {
                if ((c == '_') ||
                        (c == ':') ||
                        ((c >= 'a') && (c <= 'z')) ||
                        ((c >= 'A') && (c <= 'Z')) ||
                        ((c >= '0') && (c <= '9')))
                    p += 1;
                else {
                    ts.explicit_type.truncate(p - p2);
                    break;
                }
            }

//#warning NAMESPACE

            if (dontsubstituteuntil == 0) {
                Q3CString subst = CppSettings::type(ts.explicit_type);

                if (subst != ts.explicit_type) {
                    decl = subst + ' ' + p;
                    p = decl;
                    dontsubstituteuntil = p + subst.length();
                    continue;
                }
            }
        }

        // check manually added keyword
        if ((ts.explicit_type == "const") ||
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: c

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));
//.........这里部分代码省略.........
开发者ID:mpvader,项目名称:qt,代码行数:101,代码来源:tst_q3cstring.cpp

示例15: gen_app

void UmlArtifact::gen_app(const Q3CString & path) {
  Q3CString target;
  Q3CString pro;

  propertyValue("genpro target", target);
  propertyValue("genpro pro", pro);

  if (target.isEmpty()) {
    if ((target = name()) == "executable")
      target = UmlPackage::getProject()->name();
#ifdef WIN32
    target += ".exe";
#endif
  }

  if (pro.isEmpty()) {
    pro = target;
#ifdef WIN32
    if (pro.right(4) == ".exe")
      pro.resize(pro.length() - 4);
#endif
    
    QDir d(path);
    
    pro = d.absFilePath(pro + ".pro");
  }

  Q3CString tmplt;
  Q3CString config;
  Q3CString defines;
  Q3CString includepath;
  Q3CString dependpath;
  Q3CString objectsdir;
  Q3CString footer;

  if (!propertyValue("genpro tmplt", tmplt))
    tmplt = "app";
  if (!propertyValue("genpro config", config))
    config = "debug warn_on qt";
  if (!propertyValue("genpro defines", defines))
    defines = "WITHCPP WITHJAVA WITHPHP WITHPYTHON WITHIDL";
  else if (defines.find("WITHPHP") == -1) {
    int n = 0;
    
    if (defines.find("WITHCPP") != -1)
      n += 1;
    
    if (defines.find("WITHJAVA") != -1)
      n += 1;
    
    if (defines.find("WITHIDL") != -1)
      n += 1;
    
    if (n > 1)
      defines += " WITHPHP WITHPYTHON";
  }
  else if (defines.find("WITHPYTHON") == -1) {
    int n = 0;
    
    if (defines.find("WITHCPP") != -1)
      n += 1;
    
    if (defines.find("WITHJAVA") != -1)
      n += 1;
    
    if (defines.find("WITHIDL") != -1)
      n += 1;
    
    if (defines.find("WITHPHP") != -1)
      n += 1;
    
    if (n > 1)
      defines += " WITHPYTHON";
  }
  propertyValue("genpro includepath", includepath);
  propertyValue("genpro dependpath", dependpath);
  propertyValue("genpro objectsdir", objectsdir);
  propertyValue("genpro footer", footer);
  
  for (;;) {
    Dialog dialog(this, path, pro, target, tmplt, config, defines,
		  includepath, dependpath, objectsdir, footer);
    
    if (dialog.exec() != QDialog::Accepted)
      return;
    
    set_PropertyValue("genpro pro", pro);
    set_PropertyValue("genpro path", path);
    set_PropertyValue("genpro target", target);
    set_PropertyValue("genpro tmplt", tmplt);
    set_PropertyValue("genpro config", config);
    set_PropertyValue("genpro defines", defines);
    set_PropertyValue("genpro includepath", includepath);
    set_PropertyValue("genpro dependpath", dependpath);
    set_PropertyValue("genpro objectsdir", objectsdir);
    set_PropertyValue("genpro footer", footer);

    QFile f(pro);
    
    if (! f.open(QIODevice::WriteOnly))
//.........这里部分代码省略.........
开发者ID:SciBoy,项目名称:douml,代码行数:101,代码来源:UmlArtifact.cpp


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