Go to the documentation of this file.
25 static const int max_write_length = 65532;
31 FltRecordWriter(std::ostream &out) :
78 std::min((
int)_datagram.
get_length() - start_byte, max_write_length - header_size);
79 FltOpcode opcode = _opcode;
82 if (flt_cat.is_debug()) {
84 <<
"Writing " << opcode <<
" of length "
85 << write_length + header_size <<
"\n";
93 nassertr((
int)dg.
get_length() == header_size, FE_internal);
97 assert(!flt_error_abort);
98 return FE_write_error;
102 _out.write((
const char *)_datagram.
get_data() + start_byte, write_length);
104 assert(!flt_error_abort);
105 return FE_write_error;
108 start_byte += write_length;
110 std::min((
int)_datagram.
get_length() - start_byte, max_write_length - header_size);
111 opcode = FO_continuation;
112 }
while (write_length > 0);
127 _datagram = datagram;
137 bool inserted = _instances_written.insert(instance_index).second;
145 if (instance ==
nullptr) {
146 assert(!flt_error_abort);
147 return FE_undefined_instance;
150 return instance->write_record_and_children(*
this);
FltError write_instance_def(FltHeader *header, int instance_index)
Ensures that the given instance definition has already been written to the file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_be_int16(int16_t value)
Adds a signed 16-bit big-endian integer to the datagram.
virtual void clear()
Resets the datagram to empty, in preparation for building up a new datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_datagram(const Datagram &datagram)
Sets the datagram that will be written when advance() is called.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.
Datagram & update_datagram()
Returns a modifiable reference to the datagram associated with the current record.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
size_t get_length() const
Returns the number of bytes in the datagram.
FltError write_record(FltOpcode opcode, const Datagram &datagram=Datagram())
A convenience function to quickly write a simple record that consists of an opcode and possibly a dat...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This special kind of record marks the top node of an instance subtree.
const void * get_data() const
Returns a pointer to the beginning of the datagram's data.
FltError advance()
Writes the current record to the flt file, and resets the current record to receive new data.