• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ofXml类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ofXml的典型用法代码示例。如果您正苦于以下问题:C++ ofXml类的具体用法?C++ ofXml怎么用?C++ ofXml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ofXml类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
	}
}
开发者ID:chuckleplant,项目名称:openFrameworks,代码行数:27,代码来源:ofXml.cpp


示例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");
 }
开发者ID:toruurakawa,项目名称:Climbing,代码行数:25,代码来源:BPSky.hpp


示例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]);
    }
}
开发者ID:charlesveasey,项目名称:vDome,代码行数:9,代码来源:projector.cpp


示例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();
}
开发者ID:m-theater,项目名称:vDome,代码行数:10,代码来源:render.cpp


示例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);
}
开发者ID:loudcube,项目名称:ofxGLWarper,代码行数:12,代码来源:ofxGLWarper.cpp


示例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");
    }
}
开发者ID:genekogan,项目名称:ofxControl,代码行数:15,代码来源:ofxControlPanel.cpp


示例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...

}
开发者ID:loudcube,项目名称:ofxGLWarper,代码行数:27,代码来源:ofxGLWarper.cpp


示例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());
			}
		}
	}
}
开发者ID:chuckleplant,项目名称:openFrameworks,代码行数:28,代码来源:ofXml.cpp


示例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();
}
开发者ID:8morikazuto,项目名称:openFrameworks,代码行数:8,代码来源:ofXml.cpp


示例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;	
}
开发者ID:BentleyBlanks,项目名称:ksApp,代码行数:17,代码来源:ofxFadeEffect.cpp


示例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;	
}
开发者ID:BentleyBlanks,项目名称:ksApp,代码行数:18,代码来源:ofxImageThing.cpp


示例12: saveSequencerToXml

void ofxControlPanel::saveSequencerToXml(ofXml &xml)
{
    if (sequencerMade)
    {
        ofXml xmlSequencer;
        xmlSequencer.addChild("Sequencer");
        xmlSequencer.setTo("Sequencer");
        sequencer->getXml(xmlSequencer);
        xml.addXml(xmlSequencer);
    }
}
开发者ID:genekogan,项目名称:ofxControl,代码行数:11,代码来源:ofxControlPanel.cpp


示例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");
    }
}
开发者ID:genekogan,项目名称:ofxControl,代码行数:14,代码来源:ofxControlPanel.cpp


示例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();
}
开发者ID:flair2005,项目名称:vDome,代码行数:17,代码来源:socket.cpp


示例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();
}
开发者ID:flair2005,项目名称:vDome,代码行数:12,代码来源:socket.cpp


示例16: saveXML

void Projector::saveXML(ofXml &xml) {
    // color
    xml.setAttribute("brightness", ofToString(roundTo(brightness, .001)));
    xml.setAttribute("contrast", ofToString(roundTo(contrast, .001)));
    xml.setAttribute("saturation", ofToString(roundTo(hue, .001)) +  "," + ofToString(roundTo(saturation, .001)) +  "," + ofToString(roundTo(lightness, .001))  );

    //camera
    xml.setAttribute("position", ofToString(roundTo(cameraPosition.x, .01)) +  "," + ofToString(roundTo(cameraPosition.y, .01)) +  "," + ofToString(roundTo(cameraPosition.z, .01)) );
    xml.setAttribute("orientation", ofToString(roundTo(cameraOrientation.x, .01)) +  "," + ofToString(roundTo(cameraOrientation.y, .01)) +  "," + ofToString(roundTo(cameraOrientation.z, .01)) );
    xml.setAttribute("fov", ofToString(roundTo(cameraFov, .01)));
    xml.setAttribute("offset", ofToString(roundTo(cameraOffset.x, .001)) +  "," + ofToString(roundTo(cameraOffset.y, .001)) );
    
    // plane
    plane.save(xml);
	curves.save(projectorStartingIndex);
    mask.save(projectorStartingIndex);    
}
开发者ID:charlesveasey,项目名称:vDome,代码行数:17,代码来源:projector.cpp


示例17: addXml

void ofXml::addXml( ofXml& xml, bool copyAll ) {
    
    Poco::XML::Node *n = 0;
    if(copyAll) {
        n = document->importNode(xml.getPocoDocument()->documentElement(), true);
    } else {
        if(xml.getPocoElement() == 0 || xml.getPocoElement() == xml.getPocoDocument()->documentElement()) {
            n = document->importNode(xml.getPocoDocument()->documentElement(), true);
        } else {
            n = document->importNode( xml.getPocoElement(), true);
        }
    }

    // we have an element, i.e. the document has child nodes
    // or we don't, so append it directly to the document
    if( element ) {
        element->appendChild(n);
    } else {
        document->appendChild(n);
    }
    
}
开发者ID:8morikazuto,项目名称:openFrameworks,代码行数:22,代码来源:ofXml.cpp


