Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FileNameStrings Class Reference

#include <RawFileUtil.h>

List of all members.

Public Member Functions

void dump (std::ostream &os=std::cout) const
void dump (std::ostream &os=std::cout) const
 FileNameStrings ()
 FileNameStrings ()
const std::string & gerAppName () const
const std::string & gerAppName () const
const std::string & gerUsrTag () const
const std::string & gerUsrTag () const
const file_name_stringsgetRecord () const
const file_name_stringsgetRecord () const

Private Attributes

std::string m_appName
file_name_strings m_record
std::string m_usrTag

Friends

raw_ofstreamoperator<< (raw_ofstream &os, FileNameStrings &record)
raw_ofstreamoperator<< (raw_ofstream &os, FileNameStrings &record)
raw_ifstreamoperator>> (raw_ifstream &is, FileNameStrings &record)
raw_ifstreamoperator>> (raw_ifstream &is, FileNameStrings &record)


Constructor & Destructor Documentation

FileNameStrings::FileNameStrings  ) 
 

00246 {
00247    m_record.marker   = 0x1234aabb;
00248    m_record.length1  = 4;
00249    m_record.length2  = 7;
00250    m_appName         = "BOSS";
00251    m_usrTag          = "offline";
00252 }

FileNameStrings::FileNameStrings  ) 
 


Member Function Documentation

void FileNameStrings::dump std::ostream os = std::cout  )  const
 

void FileNameStrings::dump std::ostream os = std::cout  )  const
 

00304                                                {
00305   os << "[RawFile] FileNameStrings:" << std::endl << std::hex
00306      << "[RawFile] \tmarker               : 0x" << m_record.marker << std::endl
00307      << "[RawFile] \tAppName length       : 0x" << m_record.length1 << std::endl
00308      << "[RawFile] \tAppName              : " << m_appName << std::endl
00309      << "[RawFile] \tUsrTag  length       : 0x" << m_record.length2 << std::endl
00310      << "[RawFile] \tUsrTag               : " << m_usrTag
00311      << std::dec << std::endl;
00312 }

const std::string& FileNameStrings::gerAppName  )  const [inline]
 

00073 { return m_appName; }

const std::string& FileNameStrings::gerAppName  )  const [inline]
 

00073 { return m_appName; }

const std::string& FileNameStrings::gerUsrTag  )  const [inline]
 

00074 { return m_usrTag; }

const std::string& FileNameStrings::gerUsrTag  )  const [inline]
 

00074 { return m_usrTag; }

const file_name_strings& FileNameStrings::getRecord  )  const [inline]
 

00071 { return m_record; }

const file_name_strings& FileNameStrings::getRecord  )  const [inline]
 

00071 { return m_record; }


Friends And Related Function Documentation

raw_ofstream& operator<< raw_ofstream os,
FileNameStrings record
[friend]
 

00185                                                                     {
00186   // write data block
00187   os.write((char*)(&record.m_record), sizeof(uint32_t)*2);
00188   uint32_t sizebyte = record.m_record.length1;
00189   uint32_t sizeword = (sizebyte+3)/4;
00190   os.write(record.m_appName.c_str(), sizeword*4);
00191   os.write((char*)(&record.m_record.length2), sizeof(uint32_t));
00192   sizebyte = record.m_record.length2;
00193   sizeword = (sizebyte+3)/4;
00194   os.write(record.m_usrTag.c_str(), sizeword*4);
00195   if ( os.fail() ) {
00196     std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
00197     throw FailedToWrite("FileNameStrings");
00198   }
00199   return os;
00200 }

raw_ofstream& operator<< raw_ofstream os,
FileNameStrings record
[friend]
 

00185                                                                     {
00186   // write data block
00187   os.write((char*)(&record.m_record), sizeof(uint32_t)*2);
00188   uint32_t sizebyte = record.m_record.length1;
00189   uint32_t sizeword = (sizebyte+3)/4;
00190   os.write(record.m_appName.c_str(), sizeword*4);
00191   os.write((char*)(&record.m_record.length2), sizeof(uint32_t));
00192   sizebyte = record.m_record.length2;
00193   sizeword = (sizebyte+3)/4;
00194   os.write(record.m_usrTag.c_str(), sizeword*4);
00195   if ( os.fail() ) {
00196     std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
00197     throw FailedToWrite("FileNameStrings");
00198   }
00199   return os;
00200 }

