]>
git.saurik.com Git - apple/icu.git/blob - icuSources/io/ufile.h
2 *******************************************************************************
4 * Copyright (C) 1998-2010, 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"
23 #include "unicode/ucnv.h"
24 #include "unicode/utrans.h"
27 /* The buffer size for fromUnicode calls */
28 #define UFILE_CHARBUFFER_SIZE 1024
30 /* The buffer size for toUnicode calls */
31 #define UFILE_UCHARBUFFER_SIZE 1024
35 #if !UCONFIG_NO_TRANSLITERATION
38 UChar
*buffer
; /* Beginning of buffer */
39 int32_t capacity
; /* Capacity of buffer */
40 int32_t pos
; /* Beginning of untranslitted data */
41 int32_t length
; /* Length *from beginning of buffer* of untranslitted data */
42 UTransliterator
*translit
;
43 } UFILETranslitBuffer
;
47 typedef struct u_localized_string
{
48 UChar
*fPos
; /* current pos in fUCBuffer */
49 const UChar
*fLimit
; /* data limit in fUCBuffer */
50 UChar
*fBuffer
; /* Place to write the string */
52 #if !UCONFIG_NO_FORMATTING
53 ULocaleBundle fBundle
; /* formatters */
58 #if !UCONFIG_NO_TRANSLITERATION
59 UFILETranslitBuffer
*fTranslit
;
62 FILE *fFile
; /* the actual filesystem interface */
64 UConverter
*fConverter
; /* for codeset conversion */
66 u_localized_string str
; /* struct to handle strings for number formatting */
68 UChar fUCBuffer
[UFILE_UCHARBUFFER_SIZE
];/* buffer used for toUnicode */
70 UBool fOwnFile
; /* TRUE if fFile should be closed */
72 int32_t fFileno
; /* File number. Useful to determine if it's stdin. */
76 * Like u_file_write but takes a flush parameter
78 U_CFUNC
int32_t U_EXPORT2
79 u_file_write_flush( const UChar
*chars
,
86 * Fill a UFILE's buffer with converted codepage data.
87 * @param f The UFILE containing the buffer to fill.
90 ufile_fill_uchar_buffer(UFILE
*f
);
93 * Get one code unit and detect whether the end of file has been reached.
94 * @param f The UFILE containing the characters.
95 * @param ch The read in character
96 * @return TRUE if the character is valid, or FALSE when EOF has been detected
98 U_CFUNC UBool U_EXPORT2
99 ufile_getch(UFILE
*f
, UChar
*ch
);
102 * Get one character and detect whether the end of file has been reached.
103 * @param f The UFILE containing the characters.
104 * @param ch The read in character
105 * @return TRUE if the character is valid, or FALSE when EOF has been detected
107 U_CFUNC UBool U_EXPORT2
108 ufile_getch32(UFILE
*f
, UChar32
*ch
);
111 * Close out the transliterator and flush any data therein.
115 ufile_close_translit(UFILE
*f
);
118 * Flush the buffer in the transliterator
119 * @param f UFile to flush
122 ufile_flush_translit(UFILE
*f
);
125 * Flush the IO buffer
126 * @param f UFile to flush
129 ufile_flush_io(UFILE
*f
);