Readers

Inlet has built-in support for three input file languages: JSON, Lua, and YAML. Due to language features, not all readers support all Inlet features. Below is a table that lists supported features:

Table 13 Supported Language Features

JSON

Lua

YAML

Primitive Types

bool, double, int, string

bool, double, int, string

bool, double, int, string

Dictionaries

X

X

X

Arrays

X

X

X

Non-contiguous Arrays

X

Mixed-typed key Arrays

X

Callback Functions

X

Extra Lua Functionality

The LuaReader class has the ability to access the entire Lua State via the protected member function LuaReader::solState(). This allows you fully utilize the Sol library, documented in Sol’s documentation. This is an advanced feature and not recommended unless there is a good reason. We provide an example on how to create a derived reader class here:

// Header required here because `axom::sol::state` is only forward declared in LuaReader.hpp.
#include "axom/sol.hpp"

class SolStateReader : public axom::inlet::LuaReader
{
public:
  using LuaReader::solState;
};

Inlet opens four Lua libraries by default: base, math, string, package. All libraries are documented in Sol’s open_library documentation.

For example, you can add the io library by doing this:

  // Create Inlet Reader that supports Lua input files
  auto reader = std::make_unique<SolStateReader>();

  // Load extra io Lua library
  reader->solState()->open_libraries(axom::sol::lib::io);

  // Parse example input string
  reader->parseString(input);