Exemplo n.º 1
0
      //! Initialize the binding
      OutputBindingCreator()
      {
        typename OutputBindingMap<Archive>::Serializers serializers;

        serializers.shared_ptr =
          [&](void * arptr, void const * dptr)
          {
            Archive & ar = *static_cast<Archive*>(arptr);

            writeMetadata(ar);

            std::shared_ptr<T const> const ptr(static_cast<T const *>(dptr), EmptyDeleter<T const>());

            ar( _CEREAL_NVP("ptr_wrapper", memory_detail::make_ptr_wrapper(ptr)) );
          };

        serializers.unique_ptr =
          [&](void * arptr, void const * dptr)
          {
            Archive & ar = *static_cast<Archive*>(arptr);

            writeMetadata(ar);

            std::unique_ptr<T const, EmptyDeleter<T const>> const ptr(static_cast<T const *>(dptr));

            ar( _CEREAL_NVP("ptr_wrapper", memory_detail::make_ptr_wrapper(ptr)) );
          };

        StaticObject<OutputBindingMap<Archive>>::getInstance().map.insert( {std::type_index(typeid(T)), serializers} );
      }
Exemplo n.º 2
0
bool SaverXml::enter(document::Document& document)
{
    QString format = formats().format("mela")->setting<QString>("image_format", &document);
    image_format = mimeType(format, "image/png");

    writer.writeStartElement("document");
    writeId(document);
    writer.writeAttribute("width", QString::number(document.imageSize().width()));
    writer.writeAttribute("height", QString::number(document.imageSize().height()));
    writeMetadata(document.metadata());
    const auto& settings = document.formatSettings().settings();
    if ( !settings.empty() )
    {
        writer.writeStartElement("formats");
        for ( auto i = settings.begin(); i != settings.end(); ++i )
        {
            QString element = i.key() ? i.key()->id() : "default";
            writer.writeStartElement(element);
            for ( auto j = i->begin(); j != i->end(); ++j )
                writer.writeTextElement(j.key(), j.value().toString());
            writer.writeEndElement();
        }
        writer.writeEndElement();
    }
    return true;
}
Exemplo n.º 3
0
void SaverXml::visit(document::Frame& frame)
{
    writer.writeStartElement("frame");
    writeId(frame);
    writeMetadata(frame.metadata());
    writer.writeEndElement();
}
Exemplo n.º 4
0
void FileActionMngrDatabaseWorker::applyMetadata(FileActionItemInfoList infos, DisjointMetadata *hub)
{
    {
        CoreDbOperationGroup group;
        group.setMaximumTime(200);

        foreach (const ItemInfo& info, infos)
        {
            if (state() == WorkerObject::Deactivating)
            {
                break;
            }

            // apply to database
            hub->write(info);
            infos.dbProcessedOne();
            group.allowLift();
        }
    }

    if (hub->willWriteMetadata(DisjointMetadata::FullWriteIfChanged), Qt::DirectConnection)
    {
        int flags = hub->changedFlags();
        // don't filter by shallSendForWriting here; we write from the hub, not from freshly loaded data
        infos.schedulingForWrite(infos.size(), i18n("Writing metadata to files"), d->fileProgressCreator());

        for (ItemInfoTaskSplitter splitter(infos) ; splitter.hasNext() ; )
        {
            emit writeMetadata(FileActionItemInfoList(splitter.next()), flags);
        }
    }

    delete hub;
    infos.dbFinished();
}
Exemplo n.º 5
0
void SaverXml::visit(document::Image& image)
{
    writer.writeStartElement("image");
    writeId(image);

    if ( image.frame() )
        writeId(*image.frame(), "frame");

    if ( !image.metadata().empty() )
    {
        writeMetadata(image.metadata());
        writer.writeStartElement("bitmap");
    }

    writer.writeAttribute("type", image_format.name());
    QByteArray image_data;
    QBuffer buffer(&image_data);
    QImageWriter image_writer(&buffer, image_format.preferredSuffix().toLatin1());
    image_writer.write(image.image());
    writer.writeCharacters(image_data.toBase64());

    if ( !image.metadata().empty() )
    {
        writer.writeEndElement();
    }

    writer.writeEndElement();
}
Exemplo n.º 6
0
void KeePass2XmlWriter::writeDatabase(QIODevice* device, Database* db, KeePass2RandomStream* randomStream,
                                      const QByteArray& headerHash)
{
    m_db = db;
    m_meta = db->metadata();
    m_randomStream = randomStream;
    m_headerHash = headerHash;

    generateIdMap();

    m_xml.setDevice(device);

    m_xml.writeStartDocument("1.0", true);

    m_xml.writeStartElement("KeePassFile");

    writeMetadata();
    writeRoot();

    m_xml.writeEndElement();

    m_xml.writeEndDocument();

#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
    if (m_xml.hasError()) {
        raiseError(device->errorString());
    }
#endif
}
Exemplo n.º 7
0
void CPHDWriter::writeMetadata(const std::string& pathname,
                               const VBM& vbm)
{
    // Update the number of bytes per VBP
    mMetadata.data.numBytesVBP = vbm.getNumBytesVBP();

    mFile.create(pathname);

    const size_t numChannels = vbm.getNumChannels();
    size_t totalVBMSize = 0;
    size_t totalCPHDSize = 0;

    for (size_t ii = 0; ii < numChannels; ++ii)
    {
        totalVBMSize += vbm.getVBMsize(ii);
        totalCPHDSize += mMetadata.data.getNumVectors(ii) *
                mMetadata.data.getNumSamples(ii) * mElementSize;
    }

    writeMetadata(totalVBMSize, totalCPHDSize);

    std::vector<sys::ubyte> vbmData;
    for (size_t ii = 0; ii < numChannels; ++ii)
    {
        vbm.getVBMdata(ii, vbmData);
        if (!vbmData.empty())
        {
            writeVBMData(&vbmData[0], ii);
        }
    }
}
Exemplo n.º 8
0
void KdbxXmlWriter::writeDatabase(QIODevice* device,
                                  const Database* db,
                                  KeePass2RandomStream* randomStream,
                                  const QByteArray& headerHash)
{
    m_db = db;
    m_meta = db->metadata();
    m_randomStream = randomStream;
    m_headerHash = headerHash;

    m_xml.setAutoFormatting(true);
    m_xml.setAutoFormattingIndent(-1); // 1 tab
    m_xml.setCodec("UTF-8");

    generateIdMap();

    m_xml.setDevice(device);
    m_xml.writeStartDocument("1.0", true);
    m_xml.writeStartElement("KeePassFile");

    writeMetadata();
    writeRoot();

    m_xml.writeEndElement();
    m_xml.writeEndDocument();

    if (m_xml.hasError()) {
        raiseError(device->errorString());
    }
}
Exemplo n.º 9
0
void FileActionMngrDatabaseWorker::changeTags(FileActionItemInfoList infos,
                                              const QList<int>& tagIDs, bool addOrRemove)
{
    DisjointMetadata hub;
    QList<ItemInfo> forWriting;

    {
        CoreDbOperationGroup group;
        group.setMaximumTime(200);

        foreach (const ItemInfo& info, infos)
        {
            if (state() == WorkerObject::Deactivating)
            {
                break;
            }

            hub.load(info);

            for (QList<int>::const_iterator tagIt = tagIDs.constBegin(); tagIt != tagIDs.constEnd(); ++tagIt)
            {
                if (addOrRemove)
                {
                    hub.setTag(*tagIt, DisjointMetadata::MetadataAvailable);
                }
                else
                {
                    hub.setTag(*tagIt, DisjointMetadata::MetadataInvalid);
                }
            }

            hub.write(info, DisjointMetadata::PartialWrite);

            if (hub.willWriteMetadata(DisjointMetadata::FullWriteIfChanged) && d->shallSendForWriting(info.id()))
            {
                forWriting << info;
            }

            infos.dbProcessedOne();
            group.allowLift();
        }
    }

    // send for writing file metadata
    if (!forWriting.isEmpty())
    {
        FileActionItemInfoList forWritingTaskList = FileActionItemInfoList::continueTask(forWriting, infos.progress());
        forWritingTaskList.schedulingForWrite(i18n("Writing metadata to files"), d->fileProgressCreator());

        qCDebug(DIGIKAM_GENERAL_LOG) << "Scheduled to write";

        for (ItemInfoTaskSplitter splitter(forWritingTaskList) ; splitter.hasNext() ; )
        {
            emit writeMetadata(FileActionItemInfoList(splitter.next()), MetadataHub::WRITE_TAGS);
        }
    }

    infos.dbFinished();
}
Exemplo n.º 10
0
int PathPlanner::runRRT(){
	this->RRT();
	calcPathLength();
	writePath();
	writeMetadata();
	cout<<"Estimated path length: "<<this->pathLength<<"\n";
	return 0;
}
Exemplo n.º 11
0
bool SaverXml::enter(document::Animation& animation)
{
    writer.writeStartElement("animation");
    writeId(animation);
    writer.writeAttribute("name",animation.name());
    writer.writeAttribute("fps",QString::number(animation.framesPerSecond()));
    writeMetadata(animation.metadata());
    return true;
}
Exemplo n.º 12
0
int PathPlanner::runSquareSpiral(){
	Points spiralpath = this->getSpiralPath();	
	this->setPath(spiralpath);
	calcPathLength();
	writePath();
	writeMetadata();
	cout<<"Estimated path length: "<<this->pathLength<<"\n";
	return 0;
}
Exemplo n.º 13
0
//In a perfect world these would have some kind of error checking. I like to live dangerously....
int PathPlanner::runTrace(){
	vector<Polygon_2> all = this->linearShrink();
	this->setPath(all);
	calcPathLength();
	writePath();
	writeMetadata();
	cout<<"Estimated path length: "<<this->pathLength<<"\n";
	return 0;
}
Exemplo n.º 14
0
void
MetadataEditor::loadPreviousQuery()
{
    writeMetadata();

    if ( m_interface->siblingIndex( -1, m_index ) > 0 )
    {
        m_index = m_interface->siblingIndex( -1, m_index );
        loadQuery( m_interface->queryAt( m_index ) );
    }
}
Exemplo n.º 15
0
      //! Initialize the binding
      OutputBindingCreator()
      {
        auto & map = StaticObject<OutputBindingMap<Archive>>::getInstance().map;
        auto key = std::type_index(typeid(T));
        auto lb = map.lower_bound(key);

        if (lb != map.end() && lb->first == key)
          return;

        typename OutputBindingMap<Archive>::Serializers serializers;

        serializers.shared_ptr =
          [&](void * arptr, void const * dptr)
          {
            Archive & ar = *static_cast<Archive*>(arptr);

            writeMetadata(ar);

            #ifdef _MSC_VER
            savePolymorphicSharedPtr( ar, dptr, ::cereal::traits::has_shared_from_this<T>::type() ); // MSVC doesn't like typename here
            #else // not _MSC_VER
            savePolymorphicSharedPtr( ar, dptr, typename ::cereal::traits::has_shared_from_this<T>::type() );
            #endif // _MSC_VER
          };

        serializers.unique_ptr =
          [&](void * arptr, void const * dptr)
          {
            Archive & ar = *static_cast<Archive*>(arptr);

            writeMetadata(ar);

            std::unique_ptr<T const, EmptyDeleter<T const>> const ptr(static_cast<T const *>(dptr));

            ar( CEREAL_NVP_("ptr_wrapper", memory_detail::make_ptr_wrapper(ptr)) );
          };

        map.insert( { std::move(key), std::move(serializers) } );
      }
