示例#1
0
void CSharpWriter::writeAttributes(UMLClassifier *c, QTextStream &cs) {

    UMLAttributeList  atpub, atprot, atpriv, atdefval;
    atpub.setAutoDelete(false);
    atprot.setAutoDelete(false);
    atpriv.setAutoDelete(false);
    atdefval.setAutoDelete(false);

    //sort attributes by scope and see if they have a default value
    UMLAttributeList atl = c->getAttributeList();
    UMLAttribute *at;

    for (at = atl.first(); at ; at = atl.next()) {
        if (!at->getInitialValue().isEmpty())
            atdefval.append(at);
        switch (at->getVisibility()) {
          case Uml::Visibility::Public:
            atpub.append(at);
            break;
          case Uml::Visibility::Protected:
            atprot.append(at);
            break;
          case Uml::Visibility::Private:
            atpriv.append(at);
            break;
          default:
            break;
        }
    }

    if (forceSections() || atl.count())
        cs << m_endl << m_container_indent << m_indentation << "#region Attributes" << m_endl << m_endl;

    // write public attributes
    if (forceSections() || atpub.count()) {
        writeAttributes(atpub,cs);
    }

    // write protected attributes
    if (forceSections() || atprot.count()) {
        writeAttributes(atprot,cs);
    }

    // write private attributes
    if (forceSections() || atpriv.count()) {
        writeAttributes(atpriv,cs);
    }

    if (forceSections() || atl.count())
        cs << m_endl << m_container_indent << m_indentation << "#endregion" << m_endl << m_endl;

}
void XmlImageNode::writeOut(OutputStream* out)
{
	XOJ_CHECK_TYPE(XmlImageNode);

	out->write("<");
	out->write(tag);
	writeAttributes(out);

	out->write(">");

	if (this->img == NULL)
	{
		g_error("XmlImageNode::writeOut(); this->img == NULL");
	}
	else
	{
		this->out = out;
		this->pos = 0;
		cairo_surface_write_to_png_stream(this->img, (cairo_write_func_t) &pngWriteFunction, this);
		gchar* base64_str = g_base64_encode(this->buffer, this->pos);
		out->write(base64_str);
		g_free(base64_str);

		this->out = NULL;
	}

	out->write("</");
	out->write(tag);
	out->write(">\n");
}
示例#3
0
static void writeCluster(
	std::ostream &out, int depth,
	const ClusterArray < std::vector<edge> > &edgeMap,
	const ClusterGraph &C, const ClusterGraphAttributes *CA, const cluster &c,
	int &clusterId)
{
	if(C.rootCluster() == c) {
		writeHeader(out, depth++, CA);
	} else {
		GraphIO::indent(out, depth++) << "subgraph cluster" << clusterId
		                              << " {\n";
	}
	clusterId++;

	bool whitespace; // True if a whitespace should printed (readability).

	whitespace = false;
	if(CA) {
		writeAttributes(out, depth, *CA, c);
		whitespace = true;
	}

	if(whitespace) {
		out << "\n";
	}

	// Recursively export all subclusters.
	whitespace = false;
	for(ListConstIterator<cluster> cit = c->cBegin(); cit.valid(); ++cit) {
		writeCluster(out, depth, edgeMap, C, CA, *cit, clusterId);
		whitespace = true;
	}

	if(whitespace) {
		out << "\n";
	}

	// Then, print all nodes whithout an adjacent edge.
	whitespace = false;
	for(ListConstIterator<node> nit = c->nBegin(); nit.valid(); ++nit) {
		whitespace |= writeNode(out, depth, CA, *nit);
	}

	if(whitespace) {
		out << "\n";
	}

	// Finally, we print all edges for this cluster (ugly version for now).
	const std::vector<edge> &edges = edgeMap[c];
	whitespace = false;
	for(size_t i = 0; i < edges.size(); i++) {
		whitespace |= writeEdge(out, depth, CA, edges[i]);
	}

	GraphIO::indent(out, --depth) << "}\n";
}
void XMLFileElement::writeElement(QXmlStreamWriter* xml_writer){
  if (hasSubElements())
    xml_writer->writeStartElement(elementName());
  else
    xml_writer->writeEmptyElement(elementName());
  writeAttributes(xml_writer);
  writeSubElements(xml_writer);
  if (hasSubElements())
    xml_writer->writeEndElement();
}
示例#5
0
static void writeElement(Serialization *serialization, DFNode *element, int depth)
{
    const TagDecl *tagDecl = DFNameMapNameForTag(serialization->doc->map,element->tag);
    assert(tagDecl != NULL);
    const NamespaceDecl *nsDecl = DFNameMapNamespaceForID(serialization->doc->map,tagDecl->namespaceID);
    assert(nsDecl != NULL);

    const xmlChar *prefix = (const xmlChar *)nsDecl->prefix;
    const xmlChar *localName = (const xmlChar *)tagDecl->localName;

    if (serialization->indent && (element->parent != element->doc->docNode))
        xmlTextWriterWriteRawLen(serialization->writer,INDENT,1+depth);

    if (serialization->html || (tagDecl->namespaceID == serialization->defaultNS))
        xmlTextWriterStartElement(serialization->writer,localName);
    else
        xmlTextWriterStartElementNS(serialization->writer,prefix,localName,NULL);

    if ((element->parent == serialization->doc->docNode) && !serialization->html)
        writeNamespaceDeclarations(serialization,element);

    writeAttributes(serialization,element);

    // Check if all children are text nodes. If this is true; we should treat them as if they are a single text
    // node, and not do any indentation.
    int allChildrenText = 1;
    for (DFNode *child = element->first; child != NULL; child = child->next) {
        if (child->tag != DOM_TEXT)
            allChildrenText = 0;
    }

    if (allChildrenText) {
        int oldIndent = serialization->indent;
        serialization->indent = 0;
        for (DFNode *child = element->first; child != NULL; child = child->next)
            writeNode(serialization,child,depth+2);
        serialization->indent = oldIndent;
    }
    else {
        for (DFNode *child = element->first; child != NULL; child = child->next)
            writeNode(serialization,child,depth+2);
    }

    if (serialization->indent && (element->first != NULL) && !allChildrenText) {
        if ((element->first != element->last) ||
            (element->first->tag != DOM_TEXT))
        xmlTextWriterWriteRawLen(serialization->writer,INDENT,1+depth);
    }

    if (serialization->html && (element->first == NULL) && HTML_requiresCloseTag(element->tag)) {
        xmlTextWriterWriteString(serialization->writer,(xmlChar *)"");
    }

    xmlTextWriterEndElement(serialization->writer);
}
void LLXmlTreeNode::writeNoChild(std::string &buffer, const std::string &indent) const
{
	if (!mContents.empty()) {
		writeStart(buffer, indent);
		writeEnd(buffer, indent);
	} else {
		buffer += indent + '<' + mName;
		writeAttributes(buffer);
		buffer += "/>\n";
	}
}
示例#7
0
/*
 * Writes (serializes) this SBML object by writing it to XMLOutputStream.
 */