raw_ifstream& operator>> raw_ifstream is,
FileNameStrings record
[friend]
 

00028                                                                     {
00029   // read marker
00030   if (is.read((char*)(&record.m_record.marker), sizeof(uint32_t)).fail()) {
00031     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00032     throw BadInputStream("FileNameStrings::marker");
00033   }
00034 
00035   // marker validation
00036   if (record.m_record.marker != 0x1234aabb) {
00037     //std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
00038     throw WrongMarker(0x1234aabb, record.m_record.marker);
00039   }
00040 
00041   // read length and strings
00042   if (is.read((char*)(&record.m_record.length1), sizeof(uint32_t)).fail()) {
00043     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00044     throw BadInputStream("FileNameStrings::length1");
00045   }
00046 
00047   uint32_t length1_word = (record.m_record.length1 + 3) / 4;
00048   char* appName = new char[length1_word * 4 + 1];
00049   if (is.read(appName, length1_word*4).fail()) {
00050     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00051     throw BadInputStream("FileNameStrings::appName");
00052   }
00053   appName[record.m_record.length1] = '\0';
00054   record.m_appName = appName;
00055   delete[] appName;
00056 
00057   if (is.read((char*)(&record.m_record.length2), sizeof(uint32_t)).fail()) {
00058     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00059     throw BadInputStream("FileNameStrings::length2");
00060   }
00061 
00062   uint32_t length2_word = (record.m_record.length2 + 3) / 4;
00063   char* usrTag = new char[length2_word * 4 + 1];
00064   if (is.read(usrTag, length2_word*4).fail()) {
00065     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00066     throw BadInputStream("FileNameStrings::usrTag");
00067   }
00068   usrTag[record.m_record.length2] = '\0';
00069   record.m_usrTag = usrTag;
00070   delete[] usrTag;
00071 
00072   return is;
00073 }

raw_ifstream& operator>> raw_ifstream is,
FileNameStrings record
[friend]
 

00028                                                                     {
00029   // read marker
00030   if (is.read((char*)(&record.m_record.marker), sizeof(uint32_t)).fail()) {
00031     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00032     throw BadInputStream("FileNameStrings::marker");
00033   }
00034 
00035   // marker validation
00036   if (record.m_record.marker != 0x1234aabb) {
00037     //std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
00038     throw WrongMarker(0x1234aabb, record.m_record.marker);
00039   }
00040 
00041   // read length and strings
00042   if (is.read((char*)(&record.m_record.length1), sizeof(uint32_t)).fail()) {
00043     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00044     throw BadInputStream("FileNameStrings::length1");
00045   }
00046 
00047   uint32_t length1_word = (record.m_record.length1 + 3) / 4;
00048   char* appName = new char[length1_word * 4 + 1];
00049   if (is.read(appName, length1_word*4).fail()) {
00050     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00051     throw BadInputStream("FileNameStrings::appName");
00052   }
00053   appName[record.m_record.length1] = '\0';
00054   record.m_appName = appName;
00055   delete[] appName;
00056 
00057   if (is.read((char*)(&record.m_record.length2), sizeof(uint32_t)).fail()) {
00058     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00059     throw BadInputStream("FileNameStrings::length2");
00060   }
00061 
00062   uint32_t length2_word = (record.m_record.length2 + 3) / 4;
00063   char* usrTag = new char[length2_word * 4 + 1];
00064   if (is.read(usrTag, length2_word*4).fail()) {
00065     //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
00066     throw BadInputStream("FileNameStrings::usrTag");
00067   }
00068   usrTag[record.m_record.length2] = '\0';
00069   record.m_usrTag = usrTag;
00070   delete[] usrTag;
00071 
00072   return is;
00073 }


Member Data Documentation

std::string FileNameStrings::m_appName [private]
 

file_name_strings FileNameStrings::m_record [private]
 

std::string FileNameStrings::m_usrTag [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:15:14 2011 for BOSS6.5.5 by  doxygen 1.3.9.1