Example #1
0
QVariant UsersModel::data( const QModelIndex& index, int role ) const
{
    int level = levelOf( index );
    int row = mappedRow( index );

    if ( role == Qt::DisplayRole ) {
        QVariant value = rawData( level, row, mappedColumn( index ), role );

        if ( mappedColumn( index ) == 4 ) {
            int access = value.toInt();
            if ( access == NormalAccess )
                return tr( "Regular user" );
            if ( access == AdminAccess )
                return tr( "System administrator" );
            return tr( "Disabled" );
        }

        return value;
    }

    if ( role == Qt::DecorationRole && index.column() == 0 ) {
        int access = rawData( level, row, 4, Qt::DisplayRole ).toInt();
        if ( access == AdminAccess )
            return IconLoader::overlayedPixmap( "user", "overlay-admin" );
        if ( access == NoAccess )
            return IconLoader::pixmap( "user-disabled" );
        return IconLoader::pixmap( "user" );
    }

    return QVariant();
}
/**
 * @brief Write the neutral mob data back to a file.
 */
void NeutralMob::writeToFile( QFile &unitFile )
{
    QTextStream unitStream(&unitFile);

    if ( (dirty() > 0) || (rawData() == Q_NULLPTR) ) { // dirty = 0 means not dirty, dirty < 0 means uneditable, dirty > 0 means we can probably edit this entry without issue
        unitStream << type() << "/"
                   << posX() << "/"
                   << posY() << "/"
                   << posZ() << "/"
                   << rotation() << "/";

        // Write all the unknown floats
        for (int i=0; i<4; i++)
        {
            unitStream << unknown_float(i) << "/";
        }

        // Write all the options
        for (int i=0; i<3; i++)
        {
            unitStream << QString(option(i)?"True":"False") << "/";
        }

    } else {
        unitStream << rawData();
    }

    unitStream << endl;
    unitStream.flush();
}
void CWspHeaderReader::DecodeGenericNewStringValueL(RHeaderField& aHeader) const
	{
	TPtrC8 rawHeaderData;
	aHeader.RawDataL(rawHeaderData);

	TInt startPos = 0;
	TInt separatorPos = 0;
	TInt ii = 0;
	// Loop through all the parts separated by the header field name
	do
		{
		TPtrC8 rawData(rawHeaderData.Mid(startPos));
		separatorPos = rawData.Locate((TUint8)(aHeader.Name().Index(WSP::Table) + KTopBitMask));
		if(separatorPos!=KErrNotFound)
			rawData.Set(rawHeaderData.Mid(startPos, separatorPos));

		CheckLengthL(rawData, 1);
		TWspPrimitiveDecoder wspDecoder(rawData);
		if( !(CheckNullDesPartL(aHeader, rawData, ii)) )
			{
			AddNewDecoderStringPartL(aHeader, wspDecoder, ii);
			}

		++ii;
		startPos += (separatorPos + 1);
		} while( separatorPos != KErrNotFound );
	}
