OpenClonk
C4Reloc::const_iterator Class Reference

#include <C4Reloc.h>

Public Member Functions

 const_iterator ()=default
 
 const_iterator (const const_iterator &)=default
 
 const_iterator (const const_iterator &&other)
 
 ~const_iterator ()=default
 
const_iteratoroperator++ ()
 
const PathInfooperator* () const
 
const PathInfooperator-> () const
 
const_iteratoroperator= (const const_iterator &other)
 

Protected Attributes

std::unique_ptr< PathInfotemporaryPathInfo
 
PathList::const_iterator pathListIter
 
std::stack< DirectoryIteratorsubdirIters
 

Friends

class C4Reloc
 
bool operator== (const const_iterator &, const const_iterator &)
 
bool operator!= (const const_iterator &, const const_iterator &)
 

Detailed Description

Definition at line 42 of file C4Reloc.h.

Constructor & Destructor Documentation

◆ const_iterator() [1/3]

C4Reloc::const_iterator::const_iterator ( )
default

◆ const_iterator() [2/3]

C4Reloc::const_iterator::const_iterator ( const const_iterator )
default

◆ const_iterator() [3/3]

C4Reloc::const_iterator::const_iterator ( const const_iterator &&  other)
inline

Definition at line 47 of file C4Reloc.h.

47  :
48  temporaryPathInfo(std::move(other.temporaryPathInfo)),
49  pathListIter(std::move(other.pathListIter)),
50  subdirIters(std::move(other.subdirIters))
51  {}
PathList::const_iterator pathListIter
Definition: C4Reloc.h:68
std::unique_ptr< PathInfo > temporaryPathInfo
Definition: C4Reloc.h:67
std::stack< DirectoryIterator > subdirIters
Definition: C4Reloc.h:69

◆ ~const_iterator()

C4Reloc::const_iterator::~const_iterator ( )
default

Member Function Documentation

◆ operator*()

const C4Reloc::PathInfo & C4Reloc::const_iterator::operator* ( ) const

Definition at line 119 of file C4Reloc.cpp.

120 {
121  if (!subdirIters.empty())
122  {
123  const DirectoryIterator &currentSubdir = subdirIters.top();
124  temporaryPathInfo.reset(new C4Reloc::PathInfo(StdStrBuf(*currentSubdir), PathType::PATH_Regular));
125  return *temporaryPathInfo;
126  }
127  return *pathListIter;
128 }

◆ operator++()

C4Reloc::const_iterator & C4Reloc::const_iterator::operator++ ( )

Definition at line 79 of file C4Reloc.cpp.

80 {
81  if (subdirIters.empty())
82  {
83  if ((*pathListIter).pathType == C4Reloc::PathType::PATH_IncludingSubdirectories)
84  {
85  DirectoryIterator subdir((*pathListIter).strBuf.getData());
86  if (*subdir)
87  subdirIters.emplace(subdir);
88  else
89  ++pathListIter;
90  }
91  else
92  {
93  ++pathListIter;
94  }
95  }
96  else // Currently in a subdir?
97  {
98  DirectoryIterator &currentSubdir = subdirIters.top();
99 
100  if ((!*currentSubdir) || !*(++currentSubdir))
101  {
102  subdirIters.pop();
103  if (subdirIters.empty())
104  ++pathListIter;
105  }
106  else
107  {
108  // Go deeper?
109  if (DirectoryExists(*currentSubdir))
110  {
111  DirectoryIterator subdir(*currentSubdir);
112  if (*subdir) // Make sure there is at least one file/subdir.
113  subdirIters.emplace(subdir);
114  }
115  }
116  }
117  return *this;
118 }
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:708

References DirectoryExists(), pathListIter, and subdirIters.

Here is the call graph for this function:

◆ operator->()

const PathInfo* C4Reloc::const_iterator::operator-> ( ) const
inline

Definition at line 55 of file C4Reloc.h.

55 { return &(**this); }

◆ operator=()

const_iterator& C4Reloc::const_iterator::operator= ( const const_iterator other)
inline

Definition at line 57 of file C4Reloc.h.

58  {
59  this->pathListIter = other.pathListIter;
60  this->subdirIters = other.subdirIters;
61  return *this;
62  }

References pathListIter, and subdirIters.

Friends And Related Function Documentation

◆ C4Reloc

friend class C4Reloc
friend

Definition at line 71 of file C4Reloc.h.

◆ operator!=

bool operator!= ( const const_iterator a,
const const_iterator b 
)
friend

Definition at line 137 of file C4Reloc.cpp.

138 {
139  return !(a == b);
140 }
#define a
#define b

◆ operator==

bool operator== ( const const_iterator a,
const const_iterator b 
)
friend

Definition at line 130 of file C4Reloc.cpp.

131 {
132  if (!a.subdirIters.empty()) return false;
133  if (!b.subdirIters.empty()) return false;
134  return a.pathListIter == b.pathListIter;
135 }

Member Data Documentation

◆ pathListIter

PathList::const_iterator C4Reloc::const_iterator::pathListIter
protected

Definition at line 68 of file C4Reloc.h.

Referenced by C4Reloc::begin(), C4Reloc::end(), operator++(), and operator=().

◆ subdirIters

std::stack<DirectoryIterator> C4Reloc::const_iterator::subdirIters
protected

Definition at line 69 of file C4Reloc.h.

Referenced by operator++(), and operator=().

◆ temporaryPathInfo

std::unique_ptr<PathInfo> C4Reloc::const_iterator::temporaryPathInfo
mutableprotected

Definition at line 67 of file C4Reloc.h.


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