Platforms to show: All Mac Windows Linux Cross-Platform

Back to CFBinaryDataMBS class.

CFBinaryDataMBS.base64DecodedData(options as Integer = 0) as CFBinaryDataMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 25.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes a data object with the given Base64 encoded data.
Example
Var d As New CFBinaryDataMBS("Hello World")

// encode
Var b As CFBinaryDataMBS = d.base64EncodedData

// decode
Var t As CFBinaryDataMBS = b.base64DecodedData

MessageBox b.Str + EndOfLine + t.Str

Returns a data object containing the Base64 decoded data.
Returns nil if the data object could not be decoded.

CFBinaryDataMBS.base64EncodedData(options as Integer = 0) as CFBinaryDataMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 25.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a Base64, UTF-8 encoded data object from the string using the given options.
Example
Var d As New CFBinaryDataMBS("Hello World")

// encode
Var b As CFBinaryDataMBS = d.base64EncodedData

// decode
Var t As CFBinaryDataMBS = b.base64DecodedData

MessageBox b.Str + EndOfLine + t.Str

options: A mask that specifies options for Base64 encoding the data. Possible values are given in constants.

By default, no line endings are inserted.
If you specify one of the line length options (Base64Encoding64CharacterLineLength or Base64Encoding76CharacterLineLength) but don’t specify the kind of line ending to insert, the default line ending is Carriage Return + Line Feed.

CFBinaryDataMBS.clone as CFBinaryDataMBS

Type Topic Plugin macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin ✅ Yes ❌ No ❌ No ✅ Yes All
Makes a deep copy of the CFBinaryDataMBS object.

CFBinaryDataMBS.compressedDataUsingAlgorithm(algorithm as Integer, byref ErrorCode as Integer, byref ErrorMessage as String) as CFBinaryDataMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 25.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new data object by compressing the data object’s bytes.
Example
// generate some data to compress
Var m As New MemoryBlock(1000)
m.Int64Value(100) = 12345

// copy constructor
Var d As New CFBinaryDataMBS(m)

// compress
Var ErrorCode As Integer
var ErrorMessage as string
Var b As CFBinaryDataMBS = d.compressedDataUsingAlgorithm(d.CompressionAlgorithmLZ4, ErrorCode, ErrorMessage)

MessageBox Str(b.Len)+" bytes"

// decompress
Var t As CFBinaryDataMBS = b.decompressedDataUsingAlgorithm(d.CompressionAlgorithmLZ4, ErrorCode, ErrorMessage)

If t.Len = 1000 And t.Data.Int64(100) = 12345 Then
MessageBox "success"
Else
MessageBox "failed: "+ErrorMessage
End If

algorithm: An algorithm used to compress the data. For a list of available algorithms, see constants.
ErrorCode and ErrorMessage: The errro that indicates why compressing the data failed, or "" and 0 if no error occurred.

Returns a CFBinaryDataMBS instance that contains the compressed buffer data. On failure, this method returns nil.

Use this method to compress in-memory data when you want to reduce memory usage and can afford the time to compress and decompress it. If your data object is already in a compressed format, such as media formats like JPEG images or AAC audio, additional compression may provide minimal or no reduction in memory usage.
To restore this data, use decompressedDataUsingAlgorithm(), and specify the algorithm originally used to compress the data.

CFBinaryDataMBS.Constructor(data as MemoryBlock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 13.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new data object with given content.
Example
Var m as MemoryBlock = "Hello"
Var d as new CFBinaryDataMBS(m)

MsgBox d.Str

See also:

CFBinaryDataMBS.Constructor(data as Ptr, Size as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 25.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Wraps a pointer into a CFData object.
Example
Var m As New MemoryBlock(100)

Var p As Ptr = m
// this CFBinaryDataMBS is only valid as long as the MemoryBlock lives
Var d As New CFBinaryDataMBS(p, 100)

If d.Data = p Then
// okay
Else
Break
End If

m.StringValue(0, 5) = "Hello"

// shows Hello
MessageBox d.Str(0,5)

Warning: The Ptr is not reference counted, so once the underlaying memory gets freed, this CFBinaryDataMBS object should no longer be used.

See also:

CFBinaryDataMBS.Constructor(data as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 13.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new data object with given content.
Example
Var m as string = "Hello"
Var d as new CFBinaryDataMBS(m)

MsgBox d.Str

See also:

CFBinaryDataMBS.decompressedDataUsingAlgorithm(algorithm as Integer, byref ErrorCode as Integer, byref ErrorMessage as String) as CFBinaryDataMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 25.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new data object by decompressing data object’s bytes.
Example
// generate some data to compress
Var m As New MemoryBlock(1000)
m.Int64Value(100) = 12345

// copy constructor
Var d As New CFBinaryDataMBS(m)

// compress
Var ErrorCode As Integer
var ErrorMessage as string
Var b As CFBinaryDataMBS = d.compressedDataUsingAlgorithm(d.CompressionAlgorithmLZ4, ErrorCode, ErrorMessage)

MessageBox Str(b.Len)+" bytes"

// decompress
Var t As CFBinaryDataMBS = b.decompressedDataUsingAlgorithm(d.CompressionAlgorithmLZ4, ErrorCode, ErrorMessage)

If t.Len = 1000 And t.Data.Int64(100) = 12345 Then
MessageBox "success"
Else
MessageBox "failed: "+ErrorMessage
End If

algorithm: An algorithm used to decompress the data. For a list of available algorithms, see constants.
error
ErrorCode and ErrorMessage: The errro that indicates why decompressing the data failed, or "" and 0 if no error occurred.

Returns a CFBinaryDataMBS instance that contains the decompressed buffer data. On failure, this method returns nil.

Use this method to inflate in-memory data when you need uncompressed bytes. Specify the same algorithm used to compress the data to successfully decompress it.

CFBinaryDataMBS.Edit as CFMutableBinaryDataMBS

Type Topic Plugin macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin ✅ Yes ❌ No ❌ No ✅ Yes All
Makes a copy of the CFBinaryDataMBS object for editing.

CFBinaryDataMBS.Mem as Memoryblock

Type Topic Plugin macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin ✅ Yes ❌ No ❌ No ✅ Yes All
The binary data returned as a Xojo memoryblocks.

See also:

CFBinaryDataMBS.Mem(pos as Integer,len as Integer) as Memoryblock

Type Topic Plugin macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin ✅ Yes ❌ No ❌ No ✅ Yes All
The binary data returned as a Xojo memoryblocks.

See also:

CFBinaryDataMBS.Str as String

Type Topic Plugin macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin ✅ Yes ❌ No ❌ No ✅ Yes All
The binary data returned as a Xojo string.

See also:

CFBinaryDataMBS.Str(pos as Integer,len as Integer) as String

Type Topic Plugin macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin ✅ Yes ❌ No ❌ No ✅ Yes All
The binary data returned as a Xojo string.

See also:

The items on this page are in the following plugins: MBS MacCF Plugin.


The biggest plugin in space...