]>
git.saurik.com Git - apple/icu.git/blob - icuSources/io/ufile.h
2 *******************************************************************************
4 * Copyright (C) 1998-2014, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
11 * Modification History:
13 * Date Name Description
14 * 12/01/98 stephen Creation.
15 * 03/12/99 stephen Modified for new C API.
16 *******************************************************************************
22 #include "unicode/utypes.h"
24 #if !UCONFIG_NO_CONVERSION
26 #include "unicode/ucnv.h"
27 #include "unicode/utrans.h"
30 /* The buffer size for fromUnicode calls */
31 #define UFILE_CHARBUFFER_SIZE 1024
33 /* The buffer size for toUnicode calls */
34 #define UFILE_UCHARBUFFER_SIZE 1024
38 #if !UCONFIG_NO_TRANSLITERATION
41 UChar
*buffer
; /* Beginning of buffer */
42 int32_t capacity
; /* Capacity of buffer */
43 int32_t pos
; /* Beginning of untranslitted data */
44 int32_t length
; /* Length *from beginning of buffer* of untranslitted data */
45 UTransliterator
*translit
;
46 } UFILETranslitBuffer
;
50 typedef struct u_localized_string
{
51 UChar
*fPos
; /* current pos in fUCBuffer */
52 const UChar
*fLimit
; /* data limit in fUCBuffer */
53 UChar
*fBuffer
; /* Place to write the string */
55 #if !UCONFIG_NO_FORMATTING
56 ULocaleBundle fBundle
; /* formatters */
61 #if !UCONFIG_NO_TRANSLITERATION
62 UFILETranslitBuffer
*fTranslit
;
65 FILE *fFile
; /* the actual filesystem interface */
67 UConverter
*fConverter
; /* for codeset conversion */
69 u_localized_string str
; /* struct to handle strings for number formatting */
71 UChar fUCBuffer
[UFILE_UCHARBUFFER_SIZE
];/* buffer used for toUnicode */
73 UBool fOwnFile
; /* TRUE if fFile should be closed */
75 int32_t fFileno
; /* File number. Useful to determine if it's stdin. */
79 * Like u_file_write but takes a flush parameter
81 U_CFUNC
int32_t U_EXPORT2
82 u_file_write_flush( const UChar
*chars
,
89 * Fill a UFILE's buffer with converted codepage data.
90 * @param f The UFILE containing the buffer to fill.
93 ufile_fill_uchar_buffer(UFILE
*f
);
96 * Get one code unit and detect whether the end of file has been reached.
97 * @param f The UFILE containing the characters.
98 * @param ch The read in character
99 * @return TRUE if the character is valid, or FALSE when EOF has been detected
101 U_CFUNC UBool U_EXPORT2
102 ufile_getch(UFILE
*f
, UChar
*ch
);
105 * Get one character and detect whether the end of file has been reached.
106 * @param f The UFILE containing the characters.
107 * @param ch The read in character
108 * @return TRUE if the character is valid, or FALSE when EOF has been detected
110 U_CFUNC UBool U_EXPORT2
111 ufile_getch32(UFILE
*f
, UChar32
*ch
);
114 * Close out the transliterator and flush any data therein.
118 ufile_close_translit(UFILE
*f
);
121 * Flush the buffer in the transliterator
122 * @param f UFile to flush
125 ufile_flush_translit(UFILE
*f
);
128 * Flush the IO buffer
129 * @param f UFile to flush
132 ufile_flush_io(UFILE
*f
);