本文整理汇总了C++中QByteArray::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::begin方法的具体用法?C++ QByteArray::begin怎么用?C++ QByteArray::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wordWrap
static QByteArray wordWrap(QByteArray string, int length)
{
QByteArray::iterator it = string.begin();
QByteArray::iterator lastSpace = string.begin();
int distance = 0;
while (it != string.end()) {
while (it != string.end() && distance <= length) {
distance++;
if (*it == ' ') {
lastSpace = it;
if (length == distance)
*lastSpace = '\n';
}
++it;
}
if (lastSpace != string.begin())
*lastSpace = '\n';
lastSpace = string.begin();
distance = 0;
}
return string;
}
示例2: emplaceString
static void emplaceString(std::map<std::string, Kdbx::XorredBuffer>& strings, const char* name, const QByteArray& data, bool protect, QWidget* widget){
if (protect){
std::vector<uint8_t> mask = getRandomBytes(data.size(), widget);
strings.emplace(name, Kdbx::XorredBuffer::fromRaw(data.begin(), data.end(), mask.begin()));
}else{
strings.emplace(name, Kdbx::XorredBuffer(data.begin(), data.end()));
}
}
示例3: updateLEDs
void msl::updateLEDs()
{
qDebug() << "Updating LEDs!";
QByteArray array;
array.push_back(SET_COLOR);
array.push_back(DIRECT_LED);
array.push_back((char)this->ui.verticalSlider_uv->value());
array.push_back((char)this->ui.verticalSlider_white->value());
array.push_back(this->colorDialog->currentColor().red());
array.push_back(this->colorDialog->currentColor().green());
array.push_back(this->colorDialog->currentColor().blue());
unsigned char checksum=0;
for(QByteArray::iterator it = array.begin(); it != array.end(); ++it)
{
checksum^=*it;
}
array.push_back(checksum);
//Start with AA 55
array.push_front(0x55);
array.push_front(0xAA);
emit sendArray(array);
}
示例4: response
void Endpoint_v1::TicketRequest::onRequestFinished()
{
QByteArray respbytes = reply->readAll();
reply->deleteLater();
std::string response ( respbytes.begin(), respbytes.end() );
JSONNode respnode = libJSON::parse ( response );
JSONNode errnode = respnode.at ( "error" );
if (errnode.as_string() != "") {
emit failed(QString("server_failure"), QString(errnode.as_string().c_str()));
return;
}
available = FHttpApi::Data_GetTicketDefault;
JSONNode subnode = respnode.at ("ticket");
ticket = new Ticket();
ticket->ticket = subnode.as_string().c_str();
ticket->name = _un;
ticket->password = _p;
subnode = respnode.at("default_character");
defaultCharacter = subnode.as_string().c_str();
subnode = respnode.at("characters");
qslFromJsonArray(subnode, characters);
subnode = respnode.at("bookmarks");
qslFromJsonArray(subnode, bookmarks);
emit succeeded();
}
示例5: runSend
void Chat::runSend(const QString &msg)
{
bool success = true;
QString message;
sdc::Security s;
try {
QByteArray unencMsg = msg.toUtf8();
sdc::ByteSeq encMsg = s.encryptAES(key,
sdc::ByteSeq(unencMsg.begin(), unencMsg.end()));
sessionPrx->sendMessage(encMsg, chatID.toStdString());
} catch (const sdc::SecurityException &e) {
// thrown by encryptAES
success = false;
message = e.what();
} catch (const sdc::MessageException &e) {
// thrown by sendMessage
success = false;
message = e.what.c_str();
} catch (const sdc::InterServerException &e) {
// thrown by sendMessage
success = false;
message = e.what.c_str();
} catch (...) {
success = false;
message = "Unexpected exception";
}
emit sendCompleted(success, message);
}
示例6: processString
void Preprocessor::processString(const QByteArray &str)
{
pp proc(d->env);
d->initPP(proc);
proc(str.begin(), str.end(), std::back_inserter(d->result));
}
示例7: readImage
QString AMCImporter::readImage(const QString& format_) {
if(m_failed) {
return QString();
}
quint32 l = readInt();
if(l == 0) {
return QString();
}
if(l > AMC_MAX_STRING_SIZE) {
myDebug() << "string is too long:" << l;
m_failed = true;
return QString();
}
QVector<char> buffer(l+1);
m_ds.readRawData(buffer.data(), l);
QByteArray bytes;
bytes.reserve(l);
qCopy(buffer.data(), buffer.data() + l, bytes.begin());
QImage img = QImage::fromData(bytes);
if(img.isNull()) {
myDebug() << "null image";
return QString();
}
QString format = QLatin1String("PNG");
if(format_ == QLatin1String(".jpg")) {
format = QLatin1String("JPEG");
} else if(format_ == QLatin1String(".gif")) {
format = QLatin1String("GIF");
}
return ImageFactory::addImage(img, format);
}
示例8: decode_kio_internal
void decode_kio_internal(Decoder *dec, QByteArray::ConstIterator &iit,
QByteArray::ConstIterator &iend,
QByteArray &out)
{
out.resize(outbufsize);
QByteArray::Iterator oit = out.begin();
QByteArray::ConstIterator oend = out.end();
while(!dec->decode(iit, iend, oit, oend))
if(oit == oend) return;
while(!dec->finish(oit, oend))
if(oit == oend) return;
out.truncate(oit - out.begin());
}
示例9: assert
template <> std::vector<uint8_t> Query::get(int offset) {
assert(stmt.impl && stmt.impl->query.isValid());
QByteArray byteArray = stmt.impl->query.value(offset).toByteArray();
checkQueryError(stmt.impl->query);
std::vector<uint8_t> blob(byteArray.begin(), byteArray.end());
return blob;
}
示例10: importButton
void UploadImpl::importButton()
{
QString file;
file = QFileDialog::getOpenFileName(this,
tr("Import Exercise Data"),
"",
tr("Comma separated files (*.csv *.txt);;Garmin FIT file (*.fit)"));
if (!file.isEmpty())
{
if ( QFileInfo(file.toLower()).suffix() == "fit") {
// Garmin FIT file
QFile fitFile(file);
if (!fitFile.open(QIODevice::ReadOnly)) return;
QByteArray blob = fitFile.readAll();
std::vector<uint8_t> fitData(blob.begin(), blob.end());
FIT fit;
fit.parse (fitData, exdata);
} else {
// csv file
ReadCSV(qPrintable(file), exdata);
}
if (exdata.size())
{
fillList();
}
}
}
示例11: TrackerResponse
Discovery::TrackerResponse Discovery::TrackerResponse::fromBinary(const QByteArray &data) {
MessageType type = UnknownType;
QList<Peer> peers;
TrackerResponse rc;
if (data.startsWith("BSYNC\0")) {
libtorrent::entry e = libtorrent::bdecode(data.begin()+6, data.end());
libtorrent::entry::dictionary_type dict = e.dict();
try {
type = (MessageType) dict.at("m").integer();
if (dict.count("peers")) {
libtorrent::entry::list_type stdPeers = dict.at("peers").list();
}
PeerAddress extAddr = PeerAddress::fromBinary(dict.at("ea").string());
std::string shareHash = dict.at("share").string();
rc = TrackerResponse(type, peers, extAddr, QByteArray(shareHash.data(), shareHash.length()));
}
catch (std::out_of_range e) {
}
}
return rc;
}
示例12: hmac
static QByteArray deriveKeyPbkdf2(QCryptographicHash::Algorithm algorithm,
const QByteArray &data, const QByteArray &salt,
int iterations, quint64 dkLen)
{
QByteArray key;
quint32 currentIteration = 1;
QMessageAuthenticationCode hmac(algorithm, data);
QByteArray index(4, Qt::Uninitialized);
while (quint64(key.length()) < dkLen) {
hmac.addData(salt);
qToBigEndian(currentIteration, reinterpret_cast<uchar*>(index.data()));
hmac.addData(index);
QByteArray u = hmac.result();
hmac.reset();
QByteArray tkey = u;
for (int iter = 1; iter < iterations; iter++) {
hmac.addData(u);
u = hmac.result();
hmac.reset();
std::transform(tkey.cbegin(), tkey.cend(), u.cbegin(), tkey.begin(),
std::bit_xor<char>());
}
key += tkey;
currentIteration++;
}
return key.left(dkLen);
}
示例13: parseScript
bool Vacation::parseScript( const QString & script, QString & messageText,
int & notificationInterval, QStringList & aliases,
bool & sendForSpam, QString & domainName ) {
if ( script.trimmed().isEmpty() ) {
messageText = defaultMessageText();
notificationInterval = defaultNotificationInterval();
aliases = defaultMailAliases();
sendForSpam = defaultSendForSpam();
domainName = defaultDomainName();
return true;
}
// The trimmed() call below prevents parsing errors. The
// slave somehow omits the last \n, which results in a lone \r at
// the end, leading to a parse error.
const QByteArray scriptUTF8 = script.trimmed().toUtf8();
kDebug() << "scriptUtf8 = \"" + scriptUTF8 +"\"";
KSieve::Parser parser( scriptUTF8.begin(),
scriptUTF8.begin() + scriptUTF8.length() );
VacationDataExtractor vdx;
SpamDataExtractor sdx;
DomainRestrictionDataExtractor drdx;
KSieveExt::MultiScriptBuilder tsb( &vdx, &sdx, &drdx );
parser.setScriptBuilder( &tsb );
if ( !parser.parse() )
return false;
messageText = vdx.messageText().trimmed();
notificationInterval = vdx.notificationInterval();
aliases = vdx.aliases();
if ( !GlobalSettings::allowOutOfOfficeUploadButNoSettings() ) {
sendForSpam = !sdx.found();
domainName = drdx.domainName();
}
return true;
}
示例14: transformFile
// ----------------------------------------------------------------------------
// transformFile
// ----------------------------------------------------------------------------
void MemMappedFileAppl::transformFile()
{
if (m_initialized == false) return;
if (m_mapped_data_1 == nullptr) return;
if (m_mapped_data_2 == nullptr) return;
QByteArray data;
data = QByteArray::fromRawData((char*)m_mapped_data_1, MAPPING_SIZE);
std::for_each(data.begin(),data.end(), [](char &n){ n = '1';});
memcpy(m_mapped_data_1, data.data(), MAPPING_SIZE); // copy back to mapped file mem ...
data = QByteArray::fromRawData((char*)m_mapped_data_2, MAPPING_SIZE);
std::for_each(data.begin(),data.end(), [](char &n){ n = '2';});
memcpy(m_mapped_data_2, data.data(), MAPPING_SIZE); // copy back to mapped file mem ...
}
示例15: toSafeFilesystemEncoding
string FileName::toSafeFilesystemEncoding(os::file_access how) const
{
// This will work on Windows for non ascii file names.
QString const safe_path =
toqstr(os::safe_internal_path(absFileName(), how));
QByteArray const encoded = QFile::encodeName(safe_path);
return string(encoded.begin(), encoded.end());
}