void
Text::write (XMLOutputStream& stream) const
{
    
  stream.startElement( getElementName() );

  writeAttributes( stream );
  // in addition to attributes we need to write the characters
  stream << this->getText();

  stream.endElement( getElementName() );
}
void IssueDetailsGenerator::write( HtmlWriter* writer, HtmlText::Flags flags )
{
    IssueEntity issue = IssueEntity::find( m_issueId );

    if ( issue.isValid() ) {
        writer->writeBlock( issue.name(), HtmlWriter::Header2Block );

        writer->createLayout();

        QList<ValueEntity> values;
        if ( dataManager->setting( "hide_empty_values" ) == "1" )
            values = issue.nonEmptyValues();
        else
            values = issue.values();

        writer->beginCell( HtmlWriter::TopPane, values.isEmpty() ? 2 : 1 );
        writeProperties( writer, issue );

        if ( !values.isEmpty() ) {
            writer->beginCell( HtmlWriter::TopPane );
            writeAttributes( writer, values, flags );
        }

        if ( m_description ) {
            DescriptionEntity description = issue.description();

            if ( description.isValid() ) {
                writer->appendLayoutRow();
                writer->beginCell( HtmlWriter::BottomPane, 2 );

                writer->writeBlock( descriptionLinks( description, flags ), HtmlWriter::FloatBlock );
                writer->writeBlock( tr( "Description" ), HtmlWriter::Header3Block );
                writer->writeBlock( descriptionText( description, flags ), HtmlWriter::CommentBlock );
            }
        }

        if ( m_history != NoHistory ) {
            writer->appendLayoutRow();
            writer->beginCell( HtmlWriter::BottomPane, 2 );

            if ( !flags.testFlag( HtmlText::NoInternalLinks ) )
                writer->writeBlock( historyLinks( flags ), HtmlWriter::FloatBlock );

            writer->writeBlock( tr( "Issue History" ), HtmlWriter::Header3Block );

            writeHistory( writer, issue, flags );
        }

        writer->endLayout();
    }
}
示例#9
0
static inline bool writeEdge(
	std::ostream &out, const int &depth,
	const GraphAttributes *GA, const edge &e)
{
	GraphIO::indent(out, depth) << e->source()
	                            << (GA && !GA->directed() ? " -- " : " -> ")
	                            << e->target();

	if(GA) {
		out << " ";
		writeAttributes(out, *GA, e);
	}

	out << "\n";
	return true;
}
void XmlStrokeNode::writeOut(OutputStream* out)
{
	XOJ_CHECK_TYPE(XmlStrokeNode);

	out->write("<");
	out->write(tag);
	writeAttributes(out);

	out->write(" width=\"");
	char* tmp = g_strdup_printf("%1.2lf", width);
	out->write(tmp);
	g_free(tmp);

	for (int i = 0; i < widthsLength; i++)
	{
		char* tmp = g_strdup_printf(" %1.2lf", widths[i]);
		out->write(tmp);
		g_free(tmp);
	}

	out->write("\"");

	if (this->pointsLength == 0)
	{
		out->write("/>");
	}
	else
	{
		out->write(">");

		char* tmp = g_strdup_printf("%1.2lf %1.2lf", points[0].x, points[0].y);
		out->write(tmp);
		g_free(tmp);

		for (int i = 1; i < this->pointsLength; i++)
		{
			char* tmp = g_strdup_printf(" %1.2lf %1.2lf", points[i].x, points[i].y);
			out->write(tmp);
			g_free(tmp);
		}

		out->write("</");
		out->write(tag);
		out->write(">\n");
	}
}
void GameAttributes::saveSelected()
{
	qDebug() << "OK Selected!";
	
	setVariablesFromUser();
	
	std::ofstream myfile("settings.txt");	
	
	if (myfile.is_open())
	{
		writeAttributes(&myfile);
		myfile.close();
	}
	else 
		qDebug() << "Unable to open file";
	
	close();
}
示例#12
0
void XMLWriter::writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
{
	if (!_nsContextPushed)
		_namespaces.pushContext();
	_nsContextPushed = false;
	++_elementCount;
	writeMarkup(MARKUP_LT);
	if (!localName.empty() && (qname.empty() || localName == qname))
	{
		XMLString prefix;
		if (!namespaceURI.empty() && !_namespaces.isMapped(namespaceURI))
		{
			prefix = newPrefix();
			_namespaces.declarePrefix(prefix, namespaceURI);
		}
		else prefix = _namespaces.getPrefix(namespaceURI);
		writeName(prefix, localName);
	}
	else if (namespaceURI.empty() && localName.empty() && !qname.empty())
	{
		writeXML(qname);
	}
	else if (!localName.empty() && !qname.empty())
	{
		XMLString local;
		XMLString prefix;
		Name::split(qname, prefix, local);
		if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI);
		const XMLString& uri = _namespaces.getURI(prefix);
		if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty())
		{
			_namespaces.declarePrefix(prefix, namespaceURI);
		}
		writeName(prefix, localName);
	}
	else throw XMLException("Tag mismatch", nameToString(localName, qname));

	declareAttributeNamespaces(attributes);
	AttributeMap attributeMap;
	addNamespaceAttributes(attributeMap);
	addAttributes(attributeMap, attributes, namespaceURI);
	writeAttributes(attributeMap);
	_unclosedStartTag = true;
}
示例#13
0
static inline bool writeNode(
	std::ostream &out, const int &depth,
	const GraphAttributes *GA, const node &v
)
{
	// Write a node iff it has some attributes or has no edges.
	if(!GA && v->degree() > 0) {
		return false;
	}

	GraphIO::indent(out, depth) << v;

	if(GA) {
		out << " ";
		writeAttributes(out, *GA, v);
	}

	out << "\n";
	return true;
}
示例#14
0
static inline void writeNode(
	std::ostream &out, int depth,
	const GraphAttributes *GA, node v)
{
	if(GA) {
		GraphIO::indent(out, depth) << "<node id=\"" << v->index() << "\"";
		if(GA->attributes() & GraphAttributes::nodeLabel) {
			out << " label=\"" << GA->label(v) << "\"";
		}
		out << ">\n";

		writeAttributes(out, depth + 1, *GA, v);

		GraphIO::indent(out, depth) << "</node>\n";
	} else {
		GraphIO::indent(out, depth) << "<node "
		                            << "id=\"" << v->index() << "\" "
		                            << "/>\n";
	}
}
示例#15
0
void SimpleXMLBuilder::writeElement(std::ostream& os,
		int level) const
{
	writeIndentation(os, level);
	os << "<"  << name;
	writeAttributes(os);
	os << ">";

	if (txt != NULL)
	{
		os << escape(*txt);
	}
	else
	{
		writeChildElements(os, level + 1);
		writeIndentation(os, level);
	}

	os << "</" << name << ">" << std::endl;
}
示例#16
0
static inline void writeEdge(
	std::ostream &out, int depth,
	const GraphAttributes *GA, edge e)
{
	if(GA) {
		GraphIO::indent(out, depth) << "<edge id=\"" << e->index() << "\"";
		if(GA->attributes() & GraphAttributes::edgeLabel) {
			out << " label=\"" << GA->label(e) << "\"";
		}
		out << ">\n";

		writeAttributes(out, depth + 1, *GA, e);

		GraphIO::indent(out, depth) << "</edge>\n";
	} else {
		GraphIO::indent(out, depth) << "<edge "
		                            << "id=\"" << e->index() << "\" "
		                            << "source=\"" << e->source() << "\" "
		                            << "target=\"" << e->target() << "\" "
		                            << "/>\n";
	}
}
示例#17
0
void XmlNode::writeOut(OutputStream* out, ProgressListener* listener)
{
	XOJ_CHECK_TYPE(XmlNode);

	out->write("<");
	out->write(tag);
	writeAttributes(out);

	if (this->children == NULL)
	{
		out->write("/>\n");
	}
	else
	{
		out->write(">\n");

		if(listener)
		{
			listener->setMaximumState(g_list_length(this->children));
		}

		guint i = 1;

		for (GList* l = this->children; l != NULL; l = l->next, ++i)
		{
			XmlNode* node = (XmlNode*) l->data;
			node->writeOut(out);
			if(listener)
			{
				listener->setCurrentState(i);
			}
		}

		out->write("</");
		out->write(tag);
		out->write(">\n");
	}
}
示例#18
0
static void writeElement(Serialization *serialization, DFNode *element, int depth)
{
    const TagDecl *tagDecl = DFNameMapNameForTag(serialization->doc->map,element->tag);
    assert(tagDecl != NULL);
    const NamespaceDecl *nsDecl = DFNameMapNamespaceForID(serialization->doc->map,tagDecl->namespaceID);
    assert(nsDecl != NULL);

    const xmlChar *prefix = (const xmlChar *)nsDecl->prefix;
    const xmlChar *localName = (const xmlChar *)tagDecl->localName;

    if (serialization->indent && (element->parent != element->doc->docNode))
        xmlTextWriterWriteRawLen(serialization->writer,INDENT,1+depth);

    if (serialization->html || (tagDecl->namespaceID == serialization->defaultNS))
        xmlTextWriterStartElement(serialization->writer,localName);
    else
        xmlTextWriterStartElementNS(serialization->writer,prefix,localName,NULL);

    if ((element->parent == serialization->doc->docNode) && !serialization->html)
        writeNamespaceDeclarations(serialization,element);

    writeAttributes(serialization,element);

    for (DFNode *child = element->first; child != NULL; child = child->next)
        writeNode(serialization,child,depth+2);

    if (serialization->indent && (element->first != NULL)) {
        if ((element->first != element->last) ||
            (element->first->tag != DOM_TEXT))
        xmlTextWriterWriteRawLen(serialization->writer,INDENT,1+depth);
    }

    if (serialization->html && (element->first == NULL) && HTML_requiresCloseTag(element->tag)) {
        xmlTextWriterWriteString(serialization->writer,(xmlChar *)"");
    }

    xmlTextWriterEndElement(serialization->writer);
}
示例#19
0
static void
writeTemplate(const template_t *tc, tfile_t *tf)
{
	int magic = TMPL_MAGIC;

	/*
	 * We discard 'const' because the various I/O functions don't
	 * promise const (because they're 'I' as well as 'O').
	 */
	template_t *t = (template_t*) tc;

	writeScalar(magic, tf);
	writeHeader(t, tf);
	writeScalar(t->tm_flags, tf);
	writeScalar(t->tm_alignment, tf);
	writeScalar(t->tm_minsize, tf);
	writeTemplateRefs(t, tf);
	writeAttributes(t, tf);
	if (isRedirectTmpl(t)) {
		writeTmplRedirection(t, tf);
	}
	writeTmplFormat(t, tf);
}
示例#20
0
void MessageFactory::serialize(Stanza *stanza, QXmlStreamWriter *writer)
{
	if (!StanzaPrivate::get(*stanza)->tokens.isEmpty()) {
		StanzaFactory::serialize(stanza, writer);
		return;
	}
	Message *message = static_cast<Message*>(stanza);
	if (message->subtype() == Message::Invalid)
		return;

	QLatin1String subtype = enumToStr(message->subtype(),message_types);

	writer->writeStartElement(QLatin1String("message"));
	writeAttributes(stanza, writer);
	if (subtype != QLatin1String(""))
		writer->writeAttribute(QLatin1String("type"), subtype);
	writeLangMap(QLatin1String("subject"),message->subject(),writer);
	writeLangMap(QLatin1String("body"),message->body(),writer);
	if(!message->thread().isEmpty())
		writer->writeTextElement(QLatin1String("thread"),message->thread());
	writePayloads(stanza, writer);
	writer->writeEndElement();
}
示例#21
0
void SQLWriter::writeClass(UMLClassifier *c) {

    if(!c) {
        kDebug()<<"Cannot write class of NULL concept!" << endl;
        return;
    }

    const bool isClass = !c->isInterface();
    QString classname = cleanName(c->getName());

    //find an appropriate name for our file
    QString fileName = findFileName(c, ".sql");
    if (fileName.isEmpty()) {
        emit codeGenerated(c, false);
        return;
    }

    QFile file;
    if( !openFile(file, fileName) ) {
        emit codeGenerated(c, false);
        return;
    }

    //Start generating the code!!

    QTextStream sql(&file);
    //try to find a heading file (license, coments, etc)
    QString str;
    str = getHeadingFile(".sql");
    if(!str.isEmpty()) {
        str.replace(QRegExp("%filename%"),fileName);
        str.replace(QRegExp("%filepath%"),file.name());
        sql<<str<<m_endl;
    }

    //Write class Documentation if there is somthing or if force option
    if(forceDoc() || !c->getDoc().isEmpty()) {
        sql << m_endl << "--" << m_endl;
        sql<<"-- TABLE: "<<classname<<m_endl;
        sql<<formatDoc(c->getDoc(),"-- ");
        sql << "--  " << m_endl << m_endl;
    }

    sql << "CREATE TABLE "<< classname << " ( " << m_endl;

    if (isClass)
        writeAttributes(c, sql);

    sql << m_endl << ");" << m_endl;

    QMap<UMLAssociation*,UMLAssociation*> constraintMap; // so we don't repeat constraint
    UMLAssociationList aggregations = c->getAggregations();
    if( forceSections() || !aggregations.isEmpty() ) {
        for(UMLAssociation* a = aggregations.first(); a; a = aggregations.next()) {
            UMLObject *objA = a->getObject(Uml::A);
            UMLObject *objB = a->getObject(Uml::B);
            if (objA->getID() == c->getID() && objB->getID() != c->getID())
                continue;
            constraintMap[a] = a;
        }
    }

    QMap<UMLAssociation*,UMLAssociation*>::Iterator itor = constraintMap.begin();
    for (;itor != constraintMap.end();itor++) {
        UMLAssociation* a = itor.data();
        sql << "ALTER TABLE "<< classname
            << " ADD CONSTRAINT " << a->getName() << " FOREIGN KEY ("
            << a->getRoleName(Uml::B) << ") REFERENCES "
            << a->getObject(Uml::A)->getName()
            << " (" << a->getRoleName(Uml::A) << ");" << m_endl;
    }


    file.close();
    emit codeGenerated(c, true);
}
示例#22
0
void Writer::writeElement(ElementNodePtr element)
{
	tstring indentation;
	tstring terminator;

	if (!(m_flags & NO_FORMATTING))
	{
		for (uint i = 0; i != m_depth; ++i)
			indentation += m_indentStyle;

		terminator = DEFAULT_TERMINATOR;
	}

	if (element->hasChildren())
	{
		const bool inlineValue = ( (element->getChildCount() == 1)
								&& (element->getChild(0)->type() == TEXT_NODE) );

		if (!element->getAttributes().isEmpty())
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s"), element->name().c_str());

			writeAttributes(element->getAttributes());

			m_buffer += TXT(">");

			if (!inlineValue)
				m_buffer += terminator;
		}
		else
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s>"), element->name().c_str());

			if (!inlineValue)
				m_buffer += terminator;
		}

		++m_depth;
		writeContainer(*element);
		--m_depth;

		if (!inlineValue)
			m_buffer += indentation;

		m_buffer += Core::fmt(TXT("</%s>"), element->name().c_str());
		m_buffer += terminator;
	}
	else
	{
		if (!element->getAttributes().isEmpty())
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s"), element->name().c_str());

			writeAttributes(element->getAttributes());

			m_buffer += TXT("/>");
			m_buffer += terminator;
		}
		else
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s/>"), element->name().c_str());
			m_buffer += terminator;
		}
	}
}
示例#23
0
void Account::save(QXmlStreamWriter *xml) {
	QXmlStreamAttributes attr;
	writeAttributes(&attr);
	xml->writeAttributes(attr);
	writeElements(xml);
}
示例#24
0
/* PTGetPTF writes a PT to external memory in a variety of formats.  */
PTErr_t
	PTGetPTF (	PTRefNum_t	PTRefNum,
				PTType_t	format,
				KpInt32_t	mBlkSize,
				PTAddr_t	PTAddr)
{
PTErr_t		errnum, PTstatus;
KpHandle_t	PTHdr, PTAttr, PTData;
KpFd_t		fd;
KpInt32_t	attrSize, resultSize, nBytes;
PTRefNum_t	resizePTRefNum = 0, thePTRefNum;
KpChar_p	memData;


	errnum = getPTStatus (PTRefNum);

	if ((errnum == KCP_PT_ACTIVE) || (errnum == KCP_PT_INACTIVE) || (errnum == KCP_SERIAL_PT)) {
		#if defined KCP_DIAG_LOG
		{KpChar_t	string[256];
		sprintf (string, "\nPTGetPTF\n PTRefNum %x, format %x, mBlkSize %d, PTAddr %x\n",
							PTRefNum, format, mBlkSize, PTAddr);
		kcpDiagLog (string);}
		#endif

		PTstatus = errnum;

		/* 	verify the dimensions of the grid table are valid for the specified format. */
		errnum = gridDimValid (format, PTRefNum, &resizePTRefNum);
		if (errnum != KCP_SUCCESS) {
			goto ErrOut1;
		}

		if (resizePTRefNum != 0) {
			thePTRefNum = resizePTRefNum;	/* resized PT made */
		}
		else {
			thePTRefNum = PTRefNum;			/* use original PT */
		}
		
		/*	determine the size the resized PT */
		errnum = PTGetSizeF (thePTRefNum, format, &resultSize);
		if (errnum != KCP_SUCCESS) {
			goto ErrOut1;
		}

		if (resultSize > mBlkSize) {	/* PT may not be larger than the buffer size */
			errnum = KCP_PT_BLOCK_TOO_SMALL;
			goto ErrOut1;
		}

		PTAttr = getPTAttr (thePTRefNum);
		PTHdr = getPTHdr (thePTRefNum);
		PTData = getPTData (thePTRefNum);

		/* initialize memory file manager to write the PT */
		if (KpOpen (NULL, "m", &fd, NULL, (KpGenericPtr_t)PTAddr, mBlkSize) != KCMS_IO_SUCCESS) {
			errnum = KCP_SYSERR_1;
			goto ErrOut1;
		}

		attrSize = getAttrSize (PTAttr);					/* get size of attributes */
		errnum = TpWriteHdr (&fd, format, PTHdr, attrSize);	/* write the header info */

		if (errnum != KCP_SUCCESS) {
			Kp_close (&fd);
			goto ErrOut1;
		} 	

#if !defined KCP_ICC_ONLY
		switch (format) {
		case PTTYPE_FUTF:
			errnum = writeAttributes (&fd, PTAttr);	/* write the attributes */
			if (errnum != KCP_SUCCESS) {
				break;
			}

		default:
			break;
		}
#endif

		/* if PT active, write data to external format */
		if (((PTstatus == KCP_PT_ACTIVE) || (PTstatus == KCP_SERIAL_PT)) && (errnum == KCP_SUCCESS)) {
			errnum = TpWriteData (&fd, format, PTHdr, PTData);
		}

		(void) Kp_close (&fd);

		/*	if the result PT size is smaller than the memory block size
			fill the end of the memory block with zeros						*/
		nBytes = mBlkSize - resultSize;
		if (nBytes > 0) {
			memData = (KpChar_p)PTAddr + resultSize;
			while (nBytes--) {
				*memData++ = 0;
			}
		}			

	}

ErrOut1:
	if (resizePTRefNum != 0) {
		PTCheckOut (resizePTRefNum);
	}

	return (errnum);
}
示例#25
0
	void G3djWriter::exportG3dj(G3djFile *file, const char* filePath){
		writer = new JSONWriter(filePath);

		writer->openObject();

		writer->writeStringPair("version", G3DJ_VERSION);
		writer->nextValue(true);

		// Write Meshes
		writer->openArray("meshes");

		// meshes
		for (unsigned int i=0; i<file->getMeshCount(); i++)
		{
			Mesh *mesh = file->getMesh(i);
			if(i>0)
				writer->nextValue(true);

			writer->openObject();

			// write ID out first
			writer->writeStringPair("id", mesh->getId().c_str());
			writer->nextValue(true);

			// then the attributes
			writer->openArray("attributes");
				writeAttributes(mesh);
			writer->closeArray();
			writer->nextValue(true);

			// then the interleaved vertices
			writer->openArray("vertices");
				writeVertices(mesh);
			writer->closeArray();
			writer->nextValue(true);

			// then the mesh parts (optional)
			if(mesh->parts.size() > 0){
				writer->openArray("parts");
					writeMeshParts(mesh);
				writer->closeArray();
			}
			writer->closeObject();
		}

		writer->closeArray();
		writer->nextValue(true);

		// Write Materials
		if(file->getMaterialCount() > 0){
			writer->openArray("materials");

			for(unsigned int i=0; i<file->getMaterialCount(); i++){
				G3djMaterial* material = file->getMaterial(i);
			
				if(i>0)
					writer->nextValue(true);

				writeMaterial(material);
			}

			writer->closeArray();
			writer->nextValue(true);
		}

		// Write Nodes
		writer->openArray("nodes");

		for(unsigned int i=0; i<file->getNodeCount(); i++){
			G3djNode* node = file->getNode(i);

			if(i>0)
				writer->nextValue(true);

			writeNodeRecursive(node);
		}

		writer->closeArray();
		writer->nextValue(true);

		// Write Animations
		writer->openArray("animations");

		for(unsigned int i=0; i<file->getAnimationClipCount(); i++){
			AnimationClip* animationClip = file->getAnimationClip(i);

			if(i>0)
				writer->nextValue(true);

			writeAnimationClip(animationClip);
		}

		writer->closeArray();

		// Main object closing
		writer->closeObject();
	}
