本文整理汇总了C++中QByteArray::prepend方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::prepend方法的具体用法?C++ QByteArray::prepend怎么用?C++ QByteArray::prepend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::prepend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serializeInt
QByteArray QWsServer::serializeInt( quint32 number, quint8 nbBytes )
{
QByteArray ba;
quint8 currentNbBytes = 0;
while (number > 0 && currentNbBytes < nbBytes)
{
char car = static_cast<char>(number & 0xFF);
ba.prepend( car );
number = number >> 8;
currentNbBytes++;
}
char car = 0x00;
while (currentNbBytes < nbBytes)
{
ba.prepend( car );
currentNbBytes++;
}
return ba;
}
示例2: getSsUrl
QByteArray SSProfile::getSsUrl()
{
/*
* cook a ss:// url
*/
QString ssurl = QString("%1:%[email protected]%3:%4").arg(method.toLower()).arg(password).arg(server).arg(server_port);
QByteArray ba = QByteArray(ssurl.toStdString().c_str()).toBase64();
ba.prepend("ss://");
return ba;
}
示例3: 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);
}
示例4: setParamGrpPath
void PrefQuantitySpinBox::setParamGrpPath(const QByteArray& path)
{
Q_D(PrefQuantitySpinBox);
QByteArray groupPath = path;
if (!groupPath.startsWith("User parameter:")) {
groupPath.prepend("User parameter:BaseApp/Preferences/");
}
d->handle = App::GetApplication().GetParameterGroupByPath(groupPath);
if (d->handle.isValid())
d->prefGrp = path;
}
示例5: applyPreviousInput
QByteArray Xor::applyPreviousInput(const QByteArray &data, QByteArray & key)
{
QByteArray output;
QByteArray temp = data;
temp.prepend(key);
for (int i = key.size() ; i < temp.size(); i++) {
output.append(temp.at(i) ^ temp.at(i - key.size()));
}
return output;
}
示例6: TxtToPng
DataImageWriter TxtToPng(const QByteArray &txtData)
{
QByteArray data = qCompress(txtData, COMPRESSION_LEVEL);
qint32 actual_size = data.size();
data.prepend(reinterpret_cast<const char *>(&actual_size), sizeof(qint32));
//此处不能直接返回通过data.constData()来构建的QImage对象
//由于QByteArray的implicit sharing(copy-on-write)特性,data在离开该函数后将会被释放掉(因为其引用计数仅为1)
//从而导致QImage对象的数据出现随机值。为了避免data的释放,需要增加一个间接层来接受data,以便增加其引用计数
return DataImageWriter(data);
}
示例7: boundary
/*!
* Create boundary string
* \param cleared -detect for str boundary line in httpRequest
*/
QByteArray Uploader::boundary(bool cleared)
{
QByteArray retBoundary = _strBoundary;
if (cleared == false)
{
retBoundary.append("\r\n");
retBoundary.prepend("--");
}
return retBoundary;
}
示例8: formatRegister
static QByteArray formatRegister(quint64 v, int size, RegisterFormat format)
{
QByteArray result;
if (format == HexadecimalFormat) {
result = QByteArray::number(v, 16);
result.prepend(QByteArray(2*size - result.size(), '0'));
} else if (format == DecimalFormat) {
result = QByteArray::number(v, 10);
result.prepend(QByteArray(2*size - result.size(), ' '));
} else if (format == CharacterFormat) {
if (v >= 32 && v < 127) {
result += '\'';
result += char(v);
result += '\'';
} else {
result += " ";
}
result.prepend(QByteArray(2*size - result.size(), ' '));
}
return result;
}
示例9: generate
void Moc::generate(FILE *out)
{
QDateTime dt = QDateTime::currentDateTime();
QByteArray dstr = dt.toString().toLatin1();
QByteArray fn = filename;
int i = filename.length()-1;
while (i>0 && filename[i-1] != '/' && filename[i-1] != '\\')
--i; // skip path
if (i >= 0)
fn = filename.mid(i);
fprintf(out, "/****************************************************************************\n"
"** Meta object code from reading C++ file '%s'\n**\n" , (const char*)fn);
fprintf(out, "** Created: %s\n"
"** by: The Qt Meta Object Compiler version %d (Qt %s)\n**\n" , dstr.data(), mocOutputRevision, QT_VERSION_STR);
fprintf(out, "** WARNING! All changes made in this file will be lost!\n"
"*****************************************************************************/\n\n");
if (!noInclude) {
if (includePath.size() && includePath.right(1) != "/")
includePath += "/";
for (int i = 0; i < includeFiles.size(); ++i) {
QByteArray inc = includeFiles.at(i);
if (inc[0] != '<' && inc[0] != '"') {
if (includePath.size() && includePath != "./")
inc.prepend(includePath);
inc = "\"" + inc + "\"";
}
fprintf(out, "#include %s\n", inc.constData());
}
}
if (classList.size() && classList.first().classname == "Qt")
fprintf(out, "#include <QtCore/qobject.h>\n");
fprintf(out, "#if !defined(Q_MOC_OUTPUT_REVISION)\n"
"#error \"The header file '%s' doesn't include <QObject>.\"\n", (const char *)fn);
fprintf(out, "#elif Q_MOC_OUTPUT_REVISION != %d\n", mocOutputRevision);
fprintf(out, "#error \"This file was generated using the moc from %s."
" It\"\n#error \"cannot be used with the include files from"
" this version of Qt.\"\n#error \"(The moc has changed too"
" much.)\"\n", QT_VERSION_STR);
fprintf(out, "#endif\n\n");
fprintf(out, "QT_BEGIN_MOC_NAMESPACE\n");
for (i = 0; i < classList.size(); ++i) {
Generator generator(&classList[i], metaTypes, out);
generator.generateCode();
}
fprintf(out, "QT_END_MOC_NAMESPACE\n");
}
示例10: formatRegister
static QByteArray formatRegister(quint64 v, int size, RegisterFormat format, bool forEdit)
{
QByteArray result;
if (format == HexadecimalFormat) {
result = QByteArray::number(v, 16);
result.prepend(QByteArray(2*size - result.size(), '0'));
} else if (format == DecimalFormat) {
result = QByteArray::number(v, 10);
result.prepend(QByteArray(2*size - result.size(), ' '));
} else if (format == SignedDecimalFormat) {
qint64 sv;
if (size >= 8)
sv = qint64(v);
else if (size >= 4)
sv = qint32(v);
else if (size >= 2)
sv = qint16(v);
else
sv = qint8(v);
result = QByteArray::number(sv, 10);
result.prepend(QByteArray(2*size - result.size(), ' '));
} else if (format == CharacterFormat) {
bool spacesOnly = true;
if (v >= 32 && v < 127) {
spacesOnly = false;
if (!forEdit)
result += '\'';
result += char(v);
if (!forEdit)
result += '\'';
} else {
result += " ";
}
if (spacesOnly && forEdit)
result.clear();
else
result.prepend(QByteArray(2*size - result.size(), ' '));
}
return result;
}
示例11: R
void PHPQt5::zif_R(INTERNAL_FUNCTION_PARAMETERS)
{
#ifdef PQDEBUG
PQDBG_LVL_START(__FUNCTION__);
#endif
const char* path;
int path_len;
bool addQRC = false;
if(zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &path, &path_len, &addQRC)) {
return;
}
/* old
echo R($path); // :/corename/some/file.txt
echo R($path, false); // :/corename/some/file.txt
echo R($path, true); // qrc://corename/some/file.txt
*/
/* new
echo R($path); // :/some/file.txt
echo R($path, false); // :/some/file.txt
echo R($path, true); // qrc://some/file.txt
*/
QByteArray rpath = QByteArray(path).replace("\\", "/").replace("//","/");
if(addQRC) {
//rpath.prepend(getCorename().prepend("qrc://").append("/"));
rpath.prepend("qrc://");
}
else {
//rpath.prepend(getCorename().prepend(":/").append("/"));
rpath.prepend(":/");
}
PQDBG_LVL_DONE();
RETURN_STRING(rpath.constData());
}
示例12: toByteArray
QByteArray Data::toByteArray() const
{
QByteArray bytes = m_data;
switch(m_format)
{
case BYTES:
case UTF8:
case LATIN1:
case ASCII:
bytes.prepend((char)((int)'0' + (int)m_format));
break;
case FILE:
bytes.prepend((m_name+'<').toUtf8());
bytes.prepend((char)((int)'0' + (int)m_format));
break;
case UINT32:
case F_UNDEF:
break;
}
return bytes;
}
示例13: dectoString
QString EircomKeygen::dectoString(int mac) {
QByteArray ret;
while (mac > 0) {
switch (mac % 10) {
case 0:
ret.prepend("Zero");
break;
case 1:
ret.prepend("One");
break;
case 2:
ret.prepend("Two");
break;
case 3:
ret.prepend("Three");
break;
case 4:
ret.prepend("Four");
break;
case 5:
ret.prepend("Five");
break;
case 6:
ret.prepend("Six");
break;
case 7:
ret.prepend("Seven");
break;
case 8:
ret.prepend("Eight");
break;
case 9:
ret.prepend("Nine");
break;
}
mac /= 10;
}
return ret;
}
示例14: removeService
void BrisaWebserver::removeService(QByteArray path)
{
if (!path.startsWith('/'))
path.prepend('/');
mutex.lock();
if (services.contains(path)) {
services[path]->m_path.clear();
services.remove(path);
}
mutex.unlock();
}
示例15: spySignals
void RpcAdaptor::spySignals(QObject *target)
{
const QMetaObject *them = target->metaObject();
for(int idx=0;idx<them->methodCount();idx++)
{
QMetaMethod mm = them->method(idx);
if (mm.methodType() != QMetaMethod::Signal)
continue;
QByteArray sig = QMetaObject::normalizedSignature(mm.signature());
sig.prepend(QSIGNAL_CODE + '0');
QSignalIntercepter *si = new RpcSignalIntercepter(target, sig, this);
// qLog(Debug)<<"signalspy:"<<sig;
}
}