15 #include "fltRecordWriter.h" 16 #include "fltInstanceDefinition.h" 17 #include "fltHeader.h" 18 #include "config_flt.h" 27 static const int max_write_length = 65532;
35 FltRecordWriter(ostream &out) :
95 min((
int)_datagram.
get_length() - start_byte, max_write_length - header_size);
96 FltOpcode opcode = _opcode;
99 if (flt_cat.is_debug()) {
101 <<
"Writing " << opcode <<
" of length " 102 << write_length + header_size <<
"\n";
110 nassertr((
int)dg.
get_length() == header_size, FE_internal);
114 assert(!flt_error_abort);
115 return FE_write_error;
119 _out.write((
const char *)_datagram.
get_data() + start_byte, write_length);
121 assert(!flt_error_abort);
122 return FE_write_error;
125 start_byte += write_length;
127 min((
int)_datagram.
get_length() - start_byte, max_write_length - header_size);
128 opcode = FO_continuation;
129 }
while (write_length > 0);
147 _datagram = datagram;
160 bool inserted = _instances_written.insert(instance_index).second;
169 assert(!flt_error_abort);
170 return FE_undefined_instance;
173 return instance->write_record_and_children(*
this);
void set_datagram(const Datagram &datagram)
Sets the datagram that will be written when advance() is called.
virtual void clear()
Resets the datagram to empty, in preparation for building up a new datagram.
FltError write_instance_def(FltHeader *header, int instance_index)
Ensures that the given instance definition has already been written to the file.
FltError advance()
Writes the current record to the flt file, and resets the current record to receive new data...
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.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This special kind of record marks the top node of an instance subtree.
void add_be_int16(PN_int16 value)
Adds a signed 16-bit big-endian integer to the datagram.
size_t get_length() const
Returns the number of bytes in the datagram.
const void * get_data() const
Returns a pointer to the beginning of the datagram's data.
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...