Thrill  0.1
CSimpleGlobTempl< SOCHAR > Class Template Reference

Detailed Description

template<typename SOCHAR>
class thrill::vfs::glob_local::CSimpleGlobTempl< SOCHAR >

Implementation of the SimpleGlob class.

Definition at line 550 of file simple_glob.hpp.

+ Inheritance diagram for CSimpleGlobTempl< SOCHAR >:
+ Collaboration diagram for CSimpleGlobTempl< SOCHAR >:

#include <simple_glob.hpp>

Public Member Functions

 CSimpleGlobTempl (unsigned int a_uiFlags=0, int a_nReservedSlots=0)
 Initialize the class. More...
 
 ~CSimpleGlobTempl ()
 Deallocate all memory buffers. More...
 
int Add (const SOCHAR *a_pszFileSpec)
 Add a new filespec to the glob. More...
 
int Add (int a_nCount, const SOCHAR *const *a_rgpszFileSpec)
 Add an array of filespec to the glob. More...
 
SOCHAR * File (int n)
 Return the a single file. More...
 
int FileCount () const
 Return the number of files in the argv array. More...
 
SOCHAR ** Files ()
 Return the full argv array. More...
 
int Init (unsigned int a_uiFlags=0, int a_nReservedSlots=0)
 Initialize (or re-initialize) the class in preparation for adding new filespecs. More...
 

Private Types

enum  ARG_ARRAY_TYPE { OFFSETS, POINTERS }
 The argv array has it's members stored as either an offset into the string buffer, or as pointers to their string in the buffer. More...
 

Private Member Functions

 CSimpleGlobTempl (const CSimpleGlobTempl &)
 
int AppendName (const SOCHAR *a_pszFileName, bool a_bIsDir)
 Add a filename to the array if it passes all requirements. More...
 
bool GrowArgvArray (int a_nNewLen)
 Grow the argv array to the required size. More...
 
bool GrowStringBuffer (size_t a_uiMinSize)
 Grow the string buffer to the required size. More...
 
CSimpleGlobTemploperator= (const CSimpleGlobTempl &)
 
void SetArgvArrayType (ARG_ARRAY_TYPE a_nNewType)
 Change the type of data stored in the argv array. More...
 
- Private Member Functions inherited from SimpleGlobBase< SOCHAR >
 SimpleGlobBase ()
 
 ~SimpleGlobBase ()
 
void FilePrep ()
 
void FindDone ()
 
int FindFirstFileS (const char *a_pszFileSpec, unsigned int a_uiFlags)
 
bool FindNextFileS (char)
 
const char * GetFileNameS (char) const
 
SG_FileType GetFileTypeS (const char *a_pszPath) const
 
bool IsDirS (char) const
 

Static Private Member Functions

static int fileSortCompare (const void *a1, const void *a2)
 Compare two (possible nullptr) strings. More...
 

Private Attributes

ARG_ARRAY_TYPE m_nArgArrayType
 argv is indexes or pointers More...
 
int m_nArgsLen
 used length More...
 
int m_nArgsSize
 allocated size of array More...
 
int m_nReservedSlots
 

client slots in argv array

More...
 
SOCHAR * m_pBuffer
 argv string buffer More...
 
SOCHAR ** m_rgpArgs
 argv More...
 
SOCHAR m_szPathPrefix [PATH_MAX]
 wildcard path prefix More...
 
size_t m_uiBufferLen
 used length of buffer More...
 
size_t m_uiBufferSize
 allocated size of buffer More...
 
unsigned int m_uiFlags
 

Member Enumeration Documentation

◆ ARG_ARRAY_TYPE

enum ARG_ARRAY_TYPE
private

The argv array has it's members stored as either an offset into the string buffer, or as pointers to their string in the buffer.

The offsets are used because if the string buffer is dynamically resized, all pointers into that buffer would become invalid.

Enumerator
OFFSETS 
POINTERS 

Definition at line 636 of file simple_glob.hpp.

Constructor & Destructor Documentation

◆ CSimpleGlobTempl() [1/2]

CSimpleGlobTempl ( unsigned int  a_uiFlags = 0,
int  a_nReservedSlots = 0 
)
explicit

Initialize the class.

Parameters
a_uiFlagsCombination of SG_GLOB flags.
a_nReservedSlotsNumber of slots in the argv array that should be reserved. In the returned array these slots argv[0] ... argv[a_nReservedSlots-1] will be left empty for the caller to fill in.

Definition at line 671 of file simple_glob.hpp.

◆ ~CSimpleGlobTempl()

Deallocate all memory buffers.

Definition at line 684 of file simple_glob.hpp.

References free().

◆ CSimpleGlobTempl() [2/2]

CSimpleGlobTempl ( const CSimpleGlobTempl< SOCHAR > &  )
private

Member Function Documentation

◆ Add() [1/2]

int Add ( const SOCHAR *  a_pszFileSpec)

Add a new filespec to the glob.

The filesystem will be immediately scanned for all matching files and directories and they will be added to the glob.

Parameters
a_pszFileSpecFilespec to add to the glob.
Returns
SG_SUCCESS Matching files were added to the glob.
SG_ERR_NOMATCH Nothing matched the pattern. To ignore this error compare return value to >= SG_SUCCESS.
SG_ERR_MEMORY Out of memory failure.
SG_ERR_FAILURE General failure.

