ICU 57.1  57.1
idna.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2010-2012, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 * file name: idna.h
7 * encoding: US-ASCII
8 * tab size: 8 (not used)
9 * indentation:4
10 *
11 * created on: 2010mar05
12 * created by: Markus W. Scherer
13 */
14 
15 #ifndef __IDNA_H__
16 #define __IDNA_H__
17 
23 #include "unicode/utypes.h"
24 
25 #if !UCONFIG_NO_IDNA
26 
27 #include "unicode/bytestream.h"
28 #include "unicode/stringpiece.h"
29 #include "unicode/uidna.h"
30 #include "unicode/unistr.h"
31 
33 
34 class IDNAInfo;
35 
48 class U_COMMON_API IDNA : public UObject {
49 public:
54  ~IDNA();
55 
89  static IDNA *
90  createUTS46Instance(uint32_t options, UErrorCode &errorCode);
91 
112  virtual UnicodeString &
113  labelToASCII(const UnicodeString &label, UnicodeString &dest,
114  IDNAInfo &info, UErrorCode &errorCode) const = 0;
115 
134  virtual UnicodeString &
135  labelToUnicode(const UnicodeString &label, UnicodeString &dest,
136  IDNAInfo &info, UErrorCode &errorCode) const = 0;
137 
158  virtual UnicodeString &
159  nameToASCII(const UnicodeString &name, UnicodeString &dest,
160  IDNAInfo &info, UErrorCode &errorCode) const = 0;
161 
180  virtual UnicodeString &
181  nameToUnicode(const UnicodeString &name, UnicodeString &dest,
182  IDNAInfo &info, UErrorCode &errorCode) const = 0;
183 
184  // UTF-8 versions of the processing methods ---------------------------- ***
185 
200  virtual void
201  labelToASCII_UTF8(const StringPiece &label, ByteSink &dest,
202  IDNAInfo &info, UErrorCode &errorCode) const;
203 
218  virtual void
219  labelToUnicodeUTF8(const StringPiece &label, ByteSink &dest,
220  IDNAInfo &info, UErrorCode &errorCode) const;
221 
236  virtual void
237  nameToASCII_UTF8(const StringPiece &name, ByteSink &dest,
238  IDNAInfo &info, UErrorCode &errorCode) const;
239 
254  virtual void
255  nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest,
256  IDNAInfo &info, UErrorCode &errorCode) const;
257 };
258 
259 class UTS46;
260 
266 class U_COMMON_API IDNAInfo : public UMemory {
267 public:
272  IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
278  UBool hasErrors() const { return errors!=0; }
285  uint32_t getErrors() const { return errors; }
299  UBool isTransitionalDifferent() const { return isTransDiff; }
300 
301 private:
302  friend class UTS46;
303 
304  IDNAInfo(const IDNAInfo &other); // no copying
305  IDNAInfo &operator=(const IDNAInfo &other); // no copying
306 
307  void reset() {
308  errors=labelErrors=0;
309  isTransDiff=FALSE;
310  isBiDi=FALSE;
311  isOkBiDi=TRUE;
312  }
313 
314  uint32_t errors, labelErrors;
315  UBool isTransDiff;
316  UBool isBiDi;
317  UBool isOkBiDi;
318 };
319 
321 
322 #endif // UCONFIG_NO_IDNA
323 #endif // __IDNA_H__
Output container for IDNA processing errors.
Definition: idna.h:266
IDNAInfo()
Constructor for stack allocation.
Definition: idna.h:272
C++ API: Unicode String.
A ByteSink can be filled with bytes.
Definition: bytestream.h:48
C++ API: StringPiece: Read-only byte string wrapper class.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
UBool isTransitionalDifferent() const
Returns TRUE if transitional and nontransitional processing produce different results.
Definition: idna.h:299
C++ API: Interface for writing bytes, and implementation classes.
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:238
C API: Internationalizing Domain Names in Applications (IDNA)
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
Basic definitions for ICU, for both C and C++ APIs.
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:242
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:357
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
uint32_t getErrors() const
Returns a bit set indicating IDNA processing errors.
Definition: idna.h:285
Abstract base class for IDNA processing.
Definition: idna.h:48
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:52
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UMemory is the common ICU base class.
Definition: uobject.h:110
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
UBool hasErrors() const
Were there IDNA processing errors?
Definition: idna.h:278