Ignore:
Timestamp:
05/21/18 14:01:14 (6 years ago)
Author:
Maciej Komosinski
Message:

Improved shortening of long stringified values in error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/sstringutils.cpp

    r785 r786  
    157157}
    158158
    159 SString sstringShorten(const SString &in, int maxlen)
     159SString sstringDelimitAndShorten(const SString &in, int maxlen, bool show_length, const SString& before, const SString& after)
    160160{
    161161        SString out;
    162162        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);
    164164        else
    165                 out = in;
     165        {
     166                out = in; show_length = false;
     167        }
    166168        sstringQuote(out);
     169        out = before + out + after;
     170        if (show_length)
     171                out += SString::sprintf(" (length %d)", in.len());
    167172        return out;
    168173}
Note: See TracChangeset for help on using the changeset viewer.