void SaveXMLDoc(XMLDocument& doc, string fileName){ ofstream fileOut; fileOut.open(fileName.c_str()); if(!fileOut.good()){ cout << "Failed to open file " << fileName << " for saving.\n"; return; } string docContents = ""; for(auto iter = doc.contents.begin(); iter != doc.contents.end(); iter++){ docContents += iter->SaveElement(); docContents += "\n"; } fileOut << docContents; }
string XMLElement::SaveElement(string tabbing){ string save = tabbing + "<" + name; for(auto iter = attributes.begin(); iter != attributes.end(); iter++){ save = save + " " + iter->ToString(); } if(children.size() == 0){ save += "/>"; return save; } else{ save += ">\n"; for(auto iter = children.begin(); iter != children.end(); iter++){ save += (iter->SaveElement(tabbing + " ")); save += "\n"; } save = save + (tabbing + "</" + name + ">"); return save; } }
mat_ZZ getbasis(int n,int seed,vec_ZZ& phi,double bit=10) { initialize(); std::ostringstream fname; fname << getfname(n,seed,bit,0); mat_ZZ L; if (FileExists(fname)==true) { LoadLattice(L,fname.str()); fname << ".phi"; LoadElement(phi,fname.str()); } else { vec_ZZ phi; //n stands for index gen_idealsvpchallenge(L,n,to_ZZ(seed),phi); #ifdef _allow_cachefiles SaveLattice(L,fname.str()); fname << ".phi"; SaveElement(phi,fname.str()); #endif } return L; }
void FopLeader::read( const QDomElement e , qreal pagewidth) /* to be % width space */ { QDomNamedNodeMap attlist = e.attributes(); qreal border = 0; QStringList WI_rec; QStringList HI_rec; WI_rec << "content-width" << "width" << "leader-length"; HI_rec << "content-height" << "height" << "rule-thickness"; for (int i=0; i<attlist.count(); i++) { QDomNode nod = attlist.item(i); const QString valore = nod.nodeValue().toLower(); if (nod.nodeName().toLower() == "background-color") { bg = ColorFromFoString(valore); format.setBackground(QBrush(bg)); } if (nod.nodeName().toLower() == "color") { co = ColorFromFoString(valore); //////format.setBackground(QBrush(bg)); } if (nod.nodeName().toLower().startsWith("border-") && nod.nodeName().toLower().endsWith("-width") ) { if (valore.endsWith("%")) { border = 0.5; } else { border = qMax(border,FopInt(valore)); } } /* width */ if ( WI_rec.contains( nod.nodeName().toLower() ) ) { if (valore.endsWith("%")) { int percentual = valore.left( valore.length() - 1 ).toInt(); area.setWidth(pagewidth / 100. * percentual); format.setWidth ( area.width() ); } else { if (FopInt(valore) > 0) { area.setWidth(FopInt(valore)); format.setWidth ( area.width() ); } } } /* height */ if ( HI_rec.contains( nod.nodeName().toLower() ) ) { if (valore.endsWith("%")) { int percentual = valore.left( valore.length() - 1 ).toInt(); area.setHeight(pagewidth / 100. * percentual); format.setHeight ( area.height() ); } else { if (FopInt(valore) > 0) { area.setHeight (FopInt(valore)); format.setHeight ( area.height() ); } } } if ( nod.nodeName().toLower() == "space-before" || nod.nodeName().toLower() == "space-before.optimum" || nod.nodeName().toLower() == "margin-top" ) { /* top */ if (FopInt(nod.nodeValue()) > 0) { format.setTopMargin(FopInt(nod.nodeValue())); } } if ( nod.nodeName().toLower() == "space-after" || nod.nodeName().toLower() == "space-after.optimum" || nod.nodeName().toLower() == "margin-bottom" ) { /* top */ if (FopInt(nod.nodeValue()) > 0) { format.setBottomMargin(FopInt(nod.nodeValue())); } } if ( nod.nodeName().toLower() == "space-start" || nod.nodeName().toLower() == "end-indent" || nod.nodeName().toLower() == "margin-right" ) { /* right */ format.setRightMargin(FopInt(nod.nodeValue())); } if ( nod.nodeName().toLower() == "space-end" || nod.nodeName().toLower() == "start-indent" || nod.nodeName().toLower() == "margin-left" ) { /* left */ format.setLeftMargin(FopInt(nod.nodeValue())); } if (display.contains(nod.nodeValue())) { visibility = display.indexOf(nod.nodeValue()); } if (pattern.contains(nod.nodeValue())) { leaderpattern = pattern.indexOf(nod.nodeValue()); } } /* loop attributes */ if ( leaderpattern == 3 ) { area = QRectF(0,0,1,1); } ///////////qDebug() << "### leaderpattern ------- " << leaderpattern; ELoriginal = SaveElement(e); ///////format.setProperty(LeaderNummer,this); }