home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / extra / ustdio / uscanf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  3.6 KB  |  98 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 uscanf.h
  13. *
  14. * Modification History:
  15. *
  16. *   Date        Name        Description
  17. *   12/02/98    stephen        Creation.
  18. *   03/13/99    stephen     Modified for new C API.
  19. *******************************************************************************
  20. */
  21.  
  22. #ifndef USCANF_H
  23. #define USCANF_H
  24.  
  25. #include "ustdio.h"
  26. #include "ufmt_cmn.h"
  27.  
  28. /**
  29.  * Struct encapsulating a single uscanf format specification.
  30.  */
  31. struct u_scanf_spec_info {
  32.   UChar     fSpec;            /* Format specification  */
  33.  
  34.   int32_t    fWidth;            /* Width  */
  35.  
  36.   UChar     fPadChar;        /* Padding character  */
  37.  
  38.   bool_t     fIsLongDouble;        /* L flag  */
  39.   bool_t     fIsShort;        /* h flag  */
  40.   bool_t     fIsLong;        /* l flag  */
  41.   bool_t     fIsLongLong;        /* ll flag  */
  42. };
  43. typedef struct u_scanf_spec_info u_scanf_spec_info;
  44.  
  45. /**
  46.  * A u_scanf info function.
  47.  * A u_scanf info is reponsible for reporting to u_scanf how many
  48.  * arguments are required for the <TT>u_scanf_spec_info</TT> <TT>info</TT>,
  49.  * and what their types are.
  50.  * @param info A pointer to a <TT>uscan_info</TT> struct containing
  51.  * information on the format specification.
  52.  * @param argtypes The array to receive the types of arguments specified
  53.  * by <TT>info</TT>.
  54.  * @param n The number of available slots in the array <TT>argtypes</TT>
  55.  * @return The number of arguments required by <TT>info</TT>.
  56.  */
  57. typedef int32_t (*u_scanf_info) (const u_scanf_spec_info     *info,
  58.                 int32_t             *argtypes,
  59.                 int32_t             n);
  60.  
  61. /**
  62.  * A u_scanf handler function.  
  63.  * A u_scanf handler is responsible for handling a single u_scanf 
  64.  * format specification, for example 'd' or 's'.
  65.  * @param stream The UFILE to which to write output.
  66.  * @param info A pointer to a <TT>u_scanf_spec_info</TT> struct containing
  67.  * information on the format specification.
  68.  * @param args A pointer to the argument data
  69.  * @param fmt A pointer to the first character in the format string
  70.  * following the spec.
  71.  * @param consumed On output, set to the number of characters consumed
  72.  * in <TT>fmt</TT>.
  73.  * @return The number of arguments converted and assigned, or -1 if an
  74.  * error occurred.
  75.  */
  76. typedef int32_t (*u_scanf_handler) (UFILE            *stream,
  77.                    const u_scanf_spec_info     *info,
  78.                    ufmt_args  *args,
  79.                    const UChar            *fmt,
  80.                    int32_t            *consumed);
  81.  
  82. /**
  83.  * Register a u_scanf handler function with u_scanf.
  84.  * @param spec The format specififier handled by the handler <TT>func</TT>.
  85.  * @param nfo A pointer to the <TT>u_scanf_info</TT> function used
  86.  * to determine how many arguments are required for <TT>spec</TT>, and
  87.  * what their types are.
  88.  * @param handler A pointer to the <TT>u_scanf_handler</TT> function.
  89.  * @return 0 if successful
  90.  */
  91. int32_t
  92. u_scanf_register_handler (UChar            spec, 
  93.              u_scanf_info         info,
  94.              u_scanf_handler     handler);
  95.  
  96. #endif
  97.  
  98.