ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
idna.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2010, 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:
83  static IDNA *
84  createUTS46Instance(uint32_t options, UErrorCode &errorCode);
85 
106  virtual UnicodeString &
107  labelToASCII(const UnicodeString &label, UnicodeString &dest,
108  IDNAInfo &info, UErrorCode &errorCode) const = 0;
109 
128  virtual UnicodeString &
129  labelToUnicode(const UnicodeString &label, UnicodeString &dest,
130  IDNAInfo &info, UErrorCode &errorCode) const = 0;
131 
152  virtual UnicodeString &
153  nameToASCII(const UnicodeString &name, UnicodeString &dest,
154  IDNAInfo &info, UErrorCode &errorCode) const = 0;
155 
174  virtual UnicodeString &
175  nameToUnicode(const UnicodeString &name, UnicodeString &dest,
176  IDNAInfo &info, UErrorCode &errorCode) const = 0;
177 
178  // UTF-8 versions of the processing methods ---------------------------- ***
179 
194  virtual void
195  labelToASCII_UTF8(const StringPiece &label, ByteSink &dest,
196  IDNAInfo &info, UErrorCode &errorCode) const;
197 
212  virtual void
213  labelToUnicodeUTF8(const StringPiece &label, ByteSink &dest,
214  IDNAInfo &info, UErrorCode &errorCode) const;
215 
230  virtual void
231  nameToASCII_UTF8(const StringPiece &name, ByteSink &dest,
232  IDNAInfo &info, UErrorCode &errorCode) const;
233 
248  virtual void
249  nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest,
250  IDNAInfo &info, UErrorCode &errorCode) const;
251 
252 private:
253  // No ICU "poor man's RTTI" for this class nor its subclasses.
254  virtual UClassID getDynamicClassID() const;
255 };
256 
257 class UTS46;
258 
264 class U_COMMON_API IDNAInfo : public UMemory {
265 public:
270  IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
276  UBool hasErrors() const { return errors!=0; }
283  uint32_t getErrors() const { return errors; }
297  UBool isTransitionalDifferent() const { return isTransDiff; }
298 
299 private:
300  friend class UTS46;
301 
302  IDNAInfo(const IDNAInfo &other); // no copying
303  IDNAInfo &operator=(const IDNAInfo &other); // no copying
304 
305  void reset() {
306  errors=labelErrors=0;
307  isTransDiff=FALSE;
308  isBiDi=FALSE;
309  isOkBiDi=TRUE;
310  }
311 
312  uint32_t errors, labelErrors;
313  UBool isTransDiff;
314  UBool isBiDi;
315  UBool isOkBiDi;
316 };
317 
319 
320 #endif // UCONFIG_NO_IDNA
321 #endif // __IDNA_H__
IDNAInfo()
Constructor for stack allocation.
Definition: idna.h:270
A ByteSink can be filled with bytes.
Definition: bytestream.h:48
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:52
C++ API: Unicode String.
Abstract base class for IDNA processing.
Definition: idna.h:48
uint32_t getErrors() const
Returns a bit set indicating IDNA processing errors.
Definition: idna.h:283
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:131
C++ API: Interface for writing bytes, and implementation classes.
Output container for IDNA processing errors.
Definition: idna.h:264
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:232
UMemory is the common ICU base class.
Definition: uobject.h:101
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:188
C API: Internationalizing Domain Names in Applications (IDNA)
UBool hasErrors() const
Were there IDNA processing errors?
Definition: idna.h:276
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:215
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:385
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:639
UBool isTransitionalDifferent() const
Returns TRUE if transitional and nontransitional processing produce different results.
Definition: idna.h:297
Basic definitions for ICU, for both C and C++ APIs.
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:236
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:520
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228