Module exmpp_utils

The module exmpp_utils provides functions which doesn't deserve a dedicated module.

Authors: Jean-Sebastien Pedron (js.pedron@meetic-corp.com).

Description

The module exmpp_utils provides functions which doesn't deserve a dedicated module.

Function Index

any_to_binary/1Convert any type to its binary() form.
any_to_list/1Convert any type to its string() form.
random_id/0Generate a random ID.
random_id/1Generate a random stanza ID.
strip/1Strip leading and trailing blanks.
strip/2Strip leading and/or trailing blanks, depending on the Direction.

Function Details

any_to_binary/1

any_to_binary(Atom::Any) -> Binary

Convert any type to its binary() form.

For an atom, erlang:atom_to_list/1 is used. For an integer, erlang:integer_to_list/1 is used. For a string, erlang:list_to_binary/1 is used. A binary is returned as is.

any_to_list/1

any_to_list(Atom::Any) -> String

Convert any type to its string() form.

For an atom, erlang:atom_to_list/1 is used. For an integer, erlang:integer_to_list/1 is used. For a binary, erlang:binary_to_list/1 is used. A string is returned as is.

random_id/0

random_id() -> ID

Generate a random ID.

Use the exmpp prefix.

See also: random_id/1.

random_id/1

random_id(Prefix) -> ID

Generate a random stanza ID.

This function uses random:uniform/1. It's up to the caller to seed the generator.

The ID is not guaranted to be unique.

strip/1

strip(Stream) -> Stripped

Strip leading and trailing blanks.

See also: strip/3.

strip/2

strip(Stream, X2::Direction) -> Stripped

Strip leading and/or trailing blanks, depending on the Direction.

Blanks characters are \s, \t, \n and \r.

The binary version was made by Christopher Faulet in his stream module.

See also: strip/3.


Generated by EDoc, Jan 21 2011, 01:43:52.