libDwm-0.9.45
DwmIO.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2004-2007, 2016, 2017, 2020
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
32// PURPOSE, OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
39//---------------------------------------------------------------------------
40
41#ifndef _DWMIO_HH_
42#define _DWMIO_HH_
43
44#include "DwmDescriptorIO.hh"
45#include "DwmFileIO.hh"
46#include "DwmStreamIO.hh"
47#include "DwmIOUtils.hh"
48
49namespace Dwm {
50
51 //--------------------------------------------------------------------------
57 //--------------------------------------------------------------------------
58 class IO
59 {
60 public:
61 //------------------------------------------------------------------------
63 //------------------------------------------------------------------------
64 template <typename T>
65 static std::istream & Read(std::istream & is, T & val)
66 {
67 return StreamIO::Read(is, val);
68 }
69
70 //------------------------------------------------------------------------
72 //------------------------------------------------------------------------
73 template <typename T>
74 static std::ostream & Write(std::ostream & os, const T & val)
75 {
76 return StreamIO::Write(os, val);
77 }
78
79 //------------------------------------------------------------------------
81 //------------------------------------------------------------------------
82 template <typename T>
83 static ssize_t Read(int fd, T & val)
84 {
85 return DescriptorIO::Read(fd, val);
86 }
87
88 //------------------------------------------------------------------------
90 //------------------------------------------------------------------------
91 template <typename T>
92 static ssize_t Write(int fd, const T & val)
93 {
94 return DescriptorIO::Write(fd, val);
95 }
96
97 //------------------------------------------------------------------------
99 //------------------------------------------------------------------------
100 template <typename T>
101 static size_t Read(FILE *f, T & val)
102 {
103 return FileIO::Read(f, val);
104 }
105
106 //------------------------------------------------------------------------
108 //------------------------------------------------------------------------
109 template <typename T>
110 static size_t Write(FILE *f, const T & val)
111 {
112 return FileIO::Write(f, val);
113 }
114
115 //------------------------------------------------------------------------
117 //------------------------------------------------------------------------
118 template <typename T>
119 static uint64_t StreamedLength(const T & val)
120 {
121 return IOUtils::StreamedLength(val);
122 }
123 };
124
125} // namespace Dwm
126
127
128#endif // _DWMIO_HH_
129
130//---------------------------- emacs settings -----------------------------
131// Local Variables:
132// mode: C++
133// tab-width: 2
134// indent-tabs-mode: nil
135// c-basic-offset: 2
136// End:
137//-------------------------------------------------------------------------
Dwm::DescriptorIO class declaration.
Dwm::FileIO class declaration.
Dwm::IOUtils class declaration and implementation.
Dwm::StreamIO class declaration.
static ssize_t Write(int fd, char c)
Writes c to fd.
static ssize_t Read(int fd, char &c)
Reads c from fd.
static size_t Write(FILE *f, char c)
Writes c to f.
static size_t Read(FILE *f, char &c)
Reads c from f.
static uint64_t StreamedLength(char c)
Returns the number of bytes that would be written if we called Write() for a char.
Definition DwmIOUtils.hh:85
This class is now just a wrapper for DescriptorIO, FileIO, StreamIO and IOUtils.
Definition DwmIO.hh:59
static std::istream & Read(std::istream &is, char &c)
Reads c from is. Returns is.
static std::ostream & Write(std::ostream &os, char c)
Writes c to os. Returns os.