Example #4
0
int main(int argc, char* argv[])
{
  try
  {
    if (argc < 2)
    {
      return 0;
    }
    std::unique_ptr<Dump> rawData(new Dump());
    Test::OpenFile(argv[1], *rawData);
    const Binary::Container::Ptr data = Binary::CreateContainer(std::move(rawData));
    OggBuilder builder;
    if (const auto result = Formats::Chiptune::OggVorbis::Parse(*data, builder))
    {
      std::cout << result->Size() << " bytes total" << std::endl;
    }
    else
    {
      std::cout << "Failed to parse" << std::endl;
    }
    return 0;
  }
  catch (const std::exception& e)
  {
    std::cout << e.what() << std::endl;
    return 1;
  }
}
Example #5
0
bool NameRecord::operator==(const NameRecord &o) {
	if (isNull() != o.isNull() || owner() != o.owner() || ttl() != o.ttl() || type() != o.type()) {
		return false;
	}

	switch (type()) {
		case XMPP::NameRecord::A:
		case XMPP::NameRecord::Aaaa:
			return address() == o.address();
		case XMPP::NameRecord::Mx:
			return name() == o.name() && priority() == o.priority();
		case XMPP::NameRecord::Srv:
			return name() == o.name() && port() == o.port() && priority() == o.priority() && weight() == o.weight();
		case XMPP::NameRecord::Cname:
		case XMPP::NameRecord::Ptr:
		case XMPP::NameRecord::Ns:
			return name() == o.name();
		case XMPP::NameRecord::Txt:
			return texts() == o.texts();
		case XMPP::NameRecord::Hinfo:
			return cpu() == o.cpu() && os() == o.os();
		case XMPP::NameRecord::Null:
			return rawData() == o.rawData();
		case XMPP::NameRecord::Any:
			return false;
	}

	return false;
}
Example #6
0
	void MemcachedCache::setValue(const QString& key, const CacheEntry& entry)
	{
		QWriteLocker lock(&m_lock);

		// Binary key
		const QByteArray rawKey(fullKey(key));

		// Binary data
		const quint64 dateTime(qToLittleEndian(static_cast<quint64>(entry.timeStamp().toTime_t())));
		QByteArray rawData(reinterpret_cast<const char*>(&dateTime), sizeof(quint64));
		rawData.append(entry.data());

		// Store in memcached
		memcached_return rt;
		rt = memcached_set(
			m_memcached,
			rawKey.constData(),
			rawKey.length(),
			rawData.constData(),
			rawData.length(),
			0, // expire
			0 // flags
		);
		if(rt != MEMCACHED_SUCCESS)
		{
			qFatal("Memcached error: %s", memcached_strerror(m_memcached, rt));
		}
	}
