|
DBus-1-TQt
1.0
|
00001 /* qdbusdatamap.h DBUS data mapping transport type 00002 * 00003 * Copyright (C) 2007 Kevin Krammer <kevin.krammer@gmx.at> 00004 * 00005 * Licensed under the Academic Free License version 2.1 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00020 * USA. 00021 * 00022 */ 00023 00024 #ifndef TQDBUSDATAMAP_H 00025 #define TQDBUSDATAMAP_H 00026 00027 #include "tqdbusmacros.h" 00028 #include <tqmap.h> 00029 00030 class TQT_DBusData; 00031 class TQT_DBusObjectPath; 00032 class TQT_DBusUnixFd; 00033 class TQT_DBusVariant; 00034 00072 template <typename T> 00073 class TQDBUS_EXPORT TQT_DBusDataMap : private TQMap<T, TQT_DBusData> 00074 { 00075 friend class TQT_DBusData; 00076 00077 public: 00082 typedef TQMapConstIterator<T, TQT_DBusData> const_iterator; 00083 00089 TQT_DBusDataMap<T>() 00090 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Invalid) {} 00091 00103 explicit TQT_DBusDataMap<T>(TQT_DBusData::Type simpleValueType) 00104 : TQMap<T, TQT_DBusData>(), m_valueType(simpleValueType) {} 00105 00116 explicit TQT_DBusDataMap<T>(const TQT_DBusData& containerValueType) 00117 : TQMap<T, TQT_DBusData>(), m_valueType(containerValueType.type()) 00118 { 00119 if (hasContainerValueType()) m_containerValueType = containerValueType; 00120 } 00121 00130 TQT_DBusDataMap<T>(const TQT_DBusDataMap<T>& other) 00131 : TQMap<T, TQT_DBusData>(other), m_valueType(other.m_valueType), 00132 m_containerValueType(other.m_containerValueType) {} 00133 00150 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusData>& other) 00151 : TQMap<T, TQT_DBusData>(other), m_valueType(TQT_DBusData::Invalid) 00152 { 00153 const_iterator it = begin(); 00154 if (it == end()) return; 00155 00156 m_valueType = (*it).type(); 00157 00158 TQCString containerSignature; 00159 if (hasContainerValueType()) 00160 { 00161 m_containerValueType = it.data(); 00162 containerSignature = m_containerValueType.buildDBusSignature(); 00163 } 00164 00165 for (++it; it != end(); ++it) 00166 { 00167 if ((*it).type() != m_valueType) 00168 { 00169 m_valueType = TQT_DBusData::Invalid; 00170 m_containerValueType = TQT_DBusData(); 00171 00172 clear(); 00173 return; 00174 } 00175 else if (hasContainerValueType()) 00176 { 00177 if (it.data().buildDBusSignature() != containerSignature) 00178 { 00179 m_valueType = TQT_DBusData::Invalid; 00180 m_containerValueType = TQT_DBusData(); 00181 00182 clear(); 00183 return; 00184 } 00185 } 00186 } 00187 } 00188 00201 TQT_DBusDataMap<T>(const TQMap<T, bool>& other) 00202 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Bool) 00203 { 00204 typename TQMap<T, bool>::const_iterator it = other.begin(); 00205 typename TQMap<T, bool>::const_iterator endIt = other.end(); 00206 for (; it != endIt; ++it) 00207 { 00208 insert(it.key(), TQT_DBusData::fromBool(it.data())); 00209 } 00210 } 00211 00224 TQT_DBusDataMap<T>(const TQMap<T, TQ_UINT8>& other) 00225 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Byte) 00226 { 00227 typename TQMap<T, TQ_UINT8>::const_iterator it = other.begin(); 00228 typename TQMap<T, TQ_UINT8>::const_iterator endIt = other.end(); 00229 for (; it != endIt; ++it) 00230 { 00231 insert(it.key(), TQT_DBusData::fromByte(it.data())); 00232 } 00233 } 00234 00247 TQT_DBusDataMap<T>(const TQMap<T, TQ_INT16>& other) 00248 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Int16) 00249 { 00250 typename TQMap<T, TQ_INT16>::const_iterator it = other.begin(); 00251 typename TQMap<T, TQ_INT16>::const_iterator endIt = other.end(); 00252 for (; it != endIt; ++it) 00253 { 00254 insert(it.key(), TQT_DBusData::fromInt16(it.data())); 00255 } 00256 } 00257 00270 TQT_DBusDataMap<T>(const TQMap<T, TQ_UINT16>& other) 00271 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::UInt16) 00272 { 00273 typename TQMap<T, TQ_UINT16>::const_iterator it = other.begin(); 00274 typename TQMap<T, TQ_UINT16>::const_iterator endIt = other.end(); 00275 for (; it != endIt; ++it) 00276 { 00277 insert(it.key(), TQT_DBusData::fromUInt16(it.data())); 00278 } 00279 } 00280 00293 TQT_DBusDataMap<T>(const TQMap<T, TQ_INT32>& other) 00294 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Int32) 00295 { 00296 typename TQMap<T, TQ_INT32>::const_iterator it = other.begin(); 00297 typename TQMap<T, TQ_INT32>::const_iterator endIt = other.end(); 00298 for (; it != endIt; ++it) 00299 { 00300 insert(it.key(), TQT_DBusData::fromInt32(it.data())); 00301 } 00302 } 00303 00316 TQT_DBusDataMap<T>(const TQMap<T, TQ_UINT32>& other) 00317 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::UInt32) 00318 { 00319 typename TQMap<T, TQ_UINT32>::const_iterator it = other.begin(); 00320 typename TQMap<T, TQ_UINT32>::const_iterator endIt = other.end(); 00321 for (; it != endIt; ++it) 00322 { 00323 insert(it.key(), TQT_DBusData::fromUInt32(it.data())); 00324 } 00325 } 00326 00339 TQT_DBusDataMap<T>(const TQMap<T, TQ_INT64>& other) 00340 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Int64) 00341 { 00342 typename TQMap<T, TQ_INT64>::const_iterator it = other.begin(); 00343 typename TQMap<T, TQ_INT64>::const_iterator endIt = other.end(); 00344 for (; it != endIt; ++it) 00345 { 00346 insert(it.key(), TQT_DBusData::fromInt64(it.data())); 00347 } 00348 } 00349 00362 TQT_DBusDataMap<T>(const TQMap<T, TQ_UINT64>& other) 00363 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::UInt64) 00364 { 00365 typename TQMap<T, TQ_UINT64>::const_iterator it = other.begin(); 00366 typename TQMap<T, TQ_UINT64>::const_iterator endIt = other.end(); 00367 for (; it != endIt; ++it) 00368 { 00369 insert(it.key(), TQT_DBusData::fromUInt64(it.data())); 00370 } 00371 } 00372 00385 TQT_DBusDataMap<T>(const TQMap<T, double>& other) 00386 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Double) 00387 { 00388 typename TQMap<T, double>::const_iterator it = other.begin(); 00389 typename TQMap<T, double>::const_iterator endIt = other.end(); 00390 for (; it != endIt; ++it) 00391 { 00392 insert(it.key(), TQT_DBusData::fromDouble(it.data())); 00393 } 00394 } 00395 00408 TQT_DBusDataMap<T>(const TQMap<T, TQString>& other) 00409 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::String) 00410 { 00411 typename TQMap<T, TQString>::const_iterator it = other.begin(); 00412 typename TQMap<T, TQString>::const_iterator endIt = other.end(); 00413 for (; it != endIt; ++it) 00414 { 00415 insert(it.key(), TQT_DBusData::fromString(it.data())); 00416 } 00417 } 00418 00431 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusObjectPath>& other) 00432 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::ObjectPath) 00433 { 00434 typename TQMap<T, TQT_DBusObjectPath>::const_iterator it = other.begin(); 00435 typename TQMap<T, TQT_DBusObjectPath>::const_iterator endIt = other.end(); 00436 for (; it != endIt; ++it) 00437 { 00438 insert(it.key(), TQT_DBusData::fromObjectPath(it.data())); 00439 } 00440 } 00441 00454 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusUnixFd>& other) 00455 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::UnixFd) 00456 { 00457 typename TQMap<T, TQT_DBusUnixFd>::const_iterator it = other.begin(); 00458 typename TQMap<T, TQT_DBusUnixFd>::const_iterator endIt = other.end(); 00459 for (; it != endIt; ++it) 00460 { 00461 insert(it.key(), TQT_DBusData::fromUnixFd(it.data())); 00462 } 00463 } 00464 00477 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusVariant>& other) 00478 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Variant) 00479 { 00480 typename TQMap<T, TQT_DBusVariant>::const_iterator it = other.begin(); 00481 typename TQMap<T, TQT_DBusVariant>::const_iterator endIt = other.end(); 00482 for (; it != endIt; ++it) 00483 { 00484 insert(it.key(), TQT_DBusData::fromVariant(it.data())); 00485 } 00486 } 00487 00493 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQ_UINT8> >& other) 00494 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00495 { 00496 typename TQMap<T, TQT_DBusDataMap<TQ_UINT8> >::const_iterator it = other.begin(); 00497 typename TQMap<T, TQT_DBusDataMap<TQ_UINT8> >::const_iterator endIt = other.end(); 00498 for (; it != endIt; ++it) 00499 { 00500 insert(it.key(), TQT_DBusData::fromByteKeyMap(it.data())); 00501 } 00502 } 00503 00509 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQ_INT16> >& other) 00510 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00511 { 00512 typename TQMap<T, TQT_DBusDataMap<TQ_INT16> >::const_iterator it = other.begin(); 00513 typename TQMap<T, TQT_DBusDataMap<TQ_INT16> >::const_iterator endIt = other.end(); 00514 for (; it != endIt; ++it) 00515 { 00516 insert(it.key(), TQT_DBusData::fromInt16KeyMap(it.data())); 00517 } 00518 } 00519 00525 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQ_UINT16> >& other) 00526 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00527 { 00528 typename TQMap<T, TQT_DBusDataMap<TQ_UINT16> >::const_iterator it = other.begin(); 00529 typename TQMap<T, TQT_DBusDataMap<TQ_UINT16> >::const_iterator endIt = other.end(); 00530 for (; it != endIt; ++it) 00531 { 00532 insert(it.key(), TQT_DBusData::fromUInt16KeyMap(it.data())); 00533 } 00534 } 00535 00541 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQ_INT32> >& other) 00542 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00543 { 00544 typename TQMap<T, TQT_DBusDataMap<TQ_INT32> >::const_iterator it = other.begin(); 00545 typename TQMap<T, TQT_DBusDataMap<TQ_INT32> >::const_iterator endIt = other.end(); 00546 for (; it != endIt; ++it) 00547 { 00548 insert(it.key(), TQT_DBusData::fromInt32KeyMap(it.data())); 00549 } 00550 } 00551 00557 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQ_UINT32> >& other) 00558 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00559 { 00560 typename TQMap<T, TQT_DBusDataMap<TQ_UINT32> >::const_iterator it = other.begin(); 00561 typename TQMap<T, TQT_DBusDataMap<TQ_UINT32> >::const_iterator endIt = other.end(); 00562 for (; it != endIt; ++it) 00563 { 00564 insert(it.key(), TQT_DBusData::fromUInt32KeyMap(it.data())); 00565 } 00566 } 00567 00573 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQ_INT64> >& other) 00574 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00575 { 00576 typename TQMap<T, TQT_DBusDataMap<TQ_INT64> >::const_iterator it = other.begin(); 00577 typename TQMap<T, TQT_DBusDataMap<TQ_INT64> >::const_iterator endIt = other.end(); 00578 for (; it != endIt; ++it) 00579 { 00580 insert(it.key(), TQT_DBusData::fromInt64KeyMap(it.data())); 00581 } 00582 } 00583 00589 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQ_UINT64> >& other) 00590 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00591 { 00592 typename TQMap<T, TQT_DBusDataMap<TQ_UINT64> >::const_iterator it = other.begin(); 00593 typename TQMap<T, TQT_DBusDataMap<TQ_UINT64> >::const_iterator endIt = other.end(); 00594 for (; it != endIt; ++it) 00595 { 00596 insert(it.key(), TQT_DBusData::fromUInt64KeyMap(it.data())); 00597 } 00598 } 00599 00605 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQString> >& other) 00606 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00607 { 00608 typename TQMap<T, TQT_DBusDataMap<TQString> >::const_iterator it = other.begin(); 00609 typename TQMap<T, TQT_DBusDataMap<TQString> >::const_iterator endIt = other.end(); 00610 for (; it != endIt; ++it) 00611 { 00612 insert(it.key(), TQT_DBusData::fromStringKeyMap(it.data())); 00613 } 00614 } 00615 00621 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQT_DBusObjectPath> >& other) 00622 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00623 { 00624 typename TQMap<T, TQT_DBusDataMap<TQT_DBusObjectPath> >::const_iterator it = other.begin(); 00625 typename TQMap<T, TQT_DBusDataMap<TQT_DBusObjectPath> >::const_iterator endIt = other.end(); 00626 for (; it != endIt; ++it) 00627 { 00628 insert(it.key(), TQT_DBusData::fromObjectPathKeyMap(it.data())); 00629 } 00630 } 00631 00637 TQT_DBusDataMap<T>(const TQMap<T, TQT_DBusDataMap<TQT_DBusUnixFd > >& other) 00638 : TQMap<T, TQT_DBusData>(), m_valueType(TQT_DBusData::Map) 00639 { 00640 typename TQMap<T, TQT_DBusDataMap<TQT_DBusUnixFd > >::const_iterator it = other.begin(); 00641 typename TQMap<T, TQT_DBusDataMap<TQT_DBusUnixFd > >::const_iterator endIt = other.end(); 00642 for (; it != endIt; ++it) 00643 { 00644 insert(it.key(), TQT_DBusData::fromUnixFdKeyMap(it.data())); 00645 } 00646 } 00647 00658 TQT_DBusDataMap<T>& operator=(const TQT_DBusDataMap<T>& other) 00659 { 00660 TQMap<T, TQT_DBusData>::operator=(other); 00661 00662 m_valueType = other.m_valueType; 00663 m_containerValueType = other.m_containerValueType; 00664 00665 return *this; 00666 } 00667 00682 TQT_DBusDataMap<T>& operator=(const TQMap<T, TQT_DBusData>& other) 00683 { 00684 TQMap<T, TQT_DBusData>::operator=(other); 00685 00686 m_valueType = TQT_DBusData::Invalid; 00687 m_containerValueType = TQT_DBusData(); 00688 00689 const_iterator it = begin(); 00690 if (it == end()) return *this; 00691 00692 m_valueType = (*it).type(); 00693 00694 TQCString containerSignature; 00695 if (hasContainerValueType()) 00696 { 00697 m_containerValueType = it.data(); 00698 containerSignature = m_containerValueType.buildDBusSignature(); 00699 } 00700 00701 for (++it; it != end(); ++it) 00702 { 00703 if ((*it).type() != m_valueType) 00704 { 00705 m_valueType = TQT_DBusData::Invalid; 00706 m_containerValueType = TQT_DBusData(); 00707 00708 clear(); 00709 return *this; 00710 } 00711 else if (hasContainerValueType()) 00712 { 00713 if (it.data()->buildSignature() != containerSignature) 00714 { 00715 m_valueType = TQT_DBusData::Invalid; 00716 m_containerValueType = TQT_DBusData(); 00717 00718 clear(); 00719 return *this; 00720 } 00721 } 00722 } 00723 00724 return *this; 00725 } 00726 00735 TQT_DBusData::Type keyType() const { return m_keyType; } 00736 00746 TQT_DBusData::Type valueType() const { return m_valueType; } 00747 00761 bool hasContainerValueType() const 00762 { 00763 return m_valueType == TQT_DBusData::List || m_valueType == TQT_DBusData::Struct 00764 || m_valueType == TQT_DBusData::Map; 00765 } 00766 00782 TQT_DBusData containerValueType() const { return m_containerValueType; } 00783 00791 inline bool isValid() const { return valueType() != TQT_DBusData::Invalid; } 00792 00800 bool isEmpty() const { return TQMap<T, TQT_DBusData>::empty(); } 00801 00809 uint count() const { return TQMap<T, TQT_DBusData>::count(); } 00810 00824 bool operator==(const TQT_DBusDataMap<T>& other) const 00825 { 00826 if (m_valueType != other.m_valueType) return false; 00827 00828 if (count() != other.count()) return false; 00829 00830 if (hasContainerValueType() != other.hasContainerValueType()) return false; 00831 00832 if (hasContainerValueType()) 00833 { 00834 if (m_containerValueType.buildDBusSignature() != 00835 other.m_containerValueType.buildDBusSignature()) return false; 00836 } 00837 00838 const_iterator it = begin(); 00839 const_iterator otherIt = other.begin(); 00840 for (; it != end() && otherIt != other.end(); ++it, ++otherIt) 00841 { 00842 if (it.key() != otherIt.key()) return false; 00843 00844 if (!(it.data() == otherIt.data())) return false; 00845 } 00846 00847 return true; 00848 } 00849 00855 void clear() { TQMap<T, TQT_DBusData>::clear(); } 00856 00862 const_iterator begin() const 00863 { 00864 return TQMap<T, TQT_DBusData>::begin(); 00865 } 00866 00872 const_iterator end() const 00873 { 00874 return TQMap<T, TQT_DBusData>::end(); 00875 } 00876 00895 bool insert(const T& key, const TQT_DBusData& data) 00896 { 00897 if (data.type() == TQT_DBusData::Invalid) return false; 00898 00899 if (m_valueType == TQT_DBusData::Invalid) 00900 { 00901 m_valueType = data.type(); 00902 00903 // TODO: create empty copy of container 00904 if (hasContainerValueType()) m_containerValueType = data; 00905 00906 TQMap<T, TQT_DBusData>::insert(key, data); 00907 } 00908 else if (data.type() != m_valueType) 00909 { 00910 tqWarning("TQT_DBusDataMap: trying to add data of type %s to map of type %s", 00911 data.typeName(), TQT_DBusData::typeName(m_valueType)); 00912 } 00913 else if (hasContainerValueType()) 00914 { 00915 TQCString ourSignature = m_containerValueType.buildDBusSignature(); 00916 TQCString dataSignature = data.buildDBusSignature(); 00917 00918 if (ourSignature != dataSignature) 00919 { 00920 tqWarning("TQT_DBusDataMap: trying to add data with signature %s " 00921 "to map with value signature %s", 00922 dataSignature.data(), ourSignature.data()); 00923 } 00924 else 00925 TQMap<T, TQT_DBusData>::insert(key, data); 00926 } 00927 else 00928 TQMap<T, TQT_DBusData>::insert(key, data); 00929 00930 return true; 00931 } 00932 00938 TQMap<T, TQT_DBusData> toTQMap() const { return *this; } 00939 00956 TQMap<T, bool> toBoolMap(bool* ok = 0) const 00957 { 00958 if (m_valueType != TQT_DBusData::Bool) 00959 { 00960 if (ok != 0) *ok = false; 00961 return TQMap<T, bool>(); 00962 } 00963 00964 TQMap<T, bool> result; 00965 00966 const_iterator it = begin(); 00967 const_iterator endIt = end(); 00968 for (; it != endIt; ++it) 00969 { 00970 result.insert(it.key(), (*it).toBool()); 00971 } 00972 00973 if (ok != 0) *ok = true; 00974 00975 return result; 00976 } 00977 00994 TQMap<T, TQ_UINT8> toByteMap(bool* ok = 0) const 00995 { 00996 if (m_valueType != TQT_DBusData::Byte) 00997 { 00998 if (ok != 0) *ok = false; 00999 return TQMap<T, TQ_UINT8>(); 01000 } 01001 01002 TQMap<T, TQ_UINT8> result; 01003 01004 const_iterator it = begin(); 01005 const_iterator endIt = end(); 01006 for (; it != endIt; ++it) 01007 { 01008 result.insert(it.key(), (*it).toByte()); 01009 } 01010 01011 if (ok != 0) *ok = true; 01012 01013 return result; 01014 } 01015 01033 TQMap<T, TQ_INT16> toInt16Map(bool* ok = 0) const 01034 { 01035 if (m_valueType != TQT_DBusData::Int16) 01036 { 01037 if (ok != 0) *ok = false; 01038 return TQMap<T, TQ_INT16>(); 01039 } 01040 01041 TQMap<T, TQ_INT16> result; 01042 01043 const_iterator it = begin(); 01044 const_iterator endIt = end(); 01045 for (; it != endIt; ++it) 01046 { 01047 result.insert(it.key(), (*it).toInt16()); 01048 } 01049 01050 if (ok != 0) *ok = true; 01051 01052 return result; 01053 } 01054 01072 TQMap<T, TQ_UINT16> toUInt16Map(bool* ok = 0) const 01073 { 01074 if (m_valueType != TQT_DBusData::UInt16) 01075 { 01076 if (ok != 0) *ok = false; 01077 return TQMap<T, TQ_UINT16>(); 01078 } 01079 01080 TQMap<T, TQ_UINT16> result; 01081 01082 const_iterator it = begin(); 01083 const_iterator endIt = end(); 01084 for (; it != endIt; ++it) 01085 { 01086 result.insert(it.key(), (*it).toUInt16()); 01087 } 01088 01089 if (ok != 0) *ok = true; 01090 01091 return result; 01092 } 01093 01111 TQMap<T, TQ_INT32> toInt32Map(bool* ok = 0) const 01112 { 01113 if (m_valueType != TQT_DBusData::Int32) 01114 { 01115 if (ok != 0) *ok = false; 01116 return TQMap<T, TQ_INT32>(); 01117 } 01118 01119 TQMap<T, TQ_INT32> result; 01120 01121 const_iterator it = begin(); 01122 const_iterator endIt = end(); 01123 for (; it != endIt; ++it) 01124 { 01125 result.insert(it.key(), (*it).toInt32()); 01126 } 01127 01128 if (ok != 0) *ok = true; 01129 01130 return result; 01131 } 01132 01150 TQMap<T, TQ_UINT32> toUInt32Map(bool* ok = 0) const 01151 { 01152 if (m_valueType != TQT_DBusData::UInt32) 01153 { 01154 if (ok != 0) *ok = false; 01155 return TQMap<T, TQ_UINT32>(); 01156 } 01157 01158 TQMap<T, TQ_UINT32> result; 01159 01160 const_iterator it = begin(); 01161 const_iterator endIt = end(); 01162 for (; it != endIt; ++it) 01163 { 01164 result.insert(it.key(), (*it).toUInt32()); 01165 } 01166 01167 if (ok != 0) *ok = true; 01168 01169 return result; 01170 } 01171 01189 TQMap<T, TQ_INT64> toInt64Map(bool* ok = 0) const 01190 { 01191 if (m_valueType != TQT_DBusData::Int64) 01192 { 01193 if (ok != 0) *ok = false; 01194 return TQMap<T, TQ_INT64>(); 01195 } 01196 01197 TQMap<T, TQ_INT64> result; 01198 01199 const_iterator it = begin(); 01200 const_iterator endIt = end(); 01201 for (; it != endIt; ++it) 01202 { 01203 result.insert(it.key(), (*it).toInt64()); 01204 } 01205 01206 if (ok != 0) *ok = true; 01207 01208 return result; 01209 } 01210 01228 TQMap<T, TQ_UINT64> toUInt64Map(bool* ok = 0) const 01229 { 01230 if (m_valueType != TQT_DBusData::UInt64) 01231 { 01232 if (ok != 0) *ok = false; 01233 return TQMap<T, TQ_UINT64>(); 01234 } 01235 01236 TQMap<T, TQ_UINT64> result; 01237 01238 const_iterator it = begin(); 01239 const_iterator endIt = end(); 01240 for (; it != endIt; ++it) 01241 { 01242 result.insert(it.key(), (*it).toUInt64()); 01243 } 01244 01245 if (ok != 0) *ok = true; 01246 01247 return result; 01248 } 01249 01266 TQMap<T, double> toDoubleMap(bool* ok = 0) const 01267 { 01268 if (m_valueType != TQT_DBusData::Double) 01269 { 01270 if (ok != 0) *ok = false; 01271 return TQMap<T, double>(); 01272 } 01273 01274 TQMap<T, double> result; 01275 01276 const_iterator it = begin(); 01277 const_iterator endIt = end(); 01278 for (; it != endIt; ++it) 01279 { 01280 result.insert(it.key(), (*it).toDouble()); 01281 } 01282 01283 if (ok != 0) *ok = true; 01284 01285 return result; 01286 } 01287 01304 TQMap<T, TQString> toStringMap(bool* ok = 0) const 01305 { 01306 if (m_valueType != TQT_DBusData::String) 01307 { 01308 if (ok != 0) *ok = false; 01309 return TQMap<T, TQString>(); 01310 } 01311 01312 TQMap<T, TQString> result; 01313 01314 const_iterator it = begin(); 01315 const_iterator endIt = end(); 01316 for (; it != endIt; ++it) 01317 { 01318 result.insert(it.key(), (*it).toString()); 01319 } 01320 01321 if (ok != 0) *ok = true; 01322 01323 return result; 01324 } 01325 01339 TQMap<T, TQT_DBusObjectPath> toObjectPathMap(bool* ok = 0) const 01340 { 01341 if (m_valueType != TQT_DBusData::ObjectPath) 01342 { 01343 if (ok != 0) *ok = false; 01344 return TQMap<T, TQT_DBusObjectPath>(); 01345 } 01346 01347 TQMap<T, TQT_DBusObjectPath> result; 01348 01349 const_iterator it = begin(); 01350 const_iterator endIt = end(); 01351 for (; it != endIt; ++it) 01352 { 01353 result.insert(it.key(), (*it).toObjectPath()); 01354 } 01355 01356 if (ok != 0) *ok = true; 01357 01358 return result; 01359 } 01360 01374 TQMap<T, TQT_DBusObjectPath> toUnixFdMap(bool* ok = 0) const 01375 { 01376 if (m_valueType != TQT_DBusData::UnixFd) 01377 { 01378 if (ok != 0) *ok = false; 01379 return TQMap<T, TQT_DBusUnixFd>(); 01380 } 01381 01382 TQMap<T, TQT_DBusUnixFd> result; 01383 01384 const_iterator it = begin(); 01385 const_iterator endIt = end(); 01386 for (; it != endIt; ++it) 01387 { 01388 result.insert(it.key(), (*it).toUnixFd()); 01389 } 01390 01391 if (ok != 0) *ok = true; 01392 01393 return result; 01394 } 01395 01412 TQMap<T, TQT_DBusVariant> toVariantMap(bool* ok = 0) const 01413 { 01414 if (m_valueType != TQT_DBusData::Variant) 01415 { 01416 if (ok != 0) *ok = false; 01417 return TQMap<T, TQT_DBusVariant>(); 01418 } 01419 01420 TQMap<T, TQT_DBusVariant> result; 01421 01422 const_iterator it = begin(); 01423 const_iterator endIt = end(); 01424 for (; it != endIt; ++it) 01425 { 01426 result.insert(it.key(), (*it).toVariant()); 01427 } 01428 01429 if (ok != 0) *ok = true; 01430 01431 return result; 01432 } 01433 01434 private: 01435 TQT_DBusData::Type m_valueType; 01436 TQT_DBusData m_containerValueType; 01437 01438 static const TQT_DBusData::Type m_keyType; 01439 }; 01440 01441 #endif