mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-26 22:53:16 -04:00
prc: Fix bool conversion for empty/zero config variables
This commit is contained in:
parent
fd5cab1a3f
commit
e6487651e7
@ -138,3 +138,11 @@ INLINE void ConfigVariableDouble::
|
||||
set_word(size_t n, double value) {
|
||||
set_double_word(n, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the variable is not 0.0.
|
||||
*/
|
||||
INLINE bool ConfigVariableDouble::
|
||||
__bool__() const {
|
||||
return get_value() != 0.0;
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ PUBLISHED:
|
||||
INLINE double get_word(size_t n) const;
|
||||
INLINE void set_word(size_t n, double value);
|
||||
|
||||
INLINE bool __bool__() const;
|
||||
|
||||
private:
|
||||
void set_default_value(double default_value);
|
||||
|
||||
|
@ -218,6 +218,14 @@ set_word(size_t n, const Filename &value) {
|
||||
set_string_word(n, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the variable is not empty.
|
||||
*/
|
||||
INLINE bool ConfigVariableFilename::
|
||||
__bool__() const {
|
||||
return !get_value().empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the variable's value, as a reference into the config variable
|
||||
* itself. This is the internal method that implements get_value(), which
|
||||
|
@ -60,6 +60,8 @@ PUBLISHED:
|
||||
INLINE Filename get_word(size_t n) const;
|
||||
INLINE void set_word(size_t n, const Filename &value);
|
||||
|
||||
INLINE bool __bool__() const;
|
||||
|
||||
private:
|
||||
void reload_cache();
|
||||
INLINE const Filename &get_ref_value() const;
|
||||
|
@ -138,3 +138,11 @@ INLINE void ConfigVariableInt::
|
||||
set_word(size_t n, int value) {
|
||||
set_int_word(n, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the variable is not 0.
|
||||
*/
|
||||
INLINE bool ConfigVariableInt::
|
||||
__bool__() const {
|
||||
return get_value() != 0;
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ PUBLISHED:
|
||||
INLINE int get_word(size_t n) const;
|
||||
INLINE void set_word(size_t n, int value);
|
||||
|
||||
INLINE bool __bool__() const;
|
||||
|
||||
private:
|
||||
void set_default_value(int default_value);
|
||||
|
||||
|
@ -138,3 +138,11 @@ INLINE void ConfigVariableInt64::
|
||||
set_word(size_t n, int64_t value) {
|
||||
set_int64_word(n, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the variable is not empty.
|
||||
*/
|
||||
INLINE bool ConfigVariableInt64::
|
||||
__bool__() const {
|
||||
return get_value() != 0;
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ PUBLISHED:
|
||||
INLINE int64_t get_word(size_t n) const;
|
||||
INLINE void set_word(size_t n, int64_t value);
|
||||
|
||||
INLINE bool __bool__() const;
|
||||
|
||||
private:
|
||||
void set_default_value(int64_t default_value);
|
||||
|
||||
|
@ -160,3 +160,11 @@ INLINE void ConfigVariableString::
|
||||
set_word(size_t n, const std::string &value) {
|
||||
set_string_word(n, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the variable is not empty.
|
||||
*/
|
||||
INLINE bool ConfigVariableString::
|
||||
__bool__() const {
|
||||
return !get_value().empty();
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ PUBLISHED:
|
||||
INLINE std::string get_word(size_t n) const;
|
||||
INLINE void set_word(size_t n, const std::string &value);
|
||||
|
||||
INLINE bool __bool__() const;
|
||||
|
||||
private:
|
||||
void reload_cache();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user