summaryrefslogtreecommitdiffstats
path: root/src/tqdbusdata.h
blob: ae647062341e8c42f54027f132eabb6e91008f96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
/* qdbusdata.h DBUS data transport type
 *
 * Copyright (C) 2007 Kevin Krammer <kevin.krammer@gmx.at>
 *
 * Licensed under the Academic Free License version 2.1
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 * USA.
 *
 */

#ifndef TQDBUSDATA_H
#define TQDBUSDATA_H

#include "tqdbusmacros.h"
#include <tqglobal.h>

class TQCString;
class TQT_DBusDataList;
class TQT_DBusVariant;
class TQT_DBusObjectPath;
class TQT_DBusUnixFd;
class TQString;

template<typename T> class TQValueList;
template<typename T> class TQT_DBusDataMap;

/**
 * @brief Class for accurately representing D-Bus data types
 *
 * The TQT_DBusData class can be compared to TQt's TQVariant class, but
 * specialized to contain data types used in D-Bus messages.
 *
 * Like TQVariant objects of TQT_DBusData use implicit sharing, i.e. copying
 * a TQT_DBusData object is a cheap operation and does not require that the
 * content itself is copied.
 *
 * Depending on the #Type of the object, the content can be a recursive
 * construct of TQT_DBusData objects, e.g. a #List can contain elements that are
 * containers themselves, e.g. #Map, #Struct, #Variant or even #List again.
 *
 * @see TQT_DBusDataList
 * @see TQT_DBusDataMap
 * @see TQT_DBusDataConverter
 */
class TQDBUS_EXPORT TQT_DBusData
{
public:
    /**
     * @brief Enum for the data types used in D-Bus messages
     *
     * In order to provide correct mapping of C++ and TQt types and the data
     * types used in D-Bus messages, TQT_DBusData uses explicit naming of types
     * where the name is usually the one used in D-Bus, with the exception of
     * #List and #Map since this is closer to the TQt container they are
     * implemented with (TQValueList and TQMap respectively)
     *
     * @see type(), keyType()
     * @see typeName()
     */
    enum Type
    {
        /**
         * Base type for TQT_DBusData objects created by the default constructor.
         *
         * Also used as the type of returned objects when getter type methods
         * fail due to type incompatabilties, i.e. toInt32() called on a #List
         * object.
         *
         * @see isValid()
         */
        Invalid = 0,

        /**
         * Type when encapsulating a boolean value.
         *
         * @see fromBool(), toBool()
         */
        Bool,

        /**
         * Type when encapsulating a byte (unsigned char) value.
         *
         * @see fromByte(), toByte()
         */
        Byte,

        /**
         * Type when encapsulating a signed 16-bit integer value.
         *
         * @see fromInt16(), toInt16()
         */
        Int16,

        /**
         * Type when encapsulating an unsigned 16-bit integer value.
         *
         * @see fromUInt16(), toUInt16()
         */
        UInt16,

        /**
         * Type when encapsulating a signed 32-bit integer value.
         *
         * @see fromInt32(), toInt32()
         */
        Int32,

        /**
         * Type when encapsulating an unsigned 32-bit integer value.
         *
         * @see fromUInt32(), toUInt32()
         */
        UInt32,

        /**
         * Type when encapsulating a signed 64-bit integer value.
         *
         * @see fromInt64(), toInt64()
         */
        Int64,

        /**
         * Type when encapsulating an unsigned 64-bit integer value.
         *
         * @see fromUInt64(), toUInt64()
         */
        UInt64,

        /**
         * Type when encapsulating a double value.
         *
         * @see fromDouble(), toDouble()
         */
        Double,

        /**
         * Type when encapsulating a string value.
         *
         * All strings are converted to UTF-8 during transmission
         *
         * @see fromString(), toString()
         */
        String,

        /**
         * Type when encapsulating a D-Bus object path.
         *
         * D-Bus defines a special string variation for transporting the
         * paths used to address objects within D-Bus services, see
         * @ref dbusconventions-objectpath for formatting details.
         *
         * @note from the point of view of this bindings an object path is
         *       pretty much a normal string with externally checked restrictions.
         *       However, method calls or return values can require a signature
         *       to include an object path and any remote peer might then reject
         *       the normal string signature.
         *
         * @see fromObjectPath(), toObjectPath()
         */
        ObjectPath,

