/[svn]/linuxsampler/trunk/src/drivers/DeviceParameter.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/DeviceParameter.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 212 by schoenebeck, Wed Jul 28 14:17:29 2004 UTC revision 214 by schoenebeck, Sat Aug 14 23:00:44 2004 UTC
# Line 43  namespace LinuxSampler { Line 43  namespace LinuxSampler {
43          return atof(val.c_str()); // TODO: format check is missing          return atof(val.c_str()); // TODO: format check is missing
44      }      }
45    
46        static String __parse_string(String val) {
47            // if string is encapsulated into apostrophes or quotation marks, then remove those apostrophes / quotation marks
48            if (val.size()) {
49                char cBegin = val[0];
50                char cEnd   = val[val.size() - 1];
51                if ( (cBegin == '\'' && cEnd == '\'') || (cBegin == '\"' && cEnd == '\"') ) {
52                    val = val.substr(1, val.size() - 2);
53                }
54            }
55            return val;
56        }
57    
58      static std::vector<String> __parse_strings(String val) throw (LinuxSamplerException) {      static std::vector<String> __parse_strings(String val) throw (LinuxSamplerException) {
59          std::vector<String> vS;          std::vector<String> vS;
60    
61          // if there's only a single value, then we also allow to give it without being encapsulted into apostrophes          // if there's only a single value, then we also allow to give it without being encapsulated into apostrophes
62          if (val.find("\'") == String::npos && val.find("\"") == String::npos) {          if (val.find("\'") == String::npos && val.find("\"") == String::npos) {
63              vS.push_back(val);              vS.push_back(val);
64          }          }
# Line 104  namespace LinuxSampler { Line 116  namespace LinuxSampler {
116      }      }
117    
118      String DeviceRuntimeParameterBool::Value() {      String DeviceRuntimeParameterBool::Value() {
119          return (ValueAsBool()) ? "TRUE" : "FALSE";          return (ValueAsBool()) ? "true" : "false";
120      }      }
121    
122      void DeviceRuntimeParameterBool::SetValue(String val) throw (LinuxSamplerException) {      void DeviceRuntimeParameterBool::SetValue(String val) throw (LinuxSamplerException) {
123          if (Fix()) throw LinuxSamplerException("Device parameter is read only");          if (Fix()) throw LinuxSamplerException("Device parameter is read only");
124          int b = __parse_bool(val);          int b = __parse_bool(val);
         OnSetValue(b);  
125          SetValue(b);          SetValue(b);
126      }      }
127    
# Line 118  namespace LinuxSampler { Line 129  namespace LinuxSampler {
129          return bVal;          return bVal;
130      }      }
131    
132      void DeviceRuntimeParameterBool::SetValue(bool b) {      void DeviceRuntimeParameterBool::SetValue(bool b) throw (LinuxSamplerException) {
133            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
134            OnSetValue(b);
135          bVal = b;          bVal = b;
136      }      }
137    
# Line 188  namespace LinuxSampler { Line 201  namespace LinuxSampler {
201              }              }
202              if (!valid) throw LinuxSamplerException("Invalid device parameter value: not in set of possible values");              if (!valid) throw LinuxSamplerException("Invalid device parameter value: not in set of possible values");
203          }          }
         OnSetValue(i);  
204          SetValue(i);          SetValue(i);
205      }      }
206    
# Line 196  namespace LinuxSampler { Line 208  namespace LinuxSampler {
208          return iVal;          return iVal;
209      }      }
210    
211      void DeviceRuntimeParameterInt::SetValue(int i) {      void DeviceRuntimeParameterInt::SetValue(int i) throw (LinuxSamplerException) {
212            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
213            OnSetValue(i);
214          iVal = i;          iVal = i;
215      }      }
216    
# Line 266  namespace LinuxSampler { Line 280  namespace LinuxSampler {
280              }              }
281              if (!valid) throw LinuxSamplerException("Invalid device parameter value: not in set of possible values");              if (!valid) throw LinuxSamplerException("Invalid device parameter value: not in set of possible values");
282          }          }
         OnSetValue(f);  
