home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / extra / ustdio / uprintf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  3.7 KB  |  99 lines

  1. /*
  2. *******************************************************************************
  3. *                                                                             *
  4. * COPYRIGHT:                                                                  *
  5. *   (C) Copyright International Business Machines Corporation, 1999           *
  6. *   Licensed Material - Program-Property of IBM - All Rights Reserved.        *
  7. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  8. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  9. *                                                                             *
  10. *******************************************************************************
  11. *
  12. * File uprintf.h
  13. *
  14. * Modification History:
  15. *
  16. *   Date        Name        Description
  17. *   11/19/98    stephen        Creation.
  18. *   03/12/99    stephen     Modified for new C API.
  19. *******************************************************************************
  20. */
  21.  
  22. #ifndef UPRINTF_H
  23. #define UPRINTF_H
  24.  
  25. #include "utypes.h"
  26. #include "ustdio.h"
  27. #include "ufmt_cmn.h"
  28.  
  29. /**
  30.  * Struct encapsulating a single uprintf format specification.
  31.  */
  32. struct u_printf_spec_info {
  33.   UChar     fSpec;            /* Conversion specification */
  34.  
  35.   int32_t    fPrecision;        /* Precision  */
  36.   int32_t    fWidth;            /* Width  */
  37.  
  38.   UChar     fPadChar;        /* Padding character  */
  39.  
  40.   bool_t     fAlt;            /* # flag  */
  41.   bool_t     fSpace;            /* Space flag  */
  42.   bool_t     fLeft;            /* - flag  */
  43.   bool_t     fShowSign;        /* + flag  */
  44.   bool_t     fZero;            /* 0 flag  */
  45.  
  46.   bool_t     fIsLongDouble;        /* L flag  */
  47.   bool_t     fIsShort;        /* h flag  */
  48.   bool_t     fIsLong;        /* l flag  */
  49.   bool_t     fIsLongLong;        /* ll flag  */
  50. };
  51. typedef struct u_printf_spec_info u_printf_spec_info;
  52.  
  53. /**
  54.  * A u_printf info function.
  55.  * A u_printf info is reponsible for reporting to u_printf how many
  56.  * arguments are required for the <TT>u_printf_spec_info</TT> <TT>info</TT>,
  57.  * and what their types are.
  58.  * @param info A pointer to a <TT>u_print_info</TT> struct containing
  59.  * information on the format specification.
  60.  * @param argtypes The array to receive the types of arguments specified
  61.  * by <TT>info</TT>.
  62.  * @param n The number of available slots in the array <TT>argtypes</TT>
  63.  * @return The number of arguments required by <TT>info</TT>.
  64.  */
  65. typedef int32_t (*u_printf_info) (const u_printf_spec_info     *info,
  66.                   int32_t             *argtypes,
  67.                   int32_t             n);
  68.  
  69. /**
  70.  * A u_printf handler function.  
  71.  * A u_printf handler is responsible for handling a single u_printf 
  72.  * format specification, for example 'd' or 's'.
  73.  * @param stream The UFILE to which to write output.
  74.  * @param info A pointer to a <TT>u_printf_spec_info</TT> struct containing
  75.  * information on the format specification.
  76.  * @param args A pointer to the argument data
  77.  * @return The number of Unicode characters written to <TT>stream</TT>.
  78.  */
  79. typedef int32_t (*u_printf_handler) (UFILE             *stream,
  80.                      const u_printf_spec_info     *info,
  81.                      const ufmt_args            *args);
  82.  
  83. /**
  84.  * Register a uprintf handler function with uprintf.
  85.  * @param spec The format specififier handled by the handler <TT>func</TT>.
  86.  * @param info A pointer to the <TT>uprintf_info</TT> function used
  87.  * to determine how many arguments are required for <TT>spec</TT>, and
  88.  * what their types are.
  89.  * @param handler A pointer to the <TT>uprintf_handler</TT> function.
  90.  * @return 0 if successful
  91.  */
  92. int32_t
  93. u_printf_register_handler(UChar            spec, 
  94.               u_printf_info     info,
  95.               u_printf_handler     handler);
  96.  
  97. #endif
  98.  
  99.