]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Library/PrintLib.h
added some comments in BaseLib
[mirror_edk2.git] / MdePkg / Include / Library / PrintLib.h
... / ...
CommitLineData
1/** @file\r
2 Library that provides print services\r
3\r
4 Copyright (c) 2006, Intel Corporation \r
5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13 Module Name: PrintLib.h\r
14\r
15**/\r
16\r
17#ifndef __PRINT_LIB_H__\r
18#define __PRINT_LIB_H__\r
19\r
20///\r
21/// Define the maximum number of characters that are required to\r
22/// encode a decimal, hexidecimal, GUID, or TIME value with a NULL \r
23/// terminator.\r
24/// \r
25/// Maximum Length Decimal String = 28\r
26/// "-9,223,372,036,854,775,808"\r
27/// Maximum Length Hexidecimal String = 17\r
28/// "FFFFFFFFFFFFFFFF"\r
29/// Maximum Length GUID = 37\r
30/// "00000000-0000-0000-0000-000000000000"\r
31/// Maximum Length TIME = 18\r
32/// "12/12/2006 12:12"\r
33///\r
34#define MAXIMUM_VALUE_CHARACTERS 38\r
35\r
36///\r
37/// Flags bitmask values use in UnicodeValueToString() and \r
38/// AcsiiValueToString()\r
39///\r
40#define LEFT_JUSTIFY 0x01\r
41#define COMMA_TYPE 0x08\r
42#define PREFIX_ZERO 0x20\r
43\r
44/**\r
45 Produces a Null-terminated Unicode string in an output buffer based on \r
46 a Null-terminated Unicode format string and a VA_LIST argument list\r
47 \r
48 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
49 and BufferSize. \r
50 The Unicode string is produced by parsing the format string specified by FormatString. \r
51 Arguments are pulled from the variable argument list specified by Marker based on the \r
52 contents of the format string. \r
53 The number of Unicode characters in the produced output buffer is returned not including\r
54 the Null-terminator.\r
55 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
56\r
57 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
58 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
59 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
60 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
61 ASSERT().\r
62 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
63 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
64 Null-terminator, then ASSERT().\r
65\r
66 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
67 Unicode string.\r
68 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
69 @param FormatString Null-terminated Unicode format string.\r
70 @param Marker VA_LIST marker for the variable argument list.\r
71 \r
72 @return The number of Unicode characters in the produced output buffer not including the\r
73 Null-terminator.\r
74\r
75**/\r
76UINTN\r
77EFIAPI\r
78UnicodeVSPrint (\r
79 OUT CHAR16 *StartOfBuffer,\r
80 IN UINTN BufferSize,\r
81 IN CONST CHAR16 *FormatString,\r
82 IN VA_LIST Marker\r
83 );\r
84\r
85/**\r
86 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
87 Unicode format string and variable argument list.\r
88 \r
89 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
90 and BufferSize.\r
91 The Unicode string is produced by parsing the format string specified by FormatString.\r
92 Arguments are pulled from the variable argument list based on the contents of the format string.\r
93 The number of Unicode characters in the produced output buffer is returned not including\r
94 the Null-terminator.\r
95 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
96\r
97 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
98 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
99 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
100 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
101 ASSERT().\r
102 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
103 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
104 Null-terminator, then ASSERT().\r
105\r
106 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
107 Unicode string.\r
108 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
109 @param FormatString Null-terminated Unicode format string.\r
110 \r
111 @return The number of Unicode characters in the produced output buffer not including the\r
112 Null-terminator.\r
113\r
114**/\r
115UINTN\r
116EFIAPI\r
117UnicodeSPrint (\r
118 OUT CHAR16 *StartOfBuffer,\r
119 IN UINTN BufferSize,\r
120 IN CONST CHAR16 *FormatString,\r
121 ...\r
122 );\r
123\r
124/**\r
125 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
126 ASCII format string and a VA_LIST argument list\r
127 \r
128 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
129 and BufferSize.\r
130 The Unicode string is produced by parsing the format string specified by FormatString.\r
131 Arguments are pulled from the variable argument list specified by Marker based on the \r
132 contents of the format string.\r
133 The number of Unicode characters in the produced output buffer is returned not including\r
134 the Null-terminator.\r
135 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
136\r
137 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
138 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
139 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
140 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
141 ASSERT().\r
142 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
143 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
144 Null-terminator, then ASSERT().\r
145\r
146 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
147 Unicode string.\r
148 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
149 @param FormatString Null-terminated Unicode format string.\r
150 @param Marker VA_LIST marker for the variable argument list.\r
151 \r
152 @return The number of Unicode characters in the produced output buffer not including the\r
153 Null-terminator.\r
154\r
155**/\r
156UINTN\r
157EFIAPI\r
158UnicodeVSPrintAsciiFormat (\r
159 OUT CHAR16 *StartOfBuffer,\r
160 IN UINTN BufferSize,\r
161 IN CONST CHAR8 *FormatString,\r
162 IN VA_LIST Marker\r
163 );\r
164\r
165/**\r
166 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
167 ASCII format string and variable argument list.\r
168 \r
169 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
170 and BufferSize.\r
171 The Unicode string is produced by parsing the format string specified by FormatString.\r
172 Arguments are pulled from the variable argument list based on the contents of the \r
173 format string.\r
174 The number of Unicode characters in the produced output buffer is returned not including\r
175 the Null-terminator.\r
176 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
177\r
178 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
179 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
180 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
181 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
182 ASSERT().\r
183 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
184 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
185 Null-terminator, then ASSERT().\r
186\r
187 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
188 Unicode string.\r
189 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
190 @param FormatString Null-terminated Unicode format string.\r
191 \r
192 @return The number of Unicode characters in the produced output buffer not including the\r
193 Null-terminator.\r
194\r
195**/\r
196UINTN\r
197EFIAPI\r
198UnicodeSPrintAsciiFormat (\r
199 OUT CHAR16 *StartOfBuffer,\r
200 IN UINTN BufferSize,\r
201 IN CONST CHAR8 *FormatString,\r
202 ...\r
203 );\r
204\r
205/**\r
206 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
207 ASCII format string and a VA_LIST argument list.\r
208 \r
209 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
210 and BufferSize.\r
211 The ASCII string is produced by parsing the format string specified by FormatString.\r
212 Arguments are pulled from the variable argument list specified by Marker based on \r
213 the contents of the format string.\r
214 The number of ASCII characters in the produced output buffer is returned not including\r
215 the Null-terminator.\r
216 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
217\r
218 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
219 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
220 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
221 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
222 ASSERT().\r
223 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
224 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
225 Null-terminator, then ASSERT().\r
226\r
227 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
228 ASCII string.\r
229 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
230 @param FormatString Null-terminated Unicode format string.\r
231 @param Marker VA_LIST marker for the variable argument list.\r
232 \r
233 @return The number of ASCII characters in the produced output buffer not including the\r
234 Null-terminator.\r
235\r
236**/\r
237UINTN\r
238EFIAPI\r
239AsciiVSPrint (\r
240 OUT CHAR8 *StartOfBuffer,\r
241 IN UINTN BufferSize,\r
242 IN CONST CHAR8 *FormatString,\r
243 IN VA_LIST Marker\r
244 );\r
245\r
246/**\r
247 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
248 ASCII format string and variable argument list.\r
249 \r
250 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
251 and BufferSize.\r
252 The ASCII string is produced by parsing the format string specified by FormatString.\r
253 Arguments are pulled from the variable argument list based on the contents of the \r
254 format string.\r
255 The number of ASCII characters in the produced output buffer is returned not including\r
256 the Null-terminator.\r
257 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
258\r
259 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
260 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
261 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
262 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
263 ASSERT().\r
264 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
265 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
266 Null-terminator, then ASSERT().\r
267\r
268 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
269 ASCII string.\r
270 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
271 @param FormatString Null-terminated Unicode format string.\r
272 \r
273 @return The number of ASCII characters in the produced output buffer not including the\r
274 Null-terminator.\r
275\r
276**/\r
277UINTN\r
278EFIAPI\r
279AsciiSPrint (\r
280 OUT CHAR8 *StartOfBuffer,\r
281 IN UINTN BufferSize,\r
282 IN CONST CHAR8 *FormatString,\r
283 ...\r
284 );\r
285\r
286/**\r
287 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
288 ASCII format string and a VA_LIST argument list.\r
289 \r
290 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
291 and BufferSize.\r
292 The ASCII string is produced by parsing the format string specified by FormatString.\r
293 Arguments are pulled from the variable argument list specified by Marker based on \r
294 the contents of the format string.\r
295 The number of ASCII characters in the produced output buffer is returned not including\r
296 the Null-terminator.\r
297 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
298\r
299 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
300 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
301 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
302 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
303 ASSERT().\r
304 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
305 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
306 Null-terminator, then ASSERT().\r
307\r
308 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
309 ASCII string.\r
310 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
311 @param FormatString Null-terminated Unicode format string.\r
312 @param Marker VA_LIST marker for the variable argument list.\r
313 \r
314 @return The number of ASCII characters in the produced output buffer not including the\r
315 Null-terminator.\r
316\r
317**/\r
318UINTN\r
319EFIAPI\r
320AsciiVSPrintUnicodeFormat (\r
321 OUT CHAR8 *StartOfBuffer,\r
322 IN UINTN BufferSize,\r
323 IN CONST CHAR16 *FormatString,\r
324 IN VA_LIST Marker\r
325 );\r
326\r
327/**\r
328 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
329 ASCII format string and variable argument list.\r
330 \r
331 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
332 and BufferSize.\r
333 The ASCII string is produced by parsing the format string specified by FormatString.\r
334 Arguments are pulled from the variable argument list based on the contents of the \r
335 format string.\r
336 The number of ASCII characters in the produced output buffer is returned not including\r
337 the Null-terminator.\r
338 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
339\r
340 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
341 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
342 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
343 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
344 ASSERT().\r
345 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
346 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
347 Null-terminator, then ASSERT().\r
348\r
349 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
350 ASCII string.\r
351 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
352 @param FormatString Null-terminated Unicode format string.\r
353 \r
354 @return The number of ASCII characters in the produced output buffer not including the\r
355 Null-terminator.\r
356\r
357**/\r
358UINTN\r
359EFIAPI\r
360AsciiSPrintUnicodeFormat (\r
361 OUT CHAR8 *StartOfBuffer,\r
362 IN UINTN BufferSize,\r
363 IN CONST CHAR16 *FormatString,\r
364 ...\r
365 );\r
366\r
367/**\r
368 Converts a decimal value to a Null-terminated Unicode string.\r
369 \r
370 Converts the decimal number specified by Value to a Null-terminated Unicode \r
371 string specified by Buffer containing at most Width characters.\r
372 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
373 The number of Unicode characters in Buffer is returned not including the Null-terminator.\r
374 If the conversion contains more than Width characters, then only the first\r
375 Width characters are returned, and the total number of characters \r
376 required to perform the conversion is returned.\r
377 Additional conversion parameters are specified in Flags. \r
378 The Flags bit LEFT_JUSTIFY is always ignored.\r
379 All conversions are left justified in Buffer.\r
380 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
381 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
382 are inserted every 3rd digit starting from the right.\r
383 If Value is < 0, then the fist character in Buffer is a '-'.\r
384 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
385 then Buffer is padded with '0' characters so the combination of the optional '-' \r
386 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
387 add up to Width characters.\r
388\r
389 If Buffer is NULL, then ASSERT().\r
390 If unsupported bits are set in Flags, then ASSERT().\r
391 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
392\r
393 @param Buffer Pointer to the output buffer for the produced Null-terminated\r
394 Unicode string.\r
395 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
396 @param Value The 64-bit signed value to convert to a string.\r
397 @param Width The maximum number of Unicode characters to place in Buffer, not including\r
398 the Null-terminator.\r
399 \r
400 @return The number of Unicode characters in Buffer not including the Null-terminator.\r
401\r
402**/\r
403UINTN\r
404EFIAPI\r
405UnicodeValueToString (\r
406 IN OUT CHAR16 *Buffer,\r
407 IN UINTN Flags,\r
408 IN INT64 Value,\r
409 IN UINTN Width\r
410 );\r
411\r
412/**\r
413 Converts a decimal value to a Null-terminated ASCII string.\r
414 \r
415 Converts the decimal number specified by Value to a Null-terminated ASCII string \r
416 specified by Buffer containing at most Width characters.\r
417 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
418 The number of ASCII characters in Buffer is returned not including the Null-terminator.\r
419 If the conversion contains more than Width characters, then only the first Width\r
420 characters are returned, and the total number of characters required to perform\r
421 the conversion is returned.\r
422 Additional conversion parameters are specified in Flags. \r
423 The Flags bit LEFT_JUSTIFY is always ignored.\r
424 All conversions are left justified in Buffer.\r
425 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
426 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas \r
427 are inserted every 3rd digit starting from the right.\r
428 If Value is < 0, then the fist character in Buffer is a '-'.\r
429 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer\r
430 is padded with '0' characters so the combination of the optional '-'\r
431 sign character, '0' characters, digit characters for Value, and the \r
432 Null-terminator add up to Width characters.\r
433\r
434 If Buffer is NULL, then ASSERT().\r
435 If unsupported bits are set in Flags, then ASSERT().\r
436 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
437\r
438 @param Buffer Pointer to the output buffer for the produced Null-terminated\r
439 ASCII string.\r
440 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
441 @param Value The 64-bit signed value to convert to a string.\r
442 @param Width The maximum number of ASCII characters to place in Buffer, not including\r
443 the Null-terminator.\r
444 \r
445 @return The number of ASCII characters in Buffer not including the Null-terminator.\r
446\r
447**/\r
448UINTN\r
449EFIAPI\r
450AsciiValueToString (\r
451 IN OUT CHAR8 *Buffer,\r
452 IN UINTN Flags,\r
453 IN INT64 Value,\r
454 IN UINTN Width\r
455 );\r
456\r
457#endif\r