Skip to content

Commit

Permalink
Changed various messages in the ZSwapObject class to match project do…
Browse files Browse the repository at this point in the history
…cumentation.
  • Loading branch information
xvitaly committed Oct 19, 2024
1 parent f83338d commit c49ecab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/zswapobject/zswapobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@

void ZSwapObject::CheckValueBool(const std::string& Name, const std::string& Value) const
{
if (!std::regex_match(Value, std::regex("^[YN]$"))) throw std::invalid_argument(std::format("The requested value for the variable \"{0}\" is incorrect (only Y or N are supported)!", Name));
if (!std::regex_match(Value, std::regex("^[YN]$"))) throw std::invalid_argument(std::format("The requested value for the option \"{0}\" is incorrect (only Y or N are supported)!", Name));
}

void ZSwapObject::CheckValueEmpty(const std::string& Name, const std::string& Value) const
{
if (Value.empty()) throw std::invalid_argument(std::format("The requested value for the variable \"{0}\" is empty!", Name));
if (Value.empty()) throw std::invalid_argument(std::format("The requested value for the option \"{0}\" is empty!", Name));
}

void ZSwapObject::CheckValueRange(const std::string& Name, const std::string& Value) const
{
if (!std::regex_match(Value, std::regex("^\\d{1,2}|100$"))) throw std::invalid_argument(std::format("The requested value for the variable \"{0}\" is out of range [0..100]!", Name));
if (!std::regex_match(Value, std::regex("^\\d{1,2}|100$"))) throw std::invalid_argument(std::format("The requested value for the option \"{0}\" is out of range [0..100]!", Name));
}

void ZSwapObject::WriteLogEntry(const std::string& Name, const std::string& Value) const
{
std::cout << std::format("Writing a new value \"{1}\" to the \"{0}\" variable.", Name, Value) << std::endl;
std::cout << std::format("The option \"{0}\" has been set to a new value of \"{1}\".", Name, Value) << std::endl;
}

void ZSwapObject::WriteZSwapValue(const std::string& Name, const std::string& Value) const
{
const std::string FullPath = ZSwapModuleParametersPath + Name;
if (!std::filesystem::exists(FullPath)) throw std::runtime_error(std::format("Configuring the variable \"{0}\" is not possible on the current kernel!", Name));
if (!std::filesystem::exists(FullPath)) throw std::runtime_error(std::format("Configuring the option \"{0}\" is not possible on the current kernel!", Name));
std::ofstream ZSwapSysFs(FullPath);
ZSwapSysFs << Value;
}
Expand Down

0 comments on commit c49ecab

Please sign in to comment.