ddc
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ddcStringEnum< OffT_ > Class Template Reference

#include <ddcStringEnum.h>

Collaboration diagram for ddcStringEnum< OffT_ >:
Collaboration graph
[legend]

Classes

struct  IdKeyLess
 comparison helper struct for string-to-id search More...
 

Public Types

typedef OffT_ OffT
 typedef for offset values More...
 
typedef DWORD IdT
 typedef for integer IDs More...
 

Public Member Functions

 ddcStringEnum ()
 default constructor More...
 
 ddcStringEnum (const string &cdataFile, const string &offsetsFile, const string &fallbackFile="", bool useMMap=false)
 construct and open More...
 
 ~ddcStringEnum ()
 default destructor calls close() More...
 
void clear ()
 clear() method wraps close() More...
 
size_t size () const
 returns the number of enumerated strings More...
 
bool empty () const
 STL-esque wrapper. More...
 
bool opened () const
 check whether the object is opened More...
 
 operator bool () const
 implicit typecast to bool More...
 
const char * operator[] (size_t idx) const
 indexing operator More...
 
void push_back (const string &value)
 simulate vector::push_back(): used by indexing routines More...
 
void to_vector (vector< string > &v) const
 populate v with an equivalent vector-implementation (for compile-time compatibility) More...
 
void ensureVec ()
 force vector-implementation More...
 
IdT lower_bound (const string &key) const
 returns id of lower-bound for key, or NO_ID if not found More...
 
IdT upper_bound (const string &key) const
 returns id of upper-bound for key, or NO_ID if not found More...
 
IdT find (const string &key) const
 returns id of key, or NO_ID if not found; wraps lower_bound() More...
 
ddcStringEnumopen (const string &cdataFile, const string &offsetsFile, const string &fallbackFile, bool useMMap=false)
 map a named file filename More...
 
void openCompat (const string &filename)
 open in compatibility-mode; lifted from CConcXml::CFreeBiblStringIndex::ReadBiblStringItems (vector<string>& Set, string FileName) More...
 
void close ()
 unmap current file(s), if any More...
 

Public Attributes

ddcVecFile< char > m_cdata
 underlying character data More...
 
ddcVecFile< OffTm_offsets
 offsets in m_cdata[] of NUL-terminated item strings; associated strings must be sorted in lexicographic order More...
 
vector< string > m_strings
 backwards-compatible vector<string> implementation, for read/write access More...
 
size_t m_bufsize
 buffer size for fallback loading (default=20000: old value for MaxBiblStringLen from Bibliography.cpp) More...
 

Static Public Attributes

static const IdT NO_ID = (0xffffffff)
 constant returned by string-to-id search methods indicating no match was found More...
 

Detailed Description

template<typename OffT_ = DWORD>
class ddcStringEnum< OffT_ >

convenience wrapper for file-based integer<->string mappings

Member Typedef Documentation

◆ OffT

template<typename OffT_ = DWORD>
typedef OffT_ ddcStringEnum< OffT_ >::OffT

typedef for offset values

◆ IdT

template<typename OffT_ = DWORD>
typedef DWORD ddcStringEnum< OffT_ >::IdT

typedef for integer IDs

Constructor & Destructor Documentation

◆ ddcStringEnum() [1/2]

template<typename OffT_ = DWORD>
ddcStringEnum< OffT_ >::ddcStringEnum ( )
inline

default constructor

◆ ddcStringEnum() [2/2]

template<typename OffT_ = DWORD>
ddcStringEnum< OffT_ >::ddcStringEnum ( const string &  cdataFile,
const string &  offsetsFile,
const string &  fallbackFile = "",
bool  useMMap = false 
)
inline

construct and open

References ddcStringEnum< OffT_ >::open().

Here is the call graph for this function:

◆ ~ddcStringEnum()

template<typename OffT_ = DWORD>
ddcStringEnum< OffT_ >::~ddcStringEnum ( )
inline

default destructor calls close()

References ddcStringEnum< OffT_ >::close().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

template<typename OffT_ = DWORD>
void ddcStringEnum< OffT_ >::clear ( )
inline

clear() method wraps close()

References ddcStringEnum< OffT_ >::close().

Referenced by CFreeBiblStringIndex::CreatePartitions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

template<typename OffT_ = DWORD>
size_t ddcStringEnum< OffT_ >::size ( ) const
inline

returns the number of enumerated strings

References ddcVecFile< T >::size().

Referenced by ddcStringEnum< OffT_ >::open(), CFreeBiblStringIndex::size(), and ddcStringEnum< OffT_ >::to_vector().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

template<typename OffT_ = DWORD>
bool ddcStringEnum< OffT_ >::empty ( void  ) const
inline

STL-esque wrapper.

References ddcVecFile< T >::empty().

Here is the call graph for this function:

◆ opened()

template<typename OffT_ = DWORD>
bool ddcStringEnum< OffT_ >::opened ( ) const
inline

check whether the object is opened

References ddcVecFile< T >::opened().

Referenced by ddcStringEnum< OffT_ >::open(), ddcStringEnum< OffT_ >::openCompat(), and ddcStringEnum< OffT_ >::operator bool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator bool()

template<typename OffT_ = DWORD>
ddcStringEnum< OffT_ >::operator bool ( ) const
inline

implicit typecast to bool

References ddcStringEnum< OffT_ >::opened().

Here is the call graph for this function:

◆ operator[]()

template<typename OffT_ = DWORD>
const char* ddcStringEnum< OffT_ >::operator[] ( size_t  idx) const
inline

