Back to index

enigmail  1.4.3
Public Member Functions | Static Public Member Functions | Private Member Functions
serializable< T > Class Template Reference

#include <elfxx.h>

Inheritance diagram for serializable< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 serializable ()
 serializable (const typename T::Type32 &p)
 serializable (const char *buf, size_t len, char ei_class, char ei_data)
 serializable (std::ifstream &file, char ei_class, char ei_data)
void serialize (std::ofstream &file, char ei_class, char ei_data)

Static Public Member Functions

static unsigned int size (char ei_class)

Private Member Functions

template<typename R >
void init (const char *buf, size_t len, char ei_data)

Detailed Description

template<typename T>
class serializable< T >

Definition at line 190 of file elfxx.h.


Constructor & Destructor Documentation

template<typename T>
serializable< T >::serializable ( ) [inline]

Definition at line 192 of file elfxx.h.

{};
template<typename T>
serializable< T >::serializable ( const typename T::Type32 &  p) [inline]

Definition at line 193 of file elfxx.h.

: T::Type32(p) {};
template<typename T>
serializable< T >::serializable ( const char *  buf,
size_t  len,
char  ei_class,
char  ei_data 
) [inline]

Definition at line 213 of file elfxx.h.

    {
        if (ei_class == ELFCLASS32) {
            init<typename T::Type32>(buf, len, ei_data);
            return;
        } else if (ei_class == ELFCLASS64) {
            init<typename T::Type64>(buf, len, ei_data);
            return;
        }
        throw std::runtime_error("Unsupported ELF class");
    }
template<typename T>
serializable< T >::serializable ( std::ifstream &  file,
char  ei_class,
char  ei_data 
) [inline]

Definition at line 225 of file elfxx.h.

    {
        if (ei_class == ELFCLASS32) {
            typename T::Type32 e;
            file.read((char *)&e, sizeof(e));
            if (ei_data == ELFDATA2LSB) {
                T::template swap<little_endian>(e, *this);
                return;
            } else if (ei_data == ELFDATA2MSB) {
                T::template swap<big_endian>(e, *this);
                return;
            }
        } else if (ei_class == ELFCLASS64) {
            typename T::Type64 e;
            file.read((char *)&e, sizeof(e));
            if (ei_data == ELFDATA2LSB) {
                T::template swap<little_endian>(e, *this);
                return;
            } else if (ei_data == ELFDATA2MSB) {
                T::template swap<big_endian>(e, *this);
                return;
            }
        }
        throw std::runtime_error("Unsupported ELF class or data encoding");
    }

Member Function Documentation

template<typename T>
template<typename R >
void serializable< T >::init ( const char *  buf,
size_t  len,
char  ei_data 
) [inline, private]

Definition at line 197 of file elfxx.h.

    {
        R e;
        assert(len <= sizeof(e));
        memcpy(&e, buf, sizeof(e));
        if (ei_data == ELFDATA2LSB) {
            T::template swap<little_endian>(e, *this);
            return;
        } else if (ei_data == ELFDATA2MSB) {
            T::template swap<big_endian>(e, *this);
            return;
        }
        throw std::runtime_error("Unsupported ELF data encoding");
    }
template<typename T>
void serializable< T >::serialize ( std::ofstream &  file,
char  ei_class,
char  ei_data 
) [inline]

Reimplemented in Elf_Ehdr.

Definition at line 251 of file elfxx.h.

    {
        if (ei_class == ELFCLASS32) {
            typename T::Type32 e;
            if (ei_data == ELFDATA2LSB) {
                T::template swap<little_endian>(*this, e);
                file.write((char *)&e, sizeof(e));
                return;
            } else if (ei_data == ELFDATA2MSB) {
                T::template swap<big_endian>(*this, e);
                file.write((char *)&e, sizeof(e));
                return;
            }
        } else if (ei_class == ELFCLASS64) {
            typename T::Type64 e;
            if (ei_data == ELFDATA2LSB) {
                T::template swap<little_endian>(*this, e);
                file.write((char *)&e, sizeof(e));
                return;
            } else if (ei_data == ELFDATA2MSB) {
                T::template swap<big_endian>(*this, e);
                file.write((char *)&e, sizeof(e));
                return;
            }
        }
        throw std::runtime_error("Unsupported ELF class or data encoding");
    }

Here is the caller graph for this function:

template<typename T>
static unsigned int serializable< T >::size ( char  ei_class) [inline, static]

Definition at line 279 of file elfxx.h.

    {
        if (ei_class == ELFCLASS32)
            return sizeof(typename T::Type32);
        else if (ei_class == ELFCLASS64)
            return sizeof(typename T::Type64);
        return 0;
    }

Here is the caller graph for this function:


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