283          SetValue(f);          SetValue(f);
284      }      }
285    
# Line 274  namespace LinuxSampler { Line 287  namespace LinuxSampler {
287          return fVal;          return fVal;
288      }      }
289    
290      void DeviceRuntimeParameterFloat::SetValue(float f) {      void DeviceRuntimeParameterFloat::SetValue(float f) throw (LinuxSamplerException) {
291            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
292            OnSetValue(f);
293          fVal = f;          fVal = f;
294      }      }
295    
# Line 318  namespace LinuxSampler { Line 333  namespace LinuxSampler {
333      }      }
334    
335      String DeviceRuntimeParameterString::Value() {      String DeviceRuntimeParameterString::Value() {
336          return sVal;          return "\'" + ValueAsString() + "\'";
337      }      }
338    
339      void DeviceRuntimeParameterString::SetValue(String val) throw (LinuxSamplerException) {      void DeviceRuntimeParameterString::SetValue(String val) throw (LinuxSamplerException) {
340          if (Fix()) throw LinuxSamplerException("Device parameter is read only");          if (Fix()) throw LinuxSamplerException("Device parameter is read only");
341            SetValueAsString(__parse_string(val));
342        }
343    
344        String DeviceRuntimeParameterString::ValueAsString() {
345            return sVal;
346        }
347    
348        void DeviceRuntimeParameterString::SetValueAsString(String val) throw (LinuxSamplerException) {
349            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
350          if (val.find("\'") != String::npos) throw LinuxSamplerException("Character -> \' <- not allowed");          if (val.find("\'") != String::npos) throw LinuxSamplerException("Character -> \' <- not allowed");
351          if (val.find("\"") != String::npos) throw LinuxSamplerException("Character -> \" <- not allowed");          if (val.find("\"") != String::npos) throw LinuxSamplerException("Character -> \" <- not allowed");
352          OnSetValue(val);          OnSetValue(val);
# Line 382  namespace LinuxSampler { Line 406  namespace LinuxSampler {
406      void DeviceRuntimeParameterStrings::SetValue(String val) throw (LinuxSamplerException) {      void DeviceRuntimeParameterStrings::SetValue(String val) throw (LinuxSamplerException) {
407          if (Fix()) throw LinuxSamplerException("Device parameter is read only");          if (Fix()) throw LinuxSamplerException("Device parameter is read only");
408          std::vector<String> vS = __parse_strings(val);          std::vector<String> vS = __parse_strings(val);
         OnSetValue(vS);  
409          SetValue(vS);          SetValue(vS);
410      }      }
411    
# Line 390  namespace LinuxSampler { Line 413  namespace LinuxSampler {
413          return sVals;          return sVals;
414      }      }
415    
416      void DeviceRuntimeParameterStrings::SetValue(std::vector<String> vS) {      void DeviceRuntimeParameterStrings::SetValue(std::vector<String> vS) throw (LinuxSamplerException) {
417            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
418            OnSetValue(vS);
419          sVals = vS;          sVals = vS;
420      }      }
421    
# Line 465  namespace LinuxSampler { Line 490  namespace LinuxSampler {
490      optional<String> DeviceCreationParameterBool::Default(std::map<String,String> Parameters) {      optional<String> DeviceCreationParameterBool::Default(std::map<String,String> Parameters) {
491          optional<bool> defaultval = DefaultAsBool(Parameters);          optional<bool> defaultval = DefaultAsBool(Parameters);
492          if (!defaultval) return optional<String>::nothing;          if (!defaultval) return optional<String>::nothing;
493          return (*defaultval) ? "TRUE" : "FALSE";          return (*defaultval) ? "true" : "false";
494      }      }
495    
496      optional<String> DeviceCreationParameterBool::RangeMin(std::map<String,String> Parameters) {      optional<String> DeviceCreationParameterBool::RangeMin(std::map<String,String> Parameters) {
# Line 481  namespace LinuxSampler { Line 506  namespace LinuxSampler {
506      }      }
507    
508      String DeviceCreationParameterBool::Value() {      String DeviceCreationParameterBool::Value() {
509          return (ValueAsBool()) ? "TRUE" : "FALSE";          return (ValueAsBool()) ? "true" : "false";
510      }      }
511    
512      void DeviceCreationParameterBool::SetValue(String val) throw (LinuxSamplerException) {      void DeviceCreationParameterBool::SetValue(String val) throw (LinuxSamplerException) {
513          if (Fix()) throw LinuxSamplerException("Device parameter is read only");          if (Fix()) throw LinuxSamplerException("Device parameter is read only");
514          int b = __parse_bool(val);          int b = __parse_bool(val);
         OnSetValue(b);  
515          SetValue(b);          SetValue(b);
516      }      }
517    
# Line 495  namespace LinuxSampler { Line 519  namespace LinuxSampler {
519          return bVal;          return bVal;
520      }      }
521    
522      void DeviceCreationParameterBool::SetValue(bool b) {      void DeviceCreationParameterBool::SetValue(bool b) throw (LinuxSamplerException) {
523            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
524            OnSetValue(b);
525          bVal = b;          bVal = b;
526      }      }
527    
# Line 580  namespace LinuxSampler { Line 606  namespace LinuxSampler {
606              }              }
607              if (!valid) throw LinuxSamplerException("Invalid Device parameter value: not in set of possible values");              if (!valid) throw LinuxSamplerException("Invalid Device parameter value: not in set of possible values");
608          }*/          }*/
         OnSetValue(i);  
