本文整理汇总了C++中Q3CString::mid方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3CString::mid方法的具体用法?C++ Q3CString::mid怎么用?C++ Q3CString::mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q3CString
的用法示例。
在下文中一共展示了Q3CString::mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: true_name
Q3CString UmlClassMember::true_name(Q3CString decl) {
int index = decl.find("${name}", 0); //[rageek] Removed CS=FALSE param - rethink this, case sensitive
if (index == -1)
// too complicated, return the Uml one
return name();
int begin = index;
while ((begin != 0) && identChar(decl[begin - 1]))
begin -= 1;
int sup = index + 7;
while (identChar(decl[sup]))
sup += 1;
Q3CString r = decl.mid(begin, index - begin);
Q3CString k = decl.mid(index + 2, 4);
if (k == "name")
r += name();
else if (k == "Name")
r += name().left(1).upper() + name().mid(1);
else
// NAME
r += name().upper();
r += decl.mid(index + 7, sup - index - 7);
return r;
}
示例2: decl
Q3CString UmlClass::decl() {
Q3CString result;
Q3CString close_template;
UmlArtifact * cp = associatedArtifact();
Q3CString nasp = ((UmlPackage *)
((cp != 0) ? (UmlItem *) cp : (UmlItem *) this)->package())
->cppNamespace();
if (! nasp.isEmpty()) {
int index =
// bypass :: allowing ::a...
((nasp.at(0) == ':') && (nasp != "::")) ? 2 : 0;
int index2 = 0;
while ((index2 = nasp.find("::", index)) != -1) {
result += "namespace " + nasp.mid(index, index2 - index) + " { ";
close_template += " } ";
index = index2 + 2;
}
result += "namespace " + nasp.mid(index) + " { ";
close_template += " } ";
}
Q3CString template1;
Q3CString template2;
get_template_prefixes(template1, template2);
if (!template1.isEmpty())
result += template1.left(template1.length() - 1) + ' ';
result += cpp_stereotype() + ' ';
return result + name() + ';' + close_template + '\n';
}
示例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);
}
}
}
示例4: is_imported
bool UmlArtifact::is_imported(Q3CString path, Q3CString class_name) {
if (imports == 0) {
imports = new Q3AsciiDict<UmlArtifact>(17);
Q3CString s = javaSource();
int index = 0;
while ((index = s.find("import", index)) != -1) {
if ((index == 0) || (s[index - 1] < ' ')) {
int index2 = index + 6;
while ((s[index2] == ' ') || (s[index2] == '\t'))
index2 += 1;
if ((index2 != (index + 6)) &&
((index = s.find(';', index2)) != -1) &&
(index != index2)) {
Q3CString p = s.mid(index2, index - index2);
imports->insert(p, this);
}
else
index = index2;
}
else
index += 6;
}
}
return ((imports->find(path + '.' + class_name) != 0) ||
(imports->find(path + ".*") != 0));
}
示例5: write_multiplicity
void UmlItem::write_multiplicity(FileOut & out, Q3CString s, UmlItem * who)
{
if (!s.isEmpty()) {
Q3CString min;
Q3CString max;
int index = s.find("..");
if (index != -1) {
min = s.left(index).stripWhiteSpace();
max = s.mid(index+2).stripWhiteSpace();
}
else
min = max = s.stripWhiteSpace();
out.indent();
out << "<lowerValue xmi:type=\"uml:LiteralString\"";
out.id_prefix(who, "MULTIPLICITY_L_");
out << " value=\"" << min << "\"/>\n";
out.indent();
out << "<upperValue xmi:type=\"uml:LiteralString\"";
out.id_prefix(who, "MULTIPLICITY_U_");
out << " value=\"" << max << "\"/>\n";
}
}
示例6: write_relation
void UmlRelation::write_relation(FileOut & out) {
// note : it is the first side
if (_assoc_class != 0)
// generated in the association class
return;
const char * k = (_uml_20) ? "ownedElement" : "packagedElement";
out.indent();
out << '<' << k << " xmi:type=\"uml:Association\"";
out.id_prefix(this, "ASSOC_");
Q3CString s = name();
int i1 = s.find("(");
int i2 = s.findRev(")");
if ((i1 != -1) && (i2 != -1) && (i2 > i1) && (s[i1+1] != '<') && (s[i2-1] != '>')) {
s = s.mid(i1 + 1, i2 - i1 - 1);
if (!s.isEmpty()) {
out << " name=\"";
out.quote((const char*)s);//[jasa] ambiguous call
out << '"';
}
}
write_visibility(out);
out << ">\n";
write_ends(out);
out.indent();
out << "</" << k << ">\n";
}
示例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: QCOMPARE
void tst_Q3CString::mid()
{
Q3CString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
QCOMPARE(a.mid(3,3),(Q3CString)"DEF");
QCOMPARE(a.mid(0,0),(Q3CString)"");
QVERIFY(a.mid(9999).isNull());
QVERIFY(a.mid(9999,1).isNull());
Q3CString n;
QVERIFY(n.mid(3,3).isNull());
QVERIFY(n.mid(0,0).isNull());
QVERIFY(n.mid(9999,0).isNull());
QVERIFY(n.mid(9999,1).isNull());
}
示例9: 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;
}
示例10: define_datatypes
void FileOut::define_datatypes(bool uml_20, bool primitive_type, bool gen_extension) {
const char * pfix = (primitive_type)
? ((uml_20) ? "<ownedMember xmi:type=\"uml:PrimitiveType\""
: "<packagedElement xmi:type=\"uml:PrimitiveType\"")
: ((uml_20) ? "<ownedMember xmi:type=\"uml:DataType\""
: "<packagedElement xmi:type=\"uml:DataType\"");
QMap<Q3CString, int>::ConstIterator it;
for (it = _datatypes.begin();
it != _datatypes.end();
++it) {
indent();
(*this) << pfix << " xmi:id=\"BOUML_datatype_"
<< it.data() << "\" name=\"";
quote((const char*)it.key());//[jasa] ambiguous call
(*this) << "\"/>\n";
}
const char * postfix =
(uml_20) ? "</ownedMember>\n" : "</packagedElement>\n";
for (it = _modifiedtypes.begin();
it != _modifiedtypes.end();
++it) {
Q3CString k = it.key();
int index = k.find('_');
indent();
(*this) << pfix << " xmi:id=\"BOUML_basedontype_"
<< it.data() << "\" name = \"";
quote((const char*)k.mid(index + 1));
(*this) << '"';
if (gen_extension) {
(*this) << ">\n";
indent();
(*this) << "\t<xmi:Extension extender=\"Bouml\">\n";
indent();
(*this) << "\t\t<basedOn \"BOUML_" << k.left(index) << "\"/>\n";
indent();
(*this) << "\t</xmi:Extension>\n";
indent();
(*this) << postfix;
}
else
(*this) << "/>\n";
}
}
示例11: compute_name
Q3CString UmlOperation::compute_name(Q3CString s)
{
if (!s.isEmpty()) {
UmlClassMember * m = getOf();
if ((m != 0) || ((m = setOf()) != 0)) {
Q3CString n = (m->kind() == aRelation)
? ((UmlRelation *) m)->roleName()
: m->name();
int index;
if ((index = s.find("${name}")) != -1)
return s.left(index) + n + s.mid(index + 7);
else if ((index = s.find("${Name}")) != -1)
return s.left(index) + n.left(1).upper() + n.mid(1) + s.mid(index + 7);
else if ((index = s.find("${NAME}")) != -1)
return s.left(index) + n.upper() + s.mid(index + 7);
else
return s;
}
}
return name();
}
示例12: write_default_value
void UmlItem::write_default_value(FileOut & out, Q3CString v, UmlItem * who, int rank)
{
if (! v.isEmpty()) {
if (v[0] == '=') {
v = v.mid(1);
if (v.isEmpty())
return;
}
out.indent();
out << "<defaultValue xmi:type=\"uml:LiteralString\"";
if (rank == -1)
out.id_prefix(who, "VALUE_");
else
out.id_prefix(who, "VALUE", rank);
out << " value=\"";
out.quote((const char*)v);//[jasa] ambiguous call
out << "\"/>\n";
}
}
示例13: generate_imports
void UmlOperation::generate_imports(QTextOStream & f, Q3CString & made) {
Q3CString s = pythonDecl();
if (!s.isEmpty()) {
UmlArtifact * art = ((UmlClass *) parent())->assocArtifact();
returnType().generate_import(f, art, FALSE, made);
int index1 = s.find("${(}");
if (index1 == -1)
return;
index1 += 4;
int index2 = s.find("${)}", index1);
if(index2 == -1)
return;
s = s.mid((unsigned) index1, (unsigned) (index2 - index1));
const Q3ValueList<UmlParameter> & params = this->params();
Q3ValueListConstIterator<UmlParameter> it;
unsigned rank;
char ti[16];
strcpy(ti, "${p");
for (it = params.begin(), rank = 0;
it != params.end();
++it, rank += 1) {
sprintf(ti + 3, "%u}", rank);
if (s.find(ti) != -1)
(*it).type.generate_import(f, art, FALSE, made);
}
}
}
示例14: if
UmlClass * UmlClass::import(File & f, UmlItem * parent, const Q3CString & knd)
{
Q3CString s;
if (f.read(s) != STRING)
f.syntaxError(s, "class's name");
Q3CString id;
Q3CString ste;
Q3CString doc;
Q3Dict<Q3CString> prop;
Q3CString s2;
int k;
do {
k = f.readDefinitionBeginning(s2, id, ste, doc, prop);
} while (id.isEmpty());
if (ste == "CORBAConstant") {
// not a class !
if (!scanning) {
if (parent->kind() == aClass)
UmlAttribute::importIdlConstant((UmlClass *) parent, id, s, doc, prop);
else
importIdlConstant(parent, id, s, doc, prop);
}
if (k != ')')
f.skipBlock();
return 0;
}
UmlClass * cl;
if (scanning) {
if (((cl = UmlBaseClass::create(parent, s)) == 0) &&
((cl = UmlBaseClass::create(parent, legalName(s))) == 0)) {
UmlCom::trace("<br>cannot create class '" + s + "' in " +
parent->fullName());
throw 0;
}
newItem(cl, id);
if (!ste.isEmpty()) {
if (ste.left(5) == "CORBA") {
if (ste != "CORBAValue")
cl->set_Stereotype(ste.mid(5).lower());
}
else
cl->set_Stereotype(((ste == "Actor") || (ste == "Interface"))
? ste.lower() : ste);
}
if (!doc.isEmpty())
cl->set_Description(doc);
cl->lang = None;
}
else if ((cl = (UmlClass *) findItem(id, aClass)) == 0) {
UmlCom::trace("<br>unknown class '" + s + "' in " +
parent->fullName());
throw 0;
}
Q3CString art_path;
for (;;) {
switch (k) {
case ')':
switch (cl->lang) {
case Cplusplus:
case AnsiCplusplus:
case VCplusplus:
cl->cplusplus(prop);
break;
case Oracle8:
cl->oracle8(prop);
break;
case Corba:
cl->corba(prop);
break;
case Java:
cl->java(prop);
break;
default:
break;
}
if (!scanning) {
cl->setProperties(prop);
cl->unload(TRUE);
}
return cl;
case ATOM:
if (s2 == "operations")
cl->importOperations(f);
else if (s2 == "class_attributes")
cl->importAttributes(f);
else if (!scanning &&
//.........这里部分代码省略.........
示例15: compute_type
void ClassContainer::compute_type(Q3CString type, UmlTypeSpec & typespec,
Q3CString & typeform,
bool get_first_template_actual,
const Q3ValueList<FormalParameterList> & tmplts) {
typespec.type = 0;
typespec.explicit_type = 0;
if (!strncmp((const char *) type, "struct ", 7) ||
!strncmp((const char *) type, "union ", 6) ||
!strncmp((const char *) type, "enum ", 5)) {
typespec.explicit_type = "<complex type>";
typeform = type;
return;
}
int index;
if (get_first_template_actual && ((index = type.find('<')) != -1)) {
type = Lex::normalize(type);
index = type.find('<');
const char * p = type;
if (strncmp(p + index + 1, "const ", 6) == 0)
index += 6;
// look at each actual in <>
unsigned level = 1;
int index2;
Q3CString tf1;
Q3CString t1;
for (;;) {
// earch for the current arg end
for (index2 = index + 1; p[index2]; index2 += 1) {
char c = p[index2];
if ((c == ',') || (c == '*') || (c == '[') || (c == '&')) {
if (level == 1)
break;
}
else if (c == '<')
level += 1;
else if ((c == '>') && (--level == 0))
break;
}
if (p[index2]) {
Q3CString tf = type.left(index + 1) + typeform + type.mid(index2);
Q3CString t = type.mid(index + 1, index2 - index - 1).stripWhiteSpace();
#ifdef DEBUG_BOUML
cout << "typeform '" << tf << "' type '" << t << "'\n";
#endif
UmlTypeSpec ts;
Q3CString normalized = Lex::normalize(t);
if (!find_type(normalized, ts) &&
(Namespace::current().isEmpty() ||
(normalized.at(0) == ':') ||
!find_type("::" + normalized, ts))) {
if (get_first_template_actual) {
get_first_template_actual = FALSE;
tf1 = tf;
t1 = t;
}
index = index2;
}
else {
// find a class
typeform = tf;
type = t;
typespec.type = ts.type;
break;
}
}
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;
//.........这里部分代码省略.........