This class stores and manages tabulator positions and field sizes. The class supports a simple session handling, by storing each value once for the actual output session and a second time for a future session. The motivation for writing this class came from the requirements of logging library ALox. The goals here are:
- During a logging session, log output should be as much tabular as possible.
- On the same time, the log output should be as "narrow" as possible.
If used correctly, this class helps to achieve the following:
- A new log-output session increases tab stops and field widths during execution as needed.
- If values need to be increased, a certain amount of "extra padding" might be added to avoid too many small increments.
- Once all tab stops or fields have been logged with values of their maximum size, the log output will not vary in respect to tab stops and autosizes any more.
- If a subsequent session contains the very same log-output (aka the same requested tab positions and field width), all extra space is removed and the log output is 100% tabular beginning with the session start.
- If a subsequent session contains smaller values, then this session is formatted with the (still larger) width of the previous session. After that, the next session will use the smaller sizes.
This approach very well guarantees stable log output widths across sessions. Only if the execution path of a software changes (or logging verbosity setting is changed), adjustments are performed.
To preserve the information across sessions, this class provides methods to transform it's information from and to string representations which can be stored in configuration files.
As the use case of this class is not restricted to log output, this class is exposed as a general utility class of ALib strings.
int Actual |
( |
Types |
type, |
|
|
int |
requestedSize, |
|
|
int |
growthPadding |
|
) |
| |
|
inline |
Returns the actual auto value stored, respectively, if the given requested size is higher than what is stored, stores and returns the requested size.
In the latter case, the given extra growth is added to the requested size, but only if the value was set at least once before. In other words, the extra size is added only with the second growth and each subsequent one.
The requested size in addition replaces the current "session" value if it is higher than the currently stored value. To this value, the growth padding is not added.
- Parameters
-
type | The type of entry. |
requestedSize | The minimum size that is requested. |
growthPadding | Added to the new size, if the requested size is greater than the stored size and if the stored size does not equal -1 . |
- Returns
- The (new) size of the auto field.