Coverage Report

Created: 2025-06-13 06:30

/src/wxwidgets/include/wx/datstrm.h
Line
Count
Source (jump to first uncovered line)
1
/////////////////////////////////////////////////////////////////////////////
2
// Name:        wx/datstrm.h
3
// Purpose:     Data stream classes
4
// Author:      Guilhem Lavaux
5
// Modified by: Mickael Gilabert
6
// Created:     28/06/1998
7
// Copyright:   (c) Guilhem Lavaux
8
// Licence:     wxWindows licence
9
/////////////////////////////////////////////////////////////////////////////
10
11
#ifndef _WX_DATSTREAM_H_
12
#define _WX_DATSTREAM_H_
13
14
#include "wx/stream.h"
15
#include "wx/longlong.h"
16
#include "wx/convauto.h"
17
18
#if wxUSE_STREAMS
19
20
// Common wxDataInputStream and wxDataOutputStream parameters.
21
class WXDLLIMPEXP_BASE wxDataStreamBase
22
{
23
public:
24
0
    void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
25
26
    // By default we use extended precision (80 bit) format for both float and
27
    // doubles. Call this function to switch to alternative representation in
28
    // which IEEE 754 single precision (32 bits) is used for floats and double
29
    // precision (64 bits) is used for doubles.
30
    void UseBasicPrecisions()
31
0
    {
32
0
#if wxUSE_APPLE_IEEE
33
0
        m_useExtendedPrecision = false;
34
0
#endif // wxUSE_APPLE_IEEE
35
0
    }
36
37
    // UseExtendedPrecision() is not very useful as it corresponds to the
38
    // default value, only call it in your code if you want the compilation
39
    // fail with the error when using wxWidgets library compiled without
40
    // extended precision support.
41
#if wxUSE_APPLE_IEEE
42
    void UseExtendedPrecision()
43
0
    {
44
0
        m_useExtendedPrecision = true;
45
0
    }
46
#endif // wxUSE_APPLE_IEEE
47
48
    void SetConv( const wxMBConv &conv );
49
0
    wxMBConv *GetConv() const { return m_conv; }
50
51
protected:
52
    // Ctor and dtor are both protected, this class is never used directly but
53
    // only by its derived classes.
54
    wxDataStreamBase(const wxMBConv& conv);
55
    ~wxDataStreamBase();
56
57
58
    bool m_be_order;
59
60
#if wxUSE_APPLE_IEEE
61
    bool m_useExtendedPrecision;
62
#endif // wxUSE_APPLE_IEEE
63
64
    wxMBConv *m_conv;
65
66
    wxDECLARE_NO_COPY_CLASS(wxDataStreamBase);
67
};
68
69
70
class WXDLLIMPEXP_BASE wxDataInputStream : public wxDataStreamBase
71
{
72
public:
73
    wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8);
74
75
0
    bool IsOk() { return m_input->IsOk(); }
76
77
    wxUint64 Read64();
78
    wxLongLong ReadLL();
79
    wxUint32 Read32();
80
    wxUint16 Read16();
81
    wxUint8 Read8();
82
    double ReadDouble();
83
    float ReadFloat();
84
    wxString ReadString();
85
86
    void Read64(wxUint64 *buffer, size_t size);
87
    void Read64(wxInt64 *buffer, size_t size);
88
    void Read64(wxULongLong *buffer, size_t size);
89
    void Read64(wxLongLong *buffer, size_t size);
90
    void ReadLL(wxULongLong *buffer, size_t size);
91
    void ReadLL(wxLongLong *buffer, size_t size);
92
    void Read32(wxUint32 *buffer, size_t size);
93
    void Read16(wxUint16 *buffer, size_t size);
94
    void Read8(wxUint8 *buffer, size_t size);
95
    void ReadDouble(double *buffer, size_t size);
96
    void ReadFloat(float *buffer, size_t size);
97
98
    wxDataInputStream& operator>>(wxString& s);
99
    wxDataInputStream& operator>>(wxInt8& c);
100
    wxDataInputStream& operator>>(wxInt16& i);
101
    wxDataInputStream& operator>>(wxInt32& i);
102
    wxDataInputStream& operator>>(wxUint8& c);
103
    wxDataInputStream& operator>>(wxUint16& i);
104
    wxDataInputStream& operator>>(wxUint32& i);
105
    wxDataInputStream& operator>>(wxUint64& i);
106
    wxDataInputStream& operator>>(wxInt64& i);
107
    wxDataInputStream& operator>>(wxULongLong& i);
108
    wxDataInputStream& operator>>(wxLongLong& i);
109
    wxDataInputStream& operator>>(double& d);
110
    wxDataInputStream& operator>>(float& f);
111
112
protected:
113
    wxInputStream *m_input;
114
115
    wxDECLARE_NO_COPY_CLASS(wxDataInputStream);
116
};
117
118
class WXDLLIMPEXP_BASE wxDataOutputStream : public wxDataStreamBase
119
{
120
public:
121
    wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8);
122
123
0
    bool IsOk() { return m_output->IsOk(); }
124
125
    void Write64(wxUint64 i);
126
    void Write64(wxInt64 i);
127
    void WriteLL(const wxLongLong &ll);
128
    void WriteLL(const wxULongLong &ll);
129
    void Write32(wxUint32 i);
130
    void Write16(wxUint16 i);
131
    void Write8(wxUint8 i);
132
    void WriteDouble(double d);
133
    void WriteFloat(float f);
134
    void WriteString(const wxString& string);
135
136
    void Write64(const wxUint64 *buffer, size_t size);
137
    void Write64(const wxInt64 *buffer, size_t size);
138
    void Write64(const wxULongLong *buffer, size_t size);
139
    void Write64(const wxLongLong *buffer, size_t size);
140
    void WriteLL(const wxULongLong *buffer, size_t size);
141
    void WriteLL(const wxLongLong *buffer, size_t size);
142
    void Write32(const wxUint32 *buffer, size_t size);
143
    void Write16(const wxUint16 *buffer, size_t size);
144
    void Write8(const wxUint8 *buffer, size_t size);
145
    void WriteDouble(const double *buffer, size_t size);
146
    void WriteFloat(const float *buffer, size_t size);
147
148
    wxDataOutputStream& operator<<(const wxString& string);
149
    wxDataOutputStream& operator<<(wxInt8 c);
150
    wxDataOutputStream& operator<<(wxInt16 i);
151
    wxDataOutputStream& operator<<(wxInt32 i);
152
    wxDataOutputStream& operator<<(wxUint8 c);
153
    wxDataOutputStream& operator<<(wxUint16 i);
154
    wxDataOutputStream& operator<<(wxUint32 i);
155
    wxDataOutputStream& operator<<(wxUint64 i);
156
    wxDataOutputStream& operator<<(wxInt64 i);
157
    wxDataOutputStream& operator<<(const wxULongLong &i);
158
    wxDataOutputStream& operator<<(const wxLongLong &i);
159
    wxDataOutputStream& operator<<(double d);
160
    wxDataOutputStream& operator<<(float f);
161
162
protected:
163
    wxOutputStream *m_output;
164
165
    wxDECLARE_NO_COPY_CLASS(wxDataOutputStream);
166
};
167
168
#endif
169
  // wxUSE_STREAMS
170
171
#endif
172
    // _WX_DATSTREAM_H_