~ubuntu-branches/ubuntu/karmic/firebird2.1/karmic

« back to all changes in this revision

Viewing changes to src/jrd/IntlUtil.h

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2008-05-26 23:59:25 UTC
  • Revision ID: james.westby@ubuntu.com-20080526235925-2pnqj6nxpppoeaer
Tags: upstream-2.1.0.17798-0.ds2
ImportĀ upstreamĀ versionĀ 2.1.0.17798-0.ds2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      PROGRAM:        JRD International support
 
3
 *      MODULE:         IntlUtil.h
 
4
 *      DESCRIPTION:    INTL Utility functions
 
5
 *
 
6
 *  The contents of this file are subject to the Initial
 
7
 *  Developer's Public License Version 1.0 (the "License");
 
8
 *  you may not use this file except in compliance with the
 
9
 *  License. You may obtain a copy of the License at
 
10
 *  http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
 
11
 *
 
12
 *  Software distributed under the License is distributed AS IS,
 
13
 *  WITHOUT WARRANTY OF ANY KIND, either express or implied.
 
14
 *  See the License for the specific language governing rights
 
15
 *  and limitations under the License.
 
16
 *
 
17
 *  The Original Code was created by Adriano dos Santos Fernandes
 
18
 *  for the Firebird Open Source RDBMS project.
 
19
 *
 
20
 *  Copyright (c) 2006 Adriano dos Santos Fernandes <adrianosf@uol.com.br>
 
21
 *  and all contributors signed below.
 
22
 *
 
23
 *  All Rights Reserved.
 
24
 *  Contributor(s): ______________________________________.
 
25
 */
 
26
 
 
27
#ifndef JRD_INTLUTIL_H
 
28
#define JRD_INTLUTIL_H
 
29
 
 
30
#include "../common/classes/array.h"
 
31
#include "../common/classes/GenericMap.h"
 
32
#include "../common/classes/fb_string.h"
 
33
#include "../jrd/intlobj_new.h"
 
34
 
 
35
namespace Jrd
 
36
{
 
37
        class CharSet;
 
38
}
 
39
 
 
40
namespace Firebird {
 
41
 
 
42
class IntlUtil
 
43
{
 
44
public:
 
45
        typedef Pair<Full<string, string> > SpecificAttribute;
 
46
        typedef GenericMap<SpecificAttribute> SpecificAttributesMap;
 
47
 
 
48
public:
 
49
        static string generateSpecificAttributes(
 
50
                Jrd::CharSet* cs, SpecificAttributesMap& map);
 
51
        static bool parseSpecificAttributes(
 
52
                Jrd::CharSet* cs, ULONG len, const UCHAR* s, SpecificAttributesMap* map);
 
53
 
 
54
        static string convertAsciiToUtf16(const string& ascii);
 
55
        static string convertUtf16ToAscii(const string& utf16, bool* error);
 
56
 
 
57
        static ULONG cvtAsciiToUtf16(csconvert* obj, ULONG nSrc, const UCHAR* pSrc,
 
58
                ULONG nDest, UCHAR* pDest, USHORT* err_code, ULONG* err_position);
 
59
        static ULONG cvtUtf16ToAscii(csconvert* obj, ULONG nSrc, const UCHAR* pSrc,
 
60
                ULONG nDest, UCHAR* pDest, USHORT* err_code, ULONG* err_position);
 
61
 
 
62
        static void initAsciiCharset(charset* cs);
 
63
        static void initConvert(csconvert* cvt, pfn_INTL_convert func);
 
64
        static void initNarrowCharset(charset* cs, const ASCII* name);
 
65
        static bool initUnicodeCollation(texttype* tt, charset* cs, const ASCII* name,
 
66
                USHORT attributes, const UCharBuffer& specificAttributes, const string& configInfo);
 
67
 
 
68
        static ULONG toLower(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
 
69
                const ULONG* exceptions);
 
70
        static ULONG toUpper(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
 
71
                const ULONG* exceptions);
 
72
 
 
73
        static bool readOneChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size);
 
74
 
 
75
        static bool setupIcuAttributes(charset* cs, const string& specificAttributes,
 
76
                const string& configInfo, string& newSpecificAttributes);
 
77
 
 
78
private:
 
79
        static string escapeAttribute(Jrd::CharSet* cs, const string& s);
 
80
        static string unescapeAttribute(Jrd::CharSet* cs, const string& s);
 
81
 
 
82
        static bool isAttributeEscape(Jrd::CharSet* cs, const UCHAR* s, ULONG size);
 
83
 
 
84
        static bool readAttributeChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size, bool returnEscape);
 
85
};
 
86
 
 
87
}       // namespace Firebird
 
88
 
 
89
#endif  // JRD_INTLUTIL_H