609          SetValue(i);          SetValue(i);
610      }      }
611    
# Line 588  namespace LinuxSampler { Line 613  namespace LinuxSampler {
613          return iVal;          return iVal;
614      }      }
615    
616      void DeviceCreationParameterInt::SetValue(int i) {      void DeviceCreationParameterInt::SetValue(int i) throw (LinuxSamplerException) {
617            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
618            OnSetValue(i);
619          iVal = i;          iVal = i;
620      }      }
621    
# Line 673  namespace LinuxSampler { Line 700  namespace LinuxSampler {
700              }              }
701              if (!valid) throw LinuxSamplerException("Invalid Device parameter value: not in set of possible values");              if (!valid) throw LinuxSamplerException("Invalid Device parameter value: not in set of possible values");
702          }*/          }*/
         OnSetValue(f);  
703          SetValue(f);          SetValue(f);
704      }      }
705    
# Line 681  namespace LinuxSampler { Line 707  namespace LinuxSampler {
707          return fVal;          return fVal;
708      }      }
709    
710      void DeviceCreationParameterFloat::SetValue(float f) {      void DeviceCreationParameterFloat::SetValue(float f) throw (LinuxSamplerException) {
711            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
712            OnSetValue(f);
713          fVal = f;          fVal = f;
714      }      }
715    
# Line 738  namespace LinuxSampler { Line 766  namespace LinuxSampler {
766      }      }
767    
768      String DeviceCreationParameterString::Value() {      String DeviceCreationParameterString::Value() {
769          return sVal;          return "\'" + ValueAsString() + "\'";
770      }      }
771    
772      void DeviceCreationParameterString::SetValue(String val) throw (LinuxSamplerException) {      void DeviceCreationParameterString::SetValue(String val) throw (LinuxSamplerException) {
773          if (Fix()) throw LinuxSamplerException("Device parameter is read only");          if (Fix()) throw LinuxSamplerException("Device parameter is read only");
774            SetValueAsString(__parse_string(val));
775        }
776    
777        String DeviceCreationParameterString::ValueAsString() {
778            return sVal;
779        }
780    
781        void DeviceCreationParameterString::SetValueAsString(String val) throw (LinuxSamplerException) {
782          if (val.find("\'") != String::npos) throw LinuxSamplerException("Character -> \' <- not allowed");          if (val.find("\'") != String::npos) throw LinuxSamplerException("Character -> \' <- not allowed");
783          if (val.find("\"") != String::npos) throw LinuxSamplerException("Character -> \" <- not allowed");          if (val.find("\"") != String::npos) throw LinuxSamplerException("Character -> \" <- not allowed");
784          OnSetValue(val);          OnSetValue(val);
# Line 824  namespace LinuxSampler { Line 860  namespace LinuxSampler {
860      void DeviceCreationParameterStrings::SetValue(String val) throw (LinuxSamplerException) {      void DeviceCreationParameterStrings::SetValue(String val) throw (LinuxSamplerException) {
861          if (Fix()) throw LinuxSamplerException("Device parameter is read only");          if (Fix()) throw LinuxSamplerException("Device parameter is read only");
862          std::vector<String> vS = __parse_strings(val);          std::vector<String> vS = __parse_strings(val);
         OnSetValue(vS);  
863          SetValue(vS);          SetValue(vS);
864      }      }
865    
# Line 832  namespace LinuxSampler { Line 867  namespace LinuxSampler {
867          return sVals;          return sVals;
868      }      }
869    
870      void DeviceCreationParameterStrings::SetValue(std::vector<String> vS) {      void DeviceCreationParameterStrings::SetValue(std::vector<String> vS) throw (LinuxSamplerException) {
871            if (Fix()) throw LinuxSamplerException("Device parameter is read only");
872            OnSetValue(vS);
873          sVals = vS;          sVals = vS;
874      }      }
875    

Legend:
Removed from v.212  
changed lines
  Added in v.214

  ViewVC Help
Powered by ViewVC