test
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 127 of file XMLUtils.h.

Member Typedef Documentation

Definition at line 135 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 unsigned int lhef::CBInputStream::curPos ( ) const
inlinevirtual

Definition at line 140 of file XMLUtils.h.

References pos.

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

Definition at line 138 of file XMLUtils.cc.

References buffer, lhef::CBInputStream::Reader::data(), pos, SiPixelLorentzAngle_cfi::read, 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 }
std::string buffer
Definition: XMLUtils.h:147
virtual const std::string & data()=0
unsigned int pos
Definition: XMLUtils.h:148
tuple size
Write out results.

Member Data Documentation

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

Definition at line 147 of file XMLUtils.h.

Referenced by readBytes().

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

Definition at line 146 of file XMLUtils.h.

Referenced by readBytes().