Example #7
0
void Tile<TS>::draw(Image& image, const PaletteT& palette,
                    unsigned xOffset, unsigned yOffset,
                    const bool hFlip, const bool vFlip) const
{
    if (image.size().width < (xOffset + TILE_SIZE)
        || image.size().height < (yOffset + TILE_SIZE)) {

        return;
    }

    rgba* imgBits;
    const uint8_t* tilePos = rawData();
    for (unsigned y = 0; y < TILE_SIZE; y++) {
        unsigned fy = (vFlip == false) ? y : TILE_SIZE - 1 - y;
        imgBits = image.scanline(yOffset + fy) + xOffset;

        for (unsigned x = 0; x < TILE_SIZE; x++) {
            unsigned fx = (hFlip == false) ? x : TILE_SIZE - 1 - x;

            auto p = *tilePos & palette.PIXEL_MASK;
            if (p != 0) {
                imgBits[fx] = palette.color(p).rgb();
            }
            tilePos++;
        }
    }
}
Example #8
0
int main(int argc, char* argv[])
{
    try
    {
        if (argc < 3)
        {
            return 0;
        }
        std::auto_ptr<Dump> rawData(new Dump());
        Test::OpenFile(argv[2], *rawData);
        const Binary::Container::Ptr data = Binary::CreateContainer(rawData);
        const Formats::Chiptune::ProTracker3::ChiptuneBuilder::Ptr builder = Formats::Chiptune::ProTracker3::CreateVortexTracker2Builder();
        const std::string type(argv[1]);
        if (type == "txt")
        {
            Formats::Chiptune::ProTracker3::ParseVortexTracker2(*data, *builder);
        }
        else if (type == "pt3")
        {
            Formats::Chiptune::ProTracker3::ParseCompiled(*data, *builder);
        }
        const Binary::Data::Ptr result = builder->GetResult();
        const char* const start = static_cast<const char*>(result->Start());
        std::cout << std::string(start, start + result->Size());
        return 0;
    }
    catch (const std::exception& e)
    {
        std::cout << e.what() << std::endl;
        return 1;
    }
}
Example #9
0
void ManifestCache::save (
    DatabaseCon& dbCon, std::string const& dbTable,
    std::function <bool (PublicKey const&)> isTrusted)
{
    std::lock_guard<std::mutex> lock{apply_mutex_};

    auto db = dbCon.checkoutDb ();

    soci::transaction tr(*db);
    *db << "DELETE FROM " << dbTable;
    std::string const sql =
        "INSERT INTO " + dbTable + " (RawData) VALUES (:rawData);";
    for (auto const& v : map_)
    {
        // Save all revocation manifests,
        // but only save trusted non-revocation manifests.
        if (! v.second.revoked() && ! isTrusted (v.second.masterKey))
        {

            JLOG(j_.info())
               << "Untrusted manifest in cache not saved to db";
            continue;
        }

        // soci does not support bulk insertion of blob data
        // Do not reuse blob because manifest ecdsa signatures vary in length
        // but blob write length is expected to be >= the last write
        soci::blob rawData(*db);
        convert (v.second.serialized, rawData);
        *db << sql,
            soci::use (rawData);
    }
    tr.commit ();
}
Example #10
0
VTabContent * VContentGetter::veloFileConfigs(VPlotOps * plotOps, std::string interfaceScript)
{
  VTabContent * topDummyTab = new VTabContent("Top"); // Always needed.
  std::vector<VTabContent*> allTabs; // Useful to have container for all tabs.
  allTabs.push_back(topDummyTab);

  // Load all data into a vector.
  std::vector< std::vector< std::string > > ops;
  FILE * in;
  char buff[512];

  std::string command = "python " + interfaceScript + " run_view_config";
  in = popen(command.c_str(), "r");
  while(fgets(buff, sizeof(buff), in)!=NULL) {
    std::string rawData(buff);
    // Split by spaces.
    std::vector<std::string> rawDataSplit;
    std::istringstream iss(rawData);
    std::copy(std::istream_iterator<std::string>(iss),
       std::istream_iterator<std::string>(),
       std::back_inserter(rawDataSplit));
    ops.push_back(rawDataSplit);
  }

  findChildren(topDummyTab, &allTabs, &ops); // Called recursively.
  findPlots(&allTabs, &ops, plotOps);
  return topDummyTab;
}
Example #11
0
DataWidget *WidgetArea::addWidget(QPoint pos, quint8 type, bool show)
{
    DataWidget *w = sWidgetFactory.getWidget(type, this);
    if(!w)
        return NULL;

    quint32 id = getNewId();
    w->setId(id);

    w->setUp(m_storage);

    w->move(pos);
    if(show)
        w->show();

    m_widgets.insert(id, w);

    connect(w,          SIGNAL(removeWidget(quint32)),              SLOT(removeWidget(quint32)));
    connect(w,          SIGNAL(updateMarker(DataWidget*)),          SLOT(updateMarker(DataWidget*)));
    connect(w,          SIGNAL(clearPlacementLines()),              SLOT(clearPlacementLines()));
    connect(w,          SIGNAL(updateData()),                       SIGNAL(updateData()));
    connect(w,   SIGNAL(mouseStatus(bool,data_widget_info,qint32)), SIGNAL(mouseStatus(bool,data_widget_info,qint32)));
    connect(w,          SIGNAL(SendData(QByteArray)),   m_analyzer, SIGNAL(SendData(QByteArray)));
    connect(w,          SIGNAL(toggleSelection(bool)),              SLOT(toggleSelection(bool)));
    connect(this,       SIGNAL(setTitleVisibility(bool)),        w, SLOT(setTitleVisibility(bool)));
    connect(w,  SIGNAL(addChildTab(ChildTab*,QString)), m_analyzer, SLOT(addChildTab(ChildTab*,QString)));
    connect(w,  SIGNAL(removeChildTab(ChildTab*)),      m_analyzer, SLOT(removeChildTab(ChildTab*)));
    connect(w,          SIGNAL(addUndoAct(UndoAction*)),&m_undoStack,SLOT(addAction(UndoAction*)));
    connect(m_analyzer, SIGNAL(rawData(QByteArray)),             w, SIGNAL(rawData(QByteArray)));
    connect(this,       SIGNAL(setLocked(bool)),                 w, SLOT(setLocked(bool)));

    //events
    connect(this,       SIGNAL(onWidgetAdd(DataWidget*)),        w, SLOT(onWidgetAdd(DataWidget*)));
    connect(this,       SIGNAL(onWidgetRemove(DataWidget*)),     w, SLOT(onWidgetRemove(DataWidget*)));
    connect(this,       SIGNAL(onScriptEvent(QString)),          w, SLOT(onScriptEvent(QString)));
    connect(this,       SIGNAL(onScriptEvent(QString,QVariantList)), w, SLOT(onScriptEvent(QString, QVariantList)));
    connect(w,          SIGNAL(scriptEvent(QString)),         this, SIGNAL(onScriptEvent(QString)));
    connect(w,          SIGNAL(scriptEvent(QString, QVariantList)),this, SIGNAL(onScriptEvent(QString, QVariantList)));

    emit onWidgetAdd(w);

    m_analyzer->setDataChanged();

    w->setTitleVisibility(m_actTitleVisibility->isChecked());
    return w;
}
Example #12
0
/**
 * Interpolate from input histogram to the output
 * @param input A histogram from which to interpolate
 * @param output A histogram containing the interpolated values
 */
