OpenBarnyard
 
Loading...
Searching...
No Matches
PBProperties.h
Go to the documentation of this file.
1#pragma once
2//-----------------------------------------------------------------------------
3// This plugin allows reading PProperties from it's binary format which is used
4// in TRB files. Before bnary format was introduced in TOSHI 2.0, PProperties
5// were stored in .ini files and parsed using TFileLexer.
6// Use XML2PProperties to create TRB files from XML/JSON input and backwards.
7//-----------------------------------------------------------------------------
8
9#include "Toshi/Toshi.h"
11#include "Toshi/TString8.h"
12
14{
16 : uiIndex( -1 )
17 {}
18
19 constexpr PBPropertyLocaleString( TUINT a_uiIndex )
20 : uiIndex( a_uiIndex )
21 {}
22
24 {
25 uiIndex = a_uiIndex;
26 return *this;
27 }
28
30};
31
33{
34public:
47
48 friend class PPropertiesWriter;
49
50public:
52 {
53 m_eType = Type::Int;
54 m_uValue.Pointer = TNULL;
55 }
56
58 {
59 m_eType = Type::Int;
60 m_uValue.Int = a_iValue;
61 }
62
64 {
65 m_eType = Type::Bool;
66 m_uValue.Bool = a_bValue;
67 }
68
70 {
71 m_eType = Type::Float;
72 m_uValue.Float = a_fValue;
73 }
74
76 {
77 m_eType = Type::UInt32;
78 m_uValue.UInt32 = a_uiValue;
79 }
80
81 PBPropertyValue( const TCHAR* a_pchValue )
82 {
83 m_eType = Type::String;
84 m_uValue.String = new TCHAR[ Toshi::TStringManager::String8Length( a_pchValue ) + 1 ];
85 Toshi::TStringManager::String8Copy( m_uValue.String, a_pchValue );
86 }
87
88 PBPropertyValue( const Toshi::TString8& a_sValue )
89 {
90 m_eType = Type::String;
91 m_uValue.String = new TCHAR[ a_sValue.Length() + 1 ];
92 Toshi::TStringManager::String8Copy( m_uValue.String, a_sValue );
93 }
94
96 {
97 m_eType = Type::LocaleString;
98 m_uValue.UInt32 = a_strValue.uiIndex;
99 }
100
101 PBPropertyValue( class PBProperties* a_pProperties )
102 {
103 m_eType = Type::Properties;
104 m_uValue.Properties = a_pProperties;
105 }
106
108 {
109 m_eType = Type::Array;
110 m_uValue.Array = a_pArray;
111 }
112
113 PBPropertyValue( const PBPropertyValue& other );
114 PBPropertyValue( PBPropertyValue&& other ) noexcept;
115
117
118 Type GetType() const
119 {
120 return m_eType;
121 }
122
123 void* GetRaw() const
124 {
125 return m_uValue.Pointer;
126 }
127
129 {
130 TASSERT( m_eType == Type::Bool );
131 return m_uValue.Bool;
132 }
133
135 {
136 TASSERT( m_eType == Type::Float || m_eType == Type::Int );
137 return m_eType == Type::Float ? m_uValue.Float : TFLOAT( m_uValue.Int );
138 }
139
141 {
142 TASSERT( m_eType == Type::Int );
143 return m_uValue.Int;
144 }
145
147 {
148 TASSERT( m_eType == Type::UInt32 );
149 return m_uValue.UInt32;
150 }
151
153 {
154 TASSERT( m_eType == Type::LocaleString );
155 return m_uValue.UInt32;
156 }
157
158 const TCHAR* GetString() const
159 {
160 TASSERT( m_eType == Type::String );
161 return m_uValue.String;
162 }
163
164#ifdef __TOSHI_TPSTRING8_H__
165 Toshi::TPString8 GetTPString8() const
166 {
167 TASSERT( m_eType == Type::String );
168 return Toshi::TPString8( m_uValue.String );
169 }
170#endif
171
172 const class PBProperties* GetProperties() const
173 {
174 TASSERT( m_eType == Type::Properties );
175 return m_uValue.Properties;
176 }
177
178 const class PBPropertyValueArray* GetArray() const
179 {
180 TASSERT( m_eType == Type::Array );
181 return m_uValue.Array;
182 }
183
185 {
186 TASSERT( m_eType == Type::Properties );
187 return m_uValue.Properties;
188 }
189
191 {
192 TASSERT( m_eType == Type::Array );
193 return m_uValue.Array;
194 }
195
197 {
198 TASSERT( m_eType == Type::Bool );
199 return &m_uValue.Bool;
200 }
201
203 {
204 TASSERT( m_eType == Type::Float );
205 return &m_uValue.Float;
206 }
207
209 {
210 TASSERT( m_eType == Type::Int );
211 return &m_uValue.Int;
212 }
213
215 {
216 TASSERT( m_eType == Type::LocaleString );
217 return &m_uValue.UInt32;
218 }
219
220 void SetInt( TINT a_iValue )
221 {
222 this->operator=( a_iValue );
223 }
224
225 void SetBool( TBOOL a_bValue )
226 {
227 this->operator=( a_bValue );
228 }
229
230 void SetFloat( TFLOAT a_fValue )
231 {
232 this->operator=( a_fValue );
233 }
234
235 void SetUINT32( TUINT32 a_uiValue )
236 {
237 this->operator=( a_uiValue );
238 }
239
240 void SetString( const Toshi::TString8& a_sValue )
241 {
242 this->operator=( a_sValue );
243 }
244
246 {
247 TASSERT( m_eType == Type::Int );
248 m_uValue.Int = a_iValue;
249 return *this;
250 }
251
253 {
254 TASSERT( m_eType == Type::Bool );
255 m_uValue.Bool = a_bValue;
256 return *this;
257 }
258
260 {
261 TASSERT( m_eType == Type::Float );
262 m_uValue.Float = a_fValue;
263 return *this;
264 }
265
267 {
268 TASSERT( m_eType == Type::LocaleString );
269 m_uValue.UInt32 = a_uiValue;
270 return *this;
271 }
272
273 PBPropertyValue& operator=( const Toshi::TString8& a_sValue )
274 {
275 TASSERT( m_eType == Type::String );
276
277 Delete();
278
279 m_uValue.String = new TCHAR[ a_sValue.Length() + 1 ];
280 Toshi::TStringManager::String8Copy( m_uValue.String, a_sValue );
281 return *this;
282 }
283
285 PBPropertyValue& operator=( PBPropertyValue&& other ) noexcept;
286
287private:
288 void Delete();
289
290private:
291 Type m_eType;
292
293 union
294 {
295 void* Pointer;
303 } m_uValue;
304};
305
306class PBProperties;
308
309template <typename T>
312
313template <>
318
319template <>
324
325template <>
330
331template <>
336
337template <>
342
343template <>
348
349template <>
354
355template <>
360
361template <>
366
367template <>
372
373template <>
378
379template <>
384
385template <>
390
391template <>
396
397template <>
402
403#ifdef __TOSHI_TPSTRING8_H__
404
405template <>
407{
409};
410
411#endif // __TOSHI_TPSTRING8_H__
412
414{
415public:
416 friend class PPropertiesWriter;
417
418public:
420 {
421 m_pValues = TNULL;
422 m_iSize = 0;
423 }
424
426 {
427 if ( other.m_iSize != 0 )
428 {
429 m_pValues = new PBPropertyValue[ other.m_iSize ];
430
431 for ( TSIZE i = 0; i < other.m_iSize; i++ )
432 m_pValues[ i ] = other.m_pValues[ i ];
433 }
434 else
435 {
436 m_pValues = TNULL;
437 }
438
439 m_iSize = other.m_iSize;
440 }
441
443 {
444 m_pValues = other.m_pValues;
445 m_iSize = other.m_iSize;
446 other.m_pValues = TNULL;
447 other.m_iSize = 0;
448 }
449
451 {
452 Delete();
453 }
454
456 {
457 TASSERT( m_iSize > a_iIndex );
458 return &m_pValues[ a_iIndex ];
459 }
460
461 const PBPropertyValue* GetValue( TSIZE a_iIndex ) const
462 {
463 TASSERT( m_iSize > a_iIndex );
464 return &m_pValues[ a_iIndex ];
465 }
466
468 {
469 return m_iSize;
470 }
471
473 {
474 return AllocValue( PBPropertyValue( a_iValue ) );
475 }
476
478 {
479 return AllocValue( PBPropertyValue( a_bValue ) );
480 }
481
483 {
484 return AllocValue( PBPropertyValue( a_fValue ) );
485 }
486
488 {
489 return AllocValue( PBPropertyValue( a_uiValue ) );
490 }
491
493 {
494 return AllocValue( PBPropertyValue( a_strLocaleString ) );
495 }
496
497 PBPropertyValue* Add( const Toshi::TString8& a_sValue )
498 {
499 return AllocValue( PBPropertyValue( a_sValue ) );
500 }
501
502 PBPropertyValue* Add( const TCHAR* a_pchValue )
503 {
504 return AllocValue( PBPropertyValue( a_pchValue ) );
505 }
506
508 {
509 return GetValue( a_iIndex );
510 }
511
512 const PBPropertyValue* operator[]( TSIZE a_iIndex ) const
513 {
514 return GetValue( a_iIndex );
515 }
516
518 {
519 if ( this != &other )
520 {
521 Delete();
522
523 if ( other.m_iSize != 0 )
524 {
525 m_pValues = new PBPropertyValue[ other.m_iSize ];
526
527 for ( TSIZE i = 0; i < other.m_iSize; i++ )
528 m_pValues[ i ] = other.m_pValues[ i ];
529
530 m_iSize = other.m_iSize;
531 }
532 }
533 }
534
536 {
537 if ( this != &other )
538 {
539 Delete();
540
541 m_pValues = other.m_pValues;
542 m_iSize = other.m_iSize;
543 other.m_pValues = TNULL;
544 other.m_iSize = 0;
545 }
546 }
547
548private:
549 PBPropertyValue* AllocValue( PBPropertyValue&& a_Value )
550 {
551 if ( m_pValues != TNULL )
552 {
553 auto newValues = new PBPropertyValue[ m_iSize + 1 ];
554
555 for ( TSIZE i = 0; i < m_iSize; i++ )
556 newValues[ i ] = std::move( m_pValues[ i ] );
557
558 Delete();
559 m_pValues = newValues;
560
561 m_iSize += 1;
562 }
563 else
564 {
565 m_pValues = new PBPropertyValue[ 1 ];
566 m_iSize = 1;
567 }
568
569 m_pValues[ m_iSize - 1 ] = std::move( a_Value );
570 return &m_pValues[ m_iSize - 1 ];
571 }
572
573 void Delete()
574 {
575 if ( m_pValues )
576 delete[] m_pValues;
577 }
578
579private:
580 PBPropertyValue* m_pValues;
581 TUINT32 m_iSize;
582};
583
585{
586public:
587 friend class PPropertiesWriter;
588
589public:
591 {
592 m_szName = TNULL;
593 }
594
595 PBPropertyName( const Toshi::TString8& a_sName )
596 {
597 m_szName = new TCHAR[ a_sName.Length() + 1 ];
598 Toshi::TStringManager::String8Copy( m_szName, a_sName );
599 }
600
602 {
603 m_szName = new TCHAR[ Toshi::TStringManager::String8Length( other.m_szName ) + 1 ];
604 Toshi::TStringManager::String8Copy( m_szName, other.m_szName );
605 }
606
607 PBPropertyName( PBPropertyName&& other ) noexcept
608 {
609 m_szName = other.m_szName;
610 other.m_szName = TNULL;
611 }
612
614 {
615 Delete();
616 }
617
618 void SetName( const Toshi::TString8& a_sName )
619 {
620 Delete();
621
622 m_szName = new TCHAR[ a_sName.Length() + 1 ];
623 Toshi::TStringManager::String8Copy( m_szName, a_sName );
624 }
625
626 const TCHAR* GetString() const
627 {
628 return m_szName;
629 }
630
632 {
633 return Toshi::TStringManager::String8Compare( m_szName, a_pName->m_szName ) == 0;
634 }
635
636 TBOOL operator==( const TCHAR* a_szName ) const
637 {
638 return Toshi::TStringManager::String8Compare( m_szName, a_szName ) == 0;
639 }
640
641 PBPropertyName operator=( const Toshi::TString8& a_sName )
642 {
643 Delete();
644
645 m_szName = new TCHAR[ a_sName.Length() + 1 ];
646 Toshi::TStringManager::String8Copy( m_szName, a_sName );
647 }
648
649private:
650 void Delete()
651 {
652 if ( m_szName )
653 delete[] m_szName;
654 }
655
656private:
657 TCHAR* m_szName;
658};
659
661{
662public:
664 {
665 public:
666 friend class PPropertiesWriter;
667
668 public:
670 {
671 m_pName = TNULL;
672 m_pValue = TNULL;
673 }
674
675 PBProperty( const Toshi::TString8& a_sName, TINT a_iValue )
676 {
677 m_pName = new PBPropertyName( a_sName );
678 m_pValue = new PBPropertyValue( a_iValue );
679 }
680
681 PBProperty( const Toshi::TString8& a_sName, TBOOL a_bValue )
682 {
683 m_pName = new PBPropertyName( a_sName );
684 m_pValue = new PBPropertyValue( a_bValue );
685 }
686
687 PBProperty( const Toshi::TString8& a_sName, TFLOAT a_fValue )
688 {
689 m_pName = new PBPropertyName( a_sName );
690 m_pValue = new PBPropertyValue( a_fValue );
691 }
692
693 PBProperty( const Toshi::TString8& a_sName, TUINT32 a_uiValue )
694 {
695 m_pName = new PBPropertyName( a_sName );
696 m_pValue = new PBPropertyValue( a_uiValue );
697 }
698
699 PBProperty( const Toshi::TString8& a_sName, const Toshi::TString8& a_sValue )
700 {
701 m_pName = new PBPropertyName( a_sName );
702 m_pValue = new PBPropertyValue( a_sValue );
703 }
704
705 PBProperty( const Toshi::TString8& a_sName, PBProperties* a_pProperties )
706 {
707 m_pName = new PBPropertyName( a_sName );
708 m_pValue = new PBPropertyValue( a_pProperties );
709 }
710
711 PBProperty( const Toshi::TString8& a_sName, PBPropertyValueArray* a_pArray )
712 {
713 m_pName = new PBPropertyName( a_sName );
714 m_pValue = new PBPropertyValue( a_pArray );
715 }
716
717 PBProperty( const Toshi::TString8& a_sName, PBPropertyLocaleString a_strLocaleString )
718 {
719 m_pName = new PBPropertyName( a_sName );
720 m_pValue = new PBPropertyValue( a_strLocaleString );
721 }
722
723 PBProperty( const PBProperty& other )
724 {
725 m_pName = new PBPropertyName( *other.m_pName );
726 m_pValue = new PBPropertyValue( *other.m_pValue );
727 }
728
729 PBProperty( PBProperty&& other ) noexcept
730 {
731 m_pName = other.m_pName;
732 m_pValue = other.m_pValue;
733 other.m_pName = TNULL;
734 other.m_pValue = TNULL;
735 }
736
738 {
739 Delete();
740 }
741
743 {
744 return *m_pName;
745 }
746
748 {
749 return m_pValue;
750 }
751
752 const PBPropertyName& GetName() const
753 {
754 return *m_pName;
755 }
756
758 {
759 return m_pValue;
760 }
761
763 {
764 Delete();
765
766 m_pName = new PBPropertyName( *other.m_pName );
767 m_pValue = new PBPropertyValue( *other.m_pValue );
768
769 return *this;
770 }
771
772 PBProperty& operator=( PBProperty&& other ) noexcept
773 {
774 Delete();
775
776 m_pName = other.m_pName;
777 m_pValue = other.m_pValue;
778 other.m_pName = TNULL;
779 other.m_pValue = TNULL;
780
781 return *this;
782 }
783
784 private:
785 void Delete()
786 {
787 if ( m_pName )
788 delete m_pName;
789
790 if ( m_pValue )
791 delete m_pValue;
792 }
793
794 private:
795 PBPropertyName* m_pName;
796 PBPropertyValue* m_pValue;
797 };
798
799 friend class PPropertiesWriter;
800
801 static constexpr const TCHAR* TRB_SECTION_NAME = "Main";
802
803public:
805 {
806 m_pParent = TNULL;
807 m_pProperties = TNULL;
808 m_iCount = 0;
809 }
810
812 {
813 m_pParent = other.m_pParent;
814
815 if ( other.m_pProperties != TNULL )
816 {
817 m_pProperties = new PBProperty[ other.m_iCount ];
818
819 for ( TSIZE i = 0; i < other.m_iCount; i++ )
820 {
821 m_pProperties[ i ] = other.m_pProperties[ i ];
822 auto pValue = m_pProperties[ i ].GetValue();
823
824 if ( pValue->GetType() == PBPropertyValue::Type::Properties )
825 {
826 pValue->GetProperties()->m_pParent = this;
827 }
828 }
829 }
830 else
831 {
832 m_pProperties = other.m_pProperties;
833 }
834
835 m_iCount = other.m_iCount;
836 }
837
838 PBProperties( PBProperties&& other ) noexcept
839 {
840 m_pParent = other.m_pParent;
841 m_pProperties = other.m_pProperties;
842 m_iCount = other.m_iCount;
843 other.m_pParent = TNULL;
844 other.m_pProperties = TNULL;
845 other.m_iCount = 0;
846 }
847
849 {
850 Delete();
851 }
852
854 {
855 return m_pProperties;
856 }
857
859 {
860 return m_pProperties + m_iCount;
861 }
862
863 const PBProperty* Begin() const
864 {
865 return m_pProperties;
866 }
867
868 const PBProperty* End() const
869 {
870 return m_pProperties + m_iCount;
871 }
872
873 const PBProperty* GetPropertyByIndex( TSIZE a_iIndex ) const
874 {
875 TASSERT( m_iCount > a_iIndex );
876 return &m_pProperties[ a_iIndex ];
877 }
878
879 const PBPropertyValue* GetPropertyValue( TSIZE a_iIndex ) const
880 {
881 return GetPropertyByIndex( a_iIndex )->GetValue();
882 }
883
884 const PBPropertyValue* GetProperty( const TCHAR* a_szName ) const
885 {
886 for ( TSIZE i = 0; i < m_iCount; i++ )
887 {
888 if ( m_pProperties[ i ].GetName() == a_szName )
889 {
890 return m_pProperties[ i ].GetValue();
891 }
892 }
893
894 return TNULL;
895 }
896
897 template <typename T>
898 TBOOL GetOptionalPropertyValue( T& a_rOutValue, const TCHAR* a_szName ) const
899 {
900 const PBPropertyValue* pFoundProperty = GetProperty( a_szName );
901
902 if ( pFoundProperty && pFoundProperty->GetType() == PBPropertiesTypeCast<T>::type )
903 {
905 a_rOutValue = pFoundProperty->GetFloat();
907 a_rOutValue = pFoundProperty->GetInteger();
909 a_rOutValue = pFoundProperty->GetBoolean();
911 a_rOutValue = pFoundProperty->GetUINT32();
913 a_rOutValue = pFoundProperty->GetString();
914 else
915 {
916 void* rawValue = pFoundProperty->GetRaw();
917 a_rOutValue = *(T*)( &rawValue );
918 }
919
920 return TTRUE;
921 }
922
923 return TFALSE;
924 }
925
927 {
928 return m_pParent;
929 }
930
932 {
933 return m_iCount;
934 }
935
936 PBProperty* AddProperty( const Toshi::TString8& a_Name, TINT a_iValue )
937 {
938 return AllocProperty( PBProperty( a_Name, a_iValue ) );
939 }
940
941 PBProperty* AddProperty( const Toshi::TString8& a_Name, PBPropertyLocaleString a_strLocaleString )
942 {
943 return AllocProperty( PBProperty( a_Name, a_strLocaleString ) );
944 }
945
946 PBProperty* AddPropertyBool( const Toshi::TString8& a_Name, TBOOL a_bValue )
947 {
948 return AllocProperty( PBProperty( a_Name, a_bValue ) );
949 }
950
951 PBProperty* AddProperty( const Toshi::TString8& a_Name, TFLOAT a_fValue )
952 {
953 return AllocProperty( PBProperty( a_Name, a_fValue ) );
954 }
955
956 PBProperty* AddProperty( const Toshi::TString8& a_Name, TUINT32 a_uiValue )
957 {
958 return AllocProperty( PBProperty( a_Name, a_uiValue ) );
959 }
960
961 PBProperty* AddProperty( const Toshi::TString8& a_Name, const Toshi::TString8& a_sValue )
962 {
963 return AllocProperty( PBProperty( a_Name, a_sValue ) );
964 }
965
966 PBProperty* AddProperties( const Toshi::TString8& a_Name )
967 {
968 PBProperties* pProperties = new PBProperties;
969 pProperties->m_pParent = this;
970
971 return AllocProperty( PBProperty( a_Name, pProperties ) );
972 }
973
974 PBProperty* AddPropertyArray( const Toshi::TString8& a_Name )
975 {
977
978 return AllocProperty( PBProperty( a_Name, pArray ) );
979 }
980
981#ifdef __TOSHI_TTRB_H__
982 TFORCEINLINE static const PBProperties* LoadFromTRB( Toshi::TTRB* a_pTRB )
983 {
984 return a_pTRB->CastSymbol<PBProperties>( TRB_SECTION_NAME );
985 }
986
987 TFORCEINLINE static const PBProperties* LoadFromTRB( Toshi::TTRB& a_TRB )
988 {
989 return a_TRB.CastSymbol<PBProperties>( TRB_SECTION_NAME );
990 }
991
992 TFORCEINLINE static const PBProperties* LoadFromAsset( Toshi::TTRB* a_pTRB, const TCHAR* a_szFileName )
993 {
994 Toshi::TString8 symbolName = a_szFileName;
995 symbolName.MakeLower();
996 symbolName += "_";
997 symbolName += TRB_SECTION_NAME;
998
999 return a_pTRB->CastSymbol<PBProperties>( symbolName );
1000 }
1001
1002 TFORCEINLINE static const PBProperties* LoadFromAsset( Toshi::TTRB& a_TRB, const TCHAR* a_szFileName )
1003 {
1004 Toshi::TString8 symbolName = a_szFileName;
1005 symbolName.MakeLower();
1006 symbolName += "_";
1007 symbolName += TRB_SECTION_NAME;
1008
1009 return a_TRB.CastSymbol<PBProperties>( symbolName );
1010 }
1011#endif
1012
1013private:
1014 PBProperty* AllocProperty( PBProperty&& a_Property )
1015 {
1016 if ( m_pProperties != TNULL )
1017 {
1018 auto newProperties = new PBProperty[ m_iCount + 1 ];
1019
1020 for ( TSIZE i = 0; i < m_iCount; i++ )
1021 newProperties[ i ] = std::move( m_pProperties[ i ] );
1022
1023 Delete();
1024 m_pProperties = newProperties;
1025
1026 m_iCount += 1;
1027 }
1028 else
1029 {
1030 m_pProperties = new PBProperty[ 1 ];
1031 m_iCount = 1;
1032 }
1033
1034 m_pProperties[ m_iCount - 1 ] = std::move( a_Property );
1035 return &m_pProperties[ m_iCount - 1 ];
1036 }
1037
1038 void Delete()
1039 {
1040 if ( m_pProperties )
1041 delete[] m_pProperties;
1042 }
1043
1044private:
1045 PBProperties* m_pParent;
1046 PBProperty* m_pProperties;
1047 TUINT32 m_iCount;
1048};
1049
1050inline void PBPropertyValue::Delete()
1051{
1052 if ( m_uValue.Pointer )
1053 {
1054 if ( m_eType == Type::Array )
1055 delete m_uValue.Array;
1056 else if ( m_eType == Type::Properties )
1057 delete m_uValue.Properties;
1058 else if ( m_eType == Type::String )
1059 delete[] m_uValue.String;
1060 }
1061}
1062
1064{
1065 m_eType = other.m_eType;
1066 m_uValue.Pointer = TNULL;
1067
1068 if ( other.m_eType == Type::Array )
1069 m_uValue.Array = new PBPropertyValueArray( *other.m_uValue.Array );
1070 else if ( other.m_eType == Type::Properties )
1071 m_uValue.Properties = new PBProperties( *other.m_uValue.Properties );
1072 else if ( other.m_eType == Type::String )
1073 SetString( other.m_uValue.String );
1074 else
1075 m_uValue = other.m_uValue;
1076}
1077
1079{
1080 m_eType = other.m_eType;
1081 m_uValue.Pointer = other.m_uValue.Pointer;
1082 other.m_uValue.Pointer = TNULL;
1083}
1084
1086{
1087 Delete();
1088
1089 m_eType = other.m_eType;
1090
1091 if ( other.m_eType == Type::Array )
1092 m_uValue.Array = new PBPropertyValueArray( *other.m_uValue.Array );
1093 else if ( other.m_eType == Type::Properties )
1094 m_uValue.Properties = new PBProperties( *other.m_uValue.Properties );
1095 else if ( other.m_eType == Type::String )
1096 SetString( other.m_uValue.String );
1097 else
1098 m_uValue = other.m_uValue;
1099
1100 return *this;
1101}
1102
1104{
1105 Delete();
1106
1107 m_eType = other.m_eType;
1108 m_uValue.Pointer = other.m_uValue.Pointer;
1109 other.m_uValue.Pointer = TNULL;
1110
1111 return *this;
1112}
1113
1115{
1116 Delete();
1117}
#define TASSERT(X,...)
Definition Defines.h:138
#define TFORCEINLINE
Definition Defines.h:74
Main header file for the Toshi game engine.
Char string implementation for the Toshi engine.
uint16_t TUINT16
Definition Typedefs.h:15
unsigned int TUINT
Definition Typedefs.h:8
int16_t TINT16
Definition Typedefs.h:14
size_t TSIZE
Definition Typedefs.h:9
char TCHAR
Definition Typedefs.h:20
uint8_t TUINT8
Definition Typedefs.h:17
float TFLOAT
Definition Typedefs.h:4
#define TNULL
Definition Typedefs.h:23
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
int8_t TINT8
Definition Typedefs.h:16
constexpr PBPropertyLocaleString(TUINT a_uiIndex)
constexpr PBPropertyLocaleString()
PBPropertyLocaleString & operator=(TUINT a_uiIndex)
class PBPropertyValueArray * Array
class PBPropertyValueArray * GetArray()
TBOOL * GetBooleanPointer()
PBPropertyValue & operator=(TBOOL a_bValue)
const class PBProperties * GetProperties() const
PBPropertyValue(TBOOL a_bValue)
void SetInt(TINT a_iValue)
TFLOAT * GetFloatPointer()
TUINT32 * GetUINT32Pointer()
PBPropertyValue & operator=(TUINT32 a_uiValue)
PBPropertyValue(TINT a_iValue)
PBPropertyValue(PBPropertyLocaleString a_strValue)
PBPropertyValue & operator=(TFLOAT a_fValue)
PBPropertyValue(class PBPropertyValueArray *a_pArray)
void * GetRaw() const
PBPropertyValue(TUINT32 a_uiValue)
void SetString(const Toshi::TString8 &a_sValue)
PBPropertyLocaleString GetLocaleString() const
const class PBPropertyValueArray * GetArray() const
PBPropertyValue(const Toshi::TString8 &a_sValue)
TUINT32 GetUINT32() const
void SetBool(TBOOL a_bValue)
TINT GetInteger() const
friend class PPropertiesWriter
void SetFloat(TFLOAT a_fValue)
class PBProperties * Properties
PBPropertyValue & operator=(TINT a_iValue)
Type GetType() const
PBPropertyValue(const TCHAR *a_pchValue)
void SetUINT32(TUINT32 a_uiValue)
TBOOL GetBoolean() const
PBPropertyValue & operator=(const Toshi::TString8 &a_sValue)
TINT * GetIntegerPointer()
TFLOAT GetFloat() const
PBPropertyValue(class PBProperties *a_pProperties)
PBPropertyValue(TFLOAT a_fValue)
const TCHAR * GetString() const
class PBProperties * GetProperties()
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
static constexpr PBPropertyValue::Type type
PBPropertyValue * GetValue(TSIZE a_iIndex)
PBPropertyValueArray(PBPropertyValueArray &&other) noexcept
PBPropertyValue * Add(const TCHAR *a_pchValue)
PBPropertyValueArray & operator=(PBPropertyValueArray &&other) noexcept
PBPropertyValue * Add(TINT a_iValue)
TUINT32 GetSize() const
friend class PPropertiesWriter
PBPropertyValue * Add(TFLOAT a_fValue)
PBPropertyValue * operator[](TSIZE a_iIndex)
PBPropertyValue * Add(const Toshi::TString8 &a_sValue)
PBPropertyValue * Add(TBOOL a_bValue)
PBPropertyValueArray & operator=(const PBPropertyValueArray &other)
const PBPropertyValue * GetValue(TSIZE a_iIndex) const
const PBPropertyValue * operator[](TSIZE a_iIndex) const
PBPropertyValueArray(const PBPropertyValueArray &other)
PBPropertyValue * Add(TUINT32 a_uiValue)
PBPropertyValue * Add(PBPropertyLocaleString a_strLocaleString)
void SetName(const Toshi::TString8 &a_sName)
const TCHAR * GetString() const
PBPropertyName(const Toshi::TString8 &a_sName)
TBOOL operator==(PBPropertyName *a_pName) const
PBPropertyName operator=(const Toshi::TString8 &a_sName)
PBPropertyName(PBPropertyName &&other) noexcept
friend class PPropertiesWriter
TBOOL operator==(const TCHAR *a_szName) const
PBPropertyName(const PBPropertyName &other)
const PBProperties * GetParentProperties() const
PBProperty * AddPropertyBool(const Toshi::TString8 &a_Name, TBOOL a_bValue)
PBProperty * AddPropertyArray(const Toshi::TString8 &a_Name)
TUINT32 GetPropertyCount() const
PBProperty * AddProperty(const Toshi::TString8 &a_Name, TINT a_iValue)
PBProperty * Begin()
static constexpr const TCHAR * TRB_SECTION_NAME
PBProperties(PBProperties &&other) noexcept
PBProperty * AddProperty(const Toshi::TString8 &a_Name, TFLOAT a_fValue)
PBProperty * AddProperty(const Toshi::TString8 &a_Name, PBPropertyLocaleString a_strLocaleString)
PBProperties(const PBProperties &other)
PBProperty * AddProperty(const Toshi::TString8 &a_Name, TUINT32 a_uiValue)
const PBPropertyValue * GetPropertyValue(TSIZE a_iIndex) const
PBProperty * End()
const PBProperty * Begin() const
friend class PPropertiesWriter
const PBProperty * End() const
const PBPropertyValue * GetProperty(const TCHAR *a_szName) const
PBProperty * AddProperty(const Toshi::TString8 &a_Name, const Toshi::TString8 &a_sValue)
PBProperty * AddProperties(const Toshi::TString8 &a_Name)
TBOOL GetOptionalPropertyValue(T &a_rOutValue, const TCHAR *a_szName) const
const PBProperty * GetPropertyByIndex(TSIZE a_iIndex) const
PBProperty & operator=(const PBProperty &other)
PBProperty(const Toshi::TString8 &a_sName, TBOOL a_bValue)
PBProperty & operator=(PBProperty &&other) noexcept
PBProperty(const Toshi::TString8 &a_sName, const Toshi::TString8 &a_sValue)
const PBPropertyValue * GetValue() const
PBProperty(const PBProperty &other)
PBProperty(const Toshi::TString8 &a_sName, TFLOAT a_fValue)
PBProperty(const Toshi::TString8 &a_sName, TUINT32 a_uiValue)
PBPropertyValue * GetValue()
PBProperty(const Toshi::TString8 &a_sName, TINT a_iValue)
friend class PPropertiesWriter
PBProperty(const Toshi::TString8 &a_sName, PBProperties *a_pProperties)
const PBPropertyName & GetName() const
PBPropertyName & GetName()
PBProperty(const Toshi::TString8 &a_sName, PBPropertyLocaleString a_strLocaleString)
PBProperty(const Toshi::TString8 &a_sName, PBPropertyValueArray *a_pArray)
PBProperty(PBProperty &&other) noexcept