List of all members.
Public Member Functions |
| buffer (std::ostream &a_out, bool a_byte_swap, uint32 a_size, char *a_buffer, uint32 a_klen, bool a_verbose) |
virtual | ~buffer () |
void | set_offset (unsigned int a_off) |
uint32 | length () const |
uint32 | size () const |
bool | read_object (ifac &a_fac, const ifac::args &a_args, iro *&a_obj) |
bool | read_version (short &a_version) |
bool | read_version (short &a_version, uint32 &a_start_pos, uint32 &a_byte_count) |
bool | check_byte_count (uint32 a_start_pos, uint32 a_byte_count, const std::string &a_store_cls) |
Protected Member Functions |
| buffer (const buffer &a_from) |
buffer & | operator= (const buffer &) |
bool | read_class_tag (std::string &a_class) |
bool | read_class (std::string &a_class, uint32 &a_bcnt, bool &a_is_ref) |
bool | read_string (char *a_string, uint32 a_max) |
Static Protected Member Functions |
static uint32 | kNullTag () |
static uint32 | kByteCountMask () |
static uint32 | kNewClassTag () |
static uint32 | kClassMask () |
static uint32 | kMapOffset () |
static short | kByteCountVMask () |
static std::string | sout (const std::string &a_string) |
Protected Attributes |
bool | m_byte_swap |
bool | m_verbose |
uint32 | m_size |
char * | m_buffer |
char * | m_pos |
uint32 | m_klen |
Detailed Description
Definition at line 22 of file buffer.
Constructor & Destructor Documentation
inlib::rroot::buffer::buffer |
( |
std::ostream & |
a_out, |
|
|
bool |
a_byte_swap, |
|
|
uint32 |
a_size, |
|
|
char * |
a_buffer, |
|
|
uint32 |
a_klen, |
|
|
bool |
a_verbose |
|
) |
| [inline] |
virtual inlib::rroot::buffer::~buffer |
( |
| ) |
[inline, virtual] |
Definition at line 42 of file buffer.
{
#ifdef INLIB_MEM
mem::decrement(s_class().c_str());
#endif
}
inlib::rroot::buffer::buffer |
( |
const buffer & |
a_from | ) |
[inline, protected] |
Definition at line 48 of file buffer.
: rbuf(a_from.m_out,a_from.m_byte_swap,0,m_pos)
,m_byte_swap(a_from.m_byte_swap)
{
#ifdef INLIB_MEM
mem::increment(s_class().c_str());
#endif
}
Member Function Documentation
bool inlib::rroot::buffer::check_byte_count |
( |
uint32 |
a_start_pos, |
|
|
uint32 |
a_byte_count, |
|
|
const std::string & |
a_store_cls |
|
) |
| [inline] |
Definition at line 381 of file buffer.
{
if(!a_byte_count) return true;
unsigned long len = a_start_pos + a_byte_count + sizeof(unsigned int);
unsigned long diff = m_pos-m_buffer;
if(diff==len) return true;
if(diff<len) {
m_out << "inlib::rroot::buffer::check_byte_count :"
<< " object of class " << sout(a_store_cls)
<< " read too few bytes ("
<< long2s(len-diff) << " missing)."
<< std::endl;
}
if(diff>len) {
m_out << "inlib::rroot::buffer::check_byte_count :"
<< " object of class " << sout(a_store_cls)
<< " read too many bytes ("
<< long2s(diff-len) << " in excess)." << std::endl;
}
m_out << "inlib::rroot::buffer::check_byte_count :"
<< " " << sout(a_store_cls)
<< " streamer not in sync with data on file, fix streamer."
<< std::endl;
m_pos = m_buffer+len;
return false;
}
static uint32 inlib::rroot::buffer::kByteCountMask |
( |
| ) |
[inline, static, protected] |
static short inlib::rroot::buffer::kByteCountVMask |
( |
| ) |
[inline, static, protected] |
static uint32 inlib::rroot::buffer::kClassMask |
( |
| ) |
[inline, static, protected] |
static uint32 inlib::rroot::buffer::kMapOffset |
( |
| ) |
[inline, static, protected] |
static uint32 inlib::rroot::buffer::kNewClassTag |
( |
| ) |
[inline, static, protected] |
static uint32 inlib::rroot::buffer::kNullTag |
( |
| ) |
[inline, static, protected] |
uint32 inlib::rroot::buffer::length |
( |
| ) |
const [inline] |
buffer& inlib::rroot::buffer::operator= |
( |
const buffer & |
| ) |
[inline, protected] |
bool inlib::rroot::buffer::read_class |
( |
std::string & |
a_class, |
|
|
uint32 & |
a_bcnt, |
|
|
bool & |
a_is_ref |
|
) |
| [inline, protected] |
Definition at line 122 of file buffer.
{
a_class.clear();
a_bcnt = 0;
a_is_ref = false;
uint32 fVersion = 0;
uint32 first_int = 0;
if(!rbuf::read(first_int)) return false;
if(m_verbose) {
m_out << "inlib::rroot::read_class :"
<< " first_int " << tosx(first_int)
<< std::endl;
}
if(first_int==kNullTag()) {
if(m_verbose) {
m_out << "inlib::rroot::read_class :"
<< " first_int is kNullTag."
<< std::endl;
}
a_bcnt = 0;
return true;
} else if(first_int & kByteCountMask()) {
if(m_verbose) {
m_out << "inlib::rroot::read_class :"
<< " first_int & kByteCountMask."
<< std::endl;
}
uint32 bef_tag = m_pos-m_buffer;
fVersion = 1;
std::string scls;
if(!read_class_tag(scls)) return false;
if(scls.empty()) {
m_out << "inlib::rroot::buffer::read_class :"
<< " read_class_tag did not find a class name."
<< std::endl;
return false;
}
a_class = scls;
a_bcnt = (first_int & ~kByteCountMask());
if(m_verbose) {
m_out << "inlib::rroot::read_class :"
<< " kNewClassTag : read class name " << sout(a_class)
<< " a_bcnt " << a_bcnt
<< " bef_tag " << bef_tag
<< "." << std::endl;
}
return true;
} else {
if(m_verbose) {
m_out << "inlib::rroot::read_class :"
<< " first_int " << tosx(first_int)
<< ". first_int is position toward object."
<< std::endl;
}
a_bcnt = first_int;
a_is_ref = true;
a_class.clear();
return true;
}
return false;
}
bool inlib::rroot::buffer::read_class_tag |
( |
std::string & |
a_class | ) |
[inline, protected] |
bool inlib::rroot::buffer::read_object |
( |
ifac & |
a_fac, |
|
|
const ifac::args & |
a_args, |
|
|
iro *& |
a_obj |
|
) |
| [inline] |
Definition at line 207 of file buffer.
{
a_obj = 0;
uint32 startpos = (uint32)(m_pos-m_buffer);
uint32 bcnt;
std::string sclass;
bool is_ref;
if(!read_class(sclass,bcnt,is_ref)) {
m_out << "inlib::rroot::buffer::read_object :"
<< " can't read class." << std::endl;
return false;
}
if(m_verbose) {
m_out << "inlib::rroot::buffer::read_object :"
<< " class " << sout(sclass)
<< " bcnt " << bcnt
<< std::endl;
}
if(is_ref) {
{char* old_pos = m_pos;
unsigned int obj_offset = bcnt;
obj_offset -= kMapOffset();
obj_offset -= m_klen;
m_pos = m_buffer + obj_offset;
uint32 first_int;
if(!rbuf::read(first_int)) return false;
if(first_int & kByteCountMask()) {
std::string scls;
if(!read_class_tag(scls)) return false;
if(scls.empty()) {
m_out << "inlib::rroot::buffer::read_object :"
<< " read_class_tag did not find a class name."
<< std::endl;
}
} else {
m_out << "inlib::rroot::buffer::read_object :"
<< " zzz"
<< std::endl;
}
m_pos = old_pos;}
m_pos = m_buffer+startpos+sizeof(unsigned int);
} else {
if(sclass.empty()) {
m_pos = m_buffer+startpos+bcnt+sizeof(unsigned int);
} else {
iro* obj = a_fac.create(sclass,a_args);
if(!obj) return false;
if(!obj->stream(*this)) {
m_pos = m_buffer+startpos+bcnt+sizeof(unsigned int);
delete obj;
return false;
}
if(!check_byte_count(startpos,bcnt,sclass)) {
m_out << "inlib::rroot::buffer::read_object :"
<< " check_byte_count failed "
<< "for object of class "
<< sout(sclass) << "." << std::endl;
delete obj;
return false;
}
a_obj = obj;
}
}
if(m_verbose) {
m_out << "inlib::rroot::buffer::read_object :"
<< " end : "
<< std::endl;
}
return true;
}
bool inlib::rroot::buffer::read_string |
( |
char * |
a_string, |
|
|
uint32 |
a_max |
|
) |
| [inline, protected] |
Definition at line 416 of file buffer.
{
int nr = 0;
while (nr < int(a_max-1)) {
char ch;
if(!rbuf::read(ch)) return false;
if(ch == 0) break;
a_string[nr++] = ch;
}
a_string[nr] = 0;
return true;
}
bool inlib::rroot::buffer::read_version |
( |
short & |
a_version | ) |
[inline] |
bool inlib::rroot::buffer::read_version |
( |
short & |
a_version, |
|
|
uint32 & |
a_start_pos, |
|
|
uint32 & |
a_byte_count |
|
) |
| [inline] |
void inlib::rroot::buffer::set_offset |
( |
unsigned int |
a_off | ) |
[inline] |
uint32 inlib::rroot::buffer::size |
( |
| ) |
const [inline] |
static std::string inlib::rroot::buffer::sout |
( |
const std::string & |
a_string | ) |
[inline, static, protected] |
Definition at line 435 of file buffer.
{
return std::string("\"")+a_string+"\"";
}
Member Data Documentation
The documentation for this class was generated from the following file:
- /Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/rroot/buffer