CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
lhef::CBInputStream Class Reference

#include <XMLUtils.h>

Inheritance diagram for lhef::CBInputStream:

Classes

class  Reader
 

Public Types

typedef Reader Stream_t
 

Public Member Functions

 CBInputStream (Reader &in)
 
virtual XMLFilePos curPos () const override
 
virtual const XMLCh * getContentType () const override
 
virtual XMLSize_t readBytes (XMLByte *const buf, const XMLSize_t size) override
 
virtual ~CBInputStream ()
 

Private Attributes

std::string buffer
 
unsigned int pos
 
Readerreader
 

Detailed Description

Definition at line 128 of file XMLUtils.h.

Member Typedef Documentation

Definition at line 136 of file XMLUtils.h.

Constructor & Destructor Documentation

lhef::CBInputStream::CBInputStream ( Reader in)

Definition at line 129 of file XMLUtils.cc.

129  :
130  reader(reader)
131 {
132 }
lhef::CBInputStream::~CBInputStream ( )
virtual

Definition at line 134 of file XMLUtils.cc.

135 {
136 }

Member Function Documentation

virtual XMLFilePos lhef::CBInputStream::curPos ( ) const
inlineoverridevirtual

Definition at line 141 of file XMLUtils.h.

References findQualityFiles::size.

141 { return pos; }
unsigned int pos
Definition: XMLUtils.h:151
virtual const XMLCh* lhef::CBInputStream::getContentType ( ) const
inlineoverridevirtual

Definition at line 146 of file XMLUtils.h.

146 { return 0; }
XMLSize_t lhef::CBInputStream::readBytes ( XMLByte *const  buf,
const XMLSize_t  size 
)
overridevirtual

Definition at line 138 of file XMLUtils.cc.

References buffer, lhef::CBInputStream::Reader::data(), and reader.

140 {
141  char *rawBuf = reinterpret_cast<char*>(buf);
142  unsigned int bytes = size * sizeof(XMLByte);
143  unsigned int read = 0;
144 
145  while(read < bytes) {
146  if (buffer.empty()) {
147  buffer = reader.data();
148  if (buffer.empty())
149  break;
150  }
151 
152  unsigned int len = buffer.length();
153  unsigned int rem = bytes - read;
154  if (rem < len) {
155  std::memcpy(rawBuf + read, buffer.c_str(), rem);
156  buffer.erase(0, rem);
157  read += rem;
158  break;
159  }
160 
161  std::memcpy(rawBuf + read, buffer.c_str(), len);
162  buffer.clear();
163  read += len;
164  }
165 
166  read /= sizeof(XMLByte);
167  pos += read;
168 
169  return read;
170 }
size
Write out results.
std::string buffer
Definition: XMLUtils.h:150
virtual const std::string & data()=0

Member Data Documentation

std::string lhef::CBInputStream::buffer
private

Definition at line 150 of file XMLUtils.h.

Referenced by readBytes().

unsigned int lhef::CBInputStream::pos
private
Reader& lhef::CBInputStream::reader
private

Definition at line 149 of file XMLUtils.h.

Referenced by readBytes().