Qore Programming Language Reference Manual 2.0.0
Loading...
Searching...
No Matches
<object> Class Reference

Methods in this pseudo-class can be executed on objects. More...

#include <Pseudo_QC_Object.dox.h>

Inheritance diagram for Qore::<object>:
[legend]

Public Member Methods

string className ()
 Returns the class name of the object.
 
bool complexType ()
 returns True in all cases for objects
 
bool empty ()
 Returns True if the object has no public or private members, False if it does.
 
__7_ string firstKey ()
 Returns the first member name in the object or NOTHING if the object has no members; if called from outside the object, the first public member name is returned (if any)
 
code getCallReference (string identifier)
 resolve the string as a call reference
 
bool hasCallableMethod (string name)
 Returns True if the given method exists (can be non-static or static) and is callable from the current context.
 
bool hasCallableNormalMethod (string name)
 Returns True if the given non-static method exists and is callable from the current context.
 
bool hasCallableStaticMethod (string name)
 Returns True if the given static method exists and is callable from the current context.
 
bool isSystem ()
 Returns True if the object is a system object (ie a constant object like stdin, etc), False if not.
 
AbstractIterator iterator ()
 Returns an ObjectIterator object for the object's members.
 
ObjectKeyIterator keyIterator ()
 Returns a ObjectKeyIterator object for the object, iterating the object's members.
 
list< stringkeys ()
 Returns a list of member names of the object; if called from outside the object, only public members are returned.
 
__7_ string lastKey ()
 Returns the last member name in the object or NOTHING if the object has no members; if called from outside the object, the last public member name is returned (if any)
 
ObjectPairIterator pairIterator ()
 Returns a ObjectPairIterator object for the object's members.
 
int size ()
 Returns the number of members in the object, public and private.
 
bool sizep ()
 Returns True since objects can return a non-zero size.
 
int typeCode ()
 Returns Qore::NT_OBJECT.
 
string uniqueHash ()
 Return a unique string for the data independent of the content.
 
bool val ()
 Returns False if the object has no public or private members, True if it does.
 
- 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)
 
bool complexType ()
 returns True if the value has a complex type, False if not
 
bool empty ()
 Returns True; this method will be reimplemented in container types where it may return False.
 
string fullType (__7_ bool with_namespaces)
 returns the full type name which differs from the simple type name in case of complex types and objects
 
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.
 
AbstractIterator iterator ()
 Returns an iterator object for the value; the default iterator object returned is SingleValueIterator.
 
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.
 
int size ()
 Returns zero; this method will be reimplemented in container types where it may return a non-zero value.
 
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)
 
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.
 
bool toBool ()
 Returns the boolean representation of the value; the default is False.
 
float toFloat ()
 Returns the floating-point representation of the value; the default is 0.0.
 
int toInt ()
 Returns the integer representation of the value; the default is 0.
 
number toNumber ()
 Returns the arbitrary-precision numeric representation of the value; the default is 0.
 
string toString (__7_ string encoding)
 Returns the string representation of the value; the default is an empty string.
 
string type ()
 Returns the string type for the value.
 
int typeCode ()
 Returns the type code for the value.
 
bool val ()
 Returns False; this method is reimplemented in other types and will return True if the given expression has a non-empty value.
 

Detailed Description

Methods in this pseudo-class can be executed on objects.

Member Function Documentation

◆ className()

string <object>::className ( )

Returns the class name of the object.

Returns
the class name of the object
Code Flags:
CONSTANT
Example:
string cn = o.className();
Note
equivalent to get_class_name()

◆ complexType()

bool <object>::complexType ( )

returns True in all cases for objects

Code Flags:
CONSTANT
Example:
bool b = n.complexType();
Returns
True in all cases for objects
See also
Since
Qore 0.8.13

◆ empty()

bool <object>::empty ( )

Returns True if the object has no public or private members, False if it does.

The opposite of <object>::val()

Returns
True if the object has no public or private members, False if it does
Code Flags:
RET_VALUE_ONLY
Example:
bool b = o.empty();

◆ firstKey()

__7_ string <object>::firstKey ( )

Returns the first member name in the object or NOTHING if the object has no members; if called from outside the object, the first public member name is returned (if any)

Returns
the first member name in the object or NOTHING if the object has no members; if called from outside the object, the first public member name is returned (if any)
Code Flags:
RET_VALUE_ONLY
Example:
*string n = o.firstKey();
See also
<object>::lastKey()

◆ getCallReference()

code <object>::getCallReference ( string  identifier)

resolve the string as a call reference

Code Flags:
RET_VALUE_ONLY
Parameters
identifierthe string to resolve; function or static class method, can include namespace path
Returns
the call reference to the given function or static method; the string is resolved as follows:
  • if in a class method, a non-static method lookup is made
  • if not found, then a static method lookup is made
  • if not found, then a function lookup is made
  • if not found, an CALL-REFERENCE-ERROR exception is thrown
Exceptions
CALL-REFERENCE-ERRORcannot resolve call reference; method not accessible in the calling context
Note
  • Pseudo-methods run with the class context of the caller, which enables this method to access any accessible private method; use this pseudo-method instead of get_call_reference() to get call references to accessible private methods in a class context
  • call references to non-static methods contain a weak reference to the object; the lifetime of the object is not extended by the call reference
