2013-02-19 21:29:58 +01:00
|
|
|
//
|
|
|
|
// RecursiveDirectoryIteratorStategies.h
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: Filesystem
|
|
|
|
// Module: RecursiveDirectoryIterator
|
|
|
|
//
|
|
|
|
// Definitions of the RecursiveDirectoryIterator stategy classes.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
2014-05-04 21:02:42 +02:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2013-02-19 21:29:58 +01:00
|
|
|
//
|
|
|
|
|
2013-02-20 09:44:25 +01:00
|
|
|
|
2013-07-18 17:28:16 +02:00
|
|
|
#ifndef Foundation_RecursiveDirectoryIteratorStrategy_INCLUDED
|
|
|
|
#define Foundation_RecursiveDirectoryIteratorStrategy_INCLUDED
|
|
|
|
|
2013-02-19 21:29:58 +01:00
|
|
|
|
|
|
|
#include "Poco/Foundation.h"
|
|
|
|
#include "Poco/DirectoryIterator.h"
|
|
|
|
#include <stack>
|
|
|
|
#include <queue>
|
|
|
|
#include <functional>
|
|
|
|
|
2013-02-20 09:44:25 +01:00
|
|
|
|
2013-07-18 17:28:16 +02:00
|
|
|
namespace Poco {
|
|
|
|
|
2013-02-19 21:29:58 +01:00
|
|
|
|
2013-03-10 18:25:47 +01:00
|
|
|
class Foundation_API TraverseBase
|
2013-02-19 21:29:58 +01:00
|
|
|
{
|
|
|
|
public:
|
2020-01-09 10:08:09 +01:00
|
|
|
using Stack = std::stack<DirectoryIterator>;
|
|
|
|
using DepthFun = std::function<UInt16(const Stack&)>;
|
2013-02-19 21:29:58 +01:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2013-07-18 17:28:16 +02:00
|
|
|
D_INFINITE = 0 /// Special value for infinite traverse depth.
|
2013-02-19 21:29:58 +01:00
|
|
|
};
|
|
|
|
|
2020-01-04 11:28:24 +01:00
|
|
|
TraverseBase(DepthFun depthDeterminer, UInt16 maxDepth = D_INFINITE);
|
2013-02-19 21:29:58 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool isFiniteDepth();
|
2013-07-18 17:28:16 +02:00
|
|
|
bool isDirectory(Poco::File& file);
|
2013-02-19 21:29:58 +01:00
|
|
|
|
2020-01-04 11:28:24 +01:00
|
|
|
DepthFun _depthDeterminer;
|
2013-02-19 21:29:58 +01:00
|
|
|
UInt16 _maxDepth;
|
|
|
|
DirectoryIterator _itEnd;
|
|
|
|
|
|
|
|
private:
|
|
|
|
TraverseBase();
|
|
|
|
TraverseBase(const TraverseBase&);
|
|
|
|
TraverseBase& operator=(const TraverseBase&);
|
|
|
|
};
|
|
|
|
|
2013-02-20 09:44:25 +01:00
|
|
|
|
2013-03-10 18:25:47 +01:00
|
|
|
class Foundation_API ChildrenFirstTraverse: public TraverseBase
|
2013-02-19 21:29:58 +01:00
|
|
|
{
|
|
|
|
public:
|
2020-01-04 11:28:24 +01:00
|
|
|
ChildrenFirstTraverse(DepthFun depthDeterminer, UInt16 maxDepth = D_INFINITE);
|
2013-02-19 21:29:58 +01:00
|
|
|
|
|
|
|
const std::string next(Stack* itStack, bool* isFinished);
|
|
|
|
|
|
|
|
private:
|
|
|
|
ChildrenFirstTraverse();
|
|
|
|
ChildrenFirstTraverse(const ChildrenFirstTraverse&);
|
|
|
|
ChildrenFirstTraverse& operator=(const ChildrenFirstTraverse&);
|
|
|
|
};
|
|
|
|
|
2013-02-20 09:44:25 +01:00
|
|
|
|
2013-03-10 18:25:47 +01:00
|
|
|
class Foundation_API SiblingsFirstTraverse: public TraverseBase
|
2013-02-19 21:29:58 +01:00
|
|
|
{
|
|
|
|
public:
|
2020-01-04 11:28:24 +01:00
|
|
|
SiblingsFirstTraverse(DepthFun depthDeterminer, UInt16 maxDepth = D_INFINITE);
|
2013-02-19 21:29:58 +01:00
|
|
|
|
|
|
|
const std::string next(Stack* itStack, bool* isFinished);
|
|
|
|
|
|
|
|
private:
|
|
|
|
SiblingsFirstTraverse();
|
|
|
|
SiblingsFirstTraverse(const SiblingsFirstTraverse&);
|
|
|
|
SiblingsFirstTraverse& operator=(const SiblingsFirstTraverse&);
|
|
|
|
|
2020-01-09 10:08:09 +01:00
|
|
|
std::stack<std::queue<std::string>> _dirsStack;
|
2013-02-19 21:29:58 +01:00
|
|
|
};
|
|
|
|
|
2013-02-20 09:44:25 +01:00
|
|
|
|
2013-02-19 21:29:58 +01:00
|
|
|
} // namespace Poco
|
|
|
|
|
2013-07-18 17:28:16 +02:00
|
|
|
|
|
|
|
#endif // Foundation_RecursiveDirectoryIteratorStrategy_INCLUDED
|