indexing operator

References ddcVecFile< T >::m_data.

◆ push_back()

template<typename OffT_ = DWORD>
void ddcStringEnum< OffT_ >::push_back ( const string &  value)
inline

simulate vector::push_back(): used by indexing routines

References ddcStringEnum< OffT_ >::ensureVec().

Here is the call graph for this function:

◆ to_vector()

template<typename OffT_ = DWORD>
void ddcStringEnum< OffT_ >::to_vector ( vector< string > &  v) const
inline

populate v with an equivalent vector-implementation (for compile-time compatibility)

References ddcVecFile< T >::begin(), ClearVector(), ddcVecFile< T >::end(), ddcVecFile< T >::m_data, ddcStringEnum< OffT_ >::m_strings, and ddcStringEnum< OffT_ >::size().

Referenced by ddcStringEnum< OffT_ >::ensureVec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureVec()

template<typename OffT_ = DWORD>
void ddcStringEnum< OffT_ >::ensureVec ( )
inline

force vector-implementation

References ddcVecFile< T >::close(), ddcLogWarn, ddcVecFile< T >::filename(), Format(), and ddcStringEnum< OffT_ >::to_vector().

Referenced by CFreeBiblStringIndex::CreatePartitions(), and ddcStringEnum< OffT_ >::push_back().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lower_bound()

template<typename OffT_ = DWORD>
IdT ddcStringEnum< OffT_ >::lower_bound ( const string &  key) const
inline

returns id of lower-bound for key, or NO_ID if not found

References ddcVecFile< T >::begin(), ddcVecFile< T >::end(), ddcStringEnum< OffT_ >::IdKeyLess::IdKeyLess(), and ddcStringEnum< OffT_ >::NO_ID.

Referenced by ddcStringEnum< OffT_ >::find().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ upper_bound()

template<typename OffT_ = DWORD>
IdT ddcStringEnum< OffT_ >::upper_bound ( const string &  key) const
inline

returns id of upper-bound for key, or NO_ID if not found

References ddcVecFile< T >::begin(), ddcVecFile< T >::end(), ddcStringEnum< OffT_ >::IdKeyLess::IdKeyLess(), and ddcStringEnum< OffT_ >::NO_ID.

Here is the call graph for this function:

◆ find()

template<typename OffT_ = DWORD>
IdT ddcStringEnum< OffT_ >::find ( const string &  key) const
inline

returns id of key, or NO_ID if not found; wraps lower_bound()

References ddcStringEnum< OffT_ >::lower_bound(), and ddcStringEnum< OffT_ >::NO_ID.

Here is the call graph for this function:

◆ open()

template<typename OffT_ = DWORD>
ddcStringEnum& ddcStringEnum< OffT_ >::open ( const string &  cdataFile,
const string &  offsetsFile,
const string &  fallbackFile,
bool  useMMap = false 
)
inline

map a named file filename

References ddcStringEnum< OffT_ >::close(), ddcLogDebug, ddcLogWarn, FileExists(), Format(), ddcVecFile< T >::open(), ddcStringEnum< OffT_ >::openCompat(), ddcStringEnum< OffT_ >::opened(), and ddcStringEnum< OffT_ >::size().

Referenced by ddcStringEnum< OffT_ >::ddcStringEnum().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openCompat()

template<typename OffT_ = DWORD>
void ddcStringEnum< OffT_ >::openCompat ( const string &  filename)
inline

open in compatibility-mode; lifted from CConcXml::CFreeBiblStringIndex::ReadBiblStringItems (vector<string>& Set, string FileName)

References ddcStringEnum< OffT_ >::close(), Format(), ddcStringEnum< OffT_ >::opened(), and Trim().

Referenced by ddcStringEnum< OffT_ >::open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ close()

template<typename OffT_ = DWORD>
void ddcStringEnum< OffT_ >::close ( void  )
inline

unmap current file(s), if any

References ClearVector(), and ddcVecFile< T >::close().

Referenced by ddcStringEnum< OffT_ >::clear(), ddcStringEnum< OffT_ >::open(), ddcStringEnum< OffT_ >::openCompat(), and ddcStringEnum< OffT_ >::~ddcStringEnum().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_cdata

template<typename OffT_ = DWORD>
ddcVecFile<char> ddcStringEnum< OffT_ >::m_cdata

underlying character data

◆ m_offsets

template<typename OffT_ = DWORD>
ddcVecFile<OffT> ddcStringEnum< OffT_ >::m_offsets

offsets in m_cdata[] of NUL-terminated item strings; associated strings must be sorted in lexicographic order

◆ m_strings

template<typename OffT_ = DWORD>
vector<string> ddcStringEnum< OffT_ >::m_strings

backwards-compatible vector<string> implementation, for read/write access

Referenced by CFreeBiblStringIndex::CreatePartitions(), and ddcStringEnum< OffT_ >::to_vector().

◆ m_bufsize

template<typename OffT_ = DWORD>
size_t ddcStringEnum< OffT_ >::m_bufsize

buffer size for fallback loading (default=20000: old value for MaxBiblStringLen from Bibliography.cpp)

◆ NO_ID

template<typename OffT_ = DWORD>
const IdT ddcStringEnum< OffT_ >::NO_ID = (0xffffffff)
static

constant returned by string-to-id search methods indicating no match was found

Referenced by ddcStringEnum< OffT_ >::find(), ddcStringEnum< OffT_ >::lower_bound(), and ddcStringEnum< OffT_ >::upper_bound().


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