ICU 49.1.1  49.1.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 
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__