Debian Codegraph @

core/libs/dngwriter/extra/xmp_sdk/source/UnicodeConversions.hpp

raw
1 #ifndef __UnicodeConversions_h__
2 #define __UnicodeConversions_h__
3
4 // =================================================================================================
5 // Copyright 2004 Adobe
6 // All Rights Reserved.
7 //
8 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
9 // of the Adobe license agreement accompanying it. If you have received this file from a source other
10 // than Adobe, then your use, modification, or distribution of it requires the prior written permission
11 // of Adobe.
12 // =================================================================================================
13
14 #if AdobePrivate
15 // =================================================================================================
16 // Change history
17 // ==============
18 //
19 // Writers:
20 // AWL Alan Lillich
21 //
22 // mm-dd-yy who Description of changes, most recent on top.
23 //
24 // 06-07-06 AWL 4.0-c007-f010 Improve the Unicode conversions.
25 // 03-24-06 AWL 4.0-c001 Adapt for move to ham-perforce, integrate XMPFiles, bump version to 4.
26 //
27 // 01-28-05 AWL 3.2-001 Remove BIB.
28 // 02-02-05 AWL 3.1.1-110 [1145657] Add UTF8_to_UTF16 and UTF8_to_UTF16 to convert std::string values.
29 // 12-09-04 AWl 3.1.1-099 [1041438] Add parsing and serialization support for UTF-16 and UTF-32.
30 // 12-06-04 AWL Cleanup for toolkit builds.
31 // 11-30-04 AWL Initial creation.
32 //
33 // =================================================================================================
34 #endif // AdobePrivate
35
36 #include <string>
37
38 // =================================================================================================
39
40 typedef XMP_Uns8 UTF8Unit;
41 typedef XMP_Uns16 UTF16Unit;
42 typedef XMP_Uns32 UTF32Unit;
43
44 // -------------------------------------------------------------------------------------------------
45
46 // ! The UTF16 and UTF32 counts are in storage units, not bytes! CodePoint values are always native.
47
48 // *** MIght be better to return a status than throw an exception for errors?
49
50 typedef void (*CodePoint_to_UTF16_Proc) ( const UTF32Unit cpIn, UTF16Unit * utf16Out, const size_t utf16Len, size_t * utf16Written );
51
52 typedef void (*CodePoint_from_UTF16_Proc) ( const UTF16Unit * utf16In, const size_t utf16Len, UTF32Unit * cpOut, size_t * utf16Read );
53
54 typedef void (*UTF8_to_UTF16_Proc) ( const UTF8Unit * utf8In, const size_t utf8Len,
55 UTF16Unit * utf16Out, const size_t utf16Len,
56 size_t * utf8Read, size_t * utf16Written );
57
58 typedef void (*UTF8_to_UTF32_Proc) ( const UTF8Unit * utf8In, const size_t utf8Len,
59 UTF32Unit * utf32Out, const size_t utf32Len,
60 size_t * utf8Read, size_t * utf32Written );
61
62 typedef void (*UTF16_to_UTF8_Proc) ( const UTF16Unit * utf16In, const size_t utf16Len,
63 UTF8Unit * utf8Out, const size_t utf8Len,
64 size_t * utf16Read, size_t * utf8Written );
65
66 typedef void (*UTF32_to_UTF8_Proc) ( const UTF32Unit * utf32In, const size_t utf32Len,
67 UTF8Unit * utf8Out, const size_t utf8Len,
68 size_t * utf32Read, size_t * utf8Written );
69
70 typedef void (*UTF16_to_UTF32_Proc) ( const UTF16Unit * utf16In, const size_t utf16Len,
71 UTF32Unit * utf32Out, const size_t utf32Len,
72 size_t * utf16Read, size_t * utf32Written );
73
74 typedef void (*UTF32_to_UTF16_Proc) ( const UTF32Unit * utf32In, const size_t utf32Len,
75 UTF16Unit * utf16Out, const size_t utf16Len,
76 size_t * utf32Read, size_t * utf16Written );
77
78 // -------------------------------------------------------------------------------------------------
79
80 extern void CodePoint_to_UTF8 ( const UTF32Unit cpIn, UTF8Unit * utf8Out, const size_t utf8Len, size_t * utf8Written );
81
82 extern void CodePoint_from_UTF8 ( const UTF8Unit * utf8In, const size_t utf8Len, UTF32Unit * cpOut, size_t * utf8Read );
83
84 extern CodePoint_to_UTF16_Proc CodePoint_to_UTF16BE;
85 extern CodePoint_to_UTF16_Proc CodePoint_to_UTF16LE;
86
87 extern CodePoint_from_UTF16_Proc CodePoint_from_UTF16BE;
88 extern CodePoint_from_UTF16_Proc CodePoint_from_UTF16LE;
89
90 extern UTF8_to_UTF16_Proc UTF8_to_UTF16BE;
91 extern UTF8_to_UTF16_Proc UTF8_to_UTF16LE;
92
93 extern UTF8_to_UTF32_Proc UTF8_to_UTF32BE;
94 extern UTF8_to_UTF32_Proc UTF8_to_UTF32LE;
95
96 extern UTF16_to_UTF8_Proc UTF16BE_to_UTF8;
97 extern UTF16_to_UTF8_Proc UTF16LE_to_UTF8;
98
99 extern UTF32_to_UTF8_Proc UTF32BE_to_UTF8;
100 extern UTF32_to_UTF8_Proc UTF32LE_to_UTF8;
101
102 extern UTF8_to_UTF16_Proc UTF8_to_UTF16Native;
103 extern UTF8_to_UTF32_Proc UTF8_to_UTF32Native;
104
105 extern UTF16_to_UTF8_Proc UTF16Native_to_UTF8;
106 extern UTF32_to_UTF8_Proc UTF32Native_to_UTF8;
107
108 extern UTF16_to_UTF32_Proc UTF16BE_to_UTF32BE;
109 extern UTF16_to_UTF32_Proc UTF16BE_to_UTF32LE;
110
111 extern UTF16_to_UTF32_Proc UTF16LE_to_UTF32BE;
112 extern UTF16_to_UTF32_Proc UTF16LE_to_UTF32LE;
113
114 extern UTF32_to_UTF16_Proc UTF32BE_to_UTF16BE;
115 extern UTF32_to_UTF16_Proc UTF32BE_to_UTF16LE;
116
117 extern UTF32_to_UTF16_Proc UTF32LE_to_UTF16BE;
118 extern UTF32_to_UTF16_Proc UTF32LE_to_UTF16LE;
119
120 extern void SwapUTF16 ( const UTF16Unit * utf16In, UTF16Unit * utf16Out, const size_t utf16Len );
121 extern void SwapUTF32 ( const UTF32Unit * utf32In, UTF32Unit * utf32Out, const size_t utf32Len );
122
123 extern void ToUTF16 ( const UTF8Unit * utf8In, size_t utf8Len, std::string * utf16Str, bool bigEndian );
124 extern void ToUTF32 ( const UTF8Unit * utf8In, size_t utf8Len, std::string * utf32Str, bool bigEndian );
125
126 extern void FromUTF16 ( const UTF16Unit * utf16In, size_t utf16Len, std::string * utf8Str, bool bigEndian );
127 extern void FromUTF32 ( const UTF32Unit * utf32In, size_t utf32Len, std::string * utf8Str, bool bigEndian );
128
129 extern void ToUTF16Native ( const UTF8Unit * utf8In, size_t utf8Len, std::string * utf16Str );
130 extern void ToUTF32Native ( const UTF8Unit * utf8In, size_t utf8Len, std::string * utf32Str );
131
132 extern void FromUTF16Native ( const UTF16Unit * utf16In, size_t utf16Len, std::string * utf8Str );
133 extern void FromUTF32Native ( const UTF32Unit * utf32In, size_t utf32Len, std::string * utf8Str );
134
135 extern void InitializeUnicodeConversions();
136
137 // =================================================================================================
138
139 #endif // __UnicodeConversions_h__