示例18: addClass

void KinectV2Classifier::setFromLearnXml(ofXml &xml)
{
    xml.setTo("LearnInfo");
    
    if (xml.exists("Classes")) {
        xml.setTo("Classes");
        if (xml.exists("Class[0]"))
        {
            xml.setTo("Class[0]");
            do {
                addClass(xml.getValue<string>("Name"));
            }
            while(xml.setToSibling());
            xml.setToParent();
        }
        xml.setToParent();
    }
    
    if (xml.exists("Ranges")) {
        xml.setTo("Ranges");
        if (xml.exists("Joint[0]"))
        {
            int idx = 0;
            xml.setTo("Joint[0]");
            do {
                min[idx] = xml.getValue<float>("Min");
                max[idx] = xml.getValue<float>("Max");
                idx++;
            }
            while(xml.setToSibling());
            xml.setToParent();
        }
        xml.setToParent();
    }
    
    if (xml.exists("Training")) {
        xml.setTo("Training");
        if (xml.exists("Entry[0]"))
        {
            xml.setTo("Entry[0]");
            do {
                double label = xml.getValue<double>("Label");
                vector<string> featureVectorS = ofSplitString(xml.getValue<string>("Features"), ",");
                vector<float> entry;
                entry.push_back(label);
                for (auto f : featureVectorS) {
                    entry.push_back(ofToFloat(f));
                }
                data.addEntry(entry);
            }
            while(xml.setToSibling());
            xml.setToParent();
        }
        xml.setToParent();
    }
    
    if (xml.exists("Model")) {
        xml.setTo("Model");
        string path = xml.getValue<string>("Path");
        svm.loadModel(path);
        trained = true;
        xml.setToParent();
    }
    xml.setToParent();
}
开发者ID:benmanw,项目名称:Kinect2Gesture,代码行数:65,代码来源:KinectV2Classifier.cpp


示例19: ofJoinString

void KinectV2Classifier::setLearnXml(ofXml &xml)
{
    // first save the classifier
    if (trained) {
        svm.saveModel(ofToDataPath("svmModel.dat"));
    }
    
    // event-parameter mappings
    xml.addChild("LearnInfo");
    xml.setTo("LearnInfo");
    
    // classes
    xml.addChild("Classes");
    xml.setTo("Classes");
    for (int i=0; i<classes.size(); i++) {
        ofXml xml_;
        xml_.addChild("Class");
        xml_.setTo("Class");
        xml_.addValue("Name", classes[i]);
        xml.addXml(xml_);
    }
    xml.setToParent();
    
    // ranges
    xml.addChild("Ranges");
    xml.setTo("Ranges");
    for (int i=0; i<min.size(); i++) {
        ofXml xml_;
        xml_.addChild("Joint");
        xml_.setTo("Joint");
        xml_.addValue("Min", min[i]);
        xml_.addValue("Max", max[i]);
        xml.addXml(xml_);
    }
    xml.setToParent();
    
    vector<vector<float> > & entries = data.getEntries();
    if (entries.size() > 0) {
        xml.addChild("Training");
        xml.setTo("Training");
        for (int i = 0; i < entries.size(); i++) {
            vector<string> featureStringV;
            for (int f=1; f<entries[i].size(); f++) {
                featureStringV.push_back(ofToString(entries[i][f]));
            }
            string featureString = ofJoinString(featureStringV, ",");
            double label = entries[i][0];
            ofXml xml_;
            xml_.addChild("Entry");
            xml_.setTo("Entry");
            xml_.addValue("Label", label);
            xml_.addValue("Features", featureString);
            xml.addXml(xml_);
        }
        xml.setToParent();
    }
    
    if (trained) {
        xml.addChild("Model");
        xml.setTo("Model");
        xml.addValue("Path", ofToDataPath("svmModel.dat"));
        xml.setToParent();
    }
    
    xml.setToParent();
}
开发者ID:benmanw,项目名称:Kinect2Gesture,代码行数:66,代码来源:KinectV2Classifier.cpp


示例20: saveXML

void Render::saveXML(ofXml &xml) {
    if (vsync)  xml.setAttribute("vsync", "on" );
    else        xml.setAttribute("vsync", "off" );

    xml.setAttribute("framerate", ofToString(framerate) );
}
开发者ID:m-theater,项目名称:vDome,代码行数:6,代码来源:render.cpp



注:本文中的ofXml类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ofstream类代码示例发布时间:2022-05-31
下一篇:
C++ ofVideoPlayer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap