OpenBarnyard
 
Loading...
Searching...
No Matches
PBProperties Class Reference

#include <PBProperties.h>

Classes

class  PBProperty
 

Public Member Functions

 PBProperties ()
 
 PBProperties (const PBProperties &other)
 
 PBProperties (PBProperties &&other) noexcept
 
 ~PBProperties ()
 
PBPropertyBegin ()
 
PBPropertyEnd ()
 
const PBPropertyBegin () const
 
const PBPropertyEnd () const
 
const PBPropertyGetPropertyByIndex (TSIZE a_iIndex) const
 
const PBPropertyValueGetPropertyValue (TSIZE a_iIndex) const
 
const PBPropertyValueGetProperty (const TCHAR *a_szName) const
 
template<typename T>
TBOOL GetOptionalPropertyValue (T &a_rOutValue, const TCHAR *a_szName) const
 
const PBPropertiesGetParentProperties () const
 
TUINT32 GetPropertyCount () const
 
PBPropertyAddProperty (const Toshi::TString8 &a_Name, TINT a_iValue)
 
PBPropertyAddProperty (const Toshi::TString8 &a_Name, PBPropertyLocaleString a_strLocaleString)
 
PBPropertyAddPropertyBool (const Toshi::TString8 &a_Name, TBOOL a_bValue)
 
PBPropertyAddProperty (const Toshi::TString8 &a_Name, TFLOAT a_fValue)
 
PBPropertyAddProperty (const Toshi::TString8 &a_Name, TUINT32 a_uiValue)
 
PBPropertyAddProperty (const Toshi::TString8 &a_Name, const Toshi::TString8 &a_sValue)
 
PBPropertyAddProperties (const Toshi::TString8 &a_Name)
 
PBPropertyAddPropertyArray (const Toshi::TString8 &a_Name)
 

Static Public Attributes

static constexpr const TCHARTRB_SECTION_NAME = "Main"
 

Friends

class PPropertiesWriter
 

Detailed Description

Definition at line 660 of file PBProperties.h.

Constructor & Destructor Documentation

◆ PBProperties() [1/3]

PBProperties::PBProperties ( )
inline

Definition at line 804 of file PBProperties.h.

805 {
806 m_pParent = TNULL;
807 m_pProperties = TNULL;
808 m_iCount = 0;
809 }
#define TNULL
Definition Typedefs.h:23

◆ PBProperties() [2/3]

PBProperties::PBProperties ( const PBProperties & other)
inline

Definition at line 811 of file PBProperties.h.

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 }
size_t TSIZE
Definition Typedefs.h:9
PBPropertyValue * GetValue()

◆ PBProperties() [3/3]

PBProperties::PBProperties ( PBProperties && other)
inlinenoexcept

Definition at line 838 of file PBProperties.h.

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 }

◆ ~PBProperties()

PBProperties::~PBProperties ( )
inline

Definition at line 848 of file PBProperties.h.

849 {
850 Delete();
851 }

Member Function Documentation

◆ AddProperties()

PBProperty * PBProperties::AddProperties ( const Toshi::TString8 & a_Name)
inline

Definition at line 966 of file PBProperties.h.

967 {
968 PBProperties* pProperties = new PBProperties;
969 pProperties->m_pParent = this;
970
971 return AllocProperty( PBProperty( a_Name, pProperties ) );
972 }

◆ AddProperty() [1/5]

PBProperty * PBProperties::AddProperty ( const Toshi::TString8 & a_Name,
const Toshi::TString8 & a_sValue )
inline

Definition at line 961 of file PBProperties.h.

962 {
963 return AllocProperty( PBProperty( a_Name, a_sValue ) );
964 }

◆ AddProperty() [2/5]

PBProperty * PBProperties::AddProperty ( const Toshi::TString8 & a_Name,
PBPropertyLocaleString a_strLocaleString )
inline

Definition at line 941 of file PBProperties.h.

942 {
943 return AllocProperty( PBProperty( a_Name, a_strLocaleString ) );
944 }

◆ AddProperty() [3/5]

PBProperty * PBProperties::AddProperty ( const Toshi::TString8 & a_Name,
TFLOAT a_fValue )
inline

Definition at line 951 of file PBProperties.h.

952 {
953 return AllocProperty( PBProperty( a_Name, a_fValue ) );
954 }

◆ AddProperty() [4/5]

PBProperty * PBProperties::AddProperty ( const Toshi::TString8 & a_Name,
TINT a_iValue )
inline

Definition at line 936 of file PBProperties.h.

937 {
938 return AllocProperty( PBProperty( a_Name, a_iValue ) );
939 }

◆ AddProperty() [5/5]

PBProperty * PBProperties::AddProperty ( const Toshi::TString8 & a_Name,
TUINT32 a_uiValue )
inline

Definition at line 956 of file PBProperties.h.

