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)
 
XMLFilePos curPos () const override
 
const XMLCh * getContentType () const override
 
XMLSize_t readBytes (XMLByte *const buf, const XMLSize_t size) override
 
 ~CBInputStream () override
 

Private Attributes

std::string buffer
 
unsigned int pos
 
Readerreader
 

Detailed Description

Definition at line 129 of file XMLUtils.h.

Member Typedef Documentation

Definition at line 137 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 ( )
override

Definition at line 134 of file XMLUtils.cc.

135 {
136 }

Member Function Documentation

XMLFilePos lhef::CBInputStream::curPos ( ) const
inlineoverride

Definition at line 142 of file XMLUtils.h.

References findQualityFiles::size.

142 { return pos; }
unsigned int pos
Definition: XMLUtils.h:152
const XMLCh* lhef::CBInputStream::getContentType ( ) const
inlineoverride

Definition at line 147 of file XMLUtils.h.

147 { return nullptr; }
XMLSize_t lhef::CBInputStream::readBytes ( XMLByte *const  buf,
const XMLSize_t  size 
)
override

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:151
virtual const std::string & data()=0

Member Data Documentation

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

Definition at line 151 of file XMLUtils.h.

Referenced by readBytes().

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

Definition at line 150 of file XMLUtils.h.

Referenced by readBytes().