28 |
|
|
29 |
namespace LinuxSampler { |
namespace LinuxSampler { |
30 |
|
|
31 |
|
// if string is encapsulated into apostrophes or quotation marks, then remove those apostrophes / quotation marks |
32 |
|
static void __eliminate_quotation(String& s) { |
33 |
|
if (s.size()) { |
34 |
|
const char cBegin = s[0]; |
35 |
|
const char cEnd = s[s.size() - 1]; |
36 |
|
if ( (cBegin == '\'' && cEnd == '\'') || (cBegin == '\"' && cEnd == '\"') ) { |
37 |
|
s = s.substr(1, s.size() - 2); |
38 |
|
} |
39 |
|
} |
40 |
|
} |
41 |
|
|
42 |
static bool __parse_bool(String val) throw (LinuxSamplerException) { |
static bool __parse_bool(String val) throw (LinuxSamplerException) { |
43 |
|
__eliminate_quotation(val); |
44 |
int b; |
int b; |
45 |
if (val == "1" || !strcasecmp(val.c_str(),"true")) b = true; |
if (val == "1" || !strcasecmp(val.c_str(),"true")) b = true; |
46 |
else if (val == "0" || !strcasecmp(val.c_str(),"false")) b = false; |
else if (val == "0" || !strcasecmp(val.c_str(),"false")) b = false; |
49 |
} |
} |
50 |
|
|
51 |
static int __parse_int(String val) throw (LinuxSamplerException) { |
static int __parse_int(String val) throw (LinuxSamplerException) { |
52 |
|
__eliminate_quotation(val); |
53 |
return atoi(val.c_str()); // TODO: format check is missing |
return atoi(val.c_str()); // TODO: format check is missing |
54 |
} |
} |
55 |
|
|
56 |
static float __parse_float(String val) throw (LinuxSamplerException) { |
static float __parse_float(String val) throw (LinuxSamplerException) { |
57 |
|
__eliminate_quotation(val); |
58 |
return atof(val.c_str()); // TODO: format check is missing |
return atof(val.c_str()); // TODO: format check is missing |
59 |
} |
} |
60 |
|
|
61 |
static String __parse_string(String val) { |
static String __parse_string(String val) { |
62 |
// if string is encapsulated into apostrophes or quotation marks, then remove those apostrophes / quotation marks |
__eliminate_quotation(val); |
|
if (val.size()) { |
|
|
char cBegin = val[0]; |
|
|
char cEnd = val[val.size() - 1]; |
|
|
if ( (cBegin == '\'' && cEnd == '\'') || (cBegin == '\"' && cEnd == '\"') ) { |
|
|
val = val.substr(1, val.size() - 2); |
|
|
} |
|
|
} |
|
63 |
return val; |
return val; |
64 |
} |
} |
65 |
|
|
730 |
// * |
// * |
731 |
|
|
732 |
DeviceCreationParameterString::DeviceCreationParameterString(String sVal) : DeviceCreationParameter() { |
DeviceCreationParameterString::DeviceCreationParameterString(String sVal) : DeviceCreationParameter() { |
733 |
this->sVal = sVal; |
this->sVal = __parse_string(sVal); |
734 |
} |
} |
735 |
|
|
736 |
void DeviceCreationParameterString::InitWithDefault() { |
void DeviceCreationParameterString::InitWithDefault() { |