Portability | portable, ffi |
---|---|
Stability | alpha |
Maintainer | [email protected] |
Safe Haskell | Safe-Inferred |
Scripting.Lua.ConfigFile
Description
Reads configuration files written in Lua. See http://www.lua.org/
for more details.
- data Config
- openConfig :: FilePath -> IO Config
- closeConfig :: Config -> IO ()
- getBool :: Config -> String -> IO Bool
- getString :: Config -> String -> IO String
- getInt :: Config -> String -> IO (Maybe Int)
- getDouble :: Config -> String -> IO (Maybe Double)
- getList :: Config -> String -> IO [String]
- getNestedLists :: Config -> String -> IO [[String]]
- getAssocList :: Config -> String -> IO [(String, String)]
- getListOfAssocLists :: Config -> String -> IO [[(String, String)]]
- getNestedAssocLists :: Config -> String -> IO [(String, [(String, String)])]
- data ConfigFileException
Documentation
openConfig :: FilePath -> IO ConfigSource
Opens a config file and returns an opaque reference to the file.
You must close this reference using close
when you're done reading
the file.
closeConfig :: Config -> IO ()Source
Closes a configuration file.
getBool :: Config -> String -> IO BoolSource
Returns a boolean value from a configuration file. Returns False
if the value is not defined in the file. Example:
someVal = true
getString :: Config -> String -> IO StringSource
Returns a string value from a configuration file. Returns the empty string if the value is not defined in the file. Example:
someVal = "foo"
getInt :: Config -> String -> IO (Maybe Int)Source
Returns an integer value from a configuration file. Example:
someVal = 2
getDouble :: Config -> String -> IO (Maybe Double)Source
Returns a double value from a configuration file. Example:
someVal = 3.1415926
getList :: Config -> String -> IO [String]Source
Returns a list of strings (i.e. a Lua table in which the keys are integers and the values are strings) from a configuration file. Example:
someVal = { "foo", "bar", "baz" }
getNestedLists :: Config -> String -> IO [[String]]Source
Returns a list of lists, i.e. a Lua table of tables. In the outer table, the keys are integers and the values are tables, and in the inner tables, the keys are integers and the values are strings. Example:
someVal = { { "foo one", "foo two", "foo three" }, { "bar one", "bar two", "bar three" } }
getAssocList :: Config -> String -> IO [(String, String)]Source
Returns an association list, i.e. a Lua table in which the keys and values are strings. Example:
someVal = { one = "foo", two = "bar", three = "baz" }
getListOfAssocLists :: Config -> String -> IO [[(String, String)]]Source
Returns a list of association lists, i.e. a Lua table of tables. In the outer table, the keys are integers and the values are tables, and in the inner tables, the keys and values are strings. Example:
someVal = { { foo = "aaa", bar = "bbb", baz = "ccc" }, { foo = "ddd", bar = "eee", baz = "fff" } }
getNestedAssocLists :: Config -> String -> IO [(String, [(String, String)])]Source
Returns an association list of association lists, i.e. a Lua table of tables. In the outer table, the keys are strings and the values are tables, and in the inner tables, the keys and values are strings. Example:
someVal = { something = { foo = "aaa", bar = "bbb", baz = "ccc" }, somethingElse = { foo = "ddd", bar = "eee", baz = "fff" } }
data ConfigFileException Source
Thrown when an error occurs in reading a configuration file.