本文整理汇总了C++中XML_Node::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XML_Node::addChild方法的具体用法?C++ XML_Node::addChild怎么用?C++ XML_Node::addChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML_Node
的用法示例。
在下文中一共展示了XML_Node::addChild方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeDefaultXMLTree
XML_Node* MetalSHEelectrons::makeDefaultXMLTree()
{
XML_Node* xtop = new XML_Node("ctml", 0);
XML_Node& xv = xtop->addChild("validate");
xv.addAttribute("reactions", "yes");
xv.addAttribute("species", "yes");
XML_Node& xp = xtop->addChild("phase");
xp.addAttribute("dim", "3");
xp.addAttribute("id", "MetalSHEelectrons");
XML_Node& xe = xp.addChild("elementArray", "E");
xe.addAttribute("datasrc", "elements.xml");
XML_Node& xs = xp.addChild("speciesArray", "she_electron");
xs.addAttribute("datasrc", "#species_Metal_SHEelectrons");
XML_Node& xt = xp.addChild("thermo");
xt.addAttribute("model", "metalSHEelectrons");
XML_Node& xtr = xp.addChild("transport");
xtr.addAttribute("model", "none");
XML_Node& xk = xp.addChild("kinetics");
xk.addAttribute("model", "none");
XML_Node& xsd = xtop->addChild("speciesData");
xsd.addAttribute("id", "species_Metal_SHEelectrons");
XML_Node& xsp = xsd.addChild("species");
xsp.addAttribute("name", "she_electron");
xsp.addChild("atomArray", "E:1");
xsp.addChild("charge", "-1");
XML_Node& xspt = xsp.addChild("thermo");
XML_Node& xN1 = xspt.addChild("NASA");
xN1.addAttribute("Tmax", "1000.");
xN1.addAttribute("Tmin", "200.");
xN1.addAttribute("P0", "100000.0");
XML_Node& xF1 = xsd.addChild("floatArray",
"1.172165560E+00, 3.990260375E-03, -9.739075500E-06, "
"1.007860470E-08, -3.688058805E-12, -4.589675865E+02, 3.415051190E-01");
xF1.addAttribute("name", "coeffs");
xF1.addAttribute("size", "7");
XML_Node& xN2 = xspt.addChild("NASA");
xN2.addAttribute("Tmax", "6000.");
xN2.addAttribute("Tmin", "1000.");
xN2.addAttribute("P0", "100000.0");
XML_Node& xF2 = xsd.addChild("floatArray",
"1.466432895E+00, 4.133039835E-04, -7.320116750E-08, 7.705017950E-12,"
"-3.444022160E-16, -4.065327985E+02, -5.121644350E-01");
xF2.addAttribute("name", "coeffs");
xF2.addAttribute("size", "7");
return xtop;
}
示例2: ecomp
//====================================================================================================================
FixedChemPotSSTP::FixedChemPotSSTP(std::string Ename, doublereal val) :
SingleSpeciesTP(),
chemPot_(0.0)
{
std::string pname = Ename + "Fixed";
setID(pname);
setName(pname);
setNDim(3);
addUniqueElement(Ename, -12345.);
freezeElements();
vector_fp ecomp(nElements(), 0.0);
ecomp[0] = 1.0;
double chrg = 0.0;
SpeciesThermo* spth = new SimpleThermo();
setSpeciesThermo(spth);
addUniqueSpecies(pname, &ecomp[0], chrg, 0.0);
double c[4];
c[0] = 298.15;
c[1] = val;
c[2] = 0.0;
c[3] = 0.0;
m_spthermo->install(pname, 0, SIMPLE, c, 0.0, 1.0E30, OneAtm);
freezeSpecies();
initThermo();
m_p0 = OneAtm;
m_tlast = 298.15;
setChemicalPotential(val);
// Create an XML_Node entry for this species
XML_Node* s = new XML_Node("species", 0);
s->addAttribute("name", pname);
std::string aaS = Ename + ":1";
s->addChild("atomArray", aaS);
XML_Node& tt = s->addChild("thermo");
XML_Node& ss = tt.addChild("Simple");
ss.addAttribute("Pref", "1 bar");
ss.addAttribute("Tmax", "5000.");
ss.addAttribute("Tmin", "100.");
ss.addChild("t0", "298.15");
ss.addChild("cp0", "0.0");
std::string sval = fp2str(val);
ss.addChild("h", sval);
ss.addChild("s", "0.0");
saveSpeciesData(0, s);
delete s;
s = 0;
}
示例3: addFloatArray
void addFloatArray(XML_Node& node, const std::string& title, const size_t n,
const doublereal* const vals, const std::string& units,
const std::string& type,
const doublereal minval, const doublereal maxval)
{
std::string v = "";
for (size_t i = 0; i < n; i++) {
v += fp2str(vals[i],FP_Format);
if (i == n-1) {
v += "\n";
} else if (i > 0 && (i+1) % 3 == 0) {
v += ",\n";
} else {
v += ", ";
}
}
XML_Node& f = node.addChild("floatArray",v);
f.addAttribute("title",title);
if (type != "") {
f.addAttribute("type",type);
}
f.addAttribute("size", double(n));
if (units != "") {
f.addAttribute("units",units);
}
if (minval != Undef) {
f.addAttribute("min",minval);
}
if (maxval != Undef) {
f.addAttribute("max",maxval);
}
}
示例4: save
void OutletRes1D::
save(XML_Node& o, doublereal* soln) {
XML_Node& outlt = o.addChild("domain");
outlt.addAttribute("id",id());
outlt.addAttribute("points",1);
outlt.addAttribute("type","outletres");
outlt.addAttribute("components",nComponents());
}
示例5: main
int main()
{
XML_Document pars;
pars.addDecleration();
XML_Node files;
XML_Attrib files_attrib;
pars.addNode(files, "Files");
files.addAttribute(files_attrib, "dummy", "foobar.com");
XML_Node file, path, name;
for(int i=0; i<10; ++i)
{
files.addChild(file, "File");
file.addChild(path, "Path", "File_Path");
file.addChild(name, "Name", "File_Name");
cout << file.name() << " -> " << file.value() << endl;
cout << path.name() << " -> " << path.value() << endl;
cout << name.name() << " -> " << name.value() << endl;
}
file.removeChild(name);
pars.save("example2.xml");
return 0;
// xml_document<> doc;
// xml_node<>* decl = doc.allocate_node(node_declaration);
// decl->append_attribute(doc.allocate_attribute("version", "1.0"));
// decl->append_attribute(doc.allocate_attribute("encoding", "UTF-8"));
// doc.append_node(decl);
// xml_node<> *files = doc.allocate_node(node_element, "Files");
// doc.append_node(files);
// xml_attribute<> *attr = doc.allocate_attribute("dummy", "google.com");
// files->append_attribute(attr);
// for(int i = 0;i<10;++i)
// {
// xml_node<> *file = doc.allocate_node(node_element, "File");
// files->append_node(file);
// xml_node<> *path = doc.allocate_node(node_element, "Path","File_path");
// file->append_node(path);
// xml_node<> *name = doc.allocate_node(node_element, "Name","File_name");
// file->append_node(name);
// }
// std::ofstream myfile;
// myfile.open ("example.xml");
// myfile << doc;
// //print(std::cout, doc, 0);
// return 0;
};
示例6: addString
void addString(XML_Node& node, const std::string& titleString,
const std::string& valueString,
const std::string& typeString)
{
XML_Node& f = node.addChild("string", valueString);
f.addAttribute("title", titleString);
if (typeString != "") {
f.addAttribute("type", typeString);
}
}
示例7: addInteger
void addInteger(XML_Node& node, const std::string& title, const int val,
const std::string& units, const std::string& type)
{
XML_Node& f = node.addChild(title, val);
f.addAttribute("vtype", "integer");
if (type != "") {
f.addAttribute("type",type);
}
if (units != "") {
f.addAttribute("units",units);
}
}
示例8: addFloat
void addFloat(XML_Node& node, const std::string& title,
const doublereal val, const std::string& units,
const std::string& type, const doublereal minval,
const doublereal maxval)
{
XML_Node& f = node.addChild(title, val, FP_Format);
if (type != "") {
f.addAttribute("type",type);
}
if (units != "") {
f.addAttribute("units",units);
}
f.addAttribute("vtype", "float");
if (minval != Undef) {
f.addAttribute("min",minval);
}
if (maxval != Undef) {
f.addAttribute("max",maxval);
}
}
示例9: addNamedFloatArray
void addNamedFloatArray(XML_Node& node, const std::string& name, const size_t n,
const doublereal* const vals, const std::string units,
const std::string type, const doublereal minval,
const doublereal maxval)
{
std::string v = "";
for (size_t i = 0; i < n; i++) {
v += fp2str(vals[i],FP_Format);
if (i == n-1) {
v += "\n";
} else if (i > 0 && (i+1) % 3 == 0) {
v += ",\n";
} else {
v += ", ";
}
}
XML_Node& f = node.addChild(name, v);
if (type != "") {
f.addAttribute("type",type);
}
/*
* Add vtype, which indicates the type of the value. Here we specify it as a list of floats separated
* by commas, with a length given by size attribute.
*/
f.addAttribute("vtype", "floatArray");
f.addAttribute("size", n);
if (units != "") {
f.addAttribute("units", units);
}
if (minval != Undef) {
f.addAttribute("min", minval);
}
if (maxval != Undef) {
f.addAttribute("max", maxval);
}
}