BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
FileNameStrings Class Reference

#include <RawFileUtil.h>

Public Member Functions

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

Friends

raw_ifstreamoperator>> (raw_ifstream &is, FileNameStrings &record)
std::ofstream & operator<< (std::ofstream &os, FileNameStrings &record)
raw_ifstreamoperator>> (raw_ifstream &is, FileNameStrings &record)
std::ofstream & operator<< (std::ofstream &os, FileNameStrings &record)
raw_ifstreamoperator>> (raw_ifstream &is, FileNameStrings &record)
std::ofstream & operator<< (std::ofstream &os, FileNameStrings &record)

Detailed Description

Definition at line 64 of file Event/RawFile/include/RawFile/RawFileUtil.h.

Constructor & Destructor Documentation

◆ FileNameStrings() [1/3]

FileNameStrings::FileNameStrings ( )

Definition at line 273 of file RawFileUtil.cxx.

273 {
274 m_record.marker = 0x1234aabb;
275 m_record.length1 = 4;
276 m_record.length2 = 7;
277 m_appName = "BOSS";
278 m_usrTag = "offline";
279}

Referenced by operator<<, and operator>>.

◆ FileNameStrings() [2/3]

FileNameStrings::FileNameStrings ( )

◆ FileNameStrings() [3/3]

FileNameStrings::FileNameStrings ( )

Member Function Documentation

◆ dump() [1/3]

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

Definition at line 328 of file RawFileUtil.cxx.

328 {
329 os << "[RawFile] FileNameStrings:" << std::endl
330 << std::hex << "[RawFile] \tmarker : 0x" << m_record.marker << std::endl
331 << "[RawFile] \tAppName length : 0x" << m_record.length1 << std::endl
332 << "[RawFile] \tAppName : " << m_appName << std::endl
333 << "[RawFile] \tUsrTag length : 0x" << m_record.length2 << std::endl
334 << "[RawFile] \tUsrTag : " << m_usrTag << std::dec << std::endl;
335}

◆ dump() [2/3]

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

◆ dump() [3/3]

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

◆ gerAppName() [1/3]

const std::string & FileNameStrings::gerAppName ( ) const
inline

Definition at line 73 of file Event/RawFile/include/RawFile/RawFileUtil.h.

73{ return m_appName; }

◆ gerAppName() [2/3]

const std::string & FileNameStrings::gerAppName ( ) const
inline

Definition at line 73 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

73{ return m_appName; }

◆ gerAppName() [3/3]

const std::string & FileNameStrings::gerAppName ( ) const
inline

Definition at line 73 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

73{ return m_appName; }

◆ gerUsrTag() [1/3]

const std::string & FileNameStrings::gerUsrTag ( ) const
inline

Definition at line 74 of file Event/RawFile/include/RawFile/RawFileUtil.h.

74{ return m_usrTag; }

◆ gerUsrTag() [2/3]

const std::string & FileNameStrings::gerUsrTag ( ) const
inline

Definition at line 74 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

74{ return m_usrTag; }

◆ gerUsrTag() [3/3]

const std::string & FileNameStrings::gerUsrTag ( ) const
inline

Definition at line 74 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

74{ return m_usrTag; }

◆ getRecord() [1/3]

const file_name_strings & FileNameStrings::getRecord ( ) const
inline

Definition at line 71 of file Event/RawFile/include/RawFile/RawFileUtil.h.

71{ return m_record; }

◆ getRecord() [2/3]

const file_name_strings & FileNameStrings::getRecord ( ) const
inline

Definition at line 71 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

71{ return m_record; }

◆ getRecord() [3/3]

const file_name_strings & FileNameStrings::getRecord ( ) const
inline

Definition at line 71 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

71{ return m_record; }

◆ operator<< [1/3]

std::ofstream & operator<< ( std::ofstream & os,
FileNameStrings & record )
friend

Definition at line 210 of file RawFileUtil.cxx.

