acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
binary_stream.h
1#pragma once
2
3
4#include "file.h"
5#include "stream.h"
6#include "acme/prototype/prototype/memory.h"
7
8
10class CLASS_DECL_ACME binary_stream :
11 virtual public stream_base
12{
13public:
14
15
16 ::file_pointer m_pfile;
17 ::payload m_payloadOptions;
18
19
20 binary_stream();
21 binary_stream(const ::file_pointer & pfile);
22 ~binary_stream() override;
23
24
25 virtual bool is_end_of_file() const;
26
27
28 virtual ::payload & options();
29
30
31 //void write_buffer_length(::u64 u);
32 //::u64 read_buffer_length();
33
34
35
36 //RAW_POINTER operator ->() { return m_pfile; }
37 //const RAW_POINTER operator ->() const { return m_pfile; }
38
40
41// string fileName() { return GetFilePath(); }
42
43 // void close() ;
44
45 //inline void defer_set_storing_flag() { if (!has_storing_flag()) set_storing_flag(); }
46
47 //inline void set_storing() { m_bStoring = true; }
48
49 //inline void set_loading() { m_bStoring = false; }
50
51 //stream & operator = (const binary_stream & base) { m_pfile = base.m_pfile; return *this; }
52 //stream & operator = (binary_stream & base) { m_pfile = ::transfer(base.m_pfile); return *this; }
53
54 // FILE_POINTER & operator ->() { m_pfile; }
55
56 // stream * branch(const ::atom &) { return this; }
57
60
61
62
63 //::atom text_to_factory_id(const ::scoped_string & scopedstr);
64
65
66 //::string factory_id_to_text(const ::atom & atom);
67
68
69 //template < typename TYPE >
70 //void exchange(TYPE & t)
71 //{
72 // if (has_storing_flag())
73 // {
74 // write(t);
75 // }
76 // else
77 // {
78 // read(t);
79 // }
80 //}
81
86 //template < typename TYPE >
87 //void exchange(const ::atom &, TYPE & t)
88 //{
89
90 // ::pointer<::stream>pstream = branch(this, atom);
91
92 // t.exchange(*pstream);
93
94 //}
95
96 //explicit operator ::file::file * () { return m_pfile; }
97
98
99 // filesize translate(filesize offset, ::enum_seek eseek);
100
101
102 //string factory_id_to_text(const ::atom & atom) ;
103 //::atom text_to_factory_id(const ::scoped_string & scopedstrText) ;
104
105
106 //template < typename TYPE >
107 //stream & operator()(TYPE & t)
108 //{
109
110 // if (has_storing_flag())
111 // {
112
113 // *this << t;
114
115 // }
116 // else
117 // {
118
119 // *this >> t;
120
121 // }
122
123 // return *this;
124
125 //}
126
127
128 //bool is_open() const ;
129
130
131 // bool is_stream_null();
132 // bool is_stream_set();
133
134 //void * get_internal_data() ;
135 //memsize get_internal_data_size() const ;
136 //bool set_internal_data_size(memsize c) ;
137 //filesize get_position() const ;
138
139
140 //inline memsize read(void * pdata, memsize nCount) { return m_gcount = m_pfile->read(pdata, nCount); }
141
142 //binary_stream & operator >>(memory_base & m);
143 //binary_stream & operator <<(const memory_base & m);
144
145 // bool is_reader_null();
146 // bool is_reader_set();
147
148 //void read_to_hex(string & str, filesize iStart = -1, filesize iEnd = -1);
149
150 //void write_from_hex(const void * pdata, memsize nCount);
151
152 //void write(const void * pdata, memsize nCount);
153
154 //void write(const void * pdata, memsize nCount, memsize * dwWritten);
155
156 //bool is_writer_null() ;
157 //bool is_writer_set() ;
158
159 //void flush() ;
160
161 // void set_size(filesize len);
162
163 // This number represents a following stream of data with this length.
164 // So the extra bytes representing the variable length quantity are
165 // neglectable and worth due the very fast variable length encoding.
166 inline void write_length(::u64 u)
167 {
168
169 if (u < 255)
170 {
171
172 operator <<((::u8)u);
173
174 }
175 else if (u < 65535)
176 {
177
178 operator <<((::u8)255);
179 operator <<((::u16)u);
180
181 }
182 else
183 {
184
185 operator <<((::u8)255);
186 operator <<((::u16)65535);
187 operator <<((::u64)u);
188
189 }
190
191 }
192
193
194 inline void read_length(::u64 & u)
195 {
196
197 ::u8 uRead;
198
199 operator >>(uRead);
200
201 //if (!fail())
202 //{
203
204 if (uRead < 255)
205 {
206
207 u = uRead;
208
209 }
210 else
211 {
212
213 ::u16 uRead;
214
215 operator >>(uRead);
216
217 //if (!fail())
218 //{
219
220 if (uRead < 65535)
221 {
222
223 u = uRead;
224
225 }
226 else
227 {
228
229 operator >>(u);
230
231 }
232
233 }
234
235 // }
236
237 //}
238
239 }
240
241
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; }
246#ifdef WINDOWS
247 binary_stream & operator <<(unichar wch) {
248 raw_write(wch); return *this;
249 }
250#endif
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; }
259#endif
260 binary_stream & operator <<(::f32 f) { raw_write(f); return *this; }
261 binary_stream & operator <<(::f64 d) { raw_write(d); return *this; }
262 // void write(const ::i32_point & point) { raw_write(point); }
263 // void write(const ::i32_size & size) { raw_write(size); }
264 // void write(const ::i32_rectangle &crect) { raw_write(crect); }
265 //binary_stream & operator <<(const ::scoped_string & scopedstr);
266#ifdef WINDOWS
267 binary_stream & operator <<(const wide_character * pwsz) {
268 operator <<(string(pwsz)); return *this;
269 }
270#endif
271 //binary_stream & operator <<(const atom & atom);
272 //binary_stream & operator <<(const ::payload & payload);
273 //binary_stream & operator <<(const property & property);
274 //binary_stream & operator <<(const ::scoped_string & scopedstr);
278 //binary_stream & operator <<(const block & block);
279 //binary_stream & operator <<(const element & element);
280
281 /*::filesize tellp();
282 void seekp(filesize position);
283 void seekp(filesize offset, ::enum_seek eseek);*/
284 //void put(::i8 ch);
285
286
287
288
289 binary_stream & operator >>(bool & b) { ::u8 uch; raw_read(uch); b = uch ? true : false; return *this; }
290 //binary_stream & operator >>(::i8 & ch) { raw_read(ch); return *this; }
291 //binary_stream & operator >>(::u8 & uch) { raw_read(uch); return *this; }
292#ifdef WINDOWS
293 binary_stream & operator >>(unichar & wch) { raw_read(wch); return *this; }
294#endif
295
296
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
301
302
303 //binary_stream & operator >>(::i16 & sh) { raw_read(sh); return *this; }
304 //binary_stream & operator >>(::u16 & ush) { raw_read(ush); return *this; }
305 //binary_stream & operator >>(::i32 & i) { raw_read(i); return *this; }
306 //binary_stream & operator >>(::u32 & ui) {raw_read(ui); return *this; }
307 //binary_stream & operator >>(::i64 & hi) { raw_read(hi); return *this; }
308 //binary_stream & operator >>(::u64 & hn) { raw_read(::u64); return *this; }
309//#if defined(__APPLE__) || defined(__ANDROID__) || defined(RASPBERRYPIOS)
310// binary_stream & operator >>(ulong & u) {
311// raw_read(u); return *this;
312// }
313// binary_stream & operator >>(long & l) {
314// raw_read(l); return *this;
315// }
316//#endif
317 //binary_stream & operator >>(::f32 & f) { raw_read(f); return *this; }
318 //binary_stream & operator >>(::f64 & d) { raw_read(d); return *this; }
319 // void read(::i32_point & point) { raw_read(point); }
322 //binary_stream & operator >>(atom & atom);
323 //binary_stream & operator >>(::payload & payload);
324 // void read_var_type(enum_type & etype);
325 // void read_var_body(::payload & payload, enum_type etype);
326 //binary_stream & operator >>(property & property);
327 //binary_stream & operator >>(string & str);
331 //binary_stream & operator >>(block & block);
332 //binary_stream & operator >>(element & element);
333
334 // void save_var_type(::enum_type etype);
335
336 /* void getline(char_pointer sz, character_count n);
337 ::u8 get_byte();
338 ::u8 peek_byte();*/
339
340 // filesize get_position();
341 // filesize seek_from_begin(filesize position);
342 // void seek(filesize offset, ::enum_seek eseek);
343
344 //::filesize get_left() const;
345
346 //inline bool has_storing_flag() const { return m_bStoring; }
347 //inline bool is_loading() const { return !m_bStoring; }
348
349
350 // void write_file(const ::file::path & path, const ::matter & matter);
351 // void read_file(const ::file::path & path, ::matter & matter);
352
353 // void write_link(const ::scoped_string & scopedstrLink, ::pointer<::matter>& matter);
354 // void read_link(const ::scoped_string & scopedstrLink, ::pointer<::matter>& matter);
355
356 // void write_link(const ::matter * preference, const ::scoped_string & scopedstrLink, bool bReadOnly, ::matter * pobjectSaveOptions = nullptr);
357
358 // bool write_link(const ::matter * preference) ;
359 // void read_link(::matter * preference) ;
360
361
362 // bool get_object_link(const ::matter * preference, string & strLink, bool & bReadOnly) ;
363 // void set_object_link(const ::matter * preference, const ::scoped_string & scopedstrLink, bool bReadOnly) ;
364
365
366 // ::file::path get_link_path(const ::scoped_string & scopedstrLink);
367
368 //bool is_version(::collection::index i);
369
370 template < typename BLOCK_TYPE >
371 inline void raw_write(const BLOCK_TYPE & t) // must be POD type // block transfer // classes/structures with no members
372 {
373
374 write({ e_as_block, t });
375
376 }
377
378
379 template < typename BLOCK_TYPE >
380 inline void raw_read(BLOCK_TYPE & t) // must be POD type // block transfer // classes/structures with no members
381 {
382
383 read({ e_as_block, t });
384
385 }
386
387
388 //void read(void * pdata, memsize nCount);
389
390
391 //void xml_export(const ::xml::exportable & xmlexportable);
392
393 //void xml_import(::xml::importable & xmlimportable);
394
395
396 //template < typename BASE_TYPE >
397 //inline stream & save_object(const BASE_TYPE * pparticle);
398
399 //template < typename BASE_TYPE >
400 //inline ::pointer<BASE_TYPE>load_object();
401
402 //::pointer<::matter>create_object_from_text(const ::scoped_string & scopedstrText);
403
404
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; }
409
410
411
412 //template < typename TYPE >
413 //inline binary_stream & operator <<(const TYPE * p) { *this << *p; return *this; }
414
415 //template < typename TYPE >
416 //inline binary_stream & operator >>(TYPE * p) { *this >> *p; return *this; }
417
418 //template < typename TYPE >
419 //inline binary_stream & operator <<(const ::pointer<TYPE>& p) { *this << *p; return *this; }
420
421 //template < typename TYPE >
422 //inline binary_stream & operator >>(::pointer<TYPE>& p) { *this >> *p; return *this; }
423
424
425
426 //binary_stream(const ::file_pointer & p) :
427 // m_pfile(p)
428 //{
429
430 // set_ok_flag();
431
432 // if (m_pfile->m_eopen & ::file::e_open_write)
433 // {
434
435 // defer_set_storing_flag();
436
437 // }
438
439 //}
440
441
442 //binary_stream(const binary_stream & base) :
443 // m_pfile(base.m_pfile)
444 //{
445
446 // //set_ok_flag();
447
448 // //if (m_pfile->m_eopen & ::file::e_open_write)
449 // //{
450
451 // // defer_set_storing_flag();
452
453 // //}
454
455 //}
456
457
458 //binary_stream(binary_stream & base) :
459 // m_pfile(::transfer(base.m_pfile))
460 //{
461
462 // set_ok_flag();
463
464 // if (m_pfile->m_eopen & ::file::e_open_write)
465 // {
466
467 // defer_set_storing_flag();
468
469 // }
470
471 //}
472
473
474 // This number represents a following stream of data with this length.
475 // So the extra bytes representing the variable length quantity are
476 // neglectable and worth due the very fast variable length encoding.
477 void write_buffer_length(::u64 u)
478 {
479
480 if (u < 255)
481 {
482
483 operator <<((::u8)u);
484
485 }
486 else if (u < 65535)
487 {
488
489 operator <<((::u8)255);
490 operator <<((::u16)u);
491
492 }
493 else
494 {
495
496 operator <<((::u8)255);
497 operator <<((::u16)65535);
498 operator <<((::u64)u);
499
500 }
501
502 }
503
504
505 inline ::u64 read_buffer_length_unbounded_part2()
506 {
507
508 ::u16 ush;
509
510 ush = m_pfile->get_u16_unbounded();
511
512 if (ush < 65535)
513 {
514
515 return ush;
516
517 }
518 else
519 {
520
521 ::u64 ull;
522
523 ull = m_pfile->get_u64_unbounded();
524
525 return ull;
526
527 }
528
529 }
530
531
532 inline ::u64 read_buffer_length_unbounded()
533 {
534
535 ::u8 uch = m_pfile->get_byte_unbounded();
536
537 return uch < 255 ? uch : read_buffer_length_unbounded_part2();
538
539 }
540
541
542 virtual ::u64 read_buffer_length();
543
544
545 virtual string type_to_text(const ::platform::type & type);
546
547
548 virtual ::platform::type text_to_type(const ::scoped_string &scopedstr);
549
550
551 //bool is_open() const
552 //{
553 //
554 // if (m_pfile.is_null())
555 // {
556 //
557 // return false;
558 //
559 // }
560 //
561 // if (!m_pfile->is_opened())
562 // {
563 //
564 // return false;
565 //
566 // }
567 //
568 // return true;
569 //
570 //}
571 //
572 //
573 //void close()
574 //{
575 //
576 // m_pfile.release();
577 //
578 //}
579 //
580 //
581 //::file::path get_file_path() const
582 //{
583 //
584 // return m_pfile->get_file_path();
585 //
586 //}
587
588
589 //filesize translate(filesize offset, ::enum_seek eseek)
590 //{
591 //
592 // return m_pfile->translate(offset, eseek);
593 //
594 //}
595 //
596 //
597 //
598 //
599 //bool is_stream_null()
600 //{
601 // //return is_writer_null() && is_reader_null();
602 // return m_pfile.is_null();
603 //}
604
605
606 //bool is_stream_set()
607 //{
608 // //return is_writer_set() || is_reader_set();
609 // return m_pfile.is_set();
610 //}
611
612
613 virtual void write_from_hex(const void * pdata, memsize nCount);
614
615
616 virtual void write(const ::block & block);
617
618
619 virtual memsize defer_write(const ::block & block);
620
621
622 //void write(const ::block & block)
623 //{
624
625 // m_pfile->write(block);
626
627 //}
628
629
630
631 //binary_stream & operator <<(const ::property_set & set)
632 //{
633 //
634 // throw ::exception(todo);
635 //
636 // //__exchange_save_array(*this, (::property_set &) set);
637 //
638 // return *this;
639 //
640 //}
641 //
642
643
644 //void flush()
645 //{
646 //
647 // if (m_pfile.is_set())
648 // {
649 //
650 // m_pfile->flush();
651 //
652 // }
653 //
654 //}
655
656
657 //bool is_writer_null()
658 //{
659 //
660 // return m_pfile.is_null();
661 //
662 //}
663
664 //
665 //bool is_writer_set()
666 //{
667 //
668 // return m_pfile.is_set();
669 //
670 //}
671
672
673 binary_stream & operator <<(const_char_pointer psz);
674
675
676 virtual binary_stream & operator <<(const ::range < const_char_pointer >& str);
677
678
679 //binary_stream & operator <<(const ::particle * pparticle)
680 //{
681 //
682 // pparticle->write(*this);
683 //
684 // return * this;
685 //
686 //}
687 //
688 //
689 //binary_stream & operator <<(const matter& matter)
690 //{
691 //
692 // matter.write(*this);
693 //
694 // return * this;
695 //
696 //}
697
698
699 virtual binary_stream & operator <<(const block & block);
700
701 //binary_stream & operator <<(const ::element & element)
702 //{
703
704 // element.write(*this);
705
706 // return *this;
707
708 //}
709
710
711 //void set_size(filesize len)
712 //{
713 //
714 // m_pfile->set_size(len);
715 //
716 //}
717
718
719 void put(::i8 ch)
720 {
721
722 operator <<(ch);
723
724 return;
725
726 }
727
728
729 virtual binary_stream & operator >>(memory_base & m);
730
731
732 virtual binary_stream & operator <<(const memory_base & m);
733
734
735 virtual binary_stream & operator >>(atom & atom);
736
737 //void write_file(const ::file::path & path, const ::matter & matter)
738 //{
739 //
740 // if (path.is_empty())
741 // {
742 //
743 // throw io_exception("link path is empty");
744 //
745 // }
746 //
747 // ::stream stream(e_create_new, this, FIRST_VERSION);
748 //
749 // ::file::e_open nOpenFlags;
750 //
751 // nOpenFlags = ::file::e_open_binary | ::file::e_open_write | ::file::e_open_create | ::file::e_open_truncate | ::file::e_open_defer_create_directory | ::file::e_open_share_exclusive;
752 //
753 // stream.m_pfile = m_pfilecontext->m_pfileapexcontext->file()->get_file(path, nOpenFlags);
754 //
755 // matter.write(*this);
756 //
757 // return;
758 //
759 //}
760 //
761 //
762 //void read_file(const ::file::path & path, ::matter & matter)
763 //{
764 //
765 // if (path.is_empty())
766 // {
767 //
768 // throw io_exception("link path is empty");
769 //
770 // }
771 //
772 // ::stream stream(e_create_new, this, FIRST_VERSION);
773 //
774 // stream.m_pfile = m_pfilecontext->m_pfileapexcontext->file()->get_reader(path, ::file::e_open_share_deny_write);
775 //
776 // matter.read(*this);
777 //
778 // return;
779 //
780 //}
781
782
783 //void write_link(const ::scoped_string & scopedstrLink, const ::matter & matter)
784 //{
785 //
786 // ::file::path path = get_link_path(matter);
787 //
788 // if (path.is_empty())
789 // {
790 //
791 // throw ::exception(error_io);
792 //
793 // return;
794 //
795 // }
796 //
797 // try
798 // {
799 //
800 // write_file(path, matter);
801 //
802 // }
803 // catch (...)
804 // {
805 //
806 // throw ::exception(error_io);
807 //
808 // }
809 //
810 // return;
811 //
812 //}
813 //
814 //
815 //void read_link(const ::scoped_string & scopedstrLink, ::matter & matter)
816 //{
817 //
818 // ::file::path path = get_link_path(strLink);
819 //
820 // if (path.is_empty())
821 // {
822 //
823 // throw ::exception(error_io);
824 //
825 // return;
826 //
827 // }
828 //
829 // try
830 // {
831 //
832 // read_file(path, matter);
833 //
834 // }
835 // catch (...)
836 // {
837 //
838 // throw ::exception(error_io);
839 //
840 // }
841 //
842 // return;
843 //
844 //}
845 //
846 //
847 //bool get_object_link(const ::matter & matter, string & strLink, bool & bLink)
848 //{
849 //
850 // return false;
851 //
852 //}
853 //
854 //
855 //void set_object_link(const ::matter & matter, const ::scoped_string & scopedstrLink, bool bReadOnly)
856 //{
857 //
858 //}
859 //
860 //
861 //void write_link(const ::matter & matter)
862 //{
863 //
864 // string strLink;
865 //
866 // bool bReadOnly;
867 //
868 // if (get_object_link(matter, strLink, bReadOnly))
869 // {
870 //
871 // write_link(matter, strLink, bReadOnly);
872 //
873 // }
874 //
875 // return;
876 //
877 //}
878 //
879 //
880 //void write_link(const ::matter & matter, const ::scoped_string & scopedstrLink, bool bReadOnly)
881 //{
882 //
883 // write(bReadOnly);
884 //
885 // write(strLink);
886 //
887 // if (bReadOnly)
888 // {
889 //
890 // return;
891 //
892 // }
893 //
894 // if (strLink.has_character())
895 // {
896 //
897 // write_link(strLink, matter);
898 //
899 // }
900 //
901 // return;
902 //
903 //}
904 //
905 //void read_link(::matter & matter)
906 //{
907 //
908 // string strLink;
909 //
910 // bool bReadOnly;
911 //
912 // read(bReadOnly);
913 //
914 // read(strLink);
915 //
916 // //if (bReadOnly)
917 // //{
918 //
919 // // matter["read_only_link"] = strLink;
920 //
921 // //}
922 // //else
923 // //{
924 //
925 // // matter["link"] = strLink;
926 //
927 // //}
928 //
929 // set_object_link(matter, strLink, bReadOnly);
930 //
931 //
932 // if (strLink.has_character())
933 // {
934 //
935 // read_link(strLink, matter);
936 //
937 // }
938 //
939 // return;
940 //
941 //}
942
943
944 //bool get_object_link(const ::matter * preference, string & strLink, bool & bLink)
945 //{
946 //
947 // return false;
948 //
949 //}
950
951
952 //void set_object_link(const ::matter * preference, const ::scoped_string & scopedstrLink, bool bReadOnly)
953 //{
954 //
955 //}
956
957
958 //bool write_link(const ::particle * pparticle)
959 //{
960 //
961 // string strLink;
962 //
963 // bool bReadOnly;
964 //
965 // if (!get_object_link(pparticle, strLink, bReadOnly))
966 // {
967 //
968 // return false;
969 //
970 // }
971 //
972 // write_link(pparticle, strLink, bReadOnly);
973 //
974 // return true;
975 //
976 //}
977
978
979 //void write_link(const ::matter * preference, const ::scoped_string & scopedstrLink, bool bReadOnly, ::matter * pobjectSaveOptions)
980 //{
981 //
982 // write(bReadOnly);
983 //
984 // write(strLink);
985 //
986 // if (bReadOnly)
987 // {
988 //
989 // return;
990 //
991 // }
992 //
993 // if (strLink.has_character())
994 // {
995 //
996 // m_pfilecontext->m_pfileapexcontext->save_to_file(strLink, m_pfilevarOptions, preference);
997 //
998 // }
999 //
1000 // return;
1001 //
1002 //}
1003
1004
1005 //void read_link(::matter * preference)
1006 //{
1007 //
1008 // string strLink;
1009 //
1010 // bool bReadOnly;
1011 //
1012 // read(bReadOnly);
1013 //
1014 // read(strLink);
1015 //
1016 // //if (bReadOnly)
1017 // //{
1018 //
1019 // // matter["read_only_link"] = strLink;
1020 //
1021 // //}
1022 // //else
1023 // //{
1024 //
1025 // // matter["link"] = strLink;
1026 //
1027 // //}
1028 //
1029 // set_object_link(preference, strLink, bReadOnly);
1030 //
1031 // if (strLink.has_character())
1032 // {
1033 //
1034 // m_pfilecontext->m_pfileapexcontext->load_from_file(preference, strLink);
1035 //
1036 // }
1037 //
1038 // return;
1039 //
1040 //}
1041
1042
1043
1044
1045 virtual void read_payload_type(enum_type & etype);
1046
1047
1048 virtual void save_payload_type(enum_type etype);
1049
1050 virtual void read_payload_body(::payload & payload, enum_type etype);
1051
1052
1053 virtual binary_stream & operator >>(string & str);
1054
1055
1056
1057 //filesize get_position()
1058 //{
1059 //
1060 // return m_pfile->get_position();
1061 //
1062 //}
1063 //
1064
1065 //binary_stream & operator >>(matter & matter)
1066 //{
1067 //
1068 // matter.read(*this);
1069 //
1070 // return * this;
1071 //
1072 //}
1073 //
1074
1075 //binary_stream & operator >>(::property_set & set)
1076 //{
1077 //
1078 // throw ::exception(todo);
1079 //
1080 // //__exchange_load_array(*this, set);
1081 //
1082 // return *this;
1083 //
1084 //}
1085
1086
1087 virtual binary_stream & operator >>(block & block);
1088
1089
1090 //binary_stream & operator >>(::element & element)
1091 //{
1092
1093 // element.read(*this);
1094
1095 // return *this;
1096
1097 //}
1098
1099
1100 //void * get_internal_data()
1101 //{
1102 //
1103 // return m_pfile->get_internal_data();
1104 //
1105 //}
1106
1107
1108
1109 //
1110 //memsize get_internal_data_size() const
1111 //{
1112 //
1113 // return m_pfile->get_internal_data_size();
1114 //
1115 //}
1116
1117
1118 //
1119 //
1120 //bool set_internal_data_size(memsize c)
1121 //{
1122 //
1123 // return m_pfile->set_internal_data_size(c);
1124 //
1125 //}
1126 //
1127 //
1128
1129 //
1130 //filesize get_position() const
1131 //{
1132 //
1133 // return m_pfile->get_position();
1134 //
1135 //}
1136
1137
1138 ::u8 get_byte()
1139 {
1140 ::u8 b = 0;
1141 if (m_pfile->read(&b, 1) != 1)
1142 {
1143
1144 throw_exception(error_end_of_file);
1145
1146 }
1147 return b;
1148 }
1149
1150
1151 ::u8 peek_byte()
1152 {
1153
1154 return m_pfile->peek_byte();
1155
1156 }
1157
1158
1159 virtual void getline(char_pointer sz, character_count n);
1160
1161
1162
1163 //::memsize gcount()
1164 //{
1165 //
1166 // return m_pfile->gcount();
1167 //
1168 //}
1169
1170
1171
1172 //filesize seek_from_begin(filesize position)
1173 //{
1174 //
1175 // return m_pfile->seek(position);
1176 //
1177 //}
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188 //::filesize get_left() const
1189 //{
1190 //
1191 // return m_pfile->get_left();
1192 //
1193 //}
1194
1195
1196
1197
1198 //bool is_reader_null()
1199 //{
1200 //
1201 // return m_pfile.is_null() || !(m_pfile->m_eopen & ::file::e_open_read);
1202 //
1203 //}
1204 //
1205 //
1206 //
1207 //
1208 //bool is_reader_set()
1209 //{
1210 //
1211 // return m_pfile.is_set() && (m_pfile->m_eopen & ::file::e_open_read);
1212 //
1213 //}
1214
1215
1216
1217
1218 virtual void read_to_hex(string & str, filesize tickStart, filesize tickEnd);
1219
1220 virtual ::pointer<::particle>create_object_from_text(::particle * pparticle, const ::scoped_string & scopedstrText);
1221
1222
1223
1224
1225 //
1226 //
1227 //::atom text_to_factory_id(const ::scoped_string & scopedstr)
1228 //{
1229 //
1230 // return str;
1231 //
1232 //}
1233 //
1234 //
1235 //::string factory_id_to_text(const ::atom & atom)
1236 //{
1237 //
1238 // return atom;
1239 //
1240 //}
1241
1242
1243 void read(const ::block & block)
1244 {
1245
1246 //if (!fail())
1247 //{
1248
1249 m_gcount = m_pfile->read(block);
1250
1251 if (m_gcount != block.size())
1252 {
1253
1254 set_nok();
1255
1256 }
1257
1258 /* }*/
1259
1260 }
1261
1262
1263 virtual ::pointer < ::subparticle > read_particle();
1264 virtual void write_particle(const ::subparticle * pparticle);
1265
1266};
1267
1268
1270//inline auto __binary_stream(FILE * pfile)
1271//{
1272//
1273// return binary_stream(pfile);
1274//
1275//}
1276
1277
1279//inline auto __binary_stream(const ::pointer<FILE> & pfile)
1280//{
1281//
1282// return __binary_stream(pfile.m_p);
1283//
1284//}
1285
1286
1287
1288CLASS_DECL_ACME binary_stream& operator <<(binary_stream& stream,const atom& atom);
1289
1290CLASS_DECL_ACME binary_stream& operator <<(binary_stream& stream,const ::payload& payload);
1291
1292CLASS_DECL_ACME binary_stream& operator <<(binary_stream& stream, const ::property& property);
1293
1294
1295
1296CLASS_DECL_ACME binary_stream& operator >>(binary_stream& stream,property& property);
1297
1298CLASS_DECL_ACME binary_stream& operator >>(binary_stream& stream,::payload& payload);
1299
Definition atom.h:237
Definition binary_stream.h:12
void write_length(::u64 u)
file::path get_file_path() const;
Definition binary_stream.h:166
Definition payload.h:54
Definition property.h:81
Definition ___serialization_draft.h:42