#ifndef AVIFILE_AVM_OUTPUT_H
#define AVIFILE_AVM_OUTPUT_H

#ifdef __cplusplus
#include "avm_default.h"
#include "avm_locker.h"
#include "avm_stl.h"

#include <stdarg.h>

/**********
 * WARNING - this file is meant to be used by internal avifile application
 * DO NOT USE in your own project!
 * the API here could change in any minute
 */


AVM_BEGIN_NAMESPACE;

typedef void (*handlerFuncPtr) (const char* s, int opt);


class AvmOutput
{
public:
    AvmOutput() :priv(0) {};
    ~AvmOutput();
    void write(const char* mode, const char* format, ...); // debuglevel 0
    void write(const char* mode, int debuglevel, const char* format, ...); // any debuglevel
    void vwrite(const char* mode, const char* format, va_list va);
    void vwrite(const char* mode, int debuglevel, const char* format, va_list va);
    void setDebugLevel(const char* mode, int level);
    void resetDebugLevels(int level = 0);
private:
    void vwrite(const char* format, va_list va);
    void flush();

    struct AvmOutputPrivate;
    struct AvmOutputPrivate* priv;
};

extern AvmOutput out;

#define AVM_WRITE avm::out.write

AVM_END_NAMESPACE

#endif // __cplusplus

#ifdef __cplusplus
extern "C" {
#endif
    /** C interface **/
    void avm_printf(const char* mode, const char* format, ...);
    void avm_dprintf(const char* mode, int debuglevel, const char* format, ...);

#ifdef __cplusplus
};
#endif

#endif
