+// Insert at front of list
+void wxVariant::Insert(const wxVariant& value)
+{
+ wxVariantList& list = GetList();
+
+ list.Insert(new wxVariant(value));
+}
+
+// Returns true if the variant is a member of the list
+bool wxVariant::Member(const wxVariant& value) const
+{
+ wxVariantList& list = GetList();
+
+ wxVariantList::compatibility_iterator node = list.GetFirst();
+ while (node)
+ {
+ wxVariant* other = node->GetData();
+ if (value == *other)
+ return true;
+ node = node->GetNext();
+ }
+ return false;
+}
+
+// Deletes the nth element of the list
+bool wxVariant::Delete(size_t item)
+{
+ wxVariantList& list = GetList();
+
+ wxASSERT_MSG( (item < list.GetCount()), wxT("Invalid index to Delete") );
+ wxVariantList::compatibility_iterator node = list.Item(item);
+ wxVariant* variant = node->GetData();
+ delete variant;
+ list.Erase(node);
+ return true;
+}
+
+// Clear list
+void wxVariant::ClearList()
+{
+ if (!IsNull() && (GetType() == wxT("list")))
+ {
+ ((wxVariantDataList*) m_refData)->Clear();
+ }
+ else
+ {
+ if (!GetType().IsSameAs(wxT("list")))
+ UnRef();
+
+ m_refData = new wxVariantDataList;
+ }
+}
+
+// Treat a list variant as an array
+wxVariant wxVariant::operator[] (size_t idx) const
+{
+ wxASSERT_MSG( GetType() == wxT("list"), wxT("Invalid type for array operator") );
+
+ if (GetType() == wxT("list"))
+ {
+ wxVariantDataList* data = (wxVariantDataList*) m_refData;
+ wxASSERT_MSG( (idx < data->GetValue().GetCount()), wxT("Invalid index for array") );
+ return *(data->GetValue().Item(idx)->GetData());
+ }
+ return wxNullVariant;
+}
+
+wxVariant& wxVariant::operator[] (size_t idx)
+{
+ // We can't return a reference to a variant for a string list, since the string
+ // is actually stored as a char*, not a variant.
+
+ wxASSERT_MSG( (GetType() == wxT("list")), wxT("Invalid type for array operator") );
+
+ wxVariantDataList* data = (wxVariantDataList*) m_refData;
+ wxASSERT_MSG( (idx < data->GetValue().GetCount()), wxT("Invalid index for array") );
+
+ return * (data->GetValue().Item(idx)->GetData());
+}
+
+// Return the number of elements in a list
+size_t wxVariant::GetCount() const
+{
+ wxASSERT_MSG( GetType() == wxT("list"), wxT("Invalid type for GetCount()") );
+
+ if (GetType() == wxT("list"))
+ {
+ wxVariantDataList* data = (wxVariantDataList*) m_refData;
+ return data->GetValue().GetCount();
+ }
+ return 0;
+}