]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/PrintLib.h
2 Provides services to print a formatted string to a buffer. All combinations of
3 Unicode and ASCII strings are supported.
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef __PRINT_LIB_H__
17 #define __PRINT_LIB_H__
20 /// Define the maximum number of characters that are required to
21 /// encode a decimal, hexidecimal, GUID, or TIME value with a NULL
24 /// Maximum Length Decimal String = 28
25 /// "-9,223,372,036,854,775,808"
26 /// Maximum Length Hexidecimal String = 17
27 /// "FFFFFFFFFFFFFFFF"
28 /// Maximum Length GUID = 37
29 /// "00000000-0000-0000-0000-000000000000"
30 /// Maximum Length TIME = 18
31 /// "12/12/2006 12:12"
33 #define MAXIMUM_VALUE_CHARACTERS 38
36 /// Flags bitmask values use in UnicodeValueToString() and
37 /// AsciiValueToString()
39 #define LEFT_JUSTIFY 0x01
40 #define COMMA_TYPE 0x08
41 #define PREFIX_ZERO 0x20
42 #define RADIX_HEX 0x80
45 Produces a Null-terminated Unicode string in an output buffer based on
46 a Null-terminated Unicode format string and a VA_LIST argument list
48 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
50 The Unicode string is produced by parsing the format string specified by FormatString.
51 Arguments are pulled from the variable argument list specified by Marker based on the
52 contents of the format string.
53 The number of Unicode characters in the produced output buffer is returned not including
55 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
57 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
58 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
59 If BufferSize > 1 and FormatString is NULL, then ASSERT().
60 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
61 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
62 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
64 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
65 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
66 Null-terminator, then ASSERT().
68 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
70 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
71 @param FormatString Null-terminated Unicode format string.
72 @param Marker VA_LIST marker for the variable argument list.
74 @return The number of Unicode characters in the produced output buffer not including the
81 OUT CHAR16
*StartOfBuffer
,
83 IN CONST CHAR16
*FormatString
,
88 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
89 Unicode format string and variable argument list.
91 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
93 The Unicode string is produced by parsing the format string specified by FormatString.
94 Arguments are pulled from the variable argument list based on the contents of the format string.
95 The number of Unicode characters in the produced output buffer is returned not including
97 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
99 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
100 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
101 If BufferSize > 1 and FormatString is NULL, then ASSERT().
102 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
103 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
104 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
106 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
107 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
108 Null-terminator, then ASSERT().
110 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
112 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
113 @param FormatString Null-terminated Unicode format string.
114 @param ... The variable argument list.
116 @return The number of Unicode characters in the produced output buffer not including the
123 OUT CHAR16
*StartOfBuffer
,
125 IN CONST CHAR16
*FormatString
,
130 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
131 ASCII format string and a VA_LIST argument list
133 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
135 The Unicode string is produced by parsing the format string specified by FormatString.
136 Arguments are pulled from the variable argument list specified by Marker based on the
137 contents of the format string.
138 The number of Unicode characters in the produced output buffer is returned not including
140 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
142 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
143 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
144 If BufferSize > 1 and FormatString is NULL, then ASSERT().
145 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
146 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
148 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
149 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
150 Null-terminator, then ASSERT().
152 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
154 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
155 @param FormatString Null-terminated ASCII format string.
156 @param Marker VA_LIST marker for the variable argument list.
158 @return The number of Unicode characters in the produced output buffer not including the
164 UnicodeVSPrintAsciiFormat (
165 OUT CHAR16
*StartOfBuffer
,
167 IN CONST CHAR8
*FormatString
,
172 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
173 ASCII format string and variable argument list.
175 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
177 The Unicode string is produced by parsing the format string specified by FormatString.
178 Arguments are pulled from the variable argument list based on the contents of the
180 The number of Unicode characters in the produced output buffer is returned not including
182 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
184 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
185 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
186 If BufferSize > 1 and FormatString is NULL, then ASSERT().
187 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
188 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
190 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
191 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
192 Null-terminator, then ASSERT().
194 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
196 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
197 @param FormatString Null-terminated ASCII format string.
198 @param ... The variable argument list.
200 @return The number of Unicode characters in the produced output buffer not including the
206 UnicodeSPrintAsciiFormat (
207 OUT CHAR16
*StartOfBuffer
,
209 IN CONST CHAR8
*FormatString
,
214 Converts a decimal value to a Null-terminated Unicode string.
216 Converts the decimal number specified by Value to a Null-terminated Unicode
217 string specified by Buffer containing at most Width characters. No padding of spaces
218 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
219 The number of Unicode characters in Buffer is returned not including the Null-terminator.
220 If the conversion contains more than Width characters, then only the first
221 Width characters are returned, and the total number of characters
222 required to perform the conversion is returned.
223 Additional conversion parameters are specified in Flags.
225 The Flags bit LEFT_JUSTIFY is always ignored.
226 All conversions are left justified in Buffer.
227 If Width is 0, PREFIX_ZERO is ignored in Flags.
228 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
229 are inserted every 3rd digit starting from the right.
230 If HEX_RADIX is set in Flags, then the output buffer will be
231 formatted in hexadecimal format.
232 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
233 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
234 then Buffer is padded with '0' characters so the combination of the optional '-'
235 sign character, '0' characters, digit characters for Value, and the Null-terminator
236 add up to Width characters.
237 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
238 If Buffer is NULL, then ASSERT().
239 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
240 If unsupported bits are set in Flags, then ASSERT().
241 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
242 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
244 @param Buffer Pointer to the output buffer for the produced Null-terminated
246 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
247 @param Value The 64-bit signed value to convert to a string.
248 @param Width The maximum number of Unicode characters to place in Buffer, not including
251 @return The number of Unicode characters in Buffer not including the Null-terminator.
256 UnicodeValueToString (
257 IN OUT CHAR16
*Buffer
,
264 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
265 ASCII format string and a VA_LIST argument list.
267 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
269 The ASCII string is produced by parsing the format string specified by FormatString.
270 Arguments are pulled from the variable argument list specified by Marker based on
271 the contents of the format string.
272 The number of ASCII characters in the produced output buffer is returned not including
274 If BufferSize is 0, then no output buffer is produced and 0 is returned.
276 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
277 If BufferSize > 0 and FormatString is NULL, then ASSERT().
278 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
279 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
281 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
282 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
283 Null-terminator, then ASSERT().
285 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
287 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
288 @param FormatString Null-terminated ASCII format string.
289 @param Marker VA_LIST marker for the variable argument list.
291 @return The number of ASCII characters in the produced output buffer not including the
298 OUT CHAR8
*StartOfBuffer
,
300 IN CONST CHAR8
*FormatString
,
305 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
306 ASCII format string and variable argument list.
308 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
310 The ASCII string is produced by parsing the format string specified by FormatString.
311 Arguments are pulled from the variable argument list based on the contents of the
313 The number of ASCII characters in the produced output buffer is returned not including
315 If BufferSize is 0, then no output buffer is produced and 0 is returned.
317 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
318 If BufferSize > 0 and FormatString is NULL, then ASSERT().
319 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
320 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
322 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
323 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
324 Null-terminator, then ASSERT().
326 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
328 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
329 @param FormatString Null-terminated ASCII format string.
330 @param ... The variable argument list.
332 @return The number of ASCII characters in the produced output buffer not including the
339 OUT CHAR8
*StartOfBuffer
,
341 IN CONST CHAR8
*FormatString
,
346 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
347 Unicode format string and a VA_LIST argument list.
349 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
351 The ASCII string is produced by parsing the format string specified by FormatString.
352 Arguments are pulled from the variable argument list specified by Marker based on
353 the contents of the format string.
354 The number of ASCII characters in the produced output buffer is returned not including
356 If BufferSize is 0, then no output buffer is produced and 0 is returned.
358 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
359 If BufferSize > 0 and FormatString is NULL, then ASSERT().
360 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
361 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
362 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
364 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
365 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
366 Null-terminator, then ASSERT().
368 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
370 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
371 @param FormatString Null-terminated Unicode format string.
372 @param Marker VA_LIST marker for the variable argument list.
374 @return The number of ASCII characters in the produced output buffer not including the
380 AsciiVSPrintUnicodeFormat (
381 OUT CHAR8
*StartOfBuffer
,
383 IN CONST CHAR16
*FormatString
,
388 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
389 Unicode format string and variable argument list.
391 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
393 The ASCII string is produced by parsing the format string specified by FormatString.
394 Arguments are pulled from the variable argument list based on the contents of the
396 The number of ASCII characters in the produced output buffer is returned not including
398 If BufferSize is 0, then no output buffer is produced and 0 is returned.
400 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
401 If BufferSize > 0 and FormatString is NULL, then ASSERT().
402 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
403 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
404 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
406 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
407 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
408 Null-terminator, then ASSERT().
410 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
412 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
413 @param FormatString Null-terminated Unicode format string.
414 @param ... The variable argument list.
416 @return The number of ASCII characters in the produced output buffer not including the
422 AsciiSPrintUnicodeFormat (
423 OUT CHAR8
*StartOfBuffer
,
425 IN CONST CHAR16
*FormatString
,
430 Converts a decimal value to a Null-terminated ASCII string.
432 Converts the decimal number specified by Value to a Null-terminated ASCII string
433 specified by Buffer containing at most Width characters. No padding of spaces
435 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
436 The number of ASCII characters in Buffer is returned not including the Null-terminator.
437 If the conversion contains more than Width characters, then only the first Width
438 characters are returned, and the total number of characters required to perform
439 the conversion is returned.
440 Additional conversion parameters are specified in Flags.
441 The Flags bit LEFT_JUSTIFY is always ignored.
442 All conversions are left justified in Buffer.
443 If Width is 0, PREFIX_ZERO is ignored in Flags.
444 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
445 are inserted every 3rd digit starting from the right.
446 If HEX_RADIX is set in Flags, then the output buffer will be
447 formatted in hexadecimal format.
448 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
449 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
450 then Buffer is padded with '0' characters so the combination of the optional '-'
451 sign character, '0' characters, digit characters for Value, and the Null-terminator
452 add up to Width characters.
454 If Buffer is NULL, then ASSERT().
455 If unsupported bits are set in Flags, then ASSERT().
456 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
457 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
459 @param Buffer Pointer to the output buffer for the produced Null-terminated
461 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
462 @param Value The 64-bit signed value to convert to a string.
463 @param Width The maximum number of ASCII characters to place in Buffer, not including
466 @return The number of ASCII characters in Buffer not including the Null-terminator.
472 IN OUT CHAR8
*Buffer
,