本文整理汇总了C++中qstring::const_iterator::toLatin1方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::toLatin1方法的具体用法?C++ const_iterator::toLatin1怎么用?C++ const_iterator::toLatin1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstring::const_iterator
的用法示例。
在下文中一共展示了const_iterator::toLatin1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stamp
QString VisualLog::MessageInfo::expand(const QString &pattern) const{
QString base = "";
QDateTime dt = stamp();
QString::const_iterator it = pattern.begin();
while ( it != pattern.end() ){
if ( *it == QChar('%') ){
++it;
if ( it != pattern.end() ){
char c = it->toLatin1();
switch(c){
case 'p': {
if ( m_location && !m_location->remote.isEmpty() )
base += m_location->remote + "> ";
base += QString().sprintf(
"%0*d-%0*d-%0*d %0*d:%0*d:%0*d.%0*d %s %[email protected]%d: ",
4, dt.date().year(),
2, dt.date().month(),
2, dt.date().day(),
2, dt.time().hour(),
2, dt.time().minute(),
2, dt.time().second(),
3, dt.time().msec(),
qPrintable(levelToString(m_level).toLower()),
qPrintable(sourceFunctionName()),
sourceLineNumber()
);
break;
}
case 'r': base += sourceRemoteLocation(); break;
case 'F': base += sourceFileName(); break;
case 'N': base += extractFileNameSegment(sourceFileName()); break;
case 'U': base += sourceFunctionName(); break;
case 'L': base += QString::number(sourceLineNumber()); break;
case 'V': base += levelToString(m_level); break;
case 'v': base += levelToString(m_level).toLower(); break;
case 'w': base += QDate::shortDayName(dt.date().dayOfWeek()); break;
case 'W': base += QDate::longDayName(dt.date().dayOfWeek()); break;
case 'b': base += QDate::shortMonthName(dt.date().month()); break;
case 'B': base += QDate::longMonthName(dt.date().month()); break;
case 'd': base += QString().sprintf("%0*d", 2, dt.date().day() ); break;
case 'e': base += QString().sprintf("%d", dt.date().day() ); break;
case 'f': base += QString().sprintf("%*d", 2, dt.date().day() ); break;
case 'm': base += QString().sprintf("%0*d", 2, dt.date().month() ); break;
case 'n': base += QString().sprintf("%d", dt.date().month() ); break;
case 'o': base += QString().sprintf("%*d", 2, dt.date().month() ); break;
case 'y': base += QString().sprintf("%0*d", 2, dt.date().year() % 100 ); break;
case 'Y': base += QString().sprintf("%0*d", 4, dt.date().year() ); break;
case 'H': base += QString().sprintf("%0*d", 2, dt.time().hour() ); break;
case 'I': {
int hour = dt.time().hour();
base += QString().sprintf("%0*d", 2, (hour < 1 ? 12 : (hour > 12 ? hour - 12 : hour)));
break;
}
case 'a': base += QString().sprintf(dt.time().hour() < 12 ? "am" : "pm" ); break;
case 'A': base += QString().sprintf(dt.time().hour() < 12 ? "AM" : "PM" ); break;
case 'M': base += QString().sprintf("%0*d", 2, dt.time().minute()); break;
case 'S': base += QString().sprintf("%0*d", 2, dt.time().second() ); break;
case 's': base += QString().sprintf("%0*d.%0*d", 2, dt.time().second(), 3, dt.time().msec() ); break;
case 'i': base += QString().sprintf("%0*d", 3, dt.time().msec() ); break;
case 'c': base += QString().sprintf("%d", dt.time().msec() / 100 ); break;
default: base += *it;
}
}
} else {
base += *it;
}
++it;
}
return base;
}
示例2: switch
Arguments::Arguments( const QString &a )
{
_arguments.clear();
QString current_arg;
bool between_arguments = false;
bool quoted_argument = false;
bool escape = false;
for( QString::const_iterator itChar = a.begin(); itChar != a.end(); ++itChar )
{
if ( between_arguments )
{
switch ( itChar->toLatin1() )
{
case '"':
quoted_argument = true;
between_arguments = false;
current_arg.clear();
break;
case ' ':
case '\r':
case '\n':
case '\t':
break;
default:
quoted_argument = false;
between_arguments = false;
current_arg = *itChar;
break;
}
}
else
{
if ( escape )
{
escape = false;
current_arg += *itChar;
}
else
{
switch ( itChar->toLatin1() )
{
case '"':
quoted_argument = !quoted_argument;
break;
case ' ':
case '\r':
case '\n':
case '\t':
if ( quoted_argument )
current_arg += *itChar;
else
{
_arguments << current_arg;
between_arguments = true;
}
break;
case '\\':
escape = true ;
break;
default:
current_arg += *itChar;
break;
}
}
}
}
if ( !between_arguments )
_arguments << current_arg;
calcArguments();
}