CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IOOutput.cc
Go to the documentation of this file.
3 #include <cassert>
4 
7 {}
8 
12 
40 IOSize
41 IOOutput::write (unsigned char byte)
42 { return write (&byte, 1); }
43 
62 IOSize
64 { return write (from.data (), from.size ()); }
65 
89 IOSize
91 {
92  assert (! buffers || from);
93 
94  // Keep writing as long as possible; ignore errors if we have
95  // written something, otherwise pass it on.
96  IOSize x;
97  IOSize done = 0;
98  try
99  {
100  for (IOSize i = 0; i < buffers; ++i)
101  {
102  done += (x = write (from [i].data (), from [i].size ()));
103  if (x < from [i].size ())
104  break;
105  }
106  }
107  catch (cms::Exception &)
108  {
109  if (! done)
110  throw;
111  }
112 
113  return done;
114 }
115 
119 
145 IOSize
147 { return xwrite (from.data (), from.size ()); }
148 
175 IOSize
177 {
178  // Keep writing until we've written it all. Let errors fly over.
179  IOSize done = 0;
180  while (done < n)
181  done += write ((const char *) from + done, n - done);
182 
183  return done;
184 }
185 
214 IOSize
216 {
217  // Keep writing until we've written it all. Let errors fly over.
218  // FIXME: Use writev(from, buffers) and then sort out in case of
219  // failure, the writev probably succeed directly with much less
220  // overhead.
221  assert (! buffers || from);
222 
223  IOSize done = 0;
224  for (IOSize i = 0; i < buffers; ++i)
225  done += xwrite (from [i].data (), from [i].size ());
226 
227  return done;
228 }
virtual ~IOOutput(void)
Destruct the stream. A no-op.
Definition: IOOutput.cc:6
IOSize xwrite(const void *from, IOSize n)
Definition: IOOutput.cc:176
IOSize write(unsigned char byte)
Definition: IOOutput.cc:41
int i
Definition: DBlmapReader.cc:9
void * data(void) const
Definition: IOBuffer.h:45
unsigned char byte
IOSize size(void) const
Definition: IOBuffer.h:50
static std::string from(" from ")
virtual IOSize writev(const IOBuffer *from, IOSize buffers)
Definition: IOOutput.cc:90
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
size_t IOSize
Definition: IOTypes.h:14
x
Definition: VDTMath.h:216
IOSize xwritev(const IOBuffer *from, IOSize buffers)
Definition: IOOutput.cc:215
tuple size
Write out results.