///----------------------------------------------------------------------- /// Retrieves the named property (as either an attribute or child node) /// and returns it as a string. Processes the result through the variables /// system to expand it before returning the expanded value. ///----------------------------------------------------------------------- std::string GetPropertyValueAsStringWithVariableLookup( const XMLNode& node, const std::string& propertyName ) { std::string valueBeforeVariableLookup = GetPropertyValueAsString( node, propertyName ); std::string valueAfterVariableLookup = valueBeforeVariableLookup; // JazzSubstitutionVariableSet::ExpandJazzVariablesInString( valueBeforeVariableLookup ); return valueAfterVariableLookup ; }
///------------------------------------------------------------------ /// Retrieves the named property (as either an attribute or child node) /// and returns it as a string. ///------------------------------------------------------------------ std::string GetPropertyValueAsString( const XMLNode& node, const std::string& propertyName ) { std::string propertyValue ; XMLNode childNode = node.getChildNode( propertyName.c_str() ); // First try to get it as an attribute with that property name if ( node.getAttribute( propertyName.c_str() ) ) { propertyValue = node.getAttribute( propertyName.c_str() ); node.markUsed(); } // Second try to get it as the text of a child node with that property name else if ( childNode.hasText() ) { propertyValue = childNode.getText(); node.markUsed(); } // Third, try to get it as an attribute named "Value" of the child node with that property name else if ( !childNode.isEmpty() ) { propertyValue = GetPropertyValueAsString( childNode, "Value" ); node.markUsed(); } return propertyValue ; }
///----------------------------------------------------------------------- /// Retrieves a IntVector2 property from the specified Node ///----------------------------------------------------------------------- IntVector2 GetIntVector2Property( const XMLNode& node, const std::string& propertyName, const IntVector2& defaultValue ) { std::string propertyString = GetPropertyValueAsString( node, propertyName ); IntVector2 propertyValue = defaultValue ; if( propertyString.length() ) propertyValue = IntVector2( propertyString ); return propertyValue; }
///------------------------------------------------------------------ /// Retrieves an Rgba property from the specified Node ///------------------------------------------------------------------ Rgba GetRgbaProperty( const XMLNode& node, const std::string& propertyName, const Rgba& defaultValue ) { std::string propertyString = GetPropertyValueAsString( node, propertyName ); Rgba propertyValue = defaultValue ; if ( propertyString.length() ) propertyValue = Rgba( propertyString ); return propertyValue; }
///------------------------------------------------------------------ /// Retrieves a string property from the specified Node ///------------------------------------------------------------------ std::string GetStringProperty( const XMLNode& node, const std::string& propertyName, const std::string& defaultValue ) { std::string propertyString = GetPropertyValueAsString( node, propertyName ); std::string propertyValue = defaultValue ; if ( propertyString.length() ) propertyValue = propertyString ; return propertyValue ; }
///------------------------------------------------------------------ /// Retrieves a character property from the specified Node ///------------------------------------------------------------------ char GetCharacterProperty( const XMLNode& node, const std::string& propertyName, char defaultValue ) { std::string propertyString = GetPropertyValueAsString( node, propertyName ); char propertyValue = defaultValue ; if ( propertyString.length() == 1 ) propertyValue = propertyString.c_str()[0]; return propertyValue ; }
///------------------------------------------------------------------ /// Retrieves an integer property from the specified Node ///------------------------------------------------------------------ int GetIntProperty( const XMLNode& node, const std::string& propertyName, int defaultValue ) { std::string propertyString = GetPropertyValueAsString( node, propertyName ); int propertyValue = defaultValue ; if ( propertyString.length() ) propertyValue = GetIntFromString( propertyString ); return propertyValue ; }
///------------------------------------------------------------------ /// Retrieves a double property from the specified Node ///------------------------------------------------------------------ float GetDoubleProperty( const XMLNode& node, const std::string& propertyName, float defaultValue ) { std::string propertyString = GetPropertyValueAsString( node, propertyName ); float propertyValue = defaultValue ; if ( propertyString.length() ) ConvertType( propertyString, propertyValue ); return propertyValue ; }
///------------------------------------------------------------------ /// Retrieves a boolean property from the specified Node ///------------------------------------------------------------------ bool GetBooleanProperty( const XMLNode& node, const std::string& propertyName, bool defaultValue ) { std::string propertyString = GetPropertyValueAsString( node, propertyName ); bool propertyValue = defaultValue ; if ( propertyString.length() ) propertyValue = GetBooleanFromString( propertyString ); return propertyValue ; }
CFStringRef GetStringForMetaDataValue(UInt32 dataTypeCode, QTPropertyValuePtr keyValuePtr, ByteCount propValueSizeUsed) { CFStringRef str = nil; switch (dataTypeCode) { case kMyQTMetaDataTypeGIF: case kQTMetaDataTypeJPEGImage: case kQTMetaDataTypePNGImage: case kQTMetaDataTypeBMPImage: case kQTMetaDataTypeBinary: str = GetBinaryDataAsString(keyValuePtr, propValueSizeUsed); break; case kQTMetaDataTypeUTF8: str = GetUTF8DataAsString(keyValuePtr, propValueSizeUsed); break; case kQTMetaDataTypeUTF16BE: str = GetUTF16BEDataAsString(keyValuePtr, propValueSizeUsed); break; case kQTMetaDataTypeMacEncodedText: str = GetPropertyValueAsString(keyValuePtr, propValueSizeUsed); break; case kQTMetaDataTypeSignedIntegerBE: str = GetSignedIntegerBEDataAsString(keyValuePtr, propValueSizeUsed); break; case kQTMetaDataTypeUnsignedIntegerBE: str = GetUnsignedIntegerBEDataAsString(keyValuePtr, propValueSizeUsed); break; case kQTMetaDataTypeFloat32BE: str = GetFloat32BEDataAsString(keyValuePtr); break; case kQTMetaDataTypeFloat64BE: str = GetFloat64BEDataAsString(keyValuePtr); break; } // create a properly formatted string showing a count of the number of bytes of data // for display in our window and append the actual metadata value string to this display string CFStringRef destStr = AppendMetaValueStringToDisplayString(str, propValueSizeUsed); return destStr; }