formatting
本頁內容尚未翻譯。
cfamily.Flags
Section titled “cfamily.Flags”record FlagsThe flags of a conversion: - (left), + (sign), space, # (alternative form), 0 (zeros).
cfamily.Flags.cleared
Section titled “cfamily.Flags.cleared”def Flags.cleared : FlagsNo flags.
cfamily.Count
Section titled “cfamily.Count”data CountA width or a precision: not given, a number, or * (from an int argument).
cfamily.LengthModifier
Section titled “cfamily.LengthModifier”data LengthModifierA length modifier: none, hh, h, l, ll, z (size_t), j (intmax_t), t (ptrdiff_t), L (long double).
cfamily.FloatStyle
Section titled “cfamily.FloatStyle”data FloatStyleHow %f, %e, %g write a floating value.
cfamily.ConversionKind
Section titled “cfamily.ConversionKind”data ConversionKindWhat a conversion writes: d i, u, o, x X, c, s, f F e E g G.
cfamily.Conversion
Section titled “cfamily.Conversion”record ConversionA conversion specification.
cfamily.FormatPiece
Section titled “cfamily.FormatPiece”data FormatPieceA piece of a format: a character as is, %%, or a conversion.
cfamily.PrintArgument
Section titled “cfamily.PrintArgument”data PrintArgumentAn argument after the default argument promotions: an integer of its type, a string (its bytes up to the null, or up to a precision: none where reading them is undefined), a double, or a long double (of a format other than double’s).
cfamily.Parsed
Section titled “cfamily.Parsed”record Parsed (A : Type)A value parsed from the front of a format, and the codes after it.
cfamily.Flags.add
Section titled “cfamily.Flags.add”def Flags.add (f : Flags) (c : Nat) : Option FlagsThe flags with one more, if the code is a flag.
cfamily.Format.flags
Section titled “cfamily.Format.flags”def Format.flags (f : Flags) (cs : List Nat) : Parsed FlagsThe flags at the front.
cfamily.Format.isDigit
Section titled “cfamily.Format.isDigit”def Format.isDigit (c : Nat) : BoolWhether a code is a decimal digit.
cfamily.Format.number
Section titled “cfamily.Format.number”def Format.number (acc : Nat) (cs : List Nat) : Parsed NatThe decimal number at the front (acc so far).
cfamily.Format.givenCount
Section titled “cfamily.Format.givenCount”def Format.givenCount (cs : List Nat) : Parsed CountA count from a number at the front.
cfamily.Format.width
Section titled “cfamily.Format.width”def Format.width (cs : List Nat) : Parsed CountThe width: *, digits, or none.
cfamily.Format.precision
Section titled “cfamily.Format.precision”def Format.precision (cs : List Nat) : Parsed CountThe precision: . then * or digits (none is 0), or no precision.
cfamily.Format.doubled
Section titled “cfamily.Format.doubled”def Format.doubled (c : Nat) (single : LengthModifier) (double : LengthModifier) (cs : List Nat) : Parsed LengthModifierThe length after one h or l: doubled (hh, ll), or single.
cfamily.Format.lengthModifier
Section titled “cfamily.Format.lengthModifier”def Format.lengthModifier (cs : List Nat) : Parsed LengthModifierThe length modifier.
cfamily.Format.floatKind
Section titled “cfamily.Format.floatKind”def Format.floatKind (c : Nat) : Option ConversionKindThe floating conversion of a code: f F e E g G.
cfamily.Format.kind
Section titled “cfamily.Format.kind”def Format.kind (c : Nat) : Option ConversionKindThe conversion of a code.
cfamily.Conversion.isBare
Section titled “cfamily.Conversion.isBare”def Conversion.isBare (c : Conversion) : BoolWhether a conversion has nothing between % and its character (%% must be exactly that, C11 7.21.6.1p8).
cfamily.Format.parse
Section titled “cfamily.Format.parse”def Format.parse (format : String) : Option (List FormatPiece)The pieces of a format, none if it is not a valid format.
cfamily.LengthModifier.argumentType
Section titled “cfamily.LengthModifier.argumentType”def LengthModifier.argumentType (p : Platform) (signed : Bool) (l : LengthModifier) : IntegerTypeThe type an integer conversion’s argument has after promotion (hh and h arguments were promoted to int).
cfamily.LengthModifier.writtenType
Section titled “cfamily.LengthModifier.writtenType”def LengthModifier.writtenType (p : Platform) (signed : Bool) (l : LengthModifier) : IntegerTypeThe type an integer is converted back to before it is written (hh and h to the narrow type).
cfamily.ConversionKind.isSigned
Section titled “cfamily.ConversionKind.isSigned”def ConversionKind.isSigned (k : ConversionKind) : BoolWhether a conversion is d or i.
cfamily.PrintArgument.integerAs
Section titled “cfamily.PrintArgument.integerAs”def PrintArgument.integerAs (t : IntegerType) (a : PrintArgument) : Option IntThe integer of an argument read as a type: the same type, or its signed or unsigned counterpart with the value in both ranges (C11 7.16.1.1p2).
cfamily.Conversion.flagsFit
Section titled “cfamily.Conversion.flagsFit”def Conversion.flagsFit (c : Conversion) : BoolWhether the flags and precision suit the conversion: # only with o x X and floating, no 0 or precision with c, no 0 with s (C11 7.21.6.1p6).
cfamily.Format.ofCodes
Section titled “cfamily.Format.ofCodes”def Format.ofCodes (codes : List Nat) : StringThe characters of codes.
cfamily.Format.copies
Section titled “cfamily.Format.copies”def Format.copies (c : Nat) (k : Nat) : Stringk copies of a character.
cfamily.Format.digit
Section titled “cfamily.Format.digit”def Format.digit (upper : Bool) (d : Nat) : NatThe digit of a value below 16 (letters upper or lower).
cfamily.Format.digitsIn
Section titled “cfamily.Format.digitsIn”def Format.digitsIn (base : Nat) (upper : Bool) (fuel : Nat) (n : Nat) (acc : List Nat) : List NatThe digits of n in a base, most significant first (acc after them), within fuel.
cfamily.Format.inBase
Section titled “cfamily.Format.inBase”def Format.inBase (base : Nat) (upper : Bool) (n : Nat) : Stringn written in a base.
cfamily.Format.pad
Section titled “cfamily.Format.pad”def Format.pad (f : Flags) (width : Nat) (zerosAllowed : Bool) (lead : String) (body : String) : StringA field: the prefix and body padded to the width with spaces (left or right), or zeros after the prefix.
cfamily.Format.zeroPadded
Section titled “cfamily.Format.zeroPadded”def Format.zeroPadded (n : Nat) (s : String) : Strings padded on the left with zeros to n characters.
cfamily.ConversionKind.base
Section titled “cfamily.ConversionKind.base”def ConversionKind.base (k : ConversionKind) : NatThe base of an integer conversion.
cfamily.ConversionKind.upper
Section titled “cfamily.ConversionKind.upper”def ConversionKind.upper (k : ConversionKind) : BoolWhether an integer conversion writes upper case.
cfamily.Format.integerDigits
Section titled “cfamily.Format.integerDigits”def Format.integerDigits (k : ConversionKind) (alternative : Bool) (precision : Option Nat) (n : Nat) : StringAn integer’s digits: the precision is the least count (default 1; precision 0 and value 0 write none); #o makes the first digit 0.
cfamily.Format.integerPrefix
Section titled “cfamily.Format.integerPrefix”def Format.integerPrefix (f : Flags) (k : ConversionKind) (v : Int) : StringAn integer’s prefix: its sign (d, i), or 0x for #x of a nonzero value.
cfamily.Format.integer
Section titled “cfamily.Format.integer”def Format.integer (f : Flags) (width : Nat) (precision : Option Nat) (k : ConversionKind) (v : Int) : StringAn integer conversion of a value (already converted back to the written type).
cfamily.Format.exponent
Section titled “cfamily.Format.exponent”def Format.exponent (x : Int) (upper : Bool) : String“e+05”: the exponent with a sign and at least two digits.
cfamily.Format.fixed
Section titled “cfamily.Format.fixed”def Format.fixed (p : Nat) (v : Float) : String%.pf of a finite value’s magnitude: the value rounded to p places, p digits after the point (none for p = 0).
cfamily.Format.scientific
Section titled “cfamily.Format.scientific”def Format.scientific (p : Nat) (upper : Bool) (v : Float) : String%.pe of a finite value’s magnitude: p + 1 significant digits, one before the point.
cfamily.Format.trimmed
Section titled “cfamily.Format.trimmed”def Format.trimmed (fraction : String) : StringThe digits after the point with trailing zeros removed.
cfamily.Format.withPoint
Section titled “cfamily.Format.withPoint”def Format.withPoint (keep : Bool) (whole : String) (fraction : String) : StringA whole part and a fraction: with the fraction’s trailing zeros removed (and the point if none remain), unless kept (#g).
cfamily.Format.general
Section titled “cfamily.Format.general”def Format.general (count : Nat) (keep : Bool) (upper : Bool) (s : Significant) : String%.pg of a finite nonzero magnitude with P significant digits (P = p, or 1 for 0): fixed if the exponent X has -4 <= X < P, else scientific; trailing zeros removed unless kept (#).
cfamily.Format.generalOf
Section titled “cfamily.Format.generalOf”def Format.generalOf (p : Nat) (keep : Bool) (upper : Bool) (v : Float) : String%.pg of a finite value’s magnitude.
cfamily.Format.pointAfterFirst
Section titled “cfamily.Format.pointAfterFirst”def Format.pointAfterFirst (s : String) : StringInserts the point after the first digit (“3e+00” to “3.e+00”).
cfamily.Format.magnitude
Section titled “cfamily.Format.magnitude”def Format.magnitude (style : FloatStyle) (alternative : Bool) (upper : Bool) (p : Nat) (v : Float) : StringA floating conversion of a finite value’s magnitude; # keeps the point at precision 0 (f, e).
cfamily.Format.special
Section titled “cfamily.Format.special”def Format.special (upper : Bool) (v : Float) : Stringinf or nan, upper case for F E G.
cfamily.Format.isNegative
Section titled “cfamily.Format.isNegative”def Format.isNegative (v : Float) : BoolWhether a floating value is negative (NaN has no sign here).
cfamily.Format.isFinite
Section titled “cfamily.Format.isFinite”def Format.isFinite (v : Float) : BoolWhether a floating value is finite.
cfamily.Format.float
Section titled “cfamily.Format.float”def Format.float (f : Flags) (width : Nat) (p : Nat) (style : FloatStyle) (upper : Bool) (v : Float) : StringA floating conversion: the sign apart (0 pads after it; inf and nan are not zero padded; NaN takes no + or space, as clang’s libc).
cfamily.Fields
Section titled “cfamily.Fields”record FieldsThe width, the precision and the arguments left, after any * took an int argument (a negative width is the - flag, a negative precision is none).
cfamily.Fields.of
Section titled “cfamily.Fields.of”def Fields.of (f : Flags) (width : Nat) (rest : List PrintArgument) : FieldsFields with a width and no precision yet.
cfamily.Fields.withPrecision
Section titled “cfamily.Fields.withPrecision”def Fields.withPrecision (w : Fields) (precision : Option Nat) (rest : List PrintArgument) : FieldsThe fields with a precision and the arguments after it.
cfamily.Fields.width
Section titled “cfamily.Fields.width”def Fields.width (p : Platform) (f : Flags) (c : Count) (args : List PrintArgument) : Option FieldsThe width of a conversion.
cfamily.Fields.precision
Section titled “cfamily.Fields.precision”def Fields.precision (p : Platform) (c : Count) (w : Fields) : Option FieldsThe precision of a conversion, after its width.
cfamily.Written
Section titled “cfamily.Written”record WrittenWhat a conversion writes, and the arguments after it.
cfamily.Format.integerArgument
Section titled “cfamily.Format.integerArgument”def Format.integerArgument (p : Platform) (c : Conversion) (w : Fields) (a : PrintArgument) : Option StringAn integer or character conversion of an argument.
cfamily.Format.textArgument
Section titled “cfamily.Format.textArgument”def Format.textArgument (c : Conversion) (w : Fields) (a : PrintArgument) : Option StringA string conversion: no length modifier (%ls is not in the subset), bytes read up to the precision.
cfamily.Format.floatArgument
Section titled “cfamily.Format.floatArgument”def Format.floatArgument (c : Conversion) (w : Fields) (a : PrintArgument) : Option StringA floating conversion: no length or l (%lf is %f) with a double, L with a long double (C11 7.21.6.1p7); any other pairing is undefined (p9).
cfamily.Format.convert
Section titled “cfamily.Format.convert”def Format.convert (p : Platform) (c : Conversion) (args : List PrintArgument) : Option WrittenA conversion of the next argument.
cfamily.Format.write
Section titled “cfamily.Format.write”def Format.write (p : Platform) (pieces : List FormatPiece) (args : List PrintArgument) : Option (List String)The pieces written with the arguments.
cfamily.Format.print
Section titled “cfamily.Format.print”def Format.print (p : Platform) (format : String) (args : List PrintArgument) : Option Stringprintf’s output for a format and its arguments; none where the behavior is undefined (C11 7.21.6.1p9, and an output longer than INT_MAX, 7.21.6.1p15).