ICU 4.8.1.1
4.8.1.1
|
00001 /* 00002 ******************************************************************************* 00003 * Copyright (C) 2010, International Business Machines 00004 * Corporation and others. All Rights Reserved. 00005 ******************************************************************************* 00006 * file name: idna.h 00007 * encoding: US-ASCII 00008 * tab size: 8 (not used) 00009 * indentation:4 00010 * 00011 * created on: 2010mar05 00012 * created by: Markus W. Scherer 00013 */ 00014 00015 #ifndef __IDNA_H__ 00016 #define __IDNA_H__ 00017 00023 #include "unicode/utypes.h" 00024 00025 #if !UCONFIG_NO_IDNA 00026 00027 #include "unicode/bytestream.h" 00028 #include "unicode/stringpiece.h" 00029 #include "unicode/uidna.h" 00030 #include "unicode/unistr.h" 00031 00032 U_NAMESPACE_BEGIN 00033 00034 class U_COMMON_API IDNAInfo; 00035 00048 class U_COMMON_API IDNA : public UObject { 00049 public: 00083 static IDNA * 00084 createUTS46Instance(uint32_t options, UErrorCode &errorCode); 00085 00106 virtual UnicodeString & 00107 labelToASCII(const UnicodeString &label, UnicodeString &dest, 00108 IDNAInfo &info, UErrorCode &errorCode) const = 0; 00109 00128 virtual UnicodeString & 00129 labelToUnicode(const UnicodeString &label, UnicodeString &dest, 00130 IDNAInfo &info, UErrorCode &errorCode) const = 0; 00131 00152 virtual UnicodeString & 00153 nameToASCII(const UnicodeString &name, UnicodeString &dest, 00154 IDNAInfo &info, UErrorCode &errorCode) const = 0; 00155 00174 virtual UnicodeString & 00175 nameToUnicode(const UnicodeString &name, UnicodeString &dest, 00176 IDNAInfo &info, UErrorCode &errorCode) const = 0; 00177 00178 // UTF-8 versions of the processing methods ---------------------------- *** 00179 00194 virtual void 00195 labelToASCII_UTF8(const StringPiece &label, ByteSink &dest, 00196 IDNAInfo &info, UErrorCode &errorCode) const; 00197 00212 virtual void 00213 labelToUnicodeUTF8(const StringPiece &label, ByteSink &dest, 00214 IDNAInfo &info, UErrorCode &errorCode) const; 00215 00230 virtual void 00231 nameToASCII_UTF8(const StringPiece &name, ByteSink &dest, 00232 IDNAInfo &info, UErrorCode &errorCode) const; 00233 00248 virtual void 00249 nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest, 00250 IDNAInfo &info, UErrorCode &errorCode) const; 00251 00252 private: 00253 // No ICU "poor man's RTTI" for this class nor its subclasses. 00254 virtual UClassID getDynamicClassID() const; 00255 }; 00256 00257 class UTS46; 00258 00264 class U_COMMON_API IDNAInfo : public UMemory { 00265 public: 00270 IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {} 00276 UBool hasErrors() const { return errors!=0; } 00283 uint32_t getErrors() const { return errors; } 00297 UBool isTransitionalDifferent() const { return isTransDiff; } 00298 00299 private: 00300 friend class UTS46; 00301 00302 IDNAInfo(const IDNAInfo &other); // no copying 00303 IDNAInfo &operator=(const IDNAInfo &other); // no copying 00304 00305 void reset() { 00306 errors=labelErrors=0; 00307 isTransDiff=FALSE; 00308 isBiDi=FALSE; 00309 isOkBiDi=TRUE; 00310 } 00311 00312 uint32_t errors, labelErrors; 00313 UBool isTransDiff; 00314 UBool isBiDi; 00315 UBool isOkBiDi; 00316 }; 00317 00318 U_NAMESPACE_END 00319 00320 #endif // UCONFIG_NO_IDNA 00321 #endif // __IDNA_H__