Changeset 786
- Timestamp:
- 05/21/18 14:01:14 (6 years ago)
- Location:
- cpp/frams
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/param.h
r784 r786 252 252 }; 253 253 254 template<typename T> struct quote_in_messages { constexpr static const char* value = "'"; }; 255 template<> struct quote_in_messages < SString > { constexpr static const char* value = "\""; }; 256 template<typename T> struct length_in_messages { static const bool value = false; }; 257 template<> struct length_in_messages < SString > { static const bool value = true; }; 258 254 259 class SimpleAbstractParam : public virtual ParamInterface 255 260 { … … 298 303 SString actual = get(i); 299 304 bool s_type = type(i)[0] == 's'; 300 logPrintf("Param", "set", LOG_WARN, "Setting '%s.%s = %s' exceeded allowed range (too %s). %s to %s.", 301 getName(), id(i), sstringShorten(svaluetoset, 30).c_str(), (setflags&PSET_HITMAX) ? (s_type ? "long" : "big") : "small", s_type ? "Truncated" : "Adjusted", sstringShorten(actual, 30).c_str()); 305 logPrintf("Param", "set", LOG_WARN, "Setting %s.%s = %s exceeded allowed range (too %s). %s to %s.", 306 getName(), id(i), 307 ::sstringDelimitAndShorten(svaluetoset, 30, length_in_messages<T>::value, quote_in_messages<T>::value, quote_in_messages<T>::value).c_str(), 308 (setflags&PSET_HITMAX) ? (s_type ? "long" : "big") : "small", s_type ? "Truncated" : "Adjusted", 309 ::sstringDelimitAndShorten(actual, 30, length_in_messages<T>::value, quote_in_messages<T>::value, quote_in_messages<T>::value).c_str() 310 ); 302 311 } 303 312 } -
cpp/frams/util/extvalue.cpp
r785 r786 305 305 { 306 306 SString msg = typeDescription(); 307 SString delimit("'"); 307 308 switch (type) 308 309 { 309 case TInt: case TDouble: case TString: case TObj: 310 msg += " '"; 311 msg += sstringShorten(getString(), 30); 312 msg += "'"; 310 case TString: 311 delimit = "\""; 312 case TInt: case TDouble: case TObj: 313 msg += " "; 314 msg += sstringDelimitAndShorten(getString(), 50, (type == TString), delimit, delimit); 313 315 default:; 314 316 } -
cpp/frams/util/sstringutils.cpp
r785 r786 157 157 } 158 158 159 SString sstring Shorten(const SString &in, int maxlen)159 SString sstringDelimitAndShorten(const SString &in, int maxlen, bool show_length, const SString& before, const SString& after) 160 160 { 161 161 SString out; 162 162 if (in.len() > maxlen) 163 out = in.substr(0, maxlen / 2) + "..." + in.substr(in.len() - maxlen + maxlen / 2) + SString::sprintf(" (length %d)", in.len());163 out = in.substr(0, maxlen / 2) + "..." + in.substr(in.len() - maxlen + maxlen / 2); 164 164 else 165 out = in; 165 { 166 out = in; show_length = false; 167 } 166 168 sstringQuote(out); 169 out = before + out + after; 170 if (show_length) 171 out += SString::sprintf(" (length %d)", in.len()); 167 172 return out; 168 173 } -
cpp/frams/util/sstringutils.h
r785 r786 19 19 bool strContainsOneOf(const char* str, const char* chars); 20 20 bool sstringQuote(SString& target); 21 SString sstring Shorten(const SString &in, int maxlen);21 SString sstringDelimitAndShorten(const SString &in, int maxlen, bool show_length, const SString& before, const SString& after); 22 22 const char* skipQuoteString(const char* txt, const char* limit); 23 23 int sstringUnquote(SString &target);
Note: See TracChangeset
for help on using the changeset viewer.