        /**
         * Type when encapsulating a D-Bus unix file handle.
         *
         * @see fromUnixFd(), toUnixFd()
         */
        UnixFd,

        /**
         * Type when encapsulating a list of values.
         *
         * The D-Bus type this maps to is called @c array but since the TQt
         * container class used to implement this type is TQValueList (or rather
         * TQT_DBusDataList), the TQT_DBusData type is called @c List instead.
         *
         * A list can contain any of the supported types as elements, even
         * container types.
         * However it can only contain elements with the same type per list
         * object.
         *
         * @see fromList(), toList()
         */
        List,

        /**
         * Type when encapsulating a struct of values.
         *
         * A struct is basically a list of struct member variables, each
         * member can be any of the supported types, even containers types.
         *
         * The C++/TQt value type used in the converter methods is a TQValueList
         * with type TQT_DBusData.
         * For example a TQRect could be mapped like this:
         * @code
         * TQRect rect(0, 0, 640, 480);
         * TQValueList<TQT_DBusData> memberList;
         *
         * memberList << TQT_DBusData::fromInt32(rect.x());
         * memberList << TQT_DBusData::fromInt32(rect.y());
         * memberList << TQT_DBusData::fromInt32(rect.width());
         * memberList << TQT_DBusData::fromInt32(rect.height());
         *
         * TQT_DBusData data = TQT_DBusData:fromStruct(memberList);
         * @endcode
         *
         * And reconstructed like this:
         * @code
         * memberList = data.toStruct();
         *
         * int x = memberList[0].toInt32();
         * int y = memberList[1].toInt32();
         * int w = memberList[2].toInt32();
         * int h = memberList[3].toInt32();
         *
         * rect = TQRect(x, y, w, h);
         * @endcode
         *
         * @note Empty structs, i.e. an empty member list, are not allowed
         *
         * @see fromStruct(), toStruct()
         * @see TQT_DBusDataConverter
         */
        Struct,

        /**
         * Type when encapsulating a special variable container value.
         *
         * See TQT_DBusVariant for details on variant usage.
         *
         * @see fromVariant(), toVariant()
         */
        Variant,

        /**
         * Type when encapsulating a map of keys to values.
         *
         * The D-Bus type this maps to is called @c dict but since the TQt
         * container class used to implement this type is TQMap (or rather
         * TQT_DBusDataMap), the TQT_DBusData type is called @c Map instead.
         *
         * A map can contain any of the supported types as values, even
         * container types, but only the following basic types as keys:
         * - #Byte
         * - #Int16
         * - #UInt16
         * - #Int32
         * - #UInt32
         * - #Int64
         * - #UInt64
         * - #String
         * - #ObjectPath
         * - #UnixFd
         *
         * All values need to be of the same type.
         *
         * @see fromByteKeyMap(), toByteKeyMap()
         * @see fromInt16KeyMap(), toInt16KeyMap()
         * @see fromUInt16KeyMap(), toUInt16KeyMap()
         * @see fromInt32KeyMap(), toInt32KeyMap()
         * @see fromUInt32KeyMap(), toUInt32KeyMap()
         * @see fromInt64KeyMap(), toInt64KeyMap()
         * @see fromUInt64KeyMap(), toUInt64KeyMap()
         * @see fromStringKeyMap(), toStringKeyMap()
         * @see fromObjectPathKeyMap(), toObjectPathKeyMap()
         * @see fromUnixFdKeyMap(), toUnixFdKeyMap()
         */
        Map
    };

    /**
     * @brief Creates an empty, #Invalid data object
     */
    TQT_DBusData();

    /**
     * @brief Copies a given @p other data object
     *
     * Since TQT_DBusData is implicitly shared, both objects will have the
     * same content and the last object to reference it will delete it.
     *
     * @param other the object to copy
     */
    TQT_DBusData(const TQT_DBusData& other);

