libDwm-0.9.45
DwmASIO.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2018, 2020, 2023, 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 _DWMASIO_HH_
43#define _DWMASIO_HH_
44
45#include <array>
46#include <deque>
47#include <list>
48#include <map>
49#include <set>
50#include <string>
51#include <tuple>
52#include <unordered_map>
53#include <unordered_set>
54#include <variant>
55#include <vector>
56
57#include "DwmASIOCapable.hh"
59
60namespace Dwm {
61
62 //--------------------------------------------------------------------------
66 //--------------------------------------------------------------------------
67 template <typename S>
69 std::is_same_v<S,boost::asio::ip::tcp::socket>
70 || std::is_same_v<S,boost::asio::local::stream_protocol::socket>
71 || std::is_same_v<S,boost::asio::generic::stream_protocol::socket>;
72
73 //--------------------------------------------------------------------------
82 //--------------------------------------------------------------------------
83 class ASIO
84 {
85 public:
86 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
90 static bool Read(boost::asio::ip::tcp::socket & s, uint8_t & value,
91 boost::system::error_code & ec);
92
93 //------------------------------------------------------------------------
96 //------------------------------------------------------------------------
97 static bool Write(boost::asio::ip::tcp::socket & s, uint8_t value,
98 boost::system::error_code & ec);
99
100 //------------------------------------------------------------------------
103 //------------------------------------------------------------------------
104 static bool Read(boost::asio::local::stream_protocol::socket & s,
105 uint8_t & value, boost::system::error_code & ec);
106
107 //------------------------------------------------------------------------
110 //------------------------------------------------------------------------
111 static bool Write(boost::asio::local::stream_protocol::socket & s,
112 uint8_t value, boost::system::error_code & ec);
113
114 //------------------------------------------------------------------------
117 //------------------------------------------------------------------------
118 static bool Read(boost::asio::generic::stream_protocol::socket & s,
119 uint8_t & value, boost::system::error_code & ec);
120
121 //------------------------------------------------------------------------
124 //------------------------------------------------------------------------
125 static bool Write(boost::asio::generic::stream_protocol::socket & s,
126 uint8_t value, boost::system::error_code & ec);
127
128 //------------------------------------------------------------------------
131 //------------------------------------------------------------------------
132 static bool Read(boost::asio::ip::tcp::socket & s, bool & value,
133 boost::system::error_code & ec);
134
135 //------------------------------------------------------------------------
138 //------------------------------------------------------------------------
139 static bool Write(boost::asio::ip::tcp::socket & s, bool value,
140 boost::system::error_code & ec);
141
142 //------------------------------------------------------------------------
145 //------------------------------------------------------------------------
146 static bool Read(boost::asio::local::stream_protocol::socket & s,
147 bool & value, boost::system::error_code & ec);
148
149 //------------------------------------------------------------------------
152 //------------------------------------------------------------------------
153 static bool Write(boost::asio::local::stream_protocol::socket & s,
154 bool value, boost::system::error_code & ec);
155
156 //------------------------------------------------------------------------
159 //------------------------------------------------------------------------
160 static bool Read(boost::asio::generic::stream_protocol::socket & s,
161 bool & value, boost::system::error_code & ec);
162
163 //------------------------------------------------------------------------
166 //------------------------------------------------------------------------
167 static bool Write(boost::asio::generic::stream_protocol::socket & s,
168 bool value, boost::system::error_code & ec);
169
170 //------------------------------------------------------------------------
173 //------------------------------------------------------------------------
174 static bool Read(boost::asio::ip::tcp::socket & s, uint16_t & value,
175 boost::system::error_code & ec);
176
177 //------------------------------------------------------------------------
180 //------------------------------------------------------------------------
181 static bool Write(boost::asio::ip::tcp::socket & s, uint16_t value,
182 boost::system::error_code & ec);
183
184 //------------------------------------------------------------------------
187 //------------------------------------------------------------------------
188 static bool Read(boost::asio::local::stream_protocol::socket & s,
189 uint16_t & value, boost::system::error_code & ec);
190
191 //------------------------------------------------------------------------
194 //------------------------------------------------------------------------
195 static bool Write(boost::asio::local::stream_protocol::socket & s,
196 uint16_t value, boost::system::error_code & ec);
197
198 //------------------------------------------------------------------------
201 //------------------------------------------------------------------------
202 static bool Read(boost::asio::generic::stream_protocol::socket & s,
203 uint16_t & value, boost::system::error_code & ec);
204
205 //------------------------------------------------------------------------
208 //------------------------------------------------------------------------
209 static bool Write(boost::asio::generic::stream_protocol::socket & s,
210 uint16_t value, boost::system::error_code & ec);
211
212 //------------------------------------------------------------------------
215 //------------------------------------------------------------------------
216 static bool Read(boost::asio::ip::tcp::socket & s, uint32_t & value,
217 boost::system::error_code & ec);
218
219 //------------------------------------------------------------------------
222 //------------------------------------------------------------------------
223 static bool Write(boost::asio::ip::tcp::socket & s, uint32_t value,
224 boost::system::error_code & ec);
225
226 //------------------------------------------------------------------------
229 //------------------------------------------------------------------------
230 static bool Read(boost::asio::local::stream_protocol::socket & s,
231 uint32_t & value, boost::system::error_code & ec);
232
233 //------------------------------------------------------------------------
236 //------------------------------------------------------------------------
237 static bool Write(boost::asio::local::stream_protocol::socket & s,
238 uint32_t value, boost::system::error_code & ec);
239
240 //------------------------------------------------------------------------
243 //------------------------------------------------------------------------
244 static bool Read(boost::asio::generic::stream_protocol::socket & s,
245 uint32_t & value, boost::system::error_code & ec);
246
247 //------------------------------------------------------------------------
250 //------------------------------------------------------------------------
251 static bool Write(boost::asio::generic::stream_protocol::socket & s,
252 uint32_t value, boost::system::error_code & ec);
253
254 //------------------------------------------------------------------------
257 //------------------------------------------------------------------------
258 static bool Read(boost::asio::ip::tcp::socket & s, uint64_t & value,
259 boost::system::error_code & ec);
260
261 //------------------------------------------------------------------------
264 //------------------------------------------------------------------------
265 static bool Write(boost::asio::ip::tcp::socket & s, uint64_t value,
266 boost::system::error_code & ec);
267
268 //------------------------------------------------------------------------
271 //------------------------------------------------------------------------
272 static bool Read(boost::asio::local::stream_protocol::socket & s,
273 uint64_t & value, boost::system::error_code & ec);
274
275 //------------------------------------------------------------------------
278 //------------------------------------------------------------------------
279 static bool Write(boost::asio::local::stream_protocol::socket & s,
280 uint64_t value, boost::system::error_code & ec);
281
282 //------------------------------------------------------------------------
285 //------------------------------------------------------------------------
286 static bool Read(boost::asio::generic::stream_protocol::socket & s,
287 uint64_t & value, boost::system::error_code & ec);
288
289 //------------------------------------------------------------------------
292 //------------------------------------------------------------------------
293 static bool Write(boost::asio::generic::stream_protocol::socket & s,
294 uint64_t value, boost::system::error_code & ec);
295
296 //------------------------------------------------------------------------
299 //------------------------------------------------------------------------
300 static bool Read(boost::asio::ip::tcp::socket & s, int8_t & value,
301 boost::system::error_code & ec);
302
303 //------------------------------------------------------------------------
306 //------------------------------------------------------------------------
307 static bool Write(boost::asio::ip::tcp::socket & s, int8_t value,
308 boost::system::error_code & ec);
309
310 //------------------------------------------------------------------------
313 //------------------------------------------------------------------------
314 static bool Read(boost::asio::local::stream_protocol::socket & s,
315 int8_t & value, boost::system::error_code & ec);
316
317 //------------------------------------------------------------------------
320 //------------------------------------------------------------------------
321 static bool Write(boost::asio::local::stream_protocol::socket & s,
322 int8_t value, boost::system::error_code & ec);
323
324 //------------------------------------------------------------------------
327 //------------------------------------------------------------------------
328 static bool Read(boost::asio::generic::stream_protocol::socket & s,
329 int8_t & value, boost::system::error_code & ec);
330
331 //------------------------------------------------------------------------
334 //------------------------------------------------------------------------
335 static bool Write(boost::asio::generic::stream_protocol::socket & s,
336 int8_t value, boost::system::error_code & ec);
337
338 //------------------------------------------------------------------------
341 //------------------------------------------------------------------------
342 static bool Read(boost::asio::ip::tcp::socket & s, int16_t & value,
343 boost::system::error_code & ec);
344
345 //------------------------------------------------------------------------
348 //------------------------------------------------------------------------
349 static bool Write(boost::asio::ip::tcp::socket & s, int16_t value,
350 boost::system::error_code & ec);
351
352 //------------------------------------------------------------------------
355 //------------------------------------------------------------------------
356 static bool Read(boost::asio::local::stream_protocol::socket & s,
357 int16_t & value, boost::system::error_code & ec);
358
359 //------------------------------------------------------------------------
362 //------------------------------------------------------------------------
363 static bool Write(boost::asio::local::stream_protocol::socket & s,
364 int16_t value, boost::system::error_code & ec);
365
366 //------------------------------------------------------------------------
369 //------------------------------------------------------------------------
370 static bool Read(boost::asio::generic::stream_protocol::socket & s,
371 int16_t & value, boost::system::error_code & ec);
372
373 //------------------------------------------------------------------------
376 //------------------------------------------------------------------------
377 static bool Write(boost::asio::generic::stream_protocol::socket & s,
378 int16_t value, boost::system::error_code & ec);
379
380 //------------------------------------------------------------------------
383 //------------------------------------------------------------------------
384 static bool Read(boost::asio::ip::tcp::socket & s, int32_t & value,
385 boost::system::error_code & ec);
386
387 //------------------------------------------------------------------------
390 //------------------------------------------------------------------------
391 static bool Write(boost::asio::ip::tcp::socket & s, int32_t value,
392 boost::system::error_code & ec);
393
394 //------------------------------------------------------------------------
397 //------------------------------------------------------------------------
398 static bool Read(boost::asio::local::stream_protocol::socket & s,
399 int32_t & value, boost::system::error_code & ec);
400
401 //------------------------------------------------------------------------
404 //------------------------------------------------------------------------
405 static bool Write(boost::asio::local::stream_protocol::socket & s,
406 int32_t value, boost::system::error_code & ec);
407
408 //------------------------------------------------------------------------
411 //------------------------------------------------------------------------
412 static bool Read(boost::asio::generic::stream_protocol::socket & s,
413 int32_t & value, boost::system::error_code & ec);
414
415 //------------------------------------------------------------------------
418 //------------------------------------------------------------------------
419 static bool Write(boost::asio::generic::stream_protocol::socket & s,
420 int32_t value, boost::system::error_code & ec);
421
422 //------------------------------------------------------------------------
425 //------------------------------------------------------------------------
426 static bool Read(boost::asio::ip::tcp::socket & s, int64_t & value,
427 boost::system::error_code & ec);
428
429 //------------------------------------------------------------------------
432 //------------------------------------------------------------------------
433 static bool Write(boost::asio::ip::tcp::socket & s, int64_t value,
434 boost::system::error_code & ec);
435
436 //------------------------------------------------------------------------
439 //------------------------------------------------------------------------
440 static bool Read(boost::asio::local::stream_protocol::socket & s,
441 int64_t & value, boost::system::error_code & ec);
442
443 //------------------------------------------------------------------------
446 //------------------------------------------------------------------------
447 static bool Write(boost::asio::local::stream_protocol::socket & s,
448 int64_t value, boost::system::error_code & ec);
449
450 //------------------------------------------------------------------------
453 //------------------------------------------------------------------------
454 static bool Read(boost::asio::generic::stream_protocol::socket & s,
455 int64_t & value, boost::system::error_code & ec);
456
457 //------------------------------------------------------------------------
460 //------------------------------------------------------------------------
461 static bool Write(boost::asio::generic::stream_protocol::socket & s,
462 int64_t value, boost::system::error_code & ec);
463
464 //------------------------------------------------------------------------
467 //------------------------------------------------------------------------
468 static bool Read(boost::asio::ip::tcp::socket & s, std::string & value,
469 boost::system::error_code & ec);
470
471 //------------------------------------------------------------------------
474 //------------------------------------------------------------------------
475 static bool Write(boost::asio::ip::tcp::socket & s,
476 const std::string & value,
477 boost::system::error_code & ec);
478
479 //------------------------------------------------------------------------
482 //------------------------------------------------------------------------
483 static bool Read(boost::asio::local::stream_protocol::socket & s,
484 std::string & value, boost::system::error_code & ec);
485
486 //------------------------------------------------------------------------
489 //------------------------------------------------------------------------
490 static bool Write(boost::asio::local::stream_protocol::socket & s,
491 const std::string & value,
492 boost::system::error_code & ec);
493
494 //------------------------------------------------------------------------
497 //------------------------------------------------------------------------
498 static bool Read(boost::asio::generic::stream_protocol::socket & s,
499 std::string & value, boost::system::error_code & ec);
500
501 //------------------------------------------------------------------------
504 //------------------------------------------------------------------------
505 static bool Write(boost::asio::generic::stream_protocol::socket & s,
506 const std::string & value,
507 boost::system::error_code & ec);
508
509 //------------------------------------------------------------------------
512 //------------------------------------------------------------------------
513 static uint64_t StreamedLength(const std::string & s);
514
515 //------------------------------------------------------------------------
519 //------------------------------------------------------------------------
520 static bool Read(boost::asio::ip::tcp::socket & s, float & val,
521 boost::system::error_code & ec);
522
523 //------------------------------------------------------------------------
527 //------------------------------------------------------------------------
528 static bool Write(boost::asio::ip::tcp::socket & s, float val,
529 boost::system::error_code & ec);
530
531 //------------------------------------------------------------------------
535 //------------------------------------------------------------------------
536 static bool Read(boost::asio::local::stream_protocol::socket & s,
537 float & val, boost::system::error_code & ec);
538
539 //------------------------------------------------------------------------
543 //------------------------------------------------------------------------
544 static bool Write(boost::asio::local::stream_protocol::socket & s,
545 float val, boost::system::error_code & ec);
546
547 //------------------------------------------------------------------------
551 //------------------------------------------------------------------------
552 static bool Read(boost::asio::generic::stream_protocol::socket & s,
553 float & val, boost::system::error_code & ec);
554
555 //------------------------------------------------------------------------
559 //------------------------------------------------------------------------
560 static bool Write(boost::asio::generic::stream_protocol::socket & s,
561 float val, boost::system::error_code & ec);
562
563 //------------------------------------------------------------------------
567 //------------------------------------------------------------------------
568 static bool Read(boost::asio::ip::tcp::socket & s, double & val,
569 boost::system::error_code & ec);
570
571 //------------------------------------------------------------------------
575 //------------------------------------------------------------------------
576 static bool Write(boost::asio::ip::tcp::socket & s, double val,
577 boost::system::error_code & ec);
578
579 //------------------------------------------------------------------------
583 //------------------------------------------------------------------------
584 static bool Read(boost::asio::local::stream_protocol::socket & s,
585 double & val, boost::system::error_code & ec);
586
587 //------------------------------------------------------------------------
591 //------------------------------------------------------------------------
592 static bool Write(boost::asio::local::stream_protocol::socket & s,
593 double val, boost::system::error_code & ec);
594
595 //------------------------------------------------------------------------
599 //------------------------------------------------------------------------
600 static bool Read(boost::asio::generic::stream_protocol::socket & s,
601 double & val, boost::system::error_code & ec);
602
603 //------------------------------------------------------------------------
607 //------------------------------------------------------------------------
608 static bool Write(boost::asio::generic::stream_protocol::socket & s,
609 double val, boost::system::error_code & ec);
610
611 //------------------------------------------------------------------------
614 //------------------------------------------------------------------------
615 template <typename S, typename _firstT, typename _secondT>
617 static bool Read(S & s, std::pair<_firstT, _secondT> & p,
618 boost::system::error_code & ec)
619 {
620 bool rc = false;
621 if (Read(s, p.first, ec)) {
622 rc = Read(s, p.second, ec);
623 }
624 return(rc);
625 }
626
627 //------------------------------------------------------------------------
630 //------------------------------------------------------------------------
631 template <typename S, typename _firstT, typename _secondT>
633 static bool Write(S & s, const std::pair<_firstT,_secondT> & p,
634 boost::system::error_code & ec)
635 {
636 bool rc = false;
637 if (Write(s, p.first, ec)) {
638 rc = Write(s, p.second, ec);
639 }
640 return rc;
641 }
642
643 //------------------------------------------------------------------------
646 //------------------------------------------------------------------------
647 template <typename S, typename... Args>
649 static bool Read(S & s, std::tuple<Args...> & t,
650 boost::system::error_code & ec)
651 {
652 return(std::apply([&s,&ec](auto&&...args)
653 {
654 auto read_tuple_mem = [&s,&ec](auto&& x) { return Read(s, x, ec); };
655 return (read_tuple_mem(args) && ...);
656 }, t));
657 }
658
659 //------------------------------------------------------------------------
662 //------------------------------------------------------------------------
663 template <typename S, typename... Args>
665 static bool Write(S & s, const std::tuple<Args...> & t,
666 boost::system::error_code & ec)
667 {
668 return(std::apply([&s,&ec](auto&&...args)
669 {
670 auto write_tuple_mem = [&s,&ec](auto&& x) { return Write(s, x, ec); };
671 return (write_tuple_mem(args) && ...);
672 }, t));
673 }
674
675 //------------------------------------------------------------------------
678 //------------------------------------------------------------------------
679 template <typename S, typename... Ts>
681 static bool Read(S & s, std::variant<Ts...> & v,
682 boost::system::error_code & ec)
683 {
684 bool rc = false;
685 uint64_t index = 0;
686 if (Read(s, index, ec)) {
687 if (index < std::variant_size_v<std::variant<Ts...>>) {
688 rc = true;
689 v = VariantFromIndex<Ts...>(index);
690 std::visit([&] (auto && arg) { rc &= Read(s, arg, ec); }, v);
691 }
692 }
693 return rc;
694 }
695
696 //------------------------------------------------------------------------
699 //------------------------------------------------------------------------
700 template <typename S, typename... Ts>
702 static bool Write(S & s, const std::variant<Ts...> & v,
703 boost::system::error_code & ec)
704 {
705 bool rc = false;
706 uint64_t index = v.index();
707 if (Write(s, index, ec)) {
708 rc = true;
709 std::visit([&] (const auto & arg) { rc &= Write(s, arg, ec); }, v);
710 }
711 return rc;
712 }
713
714 //------------------------------------------------------------------------
717 //------------------------------------------------------------------------
718 template <typename S, typename _valueT, size_t N>
720 static bool Read(S & s, std::array<_valueT, N> & a,
721 boost::system::error_code & ec)
722 {
723 size_t i = 0;
724 for ( ; i < N; ++i) {
725 if (! Read(s, a[i], ec)) {
726 break;
727 }
728 }
729 return (N == i);
730 }
731
732 //------------------------------------------------------------------------
735 //------------------------------------------------------------------------
736 template <typename S, typename _valueT, size_t N>
738 static bool Write(S & s, const std::array<_valueT, N> & a,
739 boost::system::error_code & ec)
740 {
741 size_t i = 0;
742 for ( ; i < N; ++i) {
743 if (! Write(s, a[i], ec)) {
744 break;
745 }
746 }
747 return (N == i);
748 }
749
750 //------------------------------------------------------------------------
753 //------------------------------------------------------------------------
754 template <typename S, typename _valueT, typename _Alloc>
756 static bool Read(S & s, std::vector<_valueT, _Alloc> & v,
757 boost::system::error_code & ec)
758 {
759 return ContainerRead<S,std::vector<_valueT, _Alloc> >(s, v, ec);
760 }
761
762 //------------------------------------------------------------------------
765 //------------------------------------------------------------------------
766 template <typename S, typename _valueT, typename _Alloc>
768 static bool Write(S & s, const std::vector<_valueT, _Alloc> & v,
769 boost::system::error_code & ec)
770 {
771 return ContainerWrite<S,std::vector<_valueT, _Alloc> >(s, v, ec);
772 }
773
774 //------------------------------------------------------------------------
777 //------------------------------------------------------------------------
778 template <typename S, typename _valueT, typename _Alloc>
780 static bool Read(S & s, std::deque<_valueT, _Alloc> & d,
781 boost::system::error_code & ec)
782 {
783 return ContainerRead<S,std::deque<_valueT, _Alloc> >(s, d, ec);
784 }
785
786 //------------------------------------------------------------------------
789 //------------------------------------------------------------------------
790 template <typename S, typename _valueT, typename _Alloc>
792 static bool Write(S & s, const std::deque<_valueT, _Alloc> & d,
793 boost::system::error_code & ec)
794 {
795 return ContainerWrite<S,std::deque<_valueT, _Alloc> >(s, d, ec);
796 }
797
798 //------------------------------------------------------------------------
801 //------------------------------------------------------------------------
802 template <typename S, typename _valueT, typename _Alloc>
804 static bool Read(S & s, std::list<_valueT, _Alloc> & l,
805 boost::system::error_code & ec)
806 {
807 return ContainerRead<S,std::list<_valueT, _Alloc> >(s, l, ec);
808 }
809
810 //------------------------------------------------------------------------
813 //------------------------------------------------------------------------
814 template <typename S, typename _valueT, typename _Alloc>
816 static bool Write(S & s, const std::list<_valueT, _Alloc> & l,
817 boost::system::error_code & ec)
818 {
819 return ContainerWrite<S,std::list<_valueT, _Alloc> >(s, l, ec);
820 }
821
822 //------------------------------------------------------------------------
825 //------------------------------------------------------------------------
826 template <typename S, typename _keyT, typename _valueT,
827 typename _Compare, typename _Alloc>
829 static bool Read(S & s, std::map<_keyT, _valueT, _Compare, _Alloc> & m,
830 boost::system::error_code & ec)
831 {
832 return(PairAssocContRead<S,std::map<_keyT, _valueT, _Compare, _Alloc> >(s, m, ec));
833 }
834
835 //------------------------------------------------------------------------
838 //------------------------------------------------------------------------
839 template <typename S, typename _keyT, typename _valueT,
840 typename _Compare, typename _Alloc>
842 static bool Write(S & s,
843 const std::map<_keyT,_valueT, _Compare, _Alloc> & m,
844 boost::system::error_code & ec)
845 {
846 return(ContainerWrite<S,std::map<_keyT,_valueT,_Compare,_Alloc> >(s, m, ec));
847 }
848
849 //------------------------------------------------------------------------
852 //------------------------------------------------------------------------
853 template <typename S, typename _keyT, typename _valueT,
854 typename _Compare, typename _Alloc>
856 static bool Read(S & s, std::multimap<_keyT,_valueT,_Compare,_Alloc> & m,
857 boost::system::error_code & ec)
858 {
859 return(PairAssocContRead<S,std::multimap<_keyT,_valueT,_Compare,_Alloc>>(s, m, ec));
860 }
861
862 //------------------------------------------------------------------------
865 //------------------------------------------------------------------------
866 template <typename S, typename _keyT, typename _valueT,
867 typename _Compare, typename _Alloc>
869 static bool
870 Write(S & s,
871 const std::multimap<_keyT,_valueT, _Compare, _Alloc> & m,
872 boost::system::error_code & ec)
873 {
874 return(ContainerWrite<S,std::multimap<_keyT,_valueT,_Compare,_Alloc>>(s, m, ec));
875 }
876
877 //------------------------------------------------------------------------
880 //------------------------------------------------------------------------
881 template <typename S, typename _keyT, typename _valueT,
882 typename _Hash, typename _Pred, typename _Alloc>
884 static bool
885 Read(S & s, std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> & m,
886 boost::system::error_code & ec)
887 {
888 return(PairAssocContRead<S,std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> >(s, m, ec));
889 }
890
891 //------------------------------------------------------------------------
894 //------------------------------------------------------------------------
895 template <typename S, typename _keyT, typename _valueT,
896 typename _Hash, typename _Pred, typename _Alloc>
898 static bool
899 Write(S & s,
900 const std::unordered_map<_keyT, _valueT, _Hash, _Pred, _Alloc> & m,
901 boost::system::error_code & ec)
902 {
903 return(ContainerWrite<S,std::unordered_map<_keyT,_valueT,_Hash,_Pred,_Alloc> >(s, m, ec));
904 }
905
906 //------------------------------------------------------------------------
909 //------------------------------------------------------------------------
910 template <typename S, typename _valueT, typename _Compare, typename _Alloc>
912 static bool Read(S & s,
913 std::set<_valueT,_Compare,_Alloc> & m,
914 boost::system::error_code & ec)
915 {
916 return(ContainerRead<S,std::set<_valueT,_Compare,_Alloc>>(s, m, ec));
917 }
918
919 //------------------------------------------------------------------------
922 //------------------------------------------------------------------------
923 template <typename S, typename _valueT, typename _Compare, typename _Alloc>
925 static bool Write(S & s, const std::set<_valueT,_Compare,_Alloc> & m,
926 boost::system::error_code & ec)
927 {
928 return(ContainerWrite<S,std::set<_valueT,_Compare,_Alloc>>(s, m, ec));
929 }
930
931 //------------------------------------------------------------------------
934 //------------------------------------------------------------------------
935 template <typename S, typename _valueT, typename _Compare, typename _Alloc>
937 static bool Read(S & s, std::multiset<_valueT,_Compare,_Alloc> & m,
938 boost::system::error_code & ec)
939 {
940 return(ContainerRead<S,std::multiset<_valueT,_Compare,_Alloc>>(s, m, ec));
941 }
942
943 //------------------------------------------------------------------------
946 //------------------------------------------------------------------------
947 template <typename S, typename _valueT, typename _Compare, typename _Alloc>
949 static bool Write(S & s,
950 const std::multiset<_valueT,_Compare,_Alloc> & m,
951 boost::system::error_code & ec)
952 {
953 return(ContainerWrite<S,std::multiset<_valueT,_Compare,_Alloc>>(s, m, ec));
954 }
955
956 //------------------------------------------------------------------------
959 //------------------------------------------------------------------------
960 template <typename S, typename _valueT, typename _Hash,
961 typename _Pred, typename _Alloc>
963 static bool
964 Read(S & s, std::unordered_set<_valueT, _Hash, _Pred, _Alloc> & m,
965 boost::system::error_code & ec)
966 {
967 return(ContainerRead<S,std::unordered_set<_valueT,_Hash,_Pred,_Alloc>>(s, m, ec));
968 }
969
970 //------------------------------------------------------------------------
973 //------------------------------------------------------------------------
974 template <typename S, typename _valueT, typename _Hash,
975 typename _Pred, typename _Alloc>
977 static bool
978 Write(S & s, const std::unordered_set<_valueT, _Hash, _Pred, _Alloc> & m,
979 boost::system::error_code & ec)
980 {
981 return(ContainerWrite<S,std::unordered_set<_valueT,_Hash,_Pred,_Alloc>>(s, m, ec));
982 }
983
984 //------------------------------------------------------------------------
986 //------------------------------------------------------------------------
987 template <typename S>
989 static bool Read(S & s, ASIOReadable & val,
990 boost::system::error_code & ec)
991 { return val.Read(s, ec); }
992
993 //------------------------------------------------------------------------
995 //------------------------------------------------------------------------
996 template <typename S>
998 static bool Read(S & s, HasAsioRead auto & val,
999 boost::system::error_code & ec)
1000 { return val.Read(s, ec); }
1001
1002 //------------------------------------------------------------------------
1004 //------------------------------------------------------------------------
1005 template <typename S>
1007 static bool Write(S & s, const ASIOWritable & val,
1008 boost::system::error_code & ec)
1009 { return val.Write(s, ec); }
1010
1011 //------------------------------------------------------------------------
1013 //------------------------------------------------------------------------
1014 template <typename S>
1016 static bool Write(S & s, const HasAsioWrite auto & val,
1017 boost::system::error_code & ec)
1018 { return val.Write(s, ec); }
1019
1020 //------------------------------------------------------------------------
1022 //------------------------------------------------------------------------
1023 template <typename S, typename... Args>
1025 static bool ReadV(S & s, boost::system::error_code & ec, Args & ...args)
1026 {
1027 return (Read(s,args,ec) && ...);
1028 }
1029
1030 //------------------------------------------------------------------------
1032 //------------------------------------------------------------------------
1033 template <typename S, typename... Args>
1035 static bool WriteV(S & s, boost::system::error_code & ec,
1036 const Args & ...args)
1037 {
1038 return (Write(s,args,ec) && ...);
1039 }
1040
1041 private:
1042 //------------------------------------------------------------------------
1046 //------------------------------------------------------------------------
1047 template <typename S>
1048 requires IsSupportedASIOSocket<S>
1049 static bool Read(S & s, std::monostate & sm,
1050 boost::system::error_code & ec)
1051 {
1052 return true;
1053 }
1054
1055 //------------------------------------------------------------------------
1059 //------------------------------------------------------------------------
1060 template <typename S>
1061 requires IsSupportedASIOSocket<S>
1062 static bool Write(S & s, const std::monostate & sm,
1063 boost::system::error_code & ec)
1064 {
1065 return true;
1066 }
1067
1068 //------------------------------------------------------------------------
1072 //------------------------------------------------------------------------
1073 template <typename S, typename _containerT>
1074 requires IsSupportedASIOSocket<S>
1075 static bool ContainerRead(S & s, _containerT & c,
1076 boost::system::error_code & ec)
1077 {
1078 bool rc = false;
1079 c.clear();
1080 uint64_t numEntries;
1081 if (Read(s, numEntries, ec)) {
1082 uint64_t i = 0;
1083 for ( ; i < numEntries; ++i) {
1084 typename _containerT::value_type val;
1085 if (! Read(s, val, ec)) {
1086 break;
1087 }
1088 c.insert(c.end(), std::move(val));
1089 }
1090 rc = (i == numEntries);
1091 }
1092 return rc;
1093 }
1094
1095 //------------------------------------------------------------------------
1098 //------------------------------------------------------------------------
1099 template <typename S, typename _containerT>
1100 requires IsSupportedASIOSocket<S>
1101 static bool ContainerWrite(S & s, const _containerT & c,
1102 boost::system::error_code & ec)
1103 {
1104 bool rc = false;
1105 uint64_t numEntries = c.size();
1106 if (Write(s, numEntries, ec)) {
1107 if (numEntries) {
1109 c.begin(),
1110 c.end(),
1111 ec);
1112 }
1113 else {
1114 rc = true;
1115 }
1116 }
1117 return rc;
1118 }
1119
1120 //------------------------------------------------------------------------
1122 //------------------------------------------------------------------------
1123 template <typename S, typename _inputIteratorT>
1124 requires IsSupportedASIOSocket<S>
1125 static bool Write(S & s, _inputIteratorT f, _inputIteratorT l,
1126 boost::system::error_code & ec)
1127 {
1128 for ( ; f != l; ++f) {
1129 if (! Write(s, *f, ec)) {
1130 break;
1131 }
1132 }
1133 return (f == l);
1134 }
1135 //------------------------------------------------------------------------
1139 //------------------------------------------------------------------------
1140 template <typename S, typename _containerT>
1141 requires IsSupportedASIOSocket<S>
1142 static bool PairAssocContRead(S & s, _containerT & m,
1143 boost::system::error_code & ec)
1144 {
1145 bool rc = false;
1146 m.clear();
1147 uint64_t numEntries;
1148 if (Read(s, numEntries, ec)) {
1149 uint64_t i = 0;
1150 for ( ; i < numEntries; ++i) {
1151 typename _containerT::key_type key;
1152 if (Read(s, key, ec)) {
1153 typename _containerT::mapped_type val;
1154 if (Read(s, val, ec)) {
1155 m.insert(typename _containerT::value_type(std::move(key),
1156 std::move(val)));
1157 }
1158 else {
1159 break;
1160 }
1161 }
1162 else {
1163 break;
1164 }
1165 }
1166 rc = (i == numEntries);
1167
1168 }
1169 return rc;
1170 }
1171
1172 };
1173
1174} // namespace Dwm
1175
1176#endif // _DWMASIO_HH_
1177
1178
1179//---------------------------- emacs settings -----------------------------
1180// Local Variables:
1181// mode: C++
1182// tab-width: 2
1183// indent-tabs-mode: nil
1184// c-basic-offset: 2
1185// End:
1186//-------------------------------------------------------------------------
Dwm::HasAsioTcpRead, Dwm::HasAsioTcpWrite, Dwm::HasAsioLocalRead, Dwm::HasAsioLocalWrite,...
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
Interface for classes that wish to be readable via Dwm::ASIO.
Definition DwmASIOCapable.hh:145
virtual bool Read(boost::asio::ip::tcp::socket &s, boost::system::error_code &ec)=0
Should read the class from the given socket s and return true on success, false on failure.
Interface for classes that wish to be writable via Dwm::ASIO.
Definition DwmASIOCapable.hh:174
virtual bool Write(boost::asio::ip::tcp::socket &s, boost::system::error_code &ec) const =0
Should write the class to the given socket s and return true on success, false on failure.
A collection of functions for reading from and writing to Boost ASIO stream sockets.
Definition DwmASIO.hh:84
static bool Write(boost::asio::generic::stream_protocol::socket &s, uint16_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool WriteV(S &s, boost::system::error_code &ec, const Args &...args)
Writes args to s. Returns true on success, false on failure.
Definition DwmASIO.hh:1035
static bool Write(boost::asio::generic::stream_protocol::socket &s, int16_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::local::stream_protocol::socket &s, float val, boost::system::error_code &ec)
Writes val to s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Write(S &s, const std::array< _valueT, N > &a, boost::system::error_code &ec)
Writes an array<_valueT.N> v to s.
Definition DwmASIO.hh:738
static bool Write(boost::asio::local::stream_protocol::socket &s, uint64_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::generic::stream_protocol::socket &s, std::string &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(S &s, const std::deque< _valueT, _Alloc > &d, boost::system::error_code &ec)
Writes a deque<_valueT> d to s.
Definition DwmASIO.hh:792
static bool Read(boost::asio::ip::tcp::socket &s, uint64_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(boost::asio::generic::stream_protocol::socket &s, uint8_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::local::stream_protocol::socket &s, const std::string &value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::generic::stream_protocol::socket &s, bool &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, int16_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, bool &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(S &s, const std::tuple< Args... > &t, boost::system::error_code &ec)
Writes a tuple to s.
Definition DwmASIO.hh:665
static bool Read(boost::asio::ip::tcp::socket &s, int32_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(S &s, std::deque< _valueT, _Alloc > &d, boost::system::error_code &ec)
Reads a deque<_valueT> d from s.
Definition DwmASIO.hh:780
static bool Write(boost::asio::ip::tcp::socket &s, double val, boost::system::error_code &ec)
Writes val to s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Read(S &s, std::variant< Ts... > &v, boost::system::error_code &ec)
Reads a variant \C V from s.
Definition DwmASIO.hh:681
static bool Write(S &s, const std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &m, boost::system::error_code &ec)
Writes a unordered_map<_keyT,_valueT> m to s.
Definition DwmASIO.hh:899
static bool Read(boost::asio::ip::tcp::socket &s, int8_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(boost::asio::ip::tcp::socket &s, uint64_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::ip::tcp::socket &s, uint32_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::generic::stream_protocol::socket &s, int32_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::generic::stream_protocol::socket &s, const std::string &value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::generic::stream_protocol::socket &s, int16_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::ip::tcp::socket &s, float &val, boost::system::error_code &ec)
Reads val from s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Write(S &s, const std::multimap< _keyT, _valueT, _Compare, _Alloc > &m, boost::system::error_code &ec)
Writes a multimap<_keyT,_valueT> m to s.
Definition DwmASIO.hh:870
static bool Write(boost::asio::local::stream_protocol::socket &s, int8_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(S &s, const std::pair< _firstT, _secondT > &p, boost::system::error_code &ec)
Writes a pair<_firstT,_secondT> to s.
Definition DwmASIO.hh:633
static bool Write(S &s, const std::variant< Ts... > &v, boost::system::error_code &ec)
Writes a variant v to s.
Definition DwmASIO.hh:702
static bool Write(boost::asio::ip::tcp::socket &s, uint8_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::generic::stream_protocol::socket &s, uint32_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::generic::stream_protocol::socket &s, int32_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(boost::asio::local::stream_protocol::socket &s, uint8_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, double &val, boost::system::error_code &ec)
Reads val from s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Read(S &s, std::array< _valueT, N > &a, boost::system::error_code &ec)
Reads an array<_valueT,N> v from s.
Definition DwmASIO.hh:720
static bool Write(boost::asio::generic::stream_protocol::socket &s, int64_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::generic::stream_protocol::socket &s, int8_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(S &s, const HasAsioWrite auto &val, boost::system::error_code &ec)
Writes val to s. Returns true on success, false on failure.
Definition DwmASIO.hh:1016
static bool Write(boost::asio::generic::stream_protocol::socket &s, bool value, boost::system::error_code &ec)
Write value to the given socket s.
static bool ReadV(S &s, boost::system::error_code &ec, Args &...args)
Reads args from s. Returns true on success, false on failure.
Definition DwmASIO.hh:1025
static bool Read(S &s, std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &m, boost::system::error_code &ec)
Reads an unordered_set<_valueT> m from s.
Definition DwmASIO.hh:964
static bool Read(boost::asio::generic::stream_protocol::socket &s, uint64_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(S &s, const std::vector< _valueT, _Alloc > &v, boost::system::error_code &ec)
Writes a vector<_valueT> v to s.
Definition DwmASIO.hh:768
static bool Read(S &s, std::map< _keyT, _valueT, _Compare, _Alloc > &m, boost::system::error_code &ec)
Reads a map<_keyT,_valueT> m from s.
Definition DwmASIO.hh:829
static bool Write(boost::asio::generic::stream_protocol::socket &s, float val, boost::system::error_code &ec)
Writes val to s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Write(boost::asio::local::stream_protocol::socket &s, int32_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(S &s, const std::list< _valueT, _Alloc > &l, boost::system::error_code &ec)
Writes a list<_valueT> l to s.
Definition DwmASIO.hh:816
static uint64_t StreamedLength(const std::string &s)
Returns the number of bytes that should be written if we call the Write() member for a string.
static bool Read(S &s, HasAsioRead auto &val, boost::system::error_code &ec)
Reads val from s. Returns true on success, false on failure.
Definition DwmASIO.hh:998
static bool Write(S &s, const std::set< _valueT, _Compare, _Alloc > &m, boost::system::error_code &ec)
Writes a set<_valueT> m to s.
Definition DwmASIO.hh:925
static bool Write(boost::asio::generic::stream_protocol::socket &s, uint32_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, int8_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, uint32_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, uint16_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(boost::asio::ip::tcp::socket &s, const std::string &value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::ip::tcp::socket &s, uint16_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, uint64_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(S &s, std::unordered_map< _keyT, _valueT, _Hash, _Pred, _Alloc > &m, boost::system::error_code &ec)
Reads an unordered_map<_keyT,_valueT> m from s.
Definition DwmASIO.hh:885
static bool Read(boost::asio::ip::tcp::socket &s, std::string &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::ip::tcp::socket &s, int16_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(boost::asio::generic::stream_protocol::socket &s, double val, boost::system::error_code &ec)
Writes val to s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Read(boost::asio::generic::stream_protocol::socket &s, uint8_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::ip::tcp::socket &s, int64_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::ip::tcp::socket &s, bool &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(S &s, std::vector< _valueT, _Alloc > &v, boost::system::error_code &ec)
Reads a vector<_valueT> v from s.
Definition DwmASIO.hh:756
static bool Read(boost::asio::local::stream_protocol::socket &s, std::string &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::ip::tcp::socket &s, uint32_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(S &s, std::tuple< Args... > &t, boost::system::error_code &ec)
Reads a tuple from s.
Definition DwmASIO.hh:649
static bool Read(boost::asio::ip::tcp::socket &s, uint8_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(S &s, const std::multiset< _valueT, _Compare, _Alloc > &m, boost::system::error_code &ec)
Writes a multiset<_valueT> m to s.
Definition DwmASIO.hh:949
static bool Read(boost::asio::generic::stream_protocol::socket &s, float &val, boost::system::error_code &ec)
Reads val from s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Write(boost::asio::generic::stream_protocol::socket &s, uint64_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::ip::tcp::socket &s, uint16_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(boost::asio::ip::tcp::socket &s, float val, boost::system::error_code &ec)
Writes val to s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Write(boost::asio::local::stream_protocol::socket &s, int64_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::local::stream_protocol::socket &s, uint16_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::local::stream_protocol::socket &s, bool value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(S &s, const ASIOWritable &val, boost::system::error_code &ec)
Writes val to s. Returns true on success, false on failure.
Definition DwmASIO.hh:1007
static bool Read(S &s, std::set< _valueT, _Compare, _Alloc > &m, boost::system::error_code &ec)
Reads a set<_valueT> m from s.
Definition DwmASIO.hh:912
static bool Write(boost::asio::ip::tcp::socket &s, int64_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::ip::tcp::socket &s, int8_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, uint8_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(boost::asio::ip::tcp::socket &s, int32_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::local::stream_protocol::socket &s, double val, boost::system::error_code &ec)
Writes val to s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Read(boost::asio::generic::stream_protocol::socket &s, uint16_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, int64_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::local::stream_protocol::socket &s, int32_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(S &s, const std::unordered_set< _valueT, _Hash, _Pred, _Alloc > &m, boost::system::error_code &ec)
Writes a unordered_set<_valueT> m to s.
Definition DwmASIO.hh:978
static bool Read(boost::asio::generic::stream_protocol::socket &s, int64_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Read(boost::asio::ip::tcp::socket &s, double &val, boost::system::error_code &ec)
Reads val from s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Read(S &s, std::list< _valueT, _Alloc > &l, boost::system::error_code &ec)
Reads a list<_valueT> l from s.
Definition DwmASIO.hh:804
static bool Read(boost::asio::generic::stream_protocol::socket &s, int8_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static bool Write(S &s, const std::map< _keyT, _valueT, _Compare, _Alloc > &m, boost::system::error_code &ec)
Writes a map<_keyT,_valueT> m to s.
Definition DwmASIO.hh:842
static bool Read(S &s, ASIOReadable &val, boost::system::error_code &ec)
Reads val from s. Returns true on success, false on failure.
Definition DwmASIO.hh:989
static bool Read(S &s, std::pair< _firstT, _secondT > &p, boost::system::error_code &ec)
Reads a pair<_firstT,_secondT> from s.
Definition DwmASIO.hh:617
static bool Read(boost::asio::local::stream_protocol::socket &s, float &val, boost::system::error_code &ec)
Reads val from s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
static bool Write(boost::asio::local::stream_protocol::socket &s, uint32_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Write(boost::asio::ip::tcp::socket &s, int16_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(S &s, std::multiset< _valueT, _Compare, _Alloc > &m, boost::system::error_code &ec)
Reads a multiset<_valueT> m from s.
Definition DwmASIO.hh:937
static bool Write(boost::asio::local::stream_protocol::socket &s, int16_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(S &s, std::multimap< _keyT, _valueT, _Compare, _Alloc > &m, boost::system::error_code &ec)
Reads a multimap<_keyT,_valueT> m from s.
Definition DwmASIO.hh:856
static bool Write(boost::asio::ip::tcp::socket &s, bool value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::generic::stream_protocol::socket &s, double &val, boost::system::error_code &ec)
Reads val from s, in IEEE format (see RFC 1832 and/or ANSI/IEEE Standard 754-1985).
T has asio read members.
Definition DwmASIOCapable.hh:128
T has asio write members.
Definition DwmASIOCapable.hh:136
Concept for the types of ASIO sockets we can utilize.
Definition DwmASIO.hh:68