#include <variant.h>
Inheritance diagram for Kross::Api::Variant:


Definition at line 37 of file variant.h.
|
|
Shared pointer to implement reference-counting. Reimplemented in Kross::Api::Callable, Kross::Api::EventAction, Kross::Api::EventScript, Kross::Api::EventSignal, Kross::Api::EventSlot, Kross::Api::Exception, Kross::Api::List, Kross::Api::Module, Kross::Api::QtObject, Kross::Api::MainModule, Kross::Api::ScriptAction, and Kross::Api::ScriptContainer. |
|
||||||||||||
|
Constructor.
Definition at line 27 of file variant.cpp. 00028 : Value<Variant, QVariant>(value, name) 00029 { 00030 }
|
|
|
Destructor. Definition at line 32 of file variant.cpp.
|
|
||||||||||||
|
Add a new child. Replaces a possible already existing child with such a name.
Definition at line 79 of file object.cpp. References QString::arg(), QString::isEmpty(), QString::isNull(), and QMap::replace(). Referenced by Kross::Api::MainModule::addKAction(), Kross::Api::MainModule::addQObject(), Kross::Api::MainModule::addSignal(), Kross::Api::MainModule::addSlot(), Kross::Api::QtObject::QtObject(), and TestPluginModule::TestPluginModule(). 00080 { 00081 QString n = name.isNull() ? object->getName() : name; 00082 00083 #ifdef KROSS_API_OBJECT_ADDCHILD_DEBUG 00084 kdDebug() << QString("Kross::Api::Object::addChild() object.name='%2' object.classname='%3'") 00085 .arg(n).arg(object->getClassName()) << endl; 00086 #endif 00087 00088 if(n.isEmpty()) // prevent invalid items. 00089 return false; //throw Exception::Ptr( new Exception( QString("Failed to add child object to object '%1'. Invalid name for class '%2'.").arg(getName()).arg(object->getClassName()) ) ); 00090 00091 object->m_parent = this; 00092 m_children.replace(n, object); 00093 return true; 00094 }
|
|
||||||||||||
|
Pass a call to the object and evaluated it recursive down the object-hierachy. Objects like Class are able to handle call's by just implementing this function. If the call is done the called() method will be executed recursive from bottom up the call hierachy.
Reimplemented in Kross::Api::EventScript, Kross::Api::EventSignal, and Kross::Api::EventSlot. Referenced by Kross::Api::Callable::call(), and Kross::Api::Callable::callChild(). |
|
||||||||||
|
Try to convert the Object instance to the template class T.
Definition at line 198 of file object.h. 00199 { 00200 T* t = (T*) object.data(); 00201 if(! t) 00202 throw KSharedPtr<Exception>( new Exception(QString("Object \"%1\" invalid.").arg(object ? object->getClassName() : "")) ); 00203 return t; 00204 }
|
|
|
Return a list of supported callable objects.
Reimplemented in Kross::Python::PythonObject. Definition at line 186 of file object.h. 00186 { return QStringList(); }
|
|
|
Return the defined child or NULL if there is no such object with that name avaible.
Definition at line 69 of file object.cpp. Referenced by Kross::Api::Callable::getChild().
|
|
|
Return all children.
Definition at line 74 of file object.cpp. Referenced by Kross::Api::Callable::getChildrenDict(), and Kross::Api::Callable::getChildrenList().
|
|
|
Implements Kross::Api::Object. Definition at line 36 of file variant.cpp.
|
|
|
Return the name this object has.
Reimplemented in Kross::Api::ScriptContainer. Definition at line 49 of file object.cpp. Referenced by Kross::Api::Event< QtObject >::call(), Kross::Api::Callable::call(), Kross::Api::Callable::getChild(), and Kross::Api::Module::~Module().
|
|
|
Return the parent object or NULL if this object doesn't has a parent.
Definition at line 59 of file object.cpp.
|
|
|||||||||
|
Return the value.
Definition at line 66 of file value.h. Referenced by Kross::Api::List::append(), Kross::Api::List::count(), Kross::Api::List::item(), operator bool(), operator const char *(), operator const QCString(), operator const QCString &(), operator const QString(), operator const QString &(), operator const QVariant &(), operator double(), operator int(), operator QCString(), operator QString(), operator uint(), toList(), toString(), Kross::Api::List::toString(), Kross::Api::Dict::toString(), and toVariant().
|
|
|
Definition at line 46 of file variant.cpp. References toVariant(). 00047 { 00048 switch( toVariant(object).type() ) { 00049 00050 case QVariant::CString: 00051 case QVariant::String: 00052 return "Kross::Api::Variant::String"; 00053 00054 case QVariant::Map: 00055 return "Kross::Api::Variant::Dict"; 00056 00057 case QVariant::StringList: 00058 case QVariant::List: 00059 return "Kross::Api::Variant::List"; 00060 00061 case QVariant::Double: 00062 //return "Kross::Api::Variant::Double"; 00063 case QVariant::UInt: 00064 //return "Kross::Api::Variant::UInt"; // python isn't able to differ between int and uint :-( 00065 case QVariant::LongLong: 00066 case QVariant::ULongLong: 00067 case QVariant::Int: 00068 return "Kross::Api::Variant::Integer"; 00069 00070 case QVariant::Bool: 00071 return "Kross::Api::Variant::Bool"; 00072 00073 default: //Date, Time, DateTime, ByteArray, BitArray, Rect, Size, Color, Invalid, etc. 00074 return "Kross::Api::Variant"; 00075 } 00076 }
|
|
|
Returns if the defined child is avaible.
Reimplemented in Kross::Api::MainModule. Definition at line 64 of file object.cpp. References QMap::contains(). Referenced by Kross::Api::MainModule::hasChild(), and Kross::Api::Callable::hasChild(). 00065 { 00066 return m_children.contains(name); 00067 }
|
|
|
Remove all children. Definition at line 104 of file object.cpp. References QMap::clear(). 00105 { 00106 #ifdef KROSS_API_OBJECT_REMCHILD_DEBUG 00107 kdDebug() << "Kross::Api::Object::removeAllChildren()" << endl; 00108 #endif 00109 m_children.clear(); 00110 }
|
|
|
Remove an existing child.
Definition at line 96 of file object.cpp. References QMap::remove(). 00097 { 00098 #ifdef KROSS_API_OBJECT_REMCHILD_DEBUG 00099 kdDebug() << QString("Kross::Api::Object::removeChild() name='%1'").arg(name) << endl; 00100 #endif 00101 m_children.remove(name); 00102 }
|
|
|
Try to convert the given Object into a boolean value.
Definition at line 131 of file variant.cpp. References QVariant::canCast(), QVariant::toBool(), toVariant(), and QVariant::typeName(). 00132 { 00133 const QVariant& variant = toVariant(object); 00134 if(! variant.canCast(QVariant::Bool)) 00135 throw Exception::Ptr( new Exception(QString("Kross::Api::Variant::Bool expected, but got %1.").arg(variant.typeName()).latin1()) ); 00136 return variant.toBool(); 00137 }
|
|
|
Try to convert the given Object into a uint.
Definition at line 107 of file variant.cpp. References QVariant::canCast(), QVariant::toDouble(), toVariant(), and QVariant::typeName(). 00108 { 00109 const QVariant& variant = toVariant(object); 00110 if(! variant.canCast(QVariant::Double)) 00111 throw Exception::Ptr( new Exception(QString("Kross::Api::Variant::Double expected, but got %1.").arg(variant.typeName()).latin1()) ); 00112 return variant.toDouble(); 00113 }
|
|
|
Try to convert the given Object into a int.
Definition at line 91 of file variant.cpp. References QVariant::canCast(), QVariant::toInt(), toVariant(), and QVariant::typeName(). 00092 { 00093 const QVariant& variant = toVariant(object); 00094 if(! variant.canCast(QVariant::Int)) 00095 throw Exception::Ptr( new Exception(QString("Kross::Api::Variant::Int expected, but got %1.").arg(variant.typeName()).latin1()) ); 00096 return variant.toInt(); 00097 }
|
|
|
Try to convert the given Object into a QValueList of QVariant's.
Definition at line 139 of file variant.cpp. References QValueList::begin(), QValueList::end(), Kross::Api::Value< T, V >::getValue(), and toVariant(). 00140 { 00141 if(object->getClassName() == "Kross::Api::List") { 00142 QValueList<QVariant> l; 00143 QValueList<Object::Ptr> list = Object::fromObject<List>( object.data() )->getValue(); 00144 for(QValueList<Object::Ptr>::Iterator it = list.begin(); it != list.end(); ++it) 00145 l.append( toVariant(*it) ); 00146 return l; 00147 } 00148 const QVariant& variant = toVariant(object); 00149 if(! variant.canCast(QVariant::List)) 00150 throw Exception::Ptr( new Exception(QString("Kross::Api::Variant::List expected, but got '%1'.").arg(variant.typeName()).latin1()) ); 00151 return variant.toList(); 00152 }
|
|
|
Try to convert the given Object into a Q_LLONG.
Definition at line 115 of file variant.cpp. References QVariant::canCast(), QVariant::toLongLong(), toVariant(), and QVariant::typeName(). 00116 { 00117 const QVariant& variant = toVariant(object); 00118 if(! variant.canCast(QVariant::LongLong)) 00119 throw Exception::Ptr( new Exception(QString("Kross::Api::Variant::LLONG expected, but got %1.").arg(variant.typeName()).latin1()) ); 00120 return variant.toLongLong(); 00121 }
|
|
|
Try to convert the given Object into a QString.
Definition at line 83 of file variant.cpp. References QVariant::canCast(), QVariant::toString(), toVariant(), and QVariant::typeName(). 00084 { 00085 const QVariant& variant = toVariant(object); 00086 if(! variant.canCast(QVariant::String)) 00087 throw Exception::Ptr( new Exception(QString("Kross::Api::Variant::String expected, but got %1.").arg(variant.typeName()).latin1()) ); 00088 return variant.toString(); 00089 }
|
|
|
Reimplemented from Kross::Api::Object. Definition at line 41 of file variant.cpp. References Kross::Api::Value< T, V >::getValue(). Referenced by Kross::Api::Callable::callChild(), Kross::Api::Callable::getChild(), Kross::Api::Callable::hasChild(), and Kross::Api::QtObject::toQUObject(). 00042 { 00043 return getValue().toString(); 00044 }
|
|
|
Try to convert the given Object into a uint.
Definition at line 99 of file variant.cpp. References QVariant::canCast(), QVariant::toUInt(), toVariant(), and QVariant::typeName(). 00100 { 00101 const QVariant& variant = toVariant(object); 00102 if(! variant.canCast(QVariant::UInt)) 00103 throw Exception::Ptr( new Exception(QString("Kross::Api::Variant::UInt expected, but got %1.").arg(variant.typeName()).latin1()) ); 00104 return variant.toUInt(); 00105 }
|
|
|
Try to convert the given Object into a Q_ULLONG.
Definition at line 123 of file variant.cpp. References QVariant::canCast(), QVariant::toULongLong(), toVariant(), and QVariant::typeName(). 00124 { 00125 const QVariant& variant = toVariant(object); 00126 if(! variant.canCast(QVariant::ULongLong)) 00127 throw Exception::Ptr( new Exception(QString("Kross::Api::Variant::ULLONG expected, but got %1.").arg(variant.typeName()).latin1()) ); 00128 return variant.toULongLong(); 00129 }
|
|
|
Try to convert the given Object into a QVariant.
Definition at line 78 of file variant.cpp. References Kross::Api::Value< T, V >::getValue(). Referenced by getVariantType(), toBool(), toDouble(), toInt(), toList(), toLLONG(), toString(), toUInt(), and toULLONG(). 00079 { 00080 return Object::fromObject<Variant>( object.data() )->getValue(); 00081 }
|
1.4.6