예제 #1
0
void ofXml::serialize(const ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	string name = parameter.getEscapedName();
	if(name=="") name="UnknownName";
	if(parameter.type()==typeid(ofParameterGroup).name()){
		const ofParameterGroup & group = static_cast<const ofParameterGroup&>(parameter);
		if(!exists(name)){
			addChild(name);
			ofLogVerbose("ofXml") << "creating group " << name;
		}
		setTo(name);
		ofLogVerbose("ofXml") << "group " << name;
		for(int i=0;i<group.size();i++){
			serialize(group.get(i));
		}
		ofLogVerbose("ofXml") << "end group " << name;
		setToParent();
	}else{
		string value = parameter.toString();
		if(!exists(name)){
			addChild(name);
			ofLogVerbose("ofXml") << "creating tag " << name;
		}
		ofLogVerbose("ofXml") << "setting tag " << name << ": " << value;
		setValue(name,value);
	}
}
예제 #2
0
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);
	}
}
void ofxOscSender::appendParameter( ofxOscMessage & msg, const ofAbstractParameter & parameter, string address){
	msg.setAddress(address+parameter.getEscapedName());
	if(parameter.type()==typeid(ofParameter<int>).name()){
		msg.addIntArg(parameter.cast<int>());
	}else if(parameter.type()==typeid(ofParameter<float>).name()){
		msg.addFloatArg(parameter.cast<float>());
	}else if(parameter.type()==typeid(ofParameter<bool>).name()){
		msg.addIntArg(parameter.cast<bool>());
	}else{
		msg.addStringArg(parameter.toString());
	}
}
예제 #4
0
void ofxXmlSettings::serialize(const ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	string name = parameter.getEscapedName();
	if(name=="") name="UnknownName";
	if(parameter.type()==typeid(ofParameterGroup).name()){
		const ofParameterGroup & group = static_cast<const ofParameterGroup&>(parameter);
		if(!tagExists(name)) addTag(name);
		pushTag(name);
		for(int i=0;i<group.size();i++){
			serialize(group.get(i));
		}
		popTag();
	}else{
		string value = parameter.toString();
		if(!tagExists(name))
			addValue(name,value);
		else
			setValue(name,value);
	}
}