Adjust to new (and now docomented) naming convention for bison outputs.
[shapes.git] / source / charconverters.h
blob742350f854a64d7c4745c0b313f8c2aa4eb33dd9
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2010 Henrik Tidefelt
19 #pragma once
21 #include "refcount.h" // Why?! (You get strange compiler errors if you dont include refcount.h here.)
23 #include "FontMetrics_decls.h"
24 #include "config.h"
26 #include <iconv.h>
27 #include <stdint.h>
29 #ifdef HAVE_FT2
30 #include <ft2build.h>
31 #include FT_FREETYPE_H
32 #endif
34 namespace Shapes
36 namespace Helpers
39 iconv_t requireUTF8ToMacRomanConverter( bool cleanup = false );
40 iconv_t requireMacRomanToUTF8Converter( bool cleanup = false );
42 iconv_t requireUTF8ToUCS4Converter( bool cleanup = false );
43 iconv_t requireUCS4ToUTF8Converter( bool cleanup = false );
45 iconv_t requireUTF16BEToUCS4Converter( bool cleanup = false );
46 iconv_t requireUCS4ToUTF16BEConverter( bool cleanup = false );
48 iconv_t requireUTF8ToASCIIConverter( bool cleanup = false );
49 iconv_t requireUTF8ToWinANSIConverter( bool cleanup = false );
50 iconv_t requireUTF8ToUTF16BEConverter( bool cleanup = false );
52 iconv_t requireUCS4ToMacRomanConverter( bool cleanup = false );
55 const FontMetrics::GlyphList & requireGlyphList( bool cleanup = false );
56 const FontMetrics::CharacterEncoding & requireMacRomanEncoding( bool cleanup = false );
60 namespace Kernel
63 class UnicodeCodePoint
65 public:
66 typedef uint32_t value_type; /* Type to hold the code point in UCS4 format. */
67 private:
68 value_type value_;
69 public:
70 UnicodeCodePoint( ){ }
71 UnicodeCodePoint( value_type value )
72 : value_( value )
73 { }
74 UnicodeCodePoint & operator = ( const UnicodeCodePoint & orig ) { value_ = orig.value_; return *this; }
75 value_type get_UCS4( ) const { return value_; }
76 #ifdef HAVE_FT2
77 FT_ULong get_FT_charcode( ) const { return value_; }
78 #endif
79 unsigned char get_MacRoman( ) const;
80 void decode_UTF8( const char ** src, size_t * src_avail );
81 void decode_UCS4( const char ** src, size_t * src_avail );
82 void encode_UTF8( char ** dst, size_t * dst_avail ) const;
83 void encode_UTF16BE( char ** dst, size_t * dst_avail ) const;
85 void decode_UTF8( const char * src );
86 void decode_UCS4( const char * src );
88 void decode_glyph_name( const char * name );
90 bool operator == ( const UnicodeCodePoint & other ) const { return value_ == other.value_; }
91 bool operator != ( const UnicodeCodePoint & other ) const { return value_ != other.value_; }
92 bool operator < ( const UnicodeCodePoint & other ) const { return value_ < other.value_; }
93 bool operator <= ( const UnicodeCodePoint & other ) const { return value_ <= other.value_; }
94 bool operator > ( const UnicodeCodePoint & other ) const { return value_ > other.value_; }
95 bool operator >= ( const UnicodeCodePoint & other ) const { return value_ >= other.value_; }
97 static UnicodeCodePoint SPACE;
98 static UnicodeCodePoint NEWLINE;