dxx-rebirth/common/include/physfs_list.h
Kp df8dc7cc46 Include fwd-partial_range.h in physfs_list.h
All users of physfs_list.h included fwd-partial_range.h or
partial_range.h; physfs_list.h did not include either, but assumed one
would be available.  Include fwd to fix check_header_includes=1 build.

Fixes: ff67afd440 ("Propagate partial_range up into PHYSFSX_findFiles family")
2016-08-06 19:55:23 +00:00

95 lines
2.1 KiB
C++

/*
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
* It is copyright by its individual contributors, as recorded in the
* project's Git history. See COPYING.txt at the top level for license
* terms and a link to the Git history.
*/
#pragma once
#include <physfs.h>
typedef char file_extension_t[5];
#ifdef __cplusplus
#include <cstdint>
#include <memory>
#include "null_sentinel_iterator.h"
#include "dxxsconf.h"
#include "dsx-ns.h"
#include "compiler-array.h"
#include "fwd-partial_range.h"
namespace dcx {
class PHYSFS_list_deleter
{
public:
void operator()(char **list) const
{
PHYSFS_freeList(list);
}
};
template <typename D>
class PHYSFSX_uncounted_list_template : public std::unique_ptr<char *[], D>
{
typedef std::unique_ptr<char *[], D> base_ptr;
public:
typedef null_sentinel_iterator<char *> const_iterator;
DXX_INHERIT_CONSTRUCTORS(PHYSFSX_uncounted_list_template, base_ptr);
const_iterator begin() const
{
return this->get();
}
const_iterator end() const
{
return {};
}
};
template <typename D>
class PHYSFSX_counted_list_template : public PHYSFSX_uncounted_list_template<D>
{
typedef PHYSFSX_uncounted_list_template<D> base_ptr;
typedef typename base_ptr::pointer pointer;
uint_fast32_t count;
public:
PHYSFSX_counted_list_template() = default;
PHYSFSX_counted_list_template(char **p) :
base_ptr(p), count(0)
{
}
uint_fast32_t get_count() const
{
return count;
}
void set_count(uint_fast32_t c)
{
count = c;
}
void reset()
{
base_ptr::reset();
}
void reset(pointer p)
{
count = 0;
base_ptr::reset(p);
}
};
typedef PHYSFSX_uncounted_list_template<PHYSFS_list_deleter> PHYSFSX_uncounted_list;
typedef PHYSFSX_counted_list_template<PHYSFS_list_deleter> PHYSFSX_counted_list;
__attribute_nonnull()
__attribute_warn_unused_result
PHYSFSX_uncounted_list PHYSFSX_findFiles(const char *path, partial_range_t<const file_extension_t *> exts);
__attribute_nonnull()
__attribute_warn_unused_result
PHYSFSX_uncounted_list PHYSFSX_findabsoluteFiles(const char *path, const char *realpath, const partial_range_t<const file_extension_t *> exts);
}
#endif