Search documentation of jhn_stdlib

# jhn_plist (jhn_stdlib v5.10.3)

View Source

A property list style handling of {Key, Value} tuples.

# Summary

## Types

default/0
flag/0
key/0
placement/0
plist/0
value/0

## Functions

add(Key, Value, PList)

Extends Plist with the property without checking if it exists.

add(Key, Value, PList, _)

Extends Plist with the property checking if it exists if required.

compact(List)

Ensures one property per key, with the first given precedence.

delete(Key, PList)

Restricts Plist on the key without checking if it exists.

delete(Key, PList, _)

Restricts Plist on the key without checking if it exists if required.

find(Key, PList)

Finds the value of the property or undefined if not found.

find(Key, PList, Default)

Finds the value of the property or Default if not found.

find(Key, PList, Value, _)

Finds the value of the property or Default if not found. If more than property is found the one returned if determined by the Placement as being the first or last.

find_all(Key, PList)

Finds the all values associated with the key.

keys(PList)

Returns all the keys.

member(Key, PList)

Returns wether the key is to be found in the PList.

new()

Creates an empty plist.

new(Keys, Values)

Creates a plist from the zipping the lists of keys and values.

replace(Key, Value, PList)

Replaces the first occurence in the PList, adding if it if not found.

replace(Key, Value, T, Check)

Replaces the first occurence in the PList, esuring that i does exist if required.

values(PList)

Returns all the values.

# Types

# default/0

    -type default() :: _.

# flag/0

    -type flag() :: check | nocheck.

# key/0

    -type key() :: _.

# placement/0

    -type placement() :: first | last.

# plist/0

    -type plist() :: [{key(), value()}].

# value/0

    -type value() :: _.

# Functions

# add(Key, Value, PList)

    -spec add(key(), value(), plist()) -> plist().

Extends Plist with the property without checking if it exists.

# add(Key, Value, PList, _)

    -spec add(key(), value(), plist(), flag()) -> plist().

Extends Plist with the property checking if it exists if required.

# compact(List)

    -spec compact(plist()) -> plist().

Ensures one property per key, with the first given precedence.

# delete(Key, PList)

    -spec delete(key(), plist()) -> plist().

Restricts Plist on the key without checking if it exists.

# delete(Key, PList, _)

    -spec delete(key(), plist(), flag()) -> plist().

Restricts Plist on the key without checking if it exists if required.

# find(Key, PList)

    -spec find(key(), plist()) -> value() | undefined.

Finds the value of the property or undefined if not found.

# find(Key, PList, Default)

    -spec find(key(), plist(), default()) -> value() | default().

Finds the value of the property or Default if not found.

# find(Key, PList, Value, _)

    -spec find(key(), plist(), default(), placement()) -> value() | default().

Finds the value of the property or Default if not found. If more than property is found the one returned if determined by the Placement as being the first or last.

# find_all(Key, PList)

    -spec find_all(key(), plist()) -> [value()].

Finds the all values associated with the key.

# keys(PList)

    -spec keys(plist()) -> [key()].

Returns all the keys.

# member(Key, PList)

    -spec member(key(), plist()) -> boolean().

Returns wether the key is to be found in the PList.

# new()

    -spec new() -> plist().

Creates an empty plist.

# new(Keys, Values)

    -spec new([key()], [value()]) -> plist().

Creates a plist from the zipping the lists of keys and values.

# replace(Key, Value, PList)

    -spec replace(key(), value(), plist()) -> plist().

Replaces the first occurence in the PList, adding if it if not found.

# replace(Key, Value, T, Check)

    -spec replace(key(), value(), plist(), flag()) -> plist().

Replaces the first occurence in the PList, esuring that i does exist if required.

# values(PList)

    -spec values(plist()) -> [value()].

Returns all the values.