本文整理汇总了C++中QByteArray函数的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray函数的具体用法?C++ QByteArray怎么用?C++ QByteArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QByteArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* \brief muParser callback for registering user-defined variables
*
* When encountering an unknown variable within an expression, this function gets called.
* Memory for the variable is allocated in m_variables and a pointer to the memory location
* is returned to muParser. New variables are initialized with NaN.
*/
double *MuParserScript::variableFactory(const char *name, void *self) {
MuParserScript *me = static_cast<MuParserScript *>(self);
return me->m_variables.insert(QByteArray(name), NAN).operator->();
}
示例2: JDEBUG
QByteArray JsonValue::parseCString(const char *&from, const char *to)
{
QByteArray result;
JDEBUG("parseCString: " << QByteArray(from, to - from));
if (*from != '"') {
qDebug() << "JSON Parse Error, double quote expected";
++from; // So we don't hang
return QByteArray();
}
const char *ptr = from;
++ptr;
while (ptr < to) {
if (*ptr == '"') {
++ptr;
result = QByteArray(from + 1, ptr - from - 2);
break;
}
if (*ptr == '\\') {
++ptr;
if (ptr == to) {
qDebug() << "JSON Parse Error, unterminated backslash escape";
from = ptr; // So we don't hang
return QByteArray();
}
}
++ptr;
}
from = ptr;
int idx = result.indexOf('\\');
if (idx >= 0) {
char *dst = result.data() + idx;
const char *src = dst + 1, *end = result.data() + result.length();
do {
char c = *src++;
switch (c) {
case 'a': *dst++ = '\a'; break;
case 'b': *dst++ = '\b'; break;
case 'f': *dst++ = '\f'; break;
case 'n': *dst++ = '\n'; break;
case 'r': *dst++ = '\r'; break;
case 't': *dst++ = '\t'; break;
case 'v': *dst++ = '\v'; break;
case '"': *dst++ = '"'; break;
case '\\': *dst++ = '\\'; break;
default:
{
int chars = 0;
uchar prod = 0;
forever {
if (c < '0' || c > '7') {
--src;
break;
}
prod = prod * 8 + c - '0';
if (++chars == 3 || src == end)
break;
c = *src++;
}
if (!chars) {
qDebug() << "JSON Parse Error, unrecognized backslash escape";
return QByteArray();
}
*dst++ = prod;
}
}
while (src != end) {
char c = *src++;
if (c == '\\')
break;
*dst++ = c;
}
} while (src != end);
*dst = 0;
result.truncate(dst - result.data());
}
示例3: QByteArray
void SoundEditWidget::deleteSound()
{
mHasSound = false;
mSound = QByteArray();
updateView();
}
示例4: QByteArray
QByteArray Null::encodeData() const
{
return QByteArray();
}
示例5: registerFont
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
{
ATSFontContainerRef handle;
OSStatus e = noErr;
if(fnt->data.isEmpty()) {
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
extern OSErr qt_mac_create_fsref(const QString &, FSRef *); // qglobal.cpp
FSRef ref;
if(qt_mac_create_fsref(fnt->fileName, &ref) != noErr)
return;
ATSFontActivateFromFileReference(&ref, kATSFontContextLocal, kATSFontFormatUnspecified, 0, kATSOptionFlagsDefault, &handle);
} else
#endif
{
#ifndef Q_WS_MAC64
extern Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &, FSSpec *); // global.cpp
FSSpec spec;
if(qt_mac_create_fsspec(fnt->fileName, &spec) != noErr)
return;
e = ATSFontActivateFromFileSpecification(&spec, kATSFontContextLocal, kATSFontFormatUnspecified,
0, kATSOptionFlagsDefault, &handle);
#endif
}
} else {
e = ATSFontActivateFromMemory((void *)fnt->data.constData(), fnt->data.size(), kATSFontContextLocal,
kATSFontFormatUnspecified, 0, kATSOptionFlagsDefault, &handle);
fnt->data = QByteArray();
}
if(e != noErr)
return;
ItemCount fontCount = 0;
e = ATSFontFindFromContainer(handle, kATSOptionFlagsDefault, 0, 0, &fontCount);
if(e != noErr)
return;
QVarLengthArray<ATSFontRef> containedFonts(fontCount);
e = ATSFontFindFromContainer(handle, kATSOptionFlagsDefault, fontCount, containedFonts.data(), &fontCount);
if(e != noErr)
return;
fnt->families.clear();
#if defined(QT_MAC_USE_COCOA)
// Make sure that the family name set on the font matches what
// kCTFontFamilyNameAttribute returns in initializeDb().
// So far the best solution seems find the installed font
// using CoreText and get the family name from it.
// (ATSFontFamilyGetName appears to be the correct API, but also
// returns the font display name.)
for(int i = 0; i < containedFonts.size(); ++i) {
QCFString fontPostScriptName;
ATSFontGetPostScriptName(containedFonts[i], kATSOptionFlagsDefault, &fontPostScriptName);
QCFType<CTFontDescriptorRef> font = CTFontDescriptorCreateWithNameAndSize(fontPostScriptName, 14);
QCFString familyName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
fnt->families.append(familyName);
}
#else
for(int i = 0; i < containedFonts.size(); ++i) {
QCFString family;
ATSFontGetName(containedFonts[i], kATSOptionFlagsDefault, &family);
fnt->families.append(family);
}
#endif
fnt->handle = handle;
}
示例6: getConf
void Server::initializeCert() {
QByteArray crt, key, pass, dhparams;
crt = getConf("certificate", QString()).toByteArray();
key = getConf("key", QString()).toByteArray();
pass = getConf("passphrase", QByteArray()).toByteArray();
dhparams = getConf("sslDHParams", Meta::mp.qbaDHParams).toByteArray();
QList<QSslCertificate> ql;
// Attempt to load key as an RSA key or a DSA key
if (! key.isEmpty()) {
qskKey = QSslKey(key, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, pass);
if (qskKey.isNull())
qskKey = QSslKey(key, QSsl::Dsa, QSsl::Pem, QSsl::PrivateKey, pass);
}
// If we still can't load the key, try loading any keys from the certificate
if (qskKey.isNull() && ! crt.isEmpty()) {
qskKey = QSslKey(crt, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, pass);
if (qskKey.isNull())
qskKey = QSslKey(crt, QSsl::Dsa, QSsl::Pem, QSsl::PrivateKey, pass);
}
// If have a key, walk the list of certs, find the one for our key,
// remove any certs for our key from the list, what's left is part of
// the CA certificate chain.
if (! qskKey.isNull()) {
ql << QSslCertificate::fromData(crt);
ql << QSslCertificate::fromData(key);
for (int i=0;i<ql.size();++i) {
const QSslCertificate &c = ql.at(i);
if (isKeyForCert(qskKey, c)) {
qscCert = c;
ql.removeAt(i);
}
}
qlCA = ql;
}
#if defined(USE_QSSLDIFFIEHELLMANPARAMETERS)
if (! dhparams.isEmpty()) {
QSslDiffieHellmanParameters qdhp = QSslDiffieHellmanParameters(dhparams);
if (qdhp.isValid()) {
qsdhpDHParams = qdhp;
} else {
log(QString::fromLatin1("Unable to use specified Diffie-Hellman parameters (sslDHParams): %1").arg(qdhp.errorString()));
}
}
#else
if (! dhparams.isEmpty()) {
log("Diffie-Hellman parameters (sslDHParams) were specified, but will not be used. This version of Murmur does not support Diffie-Hellman parameters.");
}
#endif
QString issuer;
#if QT_VERSION >= 0x050000
QStringList issuerNames = qscCert.issuerInfo(QSslCertificate::CommonName);
if (! issuerNames.isEmpty()) {
issuer = issuerNames.first();
}
#else
issuer = qscCert.issuerInfo(QSslCertificate::CommonName);
#endif
// Really old certs/keys are no good, throw them away so we can
// generate a new one below.
if (issuer == QString::fromUtf8("Murmur Autogenerated Certificate")) {
log("Old autogenerated certificate is unusable for registration, invalidating it");
qscCert = QSslCertificate();
qskKey = QSslKey();
}
// If we have a cert, and it's a self-signed one, but we're binding to
// all the same addresses as the Meta server is, use it's cert instead.
// This allows a self-signed certificate generated by Murmur to be
// replaced by a CA-signed certificate in the .ini file.
if (!qscCert.isNull() && issuer == QString::fromUtf8("Murmur Autogenerated Certificate v2") && ! Meta::mp.qscCert.isNull() && ! Meta::mp.qskKey.isNull() && (Meta::mp.qlBind == qlBind)) {
qscCert = Meta::mp.qscCert;
qskKey = Meta::mp.qskKey;
}
// If we still don't have a certificate by now, try to load the one from Meta
if (qscCert.isNull() || qskKey.isNull()) {
if (! key.isEmpty() || ! crt.isEmpty()) {
log("Certificate specified, but failed to load.");
}
qskKey = Meta::mp.qskKey;
qscCert = Meta::mp.qscCert;
// If loading from Meta doesn't work, build+sign a new one
if (qscCert.isNull() || qskKey.isNull()) {
log("Generating new server certificate.");
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
X509 *x509 = X509_new();
EVP_PKEY *pkey = EVP_PKEY_new();
RSA *rsa = RSA_generate_key(2048,RSA_F4,NULL,NULL);
EVP_PKEY_assign_RSA(pkey, rsa);
//.........这里部分代码省略.........
示例7: _header
Frame::Frame(quint8 header)
: _header(header)
, _data(QByteArray())
{
}
示例8: QString
//.........这里部分代码省略.........
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n";
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
total_ram += QString::number(status.ullTotalPhys/1024/1024) + " MB\n";
switch(QSysInfo::windowsVersion())
{
case QSysInfo::WV_NT: os_version += "Windows NT\n"; break;
case QSysInfo::WV_2000: os_version += "Windows 2000\n"; break;
case QSysInfo::WV_XP: os_version += "Windows XP\n"; break;
case QSysInfo::WV_2003: os_version += "Windows Server 2003\n"; break;
case QSysInfo::WV_VISTA: os_version += "Windows Vista\n"; break;
case QSysInfo::WV_WINDOWS7: os_version += "Windows 7\n"; break;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
case QSysInfo::WV_WINDOWS8: os_version += "Windows 8\n"; break;
#endif
default: os_version += "Windows (Unknown version)\n"; break;
}
kernel_line += "Windows kernel\n";
#endif
#ifdef Q_OS_LINUX
number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
quint32 pages = sysconf(_SC_PHYS_PAGES);
quint32 page_size = sysconf(_SC_PAGE_SIZE);
quint64 total = (quint64)pages * page_size / 1024 / 1024;
total_ram += QString::number(total) + " MB\n";
os_version += "GNU/Linux or BSD\n";
#endif
// uname -a
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
QProcess *process = new QProcess();
QStringList arguments = QStringList("-a");
process->start("uname", arguments);
if (process->waitForFinished())
kernel_line += QString(process->readAll());
delete process;
#endif
#if (defined(Q_OS_WIN) && defined(__i386__)) || defined(__x86_64__)
// cpu info
quint32 registers[4];
quint32 i;
i = 0x80000002;
asm volatile
("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
: "a" (i), "c" (0));
processor_name += QByteArray(reinterpret_cast<char*>(®isters[0]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[1]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[2]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[3]), 4);
i = 0x80000003;
asm volatile
("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
: "a" (i), "c" (0));
processor_name += QByteArray(reinterpret_cast<char*>(®isters[0]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[1]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[2]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[3]), 4);
i = 0x80000004;
asm volatile
("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3])
: "a" (i), "c" (0));
processor_name += QByteArray(reinterpret_cast<char*>(®isters[0]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[1]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[2]), 4);
processor_name += QByteArray(reinterpret_cast<char*>(®isters[3]), 4);
processor_name += "\n";
#else
processor_name += "Unknown";
#endif
// compiler
#ifdef __GNUC__
compiler_version += "GCC " + QString(__VERSION__) + "\n";
#else
compiler_version += "Unknown\n";
#endif
if(sizeof(void*) == 4)
compiler_bits += "i386\n";
else if(sizeof(void*) == 8)
compiler_bits += "x86_64\n";
// concat system info
specs = qt_version
+ os_version
+ total_ram
+ screen_size
+ number_of_screens
+ processor_name
+ number_of_cores
+ compiler_version
+ compiler_bits
+ kernel_line;
}
示例9: data
ParametersRecord::ParametersRecord(const RecordHeader& header, const QByteArray& _data)
{
const UnsignedByteArray data(_data);
Q_ASSERT(header.type() == RecordHeader::ParametersRecord);
Q_ASSERT(data.length() >= header.contentLength());
int i = 0;
quint16 bytesToRead = header.contentLength();
const quint8 highBitMask = 1 << 7;
QByteArray name, value;
while(i < bytesToRead)
{
quint32 nameLength;
quint32 valueLength;
// See "Name-Value pairs" in the spec
// work out name length
if(data[i] & highBitMask)
{
// Four bytes of name length
nameLength =
((data[i] & ~highBitMask) << 24)
+ (data[i+1] << 16)
+ (data[i+2] << 8)
+ data[i+3]
;
i+= 4;
}
else
{
// 1 byte of name length
nameLength = data[i++];
}
// ditto for value
if(data[i] & highBitMask)
{
// Four bytes of value length
valueLength =
((data[i] & ~highBitMask) << 24)
+ (data[i+1] << 16)
+ (data[i+2] << 8)
+ data[i+3]
;
i+= 4;
}
else
{
// 1 byte of name length
valueLength = data[i++];
}
name = QByteArray(&data.constData()[i], nameLength);
i += nameLength;
value = QByteArray(&data.constData()[i], valueLength);
i += valueLength;
m_parameters.insert(name, value);
name.clear();
value.clear();
}
}
示例10: QByteArray
// XXX: documentation!!!
QByteArray QWSWindowSurface::transientState() const
{
return QByteArray();
}
示例11: Perf
//.........这里部分代码省略.........
// Prepare the source frames
QVector<void *> SrcPtr;
for( int i = 0 ; i < mInputs.size() ; i++ )
{
fugio::Image SrcImg = variant<fugio::Image>( mInputs.at( i ) );
if( !SrcImg.isValid() )
{
continue;
}
if( SrcImg.size() != SrcSze || SrcImg.lineSize( 0 ) != DstImg.lineSize( 0 ) )
{
continue;
}
SrcPtr << SrcImg.buffer( 0 );
}
//-------------------------------------------------------------------------
// Update the parameters
SetParameterStructTag PrmSet;
for( int i = 0 ; i < mParams.size() ; i++ )
{
QSharedPointer<fugio::PinInterface> PrmPin = mParams.at( i );
FreeframeLibrary::ParamEntry PrmEnt = mLibrary->params().at( i );
QVariant PrmVal = variant( PrmPin );
PrmSet.ParameterNumber = i;
if( PrmEnt.mType == FF_TYPE_STANDARD )
{
PrmSet.NewParameterValue.FloatValue = qBound( 0.0f, PrmVal.value<float>(), 1.0f );
PMU.PointerValue = &PrmSet;
MainFunc( FF_SETPARAMETER, PMU, mInstanceId );
}
else if( PrmEnt.mType == FF_TYPE_BOOLEAN )
{
PrmSet.NewParameterValue.UIntValue = PrmVal.value<bool>() ? FF_TRUE : FF_FALSE;
PMU.PointerValue = &PrmSet;
MainFunc( FF_SETPARAMETER, PMU, mInstanceId );
}
PMU.UIntValue = i;
PMU = MainFunc( FF_GETPARAMETERDISPLAY, PMU, mInstanceId );
if( PMU.UIntValue != FF_FAIL )
{
PrmPin->setDisplayLabel( QString::fromLatin1( QByteArray( (const char *)PMU.PointerValue, 16 ) ) );
}
}
//-------------------------------------------------------------------------
// Call the plugin
if( SrcPtr.size() >= mLibrary->minInputFrames() )
{
if( mLibrary->hasProcessFrameCopy() )
{
ProcessFrameCopyStruct PFC;
PFC.numInputFrames = SrcPtr.size();
PFC.pOutputFrame = DstImg.buffer( 0 );
PFC.ppInputFrames = SrcPtr.data();
PMU.PointerValue = &PFC;
PMU = MainFunc( FF_PROCESSFRAMECOPY, PMU, mInstanceId );
}
else
{
if( !SrcPtr.isEmpty() )
{
memcpy( DstImg.buffer( 0 ), SrcPtr.first(), DstImg.bufferSize( 0 ) );
}
PMU.PointerValue = DstImg.buffer( 0 );
PMU = MainFunc( FF_PROCESSFRAME, PMU, mInstanceId );
}
}
//-------------------------------------------------------------------------
// Update the pin if we succeed
if( PMU.UIntValue == FF_SUCCESS )
{
pinUpdated( mPinOutput );
}
}
示例12: QByteArray
/**
* @brief Clears contents of the movie based on a list
* @param infos List of infos which should be cleared
*/
void Movie::clear(QList<int> infos)
{
if (infos.contains(MovieScraperInfos::Actors))
m_actors.clear();
if (infos.contains(MovieScraperInfos::Backdrop)) {
m_backdrops.clear();
m_images.insert(ImageType::MovieBackdrop, QByteArray());
m_hasImageChanged.insert(ImageType::MovieBackdrop, false);
m_imagesToRemove.removeOne(ImageType::MovieBackdrop);
}
if (infos.contains(MovieScraperInfos::CdArt)) {
m_discArts.clear();
m_images.insert(ImageType::MovieCdArt, QByteArray());
m_hasImageChanged.insert(ImageType::MovieCdArt, false);
m_imagesToRemove.removeOne(ImageType::MovieCdArt);
}
if (infos.contains(MovieScraperInfos::ClearArt)) {
m_clearArts.clear();
m_images.insert(ImageType::MovieClearArt, QByteArray());
m_hasImageChanged.insert(ImageType::MovieClearArt, false);
m_imagesToRemove.removeOne(ImageType::MovieClearArt);
}
if (infos.contains(MovieScraperInfos::Logo)) {
m_logos.clear();
m_images.insert(ImageType::MovieLogo, QByteArray());
m_hasImageChanged.insert(ImageType::MovieLogo, false);
m_imagesToRemove.removeOne(ImageType::MovieLogo);
}
if (infos.contains(MovieScraperInfos::Countries))
m_countries.clear();
if (infos.contains(MovieScraperInfos::Genres))
m_genres.clear();
if (infos.contains(MovieScraperInfos::Poster)){
m_posters.clear();
m_images.insert(ImageType::MoviePoster, QByteArray());
m_hasImageChanged.insert(ImageType::MoviePoster, false);
m_numPrimaryLangPosters = 0;
m_imagesToRemove.removeOne(ImageType::MoviePoster);
}
if (infos.contains(MovieScraperInfos::Studios))
m_studios.clear();
if (infos.contains(MovieScraperInfos::Title))
m_originalName = "";
if (infos.contains(MovieScraperInfos::Set))
m_set = "";
if (infos.contains(MovieScraperInfos::Overview)) {
m_overview = "";
m_outline = "";
}
if (infos.contains(MovieScraperInfos::Rating)) {
m_rating = 0;
m_votes = 0;
}
if (infos.contains(MovieScraperInfos::Released))
m_released = QDate(2000, 02, 30); // invalid date
if (infos.contains(MovieScraperInfos::Tagline))
m_tagline = "";
if (infos.contains(MovieScraperInfos::Runtime))
m_runtime = 0;
if (infos.contains(MovieScraperInfos::Trailer))
m_trailer = "";
if (infos.contains(MovieScraperInfos::Certification))
m_certification = "";
if (infos.contains(MovieScraperInfos::Writer))
m_writer = "";
if (infos.contains(MovieScraperInfos::Director))
m_director = "";
if (infos.contains(MovieScraperInfos::Tags))
m_tags.clear();
if (infos.contains(MovieScraperInfos::Banner)) {
m_images.insert(ImageType::MovieBanner, QByteArray());
m_hasImageChanged.insert(ImageType::MovieBanner, false);
m_imagesToRemove.removeOne(ImageType::MovieBanner);
}
if (infos.contains(MovieScraperInfos::Thumb)) {
m_images.insert(ImageType::MovieThumb, QByteArray());
m_hasImageChanged.insert(ImageType::MovieThumb, false);
m_imagesToRemove.removeOne(ImageType::MovieThumb);
}
if (infos.contains(MovieScraperInfos::ExtraFanarts)) {
m_extraFanartsToRemove.clear();
m_extraFanartImagesToAdd.clear();
m_extraFanarts.clear();
}
}
示例13: QByteArray
void ImageScalingTest::shouldHaveChangeMimetype_data()
{
QTest::addColumn<QByteArray>("initialmimetype");
QTest::addColumn<QByteArray>("newmimetype");
QTest::addColumn<QString>("format");
QTest::newRow("no change mimetype when empty") << QByteArray() << QByteArray() << QStringLiteral("PNG");
QTest::newRow("no change mimetype when empty jpeg") << QByteArray() << QByteArray() << QStringLiteral("JPG");
QTest::newRow("no change mimetype when jpeg (same)") << QByteArray("image/jpeg") << QByteArray("image/jpeg") << QStringLiteral("JPG");
QTest::newRow("no change mimetype when jpeg") << QByteArray("image/jpeg") << QByteArray("image/jpeg") << QStringLiteral("PNG");
QTest::newRow("no change mimetype when png (same)") << QByteArray("image/png") << QByteArray("image/png") << QStringLiteral("JPG");
QTest::newRow("no change mimetype when png") << QByteArray("image/png") << QByteArray("image/png") << QStringLiteral("PNG");
QTest::newRow("change mimetype when png") << QByteArray("image/mng") << QByteArray("image/png") << QStringLiteral("PNG");
QTest::newRow("change mimetype when jpeg") << QByteArray("image/mng") << QByteArray("image/jpeg") << QStringLiteral("JPG");
QTest::newRow("When format is not defined but png") << QByteArray("image/png") << QByteArray("image/png") << QString();
QTest::newRow("When format is not defined but jpeg") << QByteArray("image/jpeg") << QByteArray("image/jpeg") << QString();
QTest::newRow("When format is not defined but other mimetype (return png)") << QByteArray("image/mng") << QByteArray("image/png") << QString();
}
示例14: switch
QVariant SettingsHandlerBase::handleReadItemValue(const XQSettingsKey& key, XQSettingsManager::Type type, TInt& error)
{
const TInt KRBufDefaultLength = 32;
switch(type)
{
case XQSettingsManager::TypeVariant:
{
//Try to read TInt
TInt intValue;
error = getValue(key.key(), intValue);
if (error == KErrNone)
{
return QVariant(intValue);
}
//Try to read TReal
TReal realValue;
error = getValue(key.key(), realValue);
if (error == KErrNone)
{
return QVariant(realValue);
}
//Try to read RBuf8
QVariant byteArrayVariant;
TRAP(error,
RBuf8 tdes8Value;
tdes8Value.CreateL(KRBufDefaultLength);
CleanupClosePushL(tdes8Value);
getValueL(key.key(), tdes8Value);
byteArrayVariant.setValue(QByteArray((const char*)tdes8Value.Ptr(), tdes8Value.Length()));
CleanupStack::PopAndDestroy(&tdes8Value);
)
if (error == KErrNone)
{
return byteArrayVariant;
}
break;
}
case XQSettingsManager::TypeInt:
{
//Try to read TInt
TInt intValue;
error = getValue(key.key(), intValue);
if (error == KErrNone)
{
return QVariant(intValue);
}
break;
}
case XQSettingsManager::TypeDouble:
{
//Try to read TReal
TReal realValue;
error = getValue(key.key(), realValue);
if (error == KErrNone)
{
return QVariant(realValue);
}
break;
}
case XQSettingsManager::TypeString:
{
//Try to read RBuf8
QVariant stringVariant;
TRAP(error,
RBuf16 tdes16Value;
tdes16Value.CreateL(KRBufDefaultLength);
CleanupClosePushL(tdes16Value);
getValueL(key.key(), tdes16Value);
stringVariant.setValue(QString::fromUtf16(tdes16Value.Ptr(), tdes16Value.Length()));
CleanupStack::PopAndDestroy(&tdes16Value);
)
if (error == KErrNone)
{
return stringVariant;
}
break;
}
示例15: init
void SshOutgoingPacket::generateChannelOpenFailurePacket(quint32 remoteChannel, quint32 reason,
const QByteArray &reasonString)
{
init(SSH_MSG_CHANNEL_OPEN_FAILURE).appendInt(remoteChannel).appendInt(reason)
.appendString(reasonString).appendString(QByteArray()).finalize();
}