libDwm-0.9.45
DwmStreamIO.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2004-2007, 2016, 2017, 2020, 2024
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
40//---------------------------------------------------------------------------
41
42#ifndef _DWMSTREAMIO_HH_
43#define _DWMSTREAMIO_HH_
44
45#include <array>
46#include <cassert>
47#include <cstdint>
48#include <cstdio>
49#include <deque>
50#include <iostream>
51#include <list>
52#include <map>
53#include <set>
54#include <string>
55#include <tuple>
56#include <unordered_map>
57#include <unordered_set>
58#include <variant>
59#include <vector>
60
61#include "DwmPortability.hh"
62#include "DwmStreamIOCapable.hh"
64
65namespace Dwm {
66
67 //--------------------------------------------------------------------------
81 //--------------------------------------------------------------------------
83 {
84 public:
85 //------------------------------------------------------------------------
87 //------------------------------------------------------------------------
88 static std::istream & Read(std::istream & is, char & c);
89
90 //------------------------------------------------------------------------
92 //------------------------------------------------------------------------
93 static std::ostream & Write(std::ostream & os, char c);
94
95 //------------------------------------------------------------------------
97 //------------------------------------------------------------------------
98 static std::istream & Read(std::istream & is, uint8_t & c);
99
100 //------------------------------------------------------------------------
102 //------------------------------------------------------------------------
103 static std::ostream & Write(std::ostream & os, uint8_t c);
104
105 //------------------------------------------------------------------------
107 //------------------------------------------------------------------------
108 static std::istream & Read(std::istream & is, bool & b);
109
110 //------------------------------------------------------------------------
112 //------------------------------------------------------------------------
113 static std::ostream & Write(std::ostream & os, bool b);
114
115 //------------------------------------------------------------------------
118 //------------------------------------------------------------------------
119 static std::istream & Read(std::istream & is, int16_t & val);
120
121 //------------------------------------------------------------------------
124 //------------------------------------------------------------------------
125 static std::ostream & Write(std::ostream & os, int16_t val);
126
127 //------------------------------------------------------------------------
130 //------------------------------------------------------------------------
131 static std::istream & Read(std::istream & is, uint16_t & val);
132
133 //------------------------------------------------------------------------
136 //------------------------------------------------------------------------
137 static std::ostream & Write(std::ostream & os, uint16_t val);
138
139 //------------------------------------------------------------------------
142 //------------------------------------------------------------------------
143 static std::istream & Read(std::istream & is, int32_t & val);
144
145 //------------------------------------------------------------------------
148 //------------------------------------------------------------------------
149 static std::ostream & Write(std::ostream & os, int32_t val);
150
151 //------------------------------------------------------------------------
154 //------------------------------------------------------------------------
155 static std::istream & Read(std::istream & is, uint32_t & val);
156
157 //------------------------------------------------------------------------
160 //------------------------------------------------------------------------
161 static std::ostream & Write(std::ostream & os, uint32_t val);
162
163 //------------------------------------------------------------------------
166 //------------------------------------------------------------------------
167 static std::istream & Read(std::istream & is, int64_t & val);
168
169 //------------------------------------------------------------------------
172 //------------------------------------------------------------------------
173 static std::ostream & Write(std::ostream & os, const int64_t & val);
174
175 //------------------------------------------------------------------------
178 //------------------------------------------------------------------------
179 static std::istream & Read(std::istream & is, uint64_t & val);
180
181 //------------------------------------------------------------------------
184 //------------------------------------------------------------------------
185 static std::ostream & Write(std::ostream & os, const uint64_t & val);
186
187 //------------------------------------------------------------------------
190 //------------------------------------------------------------------------
191 static std::istream & Read(std::istream & is, float & val);
192
193 //------------------------------------------------------------------------
196 //------------------------------------------------------------------------
197 static std::ostream & Write(std::ostream & os, float val);
198
199 //------------------------------------------------------------------------
202 //------------------------------------------------------------------------
203 static std::istream & Read(std::istream & is, double & val);
204
205 //------------------------------------------------------------------------
208 //------------------------------------------------------------------------
209 static std::ostream & Write(std::ostream & os, const double & val);
210
211 //------------------------------------------------------------------------
215 //------------------------------------------------------------------------
216 static std::istream & Read(std::istream & is, std::string & s);
217
218 //------------------------------------------------------------------------
224 //------------------------------------------------------------------------
225 static std::ostream & Write(std::ostream & os, const std::string & s);
226
227 //------------------------------------------------------------------------
229 //------------------------------------------------------------------------
230 static std::istream & Read(std::istream & is, StreamReadable & val)
231 {
232 return(val.Read(is));
233 }
234
235 //------------------------------------------------------------------------
238 //------------------------------------------------------------------------
239 static std::istream & Read(std::istream & is, HasStreamRead auto & t)
240 { return t.Read(is); }
241
242 //------------------------------------------------------------------------
244 //------------------------------------------------------------------------
245 static std::ostream & Write(std::ostream & os, const StreamWritable & val)
246 {
247 return(val.Write(os));
248 }
249
250 //------------------------------------------------------------------------
253 //------------------------------------------------------------------------
254 static std::ostream &
255 Write(std::ostream & os, const HasStreamWrite auto & t)
256 { return t.Write(os); }
257
258 //------------------------------------------------------------------------
260 //------------------------------------------------------------------------
261 template <typename _firstT, typename _secondT>
262 static std::istream & Read(std::istream & is,
263 std::pair<_firstT, _secondT> & p)
264 {
265 if (is) {
266 if (Read(is, p.first))
267 Read(is, p.second);
268 }
269 return(is);
270 }
271
272 //------------------------------------------------------------------------
274 //------------------------------------------------------------------------
275 template <typename _firstT, typename _secondT>
276 static std::ostream & Write(std::ostream & os,
277 const std::pair<_firstT,_secondT> & p)
278 {
279 if (os) {
280 if (Write(os, p.first)) {
281 Write(os, p.second);
282 }
283 }
284 return(os);
285 }
286
287 //------------------------------------------------------------------------
289 //------------------------------------------------------------------------
290 template <typename _keyT, typename _valueT,
291 typename _Compare, typename _Alloc>
292 static std::istream & Read(std::istream & is,
293 std::map<_keyT, _valueT, _Compare, _Alloc> & m)
294 {
295 return(PairAssocContRead<std::map<_keyT, _valueT, _Compare, _Alloc> >(is, m));
296 }
297
298 //------------------------------------------------------------------------
300 //------------------------------------------------------------------------
301 template <typename _keyT, typename _valueT,
302 typename _Compare, typename _Alloc>
303 static std::ostream & Write(std::ostream & os,
304 const std::map<_keyT,_valueT, _Compare, _Alloc> & m)
305 {
306 return(ContainerWrite<std::map<_keyT,_valueT,_Compare,_Alloc> >(os, m));
307 }
308
309 //------------------------------------------------------------------------
312 //------------------------------------------------------------------------
313 template <typename _keyT, typename _valueT,
314 typename _Compare, typename _Alloc>
315 static std::istream &
316 Read(std::istream & is, std::multimap<_keyT,_valueT,_Compare,_Alloc> & m)
317 {
318 return(PairAssocContRead<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(is, m));
319 }
320
321 //------------------------------------------------------------------------
323 //------------------------------------------------------------------------
324 template <typename _keyT, typename _valueT,
325 typename _Compare, typename _Alloc>
326 static std::ostream &
327 Write(std::ostream & os,
328 const std::multimap<_keyT,_valueT, _Compare, _Alloc> & m)
329 {
330 return(ContainerWrite<std::multimap<_keyT,_valueT,_Compare,_Alloc> >(os, m));
331 }
332
333 //------------------------------------------------------------------------
335 //------------------------------------------------------------------------
336 template <typename _valueT, size_t N>
337 static std::istream & Read(std::istream & is,
338 std::array<_valueT, N> & a)
339 {
340 if (is) {
341 for (size_t i = 0; i < N; ++i) {
342 if (! Read(is, a[i])) {
343 break;
344 }
345 }
346 }
347 return is;
348 }
349
350 //------------------------------------------------------------------------
352 //------------------------------------------------------------------------
353 template <typename _valueT, size_t N>
354 static std::ostream & Write(std::ostream & os,
355 const std::array<_valueT, N> & a)
356 {
357 if (os) {
358 for (size_t i = 0; i < N; ++i) {
359 if (! Write(os, a[i])) {
360 break;
361 }
362 }
363 }
364 return os;
365 }
366
367 //------------------------------------------------------------------------
369 //------------------------------------------------------------------------
370 template <typename _valueT, typename _Alloc>
371 static std::istream & Read(std::istream & is,
372 std::vector<_valueT, _Alloc> & v)
373 {
374 return(ContainerRead<std::vector<_valueT, _Alloc> >(is, v));
375 }
376
377 //------------------------------------------------------------------------
379 //------------------------------------------------------------------------
380 template <typename _valueT, typename _Alloc>
381 static std::ostream & Write(std::ostream & os,
382 const std::vector<_valueT, _Alloc> & v)
383 {
384 return(ContainerWrite<std::vector<_valueT, _Alloc> >(os, v));
385 }
386
387 //------------------------------------------------------------------------
389 //------------------------------------------------------------------------
390 template <typename _valueT, typename _Alloc>
391 static std::istream & Read(std::istream & is,
392 std::deque<_valueT, _Alloc> & d)
393 {
394 return(ContainerRead<std::deque<_valueT, _Alloc> >(is, d));
395 }
396
397 //------------------------------------------------------------------------
399 //------------------------------------------------------------------------
400 template <typename _valueT, typename _Alloc>
401 static std::ostream & Write(std::ostream & os,
402 const std::deque<_valueT, _Alloc> & d)
403 {
404 return(ContainerWrite<std::deque<_valueT, _Alloc> >(os, d));
405 }
406
407 //------------------------------------------------------------------------
409 //------------------------------------------------------------------------
410 template <typename _valueT, typename _Alloc>
411 static std::istream & Read(std::istream & is,
412 std::list<_valueT, _Alloc> & l)
413 {
414 return(ContainerRead<std::list<_valueT, _Alloc> >(is, l));
415 }
416
417 //------------------------------------------------------------------------
419 //------------------------------------------------------------------------
420 template <typename _valueT, typename _Alloc>
421 static std::ostream & Write(std::ostream & os,
422 const std::list<_valueT, _Alloc> & l)
423 {
424 return(ContainerWrite<std::list<_valueT, _Alloc> >(os, l));
425 }
426
427 //------------------------------------------------------------------------
429 //------------------------------------------------------------------------
430 template <typename _valueT, typename _Compare, typename _Alloc>
431 static std::istream & Read(std::istream & is,
432 std::set<_valueT, _Compare, _Alloc> & l)
433 {
434 return(ContainerRead<std::set<_valueT, _Compare, _Alloc> >(is, l));
435 }
436
437 //------------------------------------------------------------------------
439 //------------------------------------------------------------------------
440 template <typename _valueT, typename _Compare, typename _Alloc>
441 static std::ostream & Write(std::ostream & os,
442 const std::set<_valueT, _Compare, _Alloc> & l)
443 {
444 return(ContainerWrite<std::set<_valueT, _Compare, _Alloc> >(os, l));
445 }
446
447 //------------------------------------------------------------------------
449 //------------------------------------------------------------------------
450 template <typename _valueT, typename _Compare, typename _Alloc>
451 static std::istream & Read(std::istream & is,
452 std::multiset<_valueT, _Compare, _Alloc> & l)
453 {
454 return(ContainerRead<std::multiset<_valueT, _Compare, _Alloc> >(is, l));
455 }
456
457 //------------------------------------------------------------------------
459 //------------------------------------------------------------------------
460 template <typename _valueT, typename _Compare, typename _Alloc>
461 static std::ostream &
462 Write(std::ostream & os,
463 const std::multiset<_valueT, _Compare, _Alloc> & l)
464 {
465 return(ContainerWrite<std::multiset<_valueT, _Compare, _Alloc> >(os, l));
466 }
467
468 //------------------------------------------------------------------------
470 //------------------------------------------------------------------------
471 template <typename... Args>
472 static std::istream & Read(std::istream & is,
473 std::tuple<Args...> & t)
474 {
475 std::apply([&is](auto&&... args) {((Read(is,args)) && ...);}, t);
476 return is;
477 }
478
479 //------------------------------------------------------------------------
481 //------------------------------------------------------------------------
482 template <typename... Args>
483 static std::ostream & Write(std::ostream & os,
484 const std::tuple<Args...> & t)
485 {
486 std::apply([&os](auto&&... args) {((Write(os,args)) && ...);}, t);
487 return os;
488 }
489
490 //------------------------------------------------------------------------
493 //------------------------------------------------------------------------
494 template <typename _keyT, typename _valueT,
495 typename _Hash, typename _Pred, typename _Alloc>
496 static std::istream &
497 Read(std::istream & is,
498 std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
499 {
500 return(PairAssocContRead<std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> >(is, m));
501 }
502
503 //------------------------------------------------------------------------
506 //------------------------------------------------------------------------
507 template <typename _keyT, typename _valueT,
508 typename _Hash, typename _Pred, typename _Alloc>
509 static std::ostream &
510 Write(std::ostream & os,
511 const std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
512 {
513 return(ContainerWrite<std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> >(os, m));
514 }
515
516 //------------------------------------------------------------------------
519 //------------------------------------------------------------------------
520 template <typename _keyT, typename _valueT,
521 typename _Hash, typename _Pred, typename _Alloc>
522 static std::istream & Read(std::istream & is,
523 std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
524 {
525 return(PairAssocContRead<std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> >(is, m));
526 }
527
528 //------------------------------------------------------------------------
531 //------------------------------------------------------------------------
532 template <typename _keyT, typename _valueT,
533 typename _Hash, typename _Pred, typename _Alloc>
534 static std::ostream &
535 Write(std::ostream & os,
536 const std::unordered_multimap<_keyT, _valueT, _Hash, _Pred, _Alloc> & m)
537 {
538 return(ContainerWrite<std::unordered_multimap<_keyT,_valueT,_Hash,_Pred,_Alloc> >(os, m));
539 }
540
541 //------------------------------------------------------------------------
544 //------------------------------------------------------------------------
545 template <typename _valueT, typename _Hash,
546 typename _Pred, typename _Alloc>
547 static std::istream &
548 Read(std::istream & is,
549 std::unordered_set<_valueT, _Hash, _Pred, _Alloc> & m)
550 {
551 return(ContainerRead<std::unordered_set<_valueT, _Hash, _Pred, _Alloc> >(is, m));
552 }
553
554 //------------------------------------------------------------------------
557 //------------------------------------------------------------------------
558 template <typename _valueT, typename _Hash,
559 typename _Pred, typename _Alloc>
560 static std::ostream &
561 Write(std::ostream & os,
562 const std::unordered_set<_valueT, _Hash, _Pred, _Alloc> & m)
563 {
564 return(ContainerWrite<std::unordered_set<_valueT,_Hash,_Pred,_Alloc> >(os, m));
565 }
566
567 //------------------------------------------------------------------------
570 //------------------------------------------------------------------------
571 template <typename _valueT, typename _Hash,
572 typename _Pred, typename _Alloc>
573 static std::istream &
574 Read(std::istream & is,
575 std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> & m)
576 {
577 return(ContainerRead<std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> >(is, m));
578 }
579
580 //------------------------------------------------------------------------
583 //------------------------------------------------------------------------
584 template <typename _valueT, typename _Hash,
585 typename _Pred, typename _Alloc>
586 static std::ostream &
587 Write(std::ostream & os,
588 const std::unordered_multiset<_valueT, _Hash, _Pred, _Alloc> & m)
589 {
590 return(ContainerWrite<std::unordered_multiset<_valueT,_Hash,_Pred,_Alloc> >(os, m));
591 }
592
593 //------------------------------------------------------------------------
595 //------------------------------------------------------------------------
596 template <typename... Ts>
597 static std::istream & Read(std::istream & is,
598 std::variant<Ts...> & v)
599 {
600 uint64_t index = 0;
601 if (Read(is, index)) {
602 if (index < std::variant_size_v<std::variant<Ts...>>) {
603 v = VariantFromIndex<Ts...>(index);
604 std::visit([&] (auto && arg) { Read(is, arg); }, v);
605 }
606 else {
607 is.setstate(std::ios_base::failbit);
608 }
609 }
610 return is;
611 }
612
613 //------------------------------------------------------------------------
615 //------------------------------------------------------------------------
616 template <typename... Ts>
617 static std::ostream & Write(std::ostream & os,
618 const std::variant<Ts...> & v)
619 {
620 uint64_t index = v.index();
621 if (Write(os, index)) {
622 std::visit([&os] (const auto & arg) { Write(os, arg); }, v);
623 }
624 return os;
625 }
626
627 //------------------------------------------------------------------------
632 //------------------------------------------------------------------------
633 static std::istream & Read(std::istream & is, std::monostate & sm)
634 {
635 return is;
636 }
637
638 //------------------------------------------------------------------------
643 //------------------------------------------------------------------------
644 static std::ostream & Write(std::ostream & os, const std::monostate & sm)
645 {
646 return os;
647 }
648
649 //------------------------------------------------------------------------
652 //------------------------------------------------------------------------
653 template <typename... Args>
654 static std::istream & ReadV(std::istream & is, Args & ...args)
655 {
656 (Read(is,args) &&...);
657 return is;
658 }
659
660 //------------------------------------------------------------------------
663 //------------------------------------------------------------------------
664 template <typename... Args>
665 static std::ostream & WriteV(std::ostream & os, const Args & ...args)
666 {
667 (Write(os,args) &&...);
668 return os;
669 }
670
671 private:
672 //------------------------------------------------------------------------
674 //------------------------------------------------------------------------
675 template <typename _inputIteratorT>
676 static std::ostream & Write(std::ostream & os,
677 _inputIteratorT f, _inputIteratorT l)
678 {
679 if (os) {
680 for ( ; f != l; ++f) {
681 if (! Write(os, *f)) {
682 break;
683 }
684 }
685 }
686 return(os);
687 }
688
689 //------------------------------------------------------------------------
692 //------------------------------------------------------------------------
693 template <typename _containerT>
694 static std::istream & ContainerRead(std::istream & is,
695 _containerT & c)
696 {
697 if (! c.empty())
698 c.clear();
699 if (is) {
700 uint64_t numEntries;
701 if (Read(is, numEntries)) {
702 for (uint64_t i = 0; i < numEntries; ++i) {
703 typename _containerT::value_type val;
704 if (! Read(is, val))
705 break;
706 c.insert(c.end(), std::move(val));
707 }
708 }
709 }
710 return(is);
711 }
712
713 //------------------------------------------------------------------------
716 //------------------------------------------------------------------------
717 template <typename _containerT>
718 static std::ostream & ContainerWrite(std::ostream & os,
719 const _containerT & c)
720 {
721 if (os) {
722 uint64_t numEntries = c.size();
723 if (Write(os, numEntries)) {
724 if (numEntries) {
726 c.begin(),
727 c.end());
728 }
729 }
730 }
731 return(os);
732 }
733
734 //------------------------------------------------------------------------
738 //------------------------------------------------------------------------
739 template <typename _containerT>
740 static std::istream &
741 PairAssocContRead(std::istream & is, _containerT & m)
742 {
743 if (! m.empty())
744 m.clear();
745 if (is) {
746 uint64_t numEntries;
747 if (Read(is, numEntries)) {
748 for (uint64_t i = 0; i < numEntries; ++i) {
749 typename _containerT::key_type key;
750 if (Read(is, key)) {
751 typename _containerT::mapped_type val;
752 if (Read(is, val))
753 m.insert(typename _containerT::value_type(std::move(key), std::move(val)));
754 else
755 break;
756 }
757 else
758 break;
759 }
760 }
761 }
762 return(is);
763 }
764
765 };
766
767
768} // namespace Dwm
769
770#endif // _DWMSTREAMIO_HH_
771
772//---------------------------- emacs settings -----------------------------
773// Local Variables:
774// mode: C++
775// tab-width: 2
776// indent-tabs-mode: nil
777// c-basic-offset: 2
778// End:
779//-------------------------------------------------------------------------
A configure target for dealing with OS differences.
Dwm::HasStreamRead and Dwm::HasStreamWrite concepts. Dwm::StreamReadable, Dwm::StreamWritable and Dwm...
Dwm::VariantFromIndex function template.
std::variant< Ts... > VariantFromIndex(size_t index)
Returns a variant type V whose contents are set to a default constructed value of the type at index i...
Definition DwmVariantFromIndex.hh:57
This class contains a collection of static functions for reading and writing simple types,...
Definition DwmStreamIO.hh:83
static std::ostream & Write(std::ostream &os, float val)
Writes val to os, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static std::istream & ReadV(std::istream &is, Args &...args)
Reads multiple objects from an istream.
Definition DwmStreamIO.hh:654
static std::ostream & Write(std::ostream &os, const std::pair< _firstT, _secondT > &p)
Writes a pair<_firstT,_secondT> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:276
static std::ostream & Write(std::ostream &os, int16_t val)
Writes val to os, in network byte order (MSB first).
static std::ostream & Write(std::ostream &os, uint16_t val)
Writes val to os, in network byte order (MSB first).
static std::istream & Read(std::istream &is, std::set< _valueT, _Compare, _Alloc > &l)
Reads a set<_valueT> from an istream. Returns the istream.
Definition DwmStreamIO.hh:431
static std::ostream & Write(std::ostream &os, const std::deque< _valueT, _Alloc > &d)
Writes a deque<_valueT> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:401
static std::ostream & Write(std::ostream &os, uint8_t c)
Writes c to os. Returns os.
static std::ostream & WriteV(std::ostream &os, const Args &...args)
Writes multiple objects to an ostream.
Definition DwmStreamIO.hh:665
static std::istream & Read(std::istream &is, uint16_t &val)
Reads val from is, in network byte order (MSB first).
static std::ostream & Write(std::ostream &os, const std::multiset< _valueT, _Compare, _Alloc > &l)
Writes a multiset<_valueT> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:462
static std::ostream & Write(std::ostream &os, const HasStreamWrite auto &t)
Writes an object that meets the HasStreamWrite requirement to an ostream.
Definition DwmStreamIO.hh:255
static std::istream & Read(std::istream &is, std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_set<_valueT> from an istream.
Definition DwmStreamIO.hh:548
static std::istream & Read(std::istream &is, std::string &s)
Reads string s from is.
static std::istream & Read(std::istream &is, std::variant< Ts... > &v)
Reads a variant from an istream. Returns the istream.
Definition DwmStreamIO.hh:597
static std::ostream & Write(std::ostream &os, int32_t val)
Writes val to os, in network byte order (MSB first).
static std::istream & Read(std::istream &is, double &val)
Reads val from is, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static std::ostream & Write(std::ostream &os, const uint64_t &val)
Writes val to os, in network byte order (MSB first).
static std::istream & Read(std::istream &is, char &c)
Reads c from is. Returns is.
static std::istream & Read(std::istream &is, bool &b)
Reads b from is. Returns is.
static std::ostream & Write(std::ostream &os, const std::array< _valueT, N > &a)
Writes an array<_valueT,N> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:354
static std::istream & Read(std::istream &is, std::monostate &sm)
Just a dummy helper function for std::variant instances that hold a std::monostate.
Definition DwmStreamIO.hh:633
static std::ostream & Write(std::ostream &os, const std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Writes a unordered_multimap<_keyT,_valueT> to an ostream.
Definition DwmStreamIO.hh:535
static std::ostream & Write(std::ostream &os, const std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Writes a map<_keyT,_valueT> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:303
static std::ostream & Write(std::ostream &os, const std::variant< Ts... > &v)
Writes a variant to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:617
static std::istream & Read(std::istream &is, int32_t &val)
Reads val from is, in network byte order (MSB first).
static std::ostream & Write(std::ostream &os, const std::list< _valueT, _Alloc > &l)
Writes a list<_valueT> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:421
static std::istream & Read(std::istream &is, uint32_t &val)
Reads val from is, in network byte order (MSB first).
static std::istream & Read(std::istream &is, std::list< _valueT, _Alloc > &l)
Reads a list<_valueT> from an istream. Returns the istream.
Definition DwmStreamIO.hh:411
static std::istream & Read(std::istream &is, std::map< _keyT, _valueT, _Compare, _Alloc > &m)
Reads a map<_keyT,_valueT> from an istream. Returns the istream.
Definition DwmStreamIO.hh:292
static std::istream & Read(std::istream &is, std::tuple< Args... > &t)
Reads a tuple from an istream. Returns the istream.
Definition DwmStreamIO.hh:472
static std::istream & Read(std::istream &is, HasStreamRead auto &t)
Reads an object t that meets the HasStreamRead requirement from an istream.
Definition DwmStreamIO.hh:239
static std::ostream & Write(std::ostream &os, const std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &m)
Writes a unordered_set<_valueT> to an ostream.
Definition DwmStreamIO.hh:561
static std::ostream & Write(std::ostream &os, const std::vector< _valueT, _Alloc > &v)
Writes a vector<_valueT> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:381
static std::istream & Read(std::istream &is, std::pair< _firstT, _secondT > &p)
Reads a pair<_firstT,_secondT> from an istream. Returns the istream.
Definition DwmStreamIO.hh:262
static std::istream & Read(std::istream &is, std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Reads a multimap<_keyT,_valueT> from an istream.
Definition DwmStreamIO.hh:316
static std::ostream & Write(std::ostream &os, const std::monostate &sm)
Just a dummy helper function for std::variant instances that hold a std::monostate.
Definition DwmStreamIO.hh:644
static std::ostream & Write(std::ostream &os, const StreamWritable &val)
Wrapper function to write a StreamWritable object to an ostream.
Definition DwmStreamIO.hh:245
static std::ostream & Write(std::ostream &os, bool b)
Writes a bool b to an ostream os. Returns os.
static std::istream & Read(std::istream &is, std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_map<_keyT,_valueT> from an istream.
Definition DwmStreamIO.hh:497
static std::istream & Read(std::istream &is, int16_t &val)
Reads val from is, in network byte order (MSB first).
static std::ostream & Write(std::ostream &os, const std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &m)
Writes a unordered_multiset<_valueT> to an ostream.
Definition DwmStreamIO.hh:587
static std::ostream & Write(std::ostream &os, char c)
Writes c to os. Returns os.
static std::ostream & Write(std::ostream &os, const std::string &s)
Writes s to os.
static std::istream & Read(std::istream &is, std::deque< _valueT, _Alloc > &d)
Reads a deque<_valueT> from an istream. Returns the istream.
Definition DwmStreamIO.hh:391
static std::istream & Read(std::istream &is, uint8_t &c)
Reads c from is. Returns is.
static std::istream & Read(std::istream &is, std::unordered_multiset< _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_multiset<_valueT> from an istream.
Definition DwmStreamIO.hh:574
static std::ostream & Write(std::ostream &os, const std::multimap< _keyT, _valueT, _Compare, _Alloc > &m)
Writes a multimap<_keyT,_valueT> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:327
static std::istream & Read(std::istream &is, float &val)
Reads val from is, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static std::ostream & Write(std::ostream &os, const std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Writes a unordered_map<_keyT,_valueT> to an ostream.
Definition DwmStreamIO.hh:510
static std::istream & Read(std::istream &is, std::multiset< _valueT, _Compare, _Alloc > &l)
Reads a multiset<_valueT> from an istream. Returns the istream.
Definition DwmStreamIO.hh:451
static std::istream & Read(std::istream &is, int64_t &val)
Reads val from is, in network byte order (MSB first).
static std::ostream & Write(std::ostream &os, const int64_t &val)
Writes val to os, in network byte order (MSB first).
static std::istream & Read(std::istream &is, std::vector< _valueT, _Alloc > &v)
Reads a vector<_valueT> from an istream. Returns the istream.
Definition DwmStreamIO.hh:371
static std::ostream & Write(std::ostream &os, const std::set< _valueT, _Compare, _Alloc > &l)
Writes a set<_valueT> to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:441
static std::istream & Read(std::istream &is, std::unordered_multimap< _keyT, _valueT, _Hash, _Pred, _Alloc > &m)
Reads an unordered_multimap<_keyT,_valueT> from an istream.
Definition DwmStreamIO.hh:522
static std::istream & Read(std::istream &is, std::array< _valueT, N > &a)
Reads an array<_valueT,N> from an istream. Returns the istream.
Definition DwmStreamIO.hh:337
static std::ostream & Write(std::ostream &os, uint32_t val)
Writes val to os, in network byte order (MSB first).
static std::ostream & Write(std::ostream &os, const double &val)
Writes val to os, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static std::istream & Read(std::istream &is, StreamReadable &val)
Wrapper function to read a StreamReadable object from an istream.
Definition DwmStreamIO.hh:230
static std::ostream & Write(std::ostream &os, const std::tuple< Args... > &t)
Writes a tuple to an ostream. Returns the ostream.
Definition DwmStreamIO.hh:483
static std::istream & Read(std::istream &is, uint64_t &val)
Reads val from is, in network byte order (MSB first).
This class defines an interface for classes that can read their contents from an istream.
Definition DwmStreamIOCapable.hh:74
virtual std::istream & Read(std::istream &is)=0
Read from an istream. Return the istream.
This class defines an interface for classes that can write their contents to an ostream.
Definition DwmStreamIOCapable.hh:92
virtual std::ostream & Write(std::ostream &os) const =0
Write to an ostream. Return the ostream.
T has a Read(std::istream &) method that returns the std::istream reference that was passed in as its...
Definition DwmStreamIOCapable.hh:56
T has a Write(std::ostream &) const method that returns the std::ostream reference that was passed in...
Definition DwmStreamIOCapable.hh:65