示例#26
0
void CSharpWriter::writeClass(UMLClassifier *c) {
    if (!c) {
        kDebug()<<"Cannot write class of NULL concept!" << endl;
        return;
    }

    QString classname = cleanName(c->getName());
    //find an appropriate name for our file
    QString fileName = findFileName(c, ".cs");
    if (fileName.isEmpty()) {
        emit codeGenerated(c, false);
        return;
    }

    QFile filecs;
    if (!openFile(filecs, fileName)) {
        emit codeGenerated(c, false);
        return;
    }
    QTextStream cs(&filecs);

    //////////////////////////////
    //Start generating the code!!
    /////////////////////////////


    //try to find a heading file (license, coments, etc)
    QString str;
    str = getHeadingFile(".cs");
    if (!str.isEmpty()) {
        str.replace(QRegExp("%filename%"),fileName);
        str.replace(QRegExp("%filepath%"),filecs.name());
        cs<<str<<m_endl;
    }

    UMLDoc *umldoc = UMLApp::app()->getDocument();
    UMLFolder *logicalView = umldoc->getRootFolder(Uml::mt_Logical);

    // write generic includes
    cs << "using System;" << m_endl;
    cs << "using System.Text;" << m_endl;
    cs << "using System.Collections;" << m_endl;
    cs << "using System.Collections.Generic;" << m_endl << m_endl;

    //write includes and namespace

    UMLPackage *container = c->getUMLPackage();
    if (container == logicalView)
        container = NULL;

    UMLPackageList includes;
    findObjectsRelated(c, includes);
    m_seenIncludes.clear();
    //m_seenIncludes.append(logicalView);
    if (includes.count()) {
        UMLPackage *p;
        for (UMLPackageListIt it(includes); (p = it.current()) != NULL; ++it) {
            UMLClassifier *cl = dynamic_cast<UMLClassifier*>(p);
            if (cl)
                p = cl->getUMLPackage();
            if (p != logicalView && m_seenIncludes.findRef(p) == -1 && p != container) {
                cs << "using " << p->getFullyQualifiedName(".") << ";" << m_endl;
                m_seenIncludes.append(p);
            }
        }
        cs << m_endl;
    }

    m_container_indent = "";

    if (container) {
        cs << "namespace " << container->getFullyQualifiedName(".") << m_endl;
        cs << "{" << m_endl << m_endl;
        m_container_indent = m_indentation;
        m_seenIncludes.append(container);
    }

    //Write class Documentation if there is somthing or if force option
    if (forceDoc() || !c->getDoc().isEmpty()) {
        cs << m_container_indent << "/// <summary>" << m_endl;
        cs << formatDoc(c->getDoc(), m_container_indent + "/// " );
        cs << m_container_indent << "/// </summary>" << m_endl ;
    }

    UMLClassifierList superclasses = c->getSuperClasses();
    UMLAssociationList aggregations = c->getAggregations();
    UMLAssociationList compositions = c->getCompositions();
    UMLAssociationList realizations = c->getRealizations();
    bool isInterface = c->isInterface();
    m_unnamedRoles = 1;

    cs << m_container_indent << "public ";

    //check if it is an interface or regular class
    if (isInterface) {
        cs << "interface " << classname;
    } else {
        //check if class is abstract and / or has abstract methods
        if (c->getAbstract() || c->hasAbstractOps())
            cs << "abstract ";

        cs << "class " << classname << (superclasses.count() > 0 ? " : ":"");

        // write baseclass, ignore interfaces, write error on multiple inheritance
        if (superclasses.count() > 0) {
            UMLClassifier *obj;
            int supers = 0;
            for (obj = superclasses.first(); obj; obj = superclasses.next()) {
                if (!obj->isInterface()) {
                    if (supers > 0) {
                        cs << " // AND ";
                    }
                    cs << cleanName(obj->getName());
                    supers++;
                }
            }
            if (supers > 1) {
                cs << m_endl << "//WARNING: C# does not support multiple inheritance but there is more than 1 superclass defined in your UML model!" << m_endl;
        }
        }
        //check for realizations
        UMLAssociationList realizations = c->getRealizations();
        UMLAssociation *a;

        if (!realizations.isEmpty()) {
            for (a = realizations.first(); a; a = realizations.next()) {
                UMLClassifier *real = (UMLClassifier*)a->getObject(Uml::B);
                if(real != c) {
                    // write list of realizations
                    cs << ", " << real->getName();
                }

            }
        }
    }
    cs << m_endl << m_container_indent << '{' << m_endl;

    //associations
    if (forceSections() || !aggregations.isEmpty()) {
        cs << m_endl << m_container_indent << m_indentation << "#region Aggregations" << m_endl << m_endl;
        writeAssociatedAttributes(aggregations, c, cs);
        cs << m_endl << m_container_indent << m_indentation << "#endregion" << m_endl;
    }

    //compositions
    if (forceSections() || !compositions.isEmpty()) {
        cs << m_endl << m_container_indent << m_indentation << "#region Compositions" << m_endl << m_endl;
        writeAssociatedAttributes(compositions, c, cs);
        cs << m_endl << m_container_indent << m_indentation << "#endregion" << m_endl;
    }

    //attributes
    // FIXME: C# allows Properties in interface!
    if (!isInterface)
        writeAttributes(c, cs);

    //operations
    writeOperations(c, cs);

    //finish file
    cs << m_endl << m_container_indent << "}" << m_endl << m_endl; // close class

    if (container) {
        cs << "}  // end of namespace "
            << container->getFullyQualifiedName(".") << m_endl << m_endl;
    }

    //close files and notfiy we are done
    filecs.close();
    emit codeGenerated(c, true);
}
void LLXmlTreeNode::writeStart(std::string &buffer, const std::string &indent) const
{
	buffer += indent + '<' + mName;
	writeAttributes(buffer);
	buffer += ">\n";
}
示例#28
0
文件: GraphIO_dot.cpp 项目: ogdf/ogdf
static bool writeCluster(
	std::ostream &out, int depth,
	const ClusterArray < std::vector<edge> > &edgeMap,
	const ClusterGraph &C, const ClusterGraphAttributes *CA, const cluster &c,
	int &clusterId)
{
	std::ios_base::fmtflags currentFlags = out.flags();
	out.flags(currentFlags | std::ios::fixed);
	bool result = out.good();

	if(result) {
		if (C.rootCluster() == c) {
			writeHeader(out, depth++, CA);
		} else {
			GraphIO::indent(out, depth++) << "subgraph cluster" << clusterId << " {\n";
		}
		clusterId++;

		bool whitespace; // True if a whitespace should printed (readability).

		whitespace = false;
		if (CA) {
			writeAttributes(out, depth, *CA, c);
			whitespace = true;
		}

		if (whitespace) {
			out << "\n";
		}

		// Recursively export all subclusters.
		whitespace = false;
		for (cluster child : c->children) {
			writeCluster(out, depth, edgeMap, C, CA, child, clusterId);
			whitespace = true;
		}

		if (whitespace) {
			out << "\n";
		}

		// Then, print all nodes whithout an adjacent edge.
		whitespace = false;
		for (node v : c->nodes) {
			whitespace |= writeNode(out, depth, CA, v);
		}

		if (whitespace) {
			out << "\n";
		}

		// Finally, we print all edges for this cluster (ugly version for now).
		const std::vector<edge> &edges = edgeMap[c];
		whitespace = false;
		for (auto &e : edges) {
			whitespace |= writeEdge(out, depth, CA, e);
		}

		GraphIO::indent(out, --depth) << "}\n";
	}

	out.flags(currentFlags);

	return result;
}