46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
/////////////////////////////////////////////////////////
|
|
//
|
|
// Pretty-print routine.
|
|
//
|
|
// The pretty-printer can be called from C++ or Lua.
|
|
//
|
|
/////////////////////////////////////////////////////////
|
|
|
|
#ifndef PPRINT_HPP
|
|
#define PPRINT_HPP
|
|
|
|
#include "luastack.hpp"
|
|
|
|
// Output a simple value to a stream.
|
|
//
|
|
// If the value is a string, number, boolean, or nil, it is
|
|
// quoted and output to the stream, and this function returns
|
|
// true. Otherwise, this function returns false and nothing
|
|
// is sent to the stream.
|
|
//
|
|
bool string_quote(LuaStack &LS, LuaSlot val, std::ostream *os);
|
|
|
|
// Pretty print to a stream.
|
|
//
|
|
// If indent is >=0, the output is indented. If indent<0, then
|
|
// the output is emitted without newlines or indentation.
|
|
//
|
|
// Maxlen specifies the maximum number of characters output. If
|
|
// this is exceeded, then the printout is truncated.
|
|
//
|
|
void pprint(LuaStack &LS, LuaSlot val, bool indent, std::ostream *os);
|
|
|
|
// The following lua interfaces to this code are included:
|
|
//
|
|
// pprint(expr, expr, expr...)
|
|
//
|
|
// - pretty print the specified expression to stdout.
|
|
//
|
|
// string.pprint(expr, indent)
|
|
//
|
|
// - pretty print the specified expression, return the result as a string.
|
|
//
|
|
int lfn_pprint_pprint(lua_State *L);
|
|
int lfn_string_pprint(lua_State *L);
|
|
|
|
#endif // PPRINT_HPP
|