CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 unsigned int curPos () const
 
virtual unsigned int readBytes (XMLByte *const buf, const unsigned int size)
 
virtual ~CBInputStream ()
 

Private Attributes

std::string buffer
 
unsigned int pos
 
Readerreader
 

Detailed Description

Definition at line 126 of file XMLUtils.h.

Member Typedef Documentation

Definition at line 134 of file XMLUtils.h.

Constructor & Destructor Documentation

lhef::CBInputStream::CBInputStream ( Reader in)

Definition at line 128 of file XMLUtils.cc.

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

Definition at line 133 of file XMLUtils.cc.

134 {
135 }

Member Function Documentation

virtual unsigned int lhef::CBInputStream::curPos ( ) const
inlinevirtual

Definition at line 139 of file XMLUtils.h.

References pos.

139 { return pos; }
unsigned int pos
Definition: XMLUtils.h:147
unsigned int lhef::CBInputStream::readBytes ( XMLByte *const  buf,
const unsigned int  size 
)
virtual

Definition at line 137 of file XMLUtils.cc.

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

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

Member Data Documentation

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

Definition at line 146 of file XMLUtils.h.

Referenced by readBytes().

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

Definition at line 145 of file XMLUtils.h.

Referenced by readBytes().