/* Copyright 2015, 2016, Michele Santullo
* This file is part of "dindexer".
*
* "dindexer" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* "dindexer" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with "dindexer". If not, see .
*/
#ifndef idDD90110B9C7E44C4AAF8B46A663B11DC
#define idDD90110B9C7E44C4AAF8B46A663B11DC
#include
#include
#include
#include
#include
namespace dincore {
class SearchPaths {
public:
enum SearchType {
Directory,
File,
Any
};
using Predicate = std::function;
SearchPaths ( void ) = default;
explicit SearchPaths ( std::vector&& parList );
SearchPaths ( std::initializer_list parInit );
~SearchPaths ( void ) noexcept;
void add_path ( std::string&& parPath );
std::string first_hit ( boost::string_ref parFile, SearchType parType=Any ) const;
std::string first_hit ( Predicate parPredicate, SearchType parType=Any ) const;
private:
std::vector m_paths;
};
class ShallowSearchPaths {
public:
ShallowSearchPaths ( void ) = default;
explicit ShallowSearchPaths ( std::vector&& parList );
ShallowSearchPaths ( std::initializer_list parInit );
~ShallowSearchPaths ( void ) noexcept;
void add_path ( boost::string_ref parPath );
std::string first_hit ( boost::string_ref parFile, SearchPaths::SearchType parType=SearchPaths::Any ) const;
std::string first_hit ( SearchPaths::Predicate parPredicate, SearchPaths::SearchType parType=SearchPaths::Any ) const;
private:
std::vector m_paths;
};
} //namespace dincore
#endif