idna.h

Go to the documentation of this file.
00001 /*
00002 *******************************************************************************
00003 *   Copyright (C) 2010-2012, 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 IDNAInfo;
00035 
00048 class U_COMMON_API IDNA : public UObject {
00049 public:
00054     ~IDNA();
00055 
00089     static IDNA *
00090     createUTS46Instance(uint32_t options, UErrorCode &errorCode);
00091 
00112     virtual UnicodeString &
00113     labelToASCII(const UnicodeString &label, UnicodeString &dest,
00114                  IDNAInfo &info, UErrorCode &errorCode) const = 0;
00115 
00134     virtual UnicodeString &
00135     labelToUnicode(const UnicodeString &label, UnicodeString &dest,
00136                    IDNAInfo &info, UErrorCode &errorCode) const = 0;
00137 
00158     virtual UnicodeString &
00159     nameToASCII(const UnicodeString &name, UnicodeString &dest,
00160                 IDNAInfo &info, UErrorCode &errorCode) const = 0;
00161 
00180     virtual UnicodeString &
00181     nameToUnicode(const UnicodeString &name, UnicodeString &dest,
00182                   IDNAInfo &info, UErrorCode &errorCode) const = 0;
00183 
00184     // UTF-8 versions of the processing methods ---------------------------- ***
00185 
00200     virtual void
00201     labelToASCII_UTF8(const StringPiece &label, ByteSink &dest,
00202                       IDNAInfo &info, UErrorCode &errorCode) const;
00203 
00218     virtual void
00219     labelToUnicodeUTF8(const StringPiece &label, ByteSink &dest,
00220                        IDNAInfo &info, UErrorCode &errorCode) const;
00221 
00236     virtual void
00237     nameToASCII_UTF8(const StringPiece &name, ByteSink &dest,
00238                      IDNAInfo &info, UErrorCode &errorCode) const;
00239 
00254     virtual void
00255     nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest,
00256                       IDNAInfo &info, UErrorCode &errorCode) const;
00257 
00258 private:
00259     // No ICU "poor man's RTTI" for this class nor its subclasses.
00260     virtual UClassID getDynamicClassID() const;
00261 };
00262 
00263 class UTS46;
00264 
00270 class U_COMMON_API IDNAInfo : public UMemory {
00271 public:
00276     IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
00282     UBool hasErrors() const { return errors!=0; }
00289     uint32_t getErrors() const { return errors; }
00303     UBool isTransitionalDifferent() const { return isTransDiff; }
00304 
00305 private:
00306     friend class UTS46;
00307 
00308     IDNAInfo(const IDNAInfo &other);  // no copying
00309     IDNAInfo &operator=(const IDNAInfo &other);  // no copying
00310 
00311     void reset() {
00312         errors=labelErrors=0;
00313         isTransDiff=FALSE;
00314         isBiDi=FALSE;
00315         isOkBiDi=TRUE;
00316     }
00317 
00318     uint32_t errors, labelErrors;
00319     UBool isTransDiff;
00320     UBool isBiDi;
00321     UBool isOkBiDi;
00322 };
00323 
00324 U_NAMESPACE_END
00325 
00326 #endif  // UCONFIG_NO_IDNA
00327 #endif  // __IDNA_H__

Generated on 25 Nov 2014 for ICU 50.1.2 by  doxygen 1.4.7