intl/icu/source/io/ufile.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/io/ufile.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,132 @@
     1.4 +/*
     1.5 + *******************************************************************************
     1.6 + *
     1.7 + *   Copyright (C) 1998-2010, International Business Machines
     1.8 + *   Corporation and others.  All Rights Reserved.
     1.9 + *
    1.10 + *******************************************************************************
    1.11 + *
    1.12 + * File ufile.h
    1.13 + *
    1.14 + * Modification History:
    1.15 + *
    1.16 + *   Date        Name        Description
    1.17 + *   12/01/98    stephen        Creation.
    1.18 + *   03/12/99    stephen     Modified for new C API.
    1.19 + *******************************************************************************
    1.20 + */
    1.21 +
    1.22 +#ifndef UFILE_H
    1.23 +#define UFILE_H
    1.24 +
    1.25 +#include "unicode/utypes.h"
    1.26 +#include "unicode/ucnv.h"
    1.27 +#include "unicode/utrans.h"
    1.28 +#include "locbund.h"
    1.29 +
    1.30 +/* The buffer size for fromUnicode calls */
    1.31 +#define UFILE_CHARBUFFER_SIZE 1024
    1.32 +
    1.33 +/* The buffer size for toUnicode calls */
    1.34 +#define UFILE_UCHARBUFFER_SIZE 1024
    1.35 +
    1.36 +/* A UFILE */
    1.37 +
    1.38 +#if !UCONFIG_NO_TRANSLITERATION
    1.39 +
    1.40 +typedef struct {
    1.41 +    UChar  *buffer;             /* Beginning of buffer */
    1.42 +    int32_t capacity;           /* Capacity of buffer */
    1.43 +    int32_t pos;                /* Beginning of untranslitted data */
    1.44 +    int32_t length;             /* Length *from beginning of buffer* of untranslitted data */
    1.45 +    UTransliterator *translit;
    1.46 +} UFILETranslitBuffer;
    1.47 +
    1.48 +#endif
    1.49 +
    1.50 +typedef struct u_localized_string {
    1.51 +    UChar       *fPos;          /* current pos in fUCBuffer */
    1.52 +    const UChar *fLimit;        /* data limit in fUCBuffer */
    1.53 +    UChar       *fBuffer;       /* Place to write the string */
    1.54 +
    1.55 +#if !UCONFIG_NO_FORMATTING
    1.56 +    ULocaleBundle  fBundle; /* formatters */
    1.57 +#endif
    1.58 +} u_localized_string;
    1.59 +
    1.60 +struct UFILE {
    1.61 +#if !UCONFIG_NO_TRANSLITERATION
    1.62 +    UFILETranslitBuffer *fTranslit;
    1.63 +#endif
    1.64 +
    1.65 +    FILE        *fFile;         /* the actual filesystem interface */
    1.66 +
    1.67 +    UConverter  *fConverter;    /* for codeset conversion */
    1.68 +
    1.69 +    u_localized_string str;     /* struct to handle strings for number formatting */
    1.70 +
    1.71 +    UChar       fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */
    1.72 +
    1.73 +    UBool       fOwnFile;       /* TRUE if fFile should be closed */
    1.74 +
    1.75 +    int32_t     fFileno;        /* File number. Useful to determine if it's stdin. */
    1.76 +};
    1.77 +
    1.78 +/**
    1.79 + * Like u_file_write but takes a flush parameter
    1.80 + */
    1.81 +U_CFUNC int32_t U_EXPORT2
    1.82 +u_file_write_flush( const UChar     *chars, 
    1.83 +        int32_t     count, 
    1.84 +        UFILE       *f,
    1.85 +        UBool       flushIO,
    1.86 +        UBool       flushTranslit);
    1.87 +
    1.88 +/**
    1.89 + * Fill a UFILE's buffer with converted codepage data.
    1.90 + * @param f The UFILE containing the buffer to fill.
    1.91 + */
    1.92 +void
    1.93 +ufile_fill_uchar_buffer(UFILE *f);
    1.94 +
    1.95 +/**
    1.96 + * Get one code unit and detect whether the end of file has been reached.
    1.97 + * @param f The UFILE containing the characters.
    1.98 + * @param ch The read in character
    1.99 + * @return TRUE if the character is valid, or FALSE when EOF has been detected
   1.100 + */
   1.101 +U_CFUNC UBool U_EXPORT2
   1.102 +ufile_getch(UFILE *f, UChar *ch);
   1.103 +
   1.104 +/**
   1.105 + * Get one character and detect whether the end of file has been reached.
   1.106 + * @param f The UFILE containing the characters.
   1.107 + * @param ch The read in character
   1.108 + * @return TRUE if the character is valid, or FALSE when EOF has been detected
   1.109 + */
   1.110 +U_CFUNC UBool U_EXPORT2
   1.111 +ufile_getch32(UFILE *f, UChar32 *ch);
   1.112 +
   1.113 +/**
   1.114 + * Close out the transliterator and flush any data therein.
   1.115 + * @param f flu
   1.116 + */
   1.117 +void 
   1.118 +ufile_close_translit(UFILE *f);
   1.119 +
   1.120 +/**
   1.121 + * Flush the buffer in the transliterator 
   1.122 + * @param f UFile to flush
   1.123 + */
   1.124 +void 
   1.125 +ufile_flush_translit(UFILE *f);
   1.126 +
   1.127 +/**
   1.128 + * Flush the IO buffer
   1.129 + * @param f UFile to flush
   1.130 + */
   1.131 +void 
   1.132 +ufile_flush_io(UFILE *f);
   1.133 +
   1.134 +
   1.135 +#endif

mercurial