本文整理汇总了C++中writeNode函数的典型用法代码示例。如果您正苦于以下问题:C++ writeNode函数的具体用法?C++ writeNode怎么用?C++ writeNode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recDelete
int recDelete(rect *r, node *n, int pos){
int i,j;
node *n1, *n2;
if(n->leaf){
for(i = 0; i < n->size; ++i)
if(n->values[i]->child == pos){
deleteValue(n, i);
writeNode(n);
return TRUE;
}
return FALSE;
}
for(i = 0; i < n->size; ++i)
if(intersect(r, n->values[i]->r)){
n1 = readNode(n->values[i]->child);
if(recDelete(r, n1, pos)){
n->values[i]->r = dupRect(n1->MBR);
if(n1->size < b )
underflow(n, n1, i);
else{
refreshMBR(n);
writeNode(n);
freeNode(n1);
}
return TRUE;
}
else
freeNode(n1);
}
return FALSE;
}
示例2: writeConfig
void JsonTextWriter::writeToStream( const Text & text, std::ostream & os ) {
os << "{\n\tconfig: ";
writeConfig( text.getConfig(), os );
os << ",\n\tcontent: '" << text.getContent() << "',\n\tnodes: [\n\t\t";
uint nodesCount = text.getNodes().size();
if ( nodesCount > 0 ) {
writeNode( *text.getNodes().at( 0 ), os );
for ( uint i = 1; i < nodesCount; ++ i ) {
os << ",\n\t\t";
writeNode( *text.getNodes().at( i ), os );
}
}
os << "\n\t],\n\tannotations: [\n\t\t";
for ( uint i = 0; i < nodesCount; ++ i ) {
const Node & node = *text.getNodes().at( i );
for ( uint j = 0; j < node.getTransitionCount(); ++ j ) {
if ( i != 0 || j != 0 )
os << ",\n\t\t";
writeAnnotation( *node.getTransition( j ), os );
}
}
os << "\n\t]\n}";
}
示例3: writeNode
void BSPFile::writeNode( ChunkOutputStream* out, const BSPNode* nodeIn )
{
Debug::println( "bsp: Writing node of {0} polygons", nodeIn->polygons() );
out->beginChunk( "node" );
out->writeFloat( nodeIn->plane().x );
out->writeFloat( nodeIn->plane().y );
out->writeFloat( nodeIn->plane().z );
out->writeFloat( nodeIn->plane().w );
int childFlags = 0;
if ( nodeIn->positive() )
childFlags |= 1;
if ( nodeIn->negative() )
childFlags |= 2;
out->writeInt( childFlags );
if ( nodeIn->positive() )
writeNode( out, nodeIn->positive() );
if ( nodeIn->negative() )
writeNode( out, nodeIn->negative() );
out->writeInt( nodeIn->polygons() );
for ( int i = 0; i < nodeIn->polygons(); ++i )
out->writeInt( m_tree->getPolygonIndex(&nodeIn->getPolygon(i)) );
out->endChunk();
}
示例4: readNode
void Btree<T>::cutNode(T& x,
unsigned xRST,
unsigned ptr,
unsigned pos,
T& y,
unsigned &yRST)
//
// Purpose: divides the node accessed by index ptr that contains
// item x and index xRST at index pos. The new nodes are accessed
// by pointers ptr and yRST. The median element is y.
//
// Parameters:
//
// input: x - the inserted data
// xRST - the inserted index associated with item x
// ptr - the index to the manipulated node
// pos - the index of the dividing line
//
// output:
// y - the new median
// yRST - the index to the other node.
//
{
unsigned median, i;
Bstruct<T> *buf1, *buf2;
buf1 = new Bstruct<T>;
buf2 = new Bstruct<T>;
readNode(buf1, ptr);
// calculate the median element which also determines if
// the new inserted item x is placed in the new left or the
// new right nodes
median = (pos <= BTREE_MIN) ? BTREE_MIN : BTREE_MIN + 1;
// create a new tree node and put it on the right
yRST = getNodeIndex();
for (i = 0; i <= BTREE_MAX; i++)
buf2->nodeLink[i] = BTREE_NIL;
numNodes++;
// loop to move half of the keys
for (i = median + 1; i <= BTREE_MAX; i++) {
buf2->data[i - median] = buf1->data[i];
buf2->nodeLink[i - median] = buf1->nodeLink[i];
}
buf2->count = BTREE_MAX - median;
buf1->count = median;
// push in the new data
if (pos <= BTREE_MIN)
pushIn(x, xRST, buf1, pos);
else
pushIn(x, xRST, buf2, pos - median);
y = buf1->data[buf1->count];
buf2->nodeLink[0] = buf1->nodeLink[buf1->count--];
writeNode(buf1, ptr);
writeNode(buf2, yRST);
delete buf1;
delete buf2;
}
示例5: writeElement
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);
}
示例6: getNumChildren
void TOutline::writeNode(TNode *node, opstream &op) {
uchar more = (node->next != 0) ? 1 : 0;
uchar expand = (node->expanded) ? 1 : 0;
op << more;
op << expand;
op << getNumChildren(node);
op.writeString(node->text);
if (node->childList != 0)
writeNode(node->childList, op);
if (node->next != 0)
writeNode(node->next, op);
}
示例7: writeNode
void
writeNode(Node& node,
std::ostream& stream,
const WriteParameters& params)
{
writeNode(*(node.get()), stream, params);
}
示例8: writeNode
int writeNode(FILE *fpio, OctNode* node) {
int istat;
int istat_cum;
int ix, iy, iz;
float value;
value = (float) node->value;
istat = fwrite(&value, sizeof (float), 1, fpio); /* node value */
istat += fwrite(&(node->isLeaf), sizeof (char), 1, fpio); /* leaf flag, 1=leaf */
if (istat < 2)
return (-1);
if (node->isLeaf)
return (1);
istat_cum = 1;
for (ix = 0; ix < 2; ix++) {
for (iy = 0; iy < 2; iy++) {
for (iz = 0; iz < 2; iz++) {
if (node->child[ix][iy][iz] != NULL) {
istat = writeNode(fpio, node->child[ix][iy][iz]);
if (istat < 0)
return (-1);
istat_cum += istat;
}
}
}
}
return (istat_cum);
}
示例9: writeTree3D
int writeTree3D(FILE *fpio, Tree3D* tree) {
int istat;
int istat_cum;
int ix, iy, iz;
istat = fwrite(&(tree->data_code), sizeof (int), 1, fpio);
istat += fwrite(&(tree->numx), sizeof (int), 1, fpio);
istat += fwrite(&(tree->numy), sizeof (int), 1, fpio);
istat += fwrite(&(tree->numz), sizeof (int), 1, fpio);
istat += fwrite(&(tree->orig), sizeof (Vect3D), 1, fpio);
istat += fwrite(&(tree->ds), sizeof (Vect3D), 1, fpio);
istat += fwrite(&(tree->integral), sizeof (double), 1, fpio);
if (istat < 6)
return (-1);
istat_cum = 0;
for (ix = 0; ix < tree->numx; ix++) {
for (iy = 0; iy < tree->numy; iy++) {
for (iz = 0; iz < tree->numz; iz++) {
istat = writeNode(fpio, tree->nodeArray[ix][iy][iz]);
if (istat < 0)
return (-1);
istat_cum += istat;
}
}
}
return (istat_cum);
}
示例10: writeDocument
void
writeDocument(Document& document,
std::ostream& stream,
const WriteParameters& params)
{
writeNode(*(document.get()), stream, params);
}
示例11: DFSerializeXMLBuffer
void DFSerializeXMLBuffer(DFDocument *doc, NamespaceID defaultNS, int indent, DFBuffer *buf)
{
xmlOutputBufferPtr output = xmlOutputBufferCreateIO(StringBufferWrite,
StringBufferClose,
buf,
NULL);
xmlTextWriterPtr writer = xmlNewTextWriter(output);
int html = 0;
for (DFNode *child = doc->docNode->first; child != NULL; child = child->next) {
if (child->tag == HTML_HTML)
html = 1;
}
Serialization serialization;
bzero(&serialization,sizeof(serialization));
serialization.ic = iconv_open("UTF-8","UTF-16LE");
if (serialization.ic == ((iconv_t)-1)) {
fprintf(stderr,"FATAL: Can't open iconv descriptor\n");
abort();
}
serialization.writer = writer;
serialization.doc = doc;
serialization.defaultNS = defaultNS;
serialization.html = html;
serialization.indent = indent;
writeNode(&serialization,doc->docNode,0);
iconv_close(serialization.ic);
xmlFreeTextWriter(writer);
}
示例12: writeNode
void JsonWriter::writeEntry(JsonVector::const_iterator entry)
{
if (!entry->meta.empty())
out << prefix << " // " << entry->meta << "\n";
out << prefix;
writeNode(*entry);
}
示例13: _setAttributeNode
// Attr setAttributeNode(in Attr newAttr) raises(DOMException);
// Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException);
static void _setAttributeNode(Request& r, MethodParams& params) {
VXnode& vnode=GET_SELF(r, VXnode);
VXdoc& vxdoc=vnode.get_vxdoc();
xmlNode& element=get_self_element(vnode);
xmlDoc& xmldoc=vxdoc.get_xmldoc();
xmlAttr& newAttr=as_attr(params, 0, "newAttr must be ATTRIBUTE node");
if(newAttr.doc!=&xmldoc)
throw Exception("xml.dom",
0,
"WRONG_DOCUMENT_ERR");
if(newAttr.parent)
throw Exception("xml.dom",
0,
"INUSE_ATTRIBUTE_ERR");
if(xmlNode* retNode=pa_getAttributeNodeNS(element, newAttr.name, pa_xmlGetNsURI((xmlNode*)&newAttr))) {
// write out result
writeNode(r, vxdoc, retNode);
xmlUnlinkNode(retNode);
}
pa_addAttributeNode(element, newAttr);
}
示例14: switch
bool Writer::writeNode(Lattice *lattice, const Node *node,
StringBuffer *os) const {
switch (node->stat) {
case MECAB_BOS_NODE:
return writeNode(lattice, bos_format_.get(), node, os);
case MECAB_EOS_NODE:
return writeNode(lattice, eos_format_.get(), node, os);
case MECAB_UNK_NODE:
return writeNode(lattice, unk_format_.get(), node, os);
case MECAB_NOR_NODE:
return writeNode(lattice, node_format_.get(), node, os);
case MECAB_EON_NODE:
return writeNode(lattice, eon_format_.get(), node, os);
}
return true;
}
示例15: _replaceChild
// Node replaceChild(in Node newChild,in Node oldChild) raises(DOMException);
static void _replaceChild(Request& r, MethodParams& params) {
xmlNode& newChild=as_node(params, 0, "newChild must be node");
xmlNode& oldChild=as_node(params, 1, "oldChild must be node");
VXnode& vnode=GET_SELF(r, VXnode);
VXdoc& vxdoc=vnode.get_vxdoc();
xmlDoc& xmldoc=vxdoc.get_xmldoc();
xmlNode& selfNode=vnode.get_xmlnode();
if(newChild.doc!=&xmldoc)
throw Exception("xml.dom",
0,
"WRONG_DOCUMENT_ERR");
if(oldChild.doc!=&xmldoc)
throw Exception("xml.dom",
0,
"WRONG_DOCUMENT_ERR");
if(oldChild.parent!=&selfNode)
throw Exception("xml.dom",
0,
"NOT_FOUND_ERR");
xmlNode* refChild=oldChild.next;
xmlUnlinkNode(&oldChild);
xmlNode* retNode;
if(refChild)
retNode=xmlAddPrevSibling(refChild, &newChild);
else
retNode=xmlAddChild(&selfNode, &newChild);
// write out result
writeNode(r, vxdoc, retNode);
}