/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __IWEAR_MOLOADER_H
#define __IWEAR_MOLOADER_H

#ifndef __IWEAR_I18N_H
#include <iwear/i18n.h>
#endif

using std::multimap;

namespace iwear
{
///@todo FIXME this is not big-endian clean !
#define MO_MAGIC 0x950412de

class MoLoader : public i18nLoader
{
private:

    struct mo_header
    {
	uint32_t magic;
	uint32_t format;
	uint32_t entries;
	uint32_t offset_original;
	uint32_t offset_translation;
	uint32_t hashtable_size;
	uint32_t hashtable_offset;
/*	uint32_t pad6;
	uint32_t pad7;*/
    };

    struct mo_entry
    {
	uint32_t length;
	uint32_t offset;
    };

    string domain;

    /**
     * This is the mapping for the data.
     */
    multimap<const char *,string, cstring_less > langmap;

    void load_from_file( iwear_language lng );
    MoLoader() { }
public:
    MoLoader(const string& dm);
    virtual ~MoLoader();
    virtual multimap<const char *,string, cstring_less >& get_langmap( iwear_language = num_iwear_language );
    virtual void release(void);
};

}
#endif
