本文整理汇总了C++中QByteArray::split方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::split方法的具体用法?C++ QByteArray::split怎么用?C++ QByteArray::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::split方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parsePPS
bool QQnxButtonEventNotifier::parsePPS(const QByteArray &ppsData, QHash<QByteArray, QByteArray> *messageFields) const
{
// tokenize pps data into lines
QList<QByteArray> lines = ppsData.split('\n');
// validate pps object
if (lines.size() == 0 || !lines.at(0).contains(QByteArrayLiteral("@status"))) {
qWarning("QQNX: unrecognized pps object, data=%s", ppsData.constData());
return false;
}
// parse pps object attributes and extract values
for (int i = 1; i < lines.size(); i++) {
// tokenize current attribute
const QByteArray &attr = lines.at(i);
qButtonDebug() << Q_FUNC_INFO << "attr=" << attr;
int doubleColon = attr.indexOf(QByteArrayLiteral("::"));
if (doubleColon == -1) {
// abort - malformed attribute
continue;
}
QByteArray key = attr.left(doubleColon);
QByteArray value = attr.mid(doubleColon + 2);
messageFields->insert(key, value);
}
return true;
}
示例2: find
TSession TSessionCookieStore::find(const QByteArray &id)
{
TSession session;
if (id.isEmpty())
return session;
QList<QByteArray> balst = id.split('_');
if (balst.count() == 2 && !balst.value(0).isEmpty() && !balst.value(1).isEmpty()) {
QByteArray ba = QByteArray::fromHex(balst.value(0));
QByteArray digest = QCryptographicHash::hash(ba + Tf::appSettings()->value(Tf::SessionSecret).toByteArray(),
QCryptographicHash::Sha1);
if (digest != QByteArray::fromHex(balst.value(1))) {
tSystemWarn("Recieved a tampered cookie or that of other web application.");
//throw SecurityException("Tampered with cookie", __FILE__, __LINE__);
return session;
}
QDataStream ds(&ba, QIODevice::ReadOnly);
ds >> *static_cast<QVariantMap *>(&session);
if (ds.status() != QDataStream::Ok) {
tSystemError("Unable to load a session from the cookie store.");
session.clear();
}
}
示例3: ParseUrlFromRequest
QUrl LocalRedirectServer::ParseUrlFromRequest(const QByteArray& request) const {
QList<QByteArray> lines = request.split('\r');
const QByteArray& request_line = lines[0];
QByteArray path = request_line.split(' ')[1];
QUrl base_url = url();
QUrl request_url(base_url.toString() + path.mid(1), QUrl::StrictMode);
return request_url;
}
示例4: currentLocation
/**
* for now our data is just the MAC address of the default gateway
*/
NetworkLocation NetworkLocation::currentLocation()
{
QProcess ip;
ip.start("/sbin/ip", QStringList() << "route");
if (!ip.waitForStarted())
return NetworkLocation();
if (!ip.waitForFinished())
return NetworkLocation();
QByteArray gwIp;
while (ip.canReadLine()) {
QByteArray line = ip.readLine();
if (line.startsWith("default")) {
QList<QByteArray> parts = line.split(' ');
gwIp = parts[2];
break;
}
}
if (gwIp.isEmpty())
return NetworkLocation();
QProcess arp;
arp.start("/sbin/arp", QStringList() << "-a");
if (!arp.waitForStarted())
return NetworkLocation();
if (!arp.waitForFinished())
return NetworkLocation();
QByteArray gwMAC;
while (arp.canReadLine()) {
QByteArray line = arp.readLine();
if (line.contains(gwIp)) {
QList<QByteArray> parts = line.split(' ');
gwMAC = parts[3];
break;
}
}
if (gwMAC.isEmpty())
return NetworkLocation();
return NetworkLocation(gwMAC);
}
示例5: Exchange
Exchange_Bitstamp::Exchange_Bitstamp(QByteArray pRestSign, QByteArray pRestKey)
: Exchange()
{
checkDuplicatedOID=true;
accountFee=0.0;
balanceDisplayAvailableAmount=false;
minimumRequestIntervalAllowed=1200;
calculatingFeeMode=1;
isLastTradesTypeSupported=false;
exchangeSupportsAvailableAmount=true;
lastBidAskTimestamp=0;
lastTradesDate=0;
lastTickerDate=0;
baseValues.exchangeName="Bitstamp";
baseValues.currentPair.name="BTC/USD";
baseValues.currentPair.setSymbol("BTCUSD");
baseValues.currentPair.currRequestPair="BTCUSD";
baseValues.currentPair.priceDecimals=2;
baseValues.currentPair.priceMin=qPow(0.1,baseValues.currentPair.priceDecimals);
baseValues.currentPair.tradeVolumeMin=0.01;
baseValues.currentPair.tradePriceMin=0.1;
depthAsks=0;
depthBids=0;
forceDepthLoad=false;
julyHttp=0;
tickerOnly=false;
privateRestSign=pRestSign;
privateRestKey=pRestKey.split(':').last();
privateClientId=pRestKey.split(':').first();
currencyMapFile="Bitstamp";
defaultCurrencyParams.currADecimals=8;
defaultCurrencyParams.currBDecimals=5;
defaultCurrencyParams.currABalanceDecimals=8;
defaultCurrencyParams.currBBalanceDecimals=5;
defaultCurrencyParams.priceDecimals=2;
defaultCurrencyParams.priceMin=qPow(0.1,baseValues.currentPair.priceDecimals);
supportsLoginIndicator=true;
supportsAccountVolume=false;
supportsExchangeLag=false;
moveToThread(this);
authRequestTime.restart();
privateNonce=(static_cast<quint32>(time(NULL))-1371854884)*10;
}
示例6: parseHeader
bool RecvFileTransfer::parseHeader(QByteArray &recvBlock, struct TransferFile &transferFile)
{
bool ok;
int headerSize
= recvBlock.left(TRANSFER_FILE_HEADER_SIZE_LENGTH).toInt(&ok, 16);
if (!ok)
{
m_errorString = "RecvFileTransfer::parseHeader: get headerSize error";
return false;
}
QByteArray header = recvBlock.left(headerSize);
QList<QByteArray> list = header.split(':');
#define TRANSFERFILE_NAME_POS 1
#define TRANSFERFILE_SIZE_POS 2
#define TRANSFERFILE_TYPE_POS 3
#define TRANSFERFILE_ATTR_BEGIN_POS 4
// XXX NOTE: canParseHeader() make sure we have enough items in list,
// so we do not need to check size of list before call list.at()
// transferFile.name = Macai::transferCodec->codec()->toUnicode(list.at(TRANSFERFILE_NAME_POS));
QTextCodec* codec = QTextCodec::codecForName("SYSTEM");
transferFile.name = codec->toUnicode(list.at(TRANSFERFILE_NAME_POS));
transferFile.size = list.at(TRANSFERFILE_SIZE_POS).toLongLong(&ok, 16);
if (!ok)
{
m_errorString = "RecvFileTransfer::parseHeader: get file size error";
return false;
}
transferFile.type = list.at(TRANSFERFILE_TYPE_POS).toInt(&ok, 16);
if (!ok)
{
m_errorString = "RecvFileTransfer::parseHeader: get file type error";
return false;
}
// Extended file attribution like mtime, atime...
for (int i = TRANSFERFILE_ATTR_BEGIN_POS; i < list.size(); ++i)
{
QString s = list.at(i);
QStringList l = s.split(QChar('='));
if (l.size() == 2)
{
int i = l.at(0).toInt(&ok, 16);
if (ok)
{
transferFile.extendAttr.insert(i, l.at(1));
}
}
}
recvBlock.remove(0, headerSize);
return true;
}
示例7: main
virtual void main()
{
//init
bool v = getFlag("v");
//load ids and lengths
QHash<QByteArray, int> ids;
QSharedPointer<QFile> file = Helper::openFileForReading(getInfile("ids"));
while (!file->atEnd())
{
QByteArray line = file->readLine().trimmed();
if (line.isEmpty() || line[0]=='#') continue;
QList<QByteArray> parts = line.split('\t');
int length = -1;
if (parts.count()>1)
{
length = Helper::toInt(parts[1], "length value");
}
ids.insert(parts[0], length);
}
//open output stream
FastqOutfileStream outfile(getOutfile("out"), false);
//parse input and write output
FastqFileStream stream(getInfile("in"));
FastqEntry entry;
while (!stream.atEnd())
{
stream.readEntry(entry);
QByteArray id = entry.header.trimmed();
id = id.mid(1);
int comment_start = id.indexOf(' ');
if (comment_start!=-1) id = id.left(comment_start);
int length = ids.value(id, -2);
if (length==-2) //id not in list
{
if (!v) continue;
outfile.write(entry);
}
else if (length==-1) //id is in list, but no length given
{
if (v) continue;
outfile.write(entry);
}
else if (length>=1) //id is in list and length given
{
if (v) continue;
entry.bases.resize(length);
entry.qualities.resize(length);
outfile.write(entry);
}
}
}
示例8: initRenderingContext
bool EglWaylandBackend::initRenderingContext()
{
initBufferConfigs();
#ifdef KWIN_HAVE_OPENGLES
const EGLint context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
m_context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, context_attribs);
#else
const EGLint context_attribs_31_core[] = {
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
EGL_NONE
};
const EGLint context_attribs_legacy[] = {
EGL_NONE
};
const QByteArray eglExtensions = eglQueryString(m_display, EGL_EXTENSIONS);
const QList<QByteArray> extensions = eglExtensions.split(' ');
// Try to create a 3.1 core context
if (options->glCoreProfile() && extensions.contains("EGL_KHR_create_context"))
m_context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, context_attribs_31_core);
if (m_context == EGL_NO_CONTEXT)
m_context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, context_attribs_legacy);
#endif
if (m_context == EGL_NO_CONTEXT) {
qCritical() << "Create Context failed";
return false;
}
if (!m_wayland->surface()) {
return false;
}
const QSize &size = m_wayland->shellSurfaceSize();
m_overlay = wl_egl_window_create(m_wayland->surface(), size.width(), size.height());
if (!m_overlay) {
qCritical() << "Creating Wayland Egl window failed";
return false;
}
m_surface = eglCreateWindowSurface(m_display, m_config, m_overlay, NULL);
if (m_surface == EGL_NO_SURFACE) {
qCritical() << "Create Window Surface failed";
return false;
}
return makeContextCurrent();
}
示例9: loadFilters
void FramePlaybackWindow::loadFilters()
{
QString filename;
QFileDialog dialog(this);
QStringList filters;
filters.append(QString(tr("Filter List (*.ftl)")));
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilters(filters);
dialog.setViewMode(QFileDialog::Detail);
if (dialog.exec() == QDialog::Accepted)
{
filename = dialog.selectedFiles()[0];
//right now there is only one file type that can be loaded here so just do it.
QFile *inFile = new QFile(filename);
QByteArray line;
int ID;
bool checked = false;
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
return;
btnSelectNoneClick();
while (!inFile->atEnd()) {
line = inFile->readLine().simplified();
if (line.length() > 2)
{
QList<QByteArray> tokens = line.split(',');
ID = tokens[0].toInt(NULL, 16);
if (tokens[1].toUpper() == "T") checked = true;
else checked = false;
if (checked)
{
QHash<int,bool>::iterator it;
for (it = currentSeqItem->idFilters.begin(); it != currentSeqItem->idFilters.end(); ++it)
{
if (it.key() == ID)
{
it.value() = true;
}
}
for (int c = 0; c < ui->listID->count(); c++)
{
QListWidgetItem *item = ui->listID->item(c);
if (item->text().toInt(NULL, 16) == ID)
{
item->setCheckState(Qt::Checked);
}
}
}
}
}
inFile->close();
}
}
示例10: loadDataFromFile
void DataLayer::loadDataFromFile()
{
QFile file(_DATAFILE);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QList<QObject*> Appointments;
QString nextDay;
QString prevDay;
if(!file.atEnd())
{
QByteArray otherDayLine = file.readLine();
QList<QByteArray> otherDays = otherDayLine.split('\t');
if (otherDays.size()==2)
{
nextDay = otherDays.at(0);
prevDay = otherDays.at(1);
}
else
{
return;
}
while (!file.atEnd())
{
QString desc,time,place,link;
QByteArray line = file.readLine();
QList<QByteArray> data = line.split('\t');
if (data.size()>=4)
{
desc = QString(data.at(0));
time = QString(data.at(1));
place = QString(data.at(2));
link = QString(data.at(3));
Appointments.push_back(new Termin(desc,time,place,link));
}
}
}
setDataModel(new Day(Appointments,nextDay,prevDay));
}
示例11: startQtApplication
static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring paramsString, jstring environmentString)
{
m_mainLibraryHnd = NULL;
const char *nativeString = env->GetStringUTFChars(environmentString, 0);
QByteArray string = nativeString;
env->ReleaseStringUTFChars(environmentString, nativeString);
m_applicationParams=string.split('\t');
foreach (string, m_applicationParams) {
if (!string.isEmpty() && putenv(string.constData()))
qWarning() << "Can't set environment" << string;
}
nativeString = env->GetStringUTFChars(paramsString, 0);
string = nativeString;
env->ReleaseStringUTFChars(paramsString, nativeString);
m_applicationParams=string.split('\t');
// Go home
QDir::setCurrent(QDir::homePath());
//look for main()
if (m_applicationParams.length()) {
// Obtain a handle to the main library (the library that contains the main() function).
// This library should already be loaded, and calling dlopen() will just return a reference to it.
m_mainLibraryHnd = dlopen(m_applicationParams.first().data(), 0);
if (m_mainLibraryHnd == NULL) {
qCritical() << "dlopen failed:" << dlerror();
return false;
}
m_main = (Main)dlsym(m_mainLibraryHnd, "main");
} else {
qWarning() << "No main library was specified; searching entire process (this is slow!)";
m_main = (Main)dlsym(RTLD_DEFAULT, "main");
}
if (!m_main) {
qCritical() << "dlsym failed:" << dlerror();
qCritical() << "Could not find main method";
return false;
}
pthread_t appThread;
return pthread_create(&appThread, NULL, startMainMethod, NULL) == 0;
}
示例12: QString
uint RedisClient::Response::getRedirectionPort() const
{
if (!isMovedRedirect() && !isAskRedirect())
return 0;
QByteArray hostAndPort = m_responseSource.split(' ')[2];
return QString(hostAndPort.split(':')[1]).toUInt();
}
示例13: parseFunctionOutput
void CMakeValidator::parseFunctionOutput(const QByteArray &output)
{
QList<QByteArray> cmakeFunctionsList = output.split('\n');
m_functions.clear();
if (!cmakeFunctionsList.isEmpty()) {
cmakeFunctionsList.removeFirst(); //remove version string
foreach (const QByteArray &function, cmakeFunctionsList)
m_functions << QString::fromLocal8Bit(function.trimmed());
}
示例14: transform
void FixProtocol::transform(const QByteArray &input, QByteArray &output)
{
QList<QByteArray> fields = input.split(0x01);
for (int i = 0; i < fields.size(); i++) {
output.append(translateField(fields.at(i)));
if (!output.isEmpty())
output.append('\n');
}
}
示例15: locate_process_finished
void FindUtils::locate_process_finished()
{
QByteArray output = locate_process->readAllStandardOutput().trimmed();
QList<QByteArray> matches = output.split('\n');
filter_results(matches);
emit locate_finished(search_results);
}