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 |
} |
} |
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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); |
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 |
|
|
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 |
|
|
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) { |
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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); |
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 |
|
|
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 |
|
|