    /**
     * @brief Destroys the data object
     *
     * If this is the last instance to a shared content, it will delete it
     * as well.
     */
    ~TQT_DBusData();

    /**
     * @brief Copies a given @p other data object
     *
     * Since TQT_DBusData is implicitly shared, both objects will have the
     * same content and the last object to reference it will delete it.
     *
     * @param other the object to copy
     *
     * @return a reference to this instance
     */
    TQT_DBusData& operator=(const TQT_DBusData& other);

    /**
     * @brief Checks if the given @p other data object is equal to this instance
     *
     * Two TQT_DBusData object are considered equal if they reference the same
     * shared content or have the same type and the content's equality operator
     * says the contents are equal.
     *
     * @param other the object to compare with
     *
     * @return @c true if the two data objects are equal, otherwise @c false
     */
    bool operator==(const TQT_DBusData& other) const;

    /**
     * @brief Checks if the given @p other data object is different from this instance
     *
     * @param other the object to compare with
     *
     * @return @c false if the two data objects are not equal, otherwise @c false
     *
     * @see operator==()
     */
    bool operator!=(const TQT_DBusData& other) const;

    /**
     * @brief Checks whether the data object contains a valid content
     *
     * This is equal to checking type() for not being #Invalid
     *
     * @return @c true if the data object is valid, otherwise @c false
     */
    inline bool isValid() const { return type() != TQT_DBusData::Invalid; }

    /**
     * @brief Returns the #Type of the data object
     *
     * @return one of the values of the #Type enum
     *
     * @see keyType()
     * @see typeName()
     */
    Type type() const;

    /**
     * @brief Returns the #Type of the key type for maps
     *
     * If the type of the data object is #Map, this method returns the type
     * of the map's key, #String for a TQT_DBusDataMap<TQString>
     *
     * If the type of the data object is not #Map, it will return #Invalid
     *
     * @return one of the values of the #Type enum, #Invalid if the object is
     *         not holding a #Map
     *
     * @see type()
     * @see typeName()
     */
    Type keyType() const;

    /**
     * @brief Returns the string representation of the object's #Type
     *
     * @return an ASCII C-string for the object's type
     *
     * @see type()
     * @see typeName(Type)
     */
    inline const char* typeName() const { return typeName(type()); }

    /**
     * @brief Returns the string representation for the given @p type
     *
     * @param type the #Type to get the string representation for
     *
     * @return an ASCII C-string for the given @p type
     *
     * @see type()
     * @see typeName()
     */
    static const char* typeName(Type type);

    /**
     * @brief Creates a data object for the given boolean @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #Bool containing the @p value
     *
     * @see toBool()
     */
    static TQT_DBusData fromBool(bool value);