Exemplo n.º 16
0
bool SaverXml::enter(document::Layer& layer)
{
    writer.writeStartElement("layer");
    writeId(layer);
    writer.writeAttribute("name", layer.name());
    writer.writeAttribute("opacity", QString::number(layer.opacity()));
    writer.writeAttribute("visible", QString::number(layer.visible()));
    writer.writeAttribute("locked", QString::number(layer.locked()));
    writer.writeAttribute("blend", misc::composition_to_string(layer.blendMode()));
    writer.writeAttribute("background", color_widgets::stringFromColor(layer.backgroundColor().alpha()));
    writeMetadata(layer.metadata());
    return true;
}
Exemplo n.º 17
0
void encodeJpegIntoOutputStream(
    JNIEnv* env,
    DecodedImage& decoded_image,
    jobject os,
    int quality) {
  // jpeg does not support alpha channel
  THROW_AND_RETURN_IF(
      decoded_image.getPixelFormat() != PixelFormat::RGB,
      "Wrong pixel format for jpeg encoding");

  struct jpeg_compress_struct cinfo;

  // set up error handling
  JpegErrorHandler error_handler{env};
  error_handler.setCompressStruct(cinfo);
  if (setjmp(error_handler.setjmpBuffer)) {
    return;
  }

  // set up OutputStream as jpeg codec destination
  jpeg_create_compress(&cinfo);
  JpegOutputStreamWrapper os_wrapper{env, os};
  cinfo.dest = &(os_wrapper.public_fields);

  // set up image properties
  cinfo.image_width = decoded_image.getWidth();
  cinfo.image_height = decoded_image.getHeight();
  cinfo.input_components = 3;
  cinfo.in_color_space = JCS_RGB;

  jpeg_set_defaults(&cinfo);
  jpeg_set_quality(&cinfo, quality, TRUE);
  jpeg_start_compress(&cinfo, TRUE);

  writeMetadata(cinfo, decoded_image);

  // write all pixels, row by row
  JSAMPROW row_pointer = decoded_image.getPixelsPtr();
  const int stride = decoded_image.getStride();
  while (cinfo.next_scanline < cinfo.image_height) {
    if (jpeg_write_scanlines(&cinfo, &row_pointer, 1) != 1) {
      jpegSafeThrow(
          (j_common_ptr) &cinfo,
          "Could not write scanline");
    }
    std::advance(row_pointer, stride);
  }

  jpeg_finish_compress(&cinfo);
  jpeg_destroy_compress(&cinfo);
}
Exemplo n.º 18
0
void Pipeline::startRecording()
{
    currentFile = nextFileName();
    emit savedFileNameChanged(currentFile);

    // set next file name
    g_object_set(camerabin,
                 "filename",
                 currentFile.toUtf8().constData(),
                 NULL);

    // write video metadata
    writeMetadata();

    g_signal_emit_by_name(camerabin, "capture-start", 0);
}
Exemplo n.º 19
0
void FileActionMngrDatabaseWorker::assignRating(FileActionItemInfoList infos, int rating)
{
    DisjointMetadata hub;
    QList<ItemInfo> forWriting;
    rating = qMin(RatingMax, qMax(RatingMin, rating));

    {
        CoreDbOperationGroup group;
        group.setMaximumTime(200);

        foreach (const ItemInfo& info, infos)
        {
            if (state() == WorkerObject::Deactivating)
            {
                break;
            }

            hub.load(info);
            hub.setRating(rating);
            hub.write(info, DisjointMetadata::PartialWrite);

            if (hub.willWriteMetadata(DisjointMetadata::FullWriteIfChanged) && d->shallSendForWriting(info.id()))
            {
                forWriting << info;
            }

            infos.dbProcessedOne();
            group.allowLift();
        }
    }

    // send for writing file metadata
    if (!forWriting.isEmpty())
    {
        FileActionItemInfoList forWritingTaskList = FileActionItemInfoList::continueTask(forWriting, infos.progress());
        forWritingTaskList.schedulingForWrite(i18n("Writing metadata to files"), d->fileProgressCreator());

        for (ItemInfoTaskSplitter splitter(forWritingTaskList) ; splitter.hasNext() ; )
        {
            emit writeMetadata(FileActionItemInfoList(splitter.next()), MetadataHub::WRITE_RATING);
        }
    }

    infos.dbFinished();
}
Exemplo n.º 20
0
void Pipeline::captureImage()
{
    if(currentMode == MODE_VIDEO)
        setCameraMode();

    currentFile = nextFileName();
    emit savedFileNameChanged(currentFile);

    // set next file name
    g_object_set(camerabin,
                 "filename",
                 currentFile.toUtf8().constData(),
                 NULL);

    // write image metadata
    writeMetadata();

    g_signal_emit_by_name(camerabin, "capture-start", 0);
}
Exemplo n.º 21
0
void FileRecorder::stop(const MetadataChunk *meta) {
	uint32_t size = ftell(_file);

	padbyte(_file);

	if(meta != NULL)
		writeMetadata(meta);

	fseek(_file, 40, SEEK_SET);
	put32(size-44, _file); // data chunk size
	fseek(_file, 0, SEEK_END);
	size = ftell(_file);

	fseek(_file, 4, SEEK_SET);
	put32(size-8, _file); // RIFF chunk size

	fclose(_file);
	_file = NULL;
}
Exemplo n.º 22
0
void CPHDWriter::write(const std::string& pathname)
{
    mFile.create(pathname);

    writeMetadata(mVBMSize, mCPHDSize);

    for (size_t ii = 0; ii < mVBMData.size(); ++ii)
    {
        writeVBMData(mVBMData[ii], ii);
    }

    for (size_t ii = 0; ii < mCPHDData.size(); ++ii)
    {
        const size_t cphdDataSize = mMetadata.data.arraySize[ii].numVectors *
                mMetadata.data.arraySize[ii].numSamples;
        writeCPHDDataImpl(mCPHDData[ii], cphdDataSize);
    }

    mFile.close();
}
void KeePass2XmlWriter::writeDatabase(QIODevice* device, Database* db, KeePass2RandomStream* randomStream,
                                      const QByteArray& headerHash)
{
    m_db = db;
    m_meta = db->metadata();
    m_randomStream = randomStream;
    m_headerHash = headerHash;

    generateIdMap();

    m_xml.setDevice(device);

    m_xml.writeStartDocument("1.0", true);

    m_xml.writeStartElement("KeePassFile");

    writeMetadata();
    writeRoot();

    m_xml.writeEndElement();

    m_xml.writeEndDocument();
}
void GeoPackageWriter::writeTileTable(const GpkgMatrixSet& data)
{
    if (!m_sqlite)
    {
        throw pdal_error("RialtoDB: invalid state (session does exist)");
    }

    log()->get(LogLevel::Debug) << "RialtoDb::addTileTable()" << std::endl;

    e_tileTablesWritten.start();

    assert(!m_sqlite->doesTableExist(data.getName()));
    createTableGpkgPctile(data.getName());
    assert(m_sqlite->doesTableExist(data.getName()));

    const uint32_t srs_id = querySrsId(data.getWkt());

    {
        // note min_x, etc, is the bbox of the DATA and not the tile matrix set
        const std::string sql =
            "INSERT INTO gpkg_contents"
            " (table_name, data_type, identifier, description, last_change, srs_id,"
            " min_x, min_y, max_x, max_y)"
            " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

        records rs;
        row r;

        r.push_back(column(data.getName())); // table_name
        r.push_back(column("pctiles")); // data_type
        r.push_back(column(data.getName())); // identifier
        r.push_back(column(data.getDescription())); // description
        r.push_back(column(data.getDateTime())); // last_change
        r.push_back(column(srs_id));
        r.push_back(column(data.getDataMinX()));
        r.push_back(column(data.getDataMinY()));
        r.push_back(column(data.getDataMaxX()));
        r.push_back(column(data.getDataMaxY()));

        rs.push_back(r);

        m_sqlite->insert(sql, rs);
    }

    {
        // min_x, etc, is bbox of tile matrix (not data)
        const std::string sql =
            "INSERT INTO gpkg_pctile_matrix_set"
            " (table_name, srs_id,"
            " min_x, min_y, max_x, max_y)"
            " VALUES (?, ?, ?, ?, ?, ?)";

        records rs;
        row r;

        r.push_back(column(data.getName())); // table_name
        r.push_back(column(srs_id));
        r.push_back(column(data.getTmsetMinX()));
        r.push_back(column(data.getTmsetMinY()));
        r.push_back(column(data.getTmsetMaxX()));
        r.push_back(column(data.getTmsetMaxY()));

        rs.push_back(r);

        m_sqlite->insert(sql, rs);
    }

    {
        const TileMath tmm(data.getTmsetMinX(), data.getTmsetMinY(),
            data.getTmsetMaxX(), data.getTmsetMaxY(),
            data.getNumColsAtL0(), data.getNumRowsAtL0());

        for (uint32_t level=0; level<=data.getMaxLevel(); ++level)
        {
            const std::string sql =
                "INSERT INTO gpkg_pctile_matrix"
                " (table_name, zoom_level, matrix_width, matrix_height)"
                " VALUES (?, ?, ?, ?)";

            records rs;
            row r;

            uint32_t numCols, numRows;
            numCols = tmm.numColsAtLevel(level);
            numRows = tmm.numRowsAtLevel(level);

            r.push_back(column(data.getName()));
            r.push_back(column(level));
            r.push_back(column(numCols));
            r.push_back(column(numRows));
            rs.push_back(r);

            m_sqlite->insert(sql, rs);
        }
    }

    writeDimensions(data);

    writeMetadata(data);

    e_tileTablesWritten.stop();
}