本文整理汇总了C++中Q3CString::left方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3CString::left方法的具体用法?C++ Q3CString::left怎么用?C++ Q3CString::left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q3CString
的用法示例。
在下文中一共展示了Q3CString::left方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCOMPARE
void tst_Q3CString::left()
{
Q3CString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
QCOMPARE(a.left(3),(Q3CString)"ABC");
QVERIFY(!a.left(0).isNull());
QCOMPARE(a.left(0),(Q3CString)"");
Q3CString n;
QVERIFY(n.left(3).isNull());
QVERIFY(n.left(0).isNull());
QVERIFY(n.left(0).isNull());
}
示例2: find_type
bool ClassContainer::find_type(Q3CString type, UmlTypeSpec & typespec,
NDict<Class> & defined) {
typespec.explicit_type = 0;
if ((typespec.type = UmlClass::used(type)) != 0)
return TRUE;
Class * cl = defined[type];
if (cl == 0) {
int index = 0;
while ((index = type.find('<', index)) != -1) {
// goes after <...>
int index2 = index + 1;
unsigned level = 1;
for (;;) {
int c = type[index2++];
if (c == '<')
level += 1;
else if (c == 0)
// wrong template spec
return FALSE;
else if ((c == '>') && (--level == 0)) {
break;
}
}
if ((type[index2] != (char)0) && (defined[type.left(index2)] != (char)0))
// explicit template
index = index2;
else if (defined[type.left(index)] != 0)
// non explicit template, remove <>
type.remove(index, index2 - index);
else
// unknown type
return FALSE;
typespec.type = 0;
if ((cl = defined[type]) != 0)
break;
}
}
return ((cl != 0) && ((typespec.type = cl->get_uml()) != 0));
}
示例3: 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";
}
}
示例4: 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);
}
示例5: 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;
}
}
示例6: 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";
}
}
示例7: 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();
}
示例8: 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();
}
}
示例9: 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;
}
示例10: text_path
Q3CString UmlPackage::text_path(const Q3CString & f) {
Q3CString r = path(f);
return r.left(r.length() - 1 - IdlSettings::sourceExtension().length());
}
示例11: new_one
//.........这里部分代码省略.........
if (index != -1)
typespec.explicit_type.remove(index, 7);
}
Q3CString decl = CppSettings::attributeDecl("");
int index = decl.find("${type}");
if ((index == -1) ||
(decl.find("${const}") == -1) ||
(decl.find("${name}") == -1) ||
(decl.find("${mutable}") == -1) ||
(decl.find("${volatile}") == -1) ||
(decl.find(';') == -1)) {
decl = " ${comment}${static}${mutable}${volatile}${const}${type} ${name}${value};";
index = decl.find("${type}");
}
if (pfunc)
decl.replace(index, decl.find("${name}") + 7 - index, type);
else {
if (!modifier.isEmpty())
decl.insert(index + 7, (const char*)(Q3CString(" ") + modifier));
if (typeform != "${type}")
decl.replace(index, 7, typeform);
else if (typespec.type == 0) {
Q3CString t = typespec.explicit_type;
int index2;
if (!t.isEmpty() &&
(t.at(t.length() - 1) == '>') &&
((index2 = t.find('<')) > 0)) {
stereotype = t.left(index2);
typespec.explicit_type =
// may be a,b ...
t.mid(index2 + 1, t.length() - 2 - index2);
decl.replace(index, 7, "${stereotype}<${type}>");
}
}
if (!array.isEmpty())
decl.insert(decl.find("${name}") + 7, "${multiplicity}");
if (!bitfield.isEmpty())
decl.insert(decl.find(';'), (const char *)(Q3CString(" : ") + bitfield));
}
if (typenamep) {
int index = decl.find("${const}") + 8; // find cannot return -1
int index2 = decl.find("${mutable}") + 10; // find cannot return -1
int index3 = decl.find("${volatile}") + 11; // find cannot return -1
if (index2 > index) index = index2;
if (index3 > index) index = index3;
decl.insert(index, "typename ");
}
if (!value.isEmpty() && ((index = decl.find("${value}")) != -1))
decl.insert(index + 2, "h_");
#ifdef ROUNDTRIP
if (roundtrip && !created) {
if (decl.find("${description}") != -1) {
if (nequal(at->description(), description)) {
示例12: file_path
Q3CString UmlPackage::file_path(const Q3CString & f, Q3CString relto) {
if (!dir.read) {
dir.file = phpDir();
dir.file_absolute = FALSE;
QDir d_root(rootDir());
if (dir.file.isEmpty())
dir.file = RootDir;
else if (QDir::isRelativePath(dir.file))
dir.file = d_root.filePath(dir.file);
else
dir.file_absolute = TRUE;
if (dir.file.isEmpty()) {
UmlCom::trace(Q3CString("<font color=\"red\"><b><b> The generation directory "
"must be specified for the package<i> ") + name()
+ "</i>, edit the <i> generation settings</i> (tab 'directory') "
"or edit the package (tab 'Php')</b></font><br>");
UmlCom::bye(n_errors() + 1);
UmlCom::fatal_error("UmlPackage::file_path");
}
dir.read = TRUE;
}
if (f.isEmpty())
return dir.file;
QDir d(dir.file);
if (! d.exists()) {
// create directory including the intermediates
Q3CString s = dir.file;
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;
}
}
Q3CString df = (dir.file_absolute || relto.isEmpty())
? Q3CString(d.filePath(f).toAscii().constData())
: relative_path(d, relto) + f;
if (PhpSettings::isRelativePath() && (df[0] != '/') && (df[0] != '.'))
df = "./" + df;
return df + Q3CString(".") + PhpSettings::sourceExtension();
}
示例13: 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;
//.........这里部分代码省略.........
示例14: new_one
//.........这里部分代码省略.........
rel->set_isClassMember(staticp);
container->set_updated();
}
if (rel->isCppMutable() != mutablep) {
rel->set_isCppMutable(mutablep);
container->set_updated();
}
if (rel->isVolatile() != volatilep) {
rel->set_isVolatile(volatilep);
container->set_updated();
}
}
else {
#endif
rel->set_Visibility(visibility);
if (constp) rel->set_isReadOnly(TRUE);
if (staticp) rel->set_isClassMember(TRUE);
if (mutablep) rel->set_isCppMutable(TRUE);
if (volatilep) rel->set_isVolatile(TRUE);
#ifdef ROUNDTRIP
}
#endif
Q3CString decl;
if (typeform != "${type}") {
// array & modified are empty, pretype is empty ?
decl = CppSettings::relationDecl(TRUE, "*");
int index = typeform.find("<"); // cannot be -1
Q3CString st = typeform.left(index);
Q3CString st_uml = CppSettings::umlType(st);
#ifdef ROUNDTRIP
if (roundtrip) {
if (st_uml.isEmpty())
st_uml = st;
if (neq(rel->stereotype(), st_uml)) {
rel->set_Stereotype(st_uml);
container->set_updated();
}
}
else
#endif
rel->set_Stereotype((st_uml.isEmpty()) ? st : st_uml);
int index2;
if ((index2 = decl.find("<${type}>")) == -1) {
decl = " ${comment}${static}${mutable}${volatile}${const}${stereotype}<${type}> ${name}${value};";
index2 = decl.find("<${type}>");
}
decl.replace(index2, 9, typeform.mid(index));
}
else {
if (!array.isEmpty()) {
#ifdef ROUNDTRIP
if (roundtrip) {
if (neq(rel->multiplicity(), array)) {
rel->set_Multiplicity(array);
container->set_updated();
}
示例15: file_path
Q3CString UmlPackage::file_path(const Q3CString & f) {
if (!dir.read) {
dir.file = javaDir();
if (! RootDirRead) {
RootDirRead = TRUE;
RootDir = JavaSettings::rootDir();
if (!RootDir.isEmpty() && // empty -> error
QDir::isRelativePath(RootDir)) {
QFileInfo f(getProject()->supportFile());
QDir d(f.dirPath());
RootDir = d.filePath(RootDir);
}
}
QDir d_root(RootDir);
if (dir.file.isEmpty())
dir.file = RootDir;
else if (QDir::isRelativePath(dir.file))
dir.file = d_root.filePath(dir.file);
if (dir.file.isEmpty()) {
UmlCom::trace(Q3CString("<font color=\"red\"><b><b> The generation directory "
"must be specified for the package<i> ") + name()
+ "</i>, edit the <i> generation settings</i> (tab 'directory') "
"or edit the package (tab 'Java')</b></font><br>");
UmlCom::bye(n_errors() + 1);
UmlCom::fatal_error("UmlPackage::file_path");
}
dir.read = TRUE;
}
QDir d(dir.file);
if (! d.exists()) {
// create directory including the intermediates
Q3CString s = dir.file;
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;
}
}
return Q3CString(d.filePath(f).toAscii().constData()) + Q3CString(".") +
JavaSettings::sourceExtension();
}