void interpolateLinearInplace(const Histogram &input, Histogram &output) {
  sanityCheck(input, output, minSizeForLinearInterpolation());
  const auto inputPoints = input.points();
  const auto &points = inputPoints.rawData();
  const auto &y = input.y().rawData();
  const auto &interpPoints = output.points();
  auto &newY = output.mutableY();
  interpolateInplace(points, y, interpPoints, newY, InterpolationType::LINEAR);
}
Example #13
0
/*
 * reboot, 0, 3.13.0-40-generic, 0, 0x7fff5bcc427c, ~~, ~, 0, 0, 1418589862
 * bryan, 4863, :0, 0, 0x7fff5bcc427c, /3, pts/3, 0, 0, 1418652552
 */
std::string searchString(std::string searchString, std::vector<utmp> entries) {
    std::string findGroup = "test";
    pcrecpp::RE regex(searchString);
    if (!regex.PartialMatch(rawData(entries))) {
        std::cout << "Could not parse data with search string: " << searchString << std::endl;
        throw string("Error");
    }
    return findGroup;
}
Example #14
0
punchVisualiser::punchVisualiser(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::punchVisualiser)
{
    ui->setupUi(this);
    m_sportIdentModule = new SportIdentReader(this);
    connect(m_sportIdentModule, SIGNAL(logText(QString,SportIdentReader::MessageType)),
            this, SLOT(processMessage(QString,SportIdentReader::MessageType)));
    connect(m_sportIdentModule, SIGNAL(rawData(QByteArray)), this, SLOT(dataReceived(QByteArray)));
}
Example #15
0
void SshOutgoingPacket::finalize()
{
    setPadding();
    setLengthField(m_data);
    m_length = m_data.size() - 4;
    qCDebug(sshLog, "Encrypting packet of type %u", m_data.at(TypeOffset));
    encrypt();
    qCDebug(sshLog, "Sending packet of size %d", rawData().count());
    Q_ASSERT(isComplete());
}
Example #16
0
QCString &QCString::insert( uint index, const char *s )
{
  int len = s ? qstrlen(s) : 0;
  if ( len == 0 ) return *this;
  int olen = length();
  int nlen = olen + len;
  if ((int)index>=olen)
  {
    resize(nlen+index-olen+1);
    memset(rawData()+olen, ' ', index-olen);
    memcpy(rawData()+index,s, len+1);
  }
  else
  {
    resize(nlen+1);
    qmemmove(rawData()+index+len,data()+index,olen-index+1);
    memcpy(rawData()+index,s,len);
  }
  return *this;
}
Example #17
0
QTM_BEGIN_NAMESPACE


CNdefMessage* QNFCNdefUtility::QNdefMsg2CNdefMsgL( const QNdefMessage& msg )
    {
        QByteArray payload = msg.toByteArray();
        CNdefMessage* cmsg = CNdefMessage::NewL();
        TPtrC8 rawData(reinterpret_cast<const TUint8*>(payload.constData()), payload.size());
        cmsg->ImportRawDataL(rawData, 0);
        return cmsg;
    }