957 {
958 return AllocProperty( PBProperty( a_Name, a_uiValue ) );
959 }

◆ AddPropertyArray()

PBProperty * PBProperties::AddPropertyArray ( const Toshi::TString8 & a_Name)
inline

Definition at line 974 of file PBProperties.h.

975 {
976 PBPropertyValueArray* pArray = new PBPropertyValueArray;
977
978 return AllocProperty( PBProperty( a_Name, pArray ) );
979 }

◆ AddPropertyBool()

PBProperty * PBProperties::AddPropertyBool ( const Toshi::TString8 & a_Name,
TBOOL a_bValue )
inline

Definition at line 946 of file PBProperties.h.

947 {
948 return AllocProperty( PBProperty( a_Name, a_bValue ) );
949 }

◆ Begin() [1/2]

PBProperty * PBProperties::Begin ( )
inline

Definition at line 853 of file PBProperties.h.

854 {
855 return m_pProperties;
856 }

◆ Begin() [2/2]

const PBProperty * PBProperties::Begin ( ) const
inline

Definition at line 863 of file PBProperties.h.

864 {
865 return m_pProperties;
866 }

◆ End() [1/2]

PBProperty * PBProperties::End ( )
inline

Definition at line 858 of file PBProperties.h.

859 {
860 return m_pProperties + m_iCount;
861 }

◆ End() [2/2]

const PBProperty * PBProperties::End ( ) const
inline

Definition at line 868 of file PBProperties.h.

869 {
870 return m_pProperties + m_iCount;
871 }

◆ GetOptionalPropertyValue()

template<typename T>
TBOOL PBProperties::GetOptionalPropertyValue ( T & a_rOutValue,
const TCHAR * a_szName ) const
inline

Definition at line 898 of file PBProperties.h.

899 {
900 const PBPropertyValue* pFoundProperty = GetProperty( a_szName );
901
902 if ( pFoundProperty && pFoundProperty->GetType() == PBPropertiesTypeCast<T>::type )
903 {
904 if constexpr ( PBPropertiesTypeCast<T>::type == PBPropertyValue::Type::Float )
905 a_rOutValue = pFoundProperty->GetFloat();
906 else if constexpr ( PBPropertiesTypeCast<T>::type == PBPropertyValue::Type::Int )
907 a_rOutValue = pFoundProperty->GetInteger();
908 else if constexpr ( PBPropertiesTypeCast<T>::type == PBPropertyValue::Type::Bool )
909 a_rOutValue = pFoundProperty->GetBoolean();
910 else if constexpr ( PBPropertiesTypeCast<T>::type == PBPropertyValue::Type::UInt32 )
911 a_rOutValue = pFoundProperty->GetUINT32();
912 else if constexpr ( PBPropertiesTypeCast<T>::type == PBPropertyValue::Type::String )
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 }
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
void * GetRaw() const
TUINT32 GetUINT32() const
TINT GetInteger() const
Type GetType() const
TBOOL GetBoolean() const
TFLOAT GetFloat() const
const TCHAR * GetString() const
const PBPropertyValue * GetProperty(const TCHAR *a_szName) const

◆ GetParentProperties()

const PBProperties * PBProperties::GetParentProperties ( ) const
inline

Definition at line 926 of file PBProperties.h.

927 {
928 return m_pParent;
929 }

◆ GetProperty()

const PBPropertyValue * PBProperties::GetProperty ( const TCHAR * a_szName) const
inline

Definition at line 884 of file PBProperties.h.

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 }

◆ GetPropertyByIndex()

const PBProperty * PBProperties::GetPropertyByIndex ( TSIZE a_iIndex) const
inline

Definition at line 873 of file PBProperties.h.

874 {
875 TASSERT( m_iCount > a_iIndex );
876 return &m_pProperties[ a_iIndex ];
877 }
#define TASSERT(X,...)
Definition Defines.h:138

◆ GetPropertyCount()

TUINT32 PBProperties::GetPropertyCount ( ) const
inline

Definition at line 931 of file PBProperties.h.

932 {
933 return m_iCount;
934 }

◆ GetPropertyValue()

const PBPropertyValue * PBProperties::GetPropertyValue ( TSIZE a_iIndex) const
inline

Definition at line 879 of file PBProperties.h.

880 {
881 return GetPropertyByIndex( a_iIndex )->GetValue();
882 }
const PBProperty * GetPropertyByIndex(TSIZE a_iIndex) const

Friends And Related Symbol Documentation

◆ PPropertiesWriter

friend class PPropertiesWriter
friend

Definition at line 799 of file PBProperties.h.

Member Data Documentation

◆ TRB_SECTION_NAME

const TCHAR* PBProperties::TRB_SECTION_NAME = "Main"
staticconstexpr

Definition at line 801 of file PBProperties.h.


The documentation for this class was generated from the following file: