Add multiremain class.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3149
This commit is contained in:
parent
e4ab181b7b
commit
fb13f8dcbc
2 changed files with 64 additions and 4 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: setup.h,v 1.34 2008-03-19 20:35:16 qbix79 Exp $ */
|
||||
/* $Id: setup.h,v 1.35 2008-04-29 08:23:16 qbix79 Exp $ */
|
||||
|
||||
#ifndef DOSBOX_SETUP_H
|
||||
#define DOSBOX_SETUP_H
|
||||
|
@ -241,6 +241,7 @@ public:
|
|||
};
|
||||
|
||||
class Prop_multival;
|
||||
class Prop_multival_remain;
|
||||
class Section_prop:public Section {
|
||||
private:
|
||||
std::list<Property*> properties;
|
||||
|
@ -255,6 +256,7 @@ public:
|
|||
Prop_hex* Add_hex(std::string const& _propname, Property::Changeable::Value when, Hex _value=0);
|
||||
// void Add_double(char const * const _propname, double _value=0.0); P
|
||||
Prop_multival *Add_multi(std::string const& _propname, Property::Changeable::Value when,std::string const& sep);
|
||||
Prop_multival_remain *Add_multiremain(std::string const& _propname, Property::Changeable::Value when,std::string const& sep);
|
||||
|
||||
Property* Get_prop(int index);
|
||||
int Get_int(std::string const& _propname) const;
|
||||
|
@ -263,6 +265,7 @@ public:
|
|||
Hex Get_hex(std::string const& _propname) const;
|
||||
double Get_double(std::string const& _propname) const;
|
||||
Prop_multival* Get_multival(std::string const& _propname) const;
|
||||
Prop_multival_remain* Get_multivalremain(std::string const& _propname) const;
|
||||
void HandleInputline(std::string const& gegevens);
|
||||
void PrintData(FILE* outfile) const;
|
||||
virtual std::string GetPropValue(std::string const& _property) const;
|
||||
|
@ -271,6 +274,7 @@ public:
|
|||
};
|
||||
|
||||
class Prop_multival:public Property{
|
||||
protected:
|
||||
Section_prop* section;
|
||||
std::string seperator;
|
||||
public:
|
||||
|
@ -279,10 +283,18 @@ public:
|
|||
}
|
||||
Section_prop *GetSection() { return section; }
|
||||
const Section_prop *GetSection() const { return section; }
|
||||
void SetValue(std::string const& input);
|
||||
virtual void SetValue(std::string const& input);
|
||||
virtual const std::vector<Value>& GetValues() const;
|
||||
}; //value bevat totale string. setvalue zet elk van de sub properties en checked die.
|
||||
|
||||
class Prop_multival_remain:public Prop_multival{
|
||||
public:
|
||||
Prop_multival_remain(std::string const& _propname, Changeable::Value when,std::string const& sep):Prop_multival(_propname,when,sep){ }
|
||||
|
||||
virtual void SetValue(std::string const& input);
|
||||
};
|
||||
|
||||
|
||||
class Section_line: public Section{
|
||||
public:
|
||||
Section_line(std::string const& _sectionname):Section(_sectionname){}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: setup.cpp,v 1.47 2008-03-19 20:35:18 qbix79 Exp $ */
|
||||
/* $Id: setup.cpp,v 1.48 2008-04-29 08:23:16 qbix79 Exp $ */
|
||||
|
||||
#include "dosbox.h"
|
||||
#include "cross.h"
|
||||
|
@ -273,6 +273,40 @@ void Prop_hex::SetValue(std::string const& input){
|
|||
SetVal(val,false,true);
|
||||
}
|
||||
|
||||
//TODO checkvalue stuff
|
||||
void Prop_multival_remain::SetValue(std::string const& input) {
|
||||
Value val(input,Value::V_STRING);
|
||||
SetVal(val,false,true);
|
||||
|
||||
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;
|
||||
|
||||
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 = "";
|
||||
}
|
||||
p->SetValue(in);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO checkvalue stuff
|
||||
void Prop_multival::SetValue(std::string const& input) {
|
||||
Value val(input,Value::V_STRING);
|
||||
|
@ -300,6 +334,7 @@ void Prop_multival::SetValue(std::string const& input) {
|
|||
p->SetValue(in);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Value>& Property::GetValues() const {
|
||||
return suggested_values;
|
||||
}
|
||||
|
@ -360,7 +395,11 @@ Prop_multival* Section_prop::Add_multi(std::string const& _propname, Property::C
|
|||
properties.push_back(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
Prop_multival_remain* Section_prop::Add_multiremain(std::string const& _propname, Property::Changeable::Value when,std::string const& sep) {
|
||||
Prop_multival_remain* test = new Prop_multival_remain(_propname,when,sep);
|
||||
properties.push_back(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
int Section_prop::Get_int(string const&_propname) const {
|
||||
for(const_it tel=properties.begin();tel!=properties.end();tel++){
|
||||
|
@ -397,6 +436,15 @@ Prop_multival* Section_prop::Get_multival(string const& _propname) const {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Prop_multival_remain* Section_prop::Get_multivalremain(string const& _propname) const {
|
||||
for(const_it tel=properties.begin();tel!=properties.end();tel++){
|
||||
if((*tel)->propname==_propname){
|
||||
Prop_multival_remain* val = dynamic_cast<Prop_multival_remain*>((*tel));
|
||||
if(val) return val; else return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Property* Section_prop::Get_prop(int index){
|
||||
for(it tel=properties.begin();tel!=properties.end();tel++){
|
||||
if(!index--) return (*tel);
|
||||
|
|
Loading…
Add table
Reference in a new issue