aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Foundation/include/Poco/SortedDirectoryIterator.h
blob: 94c822be41219928293858487498c2a9f86f3a1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// SortedDirectoryIterator.h
//
// Library: Foundation
// Package: Filesystem
// Module:  DirectoryIterator
//
// Definition of the SortedDirectoryIterator class.
//
// Copyright (c) 2004-2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#ifndef Foundation_SortedDirectoryIterator_INCLUDED
#define Foundation_SortedDirectoryIterator_INCLUDED

#include "Poco/Foundation.h"
#include "Poco/File.h"
#include "Poco/Path.h"
#include "Poco/DirectoryIterator.h"
#include <deque>


namespace Poco
{

class Foundation_API SortedDirectoryIterator: public DirectoryIterator
	/// The SortedDirectoryIterator class is similar to
	/// DirectoryIterator class, but places directories before files
	/// and sorts content alphabetically.
{
public:
	SortedDirectoryIterator();
		/// Creates the end iterator.

	SortedDirectoryIterator(const std::string& path);
		/// Creates a directory iterator for the given path.

	SortedDirectoryIterator(const DirectoryIterator& iterator);
		/// Creates a directory iterator for the given path.

	SortedDirectoryIterator(const File& file);
		/// Creates a directory iterator for the given file.

	SortedDirectoryIterator(const Path& path);
		/// Creates a directory iterator for the given path.

	virtual ~SortedDirectoryIterator();
		/// Destroys the DirsFirstDirectoryIterator.

	virtual SortedDirectoryIterator& operator ++();   // prefix

private:
	bool _is_finished;
	std::deque<std::string> _directories;
	std::deque<std::string> _files;

	void next();
		/// Take next item
	void scan();
		/// Scan directory to collect its children directories and files
};


} // namespace Poco

#endif //Foundation_SortedDirectoryIterator_INCLUDED