// PopulateProperty //------------------------------------------------------------------------------ bool Function::PopulateProperty( NodeGraph & nodeGraph, const BFFIterator & iter, void * base, const ReflectedProperty & property, const BFFVariable * variable ) const { // Handle missing but required if ( variable == nullptr ) { const bool required = ( property.HasMetaData< Meta_Optional >() == nullptr ); if ( required ) { Error::Error_1101_MissingProperty( iter, this, AStackString<>( property.GetName() ) ); return false; } return true; // missing but not required } const PropertyType pt = property.GetType(); switch ( pt ) { case PT_ASTRING: { if ( property.IsArray() ) { return PopulateArrayOfStrings( nodeGraph, iter, base, property, variable ); } else { return PopulateString( nodeGraph, iter, base, property, variable ); } } case PT_BOOL: { return PopulateBool( iter, base, property, variable ); } case PT_UINT32: { return PopulateUInt32( iter, base, property, variable ); } case PT_STRUCT: { if ( property.IsArray() ) { return PopulateArrayOfStructs( nodeGraph, iter, base, property, variable ); } } default: { break; } } ASSERT( false ); // Unsupported type return false; }
// PopulateUInt32 //------------------------------------------------------------------------------ bool Function::PopulateUInt32( const BFFIterator & iter, void * base, const ReflectedProperty & property, const BFFVariable * variable ) const { if ( variable->IsInt() ) { const int32_t value = variable->GetInt(); // Check range const Meta_Range * rangeMD = property.HasMetaData< Meta_Range >(); if ( rangeMD ) { if ( ( value < rangeMD->GetMin() ) || ( value > rangeMD->GetMax() ) ) { Error::Error_1054_IntegerOutOfRange( iter, this, variable->GetName().Get(), rangeMD->GetMin(), rangeMD->GetMax() ); return false; } } // Int32 to UInt32 property.SetProperty( base, (uint32_t)value ); return true; } Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), variable->GetType(), BFFVariable::VAR_INT ); return false; }
// PopulateString //------------------------------------------------------------------------------ bool Function::PopulateString( const BFFIterator & iter, void * base, const ReflectedProperty & property, const BFFVariable * variable ) const { Array< AString > strings; if ( !PopulateStringHelper( iter, property.HasMetaData< Meta_Path >(), property.HasMetaData< Meta_File >(), variable, strings ) ) { return false; // PopulateStringHelper will have emitted an error } if ( variable->IsString() ) { // Handle empty strings if ( strings.IsEmpty() || strings[0].IsEmpty() ) { Error::Error_1004_EmptyStringPropertyNotAllowed( iter, this, variable->GetName().Get() ); return false; } if ( strings.GetSize() != 1 ) { Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), BFFVariable::VAR_ARRAY_OF_STRINGS, BFFVariable::VAR_STRING ); return false; } // String to String property.SetProperty( base, strings[0] ); return true; } Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), variable->GetType(), BFFVariable::VAR_STRING ); return false; }
bool Function::PopulateString( const BFFIterator & iter, Node * node, const ReflectedProperty & property, const BFFVariable * variable ) const { if ( variable->IsString() ) { // Handle empty strings if ( variable->GetString().IsEmpty() ) { Error::Error_1004_EmptyStringPropertyNotAllowed( iter, this, variable->GetName().Get() ); return false; } AStackString<> string( variable->GetString() ); // Path/File fixup needed? if ( !PopulatePathAndFileHelper( iter, property.HasMetaData< Meta_Path >(), property.HasMetaData< Meta_File >(), variable->GetName(), variable->GetString(), string ) ) { return false; } // String to String property.SetProperty( node, string ); return true; } Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), variable->GetType(), BFFVariable::VAR_STRING ); return false; }
// PopulateArrayOfStrings //------------------------------------------------------------------------------ bool Function::PopulateArrayOfStrings( const BFFIterator & iter, void * base, const ReflectedProperty & property, const BFFVariable * variable ) const { Array< AString > strings; if ( !PopulateStringHelper( iter, property.HasMetaData< Meta_Path >(), property.HasMetaData< Meta_File >(), variable, strings ) ) { return false; // PopulateStringHelper will have emitted an error } property.SetProperty( base, strings ); return true; }
// PopulateBool //------------------------------------------------------------------------------ bool Function::PopulateBool( const BFFIterator & iter, void * base, const ReflectedProperty & property, const BFFVariable * variable ) const { if ( variable->IsBool() ) { // Bool to Bool property.SetProperty( base, variable->GetBool() ); return true; } Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), variable->GetType(), BFFVariable::VAR_BOOL ); return false; }
bool Function::PopulateArrayOfStrings( const BFFIterator & iter, Node * node, const ReflectedProperty & property, const BFFVariable * variable ) const { // Array to Array if ( variable->IsArrayOfStrings() ) { Array< AString > strings( variable->GetArrayOfStrings() ); Array< AString >::Iter end = strings.End(); for ( Array< AString >::Iter it = strings.Begin(); it != end; ++it ) { AString & string = *it; // Path/File fixup needed? if ( !PopulatePathAndFileHelper( iter, property.HasMetaData< Meta_Path >(), property.HasMetaData< Meta_File >(), variable->GetName(), variable->GetArrayOfStrings()[ it - strings.Begin() ], string ) ) { return false; } } property.SetProperty( node, strings ); return true; } if ( variable->IsString() ) { // Handle empty strings if ( variable->GetString().IsEmpty() ) { Error::Error_1004_EmptyStringPropertyNotAllowed( iter, this, variable->GetName().Get() ); return false; } AStackString<> string( variable->GetString() ); // Path/File fixup needed? if ( !PopulatePathAndFileHelper( iter, property.HasMetaData< Meta_Path >(), property.HasMetaData< Meta_File >(), variable->GetName(), variable->GetString(), string ) ) { return false; } // Make array with 1 string Array< AString > strings( 1, false ); strings.Append( string ); property.SetProperty( node, strings ); return true; } Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), variable->GetType(), BFFVariable::VAR_STRING, BFFVariable::VAR_ARRAY_OF_STRINGS ); return false; }