]> git.saurik.com Git - apple/icu.git/blame - icuSources/io/ufile.h
ICU-551.51.4.tar.gz
[apple/icu.git] / icuSources / io / ufile.h
CommitLineData
374ca955 1/*
46f4442e
A
2 *******************************************************************************
3 *
b331163b 4 * Copyright (C) 1998-2014, International Business Machines
46f4442e
A
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 */
374ca955
A
18
19#ifndef UFILE_H
20#define UFILE_H
21
22#include "unicode/utypes.h"
b331163b
A
23
24#if !UCONFIG_NO_CONVERSION
25
374ca955
A
26#include "unicode/ucnv.h"
27#include "unicode/utrans.h"
28#include "locbund.h"
29
30/* The buffer size for fromUnicode calls */
31#define UFILE_CHARBUFFER_SIZE 1024
32
33/* The buffer size for toUnicode calls */
34#define UFILE_UCHARBUFFER_SIZE 1024
35
36/* A UFILE */
37
38#if !UCONFIG_NO_TRANSLITERATION
39
40typedef struct {
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;
47
48#endif
49
50typedef 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 */
54
55#if !UCONFIG_NO_FORMATTING
56 ULocaleBundle fBundle; /* formatters */
57#endif
58} u_localized_string;
59
60struct UFILE {
61#if !UCONFIG_NO_TRANSLITERATION
62 UFILETranslitBuffer *fTranslit;
63#endif
64
65 FILE *fFile; /* the actual filesystem interface */
66
67 UConverter *fConverter; /* for codeset conversion */
68
69 u_localized_string str; /* struct to handle strings for number formatting */
70
71 UChar fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */
72
73 UBool fOwnFile; /* TRUE if fFile should be closed */
74
75 int32_t fFileno; /* File number. Useful to determine if it's stdin. */
76};
77
78/**
79 * Like u_file_write but takes a flush parameter
80 */
46f4442e 81U_CFUNC int32_t U_EXPORT2
73c04bcf
A
82u_file_write_flush( const UChar *chars,
83 int32_t count,
84 UFILE *f,
85 UBool flushIO,
86 UBool flushTranslit);
374ca955
A
87
88/**
89 * Fill a UFILE's buffer with converted codepage data.
90 * @param f The UFILE containing the buffer to fill.
91 */
92void
93ufile_fill_uchar_buffer(UFILE *f);
94
95/**
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
100 */
101U_CFUNC UBool U_EXPORT2
102ufile_getch(UFILE *f, UChar *ch);
103
104/**
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
109 */
110U_CFUNC UBool U_EXPORT2
111ufile_getch32(UFILE *f, UChar32 *ch);
112
113/**
114 * Close out the transliterator and flush any data therein.
115 * @param f flu
116 */
117void
118ufile_close_translit(UFILE *f);
119
120/**
121 * Flush the buffer in the transliterator
122 * @param f UFile to flush
123 */
124void
125ufile_flush_translit(UFILE *f);
126
729e4ab9
A
127/**
128 * Flush the IO buffer
129 * @param f UFile to flush
130 */
131void
132ufile_flush_io(UFILE *f);
133
374ca955
A
134
135#endif
b331163b 136#endif