ddc
Public Types | Public Member Functions | Public Attributes | List of all members
ddcMMap< T > Class Template Reference

#include <ddcMMap.h>

Inheritance diagram for ddcMMap< T >:
Inheritance graph
[legend]
Collaboration diagram for ddcMMap< T >:
Collaboration graph
[legend]

Public Types

typedef T * iterator
 
typedef const T * const_iterator
 

Public Member Functions

 ddcMMap ()
 default constructor More...
 
 ddcMMap (const std::string &filename, int mode=O_RDONLY)
 
 ~ddcMMap ()
 default destructor calls close() More...
 
const std::string & filename () const
 returns the name of the currently mapped file, if any More...
 
size_t nbytes () const
 returns number of bytes mapped, or 0 More...
 
T * data () const
 returns a pointer to the mmap()ed file data, or NULL More...
 
size_t size () const
 returns the number of objects of type T mapped, or 0 More...
 
bool empty () const
 STL-esque wrapper for (nbytes()==0) More...
 
bool opened () const
 returns true iff m_data is non-NULL More...
 
 operator bool () const
 implicit typecast to bool More...
 
 operator T* () const
 implicit typecast to T* More...
 
T & operator[] (size_t idx) const
 indexing operator More...
 
ddcMMapopen (const std::string &filename, int mode=O_RDONLY)
 map a named file filename More...
 
void close ()
 unmap current file (if any) More...
 
iterator begin () const
 
iterator end () const
 

Public Attributes

std::string m_file
 underlying filename More...
 
size_t m_nbytes
 number of bytes mapped More...
 
T * m_data
 file data More...
 

Detailed Description

template<typename T = char>
class ddcMMap< T >

convenience wrapper for mapping entire files into virtual memory using mmap()

Member Typedef Documentation

◆ iterator

template<typename T = char>
typedef T* ddcMMap< T >::iterator

◆ const_iterator

template<typename T = char>
typedef const T* ddcMMap< T >::const_iterator

Constructor & Destructor Documentation

◆ ddcMMap() [1/2]

template<typename T = char>
ddcMMap< T >::ddcMMap ( )
inline

default constructor

◆ ddcMMap() [2/2]

template<typename T = char>
ddcMMap< T >::ddcMMap ( const std::string &  filename,
int  mode = O_RDONLY 
)
inline

◆ ~ddcMMap()

template<typename T = char>
ddcMMap< T >::~ddcMMap ( )
inline

default destructor calls close()

Member Function Documentation

◆ filename()

template<typename T = char>
const std::string& ddcMMap< T >::filename ( ) const
inline

returns the name of the currently mapped file, if any

Referenced by ddcVecFile< CIndexItem >::ensureVec(), ddcMMap< CIndexItem >::open(), ddcVecFile< CIndexItem >::open(), and ddcFileOrMMap::operator bool().

Here is the caller graph for this function:

◆ nbytes()

template<typename T = char>
size_t ddcMMap< T >::nbytes ( ) const
inline

returns number of bytes mapped, or 0

Referenced by ddcFileOrMMap::operator bool().

Here is the caller graph for this function:

◆ data()

template<typename T = char>
T* ddcMMap< T >::data ( ) const
inline

returns a pointer to the mmap()ed file data, or NULL

◆ size()

template<typename T = char>
size_t ddcMMap< T >::size ( ) const
inline

◆ empty()

template<typename T = char>
bool ddcMMap< T >::empty ( void  ) const
inline

STL-esque wrapper for (nbytes()==0)

Referenced by ddcVecFile< CIndexItem >::empty().

Here is the caller graph for this function:

◆ opened()

template<typename T = char>
bool ddcMMap< T >::opened ( ) const
inline

◆ operator bool()

template<typename T = char>
ddcMMap< T >::operator bool ( ) const
inline

implicit typecast to bool

◆ operator T*()

template<typename T = char>
ddcMMap< T >::operator T* ( ) const
inline

implicit typecast to T*

References ddcMMap< T >::m_data.

◆ operator[]()

template<typename T = char>
T& ddcMMap< T >::operator[] ( size_t  idx) const
inline

indexing operator

◆ open()

template<typename T = char>
ddcMMap& ddcMMap< T >::open ( const std::string &  filename,
int  mode = O_RDONLY 
)
inline

◆ close()

template<typename T = char>
void ddcMMap< T >::close ( void  )
inline

◆ begin()

template<typename T = char>
iterator ddcMMap< T >::begin ( ) const
inline

Referenced by ddcMapFile< DWORD, DWORD >::ensureMap(), and ddcMapFile< DWORD, DWORD >::find().

Here is the caller graph for this function:

◆ end()

template<typename T = char>
iterator ddcMMap< T >::end ( ) const
inline

Referenced by ddcMapFile< DWORD, DWORD >::ensureMap(), and ddcMapFile< DWORD, DWORD >::find().

Here is the caller graph for this function:

Member Data Documentation

◆ m_file

template<typename T = char>
std::string ddcMMap< T >::m_file

◆ m_nbytes

template<typename T = char>
size_t ddcMMap< T >::m_nbytes

number of bytes mapped

Referenced by ddcMMap< CIndexItem >::nbytes().

◆ m_data

template<typename T = char>
T* ddcMMap< T >::m_data

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