1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file chset.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-02-26 10:50:48 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#ifndef CHSET_H
|
|
|
|
|
#define CHSET_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
#include <map>
|
1999-12-20 17:38:37 +00:00
|
|
|
|
#include <utility>
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// a class for mapping char strings such as "\^{A}" to the integer value
|
1999-09-27 18:44:28 +00:00
|
|
|
|
class CharacterSet {
|
|
|
|
|
public:
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* initialise this charset from the given .cdef file
|
|
|
|
|
* param charset the charset to look for
|
|
|
|
|
*
|
|
|
|
|
* Finds a .cdef file corresponding to the named charset
|
|
|
|
|
* and parses it. This function is only intended to be
|
|
|
|
|
* called once.
|
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool loadFile(std::string const & charset);
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// return the name of the current charset
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const & getName() const;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Return the encoded charset value of the given string.
|
|
|
|
|
*
|
|
|
|
|
* The bool value is false if an encoding could not be found
|
|
|
|
|
* in this charset, and true otherwise.
|
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::pair<bool, int> const encodeString(std::string const &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// charset name
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string name_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
typedef std::map<std::string, unsigned char> Cdef;
|
2002-02-26 10:50:48 +00:00
|
|
|
|
/// mapping from string representation to encoded value
|
1999-11-15 12:01:38 +00:00
|
|
|
|
Cdef map_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#endif
|