本文整理汇总了C++中Q3CString::replace方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3CString::replace方法的具体用法?C++ Q3CString::replace怎么用?C++ Q3CString::replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q3CString
的用法示例。
在下文中一共展示了Q3CString::replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: digest
Q3CString Dialog::digest(const QString s)
{
Q3CString c = (const char *) s;
int index;
index = 0;
while ((index = c.find("\\n", index)) != -1) {
c.replace(index, 2, "\n");
index += 1;
}
index = 0;
while ((index = c.find("\\t", index)) != -1) {
c.replace(index, 2, "\t");
index += 1;
}
index = 0;
while ((index = c.find("\r", index)) != -1) {
c.remove(index, 1);
}
return c;
}
示例2: fileControl
void UmlPackage::fileControl(bool ci) {
UmlPackage * prj = getProject();
Q3CString prjfile = prj->supportFile();
BooL rec;
BooL reload;
Q3CString cmd;
if (! prj->propertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd))
cmd = "specify the command containing %file and %dir or %dironly";
Dialog dialog(ci, cmd, rec, reload); // the dialog execution set 'cmd' and 'rec'
if (dialog.exec() == QDialog::Accepted) {
// save the command for a future usage
prj->set_PropertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd);
if (reload)
saveProject();
// get files list
Q3Dict<void> files;
getFiles(files, (rec) ? ~0u : 1);
if (this == prj)
getAuxFiles(files);
// apply the command on each file
Q3DictIterator<void> it(files);
QFileInfo prjpath(prjfile);
QString dir = prjpath.dirPath(TRUE);
QString dironly = dir;
int index;
if ((dironly.length() > 3) &&
(((const char *) dironly)[1] == ':') &&
(((const char *) dironly)[2] == '/'))
dironly = dironly.mid(2);
while ((index = cmd.find("%dironly")) != -1)
cmd.replace(index, 8, dironly);
while ((index = cmd.find("%dir")) != -1)
cmd.replace(index, 4, dir);
while (it.current()) {
QString s = cmd;
while ((index = s.find("%file")) != -1)
s.replace(index, 5, it.currentKey());
system((const char *) s);
++it;
}
UmlCom::trace("Done.");
if (reload)
loadProject(prjfile);
}
}
示例3: compute_dependency
void UmlRelation::compute_dependency(Q3PtrList<CppRefType> & dependencies,
const Q3CString & cl_stereotype,
bool all_in_h) {
if (cl_stereotype == "enum")
return;
switch (relationKind()) {
case aDependency:
if (stereotype() == "friend")
break;
CppRefType::add(roleType(), dependencies, cppDecl() != "#include in source",
roleType()->isCppExternal());
break;
case aGeneralisation:
case aRealization:
CppRefType::add(roleType(), dependencies, TRUE);
break;
default:
Q3CString decl = cppDecl();
int index;
if ((index = decl.find("${static}")) != -1)
decl.remove((unsigned) index, 9);
if ((index = decl.find("${mutable}")) != -1)
decl.remove((unsigned) index, 10);
if ((index = decl.find("${volatile}")) != -1)
decl.remove((unsigned) index, 11);
if ((index = decl.find("${const}")) != -1)
decl.remove((unsigned) index, 8);
if ((index = decl.find("${multiplicity}")) != -1)
decl.remove((unsigned) index, 15);
if ((index = decl.find("${name}")) != -1)
decl.remove((unsigned) index, 7);
if ((index = decl.find("${inverse_name}")) != -1)
decl.remove((unsigned) index, 15);
if ((index = decl.find("${value}")) != -1)
decl.remove((unsigned) index, 8);
if ((index = decl.find("${h_value}")) != -1)
decl.remove((unsigned) index, 10);
if ((index = decl.find("${stereotype}")) != -1)
decl.replace((unsigned) index, 13,
CppSettings::relationAttributeStereotype(stereotype()));
if ((index = decl.find("${association}")) != -1) {
decl.replace((unsigned) index, 14,
association().toString());
}
replace_alias(decl);
UmlTypeSpec type;
type.type = roleType();
UmlClassMember::compute_dependency(dependencies, decl, type, all_in_h);
}
}
示例4: write_type
void UmlClassMember::write_type(FileOut & out, const UmlTypeSpec & t, Q3CString s, const char * k_name, const char * k_type)
{
s = s.simplifyWhiteSpace();
int index;
// remove k_name and all after it except []
if (k_name && *k_name && ((index = s.find(k_name, 0)) != -1)) {//[rageek] Removed CS=FALSE - rethink this, case sensitive
//remove name
s.remove(index, strlen(k_name));
for (;;) {
if (s[index] == ' ')
s.remove(index, 1);
if (s[index] != '[')
break;
index += 1;
int index2;
if ((index2 = s.find(index, ']')) == -1)
break;
index = index2 + 1;
}
s.resize(index);
}
else if ((index = s.find('=')) != -1) {
s.resize(index);
s = s.simplifyWhiteSpace();
}
if (k_type && *k_type && ((index = s.find(k_type)) == -1))
out.idref_datatype(s);
else if (s != k_type) {
// have modifiers
if (t.type != 0) {
s.replace(index, strlen(k_type), t.type->name());
out.idref(s, t.type);
}
else
out.idref_datatype(s.replace(index, strlen(k_type), t.explicit_type));
}
else if (t.type != 0)
out.idref(t.type);
else
out.idref_datatype(t.explicit_type);
}
示例5: remove_comments
void UmlClassMember::remove_comments(Q3CString & s)
{
int index1 = 0;
if ((index1 = s.find("${comment}")) != -1)
s.remove((unsigned) index1, 10);
else if ((index1 = s.find("${description}")) != -1)
s.remove((unsigned) index1, 14);
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;
}
}
}
示例6: create_directory
static void create_directory(Q3CString s)
{
int index = 0;
QChar sep = QDir::separator();
if (sep != '/') {
while ((index = s.find(sep, index)) != -1)
s.replace(index++, 1, "/");
}
s = QDir::cleanDirPath(s) + "/";
index = s.find("/");
int index2;
while ((index2 = s.find("/", index + 1)) != -1) {
Q3CString s2 = s.left(index2);
QDir sd(s2);
if (!sd.exists()) {
if (!sd.mkdir(s2)) {
UmlCom::trace(Q3CString("<font color=\"red\"><b> cannot create directory <i>")
+ s2 + "</i></b></font><br>");
UmlCom::bye(n_errors() + 1);
UmlCom::fatal_error("UmlPackage::file_path");
}
}
index = index2;
}
}
示例7: 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;
}
}
}
}
示例8: html
void UmlExitPointPseudoState::html(Q3CString pfix, unsigned int rank, unsigned int level) {
define();
UmlCom::message(name());
Q3CString s = sKind();
s.replace(0, 1, s.left(1).upper());
UmlItem::html(s, (UmlDiagram *) 0);
fw.write("<p>Defined in ");
if (parent()->kind() == aRegion)
parent()->parent()->write();
else
parent()->write();
fw.write("</p>");
if (reference() != 0) {
fw.write("<p>References ");
reference()->write();
fw.write("</p>");
}
write_children(pfix, rank, level);
unload(FALSE, FALSE);
}
示例9: write
void UmlClass::write(QTextOStream & f) {
if (isJavaExternal()) {
Q3CString 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;
Q3CString 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()) {
Q3CString 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();
}
}
示例10: new_one
bool UmlAttribute::new_one(Class * container, Q3CString name,
aVisibility visibility, bool constp,
bool staticp, const Q3CString & value,
Q3CString comment, Q3CString description)
{
#ifdef TRACE
cout << "ATTRIBUTE '" << name << "'\n";
#endif
#ifndef REVERSE
if (visibility == PrivateVisibility)
return TRUE;
#endif
if (((const char *) name)[0] == '$')
name = name.mid(1);
UmlClass * cl = container->get_uml();
UmlAttribute * at = UmlBaseAttribute::create(cl, name);
if (at == 0) {
PhpCatWindow::trace(Q3CString("<font face=helvetica><b>cannot add attribute <i>")
+ name + "</i> in <i>" + cl->name()
+ "</i></b></font><br>");
return FALSE;
}
#ifdef REVERSE
Statistic::one_attribute_more();
#endif
if (!comment.isEmpty()) {
Q3CString s = (at->phpDecl().find("${description}") != -1)
? description : comment;
UmlTypeSpec t;
int index;
if (! (t.explicit_type = value_of(s, "@var", index)).isEmpty()) {
at->set_Type(t);
s.replace(index, t.explicit_type.length(), "${type}");
}
at->set_Description(s);
}
if (constp)
at->set_isReadOnly(TRUE);
if (staticp)
at->set_isClassMember(TRUE);
if (! value.isEmpty())
at->set_DefaultValue(value);
at->set_Visibility(visibility);
return TRUE;
}
示例11: importIdlConstant
void UmlClass::importIdlConstant(UmlItem * parent, const Q3CString & id, const Q3CString & s, const Q3CString & doc, Q3Dict<Q3CString> & prop)
{
// use a class to define the constant !
UmlClass * x;
if ((x = UmlClass::create(parent, legalName(s))) == 0) {
UmlCom::trace("<br>cannot create class '" + s + "' in " +
parent->fullName());
throw 0;
}
newItem(x, id);
x->lang = Corba;
x->set_Stereotype("constant");
if (!doc.isEmpty())
x->set_Description(doc);
Q3CString type;
Q3CString value;
Q3CString * v;
if ((v = prop.find("CORBA/ImplementationType")) != 0) {
type = *v;
prop.remove("CORBA/ImplementationType");
}
if ((v = prop.find("CORBA/ConstValue")) != 0) {
if (!v->isEmpty())
value = " = " + *v;
prop.remove("CORBA/ConstValue");
}
Q3CString d = IdlSettings::constDecl();
int index;
if ((index = d.find("${type}")) != -1)
d.replace(index, 7, type);
if ((index = d.find("${value}")) != -1)
d.replace(index, 8, value);
x->setProperties(prop);
x->set_IdlDecl(d);
}
示例12: write_cpp_type
void UmlAttribute::write_cpp_type(FileOut & out)
{
// note : doesn't manage function/operation pointer
Q3CString s = cppDecl();
int index;
remove_comments(s);
// remove keywords not linked to the type
if ((index = s.find("${static}")) != -1)
s.replace(index, 9, " ");
if ((index = s.find("${mutable}")) != -1)
s.replace(index, 10, (isCppMutable()) ? "mutable " : "");
if ((index = s.find("${volatile}")) != -1)
s.replace(index, 11, (isVolatile()) ? "volatile " : "");
if ((index = s.find("${value}")) != -1)
s.replace(index, 8, " ");
if ((index = s.find("${h_value}")) != -1)
s.replace(index, 10, " ");
// replace keywords linked to the type
if ((index = s.find("${const}")) != -1)
s.replace(index, 8, isReadOnly() ? "const" : "");
UmlTypeSpec t = type();
if (t.type == 0)
t.explicit_type = CppSettings::type(t.explicit_type);
write_type(out, t, s, "${name}", "${type}");
}
示例13: remove_arrays
void UmlClassMember::remove_arrays(Q3CString & 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, " ");
}
}
示例14: compute_dependency
void UmlAttribute::compute_dependency(Q3PtrList<CppRefType> & dependency,
const Q3CString & cl_stereotype,
bool all_in_h) {
if ((cl_stereotype == "enum") || (cl_stereotype == "typedef"))
return;
Q3CString decl = cppDecl();
int index;
if ((index = decl.find("${static}")) != -1)
decl.remove((unsigned) index, 9);
if ((index = decl.find("${mutable}")) != -1)
decl.remove((unsigned) index, 10);
if ((index = decl.find("${volatile}")) != -1)
decl.remove((unsigned) index, 11);
if ((index = decl.find("${const}")) != -1)
decl.remove((unsigned) index, 8);
if ((index = decl.find("${multiplicity}")) != -1)
decl.remove((unsigned) index, 15);
if ((index = decl.find("${value}")) != -1)
decl.remove((unsigned) index, 8);
if ((index = decl.find("${h_value}")) != -1)
decl.remove((unsigned) index, 10);
if ((index = decl.find("${name}")) != -1)
decl.remove((unsigned) index, 7);
if ((index = decl.find("${stereotype}")) != -1)
decl.replace((unsigned) index, 13,
CppSettings::relationAttributeStereotype(stereotype()));
replace_alias(decl);
if (!UmlClassMember::compute_dependency(dependency, decl, type(), all_in_h)) {
write_trace_header();
UmlCom::trace(Q3CString(" <font color=\"red\"><b>type missing for attribute <i>")
+ name() + "</i></b></font><br>");
incr_error();
}
}
示例15: namespacify
QString Namespace::namespacify(Q3CString s, bool local) {
QString r;
int index = s.find("::");
if (index == 0)
r = ((const char *) s) + 2;
else {
if (index != -1) {
QMap<Q3CString,Q3CString>::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;
}