~ubuntu-branches/ubuntu/natty/geany/natty

« back to all changes in this revision

Viewing changes to scintilla/Converter.h

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-08-07 03:23:12 UTC
  • mfrom: (1.4.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20100807032312-ot70ac9d50cn79we
Tags: upstream-0.19
ImportĀ upstreamĀ versionĀ 0.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
// Copyright 2004 by Neil Hodgson <neilh@scintilla.org>
4
4
// The License.txt file describes the conditions under which this software may be distributed.
5
5
 
6
 
#include <iconv.h>
7
 
#if GTK_MAJOR_VERSION >= 2
8
 
        typedef GIConv ConverterHandle;
9
 
#else
10
 
        typedef iconv_t ConverterHandle;
11
 
#endif
 
6
typedef GIConv ConverterHandle;
12
7
const ConverterHandle iconvhBad = (ConverterHandle)(-1);
13
8
// Since various versions of iconv can not agree on whether the src argument
14
9
// is char ** or const char ** provide a templatised adaptor.
24
19
class Converter {
25
20
        ConverterHandle iconvh;
26
21
        void OpenHandle(const char *fullDestination, const char *charSetSource) {
27
 
#if GTK_MAJOR_VERSION >= 2
28
22
                iconvh = g_iconv_open(fullDestination, charSetSource);
29
 
#else
30
 
                iconvh = iconv_open(fullDestination, charSetSource);
31
 
#endif
32
23
        }
33
24
        bool Succeeded() const {
34
25
                return iconvh != iconvhBad;
65
56
        }
66
57
        void Close() {
67
58
                if (Succeeded()) {
68
 
#if GTK_MAJOR_VERSION >= 2
69
59
                        g_iconv_close(iconvh);
70
 
#else
71
 
                        iconv_close(iconvh);
72
 
#endif
73
60
                        iconvh = iconvhBad;
74
61
                }
75
62
        }
77
64
                if (!Succeeded()) {
78
65
                        return (size_t)(-1);
79
66
                } else {
80
 
#if GTK_MAJOR_VERSION >= 2
81
67
                        return iconv_adaptor(g_iconv, iconvh, src, srcleft, dst, dstleft);
82
 
#else
83
 
                        return iconv_adaptor(iconv, iconvh, src, srcleft, dst, dstleft);
84
 
#endif
85
68
                }
86
69
        }
87
70
};