import { BracketPaddingType } from "./BracketPaddingType"; import { PaddedFormattingTokens } from "./PaddedFormattingTokens"; import { JsonItem } from "./JsonItem"; import { NumberListAlignment } from "./NumberListAlignment"; import { IBuffer } from "./IBuffer"; import { TableColumnType } from "./TableColumnType"; export declare class TableTemplate { /** * The property name in the table that this segment matches up with. */ LocationInParent: string | undefined; /** * Type of the column, for table formatting purposes. Numbers have special options. Arrays or objects can * have recursive sub-columns. If they're other simple types or if there's a mix of types, we basically * treat them as strings (no recursion). */ Type: TableColumnType; RowCount: number; /** * Length of the longest property name. */ NameLength: number; /** * Length of the shortest property name. */ NameMinimum: number; /** * Largest length for the value parts of the column, not counting any table formatting padding. */ MaxValueLength: number; /** * Length of the largest value that can't be split apart; i.e., values other than arrays and objects. */ MaxAtomicValueLength: number; PrefixCommentLength: number; MiddleCommentLength: number; AnyMiddleCommentHasNewline: boolean; PostfixCommentLength: number; IsAnyPostCommentLineStyle: boolean; PadType: BracketPaddingType; RequiresMultipleLines: boolean; /** * Length of the value for this template when things are complicated. For arrays and objects, it's the sum of * all the child templates' lengths, plus brackets and commas and such. For number lists, it's the space * required to align them as appropriate. */ CompositeValueLength: number; /** * Length of the entire template, including space for the value, property name, and all comments. */ TotalLength: number; /** * If the row contains non-empty array or objects whose value is shorter than the literal null, an extra adjustment * is needed. */ ShorterThanNullAdjustment: number; /** * True if at least one row in the column this represents has a null value. */ ContainsNull: boolean; /** * If this TableTemplate corresponds to an object or array, Children contains sub-templates * for the array/object's children. */ Children: TableTemplate[]; constructor(pads: PaddedFormattingTokens, numberListAlignment: NumberListAlignment); /** * Analyzes an object/array for formatting as a table, formatting as a compact multiline array, or * formatting as an expanded object with aligned properties. In the first two cases, we measure recursively so * that values nested inside arrays and objects can be aligned too. * * The item given is presumed to require multiple lines. For table formatting, each of its children is * expected to be one row. For compact multiline arrays, there will be multiple children per line, but they * will be given the same amount of space and lined up neatly when spanning multiple lines. For expanded * object properties, the values may or may not span multiple lines, but the property names and the start of * their values will be on separate lines, lined up. */ MeasureTableRoot(tableRoot: JsonItem, recursive: boolean): void; /** * Check if the template's width fits in the given size. Repeatedly drop inner formatting and * recompute to make it fit, if needed. * * Fully expanded, an array might look like this when table-formatted. * * [ * { "a": 3.4, "b": 8, "c": {"x": 2, "y": 16 } }, * { "a": 2, "b": 301, "c": { "y": -4, "z": 0} } * ] * * If that's too wide, the template will give up trying to align the x,y,z properties but keep the rest. * * [ * { "a": 3.4, "b": 8, "c": {"x": 2, "y": 16} }, * { "a": 2, "b": 301, "c": {"y": -4, "z": 0} } * ] */ TryToFit(maximumLength: number): boolean; /** * Added the number, properly aligned and possibly reformatted, according to our measurements. * This assumes that the segment is a number list, and therefore that the item is a number or null. */ FormatNumber(buffer: IBuffer, item: JsonItem, commaBeforePadType: string): void; /** * Length of the largest item - including property name, comments, and padding - that can't be split across * multiple lines. */ AtomicItemSize(): number; private static readonly _trulyZeroValString; private static readonly _dotOrE; private static readonly _maxCharsForNormalize; private readonly _pads; private _numberListAlignment; private _maxDigBeforeDec; private _maxDigAfterDec; /** * Adjusts this TableTemplate (and its children) to make room for the given rowSegment (and its children). */ private MeasureRowSegment; private PruneAndRecompute; private GetTemplateComplexity; private ContainsDuplicateKeys; private GetNumberFieldWidth; }