210 {
211 // write data block
212 os.write( (char*)( &record.m_record ), sizeof( uint32_t ) * 2 );
213 uint32_t sizebyte = record.m_record.length1;
214 uint32_t sizeword = ( sizebyte + 3 ) / 4;
215 os.write( record.m_appName.c_str(), sizeword * 4 );
216 os.write( (char*)( &record.m_record.length2 ), sizeof( uint32_t ) );
217 sizebyte = record.m_record.length2;
218 sizeword = ( sizebyte + 3 ) / 4;
219 os.write( record.m_usrTag.c_str(), sizeword * 4 );
220 if ( os.fail() )
221 {
222 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
223 throw FailedToWrite( "FileNameStrings" );
224 }
225 return os;
226}

◆ operator<< [2/3]

std::ofstream & operator<< ( std::ofstream & os,
FileNameStrings & record )
friend

Definition at line 210 of file RawFileUtil.cxx.

210 {
211 // write data block
212 os.write( (char*)( &record.m_record ), sizeof( uint32_t ) * 2 );
213 uint32_t sizebyte = record.m_record.length1;
214 uint32_t sizeword = ( sizebyte + 3 ) / 4;
215 os.write( record.m_appName.c_str(), sizeword * 4 );
216 os.write( (char*)( &record.m_record.length2 ), sizeof( uint32_t ) );
217 sizebyte = record.m_record.length2;
218 sizeword = ( sizebyte + 3 ) / 4;
219 os.write( record.m_usrTag.c_str(), sizeword * 4 );
220 if ( os.fail() )
221 {
222 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
223 throw FailedToWrite( "FileNameStrings" );
224 }
225 return os;
226}

◆ operator<< [3/3]

std::ofstream & operator<< ( std::ofstream & os,
FileNameStrings & record )
friend

Definition at line 210 of file RawFileUtil.cxx.

210 {
211 // write data block
212 os.write( (char*)( &record.m_record ), sizeof( uint32_t ) * 2 );
213 uint32_t sizebyte = record.m_record.length1;
214 uint32_t sizeword = ( sizebyte + 3 ) / 4;
215 os.write( record.m_appName.c_str(), sizeword * 4 );
216 os.write( (char*)( &record.m_record.length2 ), sizeof( uint32_t ) );
217 sizebyte = record.m_record.length2;
218 sizeword = ( sizebyte + 3 ) / 4;
219 os.write( record.m_usrTag.c_str(), sizeword * 4 );
220 if ( os.fail() )
221 {
222 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
223 throw FailedToWrite( "FileNameStrings" );
224 }
225 return os;
226}

◆ operator>> [1/3]

raw_ifstream & operator>> ( raw_ifstream & is,
FileNameStrings & record )
friend

Definition at line 31 of file RawFileUtil.cxx.

31 {
32 // read marker
33 if ( is.read( (char*)( &record.m_record.marker ), sizeof( uint32_t ) ).fail() )
34 {
35 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
36 throw BadInputStream( "FileNameStrings::marker" );
37 }
38
39 // marker validation
40 if ( record.m_record.marker != 0x1234aabb )
41 {
42 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
43 throw WrongMarker( 0x1234aabb, record.m_record.marker );
44 }
45
46 // read length and strings
47 if ( is.read( (char*)( &record.m_record.length1 ), sizeof( uint32_t ) ).fail() )
48 {
49 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
50 throw BadInputStream( "FileNameStrings::length1" );
51 }
52
53 uint32_t length1_word = ( record.m_record.length1 + 3 ) / 4;
54 char* appName = new char[length1_word * 4 + 1];
55 if ( is.read( appName, length1_word * 4 ).fail() )
56 {
57 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
58 throw BadInputStream( "FileNameStrings::appName" );
59 }
60 appName[length1_word * 4] = '\0';
61 record.m_appName = appName;
62 delete[] appName;
63
64 if ( is.read( (char*)( &record.m_record.length2 ), sizeof( uint32_t ) ).fail() )
65 {
66 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
67 throw BadInputStream( "FileNameStrings::length2" );
68 }
69
70 uint32_t length2_word = ( record.m_record.length2 + 3 ) / 4;
71 char* usrTag = new char[length2_word * 4 + 1];
72 if ( is.read( usrTag, length2_word * 4 ).fail() )
73 {
74 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
75 throw BadInputStream( "FileNameStrings::usrTag" );
76 }
77 usrTag[length2_word * 4] = '\0';
78 record.m_usrTag = usrTag;
79 delete[] usrTag;
80
81 return is;
82}

