0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-13 08:23:56 +01:00

ircd::mods: Improve paths encapsulation; fix warning. (gcc-12)

This commit is contained in:
Jason Volk 2022-07-04 14:37:26 -07:00
parent 6a5e7acee1
commit 8ba5548a2e
2 changed files with 19 additions and 6 deletions

View file

@ -25,9 +25,21 @@ namespace ircd::mods
/// when a relative path/name is given to various other places in the /// when a relative path/name is given to various other places in the
/// ircd::mods interface. /// ircd::mods interface.
/// ///
struct ircd::mods::paths class ircd::mods::paths
:std::vector<std::string>
{ {
std::vector<std::string> p;
public:
auto begin() const
{
return p.begin();
}
auto end() const
{
return p.end();
}
bool added(const string_view &dir) const; bool added(const string_view &dir) const;
bool del(const string_view &dir); bool del(const string_view &dir);

View file

@ -1216,7 +1216,7 @@ ircd::mods::prefix_if_relative(std::string path)
// //
ircd::mods::paths::paths() ircd::mods::paths::paths()
:std::vector<std::string> :p
{{ {{
mods::prefix mods::prefix
}} }}
@ -1226,6 +1226,7 @@ ircd::mods::paths::paths()
bool bool
ircd::mods::paths::add(const string_view &dir) ircd::mods::paths::add(const string_view &dir)
{ {
assert(!dir.empty());
const auto path const auto path
{ {
prefix_if_relative(dir) prefix_if_relative(dir)
@ -1252,7 +1253,7 @@ ircd::mods::paths::add(const string_view &dir)
if(added(dir)) if(added(dir))
return false; return false;
emplace(begin(), dir); p.emplace(p.begin(), std::string(dir));
return true; return true;
} }
@ -1278,7 +1279,7 @@ catch(const std::exception &e)
bool bool
ircd::mods::paths::del(const string_view &dir) ircd::mods::paths::del(const string_view &dir)
{ {
std::remove(begin(), end(), prefix_if_relative(dir)); std::remove(p.begin(), p.end(), prefix_if_relative(dir));
return true; return true;
} }
@ -1286,5 +1287,5 @@ bool
ircd::mods::paths::added(const string_view &dir) ircd::mods::paths::added(const string_view &dir)
const const
{ {
return std::find(begin(), end(), dir) != end(); return std::find(p.begin(), p.end(), dir) != p.end();
} }