コード例 #1
0
ファイル: setup.cpp プロジェクト: roman-murashov/dosbox-x
//TODO checkvalue stuff
bool Prop_multival::SetValue(std::string const& input,bool init) {
	Value val(input,Value::V_STRING);
	bool retval = SetVal(val,false,true,init);

	std::string local(input);
	int i = 0;
	Property *p = section->Get_prop(0);
	//No properties in this section. do nothing
	if(!p) return false;
	string::size_type loc = string::npos;
	while( (p = section->Get_prop(i++)) ) {
		//trim leading seperators
		loc = local.find_first_not_of(seperator);
		if(loc != string::npos) local.erase(0,loc);
		loc = local.find_first_of(seperator);
		string in = "";//default value
		if(loc != string::npos) { //seperator found
			in = local.substr(0,loc);
			local.erase(0,loc+1);
		} else if(local.size()) { //last argument
			in = local;
			local = "";
		}
		//Test Value. If it fails set default
		Value valtest (in,p->Get_type());
		if(!p->CheckValue(valtest,true)) {
			make_default_value();
			return false;
		}
		p->SetValue(in);

	}
	return retval;
}
コード例 #2
0
ファイル: setup.cpp プロジェクト: roman-murashov/dosbox-x
//TODO checkvalue stuff
bool Prop_multival_remain::SetValue(std::string const& input,bool init) {
	Value val(input,Value::V_STRING);
	bool retval = SetVal(val,false,true,init);

	std::string local(input);
	int i = 0,number_of_properties = 0;
	Property *p = section->Get_prop(0);
	//No properties in this section. do nothing
	if(!p) return false;
	
	while( (section->Get_prop(number_of_properties)) )
		number_of_properties++;
	
	string::size_type loc = string::npos;
	while( (p = section->Get_prop(i++)) ) {
		//trim leading seperators
		loc = local.find_first_not_of(seperator);
		if(loc != string::npos) local.erase(0,loc);
		loc = local.find_first_of(seperator);
		string in = "";//default value
		/* when i == number_of_properties add the total line. (makes more then 
		 * one string argument possible for parameters of cpu) */
		if(loc != string::npos && i < number_of_properties) { //seperator found 
			in = local.substr(0,loc);
			local.erase(0,loc+1);
		} else if(local.size()) { //last argument or last property
			in = local;
			local = "";
		}
		//Test Value. If it fails set default
		Value valtest (in,p->Get_type());
		if(!p->CheckValue(valtest,true)) {
			make_default_value();
			return false;
		}
		p->SetValue(in);
	}
	return retval;
}