File: qfileproto.h

package info (click to toggle)
postbooks 4.9.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 103,120 kB
  • sloc: cpp: 288,269; sh: 607; xml: 214; awk: 104; makefile: 49
file content (94 lines) | stat: -rw-r--r-- 4,199 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
/*
 * This file is part of the xTuple ERP: PostBooks Edition, a free and
 * open source Enterprise Resource Planning software suite,
 * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
 * It is licensed to you under the Common Public Attribution License
 * version 1.0, the full text of which (including xTuple-specific Exhibits)
 * is available at www.xtuple.com/CPAL.  By using this software, you agree
 * to be bound by its terms.
 */

#ifndef __QFILEPROTO_H__
#define __QFILEPROTO_H__

#include <QFile>
#include <QObject>
#include <QtScript>

Q_DECLARE_METATYPE(QFile*)

Q_DECLARE_METATYPE(enum QFile::FileError);
Q_DECLARE_METATYPE(enum QFile::MemoryMapFlags);
Q_DECLARE_METATYPE(enum QFile::Permission);

void setupQFileProto(QScriptEngine *engine);
QScriptValue constructQFile(QScriptContext *context, QScriptEngine *engine);

class QFileProto : public QObject, public QScriptable
{
  Q_OBJECT

  public:
    QFileProto(QObject *parent);

    Q_INVOKABLE bool                atEnd() const;
    Q_INVOKABLE qint64              bytesAvailable() const;
    Q_INVOKABLE qint64              bytesToWrite() const;
    Q_INVOKABLE bool                canReadLine() const;
    Q_INVOKABLE void                close();
    Q_INVOKABLE bool                copy(const QString &newName);
    Q_INVOKABLE QFile::FileError    error() const;
    Q_INVOKABLE QString             errorString() const;
    Q_INVOKABLE bool                exists() const;
    Q_INVOKABLE QString             fileName() const;
    Q_INVOKABLE bool                flush();
    Q_INVOKABLE bool                getChar(char *c);
    Q_INVOKABLE int                 handle() const;
    Q_INVOKABLE bool                isOpen() const;
    Q_INVOKABLE bool                isReadable() const;
    Q_INVOKABLE bool                isSequential() const;
    Q_INVOKABLE bool                isTextModeEnabled() const;
    Q_INVOKABLE bool                isWritable() const;
    Q_INVOKABLE bool                link(const QString &linkName);
    Q_INVOKABLE uchar              *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags = QFile::NoOptions);
    Q_INVOKABLE bool                open(FILE *fh, int mode);
    Q_INVOKABLE bool                open(int fd, int mode);
    Q_INVOKABLE bool                open(int mode);
    Q_INVOKABLE QIODevice::OpenMode openMode() const;
    Q_INVOKABLE qint64              peek(char *data, qint64 maxSize);
    Q_INVOKABLE QByteArray          peek(qint64 maxSize);
    Q_INVOKABLE QFile::Permissions  permissions() const;
    Q_INVOKABLE qint64              pos() const;
    Q_INVOKABLE bool                putChar(char c);
    Q_INVOKABLE qint64              read(char *data, qint64 maxSize);
    Q_INVOKABLE QByteArray          read(qint64 maxSize);
    Q_INVOKABLE QByteArray          readAll();
    Q_INVOKABLE qint64              readLine(char *data, qint64 maxSize);
    Q_INVOKABLE QByteArray          readLine(qint64 maxSize = 0);
    Q_INVOKABLE bool                remove();
    Q_INVOKABLE bool                rename(const QString &newName);
    Q_INVOKABLE bool                reset();
    Q_INVOKABLE bool                resize(qint64 sz);
    Q_INVOKABLE bool                seek(qint64 pos);
    Q_INVOKABLE void                setFileName(const QString &name);
    Q_INVOKABLE bool                setPermissions(QFile::Permissions permissions);
    Q_INVOKABLE void                setTextModeEnabled(bool enabled);
    Q_INVOKABLE qint64              size() const;
    Q_INVOKABLE QString             symLinkTarget() const;
    Q_INVOKABLE void                ungetChar(char c);
    Q_INVOKABLE bool                unmap(uchar *address);
    Q_INVOKABLE void                unsetError();
    Q_INVOKABLE bool                waitForBytesWritten(int msecs);
    Q_INVOKABLE bool                waitForReadyRead(int msecs);
    Q_INVOKABLE qint64              write(const QByteArray &byteArray);
    Q_INVOKABLE qint64              write(const char *data);
    Q_INVOKABLE qint64              write(const char *data, qint64 maxSize);

  signals:
    void aboutToClose();
    void bytesWritten(qint64 bytes);
    void readChannelFinished();
    void readyRead();
};

#endif