CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes

lhef::CBInputStream Class Reference

#include <XMLUtils.h>

List of all members.

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.

                                           :
        reader(reader)
{
}
lhef::CBInputStream::~CBInputStream ( ) [virtual]

Definition at line 132 of file XMLUtils.cc.

{
}

Member Function Documentation

virtual unsigned int lhef::CBInputStream::curPos ( ) const [inline, virtual]

Definition at line 138 of file XMLUtils.h.

References pos.

{ return pos; }
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.

{
        char *rawBuf = reinterpret_cast<char*>(buf);
        unsigned int bytes = size * sizeof(XMLByte);
        unsigned int read = 0;

        while(read < bytes) {
                if (buffer.empty()) {
                        buffer = reader.data();
                        if (buffer.empty())
                                break;
                }

                unsigned int len = buffer.length();
                unsigned int rem = bytes - read;
                if (rem < len) {
                        std::memcpy(rawBuf + read, buffer.c_str(), rem);
                        buffer.erase(0, rem);
                        read += rem;
                        break;
                }

                std::memcpy(rawBuf + read, buffer.c_str(), len);
                buffer.clear();
                read += len;
        }

        read /= sizeof(XMLByte);
        pos += read;

        return read;
}

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]

Definition at line 146 of file XMLUtils.h.

Referenced by curPos(), and readBytes().

Definition at line 144 of file XMLUtils.h.

Referenced by readBytes().