]> git.saurik.com Git - apple/icu.git/blob - icuSources/io/ufile.h
ICU-6.2.8.tar.gz
[apple/icu.git] / icuSources / io / ufile.h
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 1998-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 *
9 * File ufile.h
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 12/01/98 stephen Creation.
15 * 03/12/99 stephen Modified for new C API.
16 *******************************************************************************
17 */
18
19 #ifndef UFILE_H
20 #define UFILE_H
21
22 #include "unicode/utypes.h"
23 #include "unicode/ucnv.h"
24 #include "unicode/utrans.h"
25 #include "locbund.h"
26
27 /* The buffer size for fromUnicode calls */
28 #define UFILE_CHARBUFFER_SIZE 1024
29
30 /* The buffer size for toUnicode calls */
31 #define UFILE_UCHARBUFFER_SIZE 1024
32
33 /* A UFILE */
34
35 #if !UCONFIG_NO_TRANSLITERATION
36
37 typedef struct {
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;
44
45 #endif
46
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 */
51
52 #if !UCONFIG_NO_FORMATTING
53 ULocaleBundle fBundle; /* formatters */
54 #endif
55 } u_localized_string;
56
57 struct UFILE {
58 #if !UCONFIG_NO_TRANSLITERATION
59 UFILETranslitBuffer *fTranslit;
60 #endif
61
62 FILE *fFile; /* the actual filesystem interface */
63
64 UConverter *fConverter; /* for codeset conversion */
65
66 u_localized_string str; /* struct to handle strings for number formatting */
67
68 UChar fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */
69
70 UBool fOwnFile; /* TRUE if fFile should be closed */
71
72 int32_t fFileno; /* File number. Useful to determine if it's stdin. */
73 };
74
75 /**
76 * Like u_file_write but takes a flush parameter
77 */
78 U_CAPI int32_t U_EXPORT2
79 u_file_write_flush( const UChar *chars,
80 int32_t count,
81 UFILE *f,
82 UBool flush);
83
84 /**
85 * Fill a UFILE's buffer with converted codepage data.
86 * @param f The UFILE containing the buffer to fill.
87 */
88 void
89 ufile_fill_uchar_buffer(UFILE *f);
90
91 /**
92 * Get one code unit and detect whether the end of file has been reached.
93 * @param f The UFILE containing the characters.
94 * @param ch The read in character
95 * @return TRUE if the character is valid, or FALSE when EOF has been detected
96 */
97 U_CFUNC UBool U_EXPORT2
98 ufile_getch(UFILE *f, UChar *ch);
99
100 /**
101 * Get one character and detect whether the end of file has been reached.
102 * @param f The UFILE containing the characters.
103 * @param ch The read in character
104 * @return TRUE if the character is valid, or FALSE when EOF has been detected
105 */
106 U_CFUNC UBool U_EXPORT2
107 ufile_getch32(UFILE *f, UChar32 *ch);
108
109 /**
110 * Close out the transliterator and flush any data therein.
111 * @param f flu
112 */
113 void
114 ufile_close_translit(UFILE *f);
115
116 /**
117 * Flush the buffer in the transliterator
118 * @param f UFile to flush
119 */
120 void
121 ufile_flush_translit(UFILE *f);
122
123
124 #endif