Files
integration/luprex/core/cpp/pprint.hpp

46 lines
1.3 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////
//
// Pretty-print routine.
//
// The pretty-printer can be called from C++ or Lua.
//
/////////////////////////////////////////////////////////
#ifndef PPRINT_HPP
#define PPRINT_HPP
#include "luastack.hpp"
2021-09-08 01:32:08 -04:00
// 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:
//
2021-09-08 01:32:08 -04:00
// pprint(expr, expr, expr...)
//
// - pretty print the specified expression to stdout.
//
2021-09-08 01:32:08 -04:00
// string.pprint(expr, indent)
//
// - pretty print the specified expression, return the result as a string.
//
2021-09-08 01:32:08 -04:00
int lfn_pprint_pprint(lua_State *L);
int lfn_string_pprint(lua_State *L);
#endif // PPRINT_HPP