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

Member Typedef Documentation

Definition at line 133 of file XMLUtils.h.

Constructor & Destructor Documentation

lhef::CBInputStream::CBInputStream ( Reader in)

Definition at line 127 of file XMLUtils.cc.

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

Definition at line 132 of file XMLUtils.cc.

133 {
134 }

Member Function Documentation

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

Definition at line 138 of file XMLUtils.h.

References pos.

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

Definition at line 136 of file XMLUtils.cc.

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

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

Member Data Documentation

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

Definition at line 145 of file XMLUtils.h.

Referenced by readBytes().

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

Definition at line 144 of file XMLUtils.h.

Referenced by readBytes().