本文整理汇总了C++中ofXml类的典型用法代码示例。如果您正苦于以下问题:C++ ofXml类的具体用法?C++ ofXml怎么用?C++ ofXml使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofXml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ofSerialize
void ofSerialize(ofXml & xml, const ofAbstractParameter & parameter){
if(!parameter.isSerializable()){
return;
}
string name = parameter.getEscapedName();
if(name == ""){
name = "UnknownName";
}
ofXml child = xml.findFirst(name);
if(!child){
child = xml.appendChild(name);
ofLogVerbose("ofXml") << "creating group " << name;
}
if(parameter.type() == typeid(ofParameterGroup).name()){
const ofParameterGroup & group = static_cast <const ofParameterGroup &>(parameter);
ofLogVerbose("ofXml") << "group " << name;
for(auto & p: group){
ofSerialize(child, *p);
}
ofLogVerbose("ofXml") << "end group " << name;
}else{
string value = parameter.toString();
child.set(value);
}
}
示例2: saveToXML
void saveToXML() {
xml.clear();
xml.addChild("SKY");
xml.setTo("SKY");
for (auto it = stars.begin(); it != stars.end(); it++) {
ofVec2f p = it->getPosition();
int m = it->getMagnitude();
int id = it->getId();
ofXml star;
star.addChild("STAR");
star.setTo("STAR");
star.addChild("POSITION");
star.setTo("POSITION");
star.addValue("X", p.x);
star.addValue("Y", p.y);
star.setTo("../");
star.addValue("MAGNITUDE", m);
star.addValue("ID", id);
xml.addXml(star);
}
xml.save("mySettings.xml");
}
示例3: loadXML
void Projector::loadXML(ofXml &xml) {
string str;
if (xml.exists("[@resolution]")) {
str = xml.getAttribute("[@resolution]");
width = ofToFloat(ofSplitString(str, ",")[0]);
height = ofToFloat(ofSplitString(str, ",")[1]);
}
}
示例4: loadXML
void Render::loadXML(ofXml &xml) {
if (xml.exists("[@vsync]")) {
string str = ofToString( xml.getAttribute("[@vsync]") );
if (str == "on") vsync = true;
else vsync = false;
}
if (xml.exists("[@framerate]"))
framerate = ofToInt( xml.getAttribute("[@framerate]") );
setup();
}
示例5: saveToXml
//--------------------------------------------------------------
void ofxGLWarper::saveToXml(ofXml &XML, const string& warperID){
XML.removeChild(warperID);//if child doesn't exist yet, it's ok.
auto c = XML.appendChild(warperID);
for(int i =0; i<4; i++){
auto nc = c.appendChild("corner");
nc.appendChild("x").set(corners[i]->x);
nc.appendChild("y").set(corners[i]->y);
}
c.appendChild("active").set(active);
}
示例6: loadSequencerFromXml
void ofxControlPanel::loadSequencerFromXml(ofXml &xml)
{
if (xml.exists("Sequencer"))
{
xml.setTo("Sequencer");
if (!sequencerMade) {
createSequencer();
}
sequencer->setFromXml(xml);
xml.setToParent();
}
else {
ofLog(OF_LOG_ERROR, "No sequencer found in preset");
}
}
示例7: loadFromXml
//--------------------------------------------------------------
void ofxGLWarper::loadFromXml(ofXml &XML, const string& warperID){
auto c = XML.getChild(warperID);
if(!c){
ofLog(OF_LOG_ERROR, "ofxGLWarper : incorrrect xml formating. No \"" + warperID + "\" tag found");
return;
}
if (c.find("corner").size()<4 ) {
ofLog(OF_LOG_ERROR, "ofxGLWarper : incorrrect xml formating. less than 4 \"corner\" tags found");
return;
}
auto cor = c.getChildren("corner");
int i = 0;
for(auto& ch: cor){
if(i<4){
corners[i] = glm::vec2(ch.getChild("x").getFloatValue(), ch.getChild("y").getFloatValue());
}
i++;
}
this->activate(c.getChild("active").getBoolValue());
processMatrices();
//ofLog(OF_LOG_WARNING, "ofxGLWarper : xml object loaded OK!."); // Since the method works, this can be quiet...
}
示例8: ofDeserialize
void ofDeserialize(const ofXml & xml, ofAbstractParameter & parameter){
if(!parameter.isSerializable()){
return;
}
string name = parameter.getEscapedName();
ofXml child = xml.findFirst(name);
if(child){
if(parameter.type() == typeid(ofParameterGroup).name()){
ofParameterGroup & group = static_cast <ofParameterGroup &>(parameter);
for(auto & p: group){
ofDeserialize(child, *p);
}
}else{
if(parameter.type() == typeid(ofParameter <int> ).name()){
parameter.cast <int>() = child.getIntValue();
}else if(parameter.type() == typeid(ofParameter <float> ).name()){
parameter.cast <float>() = child.getFloatValue();
}else if(parameter.type() == typeid(ofParameter <bool> ).name()){
parameter.cast <bool>() = child.getBoolValue();
}else if(parameter.type() == typeid(ofParameter <string> ).name()){
parameter.cast <string>() = child.getValue();
}else{
parameter.fromString(child.getValue());
}
}
}
}
示例9:
ofXml::ofXml( const ofXml& rhs ) {
document = new Poco::XML::Document();
Poco::XML::Node *n = document->importNode(rhs.getPocoDocument()->documentElement(), true);
document->appendChild(n);
element = document->documentElement();
}
示例10:
bool ofxFadeEffect::settings::deserialize( ofXml X )
{
ofParameterGroup G;
G.setName("fxShake_Settings");
X.deserialize(G);
bool bSuc = X.exists(G.getName());
if(bSuc)
{
alphaFrom = G.getInt("alphaFrom");
alphaTo = G.getInt("alphaTo");
time = G.getFloat("time");
delay = G.getFloat("delay");
}
return bSuc;
}
示例11:
bool ofxImageThing::settings::deserialize( ofXml X )
{
ofParameterGroup G;
G.setName("ofxImageThing_Settings");
X.deserialize(G);
bool bSuc = X.exists(G.getName());
if(bSuc)
{
imgPath= G.getString("imgPath");
imgColor = G.getColor("imgColor");
width = G.getFloat("width");
height = G.getFloat("height");
imgAlpha = G.getFloat("imgAlpha");
}
return bSuc;
}
示例12: saveSequencerToXml
void ofxControlPanel::saveSequencerToXml(ofXml &xml)
{
if (sequencerMade)
{
ofXml xmlSequencer;
xmlSequencer.addChild("Sequencer");
xmlSequencer.setTo("Sequencer");
sequencer->getXml(xmlSequencer);
xml.addXml(xmlSequencer);
}
}
示例13: setFromXml
void ofxControlPanel::setFromXml(ofXml &xml)
{
ofxControlWidget::setFromXml(xml);
if (xml.exists("Sequencer"))
{
if (!sequencerMade) {
createSequencer();
}
sequencer->setFromXml(xml);
}
else {
ofLog(OF_LOG_ERROR, "No sequencer found in preset");
}
}
示例14: loadXML
void Socket::loadXML(ofXml &xml) {
if (xml.exists("socket[@enabled]")) {
string str = ofToString(xml.getAttribute("socket[@enabled]"));
if (str == "on") enabled = true;
else enabled = false;
}
if (xml.exists("socket[@host]"))
host = ofToString( xml.getAttribute("socket[@host]") );
if (xml.exists("socket[@send]"))
send = ofToInt( xml.getAttribute("socket[@send]") );
if (xml.exists("socket[@receive]"))
receive = ofToInt( xml.getAttribute("socket[@receive]") );
if (enabled)
setup();
}
示例15: saveXML
void Socket::saveXML(ofXml &xml) {
xml.setTo("socket");
if (enabled) xml.setAttribute("enabled", "on");
else xml.setAttribute("enabled", "off");
xml.setAttribute("host", ofToString(host));
xml.setAttribute("send", ofToString(send));
xml.setAttribute("receive", ofToString(receive));
xml.setToParent();
}