ICU 50.1.2  50.1.2
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 private:
259  // No ICU "poor man's RTTI" for this class nor its subclasses.
260  virtual UClassID getDynamicClassID() const;
261 };
262 
263 class UTS46;
264 
270 class U_COMMON_API IDNAInfo : public UMemory {
271 public:
276  IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
282  UBool hasErrors() const { return errors!=0; }
289  uint32_t getErrors() const { return errors; }
303  UBool isTransitionalDifferent() const { return isTransDiff; }
304 
305 private:
306  friend class UTS46;
307 
308  IDNAInfo(const IDNAInfo &other); // no copying
309  IDNAInfo &operator=(const IDNAInfo &other); // no copying
310 
311  void reset() {
312  errors=labelErrors=0;
313  isTransDiff=FALSE;
314  isBiDi=FALSE;
315  isOkBiDi=TRUE;
316  }
317 
318  uint32_t errors, labelErrors;
319  UBool isTransDiff;
320  UBool isBiDi;
321  UBool isOkBiDi;
322 };
323 
325 
326 #endif // UCONFIG_NO_IDNA
327 #endif // __IDNA_H__
Output container for IDNA processing errors.
Definition: idna.h:270
IDNAInfo()
Constructor for stack allocation.
Definition: idna.h:276
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
C++ API: Unicode String.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
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:303
C++ API: Interface for writing bytes, and implementation classes.
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:204
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:208
#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:246
uint32_t getErrors() const
Returns a bit set indicating IDNA processing errors.
Definition: idna.h:289
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:229
UMemory is the common ICU base class.
Definition: uobject.h:115
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200
UBool hasErrors() const
Were there IDNA processing errors?
Definition: idna.h:282