◆ operator>> [2/3]

raw_ifstream & operator>> ( raw_ifstream & is,
FileNameStrings & record )
friend

Definition at line 31 of file RawFileUtil.cxx.

31 {
32 // read marker
33 if ( is.read( (char*)( &record.m_record.marker ), sizeof( uint32_t ) ).fail() )
34 {
35 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
36 throw BadInputStream( "FileNameStrings::marker" );
37 }
38
39 // marker validation
40 if ( record.m_record.marker != 0x1234aabb )
41 {
42 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
43 throw WrongMarker( 0x1234aabb, record.m_record.marker );
44 }
45
46 // read length and strings
47 if ( is.read( (char*)( &record.m_record.length1 ), sizeof( uint32_t ) ).fail() )
48 {
49 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
50 throw BadInputStream( "FileNameStrings::length1" );
51 }
52
53 uint32_t length1_word = ( record.m_record.length1 + 3 ) / 4;
54 char* appName = new char[length1_word * 4 + 1];
55 if ( is.read( appName, length1_word * 4 ).fail() )
56 {
57 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
58 throw BadInputStream( "FileNameStrings::appName" );
59 }
60 appName[length1_word * 4] = '\0';
61 record.m_appName = appName;
62 delete[] appName;
63
64 if ( is.read( (char*)( &record.m_record.length2 ), sizeof( uint32_t ) ).fail() )
65 {
66 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
67 throw BadInputStream( "FileNameStrings::length2" );
68 }
69
70 uint32_t length2_word = ( record.m_record.length2 + 3 ) / 4;
71 char* usrTag = new char[length2_word * 4 + 1];
72 if ( is.read( usrTag, length2_word * 4 ).fail() )
73 {
74 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
75 throw BadInputStream( "FileNameStrings::usrTag" );
76 }
77 usrTag[length2_word * 4] = '\0';
78 record.m_usrTag = usrTag;
79 delete[] usrTag;
80
81 return is;
82}

◆ operator>> [3/3]

raw_ifstream & operator>> ( raw_ifstream & is,
FileNameStrings & record )
friend

Definition at line 31 of file RawFileUtil.cxx.

31 {
32 // read marker
33 if ( is.read( (char*)( &record.m_record.marker ), sizeof( uint32_t ) ).fail() )
34 {
35 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
36 throw BadInputStream( "FileNameStrings::marker" );
37 }
38
39 // marker validation
40 if ( record.m_record.marker != 0x1234aabb )
41 {
42 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
43 throw WrongMarker( 0x1234aabb, record.m_record.marker );
44 }
45
46 // read length and strings
47 if ( is.read( (char*)( &record.m_record.length1 ), sizeof( uint32_t ) ).fail() )
48 {
49 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
50 throw BadInputStream( "FileNameStrings::length1" );
51 }
52
53 uint32_t length1_word = ( record.m_record.length1 + 3 ) / 4;
54 char* appName = new char[length1_word * 4 + 1];
55 if ( is.read( appName, length1_word * 4 ).fail() )
56 {
57 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
58 throw BadInputStream( "FileNameStrings::appName" );
59 }
60 appName[length1_word * 4] = '\0';
61 record.m_appName = appName;
62 delete[] appName;
63
64 if ( is.read( (char*)( &record.m_record.length2 ), sizeof( uint32_t ) ).fail() )
65 {
66 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
67 throw BadInputStream( "FileNameStrings::length2" );
68 }
69
70 uint32_t length2_word = ( record.m_record.length2 + 3 ) / 4;
71 char* usrTag = new char[length2_word * 4 + 1];
72 if ( is.read( usrTag, length2_word * 4 ).fail() )
73 {
74 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
75 throw BadInputStream( "FileNameStrings::usrTag" );
76 }
77 usrTag[length2_word * 4] = '\0';
78 record.m_usrTag = usrTag;
79 delete[] usrTag;
80
81 return is;
82}

The documentation for this class was generated from the following files: