]>
git.saurik.com Git - apple/icu.git/blob - icuSources/io/ufile.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 1998-2014, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
13 * Modification History:
15 * Date Name Description
16 * 12/01/98 stephen Creation.
17 * 03/12/99 stephen Modified for new C API.
18 *******************************************************************************
24 #include "unicode/utypes.h"
26 #if !UCONFIG_NO_CONVERSION
30 #include "unicode/ucnv.h"
31 #include "unicode/utrans.h"
34 /* The buffer size for fromUnicode calls */
35 #define UFILE_CHARBUFFER_SIZE 1024
37 /* The buffer size for toUnicode calls */
38 #define UFILE_UCHARBUFFER_SIZE 1024
42 #if !UCONFIG_NO_TRANSLITERATION
45 UChar
*buffer
; /* Beginning of buffer */
46 int32_t capacity
; /* Capacity of buffer */
47 int32_t pos
; /* Beginning of untranslitted data */
48 int32_t length
; /* Length *from beginning of buffer* of untranslitted data */
49 UTransliterator
*translit
;
50 } UFILETranslitBuffer
;
54 typedef struct u_localized_string
{
55 UChar
*fPos
; /* current pos in fUCBuffer */
56 const UChar
*fLimit
; /* data limit in fUCBuffer */
57 UChar
*fBuffer
; /* Place to write the string */
59 #if !UCONFIG_NO_FORMATTING
60 ULocaleBundle fBundle
; /* formatters */
65 #if !UCONFIG_NO_TRANSLITERATION
66 UFILETranslitBuffer
*fTranslit
;
69 FILE *fFile
; /* the actual filesystem interface */
71 UConverter
*fConverter
; /* for codeset conversion */
73 u_localized_string str
; /* struct to handle strings for number formatting */
75 UChar fUCBuffer
[UFILE_UCHARBUFFER_SIZE
];/* buffer used for toUnicode */
77 UBool fOwnFile
; /* TRUE if fFile should be closed */
79 int32_t fFileno
; /* File number. Useful to determine if it's stdin. */
83 * Like u_file_write but takes a flush parameter
85 U_CFUNC
int32_t U_EXPORT2
86 u_file_write_flush( const UChar
*chars
,
93 * Fill a UFILE's buffer with converted codepage data.
94 * @param f The UFILE containing the buffer to fill.
97 ufile_fill_uchar_buffer(UFILE
*f
);
100 * Get one code unit and detect whether the end of file has been reached.
101 * @param f The UFILE containing the characters.
102 * @param ch The read in character
103 * @return TRUE if the character is valid, or FALSE when EOF has been detected
105 U_CFUNC UBool U_EXPORT2
106 ufile_getch(UFILE
*f
, UChar
*ch
);
109 * Get one character and detect whether the end of file has been reached.
110 * @param f The UFILE containing the characters.
111 * @param ch The read in character
112 * @return TRUE if the character is valid, or FALSE when EOF has been detected
114 U_CFUNC UBool U_EXPORT2
115 ufile_getch32(UFILE
*f
, UChar32
*ch
);
118 * Close out the transliterator and flush any data therein.
122 ufile_close_translit(UFILE
*f
);
125 * Flush the buffer in the transliterator
126 * @param f UFile to flush
129 ufile_flush_translit(UFILE
*f
);
132 * Flush the IO buffer
133 * @param f UFile to flush
136 ufile_flush_io(UFILE
*f
);