merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / io.hxx
blob4536c3acd3d6d4cde9bbc9293e5f370c55bbcf5b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: io.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 // eigene Klasse fuer IO, die die systemunabhaengige Darstellung
31 // uebernimmt (bytes dreht, Character konvertiert)
32 // das Schreiben erfolgt aus Effizienzgruenden binaer
33 #ifndef _IO_HXX
34 #define _IO_HXX
36 #ifdef UNX
37 #include <unistd.h>
38 #else
39 #include <io.h>
40 #endif
42 #include <fcntl.h>
44 #include <sys/types.h>
45 #include <sys/stat.h>
48 #ifndef _KEYCOD_HXX //autogen
49 #include <vcl/keycod.hxx>
50 #endif
51 #include <tools/stream.hxx>
53 /*$
54 class BinaryFile {
55 int fd;
56 public:
57 enum IO_OpenMode {
58 BF_READ = O_RDONLY,
59 BF_WRITE = O_RDWR,
60 BF_CREATE = O_CREAT,
61 BF_TRUNC = O_TRUNC
63 // ctor oeffnet File im BinearMode, dtor schliesst es
64 BinaryFile(const String &, int eOpenMode);
65 ~BinaryFile();
66 BOOL Ok() const {
67 return -1 != fd;
69 operator int() const { return fd; }
73 class SwIOin {
74 private:
75 SvFileStream aStr; //$ ifstream
76 public:
77 // Stream wird im entsprechenden Mode erzeugt.
78 SwIOin(const String &rFilename, StreamMode nMode =
79 STREAM_READ | STREAM_NOCREATE );
81 SwIOin& operator>>(char& val);
82 SwIOin& operator>>(unsigned char& val);
83 SwIOin& operator>>(char* val);
84 SwIOin& operator>>(unsigned char* val);
85 SwIOin& operator>>(short& val);
86 SwIOin& operator>>(unsigned short& val);
87 SwIOin& operator>>(long& val);
88 SwIOin& operator>>(unsigned long& val);
89 String ReadString();
90 KeyCode ReadKeyCode();
91 // kann erweitert werden fuer weitere Arrays von
92 // Basistypen; nLen ist die Anzahl der Elemente
93 SwIOin& Read(char *buf, unsigned nLen);
95 int operator!() { return aStr.GetError() != SVSTREAM_OK; }
96 SvFileStream &operator()() {
97 return aStr;
101 class SwIOout {
102 private:
103 void _write(const char *buf, unsigned size);
104 SvFileStream aStr; //$ ofstream
105 public:
106 // Stream wird im entsprechenden Mode erzeugt.
107 SwIOout( const String &rFilename, StreamMode nMode =
108 STREAM_WRITE | STREAM_NOCREATE );
109 SwIOout& operator<<(char val);
110 SwIOout& operator<<(unsigned char val);
111 SwIOout& operator<<(char* val);
112 SwIOout& operator<<(unsigned char* val);
113 SwIOout& operator<<(short val);
114 SwIOout& operator<<(unsigned short val);
115 SwIOout& operator<<(long val);
116 SwIOout& operator<<(unsigned long val);
117 SwIOout& operator<<(const String &);
118 SwIOout& operator<<(const KeyCode &);
119 // kann erweitert werden fuer weitere Arrays von
120 // Basistypen; nLen ist die Anzahl der Elemente
121 SwIOout& Write(const char *buf, unsigned nLen);
123 int operator!() { return aStr.GetError() != SVSTREAM_OK; }
124 SvFileStream &operator()() {
125 return aStr;
130 class SwIOinout {
131 private:
132 SvFileStream aStr; //$ fstream
134 public:
135 // Stream wird im entsprechenden Mode erzeugt.
136 SwIOinout(const String &rFilename, StreamMode nMode =
137 STREAM_READWRITE | STREAM_NOCREATE );
139 SwIOinout& operator>>(char& val);
140 SwIOinout& operator>>(unsigned char& val);
141 SwIOinout& operator>>(char* val);
142 SwIOinout& operator>>(unsigned char* val);
143 SwIOinout& operator>>(short& val);
144 SwIOinout& operator>>(unsigned short& val);
145 SwIOinout& operator>>(long& val);
146 SwIOinout& operator>>(unsigned long& val);
147 String ReadString();
148 KeyCode ReadKeyCode();
149 // kann erweitert werden fuer weitere Arrays von
150 // Basistypen; nLen ist die Anzahl der Elemente
151 SwIOinout& Read(char *buf, unsigned nLen);
152 SwIOinout& Read(unsigned short *buf, unsigned nLen );
154 SwIOinout& operator<<(char val);
155 SwIOinout& operator<<(unsigned char val);
156 SwIOinout& operator<<(char* val);
157 SwIOinout& operator<<(unsigned char* val);
158 SwIOinout& operator<<(short val);
159 SwIOinout& operator<<(unsigned short val);
160 SwIOinout& operator<<(long val);
161 SwIOinout& operator<<(unsigned long val);
162 SwIOinout& operator<<(const String &);
163 SwIOinout& operator<<(const KeyCode &);
164 // kann erweitert werden fuer weitere Arrays von
165 // Basistypen; nLen ist die Anzahl der Elemente
166 SwIOinout& Write(const char *buf, unsigned nLen);
168 int operator!() { return aStr.GetError() != SVSTREAM_OK; }
169 SvFileStream &operator()() {
170 return aStr;
173 BOOL Ok();
178 #endif