本文整理汇总了C++中WrapperStr::truncate方法的典型用法代码示例。如果您正苦于以下问题:C++ WrapperStr::truncate方法的具体用法?C++ WrapperStr::truncate怎么用?C++ WrapperStr::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WrapperStr
的用法示例。
在下文中一共展示了WrapperStr::truncate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_comments
void UmlClassMember::remove_comments(WrapperStr & 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: write_java_returntype
void UmlOperation::write_java_returntype(FileOut & out, WrapperStr decl)
{
// manage keywords
int index;
if ((index = decl.find("${visibility}")) != -1)
decl.remove(index, 13);
if ((index = decl.find("${final}")) != -1)
decl.remove(index, 8);
if ((index = decl.find("${static}")) != -1)
decl.remove(index, 9);
if ((index = decl.find("${abstract}")) != -1)
decl.remove(index, 11);
if ((index = decl.find("${synchronized}")) != -1)
decl.remove(index, 15);
if ((index = decl.find("${@}")) != -1)
decl.remove(index, 4);
if ((index = decl.find("${(}")) == -1)
decl = "${type} ${name}";
else
decl.truncate(index);
UmlTypeSpec t = returnType();
if ((t.type != 0) ||
!(t.explicit_type = JavaSettings::type(t.explicit_type)).isEmpty())
write_type(out, t, decl, "${name}", "${type}");
}
示例3: write_cpp_returntype
void UmlOperation::write_cpp_returntype(FileOut & out, WrapperStr decl)
{
// doesn't manage function pointer
// manage keywords
int index;
if ((index = decl.find("${static}")) != -1)
decl.remove(index, 9);
if ((index = decl.find("${friend}")) != -1)
decl.remove(index, 9);
if ((index = decl.find("${virtual}")) != -1)
decl.remove(index, 10);
if ((index = decl.find("${inline}")) != -1)
decl.remove(index, 9);
if ((index = decl.find("${(}")) == -1)
decl = "${type} ${name}";
else
decl.truncate(index);
UmlTypeSpec t = returnType();
if ((t.type != 0) ||
!(t.explicit_type = CppSettings::type(t.explicit_type)).isEmpty())
write_type(out, t, decl, "${name}", "${type}");
}
示例4: remove_python_comments
void remove_python_comments(WrapperStr & s)
{
int index1 = 0;
while ((index1 = s.find('#', index1)) != -1) {
int index2;
if ((index2 = s.find('\n', index1 + 1)) != -1)
s.remove(index1, index2 - index1 + 1);
else
s.truncate(index1);
}
}
示例5: remove_arrays
void UmlClassMember::remove_arrays(WrapperStr & 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, " ");
}
}
示例6: remove_preprocessor
void UmlClassMember::remove_preprocessor(WrapperStr & 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);
}
}
示例7: manage_member
bool Class::manage_member(WrapperStr s)
{
WrapperStr comment = Lex::get_comments();
WrapperStr description = Lex::get_description();
int index;
WrapperStr access = value_of(description, "@access", index);
aVisibility visibility;
if (access == "public")
visibility = PublicVisibility;
else if (access == "protected")
visibility = ProtectedVisibility;
else if (access == "private")
visibility = PrivateVisibility;
else
visibility = PackageVisibility;
if (visibility != PackageVisibility) {
description.replace(index, access.length(), "${visibility}");
access = value_of(comment, "@access", index);
comment.replace(index, access.length(), "${visibility}");
}
bool m_staticp = FALSE;
bool m_constp = FALSE;
bool m_abstractp = FALSE;
bool m_finalp = FALSE;
#ifdef TRACE
QLOG_INFO() << "Class::manage_member(" << s << ")\n";
#endif
for (;;) {
if (s == "public")
visibility = PublicVisibility;
else if (s == "protected")
visibility = ProtectedVisibility;
else if (s == "private")
visibility = PrivateVisibility;
else if (s == "static")
m_staticp = TRUE;
else if (s == "const")
m_constp = TRUE;
else if (s == "final")
m_finalp = TRUE;
else if (s == "abstract")
m_abstractp = TRUE;
else if (s != "var")
break;
s = Lex::read_word();
}
if (s == "function") {
// an operation
return UmlOperation::new_one(this, visibility, m_finalp, m_abstractp,
m_staticp, comment, description);
}
for (;;) {
WrapperStr name = s;
WrapperStr value;
s = Lex::read_word();
#ifdef TRACE
QLOG_INFO() << "define var '" << ((const char *) name) << "' followed by '" << ((const char *) s) << "'\n";
#endif
if (s == "=") {
// initialized variable, by pass value
Lex::mark();
UmlOperation::skip_expr(0);
value = Lex::region();
#ifdef TRACE
QLOG_INFO() << "value form is '" << ((const char *) value) << "'\n";
#endif
char c = ((const char *) value)[value.length() - 1];
if ((c == ';') || (c == ',')) {
value.truncate(value.length() - 1); // remove ';' or ','
s = (c == ';') ? ";" : ",";
}
else
s = Lex::read_word();
}
if ((s != ";") && (s != ",")) {
Lex::error_near(s);
return FALSE;
}
if (!UmlAttribute::new_one(this, name, visibility, m_constp, m_staticp,
value, comment, description))
return FALSE;
if (s == ";")
//.........这里部分代码省略.........