Skip to content

Commit

Permalink
include/nutconf.hpp: annotate (for older C++) the methods which can t…
Browse files Browse the repository at this point in the history
…hrow() [networkupstools#2294]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed May 6, 2024
1 parent bd107b4 commit 9adf60a
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions include/nutconf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ class BoolInt
}

inline BoolInt& operator=(const char* s)
#if (defined __cplusplus) && (__cplusplus < 201100)
throw(std::invalid_argument)
#endif
{
if (!s)
throw std::invalid_argument(
Expand All @@ -306,6 +309,9 @@ class BoolInt
}

inline BoolInt& operator=(std::string src)
#if (defined __cplusplus) && (__cplusplus < 201100)
throw(std::invalid_argument)
#endif
{
static const Settable<bool> b0(false);
static const Settable<bool> b1(true);
Expand Down Expand Up @@ -446,6 +452,9 @@ class BoolInt
}

inline bool set()const
#if (defined __cplusplus) && (__cplusplus < 201100)
throw(std::invalid_argument)
#endif
{
if (i.set() && b.set())
throw std::invalid_argument(
Expand All @@ -454,7 +463,11 @@ class BoolInt
return (i.set() || b.set());
}

operator int() {
operator int()
#if (defined __cplusplus) && (__cplusplus < 201100)
throw(std::invalid_argument)
#endif
{
if (i.set()) return i;
if (bool01.set() && bool01 == true) {
if (b.set()) {
Expand All @@ -473,7 +486,11 @@ class BoolInt
"BoolInt value not set, neither to bool nor to int");
}

operator bool() {
operator bool()
#if (defined __cplusplus) && (__cplusplus < 201100)
throw(std::invalid_argument)
#endif
{
if (b.set()) return b;
if (bool01.set() && bool01 == true) {
if (i.set()) {
Expand All @@ -489,7 +506,11 @@ class BoolInt
"BoolInt value not set, neither to bool nor to int");
}

inline std::string toString()const {
inline std::string toString()const
#if (defined __cplusplus) && (__cplusplus < 201100)
throw(std::invalid_argument)
#endif
{
if (b.set()) {
if (b == true) return "yes";
return "no";
Expand Down Expand Up @@ -1363,6 +1384,9 @@ class GenericConfiguration : public BaseConfiguration, public Serialisable
const std::string & section,
const std::string & entry,
nut::BoolInt val = true)
#if (defined __cplusplus) && (__cplusplus < 201100)
throw(std::invalid_argument)
#endif
{
setStr(section, entry, val);
}
Expand Down

0 comments on commit 9adf60a

Please sign in to comment.