]> Creatis software - clitk.git/blob - utilities/CxImage/xfile.h
c0e4e2239f2fdd2e3d7618fe74b1ec37434c3862
[clitk.git] / utilities / CxImage / xfile.h
1 /*\r
2  * File:        xfile.h\r
3  * Purpose:     General Purpose File Class \r
4  */\r
5 /*\r
6   --------------------------------------------------------------------------------\r
7 \r
8         COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:\r
9 \r
10         CxFile (c)  11/May/2002 Davide Pizzolato - www.xdp.it\r
11         CxFile version 2.00 23/Aug/2002\r
12         CxFile version 2.10 16/Dec/2007\r
13         \r
14         Special thanks to Chris Shearer Cooper for new features, enhancements and bugfixes\r
15 \r
16         Covered code is provided under this license on an "as is" basis, without warranty\r
17         of any kind, either expressed or implied, including, without limitation, warranties\r
18         that the covered code is free of defects, merchantable, fit for a particular purpose\r
19         or non-infringing. The entire risk as to the quality and performance of the covered\r
20         code is with you. Should any covered code prove defective in any respect, you (not\r
21         the initial developer or any other contributor) assume the cost of any necessary\r
22         servicing, repair or correction. This disclaimer of warranty constitutes an essential\r
23         part of this license. No use of any covered code is authorized hereunder except under\r
24         this disclaimer.\r
25 \r
26         Permission is hereby granted to use, copy, modify, and distribute this\r
27         source code, or portions hereof, for any purpose, including commercial applications,\r
28         freely and without fee, subject to the following restrictions: \r
29 \r
30         1. The origin of this software must not be misrepresented; you must not\r
31         claim that you wrote the original software. If you use this software\r
32         in a product, an acknowledgment in the product documentation would be\r
33         appreciated but is not required.\r
34 \r
35         2. Altered source versions must be plainly marked as such, and must not be\r
36         misrepresented as being the original software.\r
37 \r
38         3. This notice may not be removed or altered from any source distribution.\r
39   --------------------------------------------------------------------------------\r
40  */\r
41 #if !defined(__xfile_h)\r
42 #define __xfile_h\r
43 \r
44 #if defined (WIN32) || defined (_WIN32_WCE)\r
45  #include <windows.h>\r
46 #endif\r
47 \r
48 #include <stdio.h>\r
49 #include <stdlib.h>\r
50 \r
51 #include "ximadef.h"\r
52 \r
53 class DLL_EXP CxFile\r
54 {\r
55 public:\r
56         CxFile(void) { };\r
57         virtual ~CxFile() { };\r
58 \r
59         virtual bool    Close() = 0;\r
60         virtual size_t  Read(void *buffer, size_t size, size_t count) = 0;\r
61         virtual size_t  Write(const void *buffer, size_t size, size_t count) = 0;\r
62         virtual bool    Seek(long offset, int origin) = 0;\r
63         virtual long    Tell() = 0;\r
64         virtual long    Size() = 0;\r
65         virtual bool    Flush() = 0;\r
66         virtual bool    Eof() = 0;\r
67         virtual long    Error() = 0;\r
68         virtual bool    PutC(unsigned char c)\r
69                 {\r
70                 // Default implementation\r
71                 size_t nWrote = Write(&c, 1, 1);\r
72                 return (bool)(nWrote == 1);\r
73                 }\r
74         virtual long    GetC() = 0;\r
75         virtual char *  GetS(char *string, int n) = 0;\r
76         virtual long    Scanf(const char *format, void* output) = 0;\r
77 };\r
78 \r
79 #endif //__xfile_h\r