Public Member Functions | Public Attributes | Friends

fio_RelFileHeader_t Struct Reference
[Classes for large file i/o, relative file, and DataBase]

The relative file header must stay the same size almost for ever. More...

#include <fio_RelFile.h>

List of all members.

Public Member Functions

 fio_RelFileHeader_t ()
 fio_RelFileHeader_t (fio_File &file)
 fio_RelFileHeader_t (string a_identification, UInt16_t a_fileID, UInt16_t a_recordStructVersion, UInt16_t a_recordSize, UInt16_t a_loUVHeaderLen, UInt16_t a_numOfDifVector, UInt16_t a_smallestVectorSize)
 ~fio_RelFileHeader_t ()
bool To64Bit ()
 Convert 32 bit variant of structure data to 64 bit variant, returns true on success, false otherwise.

Public Attributes

char identification [fio_FH_IDENTIFICATION_LEN_d]
 All follow fields until iniTime has to match to proper work.
UInt16_t fileID
UInt16_t recordStructVersion
UInt16_t recordSize
UInt16_t loUVHeaderLen
UInt16_t numOfDifVector
UInt16_t smallestVectorSize
UInt16_t relFileHeaderLen
UInt16_t byteOrder
ivd_Time32_t initTime
UInt16_t headerStructVersion
 There is reserved some space in case of some changes, that could be chacked in future versions.
 log_CLASSID_m

Friends

ostream & operator<< (ostream &a_os, fio_RelFileHeader_t &a_rfh)

Detailed Description

The relative file header must stay the same size almost for ever.

See picture about relative file structure

IVD-RelativeFileStructure.gif

Definition at line 68 of file fio_RelFile.h.


Constructor & Destructor Documentation

fio_RelFileHeader_t::fio_RelFileHeader_t (  )  [inline]

Definition at line 69 of file fio_RelFile.h.

{};

fio_RelFileHeader_t::fio_RelFileHeader_t ( fio_File file  ) 

Definition at line 80 of file fio_RelFile.cpp.

References log_FUNC_m, cmn_File::ReadF(), and cmn_File::SeekF().

                                                       {
    log_FUNC_m(fio_RelFileHeader_t);

    file.SeekF(0);
    file.ReadF(this, sizeof(*this));
}

Here is the call graph for this function:

fio_RelFileHeader_t::fio_RelFileHeader_t ( string  a_identification,
UInt16_t  a_fileID,
UInt16_t  a_recordStructVersion,
UInt16_t  a_recordSize,
UInt16_t  a_loUVHeaderLen,
UInt16_t  a_numOfDifVector,
UInt16_t  a_smallestVectorSize 
)

Definition at line 87 of file fio_RelFile.cpp.

References byteOrder, c_fio_headerStructVersion, c_fio_maxRelFileHeadLen, fileID, fio_FH_IDENTIFICATION_LEN_d, cmn_Time::GetTime_t(), headerStructVersion, identification, ie_RECORD_TOO_LARGE, initTime, ivd_Error, log_FUNC_m, loUVHeaderLen, numOfDifVector, recordSize, recordStructVersion, relFileHeaderLen, and smallestVectorSize.

{
    log_FUNC_m(fio_RelFileHeader_t);
// TO DO
    if ( a_identification.length() >= fio_FH_IDENTIFICATION_LEN_d) {
        strncpy(identification, a_identification.data(), (unsigned int)fio_FH_IDENTIFICATION_LEN_d);
    }
    else {
        strncpy(identification, a_identification.data(), a_identification.length());
        char *p;
        char *q = identification + fio_FH_IDENTIFICATION_LEN_d;
        for (p = identification + a_identification.length(); p < q; p++) {
            *p = 0;
        }
    }

    fileID             = a_fileID;
    recordStructVersion= a_recordStructVersion;
    recordSize         = a_recordSize;
    loUVHeaderLen      = a_loUVHeaderLen;
    numOfDifVector     = a_numOfDifVector;
    smallestVectorSize = a_smallestVectorSize;

    if ( sizeof(fio_RelFileHeader_t) > c_fio_maxRelFileHeadLen ) {
        throw ivd_Error(ie_RECORD_TOO_LARGE,
            "Relative file header record exceed max size.", true);
    }
    relFileHeaderLen   = sizeof(fio_RelFileHeader_t);
    byteOrder          = ibo_ENDIAN_LITTLE;
    cmn_Time time;
    initTime           = time.GetTime_t();
    headerStructVersion= c_fio_headerStructVersion;
}

