config: test for setting and getting bool

This commit is contained in:
Carlos Martín Nieto
2014-05-19 12:37:29 +02:00
parent 29d468c90a
commit f568955a95
6 changed files with 66 additions and 0 deletions

View File

@@ -36,6 +36,16 @@
start_link(Handle) ->
gen_server:start_link(?MODULE, Handle, []).
%% @doc Open a configuration file
-spec open(iolist()) -> {ok, pid()} | {error, term()}.
open(Path) ->
case geef_nif:config_open(Path) of
{ok, Handle} ->
start_link(Handle);
Error ->
Error
end.
%% @doc Set a value in the configuration
set(Pid, Name, Val) when is_boolean(Val) ->
gen_server:call(Pid, {set_bool, Name, Val}).

View File

@@ -213,6 +213,10 @@ config_set_bool(_Handle, _Name, _Val) ->
config_get_bool(_Handle, _Name) ->
?NIF_FN.
-spec config_open(iolist()) -> {ok, term()} | {error, term()}.
config_open(_Path) ->
?NIF_FN.
nif_error(Line) ->
erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).