class RPM::TagData

Overview

Stores one RPM TagData.

There are multiple similar methods available for getting value(s).

Included Modules

Defined in:

rpm/tagdata.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.create(deleter = nil, &) #

Create a new tagdata with initializing it with given block.

This method is primitive method. Passed argument is raw value of rpmtd (actually a pointer).

If given block returns 0, it will be treated as failure to set tagdata, and raises TypeCastError. You can raise another class of Exception in the block if you want to do so.


[View source]
def self.create(str : String, tag : Tag | TagValue) #

Creates a new tagdata which stores given string.


[View source]
def self.create(stra : Array(String), tag : Tag | TagValue) #

Creates a new tagdata which stores given array of strings.


[View source]
def self.create(u8 : UInt8, tag : Tag | TagValue) #

Creates a new tagdata which stores given UInt8 value.


[View source]
def self.create(u16 : UInt16, tag : Tag | TagValue) #

Creates a new tagdata which stores given UInt16 value.


[View source]
def self.create(u32 : UInt32, tag : Tag | TagValue) #

Creates a new tagdata which stores given UInt32 value.


[View source]
def self.create(u64 : UInt64, tag : Tag | TagValue) #

Creates a new tagdata which stores given UInt64 value.


[View source]
def self.create(u8a : Array(UInt8) | Bytes, tag : Tag | TagValue, copy : Bool = true) #

Creates a new tagdata which stores given array of UInt8 values.

If copy is false, the content of u8a will become a part of TagData. Though u8a will be kept until the TagData is garbage-collected, modifying it will also modifies the content of TagData.


[View source]
def self.create(u16a : Array(UInt16) | Slice(UInt16), tag : Tag | TagValue, copy : Bool = true) #

Creates a new tagdata which stores given array of UInt16 values.

If copy is false, the content of u8a will become a part of TagData. Though u8a will be kept until the TagData is garbage-collected, modifying it will also modifies the content of TagData.


[View source]
def self.create(u32a : Array(UInt32) | Slice(UInt32), tag : Tag | TagValue, copy : Bool = true) #

Creates a new tagdata which stores given array of UInt32 values.

If copy is false, the content of u8a will become a part of TagData. Though u8a will be kept until the TagData is garbage-collected, modifying it will also modifies the content of TagData.


[View source]
def self.create(u64a : Array(UInt64) | Slice(UInt64), tag : Tag | TagValue, copy : Bool = true) #

Creates a new tagdata which stores given array of UInt64 values.

If copy is false, the content of u8a will become a part of TagData. Though u8a will be kept until the TagData is garbage-collected, modifying it will also modifies the content of TagData.


[View source]
def self.create?(deleter = nil, &) #

Create a new tagdata with initializing it with given block.

This method is primitive method. Passed argument is raw value of rpmtd (actually a pointer).

If given block returns 0, it will be treated as failure to set tagdata, and returns nil. You can NOT raise an exception in the block, or make sure to rescue them.


[View source]

Instance Method Detail

def base64 #

Returns the BASE64 representation of tag data.

Equivalent to #format(TagDataFormat::BASE64).


[View source]
def bytes #

Returns raw binary data of TagData

Some types do not suitable for getting binary data. If so, this method raises TypeCastError.


[View source]
def finalize #

[View source]
def force_return_type!(type : ReturnTypeBase.class) #

Forces return type to given return type.

Returns old ReturnType class.

CHAR (ReturnTypeChar), INT8 (ReturnTypeUInt8) are interoperable (except for #bytes). Otherwise, it may cause unexpected behavior.


[View source]
def format(fmt : TagDataFormat) : String #

Format tag data in given tag data format, and returns it.


[View source]
def format(io : IO, fmt : TagDataFormat) : Void #

Format tag data in given tag data format, and send to given io


[View source]
def format(index : Int, fmt : TagDataFormat) : String #

Format a single value at specified index of tag data in given tag data format, and return it.


[View source]
def format(io : IO, index : Int, fmt : TagDataFormat) : Void #

Format a single value at specified index of tag data in given tag data format, and return it.


[View source]
def is_array? #

Returns true if tag data is array

Returns true if number of elements is greater than 1, the return type is TagReturnType::ARRAY, or the type is TagType::STRING_ARRAY.


[View source]
def return_type #

Returns the return type of tag data


[View source]
def size #

Returns the number of elements in tag data


[View source]
def tag #

Get tag value


[View source]
def tag=(val) #

Sets tag value

NOTE RPM allows to change tag value only to same type. If not, this method raises TypeCastError.


[View source]
def to_a #
Description copied from module Indexable(Char | Slice(UInt8) | String | UInt16 | UInt32 | UInt64 | UInt8)

Returns an Array with all the elements in the collection.

{1, 2, 3}.to_a # => [1, 2, 3]

[View source]
def to_s(io) #

[View source]
def to_unsafe #

Returns pointer to rpmtd to deal with librpm C API directly.


[View source]
def type #

Returns the type of tag data


[View source]
def unsafe_fetch(index : Int) #
Description copied from module Indexable(Char | Slice(UInt8) | String | UInt16 | UInt32 | UInt64 | UInt8)

Returns the element at the given index, without doing any bounds check.

Indexable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they access elements with #[](index) and #[]?(index).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.


[View source]
def value #

Returns the value.


[View source]
def value? #

Returns the value.


[View source]
def value_array #

Returns the value in array.

It raises TypeCastError if the tag data stores single value only.


[View source]
def value_array? #

Returns the value in array.

It returns nil if the tag data stores single value only.


[View source]
def value_no_array #

Returns the single value of tag data

If tag data contains array, raises TypeCastError. If tag data is not set, raises IndexError (because this methods just get the value at index 0).


[View source]
def value_no_array? #

Returns the single value of tag data

If tag data contains array or not set, returns nil.


[View source]