Here is the call graph for this function:

fio_RelFileHeader_t::~fio_RelFileHeader_t (  )  [inline]

Definition at line 79 of file fio_RelFile.h.

{};


Member Function Documentation

bool fio_RelFileHeader_t::To64Bit (  ) 

Convert 32 bit variant of structure data to 64 bit variant, returns true on success, false otherwise.

Definition at line 130 of file fio_RelFile.cpp.

References fio_HEADER_STRUCT_VERSION_d, headerStructVersion, fio_RelFileHeader32_t::headerStructVersion, fio_RelFileHeader32_t::initTime, initTime, log_FUNC_m, and relFileHeaderLen.

Referenced by Update().

                                  {
    log_FUNC_m(To64Bit);

    if(relFileHeaderLen != sizeof(*this) && relFileHeaderLen == sizeof(fio_RelFileHeader32_t)) {
        // Length okay, try to convert header
        fio_RelFileHeader32_t tmp;
        memcpy(&tmp, this, sizeof(tmp));
        // Last sanity check
        if(tmp.headerStructVersion == fio_HEADER_STRUCT_VERSION_d) {
            relFileHeaderLen = sizeof(*this);
            initTime = tmp.initTime;
            headerStructVersion = tmp.headerStructVersion;
            return true;
        }
    }

    return false;
}

Here is the caller graph for this function:


Friends And Related Function Documentation

ostream& operator<< ( ostream &  a_os,
fio_RelFileHeader_t a_rfh 
) [friend]

Definition at line 151 of file fio_RelFile.cpp.

                                                                {
//    string pref(a_et.Prefix, 2);
    cmn_Time t(a_rfh.initTime);
    a_os << "\n### Relative file header ###\n"
    << "identification:\n" << cmn_HexDump(&a_rfh.identification, fio_FH_IDENTIFICATION_LEN_d, 32, true)
    << "file ID        = " << a_rfh.fileID  << '\n'           // database unique
    << "rec struct ver = " << a_rfh.recordStructVersion << '\n' // version of record structure
    << "REC SIZE       = " << a_rfh.recordSize << '\n'
    << "UV header len  = " << a_rfh.loUVHeaderLen << '\n'       // size of pointers to records
    << "num of dif vec = " << a_rfh.numOfDifVector << '\n'
    << "small vec size = " << a_rfh.smallestVectorSize << '\n'
    << "relF hdr len   = " << a_rfh.relFileHeaderLen << '\n'
    << "byte order     = " << a_rfh.byteOrder << '\n'          // big or little endian
    << "creation time  = " << t.Time2YMDhms() << '\n'           // time of initialization of header
    << "hdr struct ver = " << a_rfh.headerStructVersion << '\n';//
    return a_os;
}


Member Data Documentation

Definition at line 98 of file fio_RelFile.h.

Referenced by fio_RelFile::fio_RelFile(), fio_RelFileHeader_t(), and operator<<().

Definition at line 91 of file fio_RelFile.h.

Referenced by fio_RelFile::fio_RelFile(), fio_RelFileHeader_t(), and operator<<().

There is reserved some space in case of some changes, that could be chacked in future versions.

Definition at line 105 of file fio_RelFile.h.

Referenced by fio_RelFile::fio_RelFile(), fio_RelFileHeader_t(), operator<<(), and To64Bit().

char fio_RelFileHeader_t::identification[fio_FH_IDENTIFICATION_LEN_d]

All follow fields until iniTime has to match to proper work.

Definition at line 89 of file fio_RelFile.h.

Referenced by fio_RelFile::fio_RelFile(), fio_RelFileHeader_t(), and operator<<().

Definition at line 100 of file fio_RelFile.h.

Referenced by fio_RelFileHeader_t(), operator<<(), and To64Bit().

Definition at line 107 of file fio_RelFile.h.

Definition at line 94 of file fio_RelFile.h.

Referenced by fio_RelFile::fio_RelFile(), fio_RelFileHeader_t(), and operator<<().

Definition at line 95 of file fio_RelFile.h.

Referenced by fio_RelFile::fio_RelFile(), fio_RelFileHeader_t(), and operator<<().

Definition at line 93 of file fio_RelFile.h.

Referenced by fio_RelFile::fio_RelFile(), fio_RelFileHeader_t(), and operator<<().

Definition at line 96 of file fio_RelFile.h.

Referenced by fio_RelFile::fio_RelFile(), fio_RelFileHeader_t(), and operator<<().


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