Changeset 247 for cpp/frams/param/param.cpp
- Timestamp:
- 11/07/14 17:51:01 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/param.cpp
r230 r247 37 37 static const char *strchrlimit(const char *t, int ch, const char *limit) 38 38 { 39 int n = limit - t;39 int n = (int)(limit - t); 40 40 for (; (n > 0) && *t; t++, n--) 41 41 if (*t == ch) return t; … … 72 72 } 73 73 74 int ParamInterface::getMinMax(int prop, long& minumum, long& maximum, long&def)74 int ParamInterface::getMinMax(int prop, paInt& minumum, paInt& maximum, paInt &def) 75 75 { 76 76 const char* t = type(prop) + 1; 77 77 while (*t) if (*t == ' ') break; else t++; 78 return sscanf(t, "%ld %ld %ld", &minumum, &maximum, &def);78 return sscanf(t, PA_INT_SCANF " " PA_INT_SCANF " " PA_INT_SCANF, &minumum, &maximum, &def); 79 79 } 80 80 … … 121 121 case 'd': 122 122 { 123 longa = 0, b = 0, c = 0;123 paInt a = 0, b = 0, c = 0; 124 124 if (getMinMax(i, a, b, c) < 3) c = a; 125 125 setInt(i, c); … … 144 144 case 'd': 145 145 { 146 longa = 0, b = 0, c = 0;146 paInt a = 0, b = 0, c = 0; 147 147 getMinMax(i, a, b, c); 148 148 setInt(i, a); … … 167 167 case 'd': 168 168 { 169 longa = 0, b = 0, c = 0;169 paInt a = 0, b = 0, c = 0; 170 170 getMinMax(i, a, b, c); 171 171 setInt(i, b); … … 178 178 SString ParamInterface::getStringById(const char*prop) 179 179 {int i=findId(prop); if (i>=0) return getString(i); else return SString();} 180 longParamInterface::getIntById(const char*prop)180 paInt ParamInterface::getIntById(const char*prop) 181 181 {int i=findId(prop); if (i>=0) return getInt(i); else return 0;} 182 182 double ParamInterface::getDoubleById(const char*prop) … … 187 187 {int i=findId(prop); if (i>=0) return getExtValue(i); else return ExtValue();} 188 188 189 int ParamInterface::setIntById(const char* prop, longv)189 int ParamInterface::setIntById(const char* prop,paInt v) 190 190 {int i=findId(prop); if (i>=0) return setInt(i,v); else return PSET_NOPROPERTY;} 191 191 int ParamInterface::setDoubleById(const char* prop,double v) … … 260 260 { 261 261 select(defdata); 262 longx = getInt(i);262 paInt x = getInt(i); 263 263 select(backup); 264 264 return x == getInt(i); … … 347 347 if (!*p0) break; 348 348 p = strchr(p0, ':'); if (!p) continue; 349 p_len = p - p0;349 p_len = (int)(p - p0); 350 350 loaded = false; 351 351 if (p_len && ((i = findIdn(p0, p_len)) >= 0) && (!(flags(i)&PARAM_DONTLOAD))) … … 442 442 if (!stringIsNumeric(str)) 443 443 { 444 longa, b, c;444 paInt a, b, c; 445 445 if (getMinMax(i, a, b, c) >= 3) 446 446 return setInt(i, c); 447 447 else 448 return setInt(i, ( long)0);448 return setInt(i, (paInt)0); 449 449 } 450 450 else … … 536 536 const char *t2 = strchr(t, '~'); 537 537 if (!t2) t2 = t + strlen(t); 538 return SString(t, t2 - t);538 return SString(t, (int)(t2 - t)); 539 539 } 540 540 } … … 599 599 #endif 600 600 601 longSimpleAbstractParam::getInt(int i)601 paInt SimpleAbstractParam::getInt(int i) 602 602 { 603 603 SANITY_CHECK(i); … … 612 612 { 613 613 void *target = getTarget(i); 614 return *(( long*)target);614 return *((paInt*)target); 615 615 } 616 616 } … … 687 687 //////// set 688 688 689 int SimpleAbstractParam::setInt(int i, longx)689 int SimpleAbstractParam::setInt(int i, paInt x) 690 690 { 691 691 SANITY_CHECK(i); … … 693 693 ParamEntry *pe = entry(i); 694 694 if (pe->flags&PARAM_READONLY) return PSET_RONLY; 695 longxcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below696 longa = 0, b = 0;695 paInt xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below 696 paInt a = 0, b = 0; 697 697 int result = 0; 698 698 const char* t = pe->type + 1; 699 699 while (*t) if (*t == ' ') break; else t++; 700 if (sscanf(t, "%ld %ld", &a, &b) == 2)700 if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &a, &b) == 2) 701 701 if (a <= b) // if max<min then the min/max constraint check is not supported 702 702 { … … 713 713 { 714 714 void *target = getTarget(i); 715 if (dontcheckchanges || (*(( long*)target) != x))715 if (dontcheckchanges || (*((paInt*)target) != x)) 716 716 { 717 717 result |= PSET_CHANGED; 718 *(( long*)target) = x;718 *((paInt*)target) = x; 719 719 } 720 720 } … … 770 770 const char* t = pe->type + 1; 771 771 while (*t) if (*t == ' ') break; else t++; 772 longa = 0, b = 0;772 paInt a = 0, b = 0; 773 773 int result = 0; 774 if (sscanf(t, "%ld %ld", &a, &b) == 2)774 if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &a, &b) == 2) 775 775 { 776 776 if ((x.len() > b) && (b > 0)) … … 883 883 const char *lf = strchr(beg, '\n'); 884 884 if (!lf) { lf = (const char*)s + s.len() - 1; poz = s.len(); } 885 else { poz = ( lf - (const char*)s) + 1; if (poz > s.len()) poz = s.len(); }885 else { poz = (int)(lf - (const char*)s) + 1; if (poz > s.len()) poz = s.len(); } 886 886 while (lf >= beg) if ((*lf == '\n') || (*lf == '\r')) lf--; else break; 887 len = lf - beg+ 1;887 len = (int)(lf - beg) + 1; 888 888 return beg; 889 889 } … … 939 939 if (equals_sign) // have parameter name 940 940 { 941 tmpi = findIdn(t, equals_sign - t);941 tmpi = findIdn(t, (int)(equals_sign - t)); 942 942 i = tmpi; 943 943 if (tmpi < 0) … … 960 960 if (quote) 961 961 { 962 tmpvalue.copyFrom(quote + 1, quote2 - quote- 1);962 tmpvalue.copyFrom(quote + 1, (int)(quote2 - quote) - 1); 963 963 sstringUnquote(tmpvalue); 964 964 value = tmpvalue;
Note: See TracChangeset
for help on using the changeset viewer.