/*---------------------------------------------------------------------------*
 |             pCOS - PDFlib Comprehensive Object Syntax                     |
 +---------------------------------------------------------------------------+
 |           Copyright (c) 2005 PDFlib GmbH. All rights reserved.            |
 +---------------------------------------------------------------------------+
 |          Proprietary source code -- do not redistribute!                  |
 *---------------------------------------------------------------------------*/

// $Id: pcos.hpp,v 1.8.2.1 2007/10/23 08:31:50 stm Exp $
//
// C++ wrapper for pCOS
//
//

#ifndef PCOSLIB_HPP
#define PCOSLIB_HPP

#include <string>

using namespace std;

// We use pCOS as a C++ class name, therefore hide the actual C struct
// name for pCOS usage with C++.

typedef struct pCOS_s pCOS_cpp;
#define pCOS pCOS_cpp
#include "pcoslib.h"
#undef pCOS

// The C++ class wrapper for pCOS

class pCOS {
public:
    class Exception
    {
    public:
	Exception(string errmsg, int errnum, string apiname, void *opaque);
	string get_errmsg();
	int get_errnum();
	string get_apiname();
	const void *get_opaque();
    private:
	string m_errmsg;
	int m_errnum;
	string m_apiname;
	void * m_opaque;
    }; // Exception

    pCOS(pcos_error_fp errorhandler = NULL, void *opaque = NULL) throw(Exception);

    ~pCOS() throw();


    void close_document(int doc) throw(pCOS::Exception);
    string get_apiname() throw(pCOS::Exception);
    string get_errmsg() throw(pCOS::Exception);
    int get_errnum() throw(pCOS::Exception);
    void * get_opaque() throw(pCOS::Exception);
    int open_document(string filename, string optlist)
	throw(pCOS::Exception);
    int open_document_callback(void *opaque, size_t filesize,
	size_t (*readproc)(void *opaque, void *buffer, size_t size),
	int (*seekproc)(void *opaque, long offset), string optlist)
	throw(pCOS::Exception);
    int open_document_mem(const void *data, size_t size, string optlist);
    double get_number(int doc, string path) throw(pCOS::Exception);
    string get_string(int doc, string path) throw(pCOS::Exception);
    const unsigned char * get_stream(int doc, int *length, string optlist,
	string path) throw(pCOS::Exception);
    void set_option(string optlist) throw(pCOS::Exception);
    string utf8_to_utf16(string utf8string, string ordering)
	throw(pCOS::Exception);
    string utf16_to_utf8(std::string utf16string)
            throw(pCOS::Exception);

private:
    pCOS_cpp *pcos;
};

#endif	// PCOSLIB_HPP
