File: file.sip

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 239,888 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 95
file content (100 lines) | stat: -rw-r--r-- 2,310 bytes parent folder | download | duplicates (4)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
class std__openmode
{
%TypeHeaderCode
	#include <BALL/SYSTEM/file.h>
	using std__openmode = File::OpenMode;
%End
	public:
};

class File
{
%TypeHeaderCode
	#include <BALL/SYSTEM/file.h>
%End
	public:

	File();
	File(const String&, OpenMode openmode = std::ios::in);
	~File();
	bool open(const String&, OpenMode openmode = std::ios::in);

	bool reopen();
	void close();
	const String& getName() const;
	Size getSize();
	OpenMode getOpenMode() const;
	bool copyTo(const String&);
	bool moveTo(const String&);
	bool remove();
	bool renameTo(const String&);
	bool truncate(int) const;
	bool operator == (const File&) const;
	bool operator != (const File&) const;
	bool isOpen() const;
	bool isClosed() const;
	bool isAccessible() const;
	bool isCanonized() const;
	bool isReadable() const;
	bool isWritable() const;
	bool isExecutable() const;
	bool isValid() const;

	private:
	File(const File&);
};

class OpenMode
{
%TypeHeaderCode
	#include <BALL/SYSTEM/file.h>
	using OpenMode = File::OpenMode;
%End
	public:

	SIP_PYOBJECT __str__();
%MethodCode
	OpenMode om = *sipCpp;
	const char* mode_string;
	switch ((int)om)
	{
		case (int)std::ios::app: 		mode_string = "std::ios::app"; break;
		case (int)std::ios::binary:	mode_string = "std::ios::binary"; break;
		case (int)std::ios::ate: 		mode_string = "std::ios::ate"; break;
		case (int)std::ios::trunc: 	mode_string = "std::ios::trunc"; break;
		case (int)std::ios::out: 		mode_string = "std::ios::out"; break;
		case (int)std::ios::in: 		mode_string = "std::ios::in"; break;
		default:										mode_string = "";
	}
	sipRes = PyString_FromString(mode_string);
%End

%ConvertToTypeCode
	if (sipIsErr == NULL)
		return (PyInt_Check(sipPy) || BALL_IS_SUBCLASS_INSTANCE(sipPy, OpenMode));

	if (PyInt_Check(sipPy))
	{
		int mode = PyInt_AS_LONG(sipPy);
		File::OpenMode result;
		switch (mode)
		{
			case std::ios::out:		result = std::ios::out; break;
			case std::ios::binary:	result = std::ios::binary; break;
			case std::ios::ate:		result = std::ios::ate; break;
			case std::ios::trunc:	result = std::ios::trunc; break;
			case std::ios::app:		result = std::ios::app; break;

			case std::ios::in:
			default: result = std::ios::in;
		};
		*sipCppPtr = new OpenMode(result);

		return 1;
	}

	*sipCppPtr = BALL_CONVERT_TO_CPP(OpenMode);

	return 0;
%End
};