本文整理汇总了C++中Q3CString::truncate方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3CString::truncate方法的具体用法?C++ Q3CString::truncate怎么用?C++ Q3CString::truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q3CString
的用法示例。
在下文中一共展示了Q3CString::truncate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
}
示例2: 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, " ");
}
}
示例3: remove_preprocessor
void UmlClassMember::remove_preprocessor(Q3CString & s)
{
int index = 0;
while ((index = s.find('#', index)) != -1) {
// remove all up to the end of line
int index2 = index + 1;
int index3;
while ((index3 = s.find('\n', index2)) != -1) {
// manage multi lines #define
if (((const char *) s)[index3 - 1] != '\\')
break;
else
index2 = index3 + 1;
}
// the \n is still here to have a separator
if (index3 == -1)
s.truncate(index);
else
s.remove(index, index3 - index);
}
}
示例4: new_one
//.........这里部分代码省略.........
else if (s != "{") {
Lex::error_near(s, " '{' expected");
return FALSE;
}
else {
Lex::mark();
// goto the end of the body
#ifndef ROUNDTRIP
Q3CString body;
#endif
int level = 1; // '{' already read
char c;
for (;;) {
if ((c = Lex::read_word_bis()) == 0)
return FALSE;
else if (c == '{')
level += 1;
else if ((c == '}') && (--level == 0))
break;
}
#ifdef REVERSE
if (
# ifdef ROUNDTRIP
may_roundtrip || (op != 0)
# else
(op != 0) && !container->from_libp()
# endif
) {
body = Lex::region();
body.truncate(body.length() - 1); // remove }
// remove fist \n
if (*((const char *) body) == '\n')
body.remove(0, 1);
// remove last spaces and tabs
int ln = body.length();
while (ln && ((body[ln - 1] == ' ') || (body[ln - 1] == '\t')))
ln -= 1;
body.truncate(ln);
if (!body.isEmpty() && (body[ln - 1] != '\n'))
body += "\n";
# ifndef ROUNDTRIP
op->set_JavaBody(body);
op->set_JavaContextualBodyIndent(FALSE);
# endif
}
#endif
}
#ifdef ROUNDTRIP
if (may_roundtrip) {
if (((op = already_exist_from_id(container, body)) != 0) ||
((op = already_exist(container, name, params)) != 0)) {
// update already existing operation
op->set_usefull();
{
// remove \r in case of preserve body
Q3CString current_body = op->javaBody();
示例5: normalize
Q3CString Lex::normalize(const Q3CString & s)
{
int index = s.find('<');
if (index == -1)
return s;
Q3CString r;
const char * p = s;
index = 0;
for (;;) {
char c = *p++;
switch (c) {
case 0:
return r;
case '<':
if (!r.isEmpty() && (r.at(r.length() - 1) == ' '))
r.truncate(r.length() - 1);
r += '<';
break;
case '>':
if (!r.isEmpty() && (r.at(r.length() - 1) == '>'))
r += " >";
else
r += '>';
break;
case '/':
if (*p == '/') {
// comment
p += 1;
do p += 1;
while (*p && (*p != '\n'));
}
else if (*p == '*') {
/* comment */
p += 1;
do p += 1;
while (*p && ((*p != '*') || (p[1] != '/')));
p += 2;
}
else {
if (!r.isEmpty() && (r.at(r.length() - 1) == ' '))
r.truncate(r.length() - 1);
}
break;
case '#':
do {
if (*++p == '\\')
p += 2;
else if ((*p == '/') && (p[1] == '*')) {
/* comment */
p += 1;
do p += 1; while (*p && ((*p != '*') || (p[1] != '/')));
p += 2;
}
} while (*p && (*p != '\n'));
break;
case '"':
if (!r.isEmpty() &&
(r.at(r.length() - 1) == '"') &&
(p[-2] != '"'))
r += ' ';
do {
if (*++p == '\\')
p += 2;
} while (*p && (*p != '"'));
break;
case '\'':
if (!r.isEmpty() && (r.at(r.length() - 1) == ' '))
r.truncate(r.length() - 1);
do {
if (*++p == '\\')
p += 2;
} while (*p && (*p != '\''));
break;
case ':':
if (!r.isEmpty() && (p[-2] <= ' '))
r += " :";
else
r += ':';
break;
default:
if (c > ' ') {
if (::identifierp(c)) {
if (!r.isEmpty() && ::identifierp(r.at(r.length() - 1)))
r += ' ';
r += c;
while ((*p == ':') || ::identifierp(*p))
r += *p++;
}
else
r += c;
}
}
}
return r;
//.........这里部分代码省略.........