/** There are two possibilities how to use this class: 1. static call to QgsVectorFileWriter::writeAsShapefile(...) which saves the whole vector layer 2. create an instance of the class and issue calls to addFeature(...) Currently supports only writing to shapefiles, but shouldn't be a problem to add capability to support other OGR-writable formats. */ class QgsVectorFileWriter { %TypeHeaderCode #include #include %End public: enum WriterError { NoError = 0, ErrDriverNotFound, ErrCreateDataSource, ErrCreateLayer }; /** Write contents of vector layer to a shapefile */ static WriterError writeAsShapefile(QgsVectorLayer* layer, const QString& shapefileName, const QString& fileEncoding, bool onlySelected = FALSE); /** create shapefile and initialize it */ QgsVectorFileWriter(const QString& shapefileName, const QString& fileEncoding, const QMap& fields, QGis::WKBTYPE geometryType, const QgsSpatialRefSys* srs); /** checks whether there were any errors in constructor */ WriterError hasError(); /** add feature to the currently opened shapefile */ bool addFeature(QgsFeature& feature); /** close opened shapefile for writing */ ~QgsVectorFileWriter(); };