本文整理汇总了C++中QCString::replace方法的典型用法代码示例。如果您正苦于以下问题:C++ QCString::replace方法的具体用法?C++ QCString::replace怎么用?C++ QCString::replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCString
的用法示例。
在下文中一共展示了QCString::replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rename
static bool rename(QCString & s, bool java, bool javasettings)
{
static const struct {
const char * o;
const char * n;
bool java_only;
} T[] = {
{ "enumDecl", "enumPatternDecl", FALSE },
{ "set_EnumDecl", "set_EnumPatternDecl", FALSE },
{ "enumItemDecl", "enumPatternItemDecl", FALSE },
{ "set_EnumItemDecl", "set_EnumPatternItemDecl", FALSE },
{ "enumItemCase", "enumPatternItemCase", FALSE },
{ "set_EnumItemCase", "set_EnumPatternItemCase", FALSE },
{ "setJavaEnumDeclCmd", "setJavaEnumPatternDeclCmd", FALSE },
{ "setJavaEnumItemDeclCmd", "setJavaEnumPatternItemDeclCmd", FALSE },
{ "setJavaEnumItemCaseCmd", "setJavaEnumPatternItemCaseCmd", FALSE },
{ "_setJavaEnumDeclCmd", "_setJavaEnumPatternDeclCmd", TRUE },
{ "_setJavaEnumItemDeclCmd", "_setJavaEnumPatternItemDeclCmd", TRUE },
{ "_setJavaEnumItemCaseCmd", "_setJavaEnumPatternItemCaseCmd", TRUE },
{ "_enum_decl", "_enum_pattern_decl", FALSE },
{ "_enum_item_decl", "_enum_pattern_item_decl", FALSE },
{ "_enum_item_case", "_enum_pattern_item_case", FALSE }
};
int t_index;
bool changed = FALSE;
for (t_index = 0; t_index != sizeof(T)/sizeof(T[0]); t_index += 1) {
if (!T[t_index].java_only || java) {
QCString o = T[t_index].o;
if (!javasettings)
o = ((java) ? "JavaSettings." : "JavaSettings::") + o;
int o_len = o.length();
QCString n = T[t_index].n;
if (!javasettings)
n = ((java) ? "JavaSettings." : "JavaSettings::") + n;
int n_len = n.length();
int index = 0;
while ((index = s.find(o, index)) != -1) {
if (((index == 0) || is_sep(s[index - 1])) &&
is_sep(s[index + o_len])) {
s.replace(index, o_len, n);
index += n_len;
changed = TRUE;
}
else
index += 1;
}
}
}
return changed;
}
示例2: replace_alias
void UmlItem::replace_alias(QCString & s) {
int index = 0;
while ((index = s.find("@{", index)) != -1) {
int index2 = s.find('}', index + 2);
if (index2 == -1)
return;
UmlBaseItem * obj = this;
QCString key = s.mid(index + 2, index2 - index - 2);
QCString 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;
}
}
}
}
示例3: remove_comments
void UmlClassItem::remove_comments(QCString & s)
{
int index1 = 0;
while ((index1 = s.find('/', index1)) != -1) {
int index2;
switch (((const char *) s)[index1 + 1]) {
case '/':
if ((index2 = s.find('\n', index1 + 2)) != -1)
s.remove(index1, index2 - index1 + 1);
else
s.truncate(index1);
break;
case '*':
if ((index2 = s.find("*/", index1 + 2)) != -1)
s.replace(index1, index2 - index1 + 1, " ");
else
s.truncate(index1);
break;
default:
index1 += 1;
}
}
}
示例4: abbreviate
//----------------------------------------------------------------------------
// some quasi intelligent brief description abbreviator :^)
QCString abbreviate(const char *s,const char *name)
{
QCString scopelessName=name;
int i=scopelessName.findRev("::");
if (i!=-1) scopelessName=scopelessName.mid(i+2);
QCString result=s;
result=result.stripWhiteSpace();
// strip trailing .
if (!result.isEmpty() && result.at(result.length()-1)=='.')
result=result.left(result.length()-1);
// strip any predefined prefix
QStrList &briefDescAbbrev = Config_getList("ABBREVIATE_BRIEF");
const char *p = briefDescAbbrev.first();
while (p)
{
QCString s = p;
s.replace(QRegExp("\\$name"), scopelessName); // replace $name with entity name
s += " ";
stripWord(result,s);
p = briefDescAbbrev.next();
}
// capitalize first word
if (!result.isEmpty())
{
int c=result[0];
if (c>='a' && c<='z') c+='A'-'a';
result[0]=c;
}
return result;
}
示例5: write
void UmlClass::write(QTextOStream & f) {
if (isJavaExternal()) {
QCString s = javaDecl().stripWhiteSpace();
int index;
if ((index = s.find("${name}")) != -1)
s.replace(index, 7, name());
else if ((index = s.find("${Name}")) != -1)
s.replace(index, 7, capitalize(name()));
else if ((index = s.find("${NAME}")) != -1)
s.replace(index, 7, name().upper());
else if ((index = s.find("${nAME}")) != -1)
s.replace(index, 7, name().lower());
f << s;
}
else {
UmlClass * toplevel = this;
UmlItem * p;
QCString s2;
while ((p = toplevel->parent())->kind() == aClass) {
toplevel = (UmlClass *) p;
s2 = dot + p->name() + s2;
}
UmlArtifact * cp = toplevel->associatedArtifact();
UmlPackage * pack = (UmlPackage *)
((cp != 0) ? (UmlItem *) cp : (UmlItem *) toplevel)->package();
if (pack != UmlArtifact::generation_package()) {
QCString s = pack->javaPackage();
if (! s.isEmpty() && (s != "java.lang") && (s.left(10) != "java.lang.")) {
s += s2;
if (JavaSettings::isForcePackagePrefixGeneration() ||
!UmlArtifact::generated_one()->is_imported(s, name()))
f << s << '.';
}
}
else if (! s2.isEmpty())
f << s2.mid(1) << '.';
f << name();
}
}
示例6: replace
QCString replace(QCString f, QCString k, QCString v)
{
int index = f.find(k);
return (index != -1)
? f.replace(index, k.length(), v)
: f;
}
示例7: set_java
void UmlOperation::set_java(const char * return_form,
const char * params, QCString body,
bool inlinep) {
QCString s = JavaSettings::operationDef();
int index = s.find("${type}");
s.replace(index, 7, return_form);
s.insert(s.find("${)}", index), params);
if (inlinep) {
s.replace(s.findRev("${body}"), 7, body);
set_JavaDef(s);
}
else {
set_JavaDef(s);
set_JavaBody(body);
}
}
示例8: remove_arrays
void UmlClassItem::remove_arrays(QCString & s)
{
int index1 = 0;
while ((index1 = s.find('[', index1)) != -1) {
int index2 = index1 = s.find(']', index1 + 1);
if (index2 == -1) {
s.truncate(index1);
return;
}
else
s.replace(index1, index2 - index1 + 1, " ");
}
}
示例9: legalName
QCString legalName(QCString s)
{
for (unsigned index = 0; index != s.length(); index += 1) {
char c = s.at(index);
if ((c != '_') &&
!((c >= 'a') && (c <= 'z')) &&
!((c >= 'A') && (c <= 'Z')) &&
!((c >= '0') && (c <= '9'))) {
s.replace(index, 1, "__");
index += 1;
}
}
return s;
}
示例10: addSlotBinding
void JSObjectProxy::addSlotBinding( const QCString &name, KJS::ExecState *exec, KJS::Object &object ) {
// Lookup and bind slot
QMetaObject * mo = obj->metaObject();
int slotid = mo->findSlot( name.data(), true );
if ( slotid == -1 )
return ;
const QMetaData *md = mo->slot( slotid, true );
if ( md->access != QMetaData::Public )
return ;
// Find signature
int id = Bindings::JSSlotUtils::findSignature( name );
// kdDebug( 80001 )<<"JSObjectProxy::addSlotBinding()::slot:"<<name<<" id:"<<id<<endl;
if ( id < 0 )
return ;
QCString jsname = name;
jsname.detach();
jsname.replace( QRegExp( "\\([^\\)]*\\)" ), "" );
// Find the return type, we only care if it is a pointer type
const QUMethod *m = md->method;
const char *retclass = 0;
QCString ptr( "ptr" );
if ( m->count && ( m->parameters->inOut == QUParameter::Out )
&& ( ptr == m->parameters->type->desc() ) ) {
retclass = ( const char * ) m->parameters->typeExtra;
// kdDebug(80001) << "Return type is a pointer, type " << retclass << endl;
}
// Create the Imp
JSObjectProxyImp *imp = new JSObjectProxyImp( exec, JSObjectProxyImp::MethodSlot,
retclass ? retclass : "", id, name, this );
if ( !object.hasProperty( exec, KJS::Identifier( jsname ) ) ) {
// The identifier is unused
object.put( exec, KJS::Identifier( jsname.data() ), KJS::Object( imp ) );
} else {
// The identifier has already been used
QString s( name );
QCString cs = QString( "%1%2" ).arg( jsname ).arg( s.contains( ',' ) + 1 ).ascii();
//kdDebug(80001) << "Method " << jsname << " exists, using " << cs << " for " << s << endl;
object.put( exec, KJS::Identifier( cs.data() ), KJS::Object( imp ) );
}
}
示例11: save
void MonitorWindow::save()
{
QString s = QFileDialog::getSaveFileName ("sim.log", QString::null, this);
if (s.isEmpty()) return;
QFile f(s);
if (!f.open(IO_WriteOnly)){
QMessageBox::warning(this, i18n("Error"), i18n("Can't create file %1") .arg(s));
return;
}
QCString t;
if (edit->hasSelectedText()){
t = unquoteText(edit->selectedText()).local8Bit();
}else{
t = unquoteText(edit->text()).local8Bit();
}
#if defined(WIN32) || defined(__OS2__)
t.replace(QRegExp("\n"),"\r\n");
#endif
f.writeBlock(t, t.length());
}
示例12: namespacify
QString Namespace::namespacify(QCString s, bool local) {
QString r;
int index = s.find("::");
if (index == 0)
r = ((const char *) s) + 2;
else {
if (index != -1) {
QMap<QCString,QCString>::ConstIterator it =
Aliases.find(s.left(index));
if (it != Aliases.end())
s.replace(0, index, *it);
}
r = (Stack.isEmpty())
? QString(s)
: Stack.last() + QString(s);
}
return (local)
? r + "\n" + Lex::filename()
: r;
}
示例13: compute
void CppRefType::compute(QList<CppRefType> & dependencies,
const QCString & hdef, const QCString & srcdef,
QCString & h_incl, QCString & decl, QCString & src_incl,
UmlArtifact * who)
{
UmlPackage * pack = who->package();
QCString hdir;
QCString srcdir;
if (CppSettings::isRelativePath()) {
QCString empty;
hdir = pack->header_path(empty);
srcdir = pack->source_path(empty);
}
else if (CppSettings::isRootRelativePath())
hdir = srcdir = UmlPackage::rootDir();
// aze.cpp includes aze.h
src_incl += "#include \"";
if (CppSettings::includeWithPath())
src_incl += pack->header_path(who->name(), srcdir);
else {
src_incl += who->name();
src_incl += '.';
src_incl += CppSettings::headerExtension();
}
src_incl += "\"\n";
h_incl = ""; // to not be QCString::null
decl = ""; // to not be QCString::null
CppRefType * ref;
for (ref = dependencies.first(); ref != 0; ref = dependencies.next()) {
UmlClass * cl = (ref->type.type)
? ref->type.type
: UmlBaseClass::get(ref->type.explicit_type, 0);
bool included = ref->included;
QCString hform; // form in header
QCString srcform; // form in source
if (cl == 0) {
QCString in = CppSettings::include(ref->type.explicit_type);
if (!in.isEmpty())
hform = srcform = in + '\n';
else
// doesn't know what it is
continue;
}
else if (cl->isCppExternal()) {
hform = cl->cppDecl();
int index;
if ((index = hform.find('\n')) == -1)
// wrong form
continue;
hform = hform.mid(index + 1) + '\n';
for (;;) {
if ((index = hform.find("${name}")) != -1)
hform.replace(index, 7, cl->name());
else if ((index = hform.find("${Name}")) != -1)
hform.replace(index, 7, capitalize(cl->name()));
else if ((index = hform.find("${NAME}")) != -1)
hform.replace(index, 7, cl->name().upper());
else if ((index = hform.find("${nAME}")) != -1)
hform.replace(index, 7, cl->name().lower());
else
break;
}
srcform = hform;
}
else {
QCString st = cl->cpp_stereotype();
if ((st == "enum") || (st == "typedef"))
included = TRUE;
UmlArtifact * art = cl->associatedArtifact();
if (art != 0) {
if (art == who)
// don't include itself
continue;
if (CppSettings::includeWithPath()) {
UmlPackage * p = art->package();
hform = "#include \"" + p->header_path(art->name(), hdir) + "\"\n";
srcform = "#include \"" + p->header_path(art->name(), srcdir) + "\"\n";
}
else
srcform = hform = "#include \"" + art->name() + '.' +
CppSettings::headerExtension() + "\"\n";
}
else if (cl->parent()->kind() != aClass) {
write_trace_header();
UmlCom::trace(QCString(" <font color=\"red\"><b> class<i> ") + cl->name() +
//.........这里部分代码省略.........
示例14: fromImage
QString KXFace::fromImage(const QImage &image)
{
if(image.isNull())
return QString::null;
QImage scaledImg = image.smoothScale(48, 48);
QByteArray ba;
QBuffer buffer(ba);
buffer.open(IO_WriteOnly);
scaledImg.save(&buffer, "XBM");
QString xbm(ba);
xbm.remove(0, xbm.find("{") + 1);
xbm.truncate(xbm.find("}"));
xbm.remove(" ");
xbm.remove(",");
xbm.remove("0x");
xbm.remove("\n");
xbm.truncate(576);
QCString tmp = QCString(xbm.latin1());
uint len = tmp.length();
for(uint i = 0; i < len; ++i)
{
switch(tmp[i])
{
case '1':
tmp[i] = '8';
break;
case '2':
tmp[i] = '4';
break;
case '3':
tmp[i] = 'c';
break;
case '4':
tmp[i] = '2';
break;
case '5':
tmp[i] = 'a';
break;
case '7':
tmp[i] = 'e';
break;
case '8':
tmp[i] = '1';
break;
case 'A':
case 'a':
tmp[i] = '5';
break;
case 'B':
case 'b':
tmp[i] = 'd';
break;
case 'C':
case 'c':
tmp[i] = '3';
break;
case 'D':
case 'd':
tmp[i] = 'b';
break;
case 'E':
case 'e':
tmp[i] = '7';
break;
}
if(i % 2)
{
char t = tmp[i];
tmp[i] = tmp[i - 1];
tmp[i - 1] = t;
}
}
tmp.replace(QRegExp("(\\w{12})"), "\\1\n");
tmp.replace(QRegExp("(\\w{4})"), "0x\\1,");
len = tmp.length();
char *fbuf = (char *)malloc(len + 1);
strncpy(fbuf, (const char *)tmp, len);
fbuf[len] = '\0';
if(!(status = setjmp(comp_env)))
{
ReadFace(fbuf);
GenFace();
CompAll(fbuf);
}
QString ret(fbuf);
free(fbuf);
return ret;
}
示例15: set_cpp
void UmlOperation::set_cpp(const char * return_form_or_inherit,
const char * params, QCString body,
bool inlinep, const char * if_def,
const char * end_if) {
if (*return_form_or_inherit == ':') {
// inherit
if (inlinep) {
QCString s = remove_throw(CppSettings::operationDecl());
int index = s.find("${)}");
s.resize(index + 5);
s.insert(index, params);
s.append(" ");
s.append(return_form_or_inherit);
if (!body.isEmpty()) {
s.append(" {\n ");
s.append(body);
s.append("}\n");
}
else
s.append(" {\n}\n");
conditional(s, if_def, end_if);
set_CppDecl(s);
set_CppDef("");
}
else {
QCString s = remove_throw(CppSettings::operationDecl());
int index = s.find("${)}");
s.resize(index + 5);
s.insert(index, params);
s.append(";");
conditional(s, if_def, end_if);
set_CppDecl(s);
s = remove_throw(CppSettings::operationDef());
index = s.find("${)}");
s.resize(index + 5);
s.insert(index, params);
s.append(" ");
s.append(return_form_or_inherit);
if (!body.isEmpty()) {
s.append(" {\n ");
s.append(body);
s.append("}\n");
}
else
s.append(" {\n}\n");
conditional(s, if_def, end_if);
set_CppDef(s);
}
}
else {
// return
if (inlinep) {
QCString s = remove_throw(CppSettings::operationDecl());
int index = s.find("${type}");
s.replace(index, 7, return_form_or_inherit);
s.insert(s.find("${)}", index), params);
s.resize(s.findRev(";") + 1);
if (!body.isEmpty()) {
s.append(" {\n ");
s.append(body);
s.append("}\n");
}
else
s.append(" {\n}\n");
conditional(s, if_def, end_if);
set_CppDecl(s);
set_CppDef("");
}
else {
QCString s = remove_throw(CppSettings::operationDecl());
int index = s.find("${type}");
s.replace(index, 7, return_form_or_inherit);
s.insert(s.find("${)}", index), params);
conditional(s, if_def, end_if);
set_CppDecl(s);
s = remove_throw(CppSettings::operationDef());
index = s.find("${type}");
s.replace(index, 7, return_form_or_inherit);
s.insert(s.find("${)}", index), params);
conditional(s, if_def, end_if);
set_CppDef(s);
set_CppBody(body);
}
}
}