aboutsummaryrefslogtreecommitdiffstats
path: root/tests/libsample/simplefile.h
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-10-20 15:34:18 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-10-20 15:34:18 -0300
commita1ea10151397cefd86aa0f6c4822932d2cc6a601 (patch)
tree72a43ad326839a1c56217b893f999c28ad0c30f3 /tests/libsample/simplefile.h
parent0953187f7b13b8ca410c8db8fa856154cc6729a8 (diff)
added the SimpleFile class to the sample library to check how a
method returning a boolean value that indicates success/failure on a IO operation could be modified to express the any occurring problems as Python exceptions (in this case IOError); the generator was changed to return a 'None' value for Python callers on methods that had it's return value removed
Diffstat (limited to 'tests/libsample/simplefile.h')
-rw-r--r--tests/libsample/simplefile.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/libsample/simplefile.h b/tests/libsample/simplefile.h
new file mode 100644
index 000000000..e709557d2
--- /dev/null
+++ b/tests/libsample/simplefile.h
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the Shiboken Python Binding Generator project.
+ *
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: PySide team <contact@pyside.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation. Please
+ * review the following information to ensure the GNU Lesser General
+ * Public License version 2.1 requirements will be met:
+ * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ *
+ * As a special exception to the GNU Lesser General Public License
+ * version 2.1, the object code form of a "work that uses the Library"
+ * may incorporate material from a header file that is part of the
+ * Library. You may distribute such object code under terms of your
+ * choice, provided that the incorporated material (i) does not exceed
+ * more than 5% of the total size of the Library; and (ii) is limited to
+ * numerical parameters, data structure layouts, accessors, macros,
+ * inline functions and templates.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef SIMPLEFILE_H
+#define SIMPLEFILE_H
+
+#include <stdio.h>
+
+class SimpleFile
+{
+public:
+ explicit SimpleFile(const char* filename)
+ : m_filename(filename), m_descriptor(0), m_size(0)
+ {
+ printf("[%s] filename: %s\n", __PRETTY_FUNCTION__, m_filename);
+ }
+
+ ~SimpleFile()
+ {
+ this->close();
+ }
+
+ const char* filename()
+ {
+ return m_filename;
+ }
+
+ long size()
+ {
+ return m_size;
+ }
+
+ int fileno()
+ {
+ if (m_descriptor)
+ return m_descriptor->_fileno;
+ return -1;
+ }
+
+ bool open();
+ void close();
+
+private:
+ const char* m_filename;
+ FILE* m_descriptor;
+ long m_size;
+};
+
+#endif // SIMPLEFILE_H
+