304 be_write(value, len); |
304 be_write(value, len); |
305 } |
305 } |
306 } |
306 } |
307 |
307 |
308 template <typename BE, typename IE, typename WriterPolicyImpl> |
308 template <typename BE, typename IE, typename WriterPolicyImpl> |
309 inline intptr_t WriterHost<BE, IE, WriterPolicyImpl>::reserve(size_t size) { |
309 inline int64_t WriterHost<BE, IE, WriterPolicyImpl>::reserve(size_t size) { |
310 if (ensure_size(size) != NULL) { |
310 if (ensure_size(size) != NULL) { |
311 intptr_t reserved_offset = this->current_offset(); |
311 const int64_t reserved_offset = this->current_offset(); |
312 this->set_current_pos(size); |
312 this->set_current_pos(size); |
313 return reserved_offset; |
313 return reserved_offset; |
314 } |
314 } |
315 this->cancel(); |
315 this->cancel(); |
316 return 0; |
316 return 0; |
317 } |
317 } |
318 |
318 |
319 template <typename BE, typename IE, typename WriterPolicyImpl> |
319 template <typename BE, typename IE, typename WriterPolicyImpl> |
320 template <typename T> |
320 template <typename T> |
321 inline void WriterHost<BE, IE, WriterPolicyImpl>::write_padded_at_offset(T value, intptr_t offset) { |
321 inline void WriterHost<BE, IE, WriterPolicyImpl>::write_padded_at_offset(T value, int64_t offset) { |
322 if (this->is_valid()) { |
322 if (this->is_valid()) { |
323 const intptr_t current = this->current_offset(); |
323 const int64_t current = this->current_offset(); |
324 this->seek(offset); |
324 this->seek(offset); |
325 write_padded(value); |
325 write_padded(value); |
326 this->seek(current); // restore |
326 this->seek(current); // restore |
327 } |
327 } |
328 } |
328 } |
329 |
329 |
330 template <typename BE, typename IE, typename WriterPolicyImpl> |
330 template <typename BE, typename IE, typename WriterPolicyImpl> |
331 template <typename T> |
331 template <typename T> |
332 inline void WriterHost<BE, IE, WriterPolicyImpl>::write_at_offset(T value, intptr_t offset) { |
332 inline void WriterHost<BE, IE, WriterPolicyImpl>::write_at_offset(T value, int64_t offset) { |
333 if (this->is_valid()) { |
333 if (this->is_valid()) { |
334 const intptr_t current = this->current_offset(); |
334 const int64_t current = this->current_offset(); |
335 this->seek(offset); |
335 this->seek(offset); |
336 write(value); |
336 write(value); |
337 this->seek(current); // restore |
337 this->seek(current); // restore |
338 } |
338 } |
339 } |
339 } |
340 |
340 |
341 template <typename BE, typename IE, typename WriterPolicyImpl> |
341 template <typename BE, typename IE, typename WriterPolicyImpl> |
342 template <typename T> |
342 template <typename T> |
343 inline void WriterHost<BE, IE, WriterPolicyImpl>::write_be_at_offset(T value, intptr_t offset) { |
343 inline void WriterHost<BE, IE, WriterPolicyImpl>::write_be_at_offset(T value, int64_t offset) { |
344 if (this->is_valid()) { |
344 if (this->is_valid()) { |
345 const intptr_t current = this->current_offset(); |
345 const int64_t current = this->current_offset(); |
346 this->seek(offset); |
346 this->seek(offset); |
347 be_write(value); |
347 be_write(value); |
348 this->seek(current); // restore |
348 this->seek(current); // restore |
349 } |
349 } |
350 } |
350 } |