CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IOInput.cc
Go to the documentation of this file.
3 #include <cassert>
4 
7 {}
8 
12 
53 int
55 {
56  unsigned char byte;
57  IOSize n = read (&byte, 1);
58  return n == 0 ? -1 : byte;
59 }
60 
83 IOSize
85 { return read (into.data (), into.size ()); }
86 
116 IOSize
118 {
119  assert (! buffers || into);
120 
121  // Keep reading as long as possible; ignore errors if we have read
122  // something, otherwise pass it on.
123  IOSize status;
124  IOSize done = 0;
125  try
126  {
127  for (IOSize i = 0; i < buffers; done += status, ++i)
128  if ((status = read (into [i])) == 0)
129  break;
130  }
131  catch (cms::Exception &)
132  {
133  if (! done)
134  throw;
135  }
136 
137  return done;
138 }
139 
143 
165 IOSize
167 { return xread (into.data (), into.size ()); }
168 
190 IOSize
191 IOInput::xread (void *into, IOSize n)
192 {
193  assert (into);
194 
195  // Keep reading as long as possible. Let system errors fly over
196  // us, they are a hard error.
197  IOSize x;
198  IOSize done = 0;
199  while (done < n && (x = read ((char *) into + done, n - done)))
200  done += x;
201 
202  return done;
203 }
204 
228 IOSize
230 {
231  // FIXME: Use read(into, buffers) and then sort out in case of
232  // failure, the readv probably succeed directly with much less
233  // overhead.
234 
235  assert (! buffers || into);
236 
237  // Keep reading as long as possible. Let system errors fly
238  // over us, they are a hard error.
239  IOSize x;
240  IOSize done = 0;
241  for (IOSize i = 0; i < buffers; ++i)
242  {
243  done += (x = xread (into [i]));
244  if (x < into [i].size ())
245  break;
246  }
247  return done;
248 }
int i
Definition: DBlmapReader.cc:9
void * data(void) const
Definition: IOBuffer.h:45
IOSize xread(IOBuffer into)
Definition: IOInput.cc:166
virtual ~IOInput(void)
Destruct the stream. A no-op.
Definition: IOInput.cc:6
unsigned char byte
virtual IOSize readv(IOBuffer *into, IOSize buffers)
Definition: IOInput.cc:117
IOSize xreadv(IOBuffer *into, IOSize buffers)
Definition: IOInput.cc:229
int read(void)
Definition: IOInput.cc:54
IOSize size(void) const
Definition: IOBuffer.h:50
size_t IOSize
Definition: IOTypes.h:14
tuple status
Definition: ntuplemaker.py:245
x
Definition: VDTMath.h:216
tuple size
Write out results.