Al (Library)

From Deep Sea Knowledge
Jump to navigation Jump to search

BYAML (Binary YAML) is a YAML, but in binary form. The al library contains multiple classes that process this data. In the LunchPack engine, these classes are contained within the Lp::Utl name space.

ByamlData

This class stores the most basic data for a BYAML node, which is the node type, and the value of the node.

class ByamlData
{
	public:
	ByamlData();
	
	void set(al::ByamlHashPair const *hashPair, bool swapEndianess);
	void set(unsigned char type, unsigned int value, bool swapEndianess);
	unsigned char getType() const;
	unsigned int getValue() const;
	
	unsigned int value;
	unsigned char type;
};

al::ByamlData::ByamlData()

The only constructor of the class. Sets both value and type to 0.

void set(al::ByamlHashPair const *hashPair, bool swapEndianess)

Sets both value and type with another hash pair instance defined with hashPair. Processes the data as big endian if the swapEndianess parameter is True.

void set(unsigned char type, unsigned int value, bool swapEndianess)

Sets both value and type with the defined type and value that are defined in the function parameter. Processes the data as big endian if the swapEndianess parameter is True.

unsigned char getType() const

Returns type.

unsigned int getValue() const

Returns value.

Members

type contains the node type, as defined in the BYAML structure. value contains the value of the node, based on the node type.

ByamlHashPair

This class contains something called a hash pair, which is BYAML data attached to a generated hash for faster access.

class ByamlHashPair
{
	public:
	unsigned short getKey(bool swapEndianess) const;
	unsigned char getType() const;
	unsigned int getValue(bool swapEndianess) const;
	
	unsigned short key;
	unsigned char type;
	unsigned int value; 
};

unsigned short getKey(bool swapEndianess) const

Returns key, and reversing it if swapEndianess is True.

unsigned char getType() const

Returns type.

unsigned int getValue(bool swapEndianess) const

Returns value, and reversing it if swapEndianess is True.

ByamlHeader

This class stores the important sections of a BYAML header.

class ByamlHeader
{
	public:
	unsigned short getTag() const;
	bool isInvert() const;
	unsigned short getVersion() const;
	unsigned int getHashKeyTableOffset() const;
	unsigned int getStringTableOffset() const;
	unsigned int getDataOffset() const;
	
	unsigned short tag;
	unsigned short version;
	unsigned int hashKeyTableOffset;
	unsigned int stringTableOffset;
	unsigned int dataOffset;
};

unsigned short getTag() const

The magic of a BYAML ("BY") is considered a "tag". If tag is reversed ("YB"), it reverses the tag and returns it. If not, it simply returns tag as-is.

bool isInvert() const

A check to see if the file uses a little-endian byte order. Checks if tag is equal to "YB". If it is, it returns True. If not, it returns False.

unsigned short getVersion() const

Returns version, and reverses it if tag is equal to "YB".

unsigned int getHashKeyTableOffset() const

Returns hashKeyTableOffset.

unsigned int getStringTableOffset() const

Returns stringTableOffset.

unsigned int getDataOffset() const

Returns dataOffset.