libs/uci: implement get_bool() to retrive uci variables as boolean value

This commit is contained in:
Jo-Philipp Wich 2009-01-19 13:39:54 +00:00
parent c1eb7cf481
commit b204c9ec8d

View file

@ -135,6 +135,16 @@ function Cursor.tset(self, config, section, values)
return stat
end
--- Get a boolean option and return it's value as true or false.
-- @param config UCI config
-- @param section UCI section name
-- @param option UCI option
-- @return Boolean
function Cursor.get_bool(self, ...)
local val = self:get(...)
return ( val == "1" or val == "true" or val == "yes" or val == "on" )
end
--- Get an option or list and return values as table.
-- @param config UCI config
-- @param section UCI section name