Example #18
0
QCString &QCString::sprintf( const char *format, ... )
{
  va_list ap;
  va_start( ap, format );
  const int minlen=256;
  int l = length();
  if (l<minlen) { resize(minlen); l=minlen; }
  int n=vsnprintf( rawData(), l, format, ap);
  if (n<0) n=l;
  resize(n+1);
  va_end( ap );
  return *this;
}
void CWspHeaderReader::DecodeContentEncodingL(RHeaderField& aHeader) const
	{
	TPtrC8 rawHeaderData;
	aHeader.RawDataL(rawHeaderData);
	TInt startPos = 0;
	TInt separatorPos = 0;
	TInt ii = 0;
	// Loop through all the parts separated by the header field token name
	do
		{
		TPtrC8 rawData(rawHeaderData.Mid(startPos));
		separatorPos = rawData.Locate((TUint8)(WSP::EContentEncoding + KTopBitMask));
		if(separatorPos!=KErrNotFound)
			rawData.Set(rawHeaderData.Mid(startPos, separatorPos));

		CheckLengthL(rawData, 1);
		TInt contentEncodingIndex = KErrNotFound;
		switch( rawData[0] )
			{
			case 128: // This is the token for 'GZip'
				{
				contentEncodingIndex = WSPStdConstants::EGzip;
				} break;
			case 129: // This is the token for 'Compress'
				{
				contentEncodingIndex = WSPStdConstants::ECompress;
				} break;
			case 130: // This is the token for 'Deflate'
				{
				contentEncodingIndex = WSPStdConstants::EDeflate;
				} break;
			default: // Must be token text
				{
				TWspPrimitiveDecoder wspDecoder(rawData);
				// Check that the data is of string type
				if( wspDecoder.VarType() == TWspPrimitiveDecoder::EString )
					{
					// Extract and add the string as a part
					AddNewDecoderStringPartL(aHeader, wspDecoder, ii);
					}
				else
					User::Leave(KErrCorrupt);
				} break;
			}

		if(contentEncodingIndex!=KErrNotFound)
			SetFStringPartL(aHeader, ii, iStrPool.StringF(contentEncodingIndex, WSPStdConstants::Table));
		++ii;
		startPos += (separatorPos + 1);
		} while( separatorPos != KErrNotFound );
	}
void CWspHeaderReader::DecodeContentLanguageL(RHeaderField& aHeader) const
	{
	TPtrC8 rawHeaderData;
	aHeader.RawDataL(rawHeaderData);
	TInt startPos = 0;
	TInt separatorPos = 0;
	TInt ii = 0;
	// Loop through all the parts separated by the header field name
	do
		{
		TPtrC8 rawData(rawHeaderData.Mid(startPos));
		separatorPos = rawData.Locate((TUint8)(WSP::EContentLanguage + KTopBitMask));
		if(separatorPos!=KErrNotFound)
			rawData.Set(rawHeaderData.Mid(startPos, separatorPos));

		CheckLengthL(rawData, 1);
		// First check for any language ('*') encoded as octet 128
		if( rawData[0] == 128 )
			SetFStringPartL(aHeader, ii, iStrPool.StringF(WSPLanguages::EAnyLanguage, WSPLanguages::Table));
		else
			{
			// Otherwise the language is encoded as a short int, long int or token text
			TWspPrimitiveDecoder wspDecoder(rawData);
			switch( wspDecoder.VarType() )
				{
				case TWspPrimitiveDecoder::E7BitVal: // short int
				case TWspPrimitiveDecoder::ELengthVal: // long int
					{
					TUint32 languageToken = 0;
					User::LeaveIfError(wspDecoder.Integer(languageToken));
					// Check if the language token is short or long int as long requires an offset
					if( languageToken >= 128 )
						// Language token is long int so apply the offset
						--languageToken;
					SetFStringPartL(aHeader, ii, iStrPool.StringF(languageToken, WSPLanguages::Table));
					} break;
				case TWspPrimitiveDecoder::EString: // token text
					{
					// Extract the token text and set the part
					AddNewDecoderStringPartL(aHeader, wspDecoder, ii);
					} break;
				default:
					User::Leave(KErrCorrupt);
					break;
				}
			}

		++ii;
		startPos += (separatorPos + 1);
		} while( separatorPos != KErrNotFound );
	}
