本文整理汇总了C++中QByteArray::trimmed方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::trimmed方法的具体用法?C++ QByteArray::trimmed怎么用?C++ QByteArray::trimmed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::trimmed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qDecodeDataUrl
QT_BEGIN_NAMESPACE
/*!
\internal
Decode a data: URL into its mimetype and payload. Returns a null string if
the URL could not be decoded.
*/
Q_CORE_EXPORT QPair<QString, QByteArray> qDecodeDataUrl(const QUrl &uri)
{
QString mimeType;
QByteArray payload;
if (uri.scheme() == QLatin1String("data") && uri.host().isEmpty()) {
mimeType = QLatin1String("text/plain;charset=US-ASCII");
// the following would have been the correct thing, but
// reality often differs from the specification. People have
// data: URIs with ? and #
//QByteArray data = QByteArray::fromPercentEncoding(uri.encodedPath());
QByteArray data = QByteArray::fromPercentEncoding(uri.toEncoded());
// remove the data: scheme
data.remove(0, 5);
// parse it:
int pos = data.indexOf(',');
if (pos != -1) {
payload = data.mid(pos + 1);
data.truncate(pos);
data = data.trimmed();
// find out if the payload is encoded in Base64
if (data.endsWith(";base64")) {
payload = QByteArray::fromBase64(payload);
data.chop(7);
}
if (data.toLower().startsWith("charset")) {
int i = 7; // strlen("charset")
while (data.at(i) == ' ')
++i;
if (data.at(i) == '=')
data.prepend("text/plain;");
}
if (!data.isEmpty())
mimeType = QLatin1String(data.trimmed());
}
}
return QPair<QString,QByteArray>(mimeType,payload);
}
示例2: parseSharedLibs
static void parseSharedLibs(const QByteArray &buffer, QStringList *libs)
{
#if defined(_WIN32)
QList<QByteArray> lines = buffer.trimmed().split('\r');
#else
QList<QByteArray> lines = buffer.trimmed().split('\n');
#endif
foreach (const QByteArray &line, lines) {
if (line.contains("(NEEDED)") && line.contains("Shared library:") ) {
const int pos = line.lastIndexOf('[') + 1;
(*libs) << QString::fromLatin1(line.mid(pos, line.length() - pos - 1));
}
}
}
示例3: set_transparency
void Oinv_cgrid::set_transparency( const QString& str ) {
for( int i = 0; i < 256; i++ ) {
volrend_colormap_->colorMap.set1Value( 4*i+3, 1.0f );
}
if( !cmap_ || str.isEmpty() ) return;
float min = cmap_->lower_bound();
float max = cmap_->upper_bound();
if( min == max ) return;
QString cleaned_intervals;
const float alpha = 0.01f;
// volrend_colormap_->colorMap.set1Value( 3, alpha );
// volrend_colormap_->colorMap.set1Value( 7, alpha );
QStringList intervals_str = str.split( ";", QString::SkipEmptyParts);
QStringList::Iterator it = intervals_str.begin();
for ( ; it != intervals_str.end(); ++it ) {
QStringList interval_str = (*it).split( ",",QString::SkipEmptyParts);
if( interval_str.size() != 2 ) continue;
cleaned_intervals += interval_str[0] + " , " + interval_str[1] + " ; ";
QByteArray tmp = interval_str[0].toLatin1();
float low = std::max( tmp.trimmed().toFloat(), min );
tmp = interval_str[1].toLatin1();
float high= std::min( tmp.trimmed().toFloat(), max );
int a= (low - min) / ( max - min ) * 255;
int b= (high - min) / ( max - min ) * 255;
appli_assert( a >=0 && b < 256 );
for( int i = a; i <= b; i++ ) {
volrend_colormap_->colorMap.set1Value( 4*i+3, alpha );
}
}
std::map< std::string, QString >::iterator found =
transparency_map_.find( current_property_name_ );
if( found == transparency_map_.end() )
transparency_map_.insert(
std::make_pair( current_property_name_, cleaned_intervals)
);
else {
found->second = cleaned_intervals;
}
}
示例4: readQuality
static void readQuality(U2OpStatus& os, IOAdapter *io, QByteArray &sequence, int count) {
QByteArray buffArray(DocumentFormat::READ_BUFF_SIZE + 1, 0);
char* buff = buffArray.data();
// reading quality sequence, ignoring whitespace at the beginning and the end of lines
int readed = 0;
while (!io->isEof() && (readed < count)) {
bool eolnFound = false;
int readedCount = io->readUntil(buff, DocumentFormat::READ_BUFF_SIZE, TextUtils::LINE_BREAKS, IOAdapter::Term_Include, &eolnFound);
CHECK_EXT(readedCount >= 0, os.setError(U2::FastqFormat::tr("Error while reading sequence")),);
QByteArray trimmed = QByteArray(buffArray.data(), readedCount);
trimmed = trimmed.trimmed();
int qualitySize = sequence.size() + trimmed.size();
if (eolnFound && (qualitySize > count)) { // read quality sequence name line, reverting back
io->skip(-readedCount);
return;
}
sequence.append(trimmed);
CHECK_OP(os,);
}
}
示例5: networkReplyFinished
void HttpLabel::networkReplyFinished(QNetworkReply * reply)
{
QByteArray data = reply->readAll();
qDebug() << "HttpLabel::networkReplyFinished" << data.trimmed();
setText(d->pattern.arg(((QString)data).trimmed()));
d->timer.start(d->interval, this);
}
示例6: clean_my_name_lable
void UCHome_Main_SiteConst::clean_my_name_lable()
{
//<my:name uid="1673222" />
//<my:name uid="1673222"></my:name>
//QString unis = this->codec->toUnicode(this->feed_page_html);
//QByteArray u8s = this->u8codec->fromUnicode(unis);
//unis = u8s;
QByteArray tarr = this->feed_page_html;
QRegExp exp1 ("<my:name uid=\"[0-9]{1,12}\" />");
QRegExp exp2 ( "<my:name uid=\"[0-9]{1,12}\"></my:name>");
tarr = tarr.trimmed();
if(tarr.startsWith("f5b")) {
tarr = tarr.right(tarr.length()-3);
}
if(tarr.endsWith("0")) {
tarr = tarr.left(tarr.length()-1);
}
//unis = unis.replace(exp1, QString(""));
//unis = unis.replace(exp2, QString(""));
//u8s = this->u8codec->fromUnicode(unis);
QString unis = this->codec->toUnicode(tarr);
this->feed_page_utf8_html = this->u8codec->fromUnicode(unis);
this->feed_page_utf8_html = this->u8codec->fromUnicode(this->codec->toUnicode(this->feed_page_html));
}
示例7: Ser_dataReceive
//当客户端发送消息时触发的槽函数
void MainWindow::Ser_dataReceive()
{
//用于保存消息的临时对象
QByteArray message;
//从tcpSocket获取消息
message=tcpSocket->readAll();
//向infopad追加状态信息
ui->infoPad->append(tcpSocket->peerAddress().toString()+":");
//向infopad追加状态信息
ui->infoPad->append("\t"+message);
//在这里可以完成规则检查或协议解析过程
//目前并没有考虑协议优化等
//目前使用的不是一个较好的协议,而是字符串协议
//以下为命令解析的过程,解析成功返回SUCCESS,失败返回FAIL
if( Ser_cmd_parser(message.trimmed())==Utils::SUCCESS)
{
//调试信息
qDebug()<<"SER:parser ok";
}
else
{
//调试信息
qDebug()<<"SER:parser fail";
}
//send back message or something other
//调试信息
//tcpSocket->write(message);
//调试信息
qDebug()<<"Ser:server receive ok";
}
示例8: if
/**
* @brief Create an AWS V3 Signature canonical header string.
*
* @note Amazon documentation does not specify how to handle whitespace within
* quotes for V3 signatures, so here we use the same approach as V3
* signatures. That is:
*
* In canonical form, header name and value are combined with a single semi-colon
* separator, with all whitespace removed from both, _except_ for whitespace within
* double-quotes.
*
* @note This function is only applicable to the `AWS3` format, not `AWS3-HTTPS`.
*
* @param headerName Name of the HTTP header to convert to canonical form.
* @param headerValue Value of the HTTP header to convert to canonical form.
*
* @return An AWS V3 Signature canonical header string.
*
* @see http://docs.aws.amazon.com/amazonswf/latest/developerguide/HMACAuth-swf.html
* @see http://docs.aws.amazon.com/general/latest/gr/sigV4-create-canonical-request.html
* @see canonicalHeaders
*/
QByteArray AwsSignatureV3Private::canonicalHeader(const QByteArray &headerName, const QByteArray &headerValue) const
{
QByteArray header = headerName.toLower() + ':';
const QByteArray trimmedHeaderValue = headerValue.trimmed();
bool isInQuotes = false;
char previousChar = '\0';
for (int index = 0; index < trimmedHeaderValue.size(); ++index) {
char thisChar = trimmedHeaderValue.at(index);
header += thisChar;
if (isInQuotes) {
if ((thisChar == '"') && (previousChar != '\\'))
isInQuotes = false;
} else {
if ((thisChar == '"') && (previousChar != '\\')) {
isInQuotes = true;
} else if (isspace(thisChar)) {
while ((index < trimmedHeaderValue.size()-1) &&
(isspace(trimmedHeaderValue.at(index+1))))
++index;
}
}
previousChar = thisChar;
}
return header;
}
示例9: readSequence
static void readSequence(U2OpStatus& os, IOAdapter *io, QByteArray &sequence, char readUntil = '+') {
QByteArray buffArray(DocumentFormat::READ_BUFF_SIZE + 1, 0);
char* buff = buffArray.data();
// reading until readUntil symbol i.e. quality or dna sequence name start, ignoring whitespace at the beginning and the end of lines
while (!io->isEof()) {
bool eolnFound = false;
int readedCount = io->readUntil(buff, DocumentFormat::READ_BUFF_SIZE, TextUtils::LINE_BREAKS, IOAdapter::Term_Include, &eolnFound);
CHECK_EXT(!io->hasError(), os.setError(io->errorString()), );
CHECK_EXT(readedCount >= 0, os.setError(U2::FastqFormat::tr("Error while reading sequence")),);
QByteArray trimmed = QByteArray(buffArray.data(), readedCount);
trimmed = trimmed.trimmed();
if (eolnFound && checkFirstSymbol(trimmed, readUntil)) { // read quality sequence name line, reverting back
io->skip(-readedCount);
if (io->hasError()) {
os.setError(io->errorString());
}
return;
}
sequence.append(trimmed);
CHECK_OP(os,);
}
if (io->hasError()) {
os.setError(io->errorString());
}
}
示例10: prepare
int SqlQuery::prepare(const QByteArray &sql, bool allow_failure)
{
_sql = sql.trimmed();
if (_stmt) {
finish();
}
if (!_sql.isEmpty()) {
int n = 0;
int rc;
do {
rc = sqlite3_prepare_v2(_db, _sql.constData(), -1, &_stmt, 0);
if ((rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED)) {
n++;
OCC::Utility::usleep(SQLITE_SLEEP_TIME_USEC);
}
} while ((n < SQLITE_REPEAT_COUNT) && ((rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED)));
_errId = rc;
if (_errId != SQLITE_OK) {
_error = QString::fromUtf8(sqlite3_errmsg(_db));
qCWarning(lcSql) << "Sqlite prepare statement error:" << _error << "in" << _sql;
ENFORCE(allow_failure, "SQLITE Prepare error");
} else {
ASSERT(_stmt);
_sqldb->_queries.insert(this);
}
}
return _errId;
}
示例11: getEnvPath
QString ddMainWindow::getEnvPath(int type)
{
QString env = "";
switch (type)
{
case eSDCARD: env = "$EXTERNAL_STORAGE";
break;
case eDATA: env = "$ANDROID_DATA";
break;
case eSDCARD_EXT: env = "$EXTERNAL_STORAGE2";
break;
}
QProcess proc;
QString cmd = "adb";
QStringList argAdb;
argAdb << "shell" << "echo" << env ;
proc.start(cmd, argAdb);
qDebug() << " pid =" << proc.pid() << " process started" ;
if (!proc.waitForFinished())
return false;
QByteArray res = proc.readLine();
return res.trimmed();
}
示例12: onReadyRead
void AsteriskManager::onReadyRead()
{
QRegExp keyValue("^([A-Za-z0-9\\-]+):\\s(.+)$");
QByteArray line;
qDebug("<ami>");
while (canReadLine()) {
line = readLine();
qDebug() << line.trimmed();
if (line != "\r\n") {
if (keyValue.indexIn(line) > -1) {
packetBuffer[keyValue.cap(1)] = stringValue(keyValue.cap(2).trimmed());
} else if (line.startsWith("Asterisk Call Manager")) {
version_ = line.replace("Asterisk Call Manager/", QByteArray()).trimmed();
emit connected(version_);
}
} else if (!packetBuffer.isEmpty()) {
dispatchPacket();
}
}
qDebug("</ami>");
}
示例13: readLines
bool mdtCsvFile::readLines(QByteArray separator, QByteArray dataProtection, QByteArray comment)
{
Q_ASSERT(separator != dataProtection);
Q_ASSERT(separator != comment);
Q_ASSERT(dataProtection != comment);
QByteArray line;
// Check if file was open
if(!isOpen()){
setErrorString(tr("mdtCsvFile::readLines(): file is not open"));
return false;
}
// Clear previous results
clear();
// Travel the file
while(!atEnd()){
// Read a line
line = readLine();
// Remove begin and end whit space, end of line, etc...
line = line.trimmed();
if(line.size() > 0){
// Check about comments
if((comment.size() > 0)&&(line.startsWith(comment))){
continue;
}
// Parse the block
pvLines << parseLine(line, separator, dataProtection);
}
}
return true;
}
示例14: onProcessFinished
void BcRequest::onProcessFinished()
{
qDebug() << "BC: Process finished";
QByteArray out;
if (proc_->bytesAvailable() > 1024 ) {
plugin()->reply(stanza(), "sorry, result is too long");
deleteLater();
return;
}
out.append( proc_->readAllStandardOutput() );
out.append( proc_->readAllStandardError() );
QString msg(out.trimmed());
int i = msg.length();
if (i <= 0 ) {
deleteLater();
return;
}
if (msg.indexOf('.') != -1) {
while (i--) {
if (msg.at(i) != '0') break;
}
if (msg.at(i) != '.') i++;
}
plugin()->reply( stanza(), QString(msg.left(i).toUtf8()).trimmed());
deleteLater();
}
示例15: attributeToFloat
qreal MStyleSheetAttribute::attributeToFloat(const QByteArray &attribute, bool *conversionOk)
{
QByteArray value = attribute.trimmed();
if (attribute.endsWith(units[PIXELS_UNIT])) {
// strip "px" from the end
value.truncate(value.length() - 2);
return value.toFloat(conversionOk);
}
if (attribute.endsWith(units[MM_UNIT])) {
// strip "mm" from the end
value.truncate(value.length() - 2);
return MDeviceProfile::instance()->mmToPixelsF(value.toFloat(conversionOk));
}
if (attribute.endsWith(units[PT_UNIT])) {
// strip "pt" from the end
value.truncate(value.length() - 2);
return MDeviceProfile::instance()->ptToPixelsF(value.toFloat(conversionOk));
}
return value.toFloat(conversionOk);
}