mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-20 15:06:33 -05:00
cleanup: move some config data structures to separate files
This commit is contained in:
parent
8052039c6f
commit
15a0aedd25
14 changed files with 348 additions and 177 deletions
136
src/config.cpp
136
src/config.cpp
|
|
@ -237,142 +237,6 @@ Config::get(const std::string &key_,
|
|||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
Config::StatFS::to_string() const
|
||||
{
|
||||
switch(_data)
|
||||
{
|
||||
case Config::StatFS::ENUM::BASE:
|
||||
return "base";
|
||||
case Config::StatFS::ENUM::FULL:
|
||||
return "full";
|
||||
}
|
||||
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
template<>
|
||||
int
|
||||
Config::StatFS::from_string(const std::string &s_)
|
||||
{
|
||||
if(s_ == "base")
|
||||
_data = Config::StatFS::ENUM::BASE;
|
||||
ef(s_ == "full")
|
||||
_data = Config::StatFS::ENUM::FULL;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
Config::StatFSIgnore::to_string() const
|
||||
{
|
||||
switch(_data)
|
||||
{
|
||||
case Config::StatFSIgnore::ENUM::NONE:
|
||||
return "none";
|
||||
case Config::StatFSIgnore::ENUM::RO:
|
||||
return "ro";
|
||||
case Config::StatFSIgnore::ENUM::NC:
|
||||
return "nc";
|
||||
}
|
||||
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
template<>
|
||||
int
|
||||
Config::StatFSIgnore::from_string(const std::string &s_)
|
||||
{
|
||||
if(s_ == "none")
|
||||
_data = Config::StatFSIgnore::ENUM::NONE;
|
||||
ef(s_ == "ro")
|
||||
_data = Config::StatFSIgnore::ENUM::RO;
|
||||
ef(s_ == "nc")
|
||||
_data = Config::StatFSIgnore::ENUM::NC;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
Config::CacheFiles::to_string() const
|
||||
{
|
||||
switch(_data)
|
||||
{
|
||||
case Config::CacheFiles::ENUM::LIBFUSE:
|
||||
return "libfuse";
|
||||
case Config::CacheFiles::ENUM::OFF:
|
||||
return "off";
|
||||
case Config::CacheFiles::ENUM::PARTIAL:
|
||||
return "partial";
|
||||
case Config::CacheFiles::ENUM::FULL:
|
||||
return "full";
|
||||
case Config::CacheFiles::ENUM::AUTO_FULL:
|
||||
return "auto-full";
|
||||
}
|
||||
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
template<>
|
||||
int
|
||||
Config::CacheFiles::from_string(const std::string &s_)
|
||||
{
|
||||
if(s_ == "libfuse")
|
||||
_data = Config::CacheFiles::ENUM::LIBFUSE;
|
||||
ef(s_ == "off")
|
||||
_data = Config::CacheFiles::ENUM::OFF;
|
||||
ef(s_ == "partial")
|
||||
_data = Config::CacheFiles::ENUM::PARTIAL;
|
||||
ef(s_ == "full")
|
||||
_data = Config::CacheFiles::ENUM::FULL;
|
||||
ef(s_ == "auto-full")
|
||||
_data = Config::CacheFiles::ENUM::AUTO_FULL;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string
|
||||
Config::XAttr::to_string() const
|
||||
{
|
||||
switch(_data)
|
||||
{
|
||||
case Config::XAttr::ENUM::PASSTHROUGH:
|
||||
return "passthrough";
|
||||
case Config::XAttr::ENUM::NOSYS:
|
||||
return "nosys";
|
||||
case Config::XAttr::ENUM::NOATTR:
|
||||
return "noattr";
|
||||
}
|
||||
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
template<>
|
||||
int
|
||||
Config::XAttr::from_string(const std::string &s_)
|
||||
{
|
||||
if(s_ == "passthrough")
|
||||
_data = Config::XAttr::ENUM::PASSTHROUGH;
|
||||
ef(s_ == "nosys")
|
||||
_data = Config::XAttr::ENUM::NOSYS;
|
||||
ef(s_ == "noattr")
|
||||
_data = Config::XAttr::ENUM::NOATTR;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Config::set_raw(const std::string &key_,
|
||||
const std::string &value_)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue