2 Base Print Library instance Internal Functions definition.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __PRINT_LIB_INTERNAL_H__
10 #define __PRINT_LIB_INTERNAL_H__
13 #include <Library/PrintLib.h>
14 #include <Library/BaseLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/PcdLib.h>
21 #define PREFIX_SIGN BIT1
22 #define PREFIX_BLANK BIT2
23 #define LONG_TYPE BIT4
24 #define OUTPUT_UNICODE BIT6
25 #define FORMAT_UNICODE BIT8
26 #define PAD_TO_WIDTH BIT9
27 #define ARGUMENT_UNICODE BIT10
28 #define PRECISION BIT11
29 #define ARGUMENT_REVERSED BIT12
30 #define COUNT_ONLY_NO_PRINT BIT13
31 #define UNSIGNED_TYPE BIT14
34 // Record date and time information
51 Worker function that produces a Null-terminated string in an output buffer
52 based on a Null-terminated format string and a VA_LIST argument list.
54 VSPrint function to process format and place the results in Buffer. Since a
55 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
56 this is the main print working routine.
58 If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.
60 @param[out] Buffer The character buffer to print the results of the
61 parsing of Format into.
62 @param[in] BufferSize The maximum number of characters to put into
64 @param[in] Flags Initial flags value.
65 Can only have FORMAT_UNICODE, OUTPUT_UNICODE,
66 and COUNT_ONLY_NO_PRINT set.
67 @param[in] Format A Null-terminated format string.
68 @param[in] VaListMarker VA_LIST style variable argument list consumed by
70 @param[in] BaseListMarker BASE_LIST style variable argument list consumed
73 @return The number of characters printed not including the Null-terminator.
74 If COUNT_ONLY_NO_PRINT was set returns the same, but without any
75 modification to Buffer.
79 BasePrintLibSPrintMarker (
83 IN CONST CHAR8
*Format
,
84 IN VA_LIST VaListMarker OPTIONAL
,
85 IN BASE_LIST BaseListMarker OPTIONAL
89 Worker function that produces a Null-terminated string in an output buffer
90 based on a Null-terminated format string and variable argument list.
92 VSPrint function to process format and place the results in Buffer. Since a
93 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
94 this is the main print working routine
96 @param StartOfBuffer The character buffer to print the results of the parsing
98 @param BufferSize The maximum number of characters to put into buffer.
100 @param Flags Initial flags value.
101 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
102 @param FormatString Null-terminated format string.
103 @param ... The variable argument list.
105 @return The number of characters printed.
111 OUT CHAR8
*StartOfBuffer
,
114 IN CONST CHAR8
*FormatString
,
119 Internal function that places the character into the Buffer.
121 Internal function that places ASCII or Unicode character into the Buffer.
123 @param Buffer Buffer to place the Unicode or ASCII string.
124 @param EndBuffer The end of the input Buffer. No characters will be
126 @param Length The count of character to be placed into Buffer.
127 (Negative value indicates no buffer fill.)
128 @param Character The character to be placed into Buffer.
129 @param Increment The character increment in Buffer.
131 @return Buffer Buffer filled with the input Character.
135 BasePrintLibFillBuffer (
144 Internal function that convert a number to a string in Buffer.
146 Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.
148 @param Buffer Location to place the ASCII string of Value.
149 @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.
150 @param Radix Radix of the value
152 @return A pointer to the end of buffer filled with ASCII string.
156 BasePrintLibValueToString (
157 IN OUT CHAR8
*Buffer
,
163 Internal function that converts a decimal value to a Null-terminated string.
165 Converts the decimal number specified by Value to a Null-terminated
166 string specified by Buffer containing at most Width characters.
167 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
168 The total number of characters placed in Buffer is returned.
169 If the conversion contains more than Width characters, then only the first
170 Width characters are returned, and the total number of characters
171 required to perform the conversion is returned.
172 Additional conversion parameters are specified in Flags.
173 The Flags bit LEFT_JUSTIFY is always ignored.
174 All conversions are left justified in Buffer.
175 If Width is 0, PREFIX_ZERO is ignored in Flags.
176 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
177 are inserted every 3rd digit starting from the right.
178 If Value is < 0, then the fist character in Buffer is a '-'.
179 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
180 then Buffer is padded with '0' characters so the combination of the optional '-'
181 sign character, '0' characters, digit characters for Value, and the Null-terminator
182 add up to Width characters.
184 If Buffer is NULL, then ASSERT().
185 If unsupported bits are set in Flags, then ASSERT().
186 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
188 @param Buffer The pointer to the output buffer for the produced Null-terminated
190 @param Flags The bitmask of flags that specify left justification, zero pad,
192 @param Value The 64-bit signed value to convert to a string.
193 @param Width The maximum number of characters to place in Buffer, not including
195 @param Increment Character increment in Buffer.
197 @return Total number of characters required to perform the conversion.
201 BasePrintLibConvertValueToString (
202 IN OUT CHAR8
*Buffer
,
210 Internal function that converts a decimal value to a Null-terminated string.
212 Converts the decimal number specified by Value to a Null-terminated string
213 specified by Buffer containing at most Width characters. If Width is 0 then a
214 width of MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more
215 than Width characters, then only the first Width characters are placed in
216 Buffer. Additional conversion parameters are specified in Flags.
217 The Flags bit LEFT_JUSTIFY is always ignored.
218 All conversions are left justified in Buffer.
219 If Width is 0, PREFIX_ZERO is ignored in Flags.
220 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
221 commas are inserted every 3rd digit starting from the right.
222 If Value is < 0, then the fist character in Buffer is a '-'.
223 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
224 then Buffer is padded with '0' characters so the combination of the optional
225 '-' sign character, '0' characters, digit characters for Value, and the
226 Null-terminator add up to Width characters.
228 If an error would be returned, the function will ASSERT().
230 @param Buffer The pointer to the output buffer for the produced
231 Null-terminated string.
232 @param BufferSize The size of Buffer in bytes, including the
234 @param Flags The bitmask of flags that specify left justification,
235 zero pad, and commas.
236 @param Value The 64-bit signed value to convert to a string.
237 @param Width The maximum number of characters to place in Buffer,
238 not including the Null-terminator.
239 @param Increment The character increment in Buffer.
241 @retval RETURN_SUCCESS The decimal value is converted.
242 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
244 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
245 If Increment is 1 and
246 PcdMaximumAsciiStringLength is not zero,
247 BufferSize is greater than
248 PcdMaximumAsciiStringLength.
249 If Increment is not 1 and
250 PcdMaximumUnicodeStringLength is not zero,
251 BufferSize is greater than
252 (PcdMaximumUnicodeStringLength *
253 sizeof (CHAR16) + 1).
254 If unsupported bits are set in Flags.
255 If both COMMA_TYPE and RADIX_HEX are set in
257 If Width >= MAXIMUM_VALUE_CHARACTERS.
261 BasePrintLibConvertValueToStringS (
262 IN OUT CHAR8
*Buffer
,