10class CLASS_DECL_ACME binary_stream :
11 virtual public stream_base
16 ::file_pointer m_pfile;
21 binary_stream(const ::file_pointer & pfile);
22 ~binary_stream()
override;
25 virtual bool is_end_of_file()
const;
28 virtual ::payload & options();
172 operator <<((::u8)u);
178 operator <<((::u8)255);
179 operator <<((::u16)u);
185 operator <<((::u8)255);
186 operator <<((::u16)65535);
187 operator <<((::u64)u);
194 inline void read_length(::u64 & u)
242 binary_stream & operator <<(::i8 ch) { raw_write(ch);
return *
this; }
243 binary_stream & operator <<(::u8 uch) { raw_write(uch);
return *
this; }
244 binary_stream & operator <<(::i16 sh) { raw_write(sh);
return *
this; }
245 binary_stream & operator <<(::u16 ush) { raw_write(ush);
return *
this; }
247 binary_stream & operator <<(unichar wch) {
248 raw_write(wch);
return *
this;
251 binary_stream & operator <<(
bool b) {
return operator <<((::u8)b ? 1 : 0); }
252 binary_stream & operator <<(::i32 i) { raw_write(i);
return *
this; }
253 binary_stream & operator <<(::u32 ui) { raw_write(ui);
return *
this; }
254 binary_stream & operator <<(::i64 hi) { raw_write(hi);
return *
this; }
255 binary_stream & operator <<(::u64 hn) { raw_write(hn);
return *
this; }
256#if defined(__APPLE__) || defined(__ANDROID__) || defined(RASPBERRYPIOS)
257 binary_stream & operator <<(ulong u) { raw_write(u);
return *
this; }
258 binary_stream & operator <<(
long l) { raw_write(l);
return *
this; }
260 binary_stream & operator <<(::f32 f) { raw_write(f);
return *
this; }
261 binary_stream & operator <<(::f64 d) { raw_write(d);
return *
this; }
267 binary_stream & operator <<(
const wide_character * pwsz) {
268 operator <<(
string(pwsz));
return *
this;
289 binary_stream & operator >>(
bool & b) { ::u8 uch; raw_read(uch); b = uch ? true :
false;
return *
this; }
293 binary_stream & operator >>(unichar & wch) { raw_read(wch);
return *
this; }
297#define NUMBER_TYPE_OPERATION(NUMBER_TYPE, NUMBER_NAME, NUMBER_SHORT_NAME, UPPER_CASE_NAME) \
298 binary_stream & operator >>(NUMBER_TYPE & NUMBER_SHORT_NAME) { raw_read(NUMBER_SHORT_NAME); return *this; }
299 DO_FOR_NUMBER_TYPES(NUMBER_TYPE_OPERATION)
300#undef NUMBER_TYPE_OPERATION
370 template <
typename BLOCK_TYPE >
371 inline void raw_write(
const BLOCK_TYPE & t)
374 write({ e_as_block, t });
379 template <
typename BLOCK_TYPE >
380 inline void raw_read(BLOCK_TYPE & t)
383 read({ e_as_block, t });
405 template <
typename BLOCK >
406 inline binary_stream & operator << (
const raw_block < BLOCK > & rawblock) { write(rawblock.block());
return *
this; }
407 template <
typename BLOCK >
408 inline binary_stream & operator >> (raw_block < BLOCK > & rawblock) { read(rawblock.block());
return *
this; }
477 void write_buffer_length(::u64 u)
483 operator <<((::u8)u);
489 operator <<((::u8)255);
490 operator <<((::u16)u);
496 operator <<((::u8)255);
497 operator <<((::u16)65535);
498 operator <<((::u64)u);
505 inline ::u64 read_buffer_length_unbounded_part2()
510 ush = m_pfile->get_u16_unbounded();
523 ull = m_pfile->get_u64_unbounded();
532 inline ::u64 read_buffer_length_unbounded()
535 ::u8 uch = m_pfile->get_byte_unbounded();
537 return uch < 255 ? uch : read_buffer_length_unbounded_part2();
542 virtual ::u64 read_buffer_length();
545 virtual string type_to_text(const ::platform::type & type);
548 virtual ::platform::type text_to_type(const ::scoped_string &scopedstr);
613 virtual void write_from_hex(
const void * pdata, memsize nCount);
616 virtual void write(const ::block & block);
619 virtual memsize defer_write(const ::block & block);
673 binary_stream & operator <<(const_char_pointer psz);
676 virtual binary_stream & operator <<(const ::range < const_char_pointer >& str);
699 virtual binary_stream & operator <<(
const block & block);
729 virtual binary_stream & operator >>(memory_base & m);
732 virtual binary_stream & operator <<(
const memory_base & m);
735 virtual binary_stream & operator >>(atom & atom);
1045 virtual void read_payload_type(enum_type & etype);
1048 virtual void save_payload_type(enum_type etype);
1050 virtual void read_payload_body(::payload & payload, enum_type etype);
1053 virtual binary_stream & operator >>(
string & str);
1087 virtual binary_stream & operator >>(block & block);
1141 if (m_pfile->read(&b, 1) != 1)
1144 throw_exception(error_end_of_file);
1154 return m_pfile->peek_byte();
1159 virtual void getline(char_pointer sz, character_count n);
1218 virtual void read_to_hex(
string & str, filesize tickStart, filesize tickEnd);
1220 virtual ::pointer<::particle>create_object_from_text(::particle * pparticle, const ::scoped_string & scopedstrText);
1243 void read(const ::block & block)
1249 m_gcount = m_pfile->read(block);
1251 if (m_gcount != block.size())
1263 virtual ::pointer < ::subparticle > read_particle();
1264 virtual void write_particle(const ::subparticle * pparticle);