-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfile.h
50 lines (42 loc) · 931 Bytes
/
file.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef FILE_H
#define FILE_H
#include <Windows.h>
#include <cstddef>
#ifndef CP_UTF16
#define CP_UTF16 1200
#endif
/*#ifndef CP_UTF16_BE
#define CP_UTF16_BE 1201
#endif
#ifndef CP_UTF32
#define CP_UTF32 12000
#endif
#ifndef CP_UTF32_BE
#define CP_UTF32_BE 12001
#endif*/
// file
// - crude output file abstraction
// - does not throw
//
class file {
HANDLE h;
UINT cp; // codepage
public:
file (const wchar_t * filename, UINT cp);
~file ();
// created
// - returns true if file was created
//
bool created () const;
// write[ln]
// - converts (if needed) string to 'cp' and appends to file
// - writeln appends CR-LF
//
bool write (const wchar_t * string);
bool write (const wchar_t * string, std::size_t length);
bool writeln (const wchar_t * string);
private:
file (const file &) = delete;
file & operator = (const file &) = delete;
};
#endif