    /**
     * @brief Tries to get the encapsulated boolean value
     *
     * If the data object is not of type #Bool this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Bool)
     *
     * @return the encapsulated boolean value or @c false if it fails
     *
     * @see fromBool()
     */
    bool toBool(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given byte (unsigned char) @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #Byte containing the @p value
     *
     * @see toByte()
     */
    static TQT_DBusData fromByte(TQ_UINT8 value);

    /**
     * @brief Tries to get the encapsulated byte (unsigned char) value
     *
     * If the data object is not of type #Byte this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Byte)
     *
     * @return the encapsulated byte (unsigned char) value or @c 0 if it fails
     *
     * @see fromByte()
     */
    TQ_UINT8 toByte(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given signed 16-bit integer @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #Int16 containing the @p value
     *
     * @see toInt16()
     */
    static TQT_DBusData fromInt16(TQ_INT16 value);

    /**
     * @brief Tries to get the encapsulated signed 16-bit integer value
     *
     * If the data object is not of type #Int16 this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Int16)
     *
     * @return the encapsulated signed 16-bit integer value or @c 0 if it fails
     *
     * @see fromInt16()
     */
    TQ_INT16 toInt16(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given unsigned 16-bit integer @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #UInt16 containing the @p value
     *
     * @see toUInt16()
     */
    static TQT_DBusData fromUInt16(TQ_UINT16 value);

    /**
     * @brief Tries to get the encapsulated unsigned 16-bit integer value
     *
     * If the data object is not of type #UInt16 this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #UInt16)
     *
     * @return the encapsulated unsigned 16-bit integer value or @c 0 if it fails
     *
     * @see fromUInt16()
     */
    TQ_UINT16 toUInt16(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given signed 32-bit integer @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #Int32 containing the @p value
     *
     * @see toInt32()
     */
    static TQT_DBusData fromInt32(TQ_INT32 value);

    /**
     * @brief Tries to get the encapsulated signed 32-bit integer value
     *
     * If the data object is not of type #Int32 this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Int32)
     *
     * @return the encapsulated signed 32-bit integer value or @c 0 if it fails
     *
     * @see fromInt32()
     */
    TQ_INT32 toInt32(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given unsigned 32-bit integer @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #UInt32 containing the @p value
     *
     * @see toUInt32()
     */
    static TQT_DBusData fromUInt32(TQ_UINT32 value);

    /**
     * @brief Tries to get the encapsulated unsigned 32-bit integer value
     *
     * If the data object is not of type #UInt32 this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #UInt32)
     *
     * @return the encapsulated unsigned 32-bit integer value or @c 0 if it fails
     *
     * @see fromUInt32()
     */
    TQ_UINT32 toUInt32(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given signed 64-bit integer @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #Int64 containing the @p value
     *
     * @see toInt64()
     */
    static TQT_DBusData fromInt64(TQ_INT64 value);

    /**
     * @brief Tries to get the encapsulated signed 64-bit integer value
     *
     * If the data object is not of type #Int64 this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Int64)
     *
     * @return the encapsulated signed 64-bit integer value or @c 0 if it fails
     *
     * @see fromInt64()
     */
    TQ_INT64 toInt64(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given unsigned 64-bit integer @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #UInt64 containing the @p value
     *
     * @see toUInt64()
     */
    static TQT_DBusData fromUInt64(TQ_UINT64 value);

    /**
     * @brief Tries to get the encapsulated unsigned 64-bit integer value
     *
     * If the data object is not of type #UInt64 this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #UInt64)
     *
     * @return the encapsulated unsigned 64-bit integer value or @c 0 if it fails
     *
     * @see fromUInt64()
     */
    TQ_UINT64 toUInt64(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given double @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #Double containing the @p value
     *
     * @see toDouble()
     */
    static TQT_DBusData fromDouble(double value);

    /**
     * @brief Tries to get the encapsulated double value
     *
     * If the data object is not of type #Double this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Double)
     *
     * @return the encapsulated double value or @c 0.0 if it fails
     *
     * @see fromDouble()
     */
    double toDouble(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given string @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #String containing the @p value
     *
     * @see toString()
     */
    static TQT_DBusData fromString(const TQString& value);

    /**
     * @brief Tries to get the encapsulated string value
     *
     * If the data object is not of type #String this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #String)
     *
     * @return the encapsulated string value or @c TQString() if it fails
     *
     * @see fromString()
     */
    TQString toString(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given object path @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #ObjectPath containing the @p value
     *
     * @see toObjectPath()
     */
    static TQT_DBusData fromObjectPath(const TQT_DBusObjectPath& value);

    /**
     * @brief Tries to get the encapsulated object path value
     *
     * If the data object is not of type #ObjectPath this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #ObjectPath)
     *
     * @return the encapsulated object path value or an empty and invalid object
     *         if it fails
     *
     * @see fromObjectPath()
     */
    TQT_DBusObjectPath toObjectPath(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given unix file handle @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #UnixFd containing the @p value
     *
     * @see toUnixFd()
     */
    static TQT_DBusData fromUnixFd(const TQT_DBusUnixFd& value);

    /**
     * @brief Tries to get the encapsulated unix file handle value
     *
     * If the data object is not of type #UnixFd this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #UnixFd)
     *
     * @return the encapsulated object path value or an empty and invalid object
     *         if it fails
     *
     * @see fromUnixFd()
     */
    TQT_DBusUnixFd toUnixFd(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p list
     *
     * \note The list is allowed to be empty but is required to have a valid type
     *
     * Unless the list the is empty, the convenience method fromTQValueList() will
     * usually be easier to use since it does not require to create a
     * TQT_DBusDataList first. For empty lists this method has to be used to
     * make sure there is sufficient type information on the list's elements
     * available for the binding's marshalling code.
     *
     * @param list the list to encapsulate
     *
     * @return a data object of type #List containing the @p list or
     *         an #Invalid object if the list's type is #Invalid
     *
     * @see toList()
     */
    static TQT_DBusData fromList(const TQT_DBusDataList& list);

    /**
     * @brief Tries to get the encapsulated list
     *
     * If the data object is not of type #List this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #List)
     *
     * @return the encapsulated list or an empty and #Invalid list if it fails
     *
     * @see fromList()
     */
    TQT_DBusDataList toList(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p list
     *
     * @warning All elements of the list have to be of the same #Type
     *
     * Convenience overload for fromList(), usually more straight forward to use
     * because it doesn't require to create a TQT_DBusDataList object first,
     * however it can only handle lists which contain elements, for empty lists
     * fromList() is the only option.
     *
     * @param list the list to encapsulate
     *
     * @return a data object of type #List containing the @p list or
     *         an #Invalid object if the list is empty or if elements have
     *         different types.
     *
     * @see toTQValueList()
     */
    static TQT_DBusData fromTQValueList(const TQValueList<TQT_DBusData>& list);

    /**
     * @brief Tries to get the encapsulated list
     *
     * Convenience overload for toList().
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #List)
     *
     * @return the encapsulated list or an empty and #Invalid list if it fails
     *
     * @see fromTQValueList()
     */
    TQValueList<TQT_DBusData> toTQValueList(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given struct's @p memberList
     *
     * See the documentation of #Struct for an example.
     *
     * @param memberList the list of already encapsulated struct members
     *
     * @return a data object of type #Struct containing the @p memberList
     *
     * @see toStruct()
     */
    static TQT_DBusData fromStruct(const TQValueList<TQT_DBusData>& memberList);

    /**
     * @brief Tries to get the encapsulated struct memberList
     *
     * If the data object is not of type #Struct this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * See the documentation of #Struct for an example.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Struct)
     *
     * @return the encapsulated memberList or an empty list if it fails
     *
     * @see fromStruct()
     */
    TQValueList<TQT_DBusData> toStruct(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given variant @p value
     *
     * @param value the value to encapsulate
     *
     * @return a data object of type #Variant containing the @p value
     *
     * @see toVariant()
     */
    static TQT_DBusData fromVariant(const TQT_DBusVariant& value);

    /**
     * @brief Tries to get the encapsulated variant value
     *
     * If the data object is not of type #Variant this will fail, i.e.
     * the parameter @p ok will be set to @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Variant)
     *
     * @return the encapsulated variant value or an empty variant if it fails
     *
     * @see fromVariant()
     */
    TQT_DBusVariant toVariant(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #Byte.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toByteKeyMap()
     */
    static TQT_DBusData fromByteKeyMap(const TQT_DBusDataMap<TQ_UINT8>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not #Byte
     * this will fail, i.e. the parameter @p ok will be set to @c false if
     * present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #Byte)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromByteKeyMap()
     */
    TQT_DBusDataMap<TQ_UINT8> toByteKeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #Int16.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toInt16KeyMap()
     */
    static TQT_DBusData fromInt16KeyMap(const TQT_DBusDataMap<TQ_INT16>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not #Int16
     * this will fail, i.e. the parameter @p ok will be set to @c false if
     * present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #Int16)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromInt16KeyMap()
     */
    TQT_DBusDataMap<TQ_INT16> toInt16KeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #UInt16.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toUInt16KeyMap()
     */
    static TQT_DBusData fromUInt16KeyMap(const TQT_DBusDataMap<TQ_UINT16>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not #UInt16
     * this will fail, i.e. the parameter @p ok will be set to @c false if
     * present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #UInt16)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromUInt16KeyMap()
     */
    TQT_DBusDataMap<TQ_UINT16> toUInt16KeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #Int32.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toInt32KeyMap()
     */
    static TQT_DBusData fromInt32KeyMap(const TQT_DBusDataMap<TQ_INT32>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not #Int32
     * this will fail, i.e. the parameter @p ok will be set to @c false if
     * present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #Int32)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromInt32KeyMap()
     */
    TQT_DBusDataMap<TQ_INT32> toInt32KeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #UInt32.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toUInt32KeyMap()
     */
    static TQT_DBusData fromUInt32KeyMap(const TQT_DBusDataMap<TQ_UINT32>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not #UInt32
     * this will fail, i.e. the parameter @p ok will be set to @c false if
     * present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #UInt32)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromUInt32KeyMap()
     */
    TQT_DBusDataMap<TQ_UINT32> toUInt32KeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #Int64.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toInt64KeyMap()
     */
    static TQT_DBusData fromInt64KeyMap(const TQT_DBusDataMap<TQ_INT64>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not #Int64
     * this will fail, i.e. the parameter @p ok will be set to @c false if
     * present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #Int64)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromInt64KeyMap()
     */
    TQT_DBusDataMap<TQ_INT64> toInt64KeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #UInt64.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toUInt64KeyMap()
     */
    static TQT_DBusData fromUInt64KeyMap(const TQT_DBusDataMap<TQ_UINT64>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not #UInt64
     * this will fail, i.e. the parameter @p ok will be set to @c false if
     * present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #UInt64)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromUInt64KeyMap()
     */
    TQT_DBusDataMap<TQ_UINT64> toUInt64KeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #String.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toStringKeyMap()
     */
    static TQT_DBusData fromStringKeyMap(const TQT_DBusDataMap<TQString>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not #String
     * this will fail, i.e. the parameter @p ok will be set to @c false if
     * present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #String)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromStringKeyMap()
     */
    TQT_DBusDataMap<TQString> toStringKeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #ObjectPath.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toObjectPathKeyMap()
     */
    static TQT_DBusData fromObjectPathKeyMap(const TQT_DBusDataMap<TQT_DBusObjectPath>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not
     * #ObjectPath this will fail, i.e. the parameter @p ok will be set to
     * @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #ObjectPath)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromObjectPathKeyMap()
     */
    TQT_DBusDataMap<TQT_DBusObjectPath> toObjectPathKeyMap(bool* ok = 0) const;

    /**
     * @brief Creates a data object for the given @p map
     *
     * \note The map is allowed to be empty but is required to have a valid
     *       value type
     *
     * The resulting data object will have the keyType() set to #UnixFd.
     *
     * @param map the map to encapsulate
     *
     * @return a data object of type #Map containing the @p map or
     *         an #Invalid object if the map's value type is #Invalid
     *
     * @see toUnixFdhKeyMap()
     */
    static TQT_DBusData fromUnixFdKeyMap(const TQT_DBusDataMap<TQT_DBusUnixFd>& map);

    /**
     * @brief Tries to get the encapsulated map
     *
     * If the data object is not of type #Map or if its value type is not
     * #UnixFd this will fail, i.e. the parameter @p ok will be set to
     * @c false if present.
     *
     * @param ok optional pointer to a bool variable to store the
     *        success information in, i.e. will be set to @c true on success
     *        and to @c false if the conversion failed (not of type #Map or
     *        value type not #UnixFd)
     *
     * @return the encapsulated map or an empty and #Invalid map if it fails
     *
     * @see fromUnixFdKeyMap()
     */
    TQT_DBusDataMap<TQT_DBusUnixFd> toUnixFdKeyMap(bool* ok = 0) const;

    /**
     * @brief Creates the data objects D-Bus signature
     *
     * Recursivly builds the D-Bus signature of the data object if it holds a
     * container type, i.e. if the object is of type #List, #Map or #Struct
     *
     * This can be used to create a signature for TQT_DBusVariant when creating one
     * for sending over D-Bus.
     *
     * @return a string containing the content's signature, or a null string
     *         if the data object is #Invalid
     */
    TQCString buildDBusSignature() const;

private:
    class Private;
    Private* d;
};

#endif