Qore Programming Language Reference Manual  1.8.0
<bool> Class Reference

Methods in this pseudo-class can be executed on booling-point values. More...

Inheritance diagram for Qore::<bool>:

Public Member Methods

bool intp ()
 Returns True because boolean values can be converted to integers (False = 0, True = 1) More...
 
bool strp ()
 Returns True because boolean values can be converted to strings (False = "0", True = "1") More...
 
int typeCode ()
 Returns Qore::NT_BOOLEAN. More...
 
bool val ()
 Returns itself. More...
 
- Public Member Methods inherited from <value>
bool callp ()
 Returns False; this method is reimplemented in other types and will return True if the given expression is a callable value (ie closures or call references) More...
 
bool complexType ()
 returns True if the value has a complex type, False if not More...
 
bool empty ()
 Returns True; this method will be reimplemented in container types where it may return False. More...
 
string fullType (*bool with_namespaces)
 returns the full type name which differs from the simple type name in case of complex types and objects More...
 
bool intp ()
 Returns False; this method is reimplemented in other types and will return True if the given expression can be converted to an integer. More...
 
AbstractIterator iterator ()
 Returns an iterator object for the value; the default iterator object returned is SingleValueIterator. More...
 
int lsize ()
 Returns 1; the return value of this method should give the list size of the value, which is normally 1 for non-lists (except for NOTHING where the size will be 0) and the number of the elements in the list for lists; this method will be reimplemented in other types where it may return other values. More...
 
int size ()
 Returns zero; this method will be reimplemented in container types where it may return a non-zero value. More...
 
bool sizep ()
 Returns True if the type can return a non-zero size (True for containers including binary objects and strings, False for everything else) More...
 
bool strp ()
 Returns False; this method is reimplemented in other types and will return True if the given expression can be converted to a string. More...
 
bool toBool ()
 Returns the boolean representation of the value; the default is False. More...
 
float toFloat ()
 Returns the floating-point representation of the value; the default is 0.0. More...
 
int toInt ()
 Returns the integer representation of the value; the default is 0. More...
 
number toNumber ()
 Returns the arbitrary-precision numeric representation of the value; the default is 0. More...
 
string toString ()
 Returns the string representation of the value; the default is an empty string. More...
 
string type ()
 Returns the string type for the value. More...
 
int typeCode ()
 Returns the type code for the value. More...
 
bool val ()
 Returns False; this method is reimplemented in other types and will return True if the given expression has a non-empty value. More...
 

Detailed Description

Methods in this pseudo-class can be executed on booling-point values.

Member Function Documentation

◆ intp()

bool <bool>::intp ( )

Returns True because boolean values can be converted to integers (False = 0, True = 1)

Returns
True because boolean values can be converted to integers (False = 0, True = 1)
Code Flags:
CONSTANT
Example:
if (n.intp())
printf("%y: can be converted to an integer: %d\n", n, int(n));
string printf(string fmt,...)
Outputs the string passed to standard output, using the first argument as a format string; does not e...
int int(string str, int base=10)
Converts the string to an integer value with respect to the base.

◆ strp()

bool <bool>::strp ( )

Returns True because boolean values can be converted to strings (False = "0", True = "1")

Returns
True because boolean values can be converted to strings (False = "0", True = "1")
Code Flags:
CONSTANT
Example:
if (n.strp())
printf("%y: can be converted to a string: '%s'\n", n, string(n));
string string(softstring str, *string enc)
Converts the argument to a string.

◆ typeCode()

int <bool>::typeCode ( )

Returns Qore::NT_BOOLEAN.

Returns
Qore::NT_BOOLEAN
Code Flags:
CONSTANT
Example:
switch (b.typeCode()) {
case NT_BOOLEAN:
printf("%y: is a bool\n", b);
break;
}

◆ val()

bool <bool>::val ( )

Returns itself.

Returns
itself
Code Flags:
CONSTANT
Example:
bool bool = b.val();
See also