void SshOutgoingPacket::finalize()
{
    setPadding();
    setLengthField(m_data);
    m_length = m_data.size() - 4;
#ifdef CREATOR_SSH_DEBUG
    qDebug("Encrypting packet of type %u", m_data.at(TypeOffset));
#endif
    encrypt();
#ifdef CREATOR_SSH_DEBUG
    qDebug("Sending packet of size %d", rawData().count());
#endif
    Q_ASSERT(isComplete());
}
Example #22
0
bool SoundData::loadWav(const byte * buffer, Uint32 bufferSize)
{
    clear();

    if (!buffer || bufferSize == 0)
    {
        return false;
    }

    if (buffer[0] != 'R' ||
            buffer[1] != 'I' ||
            buffer[2] != 'F' ||
            buffer[3] != 'F')
    {
        return false;
    }

    Uint32 dataSize;
    Uint32 sampleRate;
    Uint16 channels;
    Uint16 bitsPerSample;

    dataSize = util::bytesToUintLE(&buffer[40]);
    channels = util::bytesToUshortLE(&buffer[22]);
    sampleRate = util::bytesToUintLE(&buffer[24]);
    bitsPerSample = util::bytesToUshortLE(&buffer[34]);

    if (dataSize == 0 ||
            (channels != 1 && channels != 2) ||
            (bitsPerSample != 8 && bitsPerSample != 16))
    {
        return false;
    }

    std::vector<byte> rawData(dataSize);

    memcpy(&rawData[0], buffer + 44, dataSize);

    if (!separateChannels(rawData.data(), dataSize, channels, bitsPerSample))
    {
        return false;
    }

    _channels = channels;
    _bitsPerSample = bitsPerSample;
    _sampleRate = sampleRate;

    return true;
}
void CWspDefaultHdrReader::DecodeHeaderL(RHeaderField& aHeader)
	{
	// Get and store the header field name
	TPtrC8 headerField(aHeader.Name().DesC());

	// Decode the header as a text-string
	TPtrC8 rawHeaderData;
	aHeader.RawDataL(rawHeaderData);

	TInt startPos = 0;
	TInt separatorPos = 0;
	TInt ii = 0;
	// Loop through all the parts separated by the header field name
	do
		{
		TPtrC8 rawData(rawHeaderData.Mid(startPos));
		separatorPos = rawData.FindF(headerField);
		if(separatorPos!=KErrNotFound)
			rawData.Set(rawHeaderData.Mid(startPos, separatorPos));

		// Check that the length of the data is at least 1
		if( rawData.Length() < 1 )
			User::Leave(KErrCorrupt);

		// Check if the data is an empty string which should only have a NULL terminator
		// otherwise extract the text-string from the primitive decoder
		TUint8 firstByte = rawData[0];
		TWspPrimitiveDecoder wspDecoder(rawData);
		TPtrC8 buffer;
		if( firstByte == 0 )
			buffer.Set(KNullDesC8());
		else
			User::LeaveIfError(wspDecoder.String(buffer));

		// Create a header part from the decoded buffer and add the part to the header field
		RStringF partStr = iStrPool.OpenFStringL(buffer);
		CleanupClosePushL(partStr);
		THTTPHdrVal partVal(partStr);
		CHeaderFieldPart* part = CHeaderFieldPart::NewL(partVal);
		CleanupStack::PushL(part);
		aHeader.SetPartL(part, ii);
		CleanupStack::Pop(part);
		CleanupStack::PopAndDestroy(&partStr);

		++ii;
		startPos += (separatorPos + headerField.Length() + 1);
		} while( separatorPos != KErrNotFound );
	}
