forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamWriter.h
More file actions
88 lines (74 loc) · 3.13 KB
/
streamWriter.h
File metadata and controls
88 lines (74 loc) · 3.13 KB
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
// Filename: streamWriter.h
// Created by: drose (04Aug02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef STREAMWRITER_H
#define STREAMWRITER_H
#include "dtoolbase.h"
#include "pnotify.h"
#include "numeric_types.h"
#include "littleEndian.h"
#include "bigEndian.h"
////////////////////////////////////////////////////////////////////
// Class : StreamWriter
// Description : A StreamWriter object is used to write sequential
// binary data directly to an ostream. Its interface is
// very similar to Datagram by design; it's primarily
// intended as a convenience to eliminate the overhead
// of writing bytes to a Datagram and then writing the
// Datagram to a stream.
////////////////////////////////////////////////////////////////////
class EXPCL_DTOOLCONFIG StreamWriter {
public:
INLINE StreamWriter(ostream &out);
PUBLISHED:
INLINE StreamWriter(ostream *out, bool owns_stream);
INLINE StreamWriter(const StreamWriter ©);
INLINE void operator = (const StreamWriter ©);
INLINE ~StreamWriter();
INLINE ostream *get_ostream() const;
BLOCKING INLINE void add_bool(bool value);
BLOCKING INLINE void add_int8(PN_int8 value);
BLOCKING INLINE void add_uint8(PN_uint8 value);
// The default numeric packing is little-endian.
BLOCKING INLINE void add_int16(PN_int16 value);
BLOCKING INLINE void add_int32(PN_int32 value);
BLOCKING INLINE void add_int64(PN_int64 value);
BLOCKING INLINE void add_uint16(PN_uint16 value);
BLOCKING INLINE void add_uint32(PN_uint32 value);
BLOCKING INLINE void add_uint64(PN_uint64 value);
BLOCKING INLINE void add_float32(float value);
BLOCKING INLINE void add_float64(PN_float64 value);
// These functions pack numbers big-endian, in case that's desired.
BLOCKING INLINE void add_be_int16(PN_int16 value);
BLOCKING INLINE void add_be_int32(PN_int32 value);
BLOCKING INLINE void add_be_int64(PN_int64 value);
BLOCKING INLINE void add_be_uint16(PN_uint16 value);
BLOCKING INLINE void add_be_uint32(PN_uint32 value);
BLOCKING INLINE void add_be_uint64(PN_uint64 value);
BLOCKING INLINE void add_be_float32(float value);
BLOCKING INLINE void add_be_float64(PN_float64 value);
BLOCKING INLINE void add_string(const string &str);
BLOCKING INLINE void add_string32(const string &str);
BLOCKING INLINE void add_z_string(string str);
BLOCKING INLINE void add_fixed_string(const string &str, size_t size);
BLOCKING void pad_bytes(size_t size);
BLOCKING INLINE void append_data(const void *data, size_t size);
BLOCKING INLINE void append_data(const string &data);
BLOCKING INLINE void flush();
BLOCKING INLINE void write(const string &str);
private:
ostream *_out;
bool _owns_stream;
};
#include "streamWriter.I"
#endif