Copyright | (c) Benjamin Geer 2011, 2013 |
---|---|
License | MIT |
Maintainer | omeragacan@gmail.com |
Stability | alpha |
Portability | portable, ffi |
Safe Haskell | Safe |
Language | Haskell98 |
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
data Config
Represents an open configuration file.
openConfig :: FilePath -> IO Config
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 ()
Closes a configuration file.
getBool :: Config -> String -> IO Bool
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 String
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)
Returns an integer value from a configuration file. Example:
someVal = 2
getDouble :: Config -> String -> IO (Maybe Double)
Returns a double value from a configuration file. Example:
someVal = 3.1415926
getList :: Config -> String -> IO [String]
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]]
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)]
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)]]
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)])]
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
Thrown when an error occurs in reading a configuration file.