Example #24
0
QByteArray QxtMailAttachment::mimeData()
{
    bool isMultipart = false;
    QTextCodec* latin1 = QTextCodec::codecForName("latin1");

    if (qxt_d->attachments.count()) {
        if (!qxt_d->contentType.startsWith("multipart/", Qt::CaseInsensitive))
            setExtraHeader(QStringLiteral("Content-Type"), QStringLiteral("multipart/mixed"));
    }

    QByteArray rv = "Content-Type: " + qxt_d->contentType.toLatin1() + "\r\n";
    if (qxt_d->contentType.startsWith("multipart/", Qt::CaseInsensitive)) {
        isMultipart = true;
    }
    else {
        rv += "Content-Transfer-Encoding: base64\r\n";
    }

    foreach(const QString& r, qxt_d->extraHeaders.keys())
    {
        rv += qxt_fold_mime_header(r, extraHeader(r), latin1);
    }
    rv += "\r\n";

    const QByteArray& d = rawData();
    int chars = isMultipart? 73 : 57; // multipart preamble supposed to be 7bit latin1
    for (int pos = 0; pos < d.length(); pos += chars)
    {
        if (isMultipart) {
            rv += d.mid(pos, chars) + "\r\n";
        } else {
            rv += d.mid(pos, chars).toBase64() + "\r\n";
        }
    }

    if (isMultipart) {
        QMutableMapIterator<QString, QxtMailAttachment> it(qxt_d->attachments);
        while (it.hasNext()) {
            rv += "--" + qxt_d->boundary + "\r\n";
            rv += it.next().value().mimeData();
        }
        rv += "--" + qxt_d->boundary + "--\r\n";
    }

    return rv;
}
Example #25
0
QCString &QCString::remove( uint index, uint len )
{
  uint olen = length();
  if ( index + len >= olen ) // range problems
  {
    if ( index < olen )  // index ok
    {
      resize( index+1 );
    }
  }
  else if ( len != 0 )
  {
    QCString tmp(olen-index-len+1);
    qmemmove( tmp.rawData(), data()+index+len, olen-index-len+1 );
    resize( olen-len+1 );
    memcpy( rawData()+index,tmp.data(),tmp.length() );
  }
  return *this;
}
        Cost PathLengthDirectInfSampler::heuristicSolnCost(const State* statePtr) const
        {
            //Variable
            //The raw data in the state
            std::vector<double> rawData(informedSubSpace_->getDimension());

            //Get the raw data
            if ( StateSampler::space_->isCompound() == false )
            {
                informedSubSpace_->copyToReals(rawData, statePtr);
            }
            else
            {
                informedSubSpace_->copyToReals(rawData, statePtr->as<CompoundState>()->components[informedIdx_]);
            }

            //Calculate and return the length
            return Cost(phsPtr_->getPathLength(informedSubSpace_->getDimension(), &rawData[0]));
        }
