// We are implementing the Relooper C API, so always export from this file.
#ifndef RELOOPERDLL_EXPORTS
#define RELOOPERDLL_EXPORTS
#endif
#include "Relooper.h"
#include <string.h>
#include <stdlib.h>
#include <list>
#include <stack>
#if EMSCRIPTEN
#include "ministring.h"
#else
#include <string>
typedef std::string ministring;
#endif
template <class T, class U> static bool contains(const T& container, const U& contained) {
return container.count(contained);
}
#if DEBUG
static void PrintDebug(const char *Format, ...);
#define DebugDump(x, ...) Debugging::Dump(x, __VA_ARGS__)
#else
#define PrintDebug(x, ...)
#define DebugDump(x, ...)
#endif
#define INDENTATION 1
struct Indenter {
static int CurrIndent;
static void Indent() { CurrIndent++; }
static void Unindent() { CurrIndent--; }
};
static void PrintIndented(const char *Format, ...);
static void PutIndented(const char *String);
static char *OutputBufferRoot = NULL;
static char *OutputBuffer = NULL;
static int OutputBufferSize = 0;
static int OutputBufferOwned = false;
static int LeftInOutputBuffer() {
return OutputBufferSize - (OutputBuffer - OutputBufferRoot);
}
static bool EnsureOutputBuffer(int Needed) { // ensures the output buffer is sufficient. returns true is no problem happened
Needed++; // ensure the trailing \0 is not forgotten
int Left = LeftInOutputBuffer();
if (!OutputBufferOwned) {
assert(Needed < Left);
}