bool KmlPolygonTagWriter::write( const GeoNode *node, GeoWriter& writer ) const { const GeoDataPolygon *polygon = static_cast<const GeoDataPolygon*>( node ); writer.writeStartElement( kml::kmlTag_Polygon ); writer.writeStartElement( "outerBoundaryIs" ); writeElement( &polygon->outerBoundary(), writer ); writer.writeEndElement(); const QVector<GeoDataLinearRing>& linearRings = polygon->innerBoundaries(); if (linearRings.size() > 0) { writer.writeStartElement( "innerBoundaryIs" ); for ( int i = 0; i < linearRings.size(); ++i ) { const GeoDataLinearRing& ring = linearRings[i]; writeElement( &ring, writer ); } writer.writeEndElement(); } writer.writeEndElement(); return true; }
void CollectionScanner::scanFiles( const QStringList& entries ) { DEBUG_BLOCK typedef QPair<QString, QString> CoverBundle; QStringList validImages; validImages << "jpg" << "png" << "gif" << "jpeg"; QStringList validPlaylists; validPlaylists << "m3u" << "pls"; QValueList<CoverBundle> covers; QStringList images; foreachType( QStringList, entries ) { const QString path = *it; const QString ext = extension( path ); const QString dir = directory( path ); // Write path to logfile if( !m_logfile.isEmpty() ) { QFile log( m_logfile ); if( log.open( IO_WriteOnly ) ) log.writeBlock( path.local8Bit(), path.length() ); } if( validImages.contains( ext ) ) images += path; else if( m_importPlaylists && validPlaylists.contains( ext ) ) { AttributeMap attributes; attributes["path"] = path; writeElement( "playlist", attributes ); } else { MetaBundle::EmbeddedImageList images; MetaBundle mb( KURL::fromPathOrURL( path ), true, TagLib::AudioProperties::Fast, &images ); const AttributeMap attributes = readTags( mb ); if( !attributes.empty() ) { writeElement( "tags", attributes ); CoverBundle cover( attributes["artist"], attributes["album"] ); if( !covers.contains( cover ) ) covers += cover; foreachType( MetaBundle::EmbeddedImageList, images ) { AttributeMap attributes; attributes["path"] = path; attributes["hash"] = (*it).hash(); attributes["description"] = (*it).description(); writeElement( "embed", attributes ); } } }
void daeLIBXMLPlugin::writeElement( daeElement* element ) { daeIntegrationObject* _intObject = element->getIntObject(); daeMetaElement* _meta = element->getMeta(); if(_intObject) { // added in response to bug 478 _intObject->toCOLLADAChecked(); _intObject->toCOLLADAPostProcessChecked(); } if (!_meta->getIsTransparent() ) { if ( element->getElementName() ) { xmlTextWriterStartElement(writer, (xmlChar*)element->getElementName()); } else { xmlTextWriterStartElement(writer, (xmlChar*)(daeString)_meta->getName()); } daeMetaAttributeRefArray& attrs = _meta->getMetaAttributes(); int acnt = (int)attrs.getCount(); for(int i=0;i<acnt;i++) { writeAttribute( attrs[i], element); } } daeMetaAttribute* valueAttr = _meta->getValueAttribute(); if (valueAttr!=NULL) writeAttribute(valueAttr, element); if (_meta->getContents() != NULL) { daeElementRefArray* era = (daeElementRefArray*)_meta->getContents()->getWritableMemory(element); int elemCnt = (int)era->getCount(); for(int i = 0; i < elemCnt; i++) { daeElementRef elem = (daeElementRef)era->get(i); if (elem != NULL) { writeElement( elem ); } } } else { daeMetaElementAttributeArray& children = _meta->getMetaElements(); int cnt = (int)children.getCount(); for(int i=0;i<cnt;i++) { daeMetaElement *type = children[i]->getElementType(); if ( !type->getIsAbstract() ) { for (int c = 0; c < children[i]->getCount(element); c++ ) { writeElement( *(daeElementRef*)children[i]->get(element,c) ); } } } } if (!_meta->getIsTransparent() ) { xmlTextWriterEndElement(writer); } }
static void writeNode(Serialization *serialization, DFNode *node, int depth) { switch (node->tag) { case DOM_DOCUMENT: { if (!serialization->html) xmlTextWriterStartDocument(serialization->writer,"1.0","UTF-8","yes"); if (serialization->html) xmlTextWriterWriteDTD(serialization->writer,(xmlChar *)"html",NULL,NULL,NULL); // xmlTextWriterWriteDTD(writer, // (xmlChar *)"html", // (xmlChar *)"-//W3C//DTD XHTML 1.0 Strict//EN", // (xmlChar *)"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", // NULL); for (DFNode *child = node->first; child != NULL; child = child->next) writeNode(serialization,child,0); xmlTextWriterEndDocument(serialization->writer); break; } case DOM_TEXT: { if (serialization->indent && ((node->prev != NULL) || (node->next != NULL))) xmlTextWriterWriteRawLen(serialization->writer,INDENT,1+depth); if (serialization->html && (node->parent != NULL) && (node->parent->tag == HTML_STYLE)) { xmlTextWriterWriteRaw(serialization->writer,(const xmlChar *)node->value); } else { xmlTextWriterWriteString(serialization->writer,(const xmlChar *)node->value); } break; } case DOM_COMMENT: { xmlTextWriterWriteComment(serialization->writer,(const xmlChar *)node->value); break; } case DOM_CDATA: { xmlTextWriterWriteCDATA(serialization->writer,(const xmlChar *)node->value); break; } case DOM_PROCESSING_INSTRUCTION: { xmlTextWriterWritePI(serialization->writer, (const xmlChar *)node->target, (const xmlChar *)node->value); break; } default: { if (node->parent == serialization->doc->docNode) writeElement(serialization,node,0); else writeElement(serialization,node,depth); break; } } }
void Writer::writeContainer(const NodeContainer& container) { XML::NodeContainer::const_iterator it = container.beginChild(); XML::NodeContainer::const_iterator end = container.endChild(); for (; it != end; ++it) { if ((*it)->type() == ELEMENT_NODE) { XML::ElementNodePtr child = Core::dynamic_ptr_cast<XML::ElementNode>(*it); writeElement(child); } else if ((*it)->type() == TEXT_NODE) { XML::TextNodePtr child = Core::dynamic_ptr_cast<XML::TextNode>(*it); m_buffer += child->text(); } else { ASSERT_FALSE(); } } }
bool GeoWriter::write(QIODevice* device, const GeoNode *feature) { setDevice( device ); setAutoFormatting( true ); writeStartDocument(); //FIXME: write the starting tags. Possibly register a tag handler to do this // with a null string as the object name? GeoTagWriter::QualifiedName name( "", m_documentType ); const GeoTagWriter* writer = GeoTagWriter::recognizes(name); if( writer ) { //FIXME is this too much of a hack? //geodataobject is never used in this context GeoNode node; writer->write( &node, *this ); } else { mDebug() << "There is no GeoWriter registered for: " << name; return false; } if( ! writeElement( feature ) ) { return false; } //close the document writeEndElement(); return true; }
/* post : Adds information from StudentPtr to FileName in a sorted way, * if FileName does not exist, a new file is created. * returns: -1 in case of an error * 0 if a student with the given student number already exists * 1 if the student is added to the file */ extern int addStudentSortedToFile (char* FileName, STUDENT* StudentPtr) { if(StudentPtr) { FILE *ptr_file = fopen(*FileName, "r+b"); if(ptr_file) { fseek(ptr_file, 0, SEEK_END); int numberOfStudentsInFile = ftell(ptr_file) / sizeof(STUDENT); fseek(ptr_file, 0, SEEK_SET); STUDENT tempStudent; tempStudent.StudentNumber = -1; int studentAdded = 0; int i = 0; for (; i < numberOfStudentsInFile; i++) { STUDENT foundStudent; STUDENT studentPtr = *StudentPtr; //get student number of pointer student? readElement(ptr_file, i, &foundStudent); if(tempStudent.StudentNumber != -1) { writeElement(ptr_file, i, &tempStudent); tempStudent = foundStudent; } else { if(studentPtr.StudentNumber == foundStudent.StudentNumber) { return 0; } else if(studentPtr.StudentNumber < foundStudent.StudentNumber) { readElement(ptr_file, i, &tempStudent); writeElement(ptr_file, i, &StudentPtr); numberOfStudentsInFile++; studentAdded = 1; } } } if (studentAdded) { return 1; } } } return -1; }
bool KmlPhotoOverlayWriter::writeMid( const GeoNode *node, GeoWriter &writer ) const { const GeoDataPhotoOverlay *photo_overlay = static_cast<const GeoDataPhotoOverlay*>( node ); writeElement( &photo_overlay->point(), writer ); return true; }
void OgrWriter::writeElement(ElementInputStream& inputStream, bool debug) { // Make sure incoming element is in WGS84 assert( inputStream.getProjection()->IsSame(&_wgs84) == true ); ElementPtr nextElement = inputStream.readNextElement(); writeElement(nextElement, debug); }
void CollectionScanner::doJob() //SLOT { std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; std::cout << "<scanner>"; QStringList entries; if( m_restart ) { QFile logFile( m_logfile ); logFile.open( IO_ReadOnly ); QString lastFile = logFile.readAll(); QFile folderFile( amaroK::saveLocation( QString::null ) + "collection_scan.files" ); folderFile.open( IO_ReadOnly ); entries = QStringList::split( "\n", folderFile.readAll() ); for( int count = entries.findIndex( lastFile ) + 1; count; --count ) entries.pop_front(); // debug() << "Restarting at: " << entries.front() << endl; } else { foreachType( QStringList, m_folders ) { if( (*it).isEmpty() ) //apparently somewhere empty strings get into the mix //which results in a full-system scan! Which we can't allow continue; QString dir = *it; if( !dir.endsWith( "/" ) ) dir += '/'; readDir( dir, entries ); } QFile folderFile( amaroK::saveLocation( QString::null ) + "collection_scan.files" ); folderFile.open( IO_WriteOnly ); QTextStream stream( &folderFile ); stream << entries.join( "\n" ); folderFile.close(); } if( !entries.isEmpty() ) { if( !m_restart ) { AttributeMap attributes; attributes["count"] = QString::number( entries.count() ); writeElement( "itemcount", attributes ); } scanFiles( entries ); } std::cout << "</scanner>" << std::endl; quit(); }
std::string CChemEqInterface::getChemEqString(bool expanded) const { std::string ChemicalEquation; size_t j; if ((mSubstrateNames.size() == 0) && (mProductNames.size() == 0) && (mModifierNames.size() == 0)) return ""; for (j = 0; j < mSubstrateNames.size(); j++) { if (j) ChemicalEquation += " + "; ChemicalEquation += writeElement(mSubstrateDisplayNames[j], mSubstrateMult[j], expanded); } if (mReversibility) ChemicalEquation += " = "; else ChemicalEquation += " -> "; for (j = 0; j < mProductNames.size(); j++) { if (j) ChemicalEquation += " + "; ChemicalEquation += writeElement(mProductDisplayNames[j], mProductMult[j], expanded); } if (mModifierNames.size()) { ChemicalEquation += "; "; for (j = 0; j < mModifierNames.size(); j++) { ChemicalEquation += " "; ChemicalEquation += mModifierDisplayNames[j]; } } return ChemicalEquation; }
double& SubMatrixWriteAccess::writeElement(const unsigned int index) { if (index >= (getRows()*getColumns())) { error("Matrix::element : Subscript out of range\n"); return getDataPointer()[0]; } return writeElement(index / getColumns(), index % getColumns()); }
bool KmlPhotoOverlayWriter::writeMid( const GeoNode *node, GeoWriter &writer ) const { KmlOverlayTagWriter::writeMid( node, writer ); const GeoDataPhotoOverlay *photo_overlay = static_cast<const GeoDataPhotoOverlay*>( node ); // rotation QString const rotation = QString::number( photo_overlay->rotation(), 'f', 3 ); writer.writeOptionalElement( kml::kmlTag_rotation, rotation, "0.000" ); // ViewVolume writer.writeStartElement( kml::kmlTag_ViewVolume ); writer.writeOptionalElement<qreal>( kml::kmlTag_leftFov, photo_overlay->viewVolume().leftFov(), 0 ); writer.writeOptionalElement<qreal>( kml::kmlTag_rightFov, photo_overlay->viewVolume().rightFov(), 0 ); writer.writeOptionalElement<qreal>( kml::kmlTag_bottomFov, photo_overlay->viewVolume().bottomFov(), 0 ); writer.writeOptionalElement<qreal>( kml::kmlTag_topFov, photo_overlay->viewVolume().topFov(), 0 ); writer.writeOptionalElement<qreal>( kml::kmlTag_near, photo_overlay->viewVolume().near(), 0 ); writer.writeEndElement(); // ImagePyramid writer.writeStartElement( kml::kmlTag_ImagePyramid ); writer.writeOptionalElement<int>( kml::kmlTag_tileSize, photo_overlay->imagePyramid().tileSize(), 256 ); writer.writeOptionalElement<int>( kml::kmlTag_maxWidth, photo_overlay->imagePyramid().maxWidth() ); writer.writeOptionalElement<int>( kml::kmlTag_maxHeight, photo_overlay->imagePyramid().maxHeight() ); switch ( photo_overlay->imagePyramid().gridOrigin() ) { case GeoDataImagePyramid::LowerLeft: writer.writeElement( kml::kmlTag_gridOrigin, "lowerLeft" ); break; case GeoDataImagePyramid::UpperLeft: writer.writeElement( kml::kmlTag_gridOrigin, "upperLeft" ); break; } writer.writeEndElement(); // Point writeElement( &photo_overlay->point(), writer ); // shape switch ( photo_overlay->shape() ) { case GeoDataPhotoOverlay::Rectangle: break; case GeoDataPhotoOverlay::Cylinder: writer.writeElement( kml::kmlTag_shape, "cylinder" ); break; case GeoDataPhotoOverlay::Sphere: writer.writeElement( kml::kmlTag_shape, "sphere" ); break; } return true; }
void CollectionScanner::readDir( const QString& dir, QStringList& entries ) { // linux specific, but this fits the 90% rule if( dir.startsWith( "/dev" ) || dir.startsWith( "/sys" ) || dir.startsWith( "/proc" ) ) return; QDir d( dir ); m_scannedFolders << d.canonicalPath(); if( !d.exists() ) return; AttributeHash attributes; if( m_batch && !m_rpath.isEmpty() ) { QString rdir = dir; rdir.remove( QDir::cleanPath( QDir::currentPath() ) ); rdir.prepend( QDir::cleanPath( m_rpath + '/' ) ); attributes["path"] = rdir; } else attributes["path"] = dir; writeElement( "folder", attributes ); d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Readable ); QFileInfoList list = d.entryInfoList(); foreach( QFileInfo f, list ) { if( !f.exists() ) break; if( f.isSymLink() ) f = QFileInfo( f.symLinkTarget() ); if( f.isDir() && m_recursively && !m_scannedFolders.contains( f.canonicalFilePath() ) ) { //The following D-Bus call is used to see if a found folder is new or not //During an incremental scan the scanning isn't really recursive, as all folders //are stored in the database (even folders implicitly selected by top-level directories) //if recursive scanning is selected. So we don't scan recursively because if any of those //folders have updates ScanManager has already figured it out. Hence why we only scan //if isDirInCollection is false: it means the directory is new and we don't know about it bool isInCollection = false; if( m_incremental && m_amarokCollectionInterface ) { QDBusReply<bool> reply = m_amarokCollectionInterface->call( "isDirInCollection", f.canonicalFilePath() ); if( reply.isValid() ) isInCollection = reply.value(); } if( !m_incremental || !isInCollection ) readDir( f.absoluteFilePath() + '/', entries ); } else if( f.isFile() ) entries.append( f.absoluteFilePath() ); } }
/* post : Removes student with StudentNumber from file * returns: 0 if StudentNumber was removed from file * -1 if StudentNumber was not found or an error occurs */ extern int removeStudentFromFile (char* FileName, int StudentNumber) { if(access(FileName, W_OK ) != -1 && StudentNumber) { FILE *ptr_file = fopen(*FileName, "r+b"); if(ptr_file) { fseek(ptr_file, 0, SEEK_END); int numberOfStudentsInFile = ftell(ptr_file) / sizeof(STUDENT); fseek(ptr_file, 0, SEEK_SET); STUDENT tempStudent; tempStudent.StudentNumber = -1; int studentRemoved = 0; int i = 0; for (; i < numberOfStudentsInFile; i++) { STUDENT foundStudent; readElement(ptr_file, i, &foundStudent); if(tempStudent.StudentNumber != -1) { readElement(ptr_file, i + 1, &tempStudent); writeElement(ptr_file, i, &tempStudent); } else { if(StudentNumber == foundStudent.StudentNumber) { readElement(ptr_file, i + 1, &tempStudent); writeElement(ptr_file, i, &tempStudent); numberOfStudentsInFile--; studentRemoved = 1; } } } if (studentRemoved) { return 0; } } } return -1; }
// Must define void operator() with no arguments void IXMLWriterTest::operator()() { writeXMLHeader(); writeElement(); writeComment(); writeClosingTag(); writeText(); writeLineBreak(); ASSERTM(mes.c_str(), mes.size() == 0); }
bool KmlFlyToTagWriter::write( const GeoNode *node, GeoWriter& writer ) const { const GeoDataFlyTo *flyTo = static_cast<const GeoDataFlyTo*>( node ); writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_FlyTo ); writer.writeElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_duration, QString::number( flyTo->duration()) ); QString const flyToModeString = flyTo->flyToMode() == GeoDataFlyTo::Smooth ? "smooth" : "bounce"; writer.writeElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_flyToMode, flyToModeString ); writeElement( flyTo->view(), writer ); writer.writeEndElement(); return true; }
void SimpleXMLBuilder::write(std::ostream& os) const { if (parent != NULL) { parent->write(os); return; } os << "<?xml version=\"1.0\"?>" << std::endl; writeElement(os, 0); }
bool KmlGroundOverlayWriter::writeMid(const GeoNode *node, GeoWriter &writer) const { KmlOverlayTagWriter::writeMid( node, writer ); const GeoDataGroundOverlay *ground_overlay = static_cast<const GeoDataGroundOverlay*>( node ); writer.writeOptionalElement( kml::kmlTag_altitude, QString::number(ground_overlay->altitude()), "0" ); KmlGroundOverlayWriter::writeAltitudeMode( writer, ground_overlay->altitudeMode() ); if ( !ground_overlay->latLonBox().isEmpty() ) { writeElement( &ground_overlay->latLonBox(), writer ); } if ( ground_overlay->latLonQuad().isValid() ) { writeElement( &ground_overlay->latLonQuad(), writer ); } return true; }
bool KmlPlacemarkTagWriter::writeMid( const GeoNode *node, GeoWriter& writer ) const { const GeoDataPlacemark *placemark = static_cast<const GeoDataPlacemark*>(node); writer.writeOptionalElement( kml::kmlTag_styleUrl, placemark->styleUrl() ); if ( placemark->styleUrl().isEmpty() && placemark->customStyle() ) { writeElement( placemark->customStyle().data(), writer ); } if( placemark->geometry() ) { writeElement( placemark->geometry(), writer ); } if( placemark->isBalloonVisible() ){ QString string; string.setNum( 1 ); writer.writeElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_balloonVisibility, string ); } return true; }
bool DgmlDocumentTagWriter::write( const GeoNode *node, GeoWriter& writer ) const { const GeoSceneDocument *document = static_cast<const GeoSceneDocument*>( node ); writer.writeStartElement( dgml::dgmlTag_Document ); const GeoSceneHead *head = document->head(); writeElement( head, writer ); const GeoSceneMap *map = document->map() ; writeElement( map, writer ); const GeoSceneSettings *settings = document->settings(); writeElement( settings, writer ); const GeoSceneLegend *legend = document->legend(); writeElement( legend, writer ); writer.writeEndDocument(); return true; }
bool KmlUpdateTagWriter::write( const GeoNode *node, GeoWriter& writer ) const { const GeoDataUpdate *update = static_cast<const GeoDataUpdate*>( node ); KmlObjectTagWriter::writeIdentifiers( writer, update ); writer.writeStartElement( kml::kmlTag_Update ); writer.writeElement( kml::kmlTag_targetHref, update->targetHref() ); if( update->change() && update->change()->size() > 0 ) { writer.writeStartElement( kml::kmlTag_Change ); QVector<GeoDataFeature*>::ConstIterator it = update->change()->constBegin(); QVector<GeoDataFeature*>::ConstIterator const end = update->change()->constEnd(); for ( ; it != end; ++it ) { writeElement( *it, writer ); } writer.writeEndElement(); } else if( update->create() && update->create()->size() > 0 ) { writer.writeStartElement( kml::kmlTag_Create ); QVector<GeoDataFeature*>::ConstIterator it = update->create()->constBegin(); QVector<GeoDataFeature*>::ConstIterator const end = update->create()->constEnd(); for ( ; it != end; ++it ) { writeElement( *it, writer ); } writer.writeEndElement(); } else if( update->getDelete() && update->getDelete()->size() > 0 ) { writer.writeStartElement( kml::kmlTag_Delete ); QVector<GeoDataFeature*>::ConstIterator it = update->getDelete()->constBegin(); QVector<GeoDataFeature*>::ConstIterator const end = update->getDelete()->constEnd(); for ( ; it != end; ++it ) { writeElement( *it, writer ); } writer.writeEndElement(); } writer.writeEndElement(); return true; }
bool KmlPlacemarkTagWriter::write( const GeoNode *node, GeoWriter& writer ) const { const GeoDataPlacemark *placemark = static_cast<const GeoDataPlacemark*>(node); writer.writeStartElement( kml::kmlTag_Placemark ); writer.writeOptionalElement( "name", placemark->name() ); writer.writeElement( kml::kmlTag_visibility, QString::number( placemark->isVisible() ) ); writer.writeOptionalElement( kml::kmlTag_styleUrl, placemark->styleUrl() ); if( !placemark->description().isEmpty() ) { writer.writeStartElement( "description" ); if( placemark->descriptionIsCDATA() ) { writer.writeCDATA( placemark->description() ); } else { writer.writeCharacters( placemark->description() ); } writer.writeEndElement(); } if( !placemark->extendedData().isEmpty() ){ writeElement( &placemark->extendedData(), writer ); } if( placemark->geometry() ) { writeElement( placemark->geometry(), writer ); } if( placemark->lookAt() ){ writeElement( placemark->lookAt(), writer ); } if( placemark->timeStamp().when().isValid() ) writeElement( &placemark->timeStamp(), writer ); writer.writeEndElement(); return true; }
QByteArray KDSoapValue::toXml(KDSoapValue::Use use, const QString &messageNamespace) const { QByteArray data; QXmlStreamWriter writer(&data); writer.writeStartDocument(); KDSoapNamespacePrefixes namespacePrefixes; namespacePrefixes.writeStandardNamespaces(writer); writeElement(namespacePrefixes, writer, use, messageNamespace, false); writer.writeEndDocument(); return data; }
bool KmlDocumentTagWriter::writeMid( const GeoNode *node, GeoWriter& writer ) const { const GeoDataDocument *document = static_cast<const GeoDataDocument*>(node); for( const GeoDataStyle::ConstPtr &style: document->styles() ) { writeElement( style.data(), writer ); } for( const GeoDataStyleMap &map: document->styleMaps() ) { writeElement( &map, writer ); } for( const GeoDataSchema &schema: document->schemas() ) { writeElement( &schema, writer ); } QVector<GeoDataFeature*>::ConstIterator it = document->constBegin(); QVector<GeoDataFeature*>::ConstIterator const end = document->constEnd(); for ( ; it != end; ++it ) { writeElement( *it, writer ); } return true; }
static void writeElement(FILE *f, MsvgElement *el, int depth) { MsvgAttribute *pattr; writeLabelElement(f, el->eid, 1, depth); if (el->fattr != NULL) { pattr = el->fattr; while (pattr != NULL) { fprintf(f, " %s=\"%s\"", pattr->key, pattr->value); pattr = pattr->nattr; } } if (el->fson != NULL) { fputs(">\n", f); writeElement(f, el->fson, depth+1); writeLabelElement(f, el->eid, 0, depth); } else { fputs(" />\n", f); } if (el->nsibling != NULL) writeElement(f, el->nsibling, depth); }
/** * @brief Writes `array` to `writer`. * @param writer The JSONWriter. * @param array The Array to write. */ static void writeArray(JSONWriter *writer, const Array *array) { $(writer->data, appendBytes, (uint8_t * ) "[", 1); for (size_t i = 0; i < array->count; i++) { writeElement(writer, $(array, objectAtIndex, i)); if (i < array->count - 1) { $(writer->data, appendBytes, (uint8_t *) ", ", 2); } } $(writer->data, appendBytes, (uint8_t * ) "]", 1); }
bool Simple::writeFile( const QString &filename ) { QFile file( filename ); if ( !file.open( QIODevice::WriteOnly ) ) { qCritical() << "Unable to open file '" << filename << "'"; return false; } QTextStream ts( &file ); ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ts << writeElement(); file.close(); return true; }
//=================================================================================================== void writeList(DescriptorBase * p, fileType t){ switch(t){ case TEXT: ptr_p = TextDescriptor e; break; case PICTURE: ptr_p = PictureDescriptor e; break; case SOUND: ptr_p = SoundDescriptor e; break; } char choice = 0; do{ addDescriptor(p, writeElement(&e), t) printf("Do you want to add another descriptor (Y,N)?\n"); scanf("%s", &choice); }while(choice != "n" && choice != "N"); }
int MsvgWriteSvgFile(MsvgElement *root, const char *fname) { FILE *f; if (root == NULL) return 0; if (root->eid != EID_SVG) return 0; f = fopen(fname, "wt"); if (f == NULL) return 0; fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", f); writeElement(f, root, 0); fclose(f); return 1; }