Example #27
0
void ofxTouchBoard::update(){
	serial.lock();
		vector<ofxTB::Electrode> rawData(serial.getNormalizedData());
	serial.unlock();
	
	if(electrodes.size() == rawData.size()){
		for(int i = 0; i < electrodes.size(); ++i){
			electrodes[i].touch = rawData[i].touch;
			electrodes[i].diff = (1.0 - jitter) * rawData[i].diff + jitter * electrodes[i].diff;
			electrodes[i].bval = (1.0 - jitter) * rawData[i].bval + jitter * electrodes[i].bval;
			electrodes[i].fdat = (1.0 - jitter) * rawData[i].fdat + jitter * electrodes[i].fdat;
			electrodes[i].tths = rawData[i].tths;
			electrodes[i].rths = rawData[i].rths;
		}
	}
	else{
		ofLog() << "electrodes.size() != rawData.size()";
	}
	updateStatus();
}
Example #28
0
bool FlxSave::load(const char *path) {
    FlxBackendFile *file = FlxG::backend->openFile(path, "rb", false);
    if(!file) return false;

    file->seek(0, SEEK_END);
    unsigned int size = file->tell();
    file->seek(0, SEEK_SET);

    char *buffer = new char[size + 1];
	memset(buffer, 0, size + 1);

    file->read(buffer, size);

    for(unsigned int i = 0; i < size; i++) {
        buffer[i] ^= 24;
    }

    std::string rawData(buffer, buffer + size - 1);

    delete[] buffer;
    delete file;

	// parse data
    std::stringstream ss(rawData);
    std::string name, value;

    while(!ss.eof()) {

        if(name == "") {
            std::getline(ss, name);
        }
        else {
            std::getline(ss, value);

            data[name] = value;
            name = value = "";
        }
    }

    return true;
}
Example #29
0
sk_sp<SkColorTable> SkGIFColorMap::buildTable(SkStreamBuffer* streamBuffer, SkColorType colorType,
                                              int transparentPixel) const
{
    if (!m_isDefined)
        return nullptr;

    const PackColorProc proc = choose_pack_color_proc(false, colorType);
    if (m_table && proc == m_packColorProc && m_transPixel == transparentPixel) {
        SkASSERT(transparentPixel == kNotFound || transparentPixel > m_table->count()
                || m_table->operator[](transparentPixel) == SK_ColorTRANSPARENT);
        // This SkColorTable has already been built with the same transparent color and
        // packing proc. Reuse it.
        return m_table;
    }
    m_packColorProc = proc;
    m_transPixel = transparentPixel;

    const size_t bytes = m_colors * SK_BYTES_PER_COLORMAP_ENTRY;
    sk_sp<SkData> rawData(streamBuffer->getDataAtPosition(m_position, bytes));
    if (!rawData) {
        return nullptr;
    }

    SkASSERT(m_colors <= SK_MAX_COLORS);
    const uint8_t* srcColormap = rawData->bytes();
    SkPMColor colorStorage[SK_MAX_COLORS];
    for (int i = 0; i < m_colors; i++) {
        if (i == transparentPixel) {
            colorStorage[i] = SK_ColorTRANSPARENT;
        } else {
            colorStorage[i] = proc(255, srcColormap[0], srcColormap[1], srcColormap[2]);
        }
        srcColormap += SK_BYTES_PER_COLORMAP_ENTRY;
    }
    for (int i = m_colors; i < SK_MAX_COLORS; i++) {
        colorStorage[i] = SK_ColorTRANSPARENT;
    }
    m_table = sk_sp<SkColorTable>(new SkColorTable(colorStorage, SK_MAX_COLORS));
    return m_table;
}
void CWspHeaderReader::DecodeGenericFieldNameL(RHeaderField& aHeader) const
	{
	TPtrC8 rawHeaderData;
	aHeader.RawDataL(rawHeaderData);
	TInt startPos = 0;
	TInt separatorPos = 0;
	TInt ii = 0;
	// Loop through all the parts separated by the header field name
	do
		{
		TPtrC8 rawData(rawHeaderData.Mid(startPos));
		separatorPos = rawData.Locate((TUint8)(aHeader.Name().Index(WSP::Table) + KTopBitMask));
		if(separatorPos!=KErrNotFound)
			rawData.Set(rawHeaderData.Mid(startPos, separatorPos));

		CheckLengthL(rawData, 1);
		TWspPrimitiveDecoder wspDecoder(rawData);
		switch( wspDecoder.VarType() )
			{
			case TWspPrimitiveDecoder::EString:
				{
				AddNewDecoderStringPartL(aHeader, wspDecoder, ii);
				} break;
			case TWspPrimitiveDecoder::E7BitVal:
				{
				TUint8 fieldNameToken = 0;
				User::LeaveIfError(wspDecoder.Val7Bit(fieldNameToken));
				RStringF fieldNameStr = iStrPool.StringF(fieldNameToken, iStrTable);
				SetFStringPartL(aHeader, ii, fieldNameStr);
				} break;
			default:
				User::Leave(KErrCorrupt);
				break;
			}

		++ii;
		startPos += (separatorPos + 1);
		} while( separatorPos != KErrNotFound );
	}