Definition at line 715 of file simple_glob.hpp.

References SimpleGlobBase< SOCHAR >::FindDone(), MAX_PATH, thrill::vfs::glob_local::SG_ERR_NOMATCH, thrill::vfs::glob_local::SG_FILETYPE_DIR, thrill::vfs::glob_local::SG_FILETYPE_INVALID, thrill::vfs::glob_local::SG_GLOB_FULLSORT, thrill::vfs::glob_local::SG_GLOB_NOCHECK, thrill::vfs::glob_local::SG_GLOB_NOSORT, SG_PATH_CHAR, thrill::vfs::glob_local::SG_SUCCESS, SimpleGlobUtil::strchr(), SimpleGlobUtil::strcpy_s(), and SimpleGlobUtil::strrchr().

◆ Add() [2/2]

int Add ( int  a_nCount,
const SOCHAR *const *  a_rgpszFileSpec 
)

Add an array of filespec to the glob.

The filesystem will be immediately scanned for all matching files and directories in each filespec and they will be added to the glob.

Parameters
a_nCountNumber of filespec in the array.
a_rgpszFileSpecArray of filespec to add to the glob.
Returns
SG_SUCCESS Matching files were added to the glob.
SG_ERR_NOMATCH Nothing matched the pattern. To ignore this error compare return value to >= SG_SUCCESS.
SG_ERR_MEMORY Out of memory failure.
SG_ERR_FAILURE General failure.

Definition at line 796 of file simple_glob.hpp.

References thrill::vfs::glob_local::SG_SUCCESS.

◆ AppendName()

◆ File()

SOCHAR* File ( int  n)
inline

Return the a single file.

Definition at line 622 of file simple_glob.hpp.

References SG_ASSERT.

◆ FileCount()

int FileCount ( ) const
inline

Return the number of files in the argv array.

Definition at line 613 of file simple_glob.hpp.

◆ Files()

SOCHAR** Files ( )
inline

Return the full argv array.

Definition at line 616 of file simple_glob.hpp.

◆ fileSortCompare()

int fileSortCompare ( const void *  a1,
const void *  a2 
)
staticprivate

Compare two (possible nullptr) strings.

Definition at line 937 of file simple_glob.hpp.

References SimpleGlobUtil::strcasecmp().

◆ GrowArgvArray()

bool GrowArgvArray ( int  a_nNewLen)
private

Grow the argv array to the required size.

Definition at line 897 of file simple_glob.hpp.

References realloc().

◆ GrowStringBuffer()

bool GrowStringBuffer ( size_t  a_uiMinSize)
private

Grow the string buffer to the required size.

Definition at line 917 of file simple_glob.hpp.

References realloc().

◆ Init()

int Init ( unsigned int  a_uiFlags = 0,
int  a_nReservedSlots = 0 
)

Initialize (or re-initialize) the class in preparation for adding new filespecs.

All existing files are cleared. Note that allocated memory is only deallocated at object destruction.

Parameters
a_uiFlagsCombination of SG_GLOB flags.
a_nReservedSlotsNumber of slots in the argv array that should be reserved. In the returned array these slots argv[0] ... argv[a_nReservedSlots-1] will be left empty for the caller to fill in.

Definition at line 691 of file simple_glob.hpp.

References thrill::vfs::glob_local::SG_ERR_MEMORY, and thrill::vfs::glob_local::SG_SUCCESS.

◆ operator=()

CSimpleGlobTempl& operator= ( const CSimpleGlobTempl< SOCHAR > &  )
private

◆ SetArgvArrayType()

void SetArgvArrayType ( ARG_ARRAY_TYPE  a_nNewType)
private

Change the type of data stored in the argv array.

Definition at line 872 of file simple_glob.hpp.

References SG_ASSERT.

Member Data Documentation

◆ m_nArgArrayType

ARG_ARRAY_TYPE m_nArgArrayType
private

argv is indexes or pointers

Definition at line 655 of file simple_glob.hpp.

◆ m_nArgsLen

int m_nArgsLen
private

used length

Definition at line 659 of file simple_glob.hpp.

◆ m_nArgsSize

int m_nArgsSize
private

allocated size of array

Definition at line 658 of file simple_glob.hpp.

◆ m_nReservedSlots

int m_nReservedSlots
private

client slots in argv array

Definition at line 657 of file simple_glob.hpp.

◆ m_pBuffer

SOCHAR* m_pBuffer
private

argv string buffer

Definition at line 660 of file simple_glob.hpp.

◆ m_rgpArgs

SOCHAR** m_rgpArgs
private

argv

Definition at line 656 of file simple_glob.hpp.

◆ m_szPathPrefix

SOCHAR m_szPathPrefix[PATH_MAX]
private

wildcard path prefix

Definition at line 663 of file simple_glob.hpp.

◆ m_uiBufferLen

size_t m_uiBufferLen
private

used length of buffer

Definition at line 662 of file simple_glob.hpp.

◆ m_uiBufferSize

size_t m_uiBufferSize
private

allocated size of buffer

Definition at line 661 of file simple_glob.hpp.

◆ m_uiFlags

unsigned int m_uiFlags
private

Definition at line 654 of file simple_glob.hpp.


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