See also
Since
Qore 0.9.4

◆ hasCallableMethod()

bool <object>::hasCallableMethod ( string  name)

Returns True if the given method exists (can be non-static or static) and is callable from the current context.

Code Flags:
CONSTANT
Example:
bool b = obj.hasCallableMethod("getStatus");
Returns
True if the given method exists (can be non-static or static) and is callable from the current context
See also
Note
  • returns False if the method doesn't exist or is not callable due to being private, for example
  • if a methodGate() method exists but no explicit definition of the given method exists, then this pseudo-method will return False, but any method name can be called on the object due to the existence of the methodGate() method
  • this pseudo-method will also return True if the given method exists and is accessible in an inherited class
Since
Qore 0.8.8

◆ hasCallableNormalMethod()

bool <object>::hasCallableNormalMethod ( string  name)

Returns True if the given non-static method exists and is callable from the current context.

Code Flags:
CONSTANT
Example:
bool b = obj.hasCallableNormalMethod("getStatus");
Returns
True if the given non-static method exists and is callable from the current context
See also
Note
  • returns False if the method doesn't exist or is not callable due to being private, for example
  • if a methodGate() method exists but no explicit definition of the given method exists, then this pseudo-method will return False, but any method name can be called on the object due to the existence of the methodGate() method
  • this pseudo-method will also return True if the given method exists and is accessible in an inherited class
Since
Qore 0.8.8

◆ hasCallableStaticMethod()

bool <object>::hasCallableStaticMethod ( string  name)

Returns True if the given static method exists and is callable from the current context.

Code Flags:
CONSTANT
Example:
bool b = obj.hasCallableStaticMethod("getStatus");
Returns
True if the given static method exists and is callable from the current context
See also
Note
  • returns False if the static method doesn't exist or is not callable due to being private, for example
  • this pseudo-method will also return True if the given static method exists and is accessible in an inherited class
Since
Qore 0.8.8

◆ isSystem()

bool <object>::isSystem ( )

Returns True if the object is a system object (ie a constant object like stdin, etc), False if not.

Returns
True if the object is a system object (ie a constant object like stdin, etc), False if not
Code Flags:
CONSTANT
Example:
bool b = i.isSystem();

◆ iterator()

AbstractIterator <object>::iterator ( )

Returns an ObjectIterator object for the object's members.

Returns
an ObjectIterator object for the object's members
Code Flags:
CONSTANT
Example:
map printf("+ %y\n", $1), obj.iterator();
Since
Qore 0.8.6

◆ keyIterator()

ObjectKeyIterator <object>::keyIterator ( )

Returns a ObjectKeyIterator object for the object, iterating the object's members.

Returns
a ObjectKeyIterator object for the object, iterating the object's members
Code Flags:
CONSTANT
Example:
map printf("+ %s\n", $1), obj.keyIterator();
Since
Qore 0.8.6.2

◆ keys()

list< string > <object>::keys ( )

Returns a list of member names of the object; if called from outside the object, only public members are returned.

Returns
a list of member names of the object; if called from outside the object, only public members are returned
Code Flags:
RET_VALUE_ONLY
Example:
list<string> l = o.keys();

◆ lastKey()

__7_ string <object>::lastKey ( )

Returns the last member name in the object or NOTHING if the object has no members; if called from outside the object, the last public member name is returned (if any)

Returns
the last member name in the object or NOTHING if the object has no members; if called from outside the object, the last public member name is returned (if any)
Code Flags:
RET_VALUE_ONLY
Example:
*string n = o.lastKey();
See also
<object>::firstKey()

◆ pairIterator()

ObjectPairIterator <object>::pairIterator ( )

Returns a ObjectPairIterator object for the object's members.

Returns
a ObjectPairIterator object for the object's members
Code Flags:
CONSTANT
Example:
map printf("+ %s\n", $1), obj.pairIterator();
Since
Qore 0.8.6.2

◆ size()

int <object>::size ( )

Returns the number of members in the object, public and private.

Returns
the number of members in the object, public and private
Code Flags:
RET_VALUE_ONLY
Example:
int num = o.size();
See also
<object>::sizep()

◆ sizep()

bool <object>::sizep ( )

Returns True since objects can return a non-zero size.

Code Flags:
CONSTANT
Returns
True since objects can return a non-zero size
See also
<object>::size()
Since
Qore 0.8.9

◆ typeCode()

int <object>::typeCode ( )

Returns Qore::NT_OBJECT.

Returns
Qore::NT_OBJECT
Code Flags:
CONSTANT
Example:
switch (o.typeCode()) {
case Qore::NT_OBJECT:
printf("%y: is an object\n", o);
break;
}

◆ uniqueHash()

string <object>::uniqueHash ( )

Return a unique string for the data independent of the content.

Code Flags:
CONSTANT
Returns
a unique string for the data independent of the content
Note
an SHA1 hash is created with a random salt created when the Qore library is initialized and the internal pointer address
Since
Qore 0.8.12

◆ val()

bool <object>::val ( )

Returns False if the object has no public or private members, True if it does.

The opposite of <object>::empty()

Returns
False if the object has no public or private members, True if it does
Code Flags:
RET_VALUE_ONLY
Example:
bool b = o.val();
See also