Kaynağa Gözat

use icu in sqlite for better international character searches - http://www.sqlite.org/faq.html#q18

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@765 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 10 yıl önce
ebeveyn
işleme
90282b963d
100 değiştirilmiş dosya ile 18621 ekleme ve 33 silme
  1. 8 8
      CP_Main.vcxproj
  2. BIN
      Debug/icudt55.dll
  3. BIN
      Debug/icuin55.dll
  4. BIN
      Debug/icuio55.dll
  5. BIN
      Debug/icule55.dll
  6. BIN
      Debug/iculx55.dll
  7. BIN
      Debug/icutu55.dll
  8. BIN
      Debug/icuuc55.dll
  9. BIN
      Debug64/icudt55.dll
  10. BIN
      Debug64/icuin55.dll
  11. BIN
      Debug64/icuio55.dll
  12. BIN
      Debug64/icule55.dll
  13. BIN
      Debug64/iculx55.dll
  14. BIN
      Debug64/icutu55.dll
  15. BIN
      Debug64/icuuc55.dll
  16. 14 0
      DittoSetup/Build Portable ZIP_10.bat
  17. 14 0
      DittoSetup/DittoSetup_10.iss
  18. 21 7
      MainFrm.cpp
  19. 7 4
      QPasteWnd.cpp
  20. 33 10
      QuickPaste.cpp
  21. BIN
      Release/icudt55.dll
  22. BIN
      Release/icuin55.dll
  23. BIN
      Release/icuio55.dll
  24. BIN
      Release/icule55.dll
  25. BIN
      Release/iculx55.dll
  26. BIN
      Release/icutu55.dll
  27. BIN
      Release/icuuc55.dll
  28. BIN
      release64/icudt55.dll
  29. BIN
      release64/icuin55.dll
  30. BIN
      release64/icuio55.dll
  31. BIN
      release64/icule55.dll
  32. BIN
      release64/iculx55.dll
  33. BIN
      release64/icutu55.dll
  34. BIN
      release64/icuuc55.dll
  35. BIN
      sqlite/lib32/icudt.exp
  36. BIN
      sqlite/lib32/icudt.lib
  37. BIN
      sqlite/lib32/icuin.exp
  38. BIN
      sqlite/lib32/icuin.lib
  39. BIN
      sqlite/lib32/icuio.exp
  40. BIN
      sqlite/lib32/icuio.lib
  41. BIN
      sqlite/lib32/icule.exp
  42. BIN
      sqlite/lib32/icule.lib
  43. BIN
      sqlite/lib32/iculx.exp
  44. BIN
      sqlite/lib32/iculx.lib
  45. BIN
      sqlite/lib32/icutu.exp
  46. BIN
      sqlite/lib32/icutu.lib
  47. BIN
      sqlite/lib32/icuuc.exp
  48. BIN
      sqlite/lib32/icuuc.lib
  49. BIN
      sqlite/lib32/testplug.exp
  50. BIN
      sqlite/lib32/testplug.lib
  51. BIN
      sqlite/lib64/icudt.exp
  52. BIN
      sqlite/lib64/icudt.lib
  53. BIN
      sqlite/lib64/icuin.exp
  54. BIN
      sqlite/lib64/icuin.lib
  55. BIN
      sqlite/lib64/icuio.exp
  56. BIN
      sqlite/lib64/icuio.lib
  57. BIN
      sqlite/lib64/icule.exp
  58. BIN
      sqlite/lib64/icule.lib
  59. BIN
      sqlite/lib64/iculx.exp
  60. BIN
      sqlite/lib64/iculx.lib
  61. BIN
      sqlite/lib64/icutu.exp
  62. BIN
      sqlite/lib64/icutu.lib
  63. BIN
      sqlite/lib64/icuuc.exp
  64. BIN
      sqlite/lib64/icuuc.lib
  65. BIN
      sqlite/lib64/testplug.exp
  66. BIN
      sqlite/lib64/testplug.lib
  67. 4 4
      sqlite/sqlite3.c
  68. 752 0
      sqlite/unicode/alphaindex.h
  69. 232 0
      sqlite/unicode/appendable.h
  70. 214 0
      sqlite/unicode/basictz.h
  71. 655 0
      sqlite/unicode/brkiter.h
  72. 257 0
      sqlite/unicode/bytestream.h
  73. 519 0
      sqlite/unicode/bytestrie.h
  74. 181 0
      sqlite/unicode/bytestriebuilder.h
  75. 2549 0
      sqlite/unicode/calendar.h
  76. 208 0
      sqlite/unicode/caniter.h
  77. 722 0
      sqlite/unicode/chariter.h
  78. 594 0
      sqlite/unicode/choicfmt.h
  79. 404 0
      sqlite/unicode/coleitr.h
  80. 1269 0
      sqlite/unicode/coll.h
  81. 330 0
      sqlite/unicode/compactdecimalformat.h
  82. 130 0
      sqlite/unicode/curramt.h
  83. 258 0
      sqlite/unicode/currpinf.h
  84. 110 0
      sqlite/unicode/currunit.h
  85. 972 0
      sqlite/unicode/datefmt.h
  86. 40 0
      sqlite/unicode/dbbi.h
  87. 484 0
      sqlite/unicode/dcfmtsym.h
  88. 2478 0
      sqlite/unicode/decimfmt.h
  89. 215 0
      sqlite/unicode/docmain.h
  90. 971 0
      sqlite/unicode/dtfmtsym.h
  91. 158 0
      sqlite/unicode/dtintrv.h
  92. 985 0
      sqlite/unicode/dtitvfmt.h
  93. 514 0
      sqlite/unicode/dtitvinf.h
  94. 512 0
      sqlite/unicode/dtptngen.h
  95. 250 0
      sqlite/unicode/dtrule.h
  96. 64 0
      sqlite/unicode/enumset.h
  97. 137 0
      sqlite/unicode/errorcode.h
  98. 291 0
      sqlite/unicode/fieldpos.h
  99. 760 0
      sqlite/unicode/fmtable.h
  100. 305 0
      sqlite/unicode/format.h

+ 8 - 8
CP_Main.vcxproj

@@ -113,7 +113,7 @@
       <Optimization>MaxSpeed</Optimization>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_MBCS;AFTER_98;UNICODE;HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_MBCS;AFTER_98;UNICODE;HAVE_CONFIG_H;%(PreprocessorDefinitions);SQLITE_ENABLE_ICU</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -129,7 +129,7 @@
       <CompileAs>Default</CompileAs>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;Winmm.lib;Version.Lib;riched20.lib;EncryptDecrypt.lib;TinyXml\tinyxml.lib;zlib\zlib.lib;focus.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;Winmm.lib;Version.Lib;riched20.lib;EncryptDecrypt.lib;TinyXml\tinyxml.lib;zlib\zlib.lib;focus.lib;Shlwapi.lib;sqlite\lib32\icuio.lib;sqlite\lib32\iculx.lib;sqlite\lib32\icule.lib;sqlite\lib32\icutu.lib;sqlite\lib32\icuin.lib;sqlite\lib32\icuuc.lib;sqlite\lib32\icudt.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>release\Ditto.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@@ -168,7 +168,7 @@
       <Optimization>MaxSpeed</Optimization>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_MBCS;AFTER_98;UNICODE;HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_MBCS;AFTER_98;UNICODE;HAVE_CONFIG_H;%(PreprocessorDefinitions);SQLITE_ENABLE_ICU</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -184,7 +184,7 @@
       <CompileAs>Default</CompileAs>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;Winmm.lib;$(WindowsSdkDir)lib\x64\Version.lib;EncryptDecrypt64.lib;TinyXml\tinyxml64.lib;zlib\zlib64.lib;focus64.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;Winmm.lib;$(WindowsSdkDir)lib\x64\Version.lib;EncryptDecrypt64.lib;TinyXml\tinyxml64.lib;zlib\zlib64.lib;focus64.lib;Shlwapi.lib;sqlite\lib64\icuio.lib;sqlite\lib64\iculx.lib;sqlite\lib64\icule.lib;sqlite\lib64\icutu.lib;sqlite\lib64\icuin.lib;sqlite\lib64\icuuc.lib;sqlite\lib64\icudt.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>release64\Ditto.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@@ -220,7 +220,7 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_MBCS;AFTER_98;UNICODE;HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_MBCS;AFTER_98;UNICODE;HAVE_CONFIG_H;%(PreprocessorDefinitions);SQLITE_ENABLE_ICU</PreprocessorDefinitions>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <PrecompiledHeader>Use</PrecompiledHeader>
@@ -235,7 +235,7 @@
       <CompileAs>Default</CompileAs>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;Winmm.lib;Version.Lib;Pdh.lib;riched20.lib;EncryptDecryptD.lib;zlib\zlib.lib;TinyXml\tinyxml.lib;focus.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;Winmm.lib;Version.Lib;Pdh.lib;riched20.lib;EncryptDecryptD.lib;zlib\zlib.lib;TinyXml\tinyxml.lib;focus.lib;Shlwapi.lib;%(AdditionalDependencies);sqlite\lib32\icuio.lib;sqlite\lib32\iculx.lib;sqlite\lib32\icule.lib;sqlite\lib32\icutu.lib;sqlite\lib32\icuin.lib;sqlite\lib32\icuuc.lib;sqlite\lib32\icudt.lib</AdditionalDependencies>
       <OutputFile>debug\Ditto.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -272,7 +272,7 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_DEBUG;_WINDOWS;_MBCS;UNICODE;HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_DEBUG;_WINDOWS;_MBCS;UNICODE;HAVE_CONFIG_H;%(PreprocessorDefinitions);SQLITE_ENABLE_ICU</PreprocessorDefinitions>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <PrecompiledHeader>Use</PrecompiledHeader>
@@ -287,7 +287,7 @@
       <CompileAs>Default</CompileAs>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;Winmm.lib;Pdh.lib;$(WindowsSdkDir)lib\x64\Version.lib;EncryptDecryptD64.lib;zlib\zlibd64.lib;TinyXml\tinyxmld64.lib;focus64.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;Winmm.lib;Pdh.lib;$(WindowsSdkDir)lib\x64\Version.lib;EncryptDecryptD64.lib;zlib\zlibd64.lib;TinyXml\tinyxmld64.lib;focus64.lib;Shlwapi.lib;sqlite\lib64\icuio.lib;sqlite\lib64\iculx.lib;sqlite\lib64\icule.lib;sqlite\lib64\icutu.lib;sqlite\lib64\icuin.lib;sqlite\lib64\icuuc.lib;sqlite\lib64\icudt.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>debug64\Ditto.exe</OutputFile>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <GenerateDebugInformation>true</GenerateDebugInformation>

BIN
Debug/icudt55.dll


BIN
Debug/icuin55.dll


BIN
Debug/icuio55.dll


BIN
Debug/icule55.dll


BIN
Debug/iculx55.dll


BIN
Debug/icutu55.dll


BIN
Debug/icuuc55.dll


BIN
Debug64/icudt55.dll


BIN
Debug64/icuin55.dll


BIN
Debug64/icuio55.dll


BIN
Debug64/icule55.dll


BIN
Debug64/iculx55.dll


BIN
Debug64/icutu55.dll


BIN
Debug64/icuuc55.dll


+ 14 - 0
DittoSetup/Build Portable ZIP_10.bat

@@ -16,6 +16,13 @@ if "%2" == "bit64" goto bit64
 copy ..\Release\Ditto.exe Ditto\Ditto.exe
 copy ..\Release\Addins\*.dll Ditto\Addins\
 copy mfc-crt_10\* Ditto\
+copy ..\Release\icuuc55.dll; Ditto\icuuc55.dll
+copy ..\Release\icuin55.dll; Ditto\icuin55.dll
+copy ..\Release\icutu55.dll; Ditto\icutu55.dll
+copy ..\Release\icule55.dll; Ditto\icule55.dll
+copy ..\Release\iculx55.dll; Ditto\iculx55.dll
+copy ..\Release\icuio55.dll; Ditto\icuio55.dll
+copy ..\Release\icudt55.dll; Ditto\icudt55.dll
 
 if "%2"=="" GOTO skipBit64
 if "%2"=="bit32" GOTO skipBit64	
@@ -24,6 +31,13 @@ if "%2"=="bit32" GOTO skipBit64
 copy ..\Release64\Ditto.exe Ditto\Ditto.exe
 copy ..\Release64\Addins\*.dll Ditto\Addins\
 copy mfc-crt64\* Ditto\
+copy ..\Release64\icuuc55.dll; Ditto\icuuc55.dll
+copy ..\Release64\icuin55.dll; Ditto\icuin55.dll
+copy ..\Release64\icutu55.dll; Ditto\icutu55.dll
+copy ..\Release64\icule55.dll; Ditto\icule55.dll
+copy ..\Release64\iculx55.dll; Ditto\iculx55.dll
+copy ..\Release64\icuio55.dll; Ditto\icuio55.dll
+copy ..\Release64\icudt55.dll; Ditto\icudt55.dll
 
 :skipBit64
 

+ 14 - 0
DittoSetup/DittoSetup_10.iss

@@ -62,11 +62,25 @@ Name: RunAtStartup; Description: Run Ditto on Windows Startup
 	Source: ..\Release64\Ditto.exe; DestDir: {app}; DestName: Ditto.exe; Flags: ignoreversion;
 	Source: ..\Release64\Addins\DittoUtil.dll; DestDir: {app}\Addins; Flags: ignoreversion
 	Source: mfc-crt64\*; DestDir: {app}      
+  Source: ..\Release64\icuuc55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release64\icuin55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release64\icutu55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release64\icule55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release64\iculx55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release64\icuio55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release64\icudt55.dll; DestDir: {app}; Flags: ignoreversion
 #endif
 #ifndef bit64
 	Source: ..\Release\Ditto.exe; DestDir: {app}; DestName: Ditto.exe; Flags: ignoreversion;
 	Source: ..\Addins\DittoUtil\Release\DittoUtil.dll; DestDir: {app}\Addins; Flags: ignoreversion
 	Source: mfc-crt_10\*; DestDir: {app}
+  Source: ..\Release\icuuc55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release\icuin55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release\icutu55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release\icule55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release\iculx55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release\icuio55.dll; DestDir: {app}; Flags: ignoreversion
+  Source: ..\Release\icudt55.dll; DestDir: {app}; Flags: ignoreversion
 #endif
 
 Source: Changes.txt; DestDir: {app}

+ 21 - 7
MainFrm.cpp

@@ -397,18 +397,32 @@ void CMainFrame::DoFirstTenPositionsPaste(int nPos)
 {
     try
 	{
-		CString csSort = "case when (Main.stickyClipOrder = 0 OR Main.stickyClipOrder IS NULL) then -9999999 else Main.stickyClipOrder END DESC, "
-			"Main.bIsGroup ASC, "
-			"clipOrder DESC";
+		CString csSort = _T("");
 
-		CString filter = "((Main.bIsGroup = 1 AND Main.lParentID = -1) OR (Main.bIsGroup = 0 AND Main.lParentID = -1))";
+		csSort = "Main.bIsGroup ASC, "
+			"Main.stickyClipOrder DESC, "
+			"Main.clipOrder DESC";
 
-		if(g_Opt.m_bShowAllClipsInMainList)
+		CString strFilter = _T("");
+
+		if (g_Opt.m_bShowAllClipsInMainList)
+		{
+			if (CGetSetOptions::GetShowGroupsInMainList())
+			{
+				//found to be slower on large databases
+				strFilter = "((Main.bIsGroup = 1 AND Main.lParentID = -1) OR Main.bIsGroup = 0)";
+			}
+			else
+			{
+				strFilter = "(Main.bIsGroup = 0)";
+			}
+		}
+		else
 		{
-			filter = "((Main.bIsGroup = 1 AND Main.lParentID = -1) OR Main.bIsGroup = 0)";
+			strFilter = "((Main.bIsGroup = 1 AND Main.lParentID = -1) OR (Main.bIsGroup = 0 AND Main.lParentID = -1))";
 		}
 
-        CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID, bIsGroup FROM Main WHERE %s ORDER BY %s LIMIT 1 OFFSET %d"), filter, csSort, nPos);
+		CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID, bIsGroup FROM Main WHERE %s ORDER BY %s LIMIT 1 OFFSET %d"), strFilter, csSort, nPos);
 
         if(q.eof() == false)
         {

+ 7 - 4
QPasteWnd.cpp

@@ -601,10 +601,13 @@ BOOL CQPasteWnd::HideQPasteWindow (bool releaseFocus, bool clearSearchData)
 
 void CQPasteWnd::SaveWindowSize()
 {
-	CRect rect;
-	GetWindowRectEx(&rect);
-	CGetSetOptions::SetQuickPasteSize(rect.Size());
-	CGetSetOptions::SetQuickPastePoint(rect.TopLeft());
+	if (this->IsIconic() == FALSE)
+	{
+		CRect rect;
+		GetWindowRectEx(&rect);
+		CGetSetOptions::SetQuickPasteSize(rect.Size());
+		CGetSetOptions::SetQuickPastePoint(rect.TopLeft());
+	}
 }
 
 BOOL CQPasteWnd::ShowQPasteWindow(BOOL bFillList)

+ 33 - 10
QuickPaste.cpp

@@ -115,7 +115,8 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, bool bAtPrevPos, bool bFromKeyboa
 	m_pwndPaste->MinMaxWindow(FORCE_MAX);
 	
 	//If it is a window get the rect otherwise get the saved point and size
-	if (IsWindow(m_pwndPaste->m_hWnd))
+	if (IsWindow(m_pwndPaste->m_hWnd) &&
+		m_pwndPaste->IsIconic() == FALSE)
 	{
 		m_pwndPaste->GetWindowRect(rcPrev);
 		csSize = rcPrev.Size();
@@ -189,7 +190,7 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, bool bAtPrevPos, bool bFromKeyboa
 		forceMoveWindow = true;
 
 		Log(StrF(_T("Invalid initial size %d %d %d %d, Centered Window %d %d %d %d"), orig.left, orig.top, orig.right, orig.bottom, crRect.left, crRect.top, crRect.right, crRect.bottom));
-	}
+	}	
 	
 	if( !IsWindow(m_pwndPaste->m_hWnd) )
 	{
@@ -202,19 +203,41 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, bool bAtPrevPos, bool bFromKeyboa
 
 		VERIFY( m_pwndPaste->Create(crRect, pLocalParent) );
 	}	
-	
-	if((nPosition == POS_AT_CARET) ||
-		(nPosition == POS_AT_CURSOR) ||
-		bAtPrevPos ||
-		forceMoveWindow)
+
+	//If minimized
+	if (m_pwndPaste->IsIconic())
 	{
-		m_pwndPaste->MoveWindow(crRect);
+		m_pwndPaste->ShowWindow(SW_RESTORE);
+
+		if ((nPosition == POS_AT_CARET) ||
+			(nPosition == POS_AT_CURSOR) ||
+			bAtPrevPos ||
+			forceMoveWindow)
+		{
+			m_pwndPaste->MoveWindow(crRect);
+		}
 	}
+	else
+	{
+		if ((nPosition == POS_AT_CARET) ||
+			(nPosition == POS_AT_CURSOR) ||
+			bAtPrevPos ||
+			forceMoveWindow)
+		{
+			m_pwndPaste->MoveWindow(crRect);
+		}
+
+
+		// Show the window
+		m_pwndPaste->ShowWindow(SW_SHOW);
+	}
+	
+	
 
 	m_pwndPaste->SetKeyModiferState(bFromKeyboard);
 	
-	// Show the window
-	m_pwndPaste->ShowWindow(SW_SHOW);
+	
+
 	if(bReFillList)
 	{
 		m_pwndPaste->ShowQPasteWindow(bReFillList);

BIN
Release/icudt55.dll


BIN
Release/icuin55.dll


BIN
Release/icuio55.dll


BIN
Release/icule55.dll


BIN
Release/iculx55.dll


BIN
Release/icutu55.dll


BIN
Release/icuuc55.dll


BIN
release64/icudt55.dll


BIN
release64/icuin55.dll


BIN
release64/icuio55.dll


BIN
release64/icule55.dll


BIN
release64/iculx55.dll


BIN
release64/icutu55.dll


BIN
release64/icuuc55.dll


BIN
sqlite/lib32/icudt.exp


BIN
sqlite/lib32/icudt.lib


BIN
sqlite/lib32/icuin.exp


BIN
sqlite/lib32/icuin.lib


BIN
sqlite/lib32/icuio.exp


BIN
sqlite/lib32/icuio.lib


BIN
sqlite/lib32/icule.exp


BIN
sqlite/lib32/icule.lib


BIN
sqlite/lib32/iculx.exp


BIN
sqlite/lib32/iculx.lib


BIN
sqlite/lib32/icutu.exp


BIN
sqlite/lib32/icutu.lib


BIN
sqlite/lib32/icuuc.exp


BIN
sqlite/lib32/icuuc.lib


BIN
sqlite/lib32/testplug.exp


BIN
sqlite/lib32/testplug.lib


BIN
sqlite/lib64/icudt.exp


BIN
sqlite/lib64/icudt.lib


BIN
sqlite/lib64/icuin.exp


BIN
sqlite/lib64/icuin.lib


BIN
sqlite/lib64/icuio.exp


BIN
sqlite/lib64/icuio.lib


BIN
sqlite/lib64/icule.exp


BIN
sqlite/lib64/icule.lib


BIN
sqlite/lib64/iculx.exp


BIN
sqlite/lib64/iculx.lib


BIN
sqlite/lib64/icutu.exp


BIN
sqlite/lib64/icutu.lib


BIN
sqlite/lib64/icuuc.exp


BIN
sqlite/lib64/icuuc.lib


BIN
sqlite/lib64/testplug.exp


BIN
sqlite/lib64/testplug.lib


+ 4 - 4
sqlite/sqlite3.c

@@ -150971,10 +150971,10 @@ SQLITE_API int sqlite3_rtree_init(
 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
 
 /* Include ICU headers */
-#include <unicode/utypes.h>
-#include <unicode/uregex.h>
-#include <unicode/ustring.h>
-#include <unicode/ucol.h>
+#include "unicode/utypes.h"
+#include "unicode/uregex.h"
+#include "unicode/ustring.h"
+#include "unicode/ucol.h"
 
 /* #include <assert.h> */
 

+ 752 - 0
sqlite/unicode/alphaindex.h

@@ -0,0 +1,752 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2011-2014 International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*/
+
+#ifndef INDEXCHARS_H
+#define INDEXCHARS_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/locid.h"
+
+#if !UCONFIG_NO_COLLATION
+
+/**
+ * \file
+ * \brief C++ API: Index Characters
+ */
+
+U_CDECL_BEGIN
+
+/**
+ * Constants for Alphabetic Index Label Types.
+ * The form of these enum constants anticipates having a plain C API
+ * for Alphabetic Indexes that will also use them.
+ * @stable ICU 4.8
+ */
+typedef enum UAlphabeticIndexLabelType {
+    /**
+     *  Normal Label, typically the starting letter of the names
+     *  in the bucket with this label.
+     * @stable ICU 4.8
+     */
+    U_ALPHAINDEX_NORMAL    = 0,
+
+    /**
+     * Undeflow Label.  The bucket with this label contains names
+     * in scripts that sort before any of the bucket labels in this index.
+     * @stable ICU 4.8
+     */
+    U_ALPHAINDEX_UNDERFLOW = 1,
+
+    /**
+     * Inflow Label.  The bucket with this label contains names
+     * in scripts that sort between two of the bucket labels in this index.
+     * Inflow labels are created when an index contains normal labels for
+     * multiple scripts, and skips other scripts that sort between some of the
+     * included scripts.
+     * @stable ICU 4.8
+     */
+    U_ALPHAINDEX_INFLOW    = 2,
+
+    /**
+     * Overflow Label. Te bucket with this label contains names in scripts
+     * that sort after all of the bucket labels in this index.
+     * @stable ICU 4.8
+     */
+    U_ALPHAINDEX_OVERFLOW  = 3
+} UAlphabeticIndexLabelType;
+
+
+struct UHashtable;
+U_CDECL_END
+
+U_NAMESPACE_BEGIN
+
+// Forward Declarations
+
+class BucketList;
+class Collator;
+class RuleBasedCollator;
+class StringEnumeration;
+class UnicodeSet;
+class UVector;
+
+/**
+ * AlphabeticIndex supports the creation of a UI index appropriate for a given language.
+ * It can support either direct use, or use with a client that doesn't support localized collation.
+ * The following is an example of what an index might look like in a UI:
+ * 
+ * <pre>
+ *  <b>... A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  ...</b>
+ *
+ *  <b>A</b>
+ *     Addison
+ *     Albertson
+ *     Azensky
+ *  <b>B</b>
+ *     Baker
+ *  ...
+ * </pre>
+ *
+ * The class can generate a list of labels for use as a UI "index", that is, a list of
+ * clickable characters (or character sequences) that allow the user to see a segment
+ * (bucket) of a larger "target" list. That is, each label corresponds to a bucket in
+ * the target list, where everything in the bucket is greater than or equal to the character
+ * (according to the locale's collation). Strings can be added to the index;
+ * they will be in sorted order in the right bucket.
+ * <p>
+ * The class also supports having buckets for strings before the first (underflow),
+ * after the last (overflow), and between scripts (inflow). For example, if the index
+ * is constructed with labels for Russian and English, Greek characters would fall
+ * into an inflow bucket between the other two scripts.
+ * <p>
+ * The AlphabeticIndex class is not intended for public subclassing.
+ *
+ * <p><em>Note:</em> If you expect to have a lot of ASCII or Latin characters
+ * as well as characters from the user's language,
+ * then it is a good idea to call addLabels(Locale::getEnglish(), status).</p>
+ *
+ * <h2>Direct Use</h2>
+ * <p>The following shows an example of building an index directly.
+ *  The "show..." methods below are just to illustrate usage.
+ *
+ * <pre>
+ * // Create a simple index.  "Item" is assumed to be an application
+ * // defined type that the application's UI and other processing knows about,
+ * //  and that has a name.
+ *
+ * UErrorCode status = U_ZERO_ERROR;
+ * AlphabeticIndex index = new AlphabeticIndex(desiredLocale, status);
+ * index->addLabels(additionalLocale, status);
+ * for (Item *item in some source of Items ) {
+ *     index->addRecord(item->name(), item, status);
+ * }
+ * ...
+ * // Show index at top. We could skip or gray out empty buckets
+ *
+ * while (index->nextBucket(status)) {
+ *     if (showAll || index->getBucketRecordCount() != 0) {
+ *         showLabelAtTop(UI, index->getBucketLabel());
+ *     }
+ * }
+ *  ...
+ * // Show the buckets with their contents, skipping empty buckets
+ *
+ * index->resetBucketIterator(status);
+ * while (index->nextBucket(status)) {
+ *    if (index->getBucketRecordCount() != 0) {
+ *        showLabelInList(UI, index->getBucketLabel());
+ *        while (index->nextRecord(status)) {
+ *            showIndexedItem(UI, static_cast<Item *>(index->getRecordData()))
+ * </pre>
+ *
+ * The caller can build different UIs using this class.
+ * For example, an index character could be omitted or grayed-out
+ * if its bucket is empty. Small buckets could also be combined based on size, such as:
+ *
+ * <pre>
+ * <b>... A-F G-N O-Z ...</b>
+ * </pre>
+ *
+ * <h2>Client Support</h2>
+ * <p>Callers can also use the AlphabeticIndex::ImmutableIndex, or the AlphabeticIndex itself,
+ * to support sorting on a client that doesn't support AlphabeticIndex functionality.
+ *
+ * <p>The ImmutableIndex is both immutable and thread-safe.
+ * The corresponding AlphabeticIndex methods are not thread-safe because
+ * they "lazily" build the index buckets.
+ * <ul>
+ * <li>ImmutableIndex.getBucket(index) provides random access to all
+ *     buckets and their labels and label types.
+ * <li>The AlphabeticIndex bucket iterator or ImmutableIndex.getBucket(0..getBucketCount-1)
+ *     can be used to get a list of the labels,
+ *     such as "...", "A", "B",..., and send that list to the client.
+ * <li>When the client has a new name, it sends that name to the server.
+ * The server needs to call the following methods,
+ * and communicate the bucketIndex and collationKey back to the client.
+ *
+ * <pre>
+ * int32_t bucketIndex = index.getBucketIndex(name, status);
+ * const UnicodeString &label = immutableIndex.getBucket(bucketIndex)->getLabel();  // optional
+ * int32_t skLength = collator.getSortKey(name, sk, skCapacity);
+ * </pre>
+ *
+ * <li>The client would put the name (and associated information) into its bucket for bucketIndex. The sort key sk is a
+ * sequence of bytes that can be compared with a binary compare, and produce the right localized result.</li>
+ * </ul>
+ *
+ * @stable ICU 4.8
+ */
+class U_I18N_API AlphabeticIndex: public UObject {
+public:
+     /**
+      * An index "bucket" with a label string and type.
+      * It is referenced by getBucketIndex(),
+      * and returned by ImmutableIndex.getBucket().
+      *
+      * The Bucket class is not intended for public subclassing.
+      * @stable ICU 51
+      */
+     class U_I18N_API Bucket : public UObject {
+     public:
+        /**
+         * Destructor.
+         * @stable ICU 51
+         */
+        virtual ~Bucket();
+
+        /**
+         * Returns the label string.
+         *
+         * @return the label string for the bucket
+         * @stable ICU 51
+         */
+        const UnicodeString &getLabel() const { return label_; }
+        /**
+         * Returns whether this bucket is a normal, underflow, overflow, or inflow bucket.
+         *
+         * @return the bucket label type
+         * @stable ICU 51
+         */
+        UAlphabeticIndexLabelType getLabelType() const { return labelType_; }
+
+     private:
+        friend class AlphabeticIndex;
+        friend class BucketList;
+
+        UnicodeString label_;
+        UnicodeString lowerBoundary_;
+        UAlphabeticIndexLabelType labelType_;
+        Bucket *displayBucket_;
+        int32_t displayIndex_;
+        UVector *records_;  // Records are owned by the inputList_ vector.
+
+        Bucket(const UnicodeString &label,   // Parameter strings are copied.
+               const UnicodeString &lowerBoundary,
+               UAlphabeticIndexLabelType type);
+     };
+
+    /**
+     * Immutable, thread-safe version of AlphabeticIndex.
+     * This class provides thread-safe methods for bucketing,
+     * and random access to buckets and their properties,
+     * but does not offer adding records to the index.
+     *
+     * The ImmutableIndex class is not intended for public subclassing.
+     *
+     * @stable ICU 51
+     */
+    class U_I18N_API ImmutableIndex : public UObject {
+    public:
+        /**
+         * Destructor.
+         * @stable ICU 51
+         */
+        virtual ~ImmutableIndex();
+
+        /**
+         * Returns the number of index buckets and labels, including underflow/inflow/overflow.
+         *
+         * @return the number of index buckets
+         * @stable ICU 51
+         */
+        int32_t getBucketCount() const;
+
+        /**
+         * Finds the index bucket for the given name and returns the number of that bucket.
+         * Use getBucket() to get the bucket's properties.
+         *
+         * @param name the string to be sorted into an index bucket
+         * @return the bucket number for the name
+         * @stable ICU 51
+         */
+        int32_t getBucketIndex(const UnicodeString &name, UErrorCode &errorCode) const;
+
+        /**
+         * Returns the index-th bucket. Returns NULL if the index is out of range.
+         *
+         * @param index bucket number
+         * @return the index-th bucket
+         * @stable ICU 51
+         */
+        const Bucket *getBucket(int32_t index) const;
+
+    private:
+        friend class AlphabeticIndex;
+
+        ImmutableIndex(BucketList *bucketList, Collator *collatorPrimaryOnly)
+                : buckets_(bucketList), collatorPrimaryOnly_(collatorPrimaryOnly) {}
+
+        BucketList *buckets_;
+        Collator *collatorPrimaryOnly_;
+    };
+
+    /**
+     * Construct an AlphabeticIndex object for the specified locale.  If the locale's
+     * data does not include index characters, a set of them will be
+     * synthesized based on the locale's exemplar characters.  The locale
+     * determines the sorting order for both the index characters and the
+     * user item names appearing under each Index character.
+     *
+     * @param locale the desired locale.
+     * @param status Error code, will be set with the reason if the construction
+     *               of the AlphabeticIndex object fails.
+     * @stable ICU 4.8
+     */
+     AlphabeticIndex(const Locale &locale, UErrorCode &status);
+
+   /** 
+     * Construct an AlphabeticIndex that uses a specific collator.
+     * 
+     * The index will be created with no labels; the addLabels() function must be called
+     * after creation to add the desired labels to the index.
+     * 
+     * The index adopts the collator, and is responsible for deleting it. 
+     * The caller should make no further use of the collator after creating the index.
+     * 
+     * @param collator The collator to use to order the contents of this index.
+     * @param status Error code, will be set with the reason if the 
+     *               operation fails.
+     * @stable ICU 51
+     */
+    AlphabeticIndex(RuleBasedCollator *collator, UErrorCode &status);
+
+    /**
+     * Add Labels to this Index.  The labels are additions to those
+     * that are already in the index; they do not replace the existing
+     * ones.
+     * @param additions The additional characters to add to the index, such as A-Z.
+     * @param status Error code, will be set with the reason if the 
+     *               operation fails.
+     * @return this, for chaining
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &addLabels(const UnicodeSet &additions, UErrorCode &status);
+
+    /**
+     * Add the index characters from a Locale to the index.  The labels
+     * are added to those that are already in the index; they do not replace the
+     * existing index characters.  The collation order for this index is not
+     * changed; it remains that of the locale that was originally specified
+     * when creating this Index.
+     *
+     * @param locale The locale whose index characters are to be added.
+     * @param status Error code, will be set with the reason if the 
+     *               operation fails.
+     * @return this, for chaining
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &addLabels(const Locale &locale, UErrorCode &status);
+
+     /**
+      * Destructor
+      * @stable ICU 4.8
+      */
+    virtual ~AlphabeticIndex();
+
+    /**
+     * Builds an immutable, thread-safe version of this instance, without data records.
+     *
+     * @return an immutable index instance
+     * @stable ICU 51
+     */
+    ImmutableIndex *buildImmutableIndex(UErrorCode &errorCode);
+
+    /**
+     * Get the Collator that establishes the ordering of the items in this index.
+     * Ownership of the collator remains with the AlphabeticIndex instance.
+     *
+     * The returned collator is a reference to the internal collator used by this
+     * index.  It may be safely used to compare the names of items or to get
+     * sort keys for names.  However if any settings need to be changed,
+     * or other non-const methods called, a cloned copy must be made first.
+     *
+     * @return The collator
+     * @stable ICU 4.8
+     */
+    virtual const RuleBasedCollator &getCollator() const;
+
+
+   /**
+     * Get the default label used for abbreviated buckets <i>between</i> other index characters.
+     * For example, consider the labels when Latin and Greek are used:
+     *     X Y Z ... &#x0391; &#x0392; &#x0393;.
+     *
+     * @return inflow label
+     * @stable ICU 4.8
+     */
+    virtual const UnicodeString &getInflowLabel() const;
+
+   /**
+     * Set the default label used for abbreviated buckets <i>between</i> other index characters.
+     * An inflow label will be automatically inserted if two otherwise-adjacent label characters
+     * are from different scripts, e.g. Latin and Cyrillic, and a third script, e.g. Greek,
+     * sorts between the two.  The default inflow character is an ellipsis (...)
+     *
+     * @param inflowLabel the new Inflow label.
+     * @param status Error code, will be set with the reason if the operation fails.
+     * @return this
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &setInflowLabel(const UnicodeString &inflowLabel, UErrorCode &status);
+
+
+   /**
+     * Get the special label used for items that sort after the last normal label,
+     * and that would not otherwise have an appropriate label.
+     *
+     * @return the overflow label
+     * @stable ICU 4.8
+     */
+    virtual const UnicodeString &getOverflowLabel() const;
+
+
+   /**
+     * Set the label used for items that sort after the last normal label,
+     * and that would not otherwise have an appropriate label.
+     *
+     * @param overflowLabel the new overflow label.
+     * @param status Error code, will be set with the reason if the operation fails.
+     * @return this
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &setOverflowLabel(const UnicodeString &overflowLabel, UErrorCode &status);
+
+   /**
+     * Get the special label used for items that sort before the first normal label,
+     * and that would not otherwise have an appropriate label.
+     *
+     * @return underflow label
+     * @stable ICU 4.8
+     */
+    virtual const UnicodeString &getUnderflowLabel() const;
+
+   /**
+     * Set the label used for items that sort before the first normal label,
+     * and that would not otherwise have an appropriate label.
+     *
+     * @param underflowLabel the new underflow label.
+     * @param status Error code, will be set with the reason if the operation fails.
+     * @return this
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &setUnderflowLabel(const UnicodeString &underflowLabel, UErrorCode &status);
+
+
+    /**
+     * Get the limit on the number of labels permitted in the index.
+     * The number does not include over, under and inflow labels.
+     *
+     * @return maxLabelCount maximum number of labels.
+     * @stable ICU 4.8
+     */
+    virtual int32_t getMaxLabelCount() const;
+
+    /**
+     * Set a limit on the number of labels permitted in the index.
+     * The number does not include over, under and inflow labels.
+     * Currently, if the number is exceeded, then every
+     * nth item is removed to bring the count down.
+     * A more sophisticated mechanism may be available in the future.
+     *
+     * @param maxLabelCount the maximum number of labels.
+     * @param status error code
+     * @return This, for chaining
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &setMaxLabelCount(int32_t maxLabelCount, UErrorCode &status);
+
+
+    /**
+     * Add a record to the index.  Each record will be associated with an index Bucket
+     *  based on the record's name.  The list of records for each bucket will be sorted
+     *  based on the collation ordering of the names in the index's locale.
+     *  Records with duplicate names are permitted; they will be kept in the order
+     *  that they were added.
+     *
+     * @param name The display name for the Record.  The Record will be placed in
+     *             a bucket based on this name.
+     * @param data An optional pointer to user data associated with this
+     *             item.  When iterating the contents of a bucket, both the
+     *             data pointer the name will be available for each Record.
+     * @param status  Error code, will be set with the reason if the operation fails.
+     * @return        This, for chaining.
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &addRecord(const UnicodeString &name, const void *data, UErrorCode &status);
+
+    /**
+     * Remove all Records from the Index.  The set of Buckets, which define the headings under
+     * which records are classified, is not altered.
+     *
+     * @param status  Error code, will be set with the reason if the operation fails.
+     * @return        This, for chaining.
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &clearRecords(UErrorCode &status);
+
+
+    /**  Get the number of labels in this index.
+     *      Note: may trigger lazy index construction.
+     *
+     * @param status  Error code, will be set with the reason if the operation fails.
+     * @return        The number of labels in this index, including any under, over or
+     *                in-flow labels.
+     * @stable ICU 4.8
+     */
+    virtual int32_t  getBucketCount(UErrorCode &status);
+
+
+    /**  Get the total number of Records in this index, that is, the number
+     *   of <name, data> pairs added.
+     *
+     * @param status  Error code, will be set with the reason if the operation fails.
+     * @return        The number of records in this index, that is, the total number
+     *                of (name, data) items added with addRecord().
+     * @stable ICU 4.8
+     */
+    virtual int32_t  getRecordCount(UErrorCode &status);
+
+
+
+    /**
+     *   Given the name of a record, return the zero-based index of the Bucket
+     *   in which the item should appear.  The name need not be in the index.
+     *   A Record will not be added to the index by this function.
+     *   Bucket numbers are zero-based, in Bucket iteration order.
+     *
+     * @param itemName  The name whose bucket position in the index is to be determined.
+     * @param status  Error code, will be set with the reason if the operation fails.
+     * @return The bucket number for this name.
+     * @stable ICU 4.8
+     *
+     */
+    virtual int32_t  getBucketIndex(const UnicodeString &itemName, UErrorCode &status);
+
+
+    /**
+     *   Get the zero based index of the current Bucket from an iteration
+     *   over the Buckets of this index.  Return -1 if no iteration is in process.
+     *   @return  the index of the current Bucket
+     *   @stable ICU 4.8
+     */
+    virtual int32_t  getBucketIndex() const;
+
+
+    /**
+     *   Advance the iteration over the Buckets of this index.  Return FALSE if
+     *   there are no more Buckets.
+     *
+     *   @param status  Error code, will be set with the reason if the operation fails.
+     *   U_ENUM_OUT_OF_SYNC_ERROR will be reported if the index is modified while
+     *   an enumeration of its contents are in process.
+     *
+     *   @return TRUE if success, FALSE if at end of iteration
+     *   @stable ICU 4.8
+     */
+    virtual UBool nextBucket(UErrorCode &status);
+
+    /**
+     *   Return the name of the Label of the current bucket from an iteration over the buckets.
+     *   If the iteration is before the first Bucket (nextBucket() has not been called),
+     *   or after the last, return an empty string.
+     *
+     *   @return the bucket label.
+     *   @stable ICU 4.8
+     */
+    virtual const UnicodeString &getBucketLabel() const;
+
+    /**
+     *  Return the type of the label for the current Bucket (selected by the
+     *  iteration over Buckets.)
+     *
+     * @return the label type.
+     * @stable ICU 4.8
+     */
+    virtual UAlphabeticIndexLabelType getBucketLabelType() const;
+
+    /**
+      * Get the number of <name, data> Records in the current Bucket.
+      * If the current bucket iteration position is before the first label or after the
+      * last, return 0.
+      *
+      *  @return the number of Records.
+      *  @stable ICU 4.8
+      */
+    virtual int32_t getBucketRecordCount() const;
+
+
+    /**
+     *  Reset the Bucket iteration for this index.  The next call to nextBucket()
+     *  will restart the iteration at the first label.
+     *
+     * @param status  Error code, will be set with the reason if the operation fails.
+     * @return        this, for chaining.
+     * @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &resetBucketIterator(UErrorCode &status);
+
+    /**
+     * Advance to the next record in the current Bucket.
+     * When nextBucket() is called, Record iteration is reset to just before the
+     * first Record in the new Bucket.
+     *
+     *   @param status  Error code, will be set with the reason if the operation fails.
+     *   U_ENUM_OUT_OF_SYNC_ERROR will be reported if the index is modified while
+     *   an enumeration of its contents are in process.
+     *   @return TRUE if successful, FALSE when the iteration advances past the last item.
+     *   @stable ICU 4.8
+     */
+    virtual UBool nextRecord(UErrorCode &status);
+
+    /**
+     * Get the name of the current Record.
+     * Return an empty string if the Record iteration position is before first
+     * or after the last.
+     *
+     *  @return The name of the current index item.
+     *  @stable ICU 4.8
+     */
+    virtual const UnicodeString &getRecordName() const;
+
+
+    /**
+     * Return the data pointer of the Record currently being iterated over.
+     * Return NULL if the current iteration position before the first item in this Bucket,
+     * or after the last.
+     *
+     *  @return The current Record's data pointer.
+     *  @stable ICU 4.8
+     */
+    virtual const void *getRecordData() const;
+
+
+    /**
+     * Reset the Record iterator position to before the first Record in the current Bucket.
+     *
+     *  @return This, for chaining.
+     *  @stable ICU 4.8
+     */
+    virtual AlphabeticIndex &resetRecordIterator();
+
+private:
+     /**
+      * No Copy constructor.
+      * @internal
+      */
+     AlphabeticIndex(const AlphabeticIndex &other);
+
+     /**
+      *   No assignment.
+      */
+     AlphabeticIndex &operator =(const AlphabeticIndex & /*other*/) { return *this;};
+
+    /**
+     * No Equality operators.
+     * @internal
+     */
+     virtual UBool operator==(const AlphabeticIndex& other) const;
+
+    /**
+     * Inequality operator.
+     * @internal
+     */
+     virtual UBool operator!=(const AlphabeticIndex& other) const;
+
+     // Common initialization, for use from all constructors.
+     void init(const Locale *locale, UErrorCode &status);
+
+    /**
+     * This method is called to get the index exemplars. Normally these come from the locale directly,
+     * but if they aren't available, we have to synthesize them.
+     */
+    void addIndexExemplars(const Locale &locale, UErrorCode &status);
+    /**
+     * Add Chinese index characters from the tailoring.
+     */
+    UBool addChineseIndexCharacters(UErrorCode &errorCode);
+
+    UVector *firstStringsInScript(UErrorCode &status);
+
+    static UnicodeString separated(const UnicodeString &item);
+
+    /**
+     * Determine the best labels to use.
+     * This is based on the exemplars, but we also process to make sure that they are unique,
+     * and sort differently, and that the overall list is small enough.
+     */
+    void initLabels(UVector &indexCharacters, UErrorCode &errorCode) const;
+    BucketList *createBucketList(UErrorCode &errorCode) const;
+    void initBuckets(UErrorCode &errorCode);
+    void clearBuckets();
+    void internalResetBucketIterator();
+
+public:
+
+    //  The Record is declared public only to allow access from
+    //  implementation code written in plain C.
+    //  It is not intended for public use.
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * A (name, data) pair, to be sorted by name into one of the index buckets.
+     * The user data is not used by the index implementation.
+     * @internal
+     */
+    struct Record: public UMemory {
+        const UnicodeString  name_;
+        const void           *data_;
+        Record(const UnicodeString &name, const void *data);
+        ~Record();
+    };
+#endif  /* U_HIDE_INTERNAL_API */
+
+private:
+
+    /**
+     * Holds all user records before they are distributed into buckets.
+     * Type of contents is (Record *)
+     * @internal
+     */
+    UVector  *inputList_;
+
+    int32_t  labelsIterIndex_;        // Index of next item to return.
+    int32_t  itemsIterIndex_;
+    Bucket   *currentBucket_;         // While an iteration of the index in underway,
+                                      //   point to the bucket for the current label.
+                                      // NULL when no iteration underway.
+
+    int32_t    maxLabelCount_;        // Limit on # of labels permitted in the index.
+
+    UnicodeSet *initialLabels_;       // Initial (unprocessed) set of Labels.  Union
+                                      //   of those explicitly set by the user plus
+                                      //   those from locales.  Raw values, before
+                                      //   crunching into bucket labels.
+
+    UVector *firstCharsInScripts_;    // The first character from each script,
+                                      //   in collation order.
+
+    RuleBasedCollator *collator_;
+    RuleBasedCollator *collatorPrimaryOnly_;
+
+    // Lazy evaluated: null means that we have not built yet.
+    BucketList *buckets_;
+
+    UnicodeString  inflowLabel_;
+    UnicodeString  overflowLabel_;
+    UnicodeString  underflowLabel_;
+    UnicodeString  overflowComparisonString_;
+
+    UnicodeString emptyString_;
+};
+
+U_NAMESPACE_END
+
+#endif  // !UCONFIG_NO_COLLATION
+#endif

+ 232 - 0
sqlite/unicode/appendable.h

@@ -0,0 +1,232 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2011-2012, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*   file name:  appendable.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2010dec07
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __APPENDABLE_H__
+#define __APPENDABLE_H__
+
+/**
+ * \file
+ * \brief C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (UChars).
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+
+U_NAMESPACE_BEGIN
+
+class UnicodeString;
+
+/**
+ * Base class for objects to which Unicode characters and strings can be appended.
+ * Combines elements of Java Appendable and ICU4C ByteSink.
+ *
+ * This class can be used in APIs where it does not matter whether the actual destination is
+ * a UnicodeString, a UChar[] array, a UnicodeSet, or any other object
+ * that receives and processes characters and/or strings.
+ *
+ * Implementation classes must implement at least appendCodeUnit(UChar).
+ * The base class provides default implementations for the other methods.
+ *
+ * The methods do not take UErrorCode parameters.
+ * If an error occurs (e.g., out-of-memory),
+ * in addition to returning FALSE from failing operations,
+ * the implementation must prevent unexpected behavior (e.g., crashes)
+ * from further calls and should make the error condition available separately
+ * (e.g., store a UErrorCode, make/keep a UnicodeString bogus).
+ * @stable ICU 4.8
+ */
+class U_COMMON_API Appendable : public UObject {
+public:
+    /**
+     * Destructor.
+     * @stable ICU 4.8
+     */
+    ~Appendable();
+
+    /**
+     * Appends a 16-bit code unit.
+     * @param c code unit
+     * @return TRUE if the operation succeeded
+     * @stable ICU 4.8
+     */
+    virtual UBool appendCodeUnit(UChar c) = 0;
+
+    /**
+     * Appends a code point.
+     * The default implementation calls appendCodeUnit(UChar) once or twice.
+     * @param c code point 0..0x10ffff
+     * @return TRUE if the operation succeeded
+     * @stable ICU 4.8
+     */
+    virtual UBool appendCodePoint(UChar32 c);
+
+    /**
+     * Appends a string.
+     * The default implementation calls appendCodeUnit(UChar) for each code unit.
+     * @param s string, must not be NULL if length!=0
+     * @param length string length, or -1 if NUL-terminated
+     * @return TRUE if the operation succeeded
+     * @stable ICU 4.8
+     */
+    virtual UBool appendString(const UChar *s, int32_t length);
+
+    /**
+     * Tells the object that the caller is going to append roughly
+     * appendCapacity UChars. A subclass might use this to pre-allocate
+     * a larger buffer if necessary.
+     * The default implementation does nothing. (It always returns TRUE.)
+     * @param appendCapacity estimated number of UChars that will be appended
+     * @return TRUE if the operation succeeded
+     * @stable ICU 4.8
+     */
+    virtual UBool reserveAppendCapacity(int32_t appendCapacity);
+
+    /**
+     * Returns a writable buffer for appending and writes the buffer's capacity to
+     * *resultCapacity. Guarantees *resultCapacity>=minCapacity.
+     * May return a pointer to the caller-owned scratch buffer which must have
+     * scratchCapacity>=minCapacity.
+     * The returned buffer is only valid until the next operation
+     * on this Appendable.
+     *
+     * After writing at most *resultCapacity UChars, call appendString() with the
+     * pointer returned from this function and the number of UChars written.
+     * Many appendString() implementations will avoid copying UChars if this function
+     * returned an internal buffer.
+     *
+     * Partial usage example:
+     * \code
+     *  int32_t capacity;
+     *  UChar* buffer = app.getAppendBuffer(..., &capacity);
+     *  ... Write n UChars into buffer, with n <= capacity.
+     *  app.appendString(buffer, n);
+     * \endcode
+     * In many implementations, that call to append will avoid copying UChars.
+     *
+     * If the Appendable allocates or reallocates an internal buffer, it should use
+     * the desiredCapacityHint if appropriate.
+     * If a caller cannot provide a reasonable guess at the desired capacity,
+     * it should pass desiredCapacityHint=0.
+     *
+     * If a non-scratch buffer is returned, the caller may only pass
+     * a prefix to it to appendString().
+     * That is, it is not correct to pass an interior pointer to appendString().
+     *
+     * The default implementation always returns the scratch buffer.
+     *
+     * @param minCapacity required minimum capacity of the returned buffer;
+     *                    must be non-negative
+     * @param desiredCapacityHint desired capacity of the returned buffer;
+     *                            must be non-negative
+     * @param scratch default caller-owned buffer
+     * @param scratchCapacity capacity of the scratch buffer
+     * @param resultCapacity pointer to an integer which will be set to the
+     *                       capacity of the returned buffer
+     * @return a buffer with *resultCapacity>=minCapacity
+     * @stable ICU 4.8
+     */
+    virtual UChar *getAppendBuffer(int32_t minCapacity,
+                                   int32_t desiredCapacityHint,
+                                   UChar *scratch, int32_t scratchCapacity,
+                                   int32_t *resultCapacity);
+};
+
+/**
+ * An Appendable implementation which writes to a UnicodeString.
+ *
+ * This class is not intended for public subclassing.
+ * @stable ICU 4.8
+ */
+class U_COMMON_API UnicodeStringAppendable : public Appendable {
+public:
+    /**
+     * Aliases the UnicodeString (keeps its reference) for writing.
+     * @param s The UnicodeString to which this Appendable will write.
+     * @stable ICU 4.8
+     */
+    explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}
+
+    /**
+     * Destructor.
+     * @stable ICU 4.8
+     */
+    ~UnicodeStringAppendable();
+
+    /**
+     * Appends a 16-bit code unit to the string.
+     * @param c code unit
+     * @return TRUE if the operation succeeded
+     * @stable ICU 4.8
+     */
+    virtual UBool appendCodeUnit(UChar c);
+
+    /**
+     * Appends a code point to the string.
+     * @param c code point 0..0x10ffff
+     * @return TRUE if the operation succeeded
+     * @stable ICU 4.8
+     */
+    virtual UBool appendCodePoint(UChar32 c);
+
+    /**
+     * Appends a string to the UnicodeString.
+     * @param s string, must not be NULL if length!=0
+     * @param length string length, or -1 if NUL-terminated
+     * @return TRUE if the operation succeeded
+     * @stable ICU 4.8
+     */
+    virtual UBool appendString(const UChar *s, int32_t length);
+
+    /**
+     * Tells the UnicodeString that the caller is going to append roughly
+     * appendCapacity UChars.
+     * @param appendCapacity estimated number of UChars that will be appended
+     * @return TRUE if the operation succeeded
+     * @stable ICU 4.8
+     */
+    virtual UBool reserveAppendCapacity(int32_t appendCapacity);
+
+    /**
+     * Returns a writable buffer for appending and writes the buffer's capacity to
+     * *resultCapacity. Guarantees *resultCapacity>=minCapacity.
+     * May return a pointer to the caller-owned scratch buffer which must have
+     * scratchCapacity>=minCapacity.
+     * The returned buffer is only valid until the next write operation
+     * on the UnicodeString.
+     *
+     * For details see Appendable::getAppendBuffer().
+     *
+     * @param minCapacity required minimum capacity of the returned buffer;
+     *                    must be non-negative
+     * @param desiredCapacityHint desired capacity of the returned buffer;
+     *                            must be non-negative
+     * @param scratch default caller-owned buffer
+     * @param scratchCapacity capacity of the scratch buffer
+     * @param resultCapacity pointer to an integer which will be set to the
+     *                       capacity of the returned buffer
+     * @return a buffer with *resultCapacity>=minCapacity
+     * @stable ICU 4.8
+     */
+    virtual UChar *getAppendBuffer(int32_t minCapacity,
+                                   int32_t desiredCapacityHint,
+                                   UChar *scratch, int32_t scratchCapacity,
+                                   int32_t *resultCapacity);
+
+private:
+    UnicodeString &str;
+};
+
+U_NAMESPACE_END
+
+#endif  // __APPENDABLE_H__

+ 214 - 0
sqlite/unicode/basictz.h

@@ -0,0 +1,214 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2013, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*/
+#ifndef BASICTZ_H
+#define BASICTZ_H
+
+/**
+ * \file 
+ * \brief C++ API: ICU TimeZone base class
+ */
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/timezone.h"
+#include "unicode/tzrule.h"
+#include "unicode/tztrans.h"
+
+U_NAMESPACE_BEGIN
+
+// forward declarations
+class UVector;
+
+/**
+ * <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.
+ * This class provides some additional methods to access time zone transitions and rules.
+ * All ICU <code>TimeZone</code> concrete subclasses extend this class.
+ * @stable ICU 3.8
+ */
+class U_I18N_API BasicTimeZone: public TimeZone {
+public:
+    /**
+     * Destructor.
+     * @stable ICU 3.8
+     */
+    virtual ~BasicTimeZone();
+
+    /**
+     * Gets the first time zone transition after the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the first transition after the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 3.8
+     */
+    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0;
+
+    /**
+     * Gets the most recent time zone transition before the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the most recent transition before the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 3.8
+     */
+    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0;
+
+    /**
+     * Checks if the time zone has equivalent transitions in the time range.
+     * This method returns true when all of transition times, from/to standard
+     * offsets and DST savings used by this time zone match the other in the
+     * time range.
+     * @param tz    The <code>BasicTimeZone</code> object to be compared with.
+     * @param start The start time of the evaluated time range (inclusive)
+     * @param end   The end time of the evaluated time range (inclusive)
+     * @param ignoreDstAmount
+     *              When true, any transitions with only daylight saving amount
+     *              changes will be ignored, except either of them is zero.
+     *              For example, a transition from rawoffset 3:00/dstsavings 1:00
+     *              to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison,
+     *              but a transtion from rawoffset 2:00/dstsavings 1:00 to
+     *              rawoffset 3:00/dstsavings 0:00 is included.
+     * @param ec    Output param to filled in with a success or an error.
+     * @return      true if the other time zone has the equivalent transitions in the
+     *              time range.
+     * @stable ICU 3.8
+     */
+    virtual UBool hasEquivalentTransitions(const BasicTimeZone& tz, UDate start, UDate end,
+        UBool ignoreDstAmount, UErrorCode& ec) const;
+
+    /**
+     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
+     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
+     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.
+     * @param status    Receives error status code.
+     * @return The number of <code>TimeZoneRule</code>s representing time transitions.
+     * @stable ICU 3.8
+     */
+    virtual int32_t countTransitionRules(UErrorCode& status) const = 0;
+
+    /**
+     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
+     * which represent time transitions for this time zone.  On successful return,
+     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
+     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
+     * instances up to the size specified by trscount.  The results are referencing the
+     * rule instance held by this time zone instance.  Therefore, after this time zone
+     * is destructed, they are no longer available.
+     * @param initial       Receives the initial timezone rule
+     * @param trsrules      Receives the timezone transition rules
+     * @param trscount      On input, specify the size of the array 'transitions' receiving
+     *                      the timezone transition rules.  On output, actual number of
+     *                      rules filled in the array will be set.
+     * @param status        Receives error status code.
+     * @stable ICU 3.8
+     */
+    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
+        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const = 0;
+
+    /**
+     * Gets the set of time zone rules valid at the specified time.  Some known external time zone
+     * implementations are not capable to handle historic time zone rule changes.  Also some
+     * implementations can only handle certain type of rule definitions.
+     * If this time zone does not use any daylight saving time within about 1 year from the specified
+     * time, only the <code>InitialTimeZone</code> is returned.  Otherwise, the rule for standard
+     * time and daylight saving time transitions are returned in addition to the
+     * <code>InitialTimeZoneRule</code>.  The standard and daylight saving time transition rules are
+     * represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date
+     * rule and <code>DateTimeRule::WALL_TIME</code> for its time rule.  Because daylight saving time
+     * rule is changing time to time in many time zones and also mapping a transition time rule to
+     * different type is lossy transformation, the set of rules returned by this method may be valid
+     * for short period of time.
+     * The time zone rule objects returned by this method is owned by the caller, so the caller is
+     * responsible for deleting them after use.
+     * @param date      The date used for extracting time zone rules.
+     * @param initial   Receives the <code>InitialTimeZone</code>, always not NULL.
+     * @param std       Receives the <code>AnnualTimeZoneRule</code> for standard time transitions.
+     *                  When this time time zone does not observe daylight saving times around the
+     *                  specified date, NULL is set.
+     * @param dst       Receives the <code>AnnualTimeZoneRule</code> for daylight saving time
+     *                  transitions.  When this time zone does not observer daylight saving times
+     *                  around the specified date, NULL is set.
+     * @param status    Receives error status code.
+     * @stable ICU 3.8
+     */
+    virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
+        AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) const;
+
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * The time type option bit flags used by getOffsetFromLocal
+     * @internal
+     */
+    enum {
+        kStandard = 0x01,
+        kDaylight = 0x03,
+        kFormer = 0x04,
+        kLatter = 0x0C
+    };
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Get time zone offsets from local wall time.
+     * @internal
+     */
+    virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,
+        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const;
+
+protected:
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * The time type option bit masks used by getOffsetFromLocal
+     * @internal
+     */
+    enum {
+        kStdDstMask = kDaylight,
+        kFormerLatterMask = kLatter
+    };
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Default constructor.
+     * @stable ICU 3.8
+     */
+    BasicTimeZone();
+
+    /**
+     * Construct a timezone with a given ID.
+     * @param id a system time zone ID
+     * @stable ICU 3.8
+     */
+    BasicTimeZone(const UnicodeString &id);
+
+    /**
+     * Copy constructor.
+     * @param source the object to be copied.
+     * @stable ICU 3.8
+     */
+    BasicTimeZone(const BasicTimeZone& source);
+
+    /**
+     * Gets the set of TimeZoneRule instances applicable to the specified time and after.
+     * @param start     The start date used for extracting time zone rules
+     * @param initial   Receives the InitialTimeZone, always not NULL
+     * @param transitionRules   Receives the transition rules, could be NULL
+     * @param status    Receives error status code
+     */
+    void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules,
+        UErrorCode& status) const;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // BASICTZ_H
+
+//eof

+ 655 - 0
sqlite/unicode/brkiter.h

@@ -0,0 +1,655 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2014, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File brkiter.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/18/97    aliu        Added typedef for TextCount.  Made DONE const.
+*   05/07/97    aliu        Fixed DLL declaration.
+*   07/09/97    jfitz       Renamed BreakIterator and interface synced with JDK
+*   08/11/98    helena      Sync-up JDK1.2.
+*   01/13/2000  helena      Added UErrorCode parameter to createXXXInstance methods.
+********************************************************************************
+*/
+
+#ifndef BRKITER_H
+#define BRKITER_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Break Iterator.
+ */
+
+#if UCONFIG_NO_BREAK_ITERATION
+
+U_NAMESPACE_BEGIN
+
+/*
+ * Allow the declaration of APIs with pointers to BreakIterator
+ * even when break iteration is removed from the build.
+ */
+class BreakIterator;
+
+U_NAMESPACE_END
+
+#else
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/chariter.h"
+#include "unicode/locid.h"
+#include "unicode/ubrk.h"
+#include "unicode/strenum.h"
+#include "unicode/utext.h"
+#include "unicode/umisc.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * The BreakIterator class implements methods for finding the location
+ * of boundaries in text. BreakIterator is an abstract base class.
+ * Instances of BreakIterator maintain a current position and scan over
+ * text returning the index of characters where boundaries occur.
+ * <p>
+ * Line boundary analysis determines where a text string can be broken
+ * when line-wrapping. The mechanism correctly handles punctuation and
+ * hyphenated words.
+ * <p>
+ * Sentence boundary analysis allows selection with correct
+ * interpretation of periods within numbers and abbreviations, and
+ * trailing punctuation marks such as quotation marks and parentheses.
+ * <p>
+ * Word boundary analysis is used by search and replace functions, as
+ * well as within text editing applications that allow the user to
+ * select words with a double click. Word selection provides correct
+ * interpretation of punctuation marks within and following
+ * words. Characters that are not part of a word, such as symbols or
+ * punctuation marks, have word-breaks on both sides.
+ * <p>
+ * Character boundary analysis allows users to interact with
+ * characters as they expect to, for example, when moving the cursor
+ * through a text string. Character boundary analysis provides correct
+ * navigation of through character strings, regardless of how the
+ * character is stored.  For example, an accented character might be
+ * stored as a base character and a diacritical mark. What users
+ * consider to be a character can differ between languages.
+ * <p>
+ * The text boundary positions are found according to the rules
+ * described in Unicode Standard Annex #29, Text Boundaries, and
+ * Unicode Standard Annex #14, Line Breaking Properties.  These
+ * are available at http://www.unicode.org/reports/tr14/ and
+ * http://www.unicode.org/reports/tr29/.
+ * <p>
+ * In addition to the C++ API defined in this header file, a
+ * plain C API with equivalent functionality is defined in the
+ * file ubrk.h
+ * <p>
+ * Code snippets illustrating the use of the Break Iterator APIs
+ * are available in the ICU User Guide,
+ * http://icu-project.org/userguide/boundaryAnalysis.html
+ * and in the sample program icu/source/samples/break/break.cpp
+ *
+ */
+class U_COMMON_API BreakIterator : public UObject {
+public:
+    /**
+     *  destructor
+     *  @stable ICU 2.0
+     */
+    virtual ~BreakIterator();
+
+    /**
+     * Return true if another object is semantically equal to this
+     * one. The other object should be an instance of the same subclass of
+     * BreakIterator. Objects of different subclasses are considered
+     * unequal.
+     * <P>
+     * Return true if this BreakIterator is at the same position in the
+     * same text, and is the same class and type (word, line, etc.) of
+     * BreakIterator, as the argument.  Text is considered the same if
+     * it contains the same characters, it need not be the same
+     * object, and styles are not considered.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const BreakIterator&) const = 0;
+
+    /**
+     * Returns the complement of the result of operator==
+     * @param rhs The BreakIterator to be compared for inequality
+     * @return the complement of the result of operator==
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
+
+    /**
+     * Return a polymorphic copy of this object.  This is an abstract
+     * method which subclasses implement.
+     * @stable ICU 2.0
+     */
+    virtual BreakIterator* clone(void) const = 0;
+
+    /**
+     * Return a polymorphic class ID for this object. Different subclasses
+     * will return distinct unequal values.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+    /**
+     * Return a CharacterIterator over the text being analyzed.
+     * @stable ICU 2.0
+     */
+    virtual CharacterIterator& getText(void) const = 0;
+
+
+    /**
+      *  Get a UText for the text being analyzed.
+      *  The returned UText is a shallow clone of the UText used internally
+      *  by the break iterator implementation.  It can safely be used to
+      *  access the text without impacting any break iterator operations,
+      *  but the underlying text itself must not be altered.
+      *
+      * @param fillIn A UText to be filled in.  If NULL, a new UText will be
+      *           allocated to hold the result.
+      * @param status receives any error codes.
+      * @return   The current UText for this break iterator.  If an input
+      *           UText was provided, it will always be returned.
+      * @stable ICU 3.4
+      */
+     virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
+
+    /**
+     * Change the text over which this operates. The text boundary is
+     * reset to the start.
+     * @param text The UnicodeString used to change the text.
+     * @stable ICU 2.0
+     */
+    virtual void  setText(const UnicodeString &text) = 0;
+
+    /**
+     * Reset the break iterator to operate over the text represented by
+     * the UText.  The iterator position is reset to the start.
+     *
+     * This function makes a shallow clone of the supplied UText.  This means
+     * that the caller is free to immediately close or otherwise reuse the
+     * Utext that was passed as a parameter, but that the underlying text itself
+     * must not be altered while being referenced by the break iterator.
+     *
+     * All index positions returned by break iterator functions are
+     * native indices from the UText. For example, when breaking UTF-8
+     * encoded text, the break positions returned by next(), previous(), etc.
+     * will be UTF-8 string indices, not UTF-16 positions.
+     *
+     * @param text The UText used to change the text.
+     * @param status receives any error codes.
+     * @stable ICU 3.4
+     */
+    virtual void  setText(UText *text, UErrorCode &status) = 0;
+
+    /**
+     * Change the text over which this operates. The text boundary is
+     * reset to the start.
+     * Note that setText(UText *) provides similar functionality to this function,
+     * and is more efficient.
+     * @param it The CharacterIterator used to change the text.
+     * @stable ICU 2.0
+     */
+    virtual void  adoptText(CharacterIterator* it) = 0;
+
+    enum {
+        /**
+         * DONE is returned by previous() and next() after all valid
+         * boundaries have been returned.
+         * @stable ICU 2.0
+         */
+        DONE = (int32_t)-1
+    };
+
+    /**
+     * Sets the current iteration position to the beginning of the text, position zero.
+     * @return The offset of the beginning of the text, zero.
+     * @stable ICU 2.0
+     */
+    virtual int32_t first(void) = 0;
+
+    /**
+     * Set the iterator position to the index immediately BEYOND the last character in the text being scanned.
+     * @return The index immediately BEYOND the last character in the text being scanned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t last(void) = 0;
+
+    /**
+     * Set the iterator position to the boundary preceding the current boundary.
+     * @return The character index of the previous text boundary or DONE if all
+     * boundaries have been returned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t previous(void) = 0;
+
+    /**
+     * Advance the iterator to the boundary following the current boundary.
+     * @return The character index of the next text boundary or DONE if all
+     * boundaries have been returned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t next(void) = 0;
+
+    /**
+     * Return character index of the current interator position within the text.
+     * @return The boundary most recently returned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t current(void) const = 0;
+
+    /**
+     * Advance the iterator to the first boundary following the specified offset.
+     * The value returned is always greater than the offset or
+     * the value BreakIterator.DONE
+     * @param offset the offset to begin scanning.
+     * @return The first boundary after the specified offset.
+     * @stable ICU 2.0
+     */
+    virtual int32_t following(int32_t offset) = 0;
+
+    /**
+     * Set the iterator position to the first boundary preceding the specified offset.
+     * The value returned is always smaller than the offset or
+     * the value BreakIterator.DONE
+     * @param offset the offset to begin scanning.
+     * @return The first boundary before the specified offset.
+     * @stable ICU 2.0
+     */
+    virtual int32_t preceding(int32_t offset) = 0;
+
+    /**
+     * Return true if the specfied position is a boundary position.
+     * As a side effect, the current position of the iterator is set
+     * to the first boundary position at or following the specified offset.
+     * @param offset the offset to check.
+     * @return True if "offset" is a boundary position.
+     * @stable ICU 2.0
+     */
+    virtual UBool isBoundary(int32_t offset) = 0;
+
+    /**
+     * Set the iterator position to the nth boundary from the current boundary
+     * @param n the number of boundaries to move by.  A value of 0
+     * does nothing.  Negative values move to previous boundaries
+     * and positive values move to later boundaries.
+     * @return The new iterator position, or
+     * DONE if there are fewer than |n| boundaries in the specfied direction.
+     * @stable ICU 2.0
+     */
+    virtual int32_t next(int32_t n) = 0;
+
+   /**
+     * For RuleBasedBreakIterators, return the status tag from the 
+     * break rule that determined the most recently
+     * returned break position.
+     * <p>
+     * For break iterator types that do not support a rule status,
+     * a default value of 0 is returned.
+     * <p>
+     * @return the status from the break rule that determined the most recently
+     *         returned break position.
+     * @see RuleBaseBreakIterator::getRuleStatus()
+     * @see UWordBreak
+     * @stable ICU 52
+     */
+    virtual int32_t getRuleStatus() const;
+
+   /**
+    * For RuleBasedBreakIterators, get the status (tag) values from the break rule(s) 
+    * that determined the most recently returned break position.
+    * <p>
+    * For break iterator types that do not support rule status,
+    * no values are returned.
+    * <p>
+    * The returned status value(s) are stored into an array provided by the caller.
+    * The values are stored in sorted (ascending) order.
+    * If the capacity of the output array is insufficient to hold the data,
+    *  the output will be truncated to the available length, and a
+    *  U_BUFFER_OVERFLOW_ERROR will be signaled.
+    * <p>
+    * @see RuleBaseBreakIterator::getRuleStatusVec
+    *
+    * @param fillInVec an array to be filled in with the status values.
+    * @param capacity  the length of the supplied vector.  A length of zero causes
+    *                  the function to return the number of status values, in the
+    *                  normal way, without attemtping to store any values.
+    * @param status    receives error codes.
+    * @return          The number of rule status values from rules that determined
+    *                  the most recent boundary returned by the break iterator.
+    *                  In the event of a U_BUFFER_OVERFLOW_ERROR, the return value
+    *                  is the total number of status values that were available,
+    *                  not the reduced number that were actually returned.
+    * @see getRuleStatus
+    * @stable ICU 52
+    */
+    virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);
+
+    /**
+     * Create BreakIterator for word-breaks using the given locale.
+     * Returns an instance of a BreakIterator implementing word breaks.
+     * WordBreak is useful for word selection (ex. double click)
+     * @param where the locale.
+     * @param status the error code
+     * @return A BreakIterator for word-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.0
+     */
+    static BreakIterator* U_EXPORT2
+    createWordInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Create BreakIterator for line-breaks using specified locale.
+     * Returns an instance of a BreakIterator implementing line breaks. Line
+     * breaks are logically possible line breaks, actual line breaks are
+     * usually determined based on display width.
+     * LineBreak is useful for word wrapping text.
+     * @param where the locale.
+     * @param status The error code.
+     * @return A BreakIterator for line-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.0
+     */
+    static BreakIterator* U_EXPORT2
+    createLineInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Create BreakIterator for character-breaks using specified locale
+     * Returns an instance of a BreakIterator implementing character breaks.
+     * Character breaks are boundaries of combining character sequences.
+     * @param where the locale.
+     * @param status The error code.
+     * @return A BreakIterator for character-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.0
+     */
+    static BreakIterator* U_EXPORT2
+    createCharacterInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Create BreakIterator for sentence-breaks using specified locale
+     * Returns an instance of a BreakIterator implementing sentence breaks.
+     * @param where the locale.
+     * @param status The error code.
+     * @return A BreakIterator for sentence-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.0
+     */
+    static BreakIterator* U_EXPORT2
+    createSentenceInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Create BreakIterator for title-casing breaks using the specified locale
+     * Returns an instance of a BreakIterator implementing title breaks.
+     * The iterator returned locates title boundaries as described for
+     * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
+     * please use Word Boundary iterator.{@link #createWordInstance }
+     *
+     * @param where the locale.
+     * @param status The error code.
+     * @return A BreakIterator for title-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.1
+     */
+    static BreakIterator* U_EXPORT2
+    createTitleInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Get the set of Locales for which TextBoundaries are installed.
+     * <p><b>Note:</b> this will not return locales added through the register
+     * call. To see the registered locales too, use the getAvailableLocales
+     * function that returns a StringEnumeration object </p>
+     * @param count the output parameter of number of elements in the locale list
+     * @return available locales
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+    /**
+     * Get name of the object for the desired Locale, in the desired langauge.
+     * @param objectLocale must be from getAvailableLocales.
+     * @param displayLocale specifies the desired locale for output.
+     * @param name the fill-in parameter of the return value
+     * Uses best match.
+     * @return user-displayable name
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
+                                         const Locale& displayLocale,
+                                         UnicodeString& name);
+
+    /**
+     * Get name of the object for the desired Locale, in the langauge of the
+     * default locale.
+     * @param objectLocale must be from getMatchingLocales
+     * @param name the fill-in parameter of the return value
+     * @return user-displayable name
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
+                                         UnicodeString& name);
+
+    /**
+     * Deprecated functionality. Use clone() instead.
+     *
+     * Thread safe client-buffer-based cloning operation
+     *    Do NOT call delete on a safeclone, since 'new' is not used to create it.
+     * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.
+     * If buffer is not large enough, new memory will be allocated.
+     * @param BufferSize reference to size of allocated space.
+     * If BufferSize == 0, a sufficient size for use in cloning will
+     * be returned ('pre-flighting')
+     * If BufferSize is not enough for a stack-based safe clone,
+     * new memory will be allocated.
+     * @param status to indicate whether the operation went on smoothly or there were errors
+     *  An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were
+     *  necessary.
+     * @return pointer to the new clone
+     *
+     * @deprecated ICU 52. Use clone() instead.
+     */
+    virtual BreakIterator *  createBufferClone(void *stackBuffer,
+                                               int32_t &BufferSize,
+                                               UErrorCode &status) = 0;
+
+#ifndef U_HIDE_DEPRECATED_API
+
+    /**
+     *   Determine whether the BreakIterator was created in user memory by
+     *   createBufferClone(), and thus should not be deleted.  Such objects
+     *   must be closed by an explicit call to the destructor (not delete).
+     * @deprecated ICU 52. Always delete the BreakIterator.
+     */
+    inline UBool isBufferClone(void);
+
+#endif /* U_HIDE_DEPRECATED_API */
+
+#if !UCONFIG_NO_SERVICE
+    /**
+     * Register a new break iterator of the indicated kind, to use in the given locale.
+     * The break iterator will be adopted.  Clones of the iterator will be returned
+     * if a request for a break iterator of the given kind matches or falls back to
+     * this locale.
+     * Because ICU may choose to cache BreakIterators internally, this must
+     * be called at application startup, prior to any calls to
+     * BreakIterator::createXXXInstance to avoid undefined behavior.
+     * @param toAdopt the BreakIterator instance to be adopted
+     * @param locale the Locale for which this instance is to be registered
+     * @param kind the type of iterator for which this instance is to be registered
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this instance
+     * @stable ICU 2.4
+     */
+    static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
+                                        const Locale& locale,
+                                        UBreakIteratorType kind,
+                                        UErrorCode& status);
+
+    /**
+     * Unregister a previously-registered BreakIterator using the key returned from the
+     * register call.  Key becomes invalid after a successful call and should not be used again.
+     * The BreakIterator corresponding to the key will be deleted.
+     * Because ICU may choose to cache BreakIterators internally, this should
+     * be called during application shutdown, after all calls to
+     * BreakIterator::createXXXInstance to avoid undefined behavior.
+     * @param key the registry key returned by a previous call to registerInstance
+     * @param status the in/out status code, no special meanings are assigned
+     * @return TRUE if the iterator for the key was successfully unregistered
+     * @stable ICU 2.4
+     */
+    static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
+
+    /**
+     * Return a StringEnumeration over the locales available at the time of the call,
+     * including registered locales.
+     * @return a StringEnumeration over the locales available at the time of the call
+     * @stable ICU 2.4
+     */
+    static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
+#endif
+
+    /**
+     * Returns the locale for this break iterator. Two flavors are available: valid and
+     * actual locale.
+     * @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+#ifndef U_HIDE_INTERNAL_API
+    /** Get the locale for this break iterator object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual)
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @internal
+     */
+    const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     *  Set the subject text string upon which the break iterator is operating
+     *  without changing any other aspect of the matching state.
+     *  The new and previous text strings must have the same content.
+     *
+     *  This function is intended for use in environments where ICU is operating on
+     *  strings that may move around in memory.  It provides a mechanism for notifying
+     *  ICU that the string has been relocated, and providing a new UText to access the
+     *  string in its new position.
+     *
+     *  Note that the break iterator implementation never copies the underlying text
+     *  of a string being processed, but always operates directly on the original text
+     *  provided by the user. Refreshing simply drops the references to the old text
+     *  and replaces them with references to the new.
+     *
+     *  Caution:  this function is normally used only by very specialized,
+     *  system-level code.  One example use case is with garbage collection that moves
+     *  the text in memory.
+     *
+     * @param input      The new (moved) text string.
+     * @param status     Receives errors detected by this function.
+     * @return           *this
+     *
+     * @stable ICU 49
+     */
+    virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
+
+ private:
+    static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
+    static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
+    static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
+
+    friend class ICUBreakIteratorFactory;
+    friend class ICUBreakIteratorService;
+
+protected:
+    // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
+    // or else the compiler will create a public ones.
+    /** @internal */
+    BreakIterator();
+    /** @internal */
+    BreakIterator (const BreakIterator &other) : UObject(other) {}
+    /** @internal */
+    BreakIterator (const Locale& valid, const Locale& actual);
+private:
+
+    /** @internal */
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+
+    /**
+     * The assignment operator has no real implementation.
+     * It's provided to make the compiler happy. Do not call.
+     */
+    BreakIterator& operator=(const BreakIterator&);
+};
+
+#ifndef U_HIDE_DEPRECATED_API
+
+inline UBool BreakIterator::isBufferClone()
+{
+    return FALSE;
+}
+
+#endif /* U_HIDE_DEPRECATED_API */
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
+
+#endif // _BRKITER
+//eof

+ 257 - 0
sqlite/unicode/bytestream.h

@@ -0,0 +1,257 @@
+// Copyright (C) 2009-2012, International Business Machines
+// Corporation and others. All Rights Reserved.
+//
+// Copyright 2007 Google Inc. All Rights Reserved.
+// Author: [email protected] (Sanjay Ghemawat)
+//
+// Abstract interface that consumes a sequence of bytes (ByteSink).
+//
+// Used so that we can write a single piece of code that can operate
+// on a variety of output string types.
+//
+// Various implementations of this interface are provided:
+//   ByteSink:
+//      CheckedArrayByteSink    Write to a flat array, with bounds checking
+//      StringByteSink          Write to an STL string
+
+// This code is a contribution of Google code, and the style used here is
+// a compromise between the original Google code and the ICU coding guidelines.
+// For example, data types are ICU-ified (size_t,int->int32_t),
+// and API comments doxygen-ified, but function names and behavior are
+// as in the original, if possible.
+// Assertion-style error handling, not available in ICU, was changed to
+// parameter "pinning" similar to UnicodeString.
+//
+// In addition, this is only a partial port of the original Google code,
+// limited to what was needed so far. The (nearly) complete original code
+// is in the ICU svn repository at icuhtml/trunk/design/strings/contrib
+// (see ICU ticket 6765, r25517).
+
+#ifndef __BYTESTREAM_H__
+#define __BYTESTREAM_H__
+
+/**
+ * \file
+ * \brief C++ API: Interface for writing bytes, and implementation classes.
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/std_string.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * A ByteSink can be filled with bytes.
+ * @stable ICU 4.2
+ */
+class U_COMMON_API ByteSink : public UMemory {
+public:
+  /**
+   * Default constructor.
+   * @stable ICU 4.2
+   */
+  ByteSink() { }
+  /**
+   * Virtual destructor.
+   * @stable ICU 4.2
+   */
+  virtual ~ByteSink();
+
+  /**
+   * Append "bytes[0,n-1]" to this.
+   * @param bytes the pointer to the bytes
+   * @param n the number of bytes; must be non-negative
+   * @stable ICU 4.2
+   */
+  virtual void Append(const char* bytes, int32_t n) = 0;
+
+  /**
+   * Returns a writable buffer for appending and writes the buffer's capacity to
+   * *result_capacity. Guarantees *result_capacity>=min_capacity.
+   * May return a pointer to the caller-owned scratch buffer which must have
+   * scratch_capacity>=min_capacity.
+   * The returned buffer is only valid until the next operation
+   * on this ByteSink.
+   *
+   * After writing at most *result_capacity bytes, call Append() with the
+   * pointer returned from this function and the number of bytes written.
+   * Many Append() implementations will avoid copying bytes if this function
+   * returned an internal buffer.
+   *
+   * Partial usage example:
+   *  int32_t capacity;
+   *  char* buffer = sink->GetAppendBuffer(..., &capacity);
+   *  ... Write n bytes into buffer, with n <= capacity.
+   *  sink->Append(buffer, n);
+   * In many implementations, that call to Append will avoid copying bytes.
+   *
+   * If the ByteSink allocates or reallocates an internal buffer, it should use
+   * the desired_capacity_hint if appropriate.
+   * If a caller cannot provide a reasonable guess at the desired capacity,
+   * it should pass desired_capacity_hint=0.
+   *
+   * If a non-scratch buffer is returned, the caller may only pass
+   * a prefix to it to Append().
+   * That is, it is not correct to pass an interior pointer to Append().
+   *
+   * The default implementation always returns the scratch buffer.
+   *
+   * @param min_capacity required minimum capacity of the returned buffer;
+   *                     must be non-negative
+   * @param desired_capacity_hint desired capacity of the returned buffer;
+   *                              must be non-negative
+   * @param scratch default caller-owned buffer
+   * @param scratch_capacity capacity of the scratch buffer
+   * @param result_capacity pointer to an integer which will be set to the
+   *                        capacity of the returned buffer
+   * @return a buffer with *result_capacity>=min_capacity
+   * @stable ICU 4.2
+   */
+  virtual char* GetAppendBuffer(int32_t min_capacity,
+                                int32_t desired_capacity_hint,
+                                char* scratch, int32_t scratch_capacity,
+                                int32_t* result_capacity);
+
+  /**
+   * Flush internal buffers.
+   * Some byte sinks use internal buffers or provide buffering
+   * and require calling Flush() at the end of the stream.
+   * The ByteSink should be ready for further Append() calls after Flush().
+   * The default implementation of Flush() does nothing.
+   * @stable ICU 4.2
+   */
+  virtual void Flush();
+
+private:
+  ByteSink(const ByteSink &); // copy constructor not implemented
+  ByteSink &operator=(const ByteSink &); // assignment operator not implemented
+};
+
+// -------------------------------------------------------------
+// Some standard implementations
+
+/** 
+ * Implementation of ByteSink that writes to a flat byte array,
+ * with bounds-checking:
+ * This sink will not write more than capacity bytes to outbuf.
+ * If more than capacity bytes are Append()ed, then excess bytes are ignored,
+ * and Overflowed() will return true.
+ * Overflow does not cause a runtime error.
+ * @stable ICU 4.2
+ */
+class U_COMMON_API CheckedArrayByteSink : public ByteSink {
+public:
+  /**
+   * Constructs a ByteSink that will write to outbuf[0..capacity-1].
+   * @param outbuf buffer to write to
+   * @param capacity size of the buffer
+   * @stable ICU 4.2
+   */
+  CheckedArrayByteSink(char* outbuf, int32_t capacity);
+  /**
+   * Destructor.
+   * @stable ICU 4.2
+   */
+  virtual ~CheckedArrayByteSink();
+  /**
+   * Returns the sink to its original state, without modifying the buffer.
+   * Useful for reusing both the buffer and the sink for multiple streams.
+   * Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0
+   * and Overflowed()=FALSE.
+   * @return *this
+   * @stable ICU 4.6
+   */
+  virtual CheckedArrayByteSink& Reset();
+  /**
+   * Append "bytes[0,n-1]" to this.
+   * @param bytes the pointer to the bytes
+   * @param n the number of bytes; must be non-negative
+   * @stable ICU 4.2
+   */
+  virtual void Append(const char* bytes, int32_t n);
+  /**
+   * Returns a writable buffer for appending and writes the buffer's capacity to
+   * *result_capacity. For details see the base class documentation.
+   * @param min_capacity required minimum capacity of the returned buffer;
+   *                     must be non-negative
+   * @param desired_capacity_hint desired capacity of the returned buffer;
+   *                              must be non-negative
+   * @param scratch default caller-owned buffer
+   * @param scratch_capacity capacity of the scratch buffer
+   * @param result_capacity pointer to an integer which will be set to the
+   *                        capacity of the returned buffer
+   * @return a buffer with *result_capacity>=min_capacity
+   * @stable ICU 4.2
+   */
+  virtual char* GetAppendBuffer(int32_t min_capacity,
+                                int32_t desired_capacity_hint,
+                                char* scratch, int32_t scratch_capacity,
+                                int32_t* result_capacity);
+  /**
+   * Returns the number of bytes actually written to the sink.
+   * @return number of bytes written to the buffer
+   * @stable ICU 4.2
+   */
+  int32_t NumberOfBytesWritten() const { return size_; }
+  /**
+   * Returns true if any bytes were discarded, i.e., if there was an
+   * attempt to write more than 'capacity' bytes.
+   * @return TRUE if more than 'capacity' bytes were Append()ed
+   * @stable ICU 4.2
+   */
+  UBool Overflowed() const { return overflowed_; }
+  /**
+   * Returns the number of bytes appended to the sink.
+   * If Overflowed() then NumberOfBytesAppended()>NumberOfBytesWritten()
+   * else they return the same number.
+   * @return number of bytes written to the buffer
+   * @stable ICU 4.6
+   */
+  int32_t NumberOfBytesAppended() const { return appended_; }
+private:
+  char* outbuf_;
+  const int32_t capacity_;
+  int32_t size_;
+  int32_t appended_;
+  UBool overflowed_;
+  CheckedArrayByteSink(); ///< default constructor not implemented 
+  CheckedArrayByteSink(const CheckedArrayByteSink &); ///< copy constructor not implemented
+  CheckedArrayByteSink &operator=(const CheckedArrayByteSink &); ///< assignment operator not implemented
+};
+
+#if U_HAVE_STD_STRING
+
+/** 
+ * Implementation of ByteSink that writes to a "string".
+ * The StringClass is usually instantiated with a std::string.
+ * @stable ICU 4.2
+ */
+template<typename StringClass>
+class StringByteSink : public ByteSink {
+ public:
+  /**
+   * Constructs a ByteSink that will append bytes to the dest string.
+   * @param dest pointer to string object to append to
+   * @stable ICU 4.2
+   */
+  StringByteSink(StringClass* dest) : dest_(dest) { }
+  /**
+   * Append "bytes[0,n-1]" to this.
+   * @param data the pointer to the bytes
+   * @param n the number of bytes; must be non-negative
+   * @stable ICU 4.2
+   */
+  virtual void Append(const char* data, int32_t n) { dest_->append(data, n); }
+ private:
+  StringClass* dest_;
+  StringByteSink(); ///< default constructor not implemented 
+  StringByteSink(const StringByteSink &); ///< copy constructor not implemented
+  StringByteSink &operator=(const StringByteSink &); ///< assignment operator not implemented
+};
+
+#endif
+
+U_NAMESPACE_END
+
+#endif  // __BYTESTREAM_H__

+ 519 - 0
sqlite/unicode/bytestrie.h

@@ -0,0 +1,519 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2010-2012, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*   file name:  bytestrie.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2010sep25
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __BYTESTRIE_H__
+#define __BYTESTRIE_H__
+
+/**
+ * \file
+ * \brief C++ API: Trie for mapping byte sequences to integer values.
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/stringpiece.h"
+#include "unicode/uobject.h"
+#include "unicode/ustringtrie.h"
+
+U_NAMESPACE_BEGIN
+
+class ByteSink;
+class BytesTrieBuilder;
+class CharString;
+class UVector32;
+
+/**
+ * Light-weight, non-const reader class for a BytesTrie.
+ * Traverses a byte-serialized data structure with minimal state,
+ * for mapping byte sequences to non-negative integer values.
+ *
+ * This class owns the serialized trie data only if it was constructed by
+ * the builder's build() method.
+ * The public constructor and the copy constructor only alias the data (only copy the pointer).
+ * There is no assignment operator.
+ *
+ * This class is not intended for public subclassing.
+ * @stable ICU 4.8
+ */
+class U_COMMON_API BytesTrie : public UMemory {
+public:
+    /**
+     * Constructs a BytesTrie reader instance.
+     *
+     * The trieBytes must contain a copy of a byte sequence from the BytesTrieBuilder,
+     * starting with the first byte of that sequence.
+     * The BytesTrie object will not read more bytes than
+     * the BytesTrieBuilder generated in the corresponding build() call.
+     *
+     * The array is not copied/cloned and must not be modified while
+     * the BytesTrie object is in use.
+     *
+     * @param trieBytes The byte array that contains the serialized trie.
+     * @stable ICU 4.8
+     */
+    BytesTrie(const void *trieBytes)
+            : ownedArray_(NULL), bytes_(static_cast<const uint8_t *>(trieBytes)),
+              pos_(bytes_), remainingMatchLength_(-1) {}
+
+    /**
+     * Destructor.
+     * @stable ICU 4.8
+     */
+    ~BytesTrie();
+
+    /**
+     * Copy constructor, copies the other trie reader object and its state,
+     * but not the byte array which will be shared. (Shallow copy.)
+     * @param other Another BytesTrie object.
+     * @stable ICU 4.8
+     */
+    BytesTrie(const BytesTrie &other)
+            : ownedArray_(NULL), bytes_(other.bytes_),
+              pos_(other.pos_), remainingMatchLength_(other.remainingMatchLength_) {}
+
+    /**
+     * Resets this trie to its initial state.
+     * @return *this
+     * @stable ICU 4.8
+     */
+    BytesTrie &reset() {
+        pos_=bytes_;
+        remainingMatchLength_=-1;
+        return *this;
+    }
+
+    /**
+     * BytesTrie state object, for saving a trie's current state
+     * and resetting the trie back to this state later.
+     * @stable ICU 4.8
+     */
+    class State : public UMemory {
+    public:
+        /**
+         * Constructs an empty State.
+         * @stable ICU 4.8
+         */
+        State() { bytes=NULL; }
+    private:
+        friend class BytesTrie;
+
+        const uint8_t *bytes;
+        const uint8_t *pos;
+        int32_t remainingMatchLength;
+    };
+
+    /**
+     * Saves the state of this trie.
+     * @param state The State object to hold the trie's state.
+     * @return *this
+     * @see resetToState
+     * @stable ICU 4.8
+     */
+    const BytesTrie &saveState(State &state) const {
+        state.bytes=bytes_;
+        state.pos=pos_;
+        state.remainingMatchLength=remainingMatchLength_;
+        return *this;
+    }
+
+    /**
+     * Resets this trie to the saved state.
+     * If the state object contains no state, or the state of a different trie,
+     * then this trie remains unchanged.
+     * @param state The State object which holds a saved trie state.
+     * @return *this
+     * @see saveState
+     * @see reset
+     * @stable ICU 4.8
+     */
+    BytesTrie &resetToState(const State &state) {
+        if(bytes_==state.bytes && bytes_!=NULL) {
+            pos_=state.pos;
+            remainingMatchLength_=state.remainingMatchLength;
+        }
+        return *this;
+    }
+
+    /**
+     * Determines whether the byte sequence so far matches, whether it has a value,
+     * and whether another input byte can continue a matching byte sequence.
+     * @return The match/value Result.
+     * @stable ICU 4.8
+     */
+    UStringTrieResult current() const;
+
+    /**
+     * Traverses the trie from the initial state for this input byte.
+     * Equivalent to reset().next(inByte).
+     * @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff.
+     *               Values below -0x100 and above 0xff will never match.
+     * @return The match/value Result.
+     * @stable ICU 4.8
+     */
+    inline UStringTrieResult first(int32_t inByte) {
+        remainingMatchLength_=-1;
+        if(inByte<0) {
+            inByte+=0x100;
+        }
+        return nextImpl(bytes_, inByte);
+    }
+
+    /**
+     * Traverses the trie from the current state for this input byte.
+     * @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff.
+     *               Values below -0x100 and above 0xff will never match.
+     * @return The match/value Result.
+     * @stable ICU 4.8
+     */
+    UStringTrieResult next(int32_t inByte);
+
+    /**
+     * Traverses the trie from the current state for this byte sequence.
+     * Equivalent to
+     * \code
+     * Result result=current();
+     * for(each c in s)
+     *   if(!USTRINGTRIE_HAS_NEXT(result)) return USTRINGTRIE_NO_MATCH;
+     *   result=next(c);
+     * return result;
+     * \endcode
+     * @param s A string or byte sequence. Can be NULL if length is 0.
+     * @param length The length of the byte sequence. Can be -1 if NUL-terminated.
+     * @return The match/value Result.
+     * @stable ICU 4.8
+     */
+    UStringTrieResult next(const char *s, int32_t length);
+
+    /**
+     * Returns a matching byte sequence's value if called immediately after
+     * current()/first()/next() returned USTRINGTRIE_INTERMEDIATE_VALUE or USTRINGTRIE_FINAL_VALUE.
+     * getValue() can be called multiple times.
+     *
+     * Do not call getValue() after USTRINGTRIE_NO_MATCH or USTRINGTRIE_NO_VALUE!
+     * @return The value for the byte sequence so far.
+     * @stable ICU 4.8
+     */
+    inline int32_t getValue() const {
+        const uint8_t *pos=pos_;
+        int32_t leadByte=*pos++;
+        // U_ASSERT(leadByte>=kMinValueLead);
+        return readValue(pos, leadByte>>1);
+    }
+
+    /**
+     * Determines whether all byte sequences reachable from the current state
+     * map to the same value.
+     * @param uniqueValue Receives the unique value, if this function returns TRUE.
+     *                    (output-only)
+     * @return TRUE if all byte sequences reachable from the current state
+     *         map to the same value.
+     * @stable ICU 4.8
+     */
+    inline UBool hasUniqueValue(int32_t &uniqueValue) const {
+        const uint8_t *pos=pos_;
+        // Skip the rest of a pending linear-match node.
+        return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
+    }
+
+    /**
+     * Finds each byte which continues the byte sequence from the current state.
+     * That is, each byte b for which it would be next(b)!=USTRINGTRIE_NO_MATCH now.
+     * @param out Each next byte is appended to this object.
+     *            (Only uses the out.Append(s, length) method.)
+     * @return the number of bytes which continue the byte sequence from here
+     * @stable ICU 4.8
+     */
+    int32_t getNextBytes(ByteSink &out) const;
+
+    /**
+     * Iterator for all of the (byte sequence, value) pairs in a BytesTrie.
+     * @stable ICU 4.8
+     */
+    class U_COMMON_API Iterator : public UMemory {
+    public:
+        /**
+         * Iterates from the root of a byte-serialized BytesTrie.
+         * @param trieBytes The trie bytes.
+         * @param maxStringLength If 0, the iterator returns full strings/byte sequences.
+         *                        Otherwise, the iterator returns strings with this maximum length.
+         * @param errorCode Standard ICU error code. Its input value must
+         *                  pass the U_SUCCESS() test, or else the function returns
+         *                  immediately. Check for U_FAILURE() on output or use with
+         *                  function chaining. (See User Guide for details.)
+         * @stable ICU 4.8
+         */
+        Iterator(const void *trieBytes, int32_t maxStringLength, UErrorCode &errorCode);
+
+        /**
+         * Iterates from the current state of the specified BytesTrie.
+         * @param trie The trie whose state will be copied for iteration.
+         * @param maxStringLength If 0, the iterator returns full strings/byte sequences.
+         *                        Otherwise, the iterator returns strings with this maximum length.
+         * @param errorCode Standard ICU error code. Its input value must
+         *                  pass the U_SUCCESS() test, or else the function returns
+         *                  immediately. Check for U_FAILURE() on output or use with
+         *                  function chaining. (See User Guide for details.)
+         * @stable ICU 4.8
+         */
+        Iterator(const BytesTrie &trie, int32_t maxStringLength, UErrorCode &errorCode);
+
+        /**
+         * Destructor.
+         * @stable ICU 4.8
+         */
+        ~Iterator();
+
+        /**
+         * Resets this iterator to its initial state.
+         * @return *this
+         * @stable ICU 4.8
+         */
+        Iterator &reset();
+
+        /**
+         * @return TRUE if there are more elements.
+         * @stable ICU 4.8
+         */
+        UBool hasNext() const;
+
+        /**
+         * Finds the next (byte sequence, value) pair if there is one.
+         *
+         * If the byte sequence is truncated to the maximum length and does not
+         * have a real value, then the value is set to -1.
+         * In this case, this "not a real value" is indistinguishable from
+         * a real value of -1.
+         * @param errorCode Standard ICU error code. Its input value must
+         *                  pass the U_SUCCESS() test, or else the function returns
+         *                  immediately. Check for U_FAILURE() on output or use with
+         *                  function chaining. (See User Guide for details.)
+         * @return TRUE if there is another element.
+         * @stable ICU 4.8
+         */
+        UBool next(UErrorCode &errorCode);
+
+        /**
+         * @return The NUL-terminated byte sequence for the last successful next().
+         * @stable ICU 4.8
+         */
+        const StringPiece &getString() const { return sp_; }
+        /**
+         * @return The value for the last successful next().
+         * @stable ICU 4.8
+         */
+        int32_t getValue() const { return value_; }
+
+    private:
+        UBool truncateAndStop();
+
+        const uint8_t *branchNext(const uint8_t *pos, int32_t length, UErrorCode &errorCode);
+
+        const uint8_t *bytes_;
+        const uint8_t *pos_;
+        const uint8_t *initialPos_;
+        int32_t remainingMatchLength_;
+        int32_t initialRemainingMatchLength_;
+
+        CharString *str_;
+        StringPiece sp_;
+        int32_t maxLength_;
+        int32_t value_;
+
+        // The stack stores pairs of integers for backtracking to another
+        // outbound edge of a branch node.
+        // The first integer is an offset from bytes_.
+        // The second integer has the str_->length() from before the node in bits 15..0,
+        // and the remaining branch length in bits 24..16. (Bits 31..25 are unused.)
+        // (We could store the remaining branch length minus 1 in bits 23..16 and not use bits 31..24,
+        // but the code looks more confusing that way.)
+        UVector32 *stack_;
+    };
+
+private:
+    friend class BytesTrieBuilder;
+
+    /**
+     * Constructs a BytesTrie reader instance.
+     * Unlike the public constructor which just aliases an array,
+     * this constructor adopts the builder's array.
+     * This constructor is only called by the builder.
+     */
+    BytesTrie(void *adoptBytes, const void *trieBytes)
+            : ownedArray_(static_cast<uint8_t *>(adoptBytes)),
+              bytes_(static_cast<const uint8_t *>(trieBytes)),
+              pos_(bytes_), remainingMatchLength_(-1) {}
+
+    // No assignment operator.
+    BytesTrie &operator=(const BytesTrie &other);
+
+    inline void stop() {
+        pos_=NULL;
+    }
+
+    // Reads a compact 32-bit integer.
+    // pos is already after the leadByte, and the lead byte is already shifted right by 1.
+    static int32_t readValue(const uint8_t *pos, int32_t leadByte);
+    static inline const uint8_t *skipValue(const uint8_t *pos, int32_t leadByte) {
+        // U_ASSERT(leadByte>=kMinValueLead);
+        if(leadByte>=(kMinTwoByteValueLead<<1)) {
+            if(leadByte<(kMinThreeByteValueLead<<1)) {
+                ++pos;
+            } else if(leadByte<(kFourByteValueLead<<1)) {
+                pos+=2;
+            } else {
+                pos+=3+((leadByte>>1)&1);
+            }
+        }
+        return pos;
+    }
+    static inline const uint8_t *skipValue(const uint8_t *pos) {
+        int32_t leadByte=*pos++;
+        return skipValue(pos, leadByte);
+    }
+
+    // Reads a jump delta and jumps.
+    static const uint8_t *jumpByDelta(const uint8_t *pos);
+
+    static inline const uint8_t *skipDelta(const uint8_t *pos) {
+        int32_t delta=*pos++;
+        if(delta>=kMinTwoByteDeltaLead) {
+            if(delta<kMinThreeByteDeltaLead) {
+                ++pos;
+            } else if(delta<kFourByteDeltaLead) {
+                pos+=2;
+            } else {
+                pos+=3+(delta&1);
+            }
+        }
+        return pos;
+    }
+
+    static inline UStringTrieResult valueResult(int32_t node) {
+        return (UStringTrieResult)(USTRINGTRIE_INTERMEDIATE_VALUE-(node&kValueIsFinal));
+    }
+
+    // Handles a branch node for both next(byte) and next(string).
+    UStringTrieResult branchNext(const uint8_t *pos, int32_t length, int32_t inByte);
+
+    // Requires remainingLength_<0.
+    UStringTrieResult nextImpl(const uint8_t *pos, int32_t inByte);
+
+    // Helper functions for hasUniqueValue().
+    // Recursively finds a unique value (or whether there is not a unique one)
+    // from a branch.
+    static const uint8_t *findUniqueValueFromBranch(const uint8_t *pos, int32_t length,
+                                                    UBool haveUniqueValue, int32_t &uniqueValue);
+    // Recursively finds a unique value (or whether there is not a unique one)
+    // starting from a position on a node lead byte.
+    static UBool findUniqueValue(const uint8_t *pos, UBool haveUniqueValue, int32_t &uniqueValue);
+
+    // Helper functions for getNextBytes().
+    // getNextBytes() when pos is on a branch node.
+    static void getNextBranchBytes(const uint8_t *pos, int32_t length, ByteSink &out);
+    static void append(ByteSink &out, int c);
+
+    // BytesTrie data structure
+    //
+    // The trie consists of a series of byte-serialized nodes for incremental
+    // string/byte sequence matching. The root node is at the beginning of the trie data.
+    //
+    // Types of nodes are distinguished by their node lead byte ranges.
+    // After each node, except a final-value node, another node follows to
+    // encode match values or continue matching further bytes.
+    //
+    // Node types:
+    //  - Value node: Stores a 32-bit integer in a compact, variable-length format.
+    //    The value is for the string/byte sequence so far.
+    //    One node bit indicates whether the value is final or whether
+    //    matching continues with the next node.
+    //  - Linear-match node: Matches a number of bytes.
+    //  - Branch node: Branches to other nodes according to the current input byte.
+    //    The node byte is the length of the branch (number of bytes to select from)
+    //    minus 1. It is followed by a sub-node:
+    //    - If the length is at most kMaxBranchLinearSubNodeLength, then
+    //      there are length-1 (key, value) pairs and then one more comparison byte.
+    //      If one of the key bytes matches, then the value is either a final value for
+    //      the string/byte sequence so far, or a "jump" delta to the next node.
+    //      If the last byte matches, then matching continues with the next node.
+    //      (Values have the same encoding as value nodes.)
+    //    - If the length is greater than kMaxBranchLinearSubNodeLength, then
+    //      there is one byte and one "jump" delta.
+    //      If the input byte is less than the sub-node byte, then "jump" by delta to
+    //      the next sub-node which will have a length of length/2.
+    //      (The delta has its own compact encoding.)
+    //      Otherwise, skip the "jump" delta to the next sub-node
+    //      which will have a length of length-length/2.
+
+    // Node lead byte values.
+
+    // 00..0f: Branch node. If node!=0 then the length is node+1, otherwise
+    // the length is one more than the next byte.
+
+    // For a branch sub-node with at most this many entries, we drop down
+    // to a linear search.
+    static const int32_t kMaxBranchLinearSubNodeLength=5;
+
+    // 10..1f: Linear-match node, match 1..16 bytes and continue reading the next node.
+    static const int32_t kMinLinearMatch=0x10;
+    static const int32_t kMaxLinearMatchLength=0x10;
+
+    // 20..ff: Variable-length value node.
+    // If odd, the value is final. (Otherwise, intermediate value or jump delta.)
+    // Then shift-right by 1 bit.
+    // The remaining lead byte value indicates the number of following bytes (0..4)
+    // and contains the value's top bits.
+    static const int32_t kMinValueLead=kMinLinearMatch+kMaxLinearMatchLength;  // 0x20
+    // It is a final value if bit 0 is set.
+    static const int32_t kValueIsFinal=1;
+
+    // Compact value: After testing bit 0, shift right by 1 and then use the following thresholds.
+    static const int32_t kMinOneByteValueLead=kMinValueLead/2;  // 0x10
+    static const int32_t kMaxOneByteValue=0x40;  // At least 6 bits in the first byte.
+
+    static const int32_t kMinTwoByteValueLead=kMinOneByteValueLead+kMaxOneByteValue+1;  // 0x51
+    static const int32_t kMaxTwoByteValue=0x1aff;
+
+    static const int32_t kMinThreeByteValueLead=kMinTwoByteValueLead+(kMaxTwoByteValue>>8)+1;  // 0x6c
+    static const int32_t kFourByteValueLead=0x7e;
+
+    // A little more than Unicode code points. (0x11ffff)
+    static const int32_t kMaxThreeByteValue=((kFourByteValueLead-kMinThreeByteValueLead)<<16)-1;
+
+    static const int32_t kFiveByteValueLead=0x7f;
+
+    // Compact delta integers.
+    static const int32_t kMaxOneByteDelta=0xbf;
+    static const int32_t kMinTwoByteDeltaLead=kMaxOneByteDelta+1;  // 0xc0
+    static const int32_t kMinThreeByteDeltaLead=0xf0;
+    static const int32_t kFourByteDeltaLead=0xfe;
+    static const int32_t kFiveByteDeltaLead=0xff;
+
+    static const int32_t kMaxTwoByteDelta=((kMinThreeByteDeltaLead-kMinTwoByteDeltaLead)<<8)-1;  // 0x2fff
+    static const int32_t kMaxThreeByteDelta=((kFourByteDeltaLead-kMinThreeByteDeltaLead)<<16)-1;  // 0xdffff
+
+    uint8_t *ownedArray_;
+
+    // Fixed value referencing the BytesTrie bytes.
+    const uint8_t *bytes_;
+
+    // Iterator variables.
+
+    // Pointer to next trie byte to read. NULL if no more matches.
+    const uint8_t *pos_;
+    // Remaining length of a linear-match node, minus 1. Negative if not in such a node.
+    int32_t remainingMatchLength_;
+};
+
+U_NAMESPACE_END
+
+#endif  // __BYTESTRIE_H__

+ 181 - 0
sqlite/unicode/bytestriebuilder.h

@@ -0,0 +1,181 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2010-2014, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*   file name:  bytestriebuilder.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2010sep25
+*   created by: Markus W. Scherer
+*/
+
+/**
+ * \file
+ * \brief C++ API: Builder for icu::BytesTrie
+ */
+
+#ifndef __BYTESTRIEBUILDER_H__
+#define __BYTESTRIEBUILDER_H__
+
+#include "unicode/utypes.h"
+#include "unicode/bytestrie.h"
+#include "unicode/stringpiece.h"
+#include "unicode/stringtriebuilder.h"
+
+U_NAMESPACE_BEGIN
+
+class BytesTrieElement;
+class CharString;
+
+/**
+ * Builder class for BytesTrie.
+ *
+ * This class is not intended for public subclassing.
+ * @stable ICU 4.8
+ */
+class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder {
+public:
+    /**
+     * Constructs an empty builder.
+     * @param errorCode Standard ICU error code.
+     * @stable ICU 4.8
+     */
+    BytesTrieBuilder(UErrorCode &errorCode);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.8
+     */
+    virtual ~BytesTrieBuilder();
+
+    /**
+     * Adds a (byte sequence, value) pair.
+     * The byte sequence must be unique.
+     * The bytes will be copied; the builder does not keep
+     * a reference to the input StringPiece or its data().
+     * @param s The input byte sequence.
+     * @param value The value associated with this byte sequence.
+     * @param errorCode Standard ICU error code. Its input value must
+     *                  pass the U_SUCCESS() test, or else the function returns
+     *                  immediately. Check for U_FAILURE() on output or use with
+     *                  function chaining. (See User Guide for details.)
+     * @return *this
+     * @stable ICU 4.8
+     */
+    BytesTrieBuilder &add(const StringPiece &s, int32_t value, UErrorCode &errorCode);
+
+    /**
+     * Builds a BytesTrie for the add()ed data.
+     * Once built, no further data can be add()ed until clear() is called.
+     *
+     * A BytesTrie cannot be empty. At least one (byte sequence, value) pair
+     * must have been add()ed.
+     *
+     * This method passes ownership of the builder's internal result array to the new trie object.
+     * Another call to any build() variant will re-serialize the trie.
+     * After clear() has been called, a new array will be used as well.
+     * @param buildOption Build option, see UStringTrieBuildOption.
+     * @param errorCode Standard ICU error code. Its input value must
+     *                  pass the U_SUCCESS() test, or else the function returns
+     *                  immediately. Check for U_FAILURE() on output or use with
+     *                  function chaining. (See User Guide for details.)
+     * @return A new BytesTrie for the add()ed data.
+     * @stable ICU 4.8
+     */
+    BytesTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
+
+    /**
+     * Builds a BytesTrie for the add()ed data and byte-serializes it.
+     * Once built, no further data can be add()ed until clear() is called.
+     *
+     * A BytesTrie cannot be empty. At least one (byte sequence, value) pair
+     * must have been add()ed.
+     *
+     * Multiple calls to buildStringPiece() return StringPieces referring to the
+     * builder's same byte array, without rebuilding.
+     * If buildStringPiece() is called after build(), the trie will be
+     * re-serialized into a new array.
+     * If build() is called after buildStringPiece(), the trie object will become
+     * the owner of the previously returned array.
+     * After clear() has been called, a new array will be used as well.
+     * @param buildOption Build option, see UStringTrieBuildOption.
+     * @param errorCode Standard ICU error code. Its input value must
+     *                  pass the U_SUCCESS() test, or else the function returns
+     *                  immediately. Check for U_FAILURE() on output or use with
+     *                  function chaining. (See User Guide for details.)
+     * @return A StringPiece which refers to the byte-serialized BytesTrie for the add()ed data.
+     * @stable ICU 4.8
+     */
+    StringPiece buildStringPiece(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
+
+    /**
+     * Removes all (byte sequence, value) pairs.
+     * New data can then be add()ed and a new trie can be built.
+     * @return *this
+     * @stable ICU 4.8
+     */
+    BytesTrieBuilder &clear();
+
+private:
+    BytesTrieBuilder(const BytesTrieBuilder &other);  // no copy constructor
+    BytesTrieBuilder &operator=(const BytesTrieBuilder &other);  // no assignment operator
+
+    void buildBytes(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
+
+    virtual int32_t getElementStringLength(int32_t i) const;
+    virtual UChar getElementUnit(int32_t i, int32_t byteIndex) const;
+    virtual int32_t getElementValue(int32_t i) const;
+
+    virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t byteIndex) const;
+
+    virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t byteIndex) const;
+    virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;
+    virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, UChar byte) const;
+
+    virtual UBool matchNodesCanHaveValues() const { return FALSE; }
+
+    virtual int32_t getMaxBranchLinearSubNodeLength() const { return BytesTrie::kMaxBranchLinearSubNodeLength; }
+    virtual int32_t getMinLinearMatch() const { return BytesTrie::kMinLinearMatch; }
+    virtual int32_t getMaxLinearMatchLength() const { return BytesTrie::kMaxLinearMatchLength; }
+
+    /**
+     * @internal
+     */
+    class BTLinearMatchNode : public LinearMatchNode {
+    public:
+        BTLinearMatchNode(const char *units, int32_t len, Node *nextNode);
+        virtual UBool operator==(const Node &other) const;
+        virtual void write(StringTrieBuilder &builder);
+    private:
+        const char *s;
+    };
+
+    virtual Node *createLinearMatchNode(int32_t i, int32_t byteIndex, int32_t length,
+                                        Node *nextNode) const;
+
+    UBool ensureCapacity(int32_t length);
+    virtual int32_t write(int32_t byte);
+    int32_t write(const char *b, int32_t length);
+    virtual int32_t writeElementUnits(int32_t i, int32_t byteIndex, int32_t length);
+    virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
+    virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
+    virtual int32_t writeDeltaTo(int32_t jumpTarget);
+
+    CharString *strings;  // Pointer not object so we need not #include internal charstr.h.
+    BytesTrieElement *elements;
+    int32_t elementsCapacity;
+    int32_t elementsLength;
+
+    // Byte serialization of the trie.
+    // Grows from the back: bytesLength measures from the end of the buffer!
+    char *bytes;
+    int32_t bytesCapacity;
+    int32_t bytesLength;
+};
+
+U_NAMESPACE_END
+
+#endif  // __BYTESTRIEBUILDER_H__

+ 2549 - 0
sqlite/unicode/calendar.h

@@ -0,0 +1,2549 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2014, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File CALENDAR.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   04/22/97    aliu        Expanded and corrected comments and other header
+*                           contents.
+*   05/01/97    aliu        Made equals(), before(), after() arguments const.
+*   05/20/97    aliu        Replaced fAreFieldsSet with fAreFieldsInSync and
+*                           fAreAllFieldsSet.
+*   07/27/98    stephen     Sync up with JDK 1.2
+*   11/15/99    weiv        added YEAR_WOY and DOW_LOCAL
+*                           to EDateFields
+*    8/19/2002  srl         Removed Javaisms
+*   11/07/2003  srl         Update, clean up documentation.
+********************************************************************************
+*/
+
+#ifndef CALENDAR_H
+#define CALENDAR_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Calendar object
+ */
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+#include "unicode/locid.h"
+#include "unicode/timezone.h"
+#include "unicode/ucal.h"
+#include "unicode/umisc.h"
+
+U_NAMESPACE_BEGIN
+
+class ICUServiceFactory;
+
+/**
+ * @internal
+ */
+typedef int32_t UFieldResolutionTable[12][8];
+
+class BasicTimeZone;
+/**
+ * <code>Calendar</code> is an abstract base class for converting between
+ * a <code>UDate</code> object and a set of integer fields such as
+ * <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>, <code>HOUR</code>,
+ * and so on. (A <code>UDate</code> object represents a specific instant in
+ * time with millisecond precision. See UDate
+ * for information about the <code>UDate</code> class.)
+ *
+ * <p>
+ * Subclasses of <code>Calendar</code> interpret a <code>UDate</code>
+ * according to the rules of a specific calendar system.
+ * The most commonly used subclass of <code>Calendar</code> is
+ * <code>GregorianCalendar</code>. Other subclasses could represent
+ * the various types of lunar calendars in use in many parts of the world.
+ *
+ * <p>
+ * <b>NOTE</b>: (ICU 2.6) The subclass interface should be considered unstable
+ * - it WILL change.
+ *
+ * <p>
+ * Like other locale-sensitive classes, <code>Calendar</code> provides a
+ * static method, <code>createInstance</code>, for getting a generally useful
+ * object of this type. <code>Calendar</code>'s <code>createInstance</code> method
+ * returns the appropriate <code>Calendar</code> subclass whose
+ * time fields have been initialized with the current date and time:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * Calendar *rightNow = Calendar::createInstance(errCode);
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * <p>
+ * A <code>Calendar</code> object can produce all the time field values
+ * needed to implement the date-time formatting for a particular language
+ * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
+ *
+ * <p>
+ * When computing a <code>UDate</code> from time fields, some special circumstances
+ * may arise: there may be insufficient information to compute the
+ * <code>UDate</code> (such as only year and month but no day in the month),
+ * there may be inconsistent information (such as "Tuesday, July 15, 1996"
+ * -- July 15, 1996 is actually a Monday), or the input time might be ambiguous
+ * because of time zone transition.
+ *
+ * <p>
+ * <strong>Insufficient information.</strong> The calendar will use default
+ * information to specify the missing fields. This may vary by calendar; for
+ * the Gregorian calendar, the default for a field is the same as that of the
+ * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.
+ *
+ * <p>
+ * <strong>Inconsistent information.</strong> If fields conflict, the calendar
+ * will give preference to fields set more recently. For example, when
+ * determining the day, the calendar will look for one of the following
+ * combinations of fields.  The most recent combination, as determined by the
+ * most recently set single field, will be used.
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * MONTH + DAY_OF_MONTH
+ * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
+ * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
+ * DAY_OF_YEAR
+ * DAY_OF_WEEK + WEEK_OF_YEAR
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * For the time of day:
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * HOUR_OF_DAY
+ * AM_PM + HOUR
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * <p>
+ * <strong>Ambiguous Wall Clock Time.</strong> When time offset from UTC has
+ * changed, it produces an ambiguous time slot around the transition. For example,
+ * many US locations observe daylight saving time. On the date switching to daylight
+ * saving time in US, wall clock time jumps from 12:59 AM (standard) to 2:00 AM
+ * (daylight). Therefore, wall clock time from 1:00 AM to 1:59 AM do not exist on
+ * the date. When the input wall time fall into this missing time slot, the ICU
+ * Calendar resolves the time using the UTC offset before the transition by default.
+ * In this example, 1:30 AM is interpreted as 1:30 AM standard time (non-exist),
+ * so the final result will be 2:30 AM daylight time.
+ * 
+ * <p>On the date switching back to standard time, wall clock time is moved back one
+ * hour at 2:00 AM. So wall clock time from 1:00 AM to 1:59 AM occur twice. In this
+ * case, the ICU Calendar resolves the time using the UTC offset after the transition
+ * by default. For example, 1:30 AM on the date is resolved as 1:30 AM standard time.
+ *
+ * <p>Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs
+ * {@link #setRepeatedWallTimeOption} and {@link #setSkippedWallTimeOption}.
+ * These methods are available in ICU 49 or later versions.
+ *
+ * <p>
+ * <strong>Note:</strong> for some non-Gregorian calendars, different
+ * fields may be necessary for complete disambiguation. For example, a full
+ * specification of the historial Arabic astronomical calendar requires year,
+ * month, day-of-month <em>and</em> day-of-week in some cases.
+ *
+ * <p>
+ * <strong>Note:</strong> There are certain possible ambiguities in
+ * interpretation of certain singular times, which are resolved in the
+ * following ways:
+ * <ol>
+ *     <li> 24:00:00 "belongs" to the following day. That is,
+ *          23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970
+ *
+ *     <li> Although historically not precise, midnight also belongs to "am",
+ *          and noon belongs to "pm", so on the same day,
+ *          12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm
+ * </ol>
+ *
+ * <p>
+ * The date or time format strings are not part of the definition of a
+ * calendar, as those must be modifiable or overridable by the user at
+ * runtime. Use {@link DateFormat}
+ * to format dates.
+ *
+ * <p>
+ * <code>Calendar</code> provides an API for field "rolling", where fields
+ * can be incremented or decremented, but wrap around. For example, rolling the
+ * month up in the date <code>December 12, <b>1996</b></code> results in
+ * <code>January 12, <b>1996</b></code>.
+ *
+ * <p>
+ * <code>Calendar</code> also provides a date arithmetic function for
+ * adding the specified (signed) amount of time to a particular time field.
+ * For example, subtracting 5 days from the date <code>September 12, 1996</code>
+ * results in <code>September 7, 1996</code>.
+ *
+ * <p><big><b>Supported range</b></big>
+ *
+ * <p>The allowable range of <code>Calendar</code> has been
+ * narrowed. <code>GregorianCalendar</code> used to attempt to support
+ * the range of dates with millisecond values from
+ * <code>Long.MIN_VALUE</code> to <code>Long.MAX_VALUE</code>.
+ * The new <code>Calendar</code> protocol specifies the
+ * maximum range of supportable dates as those having Julian day numbers
+ * of <code>-0x7F000000</code> to <code>+0x7F000000</code>. This
+ * corresponds to years from ~5,800,000 BCE to ~5,800,000 CE. Programmers
+ * should use the protected constants in <code>Calendar</code> to
+ * specify an extremely early or extremely late date.</p>
+ *
+ * @stable ICU 2.0
+ */
+class U_I18N_API Calendar : public UObject {
+public:
+
+    /**
+     * Field IDs for date and time. Used to specify date/time fields. ERA is calendar
+     * specific. Example ranges given are for illustration only; see specific Calendar
+     * subclasses for actual ranges.
+     * @deprecated ICU 2.6. Use C enum UCalendarDateFields defined in ucal.h
+     */
+    enum EDateFields {
+#ifndef U_HIDE_DEPRECATED_API
+/*
+ * ERA may be defined on other platforms. To avoid any potential problems undefined it here.
+ */
+#ifdef ERA
+#undef ERA
+#endif
+        ERA,                  // Example: 0..1
+        YEAR,                 // Example: 1..big number
+        MONTH,                // Example: 0..11
+        WEEK_OF_YEAR,         // Example: 1..53
+        WEEK_OF_MONTH,        // Example: 1..4
+        DATE,                 // Example: 1..31
+        DAY_OF_YEAR,          // Example: 1..365
+        DAY_OF_WEEK,          // Example: 1..7
+        DAY_OF_WEEK_IN_MONTH, // Example: 1..4, may be specified as -1
+        AM_PM,                // Example: 0..1
+        HOUR,                 // Example: 0..11
+        HOUR_OF_DAY,          // Example: 0..23
+        MINUTE,               // Example: 0..59
+        SECOND,               // Example: 0..59
+        MILLISECOND,          // Example: 0..999
+        ZONE_OFFSET,          // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
+        DST_OFFSET,           // Example: 0 or U_MILLIS_PER_HOUR
+        YEAR_WOY,             // 'Y' Example: 1..big number - Year of Week of Year
+        DOW_LOCAL,            // 'e' Example: 1..7 - Day of Week / Localized
+        
+        EXTENDED_YEAR,
+        JULIAN_DAY,
+        MILLISECONDS_IN_DAY,
+        IS_LEAP_MONTH,
+
+        FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
+#endif /* U_HIDE_DEPRECATED_API */
+    };
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
+     * who create locale resources for the field of first-day-of-week should be aware of
+     * this. For instance, in US locale, first-day-of-week is set to 1, i.e., SUNDAY.
+     * @deprecated ICU 2.6. Use C enum UCalendarDaysOfWeek defined in ucal.h
+     */
+    enum EDaysOfWeek {
+        SUNDAY = 1,
+        MONDAY,
+        TUESDAY,
+        WEDNESDAY,
+        THURSDAY,
+        FRIDAY,
+        SATURDAY
+    };
+
+    /**
+     * Useful constants for month. Note: Calendar month is 0-based.
+     * @deprecated ICU 2.6. Use C enum UCalendarMonths defined in ucal.h
+     */
+    enum EMonths {
+        JANUARY,
+        FEBRUARY,
+        MARCH,
+        APRIL,
+        MAY,
+        JUNE,
+        JULY,
+        AUGUST,
+        SEPTEMBER,
+        OCTOBER,
+        NOVEMBER,
+        DECEMBER,
+        UNDECIMBER
+    };
+
+    /**
+     * Useful constants for hour in 12-hour clock. Used in GregorianCalendar.
+     * @deprecated ICU 2.6. Use C enum UCalendarAMPMs defined in ucal.h
+     */
+    enum EAmpm {
+        AM,
+        PM
+    };
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * destructor
+     * @stable ICU 2.0
+     */
+    virtual ~Calendar();
+
+    /**
+     * Create and return a polymorphic copy of this calendar.
+     *
+     * @return    a polymorphic copy of this calendar.
+     * @stable ICU 2.0
+     */
+    virtual Calendar* clone(void) const = 0;
+
+    /**
+     * Creates a Calendar using the default timezone and locale. Clients are responsible
+     * for deleting the object returned.
+     *
+     * @param success  Indicates the success/failure of Calendar creation. Filled in
+     *                 with U_ZERO_ERROR if created successfully, set to a failure result
+     *                 otherwise. U_MISSING_RESOURCE_ERROR will be returned if the resource data
+     *                 requests a calendar type which has not been installed.
+     * @return         A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(UErrorCode& success);
+
+    /**
+     * Creates a Calendar using the given timezone and the default locale.
+     * The Calendar takes ownership of zoneToAdopt; the
+     * client must not delete it.
+     *
+     * @param zoneToAdopt  The given timezone to be adopted.
+     * @param success      Indicates the success/failure of Calendar creation. Filled in
+     *                     with U_ZERO_ERROR if created successfully, set to a failure result
+     *                     otherwise.
+     * @return             A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, UErrorCode& success);
+
+    /**
+     * Creates a Calendar using the given timezone and the default locale.  The TimeZone
+     * is _not_ adopted; the client is still responsible for deleting it.
+     *
+     * @param zone  The timezone.
+     * @param success      Indicates the success/failure of Calendar creation. Filled in
+     *                     with U_ZERO_ERROR if created successfully, set to a failure result
+     *                     otherwise.
+     * @return             A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, UErrorCode& success);
+
+    /**
+     * Creates a Calendar using the default timezone and the given locale.
+     *
+     * @param aLocale  The given locale.
+     * @param success  Indicates the success/failure of Calendar creation. Filled in
+     *                 with U_ZERO_ERROR if created successfully, set to a failure result
+     *                 otherwise.
+     * @return         A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Creates a Calendar using the given timezone and given locale.
+     * The Calendar takes ownership of zoneToAdopt; the
+     * client must not delete it.
+     *
+     * @param zoneToAdopt  The given timezone to be adopted.
+     * @param aLocale      The given locale.
+     * @param success      Indicates the success/failure of Calendar creation. Filled in
+     *                     with U_ZERO_ERROR if created successfully, set to a failure result
+     *                     otherwise.
+     * @return             A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Gets a Calendar using the given timezone and given locale.  The TimeZone
+     * is _not_ adopted; the client is still responsible for deleting it.
+     *
+     * @param zone         The given timezone.
+     * @param aLocale      The given locale.
+     * @param success      Indicates the success/failure of Calendar creation. Filled in
+     *                     with U_ZERO_ERROR if created successfully, set to a failure result
+     *                     otherwise.
+     * @return             A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Returns a list of the locales for which Calendars are installed.
+     *
+     * @param count  Number of locales returned.
+     * @return       An array of Locale objects representing the set of locales for which
+     *               Calendars are installed.  The system retains ownership of this list;
+     *               the caller must NOT delete it. Does not include user-registered Calendars.
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+
+    /**
+     * Given a key and a locale, returns an array of string values in a preferred
+     * order that would make a difference. These are all and only those values where
+     * the open (creation) of the service with the locale formed from the input locale
+     * plus input keyword and that value has different behavior than creation with the
+     * input locale alone.
+     * @param key           one of the keys supported by this service.  For now, only
+     *                      "calendar" is supported.
+     * @param locale        the locale
+     * @param commonlyUsed  if set to true it will return only commonly used values
+     *                      with the given locale in preferred order.  Otherwise,
+     *                      it will return all the available values for the locale.
+     * @param status        ICU Error Code
+     * @return a string enumeration over keyword values for the given key and the locale.
+     * @stable ICU 4.2
+     */
+    static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* key,
+                    const Locale& locale, UBool commonlyUsed, UErrorCode& status);
+
+    /**
+     * Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70
+     * (derived from the system time).
+     *
+     * @return   The current UTC time in milliseconds.
+     * @stable ICU 2.0
+     */
+    static UDate U_EXPORT2 getNow(void);
+
+    /**
+     * Gets this Calendar's time as milliseconds. May involve recalculation of time due
+     * to previous calls to set time field values. The time specified is non-local UTC
+     * (GMT) time. Although this method is const, this object may actually be changed
+     * (semantically const).
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return        The current time in UTC (GMT) time, or zero if the operation
+     *                failed.
+     * @stable ICU 2.0
+     */
+    inline UDate getTime(UErrorCode& status) const { return getTimeInMillis(status); }
+
+    /**
+     * Sets this Calendar's current time with the given UDate. The time specified should
+     * be in non-local UTC (GMT) time.
+     *
+     * @param date  The given UDate in UTC (GMT) time.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    inline void setTime(UDate date, UErrorCode& status) { setTimeInMillis(date, status); }
+
+    /**
+     * Compares the equality of two Calendar objects. Objects of different subclasses
+     * are considered unequal. This comparison is very exacting; two Calendar objects
+     * must be in exactly the same state to be considered equal. To compare based on the
+     * represented time, use equals() instead.
+     *
+     * @param that  The Calendar object to be compared with.
+     * @return      True if the given Calendar is the same as this Calendar; false
+     *              otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Calendar& that) const;
+
+    /**
+     * Compares the inequality of two Calendar objects.
+     *
+     * @param that  The Calendar object to be compared with.
+     * @return      True if the given Calendar is not the same as this Calendar; false
+     *              otherwise.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const Calendar& that) const {return !operator==(that);}
+
+    /**
+     * Returns TRUE if the given Calendar object is equivalent to this
+     * one.  An equivalent Calendar will behave exactly as this one
+     * does, but it may be set to a different time.  By contrast, for
+     * the operator==() method to return TRUE, the other Calendar must
+     * be set to the same time.
+     *
+     * @param other the Calendar to be compared with this Calendar
+     * @stable ICU 2.4
+     */
+    virtual UBool isEquivalentTo(const Calendar& other) const;
+
+    /**
+     * Compares the Calendar time, whereas Calendar::operator== compares the equality of
+     * Calendar objects.
+     *
+     * @param when    The Calendar to be compared with this Calendar. Although this is a
+     *                const parameter, the object may be modified physically
+     *                (semantically const).
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return        True if the current time of this Calendar is equal to the time of
+     *                Calendar when; false otherwise.
+     * @stable ICU 2.0
+     */
+    UBool equals(const Calendar& when, UErrorCode& status) const;
+
+    /**
+     * Returns true if this Calendar's current time is before "when"'s current time.
+     *
+     * @param when    The Calendar to be compared with this Calendar. Although this is a
+     *                const parameter, the object may be modified physically
+     *                (semantically const).
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return        True if the current time of this Calendar is before the time of
+     *                Calendar when; false otherwise.
+     * @stable ICU 2.0
+     */
+    UBool before(const Calendar& when, UErrorCode& status) const;
+
+    /**
+     * Returns true if this Calendar's current time is after "when"'s current time.
+     *
+     * @param when    The Calendar to be compared with this Calendar. Although this is a
+     *                const parameter, the object may be modified physically
+     *                (semantically const).
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return        True if the current time of this Calendar is after the time of
+     *                Calendar when; false otherwise.
+     * @stable ICU 2.0
+     */
+    UBool after(const Calendar& when, UErrorCode& status) const;
+
+    /**
+     * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
+     * time field, based on the calendar's rules. For example, to subtract 5 days from
+     * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
+     * the month or Calendar::MONTH field, other fields like date might conflict and
+     * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
+     * in 02/29/96.
+     * Adding a positive value always means moving forward in time, so for the Gregorian calendar,
+     * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces
+     * the numeric value of the field itself).
+     *
+     * @param field   Specifies which date field to modify.
+     * @param amount  The amount of time to be added to the field, in the natural unit
+     *                for that field (e.g., days for the day fields, hours for the hour
+     *                field.)
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
+     */
+    virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
+     * time field, based on the calendar's rules. For example, to subtract 5 days from
+     * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
+     * the month or Calendar::MONTH field, other fields like date might conflict and
+     * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
+     * in 02/29/96.
+     * Adding a positive value always means moving forward in time, so for the Gregorian calendar,
+     * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces
+     * the numeric value of the field itself).
+     *
+     * @param field   Specifies which date field to modify.
+     * @param amount  The amount of time to be added to the field, in the natural unit
+     *                for that field (e.g., days for the day fields, hours for the hour
+     *                field.)
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.6.
+     */
+    virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
+     * time field. For example, to roll the current date up by one day, call
+     * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
+     * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
+     * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
+     * Calendar::MONTH field, other fields like date might conflict and, need to be
+     * changed. For instance, rolling the month up on the date 01/31/96 will result in
+     * 02/29/96. Rolling up always means rolling forward in time (unless the limit of the
+     * field is reached, in which case it may pin or wrap), so for Gregorian calendar,
+     * starting with 100 BC and rolling the year up results in 99 BC.
+     * When eras have a definite beginning and end (as in the Chinese calendar, or as in
+     * most eras in the Japanese calendar) then rolling the year past either limit of the
+     * era will cause the year to wrap around. When eras only have a limit at one end,
+     * then attempting to roll the year past that limit will result in pinning the year
+     * at that limit. Note that for most calendars in which era 0 years move forward in
+     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
+     * result in negative years for era 0 (that is the only way to represent years before
+     * the calendar epoch).
+     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
+     * hour value in the range between 0 and 23, which is zero-based.
+     * <P>
+     * NOTE: Do not use this method -- use roll(EDateFields, int, UErrorCode&) instead.
+     *
+     * @param field   The time field.
+     * @param up      Indicates if the value of the specified time field is to be rolled
+     *                up or rolled down. Use true if rolling up, false otherwise.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, UBool up, UErrorCode& status) instead.
+     */
+    inline void roll(EDateFields field, UBool up, UErrorCode& status);
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
+     * time field. For example, to roll the current date up by one day, call
+     * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
+     * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
+     * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
+     * Calendar::MONTH field, other fields like date might conflict and, need to be
+     * changed. For instance, rolling the month up on the date 01/31/96 will result in
+     * 02/29/96. Rolling up always means rolling forward in time (unless the limit of the
+     * field is reached, in which case it may pin or wrap), so for Gregorian calendar,
+     * starting with 100 BC and rolling the year up results in 99 BC.
+     * When eras have a definite beginning and end (as in the Chinese calendar, or as in
+     * most eras in the Japanese calendar) then rolling the year past either limit of the
+     * era will cause the year to wrap around. When eras only have a limit at one end,
+     * then attempting to roll the year past that limit will result in pinning the year
+     * at that limit. Note that for most calendars in which era 0 years move forward in
+     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
+     * result in negative years for era 0 (that is the only way to represent years before
+     * the calendar epoch).
+     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
+     * hour value in the range between 0 and 23, which is zero-based.
+     * <P>
+     * NOTE: Do not use this method -- use roll(UCalendarDateFields, int, UErrorCode&) instead.
+     *
+     * @param field   The time field.
+     * @param up      Indicates if the value of the specified time field is to be rolled
+     *                up or rolled down. Use true if rolling up, false otherwise.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.6.
+     */
+    inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
+
+    /**
+     * Time Field Rolling function. Rolls by the given amount on the given
+     * time field. For example, to roll the current date up by one day, call
+     * roll(Calendar::DATE, +1, status). When rolling on the month or
+     * Calendar::MONTH field, other fields like date might conflict and, need to be
+     * changed. For instance, rolling the month up on the date 01/31/96 will result in
+     * 02/29/96. Rolling by a positive value always means rolling forward in time (unless
+     * the limit of the field is reached, in which case it may pin or wrap), so for
+     * Gregorian calendar, starting with 100 BC and rolling the year by + 1 results in 99 BC.
+     * When eras have a definite beginning and end (as in the Chinese calendar, or as in
+     * most eras in the Japanese calendar) then rolling the year past either limit of the
+     * era will cause the year to wrap around. When eras only have a limit at one end,
+     * then attempting to roll the year past that limit will result in pinning the year
+     * at that limit. Note that for most calendars in which era 0 years move forward in
+     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
+     * result in negative years for era 0 (that is the only way to represent years before
+     * the calendar epoch).
+     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
+     * hour value in the range between 0 and 23, which is zero-based.
+     * <P>
+     * The only difference between roll() and add() is that roll() does not change
+     * the value of more significant fields when it reaches the minimum or maximum
+     * of its range, whereas add() does.
+     *
+     * @param field   The time field.
+     * @param amount  Indicates amount to roll.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
+     */
+    virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * Time Field Rolling function. Rolls by the given amount on the given
+     * time field. For example, to roll the current date up by one day, call
+     * roll(Calendar::DATE, +1, status). When rolling on the month or
+     * Calendar::MONTH field, other fields like date might conflict and, need to be
+     * changed. For instance, rolling the month up on the date 01/31/96 will result in
+     * 02/29/96. Rolling by a positive value always means rolling forward in time (unless
+     * the limit of the field is reached, in which case it may pin or wrap), so for
+     * Gregorian calendar, starting with 100 BC and rolling the year by + 1 results in 99 BC.
+     * When eras have a definite beginning and end (as in the Chinese calendar, or as in
+     * most eras in the Japanese calendar) then rolling the year past either limit of the
+     * era will cause the year to wrap around. When eras only have a limit at one end,
+     * then attempting to roll the year past that limit will result in pinning the year
+     * at that limit. Note that for most calendars in which era 0 years move forward in
+     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
+     * result in negative years for era 0 (that is the only way to represent years before
+     * the calendar epoch).
+     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
+     * hour value in the range between 0 and 23, which is zero-based.
+     * <P>
+     * The only difference between roll() and add() is that roll() does not change
+     * the value of more significant fields when it reaches the minimum or maximum
+     * of its range, whereas add() does.
+     *
+     * @param field   The time field.
+     * @param amount  Indicates amount to roll.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @stable ICU 2.6.
+     */
+    virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * Return the difference between the given time and the time this
+     * calendar object is set to.  If this calendar is set
+     * <em>before</em> the given time, the returned value will be
+     * positive.  If this calendar is set <em>after</em> the given
+     * time, the returned value will be negative.  The
+     * <code>field</code> parameter specifies the units of the return
+     * value.  For example, if <code>fieldDifference(when,
+     * Calendar::MONTH)</code> returns 3, then this calendar is set to
+     * 3 months before <code>when</code>, and possibly some addition
+     * time less than one month.
+     *
+     * <p>As a side effect of this call, this calendar is advanced
+     * toward <code>when</code> by the given amount.  That is, calling
+     * this method has the side effect of calling <code>add(field,
+     * n)</code>, where <code>n</code> is the return value.
+     *
+     * <p>Usage: To use this method, call it first with the largest
+     * field of interest, then with progressively smaller fields.  For
+     * example:
+     *
+     * <pre>
+     * int y = cal->fieldDifference(when, Calendar::YEAR, err);
+     * int m = cal->fieldDifference(when, Calendar::MONTH, err);
+     * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
+     *
+     * computes the difference between <code>cal</code> and
+     * <code>when</code> in years, months, and days.
+     *
+     * <p>Note: <code>fieldDifference()</code> is
+     * <em>asymmetrical</em>.  That is, in the following code:
+     *
+     * <pre>
+     * cal->setTime(date1, err);
+     * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
+     * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
+     * cal->setTime(date2, err);
+     * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
+     * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
+     *
+     * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
+     * However, this is not generally the case, because of
+     * irregularities in the underlying calendar system (e.g., the
+     * Gregorian calendar has a varying number of days per month).
+     *
+     * @param when the date to compare this calendar's time to
+     * @param field the field in which to compute the result
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @return the difference, either positive or negative, between
+     * this calendar's time and <code>when</code>, in terms of
+     * <code>field</code>.
+     * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).
+     */
+    virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
+
+    /**
+     * Return the difference between the given time and the time this
+     * calendar object is set to.  If this calendar is set
+     * <em>before</em> the given time, the returned value will be
+     * positive.  If this calendar is set <em>after</em> the given
+     * time, the returned value will be negative.  The
+     * <code>field</code> parameter specifies the units of the return
+     * value.  For example, if <code>fieldDifference(when,
+     * Calendar::MONTH)</code> returns 3, then this calendar is set to
+     * 3 months before <code>when</code>, and possibly some addition
+     * time less than one month.
+     *
+     * <p>As a side effect of this call, this calendar is advanced
+     * toward <code>when</code> by the given amount.  That is, calling
+     * this method has the side effect of calling <code>add(field,
+     * n)</code>, where <code>n</code> is the return value.
+     *
+     * <p>Usage: To use this method, call it first with the largest
+     * field of interest, then with progressively smaller fields.  For
+     * example:
+     *
+     * <pre>
+     * int y = cal->fieldDifference(when, Calendar::YEAR, err);
+     * int m = cal->fieldDifference(when, Calendar::MONTH, err);
+     * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
+     *
+     * computes the difference between <code>cal</code> and
+     * <code>when</code> in years, months, and days.
+     *
+     * <p>Note: <code>fieldDifference()</code> is
+     * <em>asymmetrical</em>.  That is, in the following code:
+     *
+     * <pre>
+     * cal->setTime(date1, err);
+     * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
+     * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
+     * cal->setTime(date2, err);
+     * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
+     * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
+     *
+     * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
+     * However, this is not generally the case, because of
+     * irregularities in the underlying calendar system (e.g., the
+     * Gregorian calendar has a varying number of days per month).
+     *
+     * @param when the date to compare this calendar's time to
+     * @param field the field in which to compute the result
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @return the difference, either positive or negative, between
+     * this calendar's time and <code>when</code>, in terms of
+     * <code>field</code>.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);
+
+    /**
+     * Sets the calendar's time zone to be the one passed in. The Calendar takes ownership
+     * of the TimeZone; the caller is no longer responsible for deleting it.  If the
+     * given time zone is NULL, this function has no effect.
+     *
+     * @param value  The given time zone.
+     * @stable ICU 2.0
+     */
+    void adoptTimeZone(TimeZone* value);
+
+    /**
+     * Sets the calendar's time zone to be the same as the one passed in. The TimeZone
+     * passed in is _not_ adopted; the client is still responsible for deleting it.
+     *
+     * @param zone  The given time zone.
+     * @stable ICU 2.0
+     */
+    void setTimeZone(const TimeZone& zone);
+
+    /**
+     * Returns a reference to the time zone owned by this calendar. The returned reference
+     * is only valid until clients make another call to adoptTimeZone or setTimeZone,
+     * or this Calendar is destroyed.
+     *
+     * @return   The time zone object associated with this calendar.
+     * @stable ICU 2.0
+     */
+    const TimeZone& getTimeZone(void) const;
+
+    /**
+     * Returns the time zone owned by this calendar. The caller owns the returned object
+     * and must delete it when done.  After this call, the new time zone associated
+     * with this Calendar is the default TimeZone as returned by TimeZone::createDefault().
+     *
+     * @return   The time zone object which was associated with this calendar.
+     * @stable ICU 2.0
+     */
+    TimeZone* orphanTimeZone(void);
+
+    /**
+     * Queries if the current date for this Calendar is in Daylight Savings Time.
+     *
+     * @param status Fill-in parameter which receives the status of this operation.
+     * @return   True if the current date for this Calendar is in Daylight Savings Time,
+     *           false, otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool inDaylightTime(UErrorCode& status) const = 0;
+
+    /**
+     * Specifies whether or not date/time interpretation is to be lenient. With lenient
+     * interpretation, a date such as "February 942, 1996" will be treated as being
+     * equivalent to the 941st day after February 1, 1996. With strict interpretation,
+     * such dates will cause an error when computing time from the time field values
+     * representing the dates.
+     *
+     * @param lenient  True specifies date/time interpretation to be lenient.
+     *
+     * @see            DateFormat#setLenient
+     * @stable ICU 2.0
+     */
+    void setLenient(UBool lenient);
+
+    /**
+     * Tells whether date/time interpretation is to be lenient.
+     *
+     * @return   True tells that date/time interpretation is to be lenient.
+     * @stable ICU 2.0
+     */
+    UBool isLenient(void) const;
+
+    /**
+     * Sets the behavior for handling wall time repeating multiple times
+     * at negative time zone offset transitions. For example, 1:30 AM on
+     * November 6, 2011 in US Eastern time (Ameirca/New_York) occurs twice;
+     * 1:30 AM EDT, then 1:30 AM EST one hour later. When <code>UCAL_WALLTIME_FIRST</code>
+     * is used, the wall time 1:30AM in this example will be interpreted as 1:30 AM EDT
+     * (first occurrence). When <code>UCAL_WALLTIME_LAST</code> is used, it will be
+     * interpreted as 1:30 AM EST (last occurrence). The default value is
+     * <code>UCAL_WALLTIME_LAST</code>.
+     * <p>
+     * <b>Note:</b>When <code>UCAL_WALLTIME_NEXT_VALID</code> is not a valid
+     * option for this. When the argument is neither <code>UCAL_WALLTIME_FIRST</code>
+     * nor <code>UCAL_WALLTIME_LAST</code>, this method has no effect and will keep
+     * the current setting.
+     * 
+     * @param option the behavior for handling repeating wall time, either
+     * <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.
+     * @see #getRepeatedWallTimeOption
+     * @stable ICU 49
+     */
+    void setRepeatedWallTimeOption(UCalendarWallTimeOption option);
+
+    /**
+     * Gets the behavior for handling wall time repeating multiple times
+     * at negative time zone offset transitions.
+     * 
+     * @return the behavior for handling repeating wall time, either
+     * <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.
+     * @see #setRepeatedWallTimeOption
+     * @stable ICU 49
+     */
+    UCalendarWallTimeOption getRepeatedWallTimeOption(void) const;
+
+    /**
+     * Sets the behavior for handling skipped wall time at positive time zone offset
+     * transitions. For example, 2:30 AM on March 13, 2011 in US Eastern time (America/New_York)
+     * does not exist because the wall time jump from 1:59 AM EST to 3:00 AM EDT. When
+     * <code>UCAL_WALLTIME_FIRST</code> is used, 2:30 AM is interpreted as 30 minutes before 3:00 AM
+     * EDT, therefore, it will be resolved as 1:30 AM EST. When <code>UCAL_WALLTIME_LAST</code>
+     * is used, 2:30 AM is interpreted as 31 minutes after 1:59 AM EST, therefore, it will be
+     * resolved as 3:30 AM EDT. When <code>UCAL_WALLTIME_NEXT_VALID</code> is used, 2:30 AM will
+     * be resolved as next valid wall time, that is 3:00 AM EDT. The default value is
+     * <code>UCAL_WALLTIME_LAST</code>.
+     * <p>
+     * <b>Note:</b>This option is effective only when this calendar is lenient.
+     * When the calendar is strict, such non-existing wall time will cause an error.
+     * 
+     * @param option the behavior for handling skipped wall time at positive time zone
+     * offset transitions, one of <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code> and
+     * <code>UCAL_WALLTIME_NEXT_VALID</code>.
+     * @see #getSkippedWallTimeOption
+     * 
+     * @stable ICU 49
+     */
+    void setSkippedWallTimeOption(UCalendarWallTimeOption option);
+
+    /**
+     * Gets the behavior for handling skipped wall time at positive time zone offset
+     * transitions.
+     * 
+     * @return the behavior for handling skipped wall time, one of
+     * <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code>
+     * and <code>UCAL_WALLTIME_NEXT_VALID</code>.
+     * @see #setSkippedWallTimeOption
+     * @stable ICU 49
+     */
+    UCalendarWallTimeOption getSkippedWallTimeOption(void) const;
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
+     *
+     * @param value  The given first day of the week.
+     * @deprecated ICU 2.6. Use setFirstDayOfWeek(UCalendarDaysOfWeek value) instead.
+     */
+    void setFirstDayOfWeek(EDaysOfWeek value);
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
+     *
+     * @param value  The given first day of the week.
+     * @stable ICU 2.6.
+     */
+    void setFirstDayOfWeek(UCalendarDaysOfWeek value);
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
+     *
+     * @return   The first day of the week.
+     * @deprecated ICU 2.6 use the overload with error code
+     */
+    EDaysOfWeek getFirstDayOfWeek(void) const;
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
+     *
+     * @param status error code
+     * @return   The first day of the week.
+     * @stable ICU 2.6
+     */
+    UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const;
+
+    /**
+     * Sets what the minimal days required in the first week of the year are; For
+     * example, if the first week is defined as one that contains the first day of the
+     * first month of a year, call the method with value 1. If it must be a full week,
+     * use value 7.
+     *
+     * @param value  The given minimal days required in the first week of the year.
+     * @stable ICU 2.0
+     */
+    void setMinimalDaysInFirstWeek(uint8_t value);
+
+    /**
+     * Gets what the minimal days required in the first week of the year are; e.g., if
+     * the first week is defined as one that contains the first day of the first month
+     * of a year, getMinimalDaysInFirstWeek returns 1. If the minimal days required must
+     * be a full week, getMinimalDaysInFirstWeek returns 7.
+     *
+     * @return   The minimal days required in the first week of the year.
+     * @stable ICU 2.0
+     */
+    uint8_t getMinimalDaysInFirstWeek(void) const;
+
+    /**
+     * Gets the minimum value for the given time field. e.g., for Gregorian
+     * DAY_OF_MONTH, 1.
+     *
+     * @param field  The given time field.
+     * @return       The minimum value for the given time field.
+     * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.
+     */
+    virtual int32_t getMinimum(EDateFields field) const;
+
+    /**
+     * Gets the minimum value for the given time field. e.g., for Gregorian
+     * DAY_OF_MONTH, 1.
+     *
+     * @param field  The given time field.
+     * @return       The minimum value for the given time field.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getMinimum(UCalendarDateFields field) const;
+
+    /**
+     * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
+     * 31.
+     *
+     * @param field  The given time field.
+     * @return       The maximum value for the given time field.
+     * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.
+     */
+    virtual int32_t getMaximum(EDateFields field) const;
+
+    /**
+     * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
+     * 31.
+     *
+     * @param field  The given time field.
+     * @return       The maximum value for the given time field.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getMaximum(UCalendarDateFields field) const;
+
+    /**
+     * Gets the highest minimum value for the given field if varies. Otherwise same as
+     * getMinimum(). For Gregorian, no difference.
+     *
+     * @param field  The given time field.
+     * @return       The highest minimum value for the given time field.
+     * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.
+     */
+    virtual int32_t getGreatestMinimum(EDateFields field) const;
+
+    /**
+     * Gets the highest minimum value for the given field if varies. Otherwise same as
+     * getMinimum(). For Gregorian, no difference.
+     *
+     * @param field  The given time field.
+     * @return       The highest minimum value for the given time field.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
+
+    /**
+     * Gets the lowest maximum value for the given field if varies. Otherwise same as
+     * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
+     *
+     * @param field  The given time field.
+     * @return       The lowest maximum value for the given time field.
+     * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.
+     */
+    virtual int32_t getLeastMaximum(EDateFields field) const;
+
+    /**
+     * Gets the lowest maximum value for the given field if varies. Otherwise same as
+     * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
+     *
+     * @param field  The given time field.
+     * @return       The lowest maximum value for the given time field.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getLeastMaximum(UCalendarDateFields field) const;
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Return the minimum value that this field could have, given the current date.
+     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
+     *
+     * The version of this function on Calendar uses an iterative algorithm to determine the
+     * actual minimum value for the field.  There is almost always a more efficient way to
+     * accomplish this (in most cases, you can simply return getMinimum()).  GregorianCalendar
+     * overrides this function with a more efficient implementation.
+     *
+     * @param field    the field to determine the minimum of
+     * @param status   Fill-in parameter which receives the status of this operation.
+     * @return         the minimum of the given field for the current date of this Calendar
+     * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field, UErrorCode& status) instead.
+     */
+    int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Return the minimum value that this field could have, given the current date.
+     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
+     *
+     * The version of this function on Calendar uses an iterative algorithm to determine the
+     * actual minimum value for the field.  There is almost always a more efficient way to
+     * accomplish this (in most cases, you can simply return getMinimum()).  GregorianCalendar
+     * overrides this function with a more efficient implementation.
+     *
+     * @param field    the field to determine the minimum of
+     * @param status   Fill-in parameter which receives the status of this operation.
+     * @return         the minimum of the given field for the current date of this Calendar
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode& status) const;
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Return the maximum value that this field could have, given the current date.
+     * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
+     * maximum would be 28; for "Feb 3, 1996" it s 29.  Similarly for a Hebrew calendar,
+     * for some years the actual maximum for MONTH is 12, and for others 13.
+     *
+     * The version of this function on Calendar uses an iterative algorithm to determine the
+     * actual maximum value for the field.  There is almost always a more efficient way to
+     * accomplish this (in most cases, you can simply return getMaximum()).  GregorianCalendar
+     * overrides this function with a more efficient implementation.
+     *
+     * @param field    the field to determine the maximum of
+     * @param status   Fill-in parameter which receives the status of this operation.
+     * @return         the maximum of the given field for the current date of this Calendar
+     * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field, UErrorCode& status) instead.
+     */
+    int32_t getActualMaximum(EDateFields field, UErrorCode& status) const;
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Return the maximum value that this field could have, given the current date.
+     * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
+     * maximum would be 28; for "Feb 3, 1996" it s 29.  Similarly for a Hebrew calendar,
+     * for some years the actual maximum for MONTH is 12, and for others 13.
+     *
+     * The version of this function on Calendar uses an iterative algorithm to determine the
+     * actual maximum value for the field.  There is almost always a more efficient way to
+     * accomplish this (in most cases, you can simply return getMaximum()).  GregorianCalendar
+     * overrides this function with a more efficient implementation.
+     *
+     * @param field    the field to determine the maximum of
+     * @param status   Fill-in parameter which receives the status of this operation.
+     * @return         the maximum of the given field for the current date of this Calendar
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Gets the value for a given time field. Recalculate the current time field values
+     * if the time value has been changed by a call to setTime(). Return zero for unset
+     * fields if any fields have been explicitly set by a call to set(). To force a
+     * recomputation of all fields regardless of the previous state, call complete().
+     * This method is semantically const, but may alter the object in memory.
+     *
+     * @param field  The given time field.
+     * @param status Fill-in parameter which receives the status of the operation.
+     * @return       The value for the given time field, or zero if the field is unset,
+     *               and set() has been called for any other field.
+     * @deprecated ICU 2.6. Use get(UCalendarDateFields field, UErrorCode& status) instead.
+     */
+    int32_t get(EDateFields field, UErrorCode& status) const;
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Gets the value for a given time field. Recalculate the current time field values
+     * if the time value has been changed by a call to setTime(). Return zero for unset
+     * fields if any fields have been explicitly set by a call to set(). To force a
+     * recomputation of all fields regardless of the previous state, call complete().
+     * This method is semantically const, but may alter the object in memory.
+     *
+     * @param field  The given time field.
+     * @param status Fill-in parameter which receives the status of the operation.
+     * @return       The value for the given time field, or zero if the field is unset,
+     *               and set() has been called for any other field.
+     * @stable ICU 2.6.
+     */
+    int32_t get(UCalendarDateFields field, UErrorCode& status) const;
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Determines if the given time field has a value set. This can affect in the
+     * resolving of time in Calendar. Unset fields have a value of zero, by definition.
+     *
+     * @param field  The given time field.
+     * @return   True if the given time field has a value set; false otherwise.
+     * @deprecated ICU 2.6. Use isSet(UCalendarDateFields field) instead.
+     */
+    UBool isSet(EDateFields field) const;
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Determines if the given time field has a value set. This can affect in the
+     * resolving of time in Calendar. Unset fields have a value of zero, by definition.
+     *
+     * @param field  The given time field.
+     * @return   True if the given time field has a value set; false otherwise.
+     * @stable ICU 2.6.
+     */
+    UBool isSet(UCalendarDateFields field) const;
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Sets the given time field with the given value.
+     *
+     * @param field  The given time field.
+     * @param value  The value to be set for the given time field.
+     * @deprecated ICU 2.6. Use set(UCalendarDateFields field, int32_t value) instead.
+     */
+    void set(EDateFields field, int32_t value);
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Sets the given time field with the given value.
+     *
+     * @param field  The given time field.
+     * @param value  The value to be set for the given time field.
+     * @stable ICU 2.6.
+     */
+    void set(UCalendarDateFields field, int32_t value);
+
+    /**
+     * Sets the values for the fields YEAR, MONTH, and DATE. Other field values are
+     * retained; call clear() first if this is not desired.
+     *
+     * @param year   The value used to set the YEAR time field.
+     * @param month  The value used to set the MONTH time field. Month value is 0-based.
+     *               e.g., 0 for January.
+     * @param date   The value used to set the DATE time field.
+     * @stable ICU 2.0
+     */
+    void set(int32_t year, int32_t month, int32_t date);
+
+    /**
+     * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE. Other
+     * field values are retained; call clear() first if this is not desired.
+     *
+     * @param year    The value used to set the YEAR time field.
+     * @param month   The value used to set the MONTH time field. Month value is
+     *                0-based. E.g., 0 for January.
+     * @param date    The value used to set the DATE time field.
+     * @param hour    The value used to set the HOUR_OF_DAY time field.
+     * @param minute  The value used to set the MINUTE time field.
+     * @stable ICU 2.0
+     */
+    void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute);
+
+    /**
+     * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and SECOND.
+     * Other field values are retained; call clear() first if this is not desired.
+     *
+     * @param year    The value used to set the YEAR time field.
+     * @param month   The value used to set the MONTH time field. Month value is
+     *                0-based. E.g., 0 for January.
+     * @param date    The value used to set the DATE time field.
+     * @param hour    The value used to set the HOUR_OF_DAY time field.
+     * @param minute  The value used to set the MINUTE time field.
+     * @param second  The value used to set the SECOND time field.
+     * @stable ICU 2.0
+     */
+    void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second);
+
+    /**
+     * Clears the values of all the time fields, making them both unset and assigning
+     * them a value of zero. The field values will be determined during the next
+     * resolving of time into time fields.
+     * @stable ICU 2.0
+     */
+    void clear(void);
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Clears the value in the given time field, both making it unset and assigning it a
+     * value of zero. This field value will be determined during the next resolving of
+     * time into time fields.
+     *
+     * @param field  The time field to be cleared.
+     * @deprecated ICU 2.6. Use clear(UCalendarDateFields field) instead.
+     */
+    void clear(EDateFields field);
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Clears the value in the given time field, both making it unset and assigning it a
+     * value of zero. This field value will be determined during the next resolving of
+     * time into time fields.
+     *
+     * @param field  The time field to be cleared.
+     * @stable ICU 2.6.
+     */
+    void clear(UCalendarDateFields field);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual method. This method is to
+     * implement a simple version of RTTI, since not all C++ compilers support genuine
+     * RTTI. Polymorphic operator==() and clone() methods call this method.
+     * <P>
+     * Concrete subclasses of Calendar must implement getDynamicClassID() and also a
+     * static method and data member:
+     *
+     *      static UClassID getStaticClassID() { return (UClassID)&amp;fgClassID; }
+     *      static char fgClassID;
+     *
+     * @return   The class ID for this object. All objects of a given class have the
+     *           same class ID. Objects of other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+    /**
+     * Returns the calendar type name string for this Calendar object.
+     * The returned string is the legacy ICU calendar attribute value,
+     * for example, "gregorian" or "japanese".
+     *
+     * See type="old type name" for the calendar attribute of locale IDs
+     * at http://www.unicode.org/reports/tr35/#Key_Type_Definitions
+     *
+     * Sample code for getting the LDML/BCP 47 calendar key value:
+     * \code
+     * const char *calType = cal->getType();
+     * if (0 == strcmp(calType, "unknown")) {
+     *     // deal with unknown calendar type
+     * } else {
+     *     string localeID("root@calendar=");
+     *     localeID.append(calType);
+     *     char langTag[100];
+     *     UErrorCode errorCode = U_ZERO_ERROR;
+     *     int32_t length = uloc_toLanguageTag(localeID.c_str(), langTag, (int32_t)sizeof(langTag), TRUE, &errorCode);
+     *     if (U_FAILURE(errorCode)) {
+     *         // deal with errors & overflow
+     *     }
+     *     string lang(langTag, length);
+     *     size_t caPos = lang.find("-ca-");
+     *     lang.erase(0, caPos + 4);
+     *     // lang now contains the LDML calendar type
+     * }
+     * \endcode
+     *
+     * @return legacy calendar type name string
+     * @stable ICU 49
+     */
+    virtual const char * getType() const = 0;
+
+    /**
+     * Returns whether the given day of the week is a weekday, a weekend day,
+     * or a day that transitions from one to the other, for the locale and
+     * calendar system associated with this Calendar (the locale's region is
+     * often the most determinant factor). If a transition occurs at midnight,
+     * then the days before and after the transition will have the
+     * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time
+     * other than midnight, then the day of the transition will have
+     * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the
+     * method getWeekendTransition() will return the point of
+     * transition.
+     * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).
+     * @param status The error code for the operation.
+     * @return The UCalendarWeekdayType for the day of the week.
+     * @stable ICU 4.4
+     */
+    virtual UCalendarWeekdayType getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
+
+    /**
+     * Returns the time during the day at which the weekend begins or ends in
+     * this calendar system.  If getDayOfWeekType() returns UCAL_WEEKEND_ONSET
+     * for the specified dayOfWeek, return the time at which the weekend begins.
+     * If getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,
+     * return the time at which the weekend ends. If getDayOfWeekType() returns
+     * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition
+     * (U_ILLEGAL_ARGUMENT_ERROR).
+     * @param dayOfWeek The day of the week for which the weekend transition time is
+     * desired (UCAL_SUNDAY..UCAL_SATURDAY).
+     * @param status The error code for the operation.
+     * @return The milliseconds after midnight at which the weekend begins or ends.
+     * @stable ICU 4.4
+     */
+    virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
+
+    /**
+     * Returns TRUE if the given UDate is in the weekend in
+     * this calendar system.
+     * @param date The UDate in question.
+     * @param status The error code for the operation.
+     * @return TRUE if the given UDate is in the weekend in
+     * this calendar system, FALSE otherwise.
+     * @stable ICU 4.4
+     */
+    virtual UBool isWeekend(UDate date, UErrorCode &status) const;
+
+    /**
+     * Returns TRUE if this Calendar's current date-time is in the weekend in
+     * this calendar system.
+     * @return TRUE if this Calendar's current date-time is in the weekend in
+     * this calendar system, FALSE otherwise.
+     * @stable ICU 4.4
+     */
+    virtual UBool isWeekend(void) const;
+
+protected:
+
+     /**
+      * Constructs a Calendar with the default time zone as returned by
+      * TimeZone::createInstance(), and the default locale.
+      *
+      * @param success  Indicates the status of Calendar object construction. Returns
+      *                 U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+      */
+    Calendar(UErrorCode& success);
+
+    /**
+     * Copy constructor
+     *
+     * @param source    Calendar object to be copied from
+     * @stable ICU 2.0
+     */
+    Calendar(const Calendar& source);
+
+    /**
+     * Default assignment operator
+     *
+     * @param right    Calendar object to be copied
+     * @stable ICU 2.0
+     */
+    Calendar& operator=(const Calendar& right);
+
+    /**
+     * Constructs a Calendar with the given time zone and locale. Clients are no longer
+     * responsible for deleting the given time zone object after it's adopted.
+     *
+     * @param zone     The given time zone.
+     * @param aLocale  The given locale.
+     * @param success  Indicates the status of Calendar object construction. Returns
+     *                 U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Constructs a Calendar with the given time zone and locale.
+     *
+     * @param zone     The given time zone.
+     * @param aLocale  The given locale.
+     * @param success  Indicates the status of Calendar object construction. Returns
+     *                 U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Converts Calendar's time field values to GMT as milliseconds.
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    virtual void computeTime(UErrorCode& status);
+
+    /**
+     * Converts GMT as milliseconds to time field values. This allows you to sync up the
+     * time field values with a new time that is set for the calendar.  This method
+     * does NOT recompute the time first; to recompute the time, then the fields, use
+     * the method complete().
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    virtual void computeFields(UErrorCode& status);
+
+    /**
+     * Gets this Calendar's current time as a long.
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return the current time as UTC milliseconds from the epoch.
+     * @stable ICU 2.0
+     */
+    double getTimeInMillis(UErrorCode& status) const;
+
+    /**
+     * Sets this Calendar's current time from the given long value.
+     * @param millis  the new time in UTC milliseconds from the epoch.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    void setTimeInMillis( double millis, UErrorCode& status );
+
+    /**
+     * Recomputes the current time from currently set fields, and then fills in any
+     * unset fields in the time field list.
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    void complete(UErrorCode& status);
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Gets the value for a given time field. Subclasses can use this function to get
+     * field values without forcing recomputation of time.
+     *
+     * @param field  The given time field.
+     * @return       The value for the given time field.
+     * @deprecated ICU 2.6. Use internalGet(UCalendarDateFields field) instead.
+     */
+    inline int32_t internalGet(EDateFields field) const {return fFields[field];}
+#endif  /* U_HIDE_DEPRECATED_API */
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Gets the value for a given time field. Subclasses can use this function to get
+     * field values without forcing recomputation of time. If the field's stamp is UNSET,
+     * the defaultValue is used.
+     *
+     * @param field  The given time field.
+     * @param defaultValue a default value used if the field is unset.
+     * @return       The value for the given time field.
+     * @internal
+     */
+    inline int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const {return fStamp[field]>kUnset ? fFields[field] : defaultValue;}
+
+    /**
+     * Gets the value for a given time field. Subclasses can use this function to get
+     * field values without forcing recomputation of time.
+     *
+     * @param field  The given time field.
+     * @return       The value for the given time field.
+     * @internal
+     */
+    inline int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}
+#endif  /* U_HIDE_INTERNAL_API */
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Sets the value for a given time field.  This is a fast internal method for
+     * subclasses.  It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
+     * flags.
+     *
+     * @param field    The given time field.
+     * @param value    The value for the given time field.
+     * @deprecated ICU 2.6. Use internalSet(UCalendarDateFields field, int32_t value) instead.
+     */
+    void internalSet(EDateFields field, int32_t value);
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Sets the value for a given time field.  This is a fast internal method for
+     * subclasses.  It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
+     * flags.
+     *
+     * @param field    The given time field.
+     * @param value    The value for the given time field.
+     * @stable ICU 2.6.
+     */
+    inline void internalSet(UCalendarDateFields field, int32_t value);
+
+    /**
+     * Prepare this calendar for computing the actual minimum or maximum.
+     * This method modifies this calendar's fields; it is called on a
+     * temporary calendar.
+     * @internal
+     */
+    virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);
+
+    /**
+     * Limit enums. Not in sync with UCalendarLimitType (refers to internal fields).
+     * @internal
+     */
+    enum ELimitType {
+#ifndef U_HIDE_INTERNAL_API
+      UCAL_LIMIT_MINIMUM = 0,
+      UCAL_LIMIT_GREATEST_MINIMUM,
+      UCAL_LIMIT_LEAST_MAXIMUM,
+      UCAL_LIMIT_MAXIMUM,
+      UCAL_LIMIT_COUNT
+#endif  /* U_HIDE_INTERNAL_API */
+    };
+
+    /**
+     * Subclass API for defining limits of different types.
+     * Subclasses must implement this method to return limits for the
+     * following fields:
+     *
+     * <pre>UCAL_ERA
+     * UCAL_YEAR
+     * UCAL_MONTH
+     * UCAL_WEEK_OF_YEAR
+     * UCAL_WEEK_OF_MONTH
+     * UCAL_DATE (DAY_OF_MONTH on Java)
+     * UCAL_DAY_OF_YEAR
+     * UCAL_DAY_OF_WEEK_IN_MONTH
+     * UCAL_YEAR_WOY
+     * UCAL_EXTENDED_YEAR</pre>
+     *
+     * @param field one of the above field numbers
+     * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
+     * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
+     * @internal
+     */
+    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const = 0;
+
+    /**
+     * Return a limit for a field.
+     * @param field the field, from <code>0..UCAL_MAX_FIELD</code>
+     * @param limitType the type specifier for the limit
+     * @see #ELimitType
+     * @internal
+     */
+    virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const;
+
+
+    /**
+     * Return the Julian day number of day before the first day of the
+     * given month in the given extended year.  Subclasses should override
+     * this method to implement their calendar system.
+     * @param eyear the extended year
+     * @param month the zero-based month, or 0 if useMonth is false
+     * @param useMonth if false, compute the day before the first day of
+     * the given year, otherwise, compute the day before the first day of
+     * the given month
+     * @return the Julian day number of the day before the first
+     * day of the given month and year
+     * @internal
+     */
+    virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
+                                                   UBool useMonth) const  = 0;
+
+    /**
+     * Return the number of days in the given month of the given extended
+     * year of this calendar system.  Subclasses should override this
+     * method if they can provide a more correct or more efficient
+     * implementation than the default implementation in Calendar.
+     * @internal
+     */
+    virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const ;
+
+    /**
+     * Return the number of days in the given extended year of this
+     * calendar system.  Subclasses should override this method if they can
+     * provide a more correct or more efficient implementation than the
+     * default implementation in Calendar.
+     * @stable ICU 2.0
+     */
+    virtual int32_t handleGetYearLength(int32_t eyear) const;
+
+
+    /**
+     * Return the extended year defined by the current fields.  This will
+     * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
+     * as UCAL_ERA) specific to the calendar system, depending on which set of
+     * fields is newer.
+     * @return the extended year
+     * @internal
+     */
+    virtual int32_t handleGetExtendedYear() = 0;
+
+    /**
+     * Subclasses may override this.  This method calls
+     * handleGetMonthLength() to obtain the calendar-specific month
+     * length.
+     * @param bestField which field to use to calculate the date
+     * @return julian day specified by calendar fields.
+     * @internal
+     */
+    virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField);
+
+    /**
+     * Subclasses must override this to convert from week fields
+     * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case
+     * where YEAR, EXTENDED_YEAR are not set.
+     * The Calendar implementation assumes yearWoy is in extended gregorian form
+     * @return the extended year, UCAL_EXTENDED_YEAR
+     * @internal
+     */
+    virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
+
+    /**
+     * Validate a single field of this calendar.  Subclasses should
+     * override this method to validate any calendar-specific fields.
+     * Generic fields can be handled by
+     * <code>Calendar::validateField()</code>.
+     * @see #validateField(int, int, int, int&)
+     * @internal
+     */
+    virtual void validateField(UCalendarDateFields field, UErrorCode &status);
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Compute the Julian day from fields.  Will determine whether to use
+     * the JULIAN_DAY field directly, or other fields.
+     * @return the julian day
+     * @internal
+     */
+    int32_t computeJulianDay();
+
+    /**
+     * Compute the milliseconds in the day from the fields.  This is a
+     * value from 0 to 23:59:59.999 inclusive, unless fields are out of
+     * range, in which case it can be an arbitrary value.  This value
+     * reflects local zone wall time.
+     * @internal
+     */
+    int32_t computeMillisInDay();
+
+    /**
+     * This method can assume EXTENDED_YEAR has been set.
+     * @param millis milliseconds of the date fields
+     * @param millisInDay milliseconds of the time fields; may be out
+     * or range.
+     * @param ec Output param set to failure code on function return
+     *          when this function fails.
+     * @internal
+     */
+    int32_t computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec);
+
+
+    /**
+     * Determine the best stamp in a range.
+     * @param start first enum to look at
+     * @param end last enum to look at
+     * @param bestSoFar stamp prior to function call
+     * @return the stamp value of the best stamp
+     * @internal
+     */
+    int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;
+
+    /**
+     * Values for field resolution tables
+     * @see #resolveFields
+     * @internal
+     */
+    enum {
+      /** Marker for end of resolve set (row or group). */
+      kResolveSTOP = -1,
+      /** Value to be bitwised "ORed" against resolve table field values for remapping.  Example: (UCAL_DATE | kResolveRemap) in 1st column will cause 'UCAL_DATE' to be returned, but will not examine the value of UCAL_DATE.  */
+      kResolveRemap = 32
+    };
+
+    /**
+     * Precedence table for Dates
+     * @see #resolveFields
+     * @internal
+     */
+    static const UFieldResolutionTable kDatePrecedence[];
+
+    /**
+     * Precedence table for Year
+     * @see #resolveFields
+     * @internal
+     */
+    static const UFieldResolutionTable kYearPrecedence[];
+
+    /**
+     * Precedence table for Day of Week
+     * @see #resolveFields
+     * @internal
+     */
+    static const UFieldResolutionTable kDOWPrecedence[];
+
+    /**
+     * Given a precedence table, return the newest field combination in
+     * the table, or UCAL_FIELD_COUNT if none is found.
+     *
+     * <p>The precedence table is a 3-dimensional array of integers.  It
+     * may be thought of as an array of groups.  Each group is an array of
+     * lines.  Each line is an array of field numbers.  Within a line, if
+     * all fields are set, then the time stamp of the line is taken to be
+     * the stamp of the most recently set field.  If any field of a line is
+     * unset, then the line fails to match.  Within a group, the line with
+     * the newest time stamp is selected.  The first field of the line is
+     * returned to indicate which line matched.
+     *
+     * <p>In some cases, it may be desirable to map a line to field that
+     * whose stamp is NOT examined.  For example, if the best field is
+     * DAY_OF_WEEK then the DAY_OF_WEEK_IN_MONTH algorithm may be used.  In
+     * order to do this, insert the value <code>kResolveRemap | F</code> at
+     * the start of the line, where <code>F</code> is the desired return
+     * field value.  This field will NOT be examined; it only determines
+     * the return value if the other fields in the line are the newest.
+     *
+     * <p>If all lines of a group contain at least one unset field, then no
+     * line will match, and the group as a whole will fail to match.  In
+     * that case, the next group will be processed.  If all groups fail to
+     * match, then UCAL_FIELD_COUNT is returned.
+     * @internal
+     */
+    UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable);
+#endif  /* U_HIDE_INTERNAL_API */
+
+
+    /**
+     * @internal
+     */
+    virtual const UFieldResolutionTable* getFieldResolutionTable() const;
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Return the field that is newer, either defaultField, or
+     * alternateField.  If neither is newer or neither is set, return defaultField.
+     * @internal
+     */
+    UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const;
+#endif  /* U_HIDE_INTERNAL_API */
+
+
+private:
+    /**
+     * Helper function for calculating limits by trial and error
+     * @param field The field being investigated
+     * @param startValue starting (least max) value of field
+     * @param endValue ending (greatest max) value of field
+     * @param status return type
+     * @internal
+     */
+    int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;
+
+
+protected:
+    /**
+     * The flag which indicates if the current time is set in the calendar.
+     * @stable ICU 2.0
+     */
+    UBool      fIsTimeSet;
+
+    /**
+     * True if the fields are in sync with the currently set time of this Calendar.
+     * If false, then the next attempt to get the value of a field will
+     * force a recomputation of all fields from the current value of the time
+     * field.
+     * <P>
+     * This should really be named areFieldsInSync, but the old name is retained
+     * for backward compatibility.
+     * @stable ICU 2.0
+     */
+    UBool      fAreFieldsSet;
+
+    /**
+     * True if all of the fields have been set.  This is initially false, and set to
+     * true by computeFields().
+     * @stable ICU 2.0
+     */
+    UBool      fAreAllFieldsSet;
+
+    /**
+     * True if all fields have been virtually set, but have not yet been
+     * computed.  This occurs only in setTimeInMillis().  A calendar set
+     * to this state will compute all fields from the time if it becomes
+     * necessary, but otherwise will delay such computation.
+     * @stable ICU 3.0
+     */
+    UBool fAreFieldsVirtuallySet;
+
+    /**
+     * Get the current time without recomputing.
+     *
+     * @return     the current time without recomputing.
+     * @stable ICU 2.0
+     */
+    UDate        internalGetTime(void) const     { return fTime; }
+
+    /**
+     * Set the current time without affecting flags or fields.
+     *
+     * @param time    The time to be set
+     * @return        the current time without recomputing.
+     * @stable ICU 2.0
+     */
+    void        internalSetTime(UDate time)     { fTime = time; }
+
+    /**
+     * The time fields containing values into which the millis is computed.
+     * @stable ICU 2.0
+     */
+    int32_t     fFields[UCAL_FIELD_COUNT];
+
+    /**
+     * The flags which tell if a specified time field for the calendar is set.
+     * @deprecated ICU 2.8 use (fStamp[n]!=kUnset)
+     */
+    UBool      fIsSet[UCAL_FIELD_COUNT];
+
+    /** Special values of stamp[]
+     * @stable ICU 2.0
+     */
+    enum {
+        kUnset                 = 0,
+        kInternallySet,
+        kMinimumUserStamp
+    };
+
+    /**
+     * Pseudo-time-stamps which specify when each field was set. There
+     * are two special values, UNSET and INTERNALLY_SET. Values from
+     * MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values.
+     * @stable ICU 2.0
+     */
+    int32_t        fStamp[UCAL_FIELD_COUNT];
+
+    /**
+     * Subclasses may override this method to compute several fields
+     * specific to each calendar system.  These are:
+     *
+     * <ul><li>ERA
+     * <li>YEAR
+     * <li>MONTH
+     * <li>DAY_OF_MONTH
+     * <li>DAY_OF_YEAR
+     * <li>EXTENDED_YEAR</ul>
+     *
+     * Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, which
+     * will be set when this method is called.  Subclasses can also call
+     * the getGregorianXxx() methods to obtain Gregorian calendar
+     * equivalents for the given Julian day.
+     *
+     * <p>In addition, subclasses should compute any subclass-specific
+     * fields, that is, fields from BASE_FIELD_COUNT to
+     * getFieldCount() - 1.
+     *
+     * <p>The default implementation in <code>Calendar</code> implements
+     * a pure proleptic Gregorian calendar.
+     * @internal
+     */
+    virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Return the extended year on the Gregorian calendar as computed by
+     * <code>computeGregorianFields()</code>.
+     * @internal
+     */
+    int32_t getGregorianYear() const {
+        return fGregorianYear;
+    }
+
+    /**
+     * Return the month (0-based) on the Gregorian calendar as computed by
+     * <code>computeGregorianFields()</code>.
+     * @internal
+     */
+    int32_t getGregorianMonth() const {
+        return fGregorianMonth;
+    }
+
+    /**
+     * Return the day of year (1-based) on the Gregorian calendar as
+     * computed by <code>computeGregorianFields()</code>.
+     * @internal
+     */
+    int32_t getGregorianDayOfYear() const {
+        return fGregorianDayOfYear;
+    }
+
+    /**
+     * Return the day of month (1-based) on the Gregorian calendar as
+     * computed by <code>computeGregorianFields()</code>.
+     * @internal
+     */
+    int32_t getGregorianDayOfMonth() const {
+      return fGregorianDayOfMonth;
+    }
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Called by computeJulianDay.  Returns the default month (0-based) for the year,
+     * taking year and era into account.  Defaults to 0 for Gregorian, which doesn't care.
+     * @param eyear The extended year
+     * @internal
+     */
+    virtual int32_t getDefaultMonthInYear(int32_t eyear) ;
+
+
+    /**
+     * Called by computeJulianDay.  Returns the default day (1-based) for the month,
+     * taking currently-set year and era into account.  Defaults to 1 for Gregorian.
+     * @param eyear the extended year
+     * @param month the month in the year
+     * @internal
+     */
+    virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month);
+
+    //-------------------------------------------------------------------------
+    // Protected utility methods for use by subclasses.  These are very handy
+    // for implementing add, roll, and computeFields.
+    //-------------------------------------------------------------------------
+
+    /**
+     * Adjust the specified field so that it is within
+     * the allowable range for the date to which this calendar is set.
+     * For example, in a Gregorian calendar pinning the {@link #UCalendarDateFields DAY_OF_MONTH}
+     * field for a calendar set to April 31 would cause it to be set
+     * to April 30.
+     * <p>
+     * <b>Subclassing:</b>
+     * <br>
+     * This utility method is intended for use by subclasses that need to implement
+     * their own overrides of {@link #roll roll} and {@link #add add}.
+     * <p>
+     * <b>Note:</b>
+     * <code>pinField</code> is implemented in terms of
+     * {@link #getActualMinimum getActualMinimum}
+     * and {@link #getActualMaximum getActualMaximum}.  If either of those methods uses
+     * a slow, iterative algorithm for a particular field, it would be
+     * unwise to attempt to call <code>pinField</code> for that field.  If you
+     * really do need to do so, you should override this method to do
+     * something more efficient for that field.
+     * <p>
+     * @param field The calendar field whose value should be pinned.
+     * @param status Output param set to failure code on function return
+     *          when this function fails.
+     *
+     * @see #getActualMinimum
+     * @see #getActualMaximum
+     * @stable ICU 2.0
+     */
+    virtual void pinField(UCalendarDateFields field, UErrorCode& status);
+
+    /**
+     * Return the week number of a day, within a period. This may be the week number in
+     * a year or the week number in a month. Usually this will be a value >= 1, but if
+     * some initial days of the period are excluded from week 1, because
+     * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1, then
+     * the week number will be zero for those
+     * initial days. This method requires the day number and day of week for some
+     * known date in the period in order to determine the day of week
+     * on the desired day.
+     * <p>
+     * <b>Subclassing:</b>
+     * <br>
+     * This method is intended for use by subclasses in implementing their
+     * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.
+     * It is often useful in {@link #getActualMinimum getActualMinimum} and
+     * {@link #getActualMaximum getActualMaximum} as well.
+     * <p>
+     * This variant is handy for computing the week number of some other
+     * day of a period (often the first or last day of the period) when its day
+     * of the week is not known but the day number and day of week for some other
+     * day in the period (e.g. the current date) <em>is</em> known.
+     * <p>
+     * @param desiredDay    The {@link #UCalendarDateFields DAY_OF_YEAR} or
+     *              {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.
+     *              Should be 1 for the first day of the period.
+     *
+     * @param dayOfPeriod   The {@link #UCalendarDateFields DAY_OF_YEAR}
+     *              or {@link #UCalendarDateFields DAY_OF_MONTH} for a day in the period whose
+     *              {@link #UCalendarDateFields DAY_OF_WEEK} is specified by the
+     *              <code>knownDayOfWeek</code> parameter.
+     *              Should be 1 for first day of period.
+     *
+     * @param dayOfWeek  The {@link #UCalendarDateFields DAY_OF_WEEK} for the day
+     *              corresponding to the <code>knownDayOfPeriod</code> parameter.
+     *              1-based with 1=Sunday.
+     *
+     * @return      The week number (one-based), or zero if the day falls before
+     *              the first week because
+     *              {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
+     *              is more than one.
+     *
+     * @stable ICU 2.8
+     */
+    int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek);
+
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Return the week number of a day, within a period. This may be the week number in
+     * a year, or the week number in a month. Usually this will be a value >= 1, but if
+     * some initial days of the period are excluded from week 1, because
+     * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1,
+     * then the week number will be zero for those
+     * initial days. This method requires the day of week for the given date in order to
+     * determine the result.
+     * <p>
+     * <b>Subclassing:</b>
+     * <br>
+     * This method is intended for use by subclasses in implementing their
+     * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.
+     * It is often useful in {@link #getActualMinimum getActualMinimum} and
+     * {@link #getActualMaximum getActualMaximum} as well.
+     * <p>
+     * @param dayOfPeriod   The {@link #UCalendarDateFields DAY_OF_YEAR} or
+     *                      {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.
+     *                      Should be 1 for the first day of the period.
+     *
+     * @param dayOfWeek     The {@link #UCalendarDateFields DAY_OF_WEEK} for the day
+     *                      corresponding to the <code>dayOfPeriod</code> parameter.
+     *                      1-based with 1=Sunday.
+     *
+     * @return      The week number (one-based), or zero if the day falls before
+     *              the first week because
+     *              {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
+     *              is more than one.
+     * @internal
+     */
+    inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);
+
+    /**
+     * returns the local DOW, valid range 0..6
+     * @internal
+     */
+    int32_t getLocalDOW();
+#endif  /* U_HIDE_INTERNAL_API */
+
+private:
+
+    /**
+     * The next available value for fStamp[]
+     */
+    int32_t fNextStamp;// = MINIMUM_USER_STAMP;
+
+    /**
+     * Recalculates the time stamp array (fStamp).
+     * Resets fNextStamp to lowest next stamp value.
+     */
+    void recalculateStamp();
+
+    /**
+     * The current time set for the calendar.
+     */
+    UDate        fTime;
+
+    /**
+     * @see   #setLenient
+     */
+    UBool      fLenient;
+
+    /**
+     * Time zone affects the time calculation done by Calendar. Calendar subclasses use
+     * the time zone data to produce the local time. Always set; never NULL.
+     */
+    TimeZone*   fZone;
+
+    /**
+     * Option for rpeated wall time
+     * @see #setRepeatedWallTimeOption
+     */
+    UCalendarWallTimeOption fRepeatedWallTime;
+
+    /**
+     * Option for skipped wall time
+     * @see #setSkippedWallTimeOption
+     */
+    UCalendarWallTimeOption fSkippedWallTime;
+
+    /**
+     * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. They are
+     * used to figure out the week count for a specific date for a given locale. These
+     * must be set when a Calendar is constructed. For example, in US locale,
+     * firstDayOfWeek is SUNDAY; minimalDaysInFirstWeek is 1. They are used to figure
+     * out the week count for a specific date for a given locale. These must be set when
+     * a Calendar is constructed.
+     */
+    UCalendarDaysOfWeek fFirstDayOfWeek;
+    uint8_t     fMinimalDaysInFirstWeek;
+    UCalendarDaysOfWeek fWeekendOnset;
+    int32_t fWeekendOnsetMillis;
+    UCalendarDaysOfWeek fWeekendCease;
+    int32_t fWeekendCeaseMillis;
+
+    /**
+     * Sets firstDayOfWeek and minimalDaysInFirstWeek. Called at Calendar construction
+     * time.
+     *
+     * @param desiredLocale  The given locale.
+     * @param type           The calendar type identifier, e.g: gregorian, buddhist, etc.
+     * @param success        Indicates the status of setting the week count data from
+     *                       the resource for the given locale. Returns U_ZERO_ERROR if
+     *                       constructed successfully.
+     */
+    void        setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& success);
+
+    /**
+     * Recompute the time and update the status fields isTimeSet
+     * and areFieldsSet.  Callers should check isTimeSet and only
+     * call this method if isTimeSet is false.
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     */
+    void updateTime(UErrorCode& status);
+
+    /**
+     * The Gregorian year, as computed by computeGregorianFields() and
+     * returned by getGregorianYear().
+     * @see #computeGregorianFields
+     */
+    int32_t fGregorianYear;
+
+    /**
+     * The Gregorian month, as computed by computeGregorianFields() and
+     * returned by getGregorianMonth().
+     * @see #computeGregorianFields
+     */
+    int32_t fGregorianMonth;
+
+    /**
+     * The Gregorian day of the year, as computed by
+     * computeGregorianFields() and returned by getGregorianDayOfYear().
+     * @see #computeGregorianFields
+     */
+    int32_t fGregorianDayOfYear;
+
+    /**
+     * The Gregorian day of the month, as computed by
+     * computeGregorianFields() and returned by getGregorianDayOfMonth().
+     * @see #computeGregorianFields
+     */
+    int32_t fGregorianDayOfMonth;
+
+    /* calculations */
+
+    /**
+     * Compute the Gregorian calendar year, month, and day of month from
+     * the given Julian day.  These values are not stored in fields, but in
+     * member variables gregorianXxx.  Also compute the DAY_OF_WEEK and
+     * DOW_LOCAL fields.
+     */
+    void computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec);
+
+protected:
+
+    /**
+     * Compute the Gregorian calendar year, month, and day of month from the
+     * Julian day.  These values are not stored in fields, but in member
+     * variables gregorianXxx.  They are used for time zone computations and by
+     * subclasses that are Gregorian derivatives.  Subclasses may call this
+     * method to perform a Gregorian calendar millis->fields computation.
+     */
+    void computeGregorianFields(int32_t julianDay, UErrorCode &ec);
+
+private:
+
+    /**
+     * Compute the fields WEEK_OF_YEAR, YEAR_WOY, WEEK_OF_MONTH,
+     * DAY_OF_WEEK_IN_MONTH, and DOW_LOCAL from EXTENDED_YEAR, YEAR,
+     * DAY_OF_WEEK, and DAY_OF_YEAR.  The latter fields are computed by the
+     * subclass based on the calendar system.
+     *
+     * <p>The YEAR_WOY field is computed simplistically.  It is equal to YEAR
+     * most of the time, but at the year boundary it may be adjusted to YEAR-1
+     * or YEAR+1 to reflect the overlap of a week into an adjacent year.  In
+     * this case, a simple increment or decrement is performed on YEAR, even
+     * though this may yield an invalid YEAR value.  For instance, if the YEAR
+     * is part of a calendar system with an N-year cycle field CYCLE, then
+     * incrementing the YEAR may involve incrementing CYCLE and setting YEAR
+     * back to 0 or 1.  This is not handled by this code, and in fact cannot be
+     * simply handled without having subclasses define an entire parallel set of
+     * fields for fields larger than or equal to a year.  This additional
+     * complexity is not warranted, since the intention of the YEAR_WOY field is
+     * to support ISO 8601 notation, so it will typically be used with a
+     * proleptic Gregorian calendar, which has no field larger than a year.
+     */
+    void computeWeekFields(UErrorCode &ec);
+
+
+    /**
+     * Ensure that each field is within its valid range by calling {@link
+     * #validateField(int, int&)} on each field that has been set.  This method
+     * should only be called if this calendar is not lenient.
+     * @see #isLenient
+     * @see #validateField(int, int&)
+     * @internal
+     */
+    void validateFields(UErrorCode &status);
+
+    /**
+     * Validate a single field of this calendar given its minimum and
+     * maximum allowed value.  If the field is out of range,
+     * <code>U_ILLEGAL_ARGUMENT_ERROR</code> will be set.  Subclasses may
+     * use this method in their implementation of {@link
+     * #validateField(int, int&)}.
+     * @internal
+     */
+    void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);
+
+ protected:
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Convert a quasi Julian date to the day of the week. The Julian date used here is
+     * not a true Julian date, since it is measured from midnight, not noon. Return
+     * value is one-based.
+     *
+     * @param julian  The given Julian date number.
+     * @return   Day number from 1..7 (SUN..SAT).
+     * @internal
+     */
+    static uint8_t julianDayToDayOfWeek(double julian);
+#endif  /* U_HIDE_INTERNAL_API */
+
+ private:
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+
+ public:
+#if !UCONFIG_NO_SERVICE
+    /**
+     * INTERNAL FOR 2.6 --  Registration.
+     */
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Return a StringEnumeration over the locales available at the time of the call,
+     * including registered locales.
+     * @return a StringEnumeration over the locales available at the time of the call
+     * @internal
+     */
+    static StringEnumeration* getAvailableLocales(void);
+
+    /**
+     * Register a new Calendar factory.  The factory will be adopted.
+     * INTERNAL in 2.6
+     *
+     * Because ICU may choose to cache Calendars internally, this must
+     * be called at application startup, prior to any calls to
+     * Calendar::createInstance to avoid undefined behavior.
+     *
+     * @param toAdopt the factory instance to be adopted
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this factory
+     * @internal
+     */
+    static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode& status);
+
+    /**
+     * Unregister a previously-registered CalendarFactory using the key returned from the
+     * register call.  Key becomes invalid after a successful call and should not be used again.
+     * The CalendarFactory corresponding to the key will be deleted.
+     * INTERNAL in 2.6
+     *
+     * Because ICU may choose to cache Calendars internally, this should
+     * be called during application shutdown, after all calls to
+     * Calendar::createInstance to avoid undefined behavior.
+     *
+     * @param key the registry key returned by a previous call to registerFactory
+     * @param status the in/out status code, no special meanings are assigned
+     * @return TRUE if the factory for the key was successfully unregistered
+     * @internal
+     */
+    static UBool unregister(URegistryKey key, UErrorCode& status);
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Multiple Calendar Implementation
+     * @internal
+     */
+    friend class CalendarFactory;
+
+    /**
+     * Multiple Calendar Implementation
+     * @internal
+     */
+    friend class CalendarService;
+
+    /**
+     * Multiple Calendar Implementation
+     * @internal
+     */
+    friend class DefaultCalendarFactory;
+#endif /* !UCONFIG_NO_SERVICE */
+
+    /**
+     * @return TRUE if this calendar has a default century (i.e. 03 -> 2003)
+     * @internal
+     */
+    virtual UBool haveDefaultCentury() const = 0;
+
+    /**
+     * @return the start of the default century, as a UDate
+     * @internal
+     */
+    virtual UDate defaultCenturyStart() const = 0;
+    /**
+     * @return the beginning year of the default century, as a year
+     * @internal
+     */
+    virtual int32_t defaultCenturyStartYear() const = 0;
+
+    /** Get the locale for this calendar object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual)
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const;
+
+    /**
+     * @return      The related Gregorian year; will be obtained by modifying the value
+     *              obtained by get from UCAL_EXTENDED_YEAR field
+     * @internal
+     */
+    virtual int32_t getRelatedYear(UErrorCode &status) const;
+
+    /**
+     * @param year  The related Gregorian year to set; will be modified as necessary then
+     *              set in UCAL_EXTENDED_YEAR field
+     * @internal
+     */
+    virtual void setRelatedYear(int32_t year);
+
+#ifndef U_HIDE_INTERNAL_API
+    /** Get the locale for this calendar object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual)
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @internal
+     */
+    const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
+#endif  /* U_HIDE_INTERNAL_API */
+
+private:
+    /**
+     * Cast TimeZone used by this object to BasicTimeZone, or NULL if the TimeZone
+     * is not an instance of BasicTimeZone.
+     */
+    BasicTimeZone* getBasicTimeZone() const;
+
+    /**
+     * Find the previous zone transtion near the given time.
+     * @param base The base time, inclusive
+     * @param transitionTime Receives the result time
+     * @param status The error status
+     * @return TRUE if a transition is found.
+     */
+    UBool getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime, UErrorCode& status) const;
+
+public:
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Creates a new Calendar from a Locale for the cache.
+     * This method does not set the time or timezone in returned calendar.
+     * @param locale the locale.
+     * @param status any error returned here.
+     * @return the new Calendar object with no time or timezone set.
+     * @internal For ICU use only.
+     */
+    static Calendar * U_EXPORT2 makeInstance(
+            const Locale &locale, UErrorCode &status);
+
+    /**
+     * Get the calendar type for given locale.
+     * @param locale the locale
+     * @param typeBuffer calendar type returned here
+     * @param typeBufferSize The size of typeBuffer in bytes. If the type
+     *   can't fit in the buffer, this method sets status to
+     *   U_BUFFER_OVERFLOW_ERROR
+     * @param status error, if any, returned here.
+     * @internal For ICU use only.
+     */
+    static void U_EXPORT2 getCalendarTypeFromLocale(
+            const Locale &locale,
+            char *typeBuffer,
+            int32_t typeBufferSize,
+            UErrorCode &status);
+#endif  /* U_HIDE_INTERNAL_API */
+};
+
+// -------------------------------------
+
+inline Calendar*
+Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode)
+{
+    // since the Locale isn't specified, use the default locale
+    return createInstance(zone, Locale::getDefault(), errorCode);
+}
+
+// -------------------------------------
+
+inline void
+Calendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status)
+{
+    roll(field, (int32_t)(up ? +1 : -1), status);
+}
+
+#ifndef U_HIDE_DEPRECATED_API
+inline void
+Calendar::roll(EDateFields field, UBool up, UErrorCode& status)
+{
+    roll((UCalendarDateFields) field, up, status);
+}
+#endif  /* U_HIDE_DEPRECATED_API */
+
+
+// -------------------------------------
+
+/**
+ * Fast method for subclasses.  The caller must maintain fUserSetDSTOffset and
+ * fUserSetZoneOffset, as well as the isSet[] array.
+ */
+
+inline void
+Calendar::internalSet(UCalendarDateFields field, int32_t value)
+{
+    fFields[field] = value;
+    fStamp[field] = kInternallySet;
+    fIsSet[field]     = TRUE; // Remove later
+}
+
+
+#ifndef U_HIDE_INTERNAL_API
+inline int32_t  Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)
+{
+  return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek);
+}
+#endif  /* U_HIDE_INTERNAL_API */
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _CALENDAR

+ 208 - 0
sqlite/unicode/caniter.h

@@ -0,0 +1,208 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 1996-2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ */
+
+#ifndef CANITER_H
+#define CANITER_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_NORMALIZATION
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+
+/**
+ * \file
+ * \brief C++ API: Canonical Iterator
+ */
+ 
+/** Should permutation skip characters with combining class zero
+ *  Should be either TRUE or FALSE. This is a compile time option
+ *  @stable ICU 2.4
+ */
+#ifndef CANITER_SKIP_ZEROES
+#define CANITER_SKIP_ZEROES TRUE
+#endif
+
+U_NAMESPACE_BEGIN
+
+class Hashtable;
+class Normalizer2;
+class Normalizer2Impl;
+
+/**
+ * This class allows one to iterate through all the strings that are canonically equivalent to a given
+ * string. For example, here are some sample results:
+Results for: {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
+1: \\u0041\\u030A\\u0064\\u0307\\u0327
+ = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
+2: \\u0041\\u030A\\u0064\\u0327\\u0307
+ = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
+3: \\u0041\\u030A\\u1E0B\\u0327
+ = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
+4: \\u0041\\u030A\\u1E11\\u0307
+ = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
+5: \\u00C5\\u0064\\u0307\\u0327
+ = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
+6: \\u00C5\\u0064\\u0327\\u0307
+ = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
+7: \\u00C5\\u1E0B\\u0327
+ = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
+8: \\u00C5\\u1E11\\u0307
+ = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
+9: \\u212B\\u0064\\u0307\\u0327
+ = {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
+10: \\u212B\\u0064\\u0327\\u0307
+ = {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
+11: \\u212B\\u1E0B\\u0327
+ = {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
+12: \\u212B\\u1E11\\u0307
+ = {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
+ *<br>Note: the code is intended for use with small strings, and is not suitable for larger ones,
+ * since it has not been optimized for that situation.
+ * Note, CanonicalIterator is not intended to be subclassed.
+ * @author M. Davis
+ * @author C++ port by V. Weinstein
+ * @stable ICU 2.4
+ */
+class U_COMMON_API CanonicalIterator U_FINAL : public UObject {
+public:
+    /**
+     * Construct a CanonicalIterator object
+     * @param source    string to get results for
+     * @param status    Fill-in parameter which receives the status of this operation.
+     * @stable ICU 2.4
+     */
+    CanonicalIterator(const UnicodeString &source, UErrorCode &status);
+
+    /** Destructor
+     *  Cleans pieces
+     * @stable ICU 2.4
+     */
+    virtual ~CanonicalIterator();
+
+    /**
+     * Gets the NFD form of the current source we are iterating over.
+     * @return gets the source: NOTE: it is the NFD form of source
+     * @stable ICU 2.4
+     */
+    UnicodeString getSource();
+
+    /**
+     * Resets the iterator so that one can start again from the beginning.
+     * @stable ICU 2.4
+     */
+    void reset();
+
+    /**
+     * Get the next canonically equivalent string.
+     * <br><b>Warning: The strings are not guaranteed to be in any particular order.</b>
+     * @return the next string that is canonically equivalent. A bogus string is returned when
+     * the iteration is done.
+     * @stable ICU 2.4
+     */
+    UnicodeString next();
+
+    /**
+     * Set a new source for this iterator. Allows object reuse.
+     * @param newSource     the source string to iterate against. This allows the same iterator to be used
+     *                     while changing the source string, saving object creation.
+     * @param status        Fill-in parameter which receives the status of this operation.
+     * @stable ICU 2.4
+     */
+    void setSource(const UnicodeString &newSource, UErrorCode &status);
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Dumb recursive implementation of permutation.
+     * TODO: optimize
+     * @param source     the string to find permutations for
+     * @param skipZeros  determine if skip zeros
+     * @param result     the results in a set.
+     * @param status       Fill-in parameter which receives the status of this operation.
+     * @internal
+     */
+    static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status);
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+private:
+    // ===================== PRIVATES ==============================
+    // private default constructor
+    CanonicalIterator();
+
+
+    /**
+     * Copy constructor. Private for now.
+     * @internal
+     */
+    CanonicalIterator(const CanonicalIterator& other);
+
+    /**
+     * Assignment operator. Private for now.
+     * @internal
+     */
+    CanonicalIterator& operator=(const CanonicalIterator& other);
+
+    // fields
+    UnicodeString source;
+    UBool done;
+
+    // 2 dimensional array holds the pieces of the string with
+    // their different canonically equivalent representations
+    UnicodeString **pieces;
+    int32_t pieces_length;
+    int32_t *pieces_lengths;
+
+    // current is used in iterating to combine pieces
+    int32_t *current;
+    int32_t current_length;
+
+    // transient fields
+    UnicodeString buffer;
+
+    const Normalizer2 &nfd;
+    const Normalizer2Impl &nfcImpl;
+
+    // we have a segment, in NFD. Find all the strings that are canonically equivalent to it.
+    UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
+
+    //Set getEquivalents2(String segment);
+    Hashtable *getEquivalents2(Hashtable *fillinResult, const UChar *segment, int32_t segLen, UErrorCode &status);
+    //Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
+
+    /**
+     * See if the decomposition of cp2 is at segment starting at segmentPos
+     * (with canonical rearrangment!)
+     * If so, take the remainder, and return the equivalents
+     */
+    //Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
+    Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
+    //Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
+
+    void cleanPieces();
+
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_NORMALIZATION */
+
+#endif

+ 722 - 0
sqlite/unicode/chariter.h

@@ -0,0 +1,722 @@
+/*
+********************************************************************
+*
+*   Copyright (C) 1997-2011, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+********************************************************************
+*/
+
+#ifndef CHARITER_H
+#define CHARITER_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+/**
+ * \file
+ * \brief C++ API: Character Iterator
+ */
+ 
+U_NAMESPACE_BEGIN
+/**
+ * Abstract class that defines an API for forward-only iteration
+ * on text objects.
+ * This is a minimal interface for iteration without random access
+ * or backwards iteration. It is especially useful for wrapping
+ * streams with converters into an object for collation or
+ * normalization.
+ *
+ * <p>Characters can be accessed in two ways: as code units or as
+ * code points.
+ * Unicode code points are 21-bit integers and are the scalar values
+ * of Unicode characters. ICU uses the type UChar32 for them.
+ * Unicode code units are the storage units of a given
+ * Unicode/UCS Transformation Format (a character encoding scheme).
+ * With UTF-16, all code points can be represented with either one
+ * or two code units ("surrogates").
+ * String storage is typically based on code units, while properties
+ * of characters are typically determined using code point values.
+ * Some processes may be designed to work with sequences of code units,
+ * or it may be known that all characters that are important to an
+ * algorithm can be represented with single code units.
+ * Other processes will need to use the code point access functions.</p>
+ *
+ * <p>ForwardCharacterIterator provides nextPostInc() to access
+ * a code unit and advance an internal position into the text object,
+ * similar to a <code>return text[position++]</code>.<br>
+ * It provides next32PostInc() to access a code point and advance an internal
+ * position.</p>
+ *
+ * <p>next32PostInc() assumes that the current position is that of
+ * the beginning of a code point, i.e., of its first code unit.
+ * After next32PostInc(), this will be true again.
+ * In general, access to code units and code points in the same
+ * iteration loop should not be mixed. In UTF-16, if the current position
+ * is on a second code unit (Low Surrogate), then only that code unit
+ * is returned even by next32PostInc().</p>
+ *
+ * <p>For iteration with either function, there are two ways to
+ * check for the end of the iteration. When there are no more
+ * characters in the text object:
+ * <ul>
+ * <li>The hasNext() function returns FALSE.</li>
+ * <li>nextPostInc() and next32PostInc() return DONE
+ *     when one attempts to read beyond the end of the text object.</li>
+ * </ul>
+ *
+ * Example:
+ * \code 
+ * void function1(ForwardCharacterIterator &it) {
+ *     UChar32 c;
+ *     while(it.hasNext()) {
+ *         c=it.next32PostInc();
+ *         // use c
+ *     }
+ * }
+ *
+ * void function1(ForwardCharacterIterator &it) {
+ *     UChar c;
+ *     while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {
+ *         // use c
+ *      }
+ *  }
+ * \endcode
+ * </p>
+ *
+ * @stable ICU 2.0
+ */
+class U_COMMON_API ForwardCharacterIterator : public UObject {
+public:
+    /**
+     * Value returned by most of ForwardCharacterIterator's functions
+     * when the iterator has reached the limits of its iteration.
+     * @stable ICU 2.0
+     */
+    enum { DONE = 0xffff };
+    
+    /**
+     * Destructor.  
+     * @stable ICU 2.0
+     */
+    virtual ~ForwardCharacterIterator();
+    
+    /**
+     * Returns true when both iterators refer to the same
+     * character in the same character-storage object.  
+     * @param that The ForwardCharacterIterator to be compared for equality
+     * @return true when both iterators refer to the same
+     * character in the same character-storage object
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;
+    
+    /**
+     * Returns true when the iterators refer to different
+     * text-storage objects, or to different characters in the
+     * same text-storage object.  
+     * @param that The ForwardCharacterIterator to be compared for inequality
+     * @return true when the iterators refer to different
+     * text-storage objects, or to different characters in the
+     * same text-storage object
+     * @stable ICU 2.0
+     */
+    inline UBool operator!=(const ForwardCharacterIterator& that) const;
+    
+    /**
+     * Generates a hash code for this iterator.  
+     * @return the hash code.
+     * @stable ICU 2.0
+     */
+    virtual int32_t hashCode(void) const = 0;
+    
+    /**
+     * Returns a UClassID for this ForwardCharacterIterator ("poor man's
+     * RTTI").<P> Despite the fact that this function is public,
+     * DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API! 
+     * @return a UClassID for this ForwardCharacterIterator 
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+    
+    /**
+     * Gets the current code unit for returning and advances to the next code unit
+     * in the iteration range
+     * (toward endIndex()).  If there are
+     * no more code units to return, returns DONE.
+     * @return the current code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         nextPostInc(void) = 0;
+    
+    /**
+     * Gets the current code point for returning and advances to the next code point
+     * in the iteration range
+     * (toward endIndex()).  If there are
+     * no more code points to return, returns DONE.
+     * @return the current code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       next32PostInc(void) = 0;
+    
+    /**
+     * Returns FALSE if there are no more code units or code points
+     * at or after the current position in the iteration range.
+     * This is used with nextPostInc() or next32PostInc() in forward
+     * iteration.
+     * @returns FALSE if there are no more code units or code points
+     * at or after the current position in the iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UBool        hasNext() = 0;
+    
+protected:
+    /** Default constructor to be overridden in the implementing class. @stable ICU 2.0*/
+    ForwardCharacterIterator();
+    
+    /** Copy constructor to be overridden in the implementing class. @stable ICU 2.0*/
+    ForwardCharacterIterator(const ForwardCharacterIterator &other);
+    
+    /**
+     * Assignment operator to be overridden in the implementing class.
+     * @stable ICU 2.0
+     */
+    ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
+};
+
+/**
+ * Abstract class that defines an API for iteration
+ * on text objects.
+ * This is an interface for forward and backward iteration
+ * and random access into a text object.
+ *
+ * <p>The API provides backward compatibility to the Java and older ICU
+ * CharacterIterator classes but extends them significantly:
+ * <ol>
+ * <li>CharacterIterator is now a subclass of ForwardCharacterIterator.</li>
+ * <li>While the old API functions provided forward iteration with
+ *     "pre-increment" semantics, the new one also provides functions
+ *     with "post-increment" semantics. They are more efficient and should
+ *     be the preferred iterator functions for new implementations.
+ *     The backward iteration always had "pre-decrement" semantics, which
+ *     are efficient.</li>
+ * <li>Just like ForwardCharacterIterator, it provides access to
+ *     both code units and code points. Code point access versions are available
+ *     for the old and the new iteration semantics.</li>
+ * <li>There are new functions for setting and moving the current position
+ *     without returning a character, for efficiency.</li>
+ * </ol>
+ *
+ * See ForwardCharacterIterator for examples for using the new forward iteration
+ * functions. For backward iteration, there is also a hasPrevious() function
+ * that can be used analogously to hasNext().
+ * The old functions work as before and are shown below.</p>
+ *
+ * <p>Examples for some of the new functions:</p>
+ *
+ * Forward iteration with hasNext():
+ * \code
+ * void forward1(CharacterIterator &it) {
+ *     UChar32 c;
+ *     for(it.setToStart(); it.hasNext();) {
+ *         c=it.next32PostInc();
+ *         // use c
+ *     }
+ *  }
+ * \endcode
+ * Forward iteration more similar to loops with the old forward iteration,
+ * showing a way to convert simple for() loops:
+ * \code
+ * void forward2(CharacterIterator &it) {
+ *     UChar c;
+ *     for(c=it.firstPostInc(); c!=CharacterIterator::DONE; c=it.nextPostInc()) {
+ *          // use c
+ *      }
+ * }
+ * \endcode
+ * Backward iteration with setToEnd() and hasPrevious():
+ * \code
+ *  void backward1(CharacterIterator &it) {
+ *      UChar32 c;
+ *      for(it.setToEnd(); it.hasPrevious();) {
+ *         c=it.previous32();
+ *          // use c
+ *      }
+ *  }
+ * \endcode
+ * Backward iteration with a more traditional for() loop:
+ * \code
+ * void backward2(CharacterIterator &it) {
+ *     UChar c;
+ *     for(c=it.last(); c!=CharacterIterator::DONE; c=it.previous()) {
+ *         // use c
+ *      }
+ *  }
+ * \endcode
+ *
+ * Example for random access:
+ * \code
+ *  void random(CharacterIterator &it) {
+ *      // set to the third code point from the beginning
+ *      it.move32(3, CharacterIterator::kStart);
+ *      // get a code point from here without moving the position
+ *      UChar32 c=it.current32();
+ *      // get the position
+ *      int32_t pos=it.getIndex();
+ *      // get the previous code unit
+ *      UChar u=it.previous();
+ *      // move back one more code unit
+ *      it.move(-1, CharacterIterator::kCurrent);
+ *      // set the position back to where it was
+ *      // and read the same code point c and move beyond it
+ *      it.setIndex(pos);
+ *      if(c!=it.next32PostInc()) {
+ *          exit(1); // CharacterIterator inconsistent
+ *      }
+ *  }
+ * \endcode
+ *
+ * <p>Examples, especially for the old API:</p>
+ *
+ * Function processing characters, in this example simple output
+ * <pre>
+ * \code
+ *  void processChar( UChar c )
+ *  {
+ *      cout << " " << c;
+ *  }
+ * \endcode
+ * </pre>
+ * Traverse the text from start to finish
+ * <pre> 
+ * \code
+ *  void traverseForward(CharacterIterator& iter)
+ *  {
+ *      for(UChar c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
+ *          processChar(c);
+ *      }
+ *  }
+ * \endcode
+ * </pre>
+ * Traverse the text backwards, from end to start
+ * <pre>
+ * \code
+ *  void traverseBackward(CharacterIterator& iter)
+ *  {
+ *      for(UChar c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
+ *          processChar(c);
+ *      }
+ *  }
+ * \endcode
+ * </pre>
+ * Traverse both forward and backward from a given position in the text. 
+ * Calls to notBoundary() in this example represents some additional stopping criteria.
+ * <pre>
+ * \code
+ * void traverseOut(CharacterIterator& iter, int32_t pos)
+ * {
+ *      UChar c;
+ *      for (c = iter.setIndex(pos);
+ *      c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
+ *          c = iter.next()) {}
+ *      int32_t end = iter.getIndex();
+ *      for (c = iter.setIndex(pos);
+ *          c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
+ *          c = iter.previous()) {}
+ *      int32_t start = iter.getIndex() + 1;
+ *  
+ *      cout << "start: " << start << " end: " << end << endl;
+ *      for (c = iter.setIndex(start); iter.getIndex() < end; c = iter.next() ) {
+ *          processChar(c);
+ *     }
+ *  }
+ * \endcode
+ * </pre>
+ * Creating a StringCharacterIterator and calling the test functions
+ * <pre>
+ * \code
+ *  void CharacterIterator_Example( void )
+ *   {
+ *       cout << endl << "===== CharacterIterator_Example: =====" << endl;
+ *       UnicodeString text("Ein kleiner Satz.");
+ *       StringCharacterIterator iterator(text);
+ *       cout << "----- traverseForward: -----------" << endl;
+ *       traverseForward( iterator );
+ *       cout << endl << endl << "----- traverseBackward: ----------" << endl;
+ *       traverseBackward( iterator );
+ *       cout << endl << endl << "----- traverseOut: ---------------" << endl;
+ *       traverseOut( iterator, 7 );
+ *       cout << endl << endl << "-----" << endl;
+ *   }
+ * \endcode
+ * </pre>
+ *
+ * @stable ICU 2.0
+ */
+class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
+public:
+    /**
+     * Origin enumeration for the move() and move32() functions.
+     * @stable ICU 2.0
+     */
+    enum EOrigin { kStart, kCurrent, kEnd };
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~CharacterIterator();
+
+    /**
+     * Returns a pointer to a new CharacterIterator of the same
+     * concrete class as this one, and referring to the same
+     * character in the same text-storage object as this one.  The
+     * caller is responsible for deleting the new clone.  
+     * @return a pointer to a new CharacterIterator
+     * @stable ICU 2.0
+     */
+    virtual CharacterIterator* clone(void) const = 0;
+
+    /**
+     * Sets the iterator to refer to the first code unit in its
+     * iteration range, and returns that code unit.
+     * This can be used to begin an iteration with next().
+     * @return the first code unit in its iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UChar         first(void) = 0;
+
+    /**
+     * Sets the iterator to refer to the first code unit in its
+     * iteration range, returns that code unit, and moves the position
+     * to the second code unit. This is an alternative to setToStart()
+     * for forward iteration with nextPostInc().
+     * @return the first code unit in its iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UChar         firstPostInc(void);
+
+    /**
+     * Sets the iterator to refer to the first code point in its
+     * iteration range, and returns that code unit,
+     * This can be used to begin an iteration with next32().
+     * Note that an iteration with next32PostInc(), beginning with,
+     * e.g., setToStart() or firstPostInc(), is more efficient.
+     * @return the first code point in its iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       first32(void) = 0;
+
+    /**
+     * Sets the iterator to refer to the first code point in its
+     * iteration range, returns that code point, and moves the position
+     * to the second code point. This is an alternative to setToStart()
+     * for forward iteration with next32PostInc().
+     * @return the first code point in its iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       first32PostInc(void);
+
+    /**
+     * Sets the iterator to refer to the first code unit or code point in its
+     * iteration range. This can be used to begin a forward
+     * iteration with nextPostInc() or next32PostInc().
+     * @return the start position of the iteration range
+     * @stable ICU 2.0
+     */
+    inline int32_t    setToStart();
+
+    /**
+     * Sets the iterator to refer to the last code unit in its
+     * iteration range, and returns that code unit.
+     * This can be used to begin an iteration with previous().
+     * @return the last code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         last(void) = 0;
+        
+    /**
+     * Sets the iterator to refer to the last code point in its
+     * iteration range, and returns that code unit.
+     * This can be used to begin an iteration with previous32().
+     * @return the last code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       last32(void) = 0;
+
+    /**
+     * Sets the iterator to the end of its iteration range, just behind
+     * the last code unit or code point. This can be used to begin a backward
+     * iteration with previous() or previous32().
+     * @return the end position of the iteration range
+     * @stable ICU 2.0
+     */
+    inline int32_t    setToEnd();
+
+    /**
+     * Sets the iterator to refer to the "position"-th code unit
+     * in the text-storage object the iterator refers to, and
+     * returns that code unit.  
+     * @param position the "position"-th code unit in the text-storage object
+     * @return the "position"-th code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         setIndex(int32_t position) = 0;
+
+    /**
+     * Sets the iterator to refer to the beginning of the code point
+     * that contains the "position"-th code unit
+     * in the text-storage object the iterator refers to, and
+     * returns that code point.
+     * The current position is adjusted to the beginning of the code point
+     * (its first code unit).
+     * @param position the "position"-th code unit in the text-storage object
+     * @return the "position"-th code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       setIndex32(int32_t position) = 0;
+
+    /**
+     * Returns the code unit the iterator currently refers to. 
+     * @return the current code unit. 
+     * @stable ICU 2.0
+     */
+    virtual UChar         current(void) const = 0;
+        
+    /**
+     * Returns the code point the iterator currently refers to.  
+     * @return the current code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       current32(void) const = 0;
+        
+    /**
+     * Advances to the next code unit in the iteration range
+     * (toward endIndex()), and returns that code unit.  If there are
+     * no more code units to return, returns DONE.
+     * @return the next code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         next(void) = 0;
+        
+    /**
+     * Advances to the next code point in the iteration range
+     * (toward endIndex()), and returns that code point.  If there are
+     * no more code points to return, returns DONE.
+     * Note that iteration with "pre-increment" semantics is less
+     * efficient than iteration with "post-increment" semantics
+     * that is provided by next32PostInc().
+     * @return the next code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       next32(void) = 0;
+        
+    /**
+     * Advances to the previous code unit in the iteration range
+     * (toward startIndex()), and returns that code unit.  If there are
+     * no more code units to return, returns DONE.  
+     * @return the previous code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         previous(void) = 0;
+
+    /**
+     * Advances to the previous code point in the iteration range
+     * (toward startIndex()), and returns that code point.  If there are
+     * no more code points to return, returns DONE. 
+     * @return the previous code point. 
+     * @stable ICU 2.0
+     */
+    virtual UChar32       previous32(void) = 0;
+
+    /**
+     * Returns FALSE if there are no more code units or code points
+     * before the current position in the iteration range.
+     * This is used with previous() or previous32() in backward
+     * iteration.
+     * @return FALSE if there are no more code units or code points
+     * before the current position in the iteration range, return TRUE otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool        hasPrevious() = 0;
+
+    /**
+     * Returns the numeric index in the underlying text-storage
+     * object of the character returned by first().  Since it's
+     * possible to create an iterator that iterates across only
+     * part of a text-storage object, this number isn't
+     * necessarily 0.  
+     * @returns the numeric index in the underlying text-storage
+     * object of the character returned by first().
+     * @stable ICU 2.0
+     */
+    inline int32_t       startIndex(void) const;
+        
+    /**
+     * Returns the numeric index in the underlying text-storage
+     * object of the position immediately BEYOND the character
+     * returned by last().  
+     * @return the numeric index in the underlying text-storage
+     * object of the position immediately BEYOND the character
+     * returned by last().
+     * @stable ICU 2.0
+     */
+    inline int32_t       endIndex(void) const;
+        
+    /**
+     * Returns the numeric index in the underlying text-storage
+     * object of the character the iterator currently refers to
+     * (i.e., the character returned by current()).  
+     * @return the numberic index in the text-storage object of 
+     * the character the iterator currently refers to
+     * @stable ICU 2.0
+     */
+    inline int32_t       getIndex(void) const;
+
+    /**
+     * Returns the length of the entire text in the underlying
+     * text-storage object.
+     * @return the length of the entire text in the text-storage object
+     * @stable ICU 2.0
+     */
+    inline int32_t           getLength() const;
+
+    /**
+     * Moves the current position relative to the start or end of the
+     * iteration range, or relative to the current position itself.
+     * The movement is expressed in numbers of code units forward
+     * or backward by specifying a positive or negative delta.
+     * @param delta the position relative to origin. A positive delta means forward;
+     * a negative delta means backward.
+     * @param origin Origin enumeration {kStart, kCurrent, kEnd}
+     * @return the new position
+     * @stable ICU 2.0
+     */
+    virtual int32_t      move(int32_t delta, EOrigin origin) = 0;
+
+    /**
+     * Moves the current position relative to the start or end of the
+     * iteration range, or relative to the current position itself.
+     * The movement is expressed in numbers of code points forward
+     * or backward by specifying a positive or negative delta.
+     * @param delta the position relative to origin. A positive delta means forward;
+     * a negative delta means backward.
+     * @param origin Origin enumeration {kStart, kCurrent, kEnd}
+     * @return the new position
+     * @stable ICU 2.0
+     */
+    virtual int32_t      move32(int32_t delta, EOrigin origin) = 0;
+
+    /**
+     * Copies the text under iteration into the UnicodeString
+     * referred to by "result".  
+     * @param result Receives a copy of the text under iteration.  
+     * @stable ICU 2.0
+     */
+    virtual void            getText(UnicodeString&  result) = 0;
+
+protected:
+    /**
+     * Empty constructor.
+     * @stable ICU 2.0
+     */
+    CharacterIterator();
+
+    /**
+     * Constructor, just setting the length field in this base class.
+     * @stable ICU 2.0
+     */
+    CharacterIterator(int32_t length);
+
+    /**
+     * Constructor, just setting the length and position fields in this base class.
+     * @stable ICU 2.0
+     */
+    CharacterIterator(int32_t length, int32_t position);
+
+    /**
+     * Constructor, just setting the length, start, end, and position fields in this base class.
+     * @stable ICU 2.0
+     */
+    CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
+  
+    /**
+     * Copy constructor.
+     *
+     * @param that The CharacterIterator to be copied
+     * @stable ICU 2.0
+     */
+    CharacterIterator(const CharacterIterator &that);
+
+    /**
+     * Assignment operator.  Sets this CharacterIterator to have the same behavior,
+     * as the one passed in.
+     * @param that The CharacterIterator passed in.
+     * @return the newly set CharacterIterator.
+     * @stable ICU 2.0
+     */
+    CharacterIterator &operator=(const CharacterIterator &that);
+
+    /**
+     * Base class text length field.
+     * Necessary this for correct getText() and hashCode().
+     * @stable ICU 2.0
+     */
+    int32_t textLength;
+
+    /**
+     * Base class field for the current position.
+     * @stable ICU 2.0
+     */
+    int32_t  pos;
+
+    /**
+     * Base class field for the start of the iteration range.
+     * @stable ICU 2.0
+     */
+    int32_t  begin;
+
+    /**
+     * Base class field for the end of the iteration range.
+     * @stable ICU 2.0
+     */
+    int32_t  end;
+};
+
+inline UBool
+ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
+    return !operator==(that);
+}
+
+inline int32_t
+CharacterIterator::setToStart() {
+    return move(0, kStart);
+}
+
+inline int32_t
+CharacterIterator::setToEnd() {
+    return move(0, kEnd);
+}
+
+inline int32_t
+CharacterIterator::startIndex(void) const {
+    return begin;
+}
+
+inline int32_t
+CharacterIterator::endIndex(void) const {
+    return end;
+}
+
+inline int32_t
+CharacterIterator::getIndex(void) const {
+    return pos;
+}
+
+inline int32_t
+CharacterIterator::getLength(void) const {
+    return textLength;
+}
+
+U_NAMESPACE_END
+#endif

+ 594 - 0
sqlite/unicode/choicfmt.h

@@ -0,0 +1,594 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2013, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File CHOICFMT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/20/97    helena      Finished first cut of implementation and got rid
+*                           of nextDouble/previousDouble and replaced with
+*                           boolean array.
+*   4/10/97     aliu        Clean up.  Modified to work on AIX.
+*   8/6/97      nos         Removed overloaded constructor, member var 'buffer'.
+*   07/22/98    stephen     Removed operator!= (implemented in Format)
+********************************************************************************
+*/
+
+#ifndef CHOICFMT_H
+#define CHOICFMT_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Choice Format.
+ */
+
+#if !UCONFIG_NO_FORMATTING
+#ifndef U_HIDE_DEPRECATED_API
+
+#include "unicode/fieldpos.h"
+#include "unicode/format.h"
+#include "unicode/messagepattern.h"
+#include "unicode/numfmt.h"
+#include "unicode/unistr.h"
+
+U_NAMESPACE_BEGIN
+
+class MessageFormat;
+
+/**
+ * ChoiceFormat converts between ranges of numeric values and strings for those ranges.
+ * The strings must conform to the MessageFormat pattern syntax.
+ *
+ * <p><em><code>ChoiceFormat</code> is probably not what you need.
+ * Please use <code>MessageFormat</code>
+ * with <code>plural</code> arguments for proper plural selection,
+ * and <code>select</code> arguments for simple selection among a fixed set of choices!</em></p>
+ *
+ * <p>A <code>ChoiceFormat</code> splits
+ * the real number line \htmlonly<code>-&#x221E;</code> to
+ * <code>+&#x221E;</code>\endhtmlonly into two
+ * or more contiguous ranges. Each range is mapped to a
+ * string.</p>
+ *
+ * <p><code>ChoiceFormat</code> was originally intended
+ * for displaying grammatically correct
+ * plurals such as &quot;There is one file.&quot; vs. &quot;There are 2 files.&quot;
+ * <em>However,</em> plural rules for many languages
+ * are too complex for the capabilities of ChoiceFormat,
+ * and its requirement of specifying the precise rules for each message
+ * is unmanageable for translators.</p>
+ *
+ * <p>There are two methods of defining a <code>ChoiceFormat</code>; both
+ * are equivalent.  The first is by using a string pattern. This is the
+ * preferred method in most cases.  The second method is through direct
+ * specification of the arrays that logically make up the
+ * <code>ChoiceFormat</code>.</p>
+ *
+ * <p>Note: Typically, choice formatting is done (if done at all) via <code>MessageFormat</code>
+ * with a <code>choice</code> argument type,
+ * rather than using a stand-alone <code>ChoiceFormat</code>.</p>
+ *
+ * <h5>Patterns and Their Interpretation</h5>
+ *
+ * <p>The pattern string defines the range boundaries and the strings for each number range.
+ * Syntax:
+ * <pre>
+ * choiceStyle = number separator message ('|' number separator message)*
+ * number = normal_number | ['-'] \htmlonly&#x221E;\endhtmlonly (U+221E, infinity)
+ * normal_number = double value (unlocalized ASCII string)
+ * separator = less_than | less_than_or_equal
+ * less_than = '<'
+ * less_than_or_equal = '#' | \htmlonly&#x2264;\endhtmlonly (U+2264)
+ * message: see {@link MessageFormat}
+ * </pre>
+ * Pattern_White_Space between syntax elements is ignored, except
+ * around each range's sub-message.</p>
+ *
+ * <p>Each numeric sub-range extends from the current range's number
+ * to the next range's number.
+ * The number itself is included in its range if a <code>less_than_or_equal</code> sign is used,
+ * and excluded from its range (and instead included in the previous range)
+ * if a <code>less_than</code> sign is used.</p>
+ *
+ * <p>When a <code>ChoiceFormat</code> is constructed from
+ * arrays of numbers, closure flags and strings,
+ * they are interpreted just like
+ * the sequence of <code>(number separator string)</code> in an equivalent pattern string.
+ * <code>closure[i]==TRUE</code> corresponds to a <code>less_than</code> separator sign.
+ * The equivalent pattern string will be constructed automatically.</p>
+ *
+ * <p>During formatting, a number is mapped to the first range
+ * where the number is not greater than the range's upper limit.
+ * That range's message string is returned. A NaN maps to the very first range.</p>
+ *
+ * <p>During parsing, a range is selected for the longest match of
+ * any range's message. That range's number is returned, ignoring the separator/closure.
+ * Only a simple string match is performed, without parsing of arguments that
+ * might be specified in the message strings.</p>
+ *
+ * <p>Note that the first range's number is ignored in formatting
+ * but may be returned from parsing.</p>
+ *
+ * <h5>Examples</h5>
+ *
+ * <p>Here is an example of two arrays that map the number
+ * <code>1..7</code> to the English day of the week abbreviations
+ * <code>Sun..Sat</code>. No closures array is given; this is the same as
+ * specifying all closures to be <code>FALSE</code>.</p>
+ *
+ * <pre>    {1,2,3,4,5,6,7},
+ *     {&quot;Sun&quot;,&quot;Mon&quot;,&quot;Tue&quot;,&quot;Wed&quot;,&quot;Thur&quot;,&quot;Fri&quot;,&quot;Sat&quot;}</pre>
+ *
+ * <p>Here is an example that maps the ranges [-Inf, 1), [1, 1], and (1,
+ * +Inf] to three strings. That is, the number line is split into three
+ * ranges: x &lt; 1.0, x = 1.0, and x &gt; 1.0.
+ * (The round parentheses in the notation above indicate an exclusive boundary,
+ * like the turned bracket in European notation: [-Inf, 1) == [-Inf, 1[  )</p>
+ *
+ * <pre>    {0, 1, 1},
+ *     {FALSE, FALSE, TRUE},
+ *     {&quot;no files&quot;, &quot;one file&quot;, &quot;many files&quot;}</pre>
+ *
+ * <p>Here is an example that shows formatting and parsing: </p>
+ *
+ * \code
+ *   #include <unicode/choicfmt.h>
+ *   #include <unicode/unistr.h>
+ *   #include <iostream.h>
+ *
+ *   int main(int argc, char *argv[]) {
+ *       double limits[] = {1,2,3,4,5,6,7};
+ *       UnicodeString monthNames[] = {
+ *           "Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
+ *       ChoiceFormat fmt(limits, monthNames, 7);
+ *       UnicodeString str;
+ *       char buf[256];
+ *       for (double x = 1.0; x <= 8.0; x += 1.0) {
+ *           fmt.format(x, str);
+ *           str.extract(0, str.length(), buf, 256, "");
+ *           str.truncate(0);
+ *           cout << x << " -> "
+ *                << buf << endl;
+ *       }
+ *       cout << endl;
+ *       return 0;
+ *   }
+ * \endcode
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ *
+ * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+ */
+class U_I18N_API ChoiceFormat: public NumberFormat {
+public:
+    /**
+     * Constructs a new ChoiceFormat from the pattern string.
+     *
+     * @param pattern   Pattern used to construct object.
+     * @param status    Output param to receive success code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    ChoiceFormat(const UnicodeString& pattern,
+                 UErrorCode& status);
+
+
+    /**
+     * Constructs a new ChoiceFormat with the given limits and message strings.
+     * All closure flags default to <code>FALSE</code>,
+     * equivalent to <code>less_than_or_equal</code> separators.
+     *
+     * Copies the limits and formats instead of adopting them.
+     *
+     * @param limits    Array of limit values.
+     * @param formats   Array of formats.
+     * @param count     Size of 'limits' and 'formats' arrays.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    ChoiceFormat(const double* limits,
+                 const UnicodeString* formats,
+                 int32_t count );
+
+    /**
+     * Constructs a new ChoiceFormat with the given limits, closure flags and message strings.
+     *
+     * Copies the limits and formats instead of adopting them.
+     *
+     * @param limits Array of limit values
+     * @param closures Array of booleans specifying whether each
+     * element of 'limits' is open or closed.  If FALSE, then the
+     * corresponding limit number is a member of its range.
+     * If TRUE, then the limit number belongs to the previous range it.
+     * @param formats Array of formats
+     * @param count Size of 'limits', 'closures', and 'formats' arrays
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    ChoiceFormat(const double* limits,
+                 const UBool* closures,
+                 const UnicodeString* formats,
+                 int32_t count);
+
+    /**
+     * Copy constructor.
+     *
+     * @param that   ChoiceFormat object to be copied from
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    ChoiceFormat(const ChoiceFormat& that);
+
+    /**
+     * Assignment operator.
+     *
+     * @param that   ChoiceFormat object to be copied
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    const ChoiceFormat& operator=(const ChoiceFormat& that);
+
+    /**
+     * Destructor.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual ~ChoiceFormat();
+
+    /**
+     * Clones this Format object. The caller owns the
+     * result and must delete it when done.
+     *
+     * @return a copy of this object
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual Format* clone(void) const;
+
+    /**
+     * Returns true if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     *
+     * @param other    ChoiceFormat object to be compared
+     * @return         true if other is the same as this.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Sets the pattern.
+     * @param pattern   The pattern to be applied.
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                              UErrorCode& status);
+
+    /**
+     * Sets the pattern.
+     * @param pattern    The pattern to be applied.
+     * @param parseError Struct to receive information on position
+     *                   of error if an error is encountered
+     * @param status     Output param set to success/failure code on
+     *                   exit. If the pattern is invalid, this will be
+     *                   set to a failure result.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                             UParseError& parseError,
+                             UErrorCode& status);
+    /**
+     * Gets the pattern.
+     *
+     * @param pattern    Output param which will receive the pattern
+     *                   Previous contents are deleted.
+     * @return    A reference to 'pattern'
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual UnicodeString& toPattern(UnicodeString &pattern) const;
+
+    /**
+     * Sets the choices to be used in formatting.
+     * For details see the constructor with the same parameter list.
+     *
+     * @param limitsToCopy      Contains the top value that you want
+     *                          parsed with that format,and should be in
+     *                          ascending sorted order. When formatting X,
+     *                          the choice will be the i, where limit[i]
+     *                          &lt;= X &lt; limit[i+1].
+     * @param formatsToCopy     The format strings you want to use for each limit.
+     * @param count             The size of the above arrays.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual void setChoices(const double* limitsToCopy,
+                            const UnicodeString* formatsToCopy,
+                            int32_t count );
+
+    /**
+     * Sets the choices to be used in formatting.
+     * For details see the constructor with the same parameter list.
+     *
+     * @param limits Array of limits
+     * @param closures Array of limit booleans
+     * @param formats Array of format string
+     * @param count The size of the above arrays
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual void setChoices(const double* limits,
+                            const UBool* closures,
+                            const UnicodeString* formats,
+                            int32_t count);
+
+    /**
+     * Returns NULL and 0.
+     * Before ICU 4.8, this used to return the choice limits array.
+     *
+     * @param count Will be set to 0.
+     * @return NULL
+     * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
+     */
+    virtual const double* getLimits(int32_t& count) const;
+
+    /**
+     * Returns NULL and 0.
+     * Before ICU 4.8, this used to return the limit booleans array.
+     *
+     * @param count Will be set to 0.
+     * @return NULL
+     * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
+     */
+    virtual const UBool* getClosures(int32_t& count) const;
+
+    /**
+     * Returns NULL and 0.
+     * Before ICU 4.8, this used to return the array of choice strings.
+     *
+     * @param count Will be set to 0.
+     * @return NULL
+     * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
+     */
+    virtual const UnicodeString* getFormats(int32_t& count) const;
+
+
+    using NumberFormat::format;
+
+    /**
+     * Formats a double number using this object's choices.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+    /**
+     * Formats an int32_t number using this object's choices.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual UnicodeString& format(int32_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Formats an int64_t number using this object's choices.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Formats an array of objects using this object's choices.
+     *
+     * @param objs      The array of objects to be formatted.
+     * @param cnt       The size of objs.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param success   Output param set to success/failure code on
+     *                  exit.
+     * @return          Reference to 'appendTo' parameter.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual UnicodeString& format(const Formattable* objs,
+                                  int32_t cnt,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& success) const;
+
+   using NumberFormat::parse;
+
+   /**
+    * Looks for the longest match of any message string on the input text and,
+    * if there is a match, sets the result object to the corresponding range's number.
+    *
+    * If no string matches, then the parsePosition is unchanged.
+    *
+    * @param text           The text to be parsed.
+    * @param result         Formattable to be set to the parse result.
+    *                       If parse fails, return contents are undefined.
+    * @param parsePosition  The position to start parsing at on input.
+    *                       On output, moved to after the last successfully
+    *                       parse character. On parse failure, does not change.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+    */
+    virtual void parse(const UnicodeString& text,
+                       Formattable& result,
+                       ParsePosition& parsePosition) const;
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Part of ICU's "poor man's RTTI".
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    /**
+     * Returns the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().  For example:
+     * <pre>
+     * .       Base* polymorphic_pointer = createPolymorphicObject();
+     * .       if (polymorphic_pointer->getDynamicClassID() ==
+     * .           Derived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+private:
+    /**
+     * Converts a double value to a string.
+     * @param value the double number to be converted.
+     * @param string the result string.
+     * @return the converted string.
+     */
+    static UnicodeString& dtos(double value, UnicodeString& string);
+
+    ChoiceFormat(); // default constructor not implemented
+
+    /**
+     * Construct a new ChoiceFormat with the limits and the corresponding formats
+     * based on the pattern.
+     *
+     * @param newPattern   Pattern used to construct object.
+     * @param parseError   Struct to receive information on position
+     *                     of error if an error is encountered.
+     * @param status       Output param to receive success code.  If the
+     *                     pattern cannot be parsed, set to failure code.
+     */
+    ChoiceFormat(const UnicodeString& newPattern,
+                 UParseError& parseError,
+                 UErrorCode& status);
+
+    friend class MessageFormat;
+
+    virtual void setChoices(const double* limits,
+                            const UBool* closures,
+                            const UnicodeString* formats,
+                            int32_t count,
+                            UErrorCode &errorCode);
+
+    /**
+     * Finds the ChoiceFormat sub-message for the given number.
+     * @param pattern A MessagePattern.
+     * @param partIndex the index of the first ChoiceFormat argument style part.
+     * @param number a number to be mapped to one of the ChoiceFormat argument's intervals
+     * @return the sub-message start part index.
+     */
+    static int32_t findSubMessage(const MessagePattern &pattern, int32_t partIndex, double number);
+
+    static double parseArgument(
+            const MessagePattern &pattern, int32_t partIndex,
+            const UnicodeString &source, ParsePosition &pos);
+
+    /**
+     * Matches the pattern string from the end of the partIndex to
+     * the beginning of the limitPartIndex,
+     * including all syntax except SKIP_SYNTAX,
+     * against the source string starting at sourceOffset.
+     * If they match, returns the length of the source string match.
+     * Otherwise returns -1.
+     */
+    static int32_t matchStringUntilLimitPart(
+            const MessagePattern &pattern, int32_t partIndex, int32_t limitPartIndex,
+            const UnicodeString &source, int32_t sourceOffset);
+
+    /**
+     * Some of the ChoiceFormat constructors do not have a UErrorCode paramater.
+     * We need _some_ way to provide one for the MessagePattern constructor.
+     * Alternatively, the MessagePattern could be a pointer field, but that is
+     * not nice either.
+     */
+    UErrorCode constructorErrorCode;
+
+    /**
+     * The MessagePattern which contains the parsed structure of the pattern string.
+     *
+     * Starting with ICU 4.8, the MessagePattern contains a sequence of
+     * numeric/selector/message parts corresponding to the parsed pattern.
+     * For details see the MessagePattern class API docs.
+     */
+    MessagePattern msgPattern;
+
+    /**
+     * Docs & fields from before ICU 4.8, before MessagePattern was used.
+     * Commented out, and left only for explanation of semantics.
+     * --------
+     * Each ChoiceFormat divides the range -Inf..+Inf into fCount
+     * intervals.  The intervals are:
+     *
+     *         0: fChoiceLimits[0]..fChoiceLimits[1]
+     *         1: fChoiceLimits[1]..fChoiceLimits[2]
+     *        ...
+     *  fCount-2: fChoiceLimits[fCount-2]..fChoiceLimits[fCount-1]
+     *  fCount-1: fChoiceLimits[fCount-1]..+Inf
+     *
+     * Interval 0 is special; during formatting (mapping numbers to
+     * strings), it also contains all numbers less than
+     * fChoiceLimits[0], as well as NaN values.
+     *
+     * Interval i maps to and from string fChoiceFormats[i].  When
+     * parsing (mapping strings to numbers), then intervals map to
+     * their lower limit, that is, interval i maps to fChoiceLimit[i].
+     *
+     * The intervals may be closed, half open, or open.  This affects
+     * formatting but does not affect parsing.  Interval i is affected
+     * by fClosures[i] and fClosures[i+1].  If fClosures[i]
+     * is FALSE, then the value fChoiceLimits[i] is in interval i.
+     * That is, intervals i and i are:
+     *
+     *  i-1:                 ... x < fChoiceLimits[i]
+     *    i: fChoiceLimits[i] <= x ...
+     *
+     * If fClosures[i] is TRUE, then the value fChoiceLimits[i] is
+     * in interval i-1.  That is, intervals i-1 and i are:
+     *
+     *  i-1:                ... x <= fChoiceLimits[i]
+     *    i: fChoiceLimits[i] < x ...
+     *
+     * Because of the nature of interval 0, fClosures[0] has no
+     * effect.
+     */
+    // double*         fChoiceLimits;
+    // UBool*          fClosures;
+    // UnicodeString*  fChoiceFormats;
+    // int32_t         fCount;
+};
+
+
+U_NAMESPACE_END
+
+#endif  // U_HIDE_DEPRECATED_API
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // CHOICFMT_H
+//eof

+ 404 - 0
sqlite/unicode/coleitr.h

@@ -0,0 +1,404 @@
+/*
+ ******************************************************************************
+ *   Copyright (C) 1997-2014, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ ******************************************************************************
+ */
+
+/**
+ * \file 
+ * \brief C++ API: Collation Element Iterator.
+ */
+
+/**
+* File coleitr.h
+*
+* Created by: Helena Shih
+*
+* Modification History:
+*
+*  Date       Name        Description
+*
+*  8/18/97    helena      Added internal API documentation.
+* 08/03/98    erm         Synched with 1.2 version CollationElementIterator.java
+* 12/10/99    aliu        Ported Thai collation support from Java.
+* 01/25/01    swquek      Modified into a C++ wrapper calling C APIs (ucoliter.h)
+* 02/19/01    swquek      Removed CollationElementsIterator() since it is 
+*                         private constructor and no calls are made to it
+* 2012-2014   markus      Rewritten in C++ again.
+*/
+
+#ifndef COLEITR_H
+#define COLEITR_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_COLLATION
+
+#include "unicode/unistr.h"
+#include "unicode/uobject.h"
+
+struct UCollationElements;
+struct UHashtable;
+
+U_NAMESPACE_BEGIN
+
+struct CollationData;
+
+class CollationIterator;
+class RuleBasedCollator;
+class UCollationPCE;
+class UVector32;
+
+/**
+* The CollationElementIterator class is used as an iterator to walk through     
+* each character of an international string. Use the iterator to return the
+* ordering priority of the positioned character. The ordering priority of a 
+* character, which we refer to as a key, defines how a character is collated in 
+* the given collation object.
+* For example, consider the following in Slovak and in traditional Spanish collation:
+* <pre>
+*        "ca" -> the first key is key('c') and second key is key('a').
+*        "cha" -> the first key is key('ch') and second key is key('a').</pre>
+* And in German phonebook collation,
+* <pre> \htmlonly       "&#x00E6;b"-> the first key is key('a'), the second key is key('e'), and
+*        the third key is key('b'). \endhtmlonly </pre>
+* The key of a character, is an integer composed of primary order(short),
+* secondary order(char), and tertiary order(char). Java strictly defines the 
+* size and signedness of its primitive data types. Therefore, the static
+* functions primaryOrder(), secondaryOrder(), and tertiaryOrder() return 
+* int32_t to ensure the correctness of the key value.
+* <p>Example of the iterator usage: (without error checking)
+* <pre>
+* \code
+*   void CollationElementIterator_Example()
+*   {
+*       UnicodeString str = "This is a test";
+*       UErrorCode success = U_ZERO_ERROR;
+*       RuleBasedCollator* rbc =
+*           (RuleBasedCollator*) RuleBasedCollator::createInstance(success);
+*       CollationElementIterator* c =
+*           rbc->createCollationElementIterator( str );
+*       int32_t order = c->next(success);
+*       c->reset();
+*       order = c->previous(success);
+*       delete c;
+*       delete rbc;
+*   }
+* \endcode
+* </pre>
+* <p>
+* The method next() returns the collation order of the next character based on
+* the comparison level of the collator. The method previous() returns the
+* collation order of the previous character based on the comparison level of
+* the collator. The Collation Element Iterator moves only in one direction
+* between calls to reset(), setOffset(), or setText(). That is, next() 
+* and previous() can not be inter-used. Whenever previous() is to be called after 
+* next() or vice versa, reset(), setOffset() or setText() has to be called first
+* to reset the status, shifting pointers to either the end or the start of
+* the string (reset() or setText()), or the specified position (setOffset()).
+* Hence at the next call of next() or previous(), the first or last collation order,
+* or collation order at the spefcifieid position will be returned. If a change of
+* direction is done without one of these calls, the result is undefined.
+* <p>
+* The result of a forward iterate (next()) and reversed result of the backward
+* iterate (previous()) on the same string are equivalent, if collation orders
+* with the value 0 are ignored.
+* Character based on the comparison level of the collator.  A collation order 
+* consists of primary order, secondary order and tertiary order.  The data 
+* type of the collation order is <strong>int32_t</strong>. 
+*
+* Note, CollationElementIterator should not be subclassed.
+* @see     Collator
+* @see     RuleBasedCollator
+* @version 1.8 Jan 16 2001
+*/
+class U_I18N_API CollationElementIterator U_FINAL : public UObject {
+public: 
+
+    // CollationElementIterator public data member ------------------------------
+
+    enum {
+        /**
+         * NULLORDER indicates that an error has occured while processing
+         * @stable ICU 2.0
+         */
+        NULLORDER = (int32_t)0xffffffff
+    };
+
+    // CollationElementIterator public constructor/destructor -------------------
+
+    /**
+    * Copy constructor.
+    *
+    * @param other    the object to be copied from
+    * @stable ICU 2.0
+    */
+    CollationElementIterator(const CollationElementIterator& other);
+
+    /** 
+    * Destructor
+    * @stable ICU 2.0
+    */
+    virtual ~CollationElementIterator();
+
+    // CollationElementIterator public methods ----------------------------------
+
+    /**
+    * Returns true if "other" is the same as "this"
+    *
+    * @param other    the object to be compared
+    * @return         true if "other" is the same as "this"
+    * @stable ICU 2.0
+    */
+    UBool operator==(const CollationElementIterator& other) const;
+
+    /**
+    * Returns true if "other" is not the same as "this".
+    *
+    * @param other    the object to be compared
+    * @return         true if "other" is not the same as "this"
+    * @stable ICU 2.0
+    */
+    UBool operator!=(const CollationElementIterator& other) const;
+
+    /**
+    * Resets the cursor to the beginning of the string.
+    * @stable ICU 2.0
+    */
+    void reset(void);
+
+    /**
+    * Gets the ordering priority of the next character in the string.
+    * @param status the error code status.
+    * @return the next character's ordering. otherwise returns NULLORDER if an 
+    *         error has occured or if the end of string has been reached
+    * @stable ICU 2.0
+    */
+    int32_t next(UErrorCode& status);
+
+    /**
+    * Get the ordering priority of the previous collation element in the string.
+    * @param status the error code status.
+    * @return the previous element's ordering. otherwise returns NULLORDER if an 
+    *         error has occured or if the start of string has been reached
+    * @stable ICU 2.0
+    */
+    int32_t previous(UErrorCode& status);
+
+    /**
+    * Gets the primary order of a collation order.
+    * @param order the collation order
+    * @return the primary order of a collation order.
+    * @stable ICU 2.0
+    */
+    static inline int32_t primaryOrder(int32_t order);
+
+    /**
+    * Gets the secondary order of a collation order.
+    * @param order the collation order
+    * @return the secondary order of a collation order.
+    * @stable ICU 2.0
+    */
+    static inline int32_t secondaryOrder(int32_t order);
+
+    /**
+    * Gets the tertiary order of a collation order.
+    * @param order the collation order
+    * @return the tertiary order of a collation order.
+    * @stable ICU 2.0
+    */
+    static inline int32_t tertiaryOrder(int32_t order);
+
+    /**
+    * Return the maximum length of any expansion sequences that end with the 
+    * specified comparison order.
+    * @param order a collation order returned by previous or next.
+    * @return maximum size of the expansion sequences ending with the collation 
+    *         element or 1 if collation element does not occur at the end of any 
+    *         expansion sequence
+    * @stable ICU 2.0
+    */
+    int32_t getMaxExpansion(int32_t order) const;
+
+    /**
+    * Gets the comparison order in the desired strength. Ignore the other
+    * differences.
+    * @param order The order value
+    * @stable ICU 2.0
+    */
+    int32_t strengthOrder(int32_t order) const;
+
+    /**
+    * Sets the source string.
+    * @param str the source string.
+    * @param status the error code status.
+    * @stable ICU 2.0
+    */
+    void setText(const UnicodeString& str, UErrorCode& status);
+
+    /**
+    * Sets the source string.
+    * @param str the source character iterator.
+    * @param status the error code status.
+    * @stable ICU 2.0
+    */
+    void setText(CharacterIterator& str, UErrorCode& status);
+
+    /**
+    * Checks if a comparison order is ignorable.
+    * @param order the collation order.
+    * @return TRUE if a character is ignorable, FALSE otherwise.
+    * @stable ICU 2.0
+    */
+    static inline UBool isIgnorable(int32_t order);
+
+    /**
+    * Gets the offset of the currently processed character in the source string.
+    * @return the offset of the character.
+    * @stable ICU 2.0
+    */
+    int32_t getOffset(void) const;
+
+    /**
+    * Sets the offset of the currently processed character in the source string.
+    * @param newOffset the new offset.
+    * @param status the error code status.
+    * @return the offset of the character.
+    * @stable ICU 2.0
+    */
+    void setOffset(int32_t newOffset, UErrorCode& status);
+
+    /**
+    * ICU "poor man's RTTI", returns a UClassID for the actual class.
+    *
+    * @stable ICU 2.2
+    */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+    * ICU "poor man's RTTI", returns a UClassID for this class.
+    *
+    * @stable ICU 2.2
+    */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+#ifndef U_HIDE_INTERNAL_API
+    /** @internal */
+    static inline CollationElementIterator *fromUCollationElements(UCollationElements *uc) {
+        return reinterpret_cast<CollationElementIterator *>(uc);
+    }
+    /** @internal */
+    static inline const CollationElementIterator *fromUCollationElements(const UCollationElements *uc) {
+        return reinterpret_cast<const CollationElementIterator *>(uc);
+    }
+    /** @internal */
+    inline UCollationElements *toUCollationElements() {
+        return reinterpret_cast<UCollationElements *>(this);
+    }
+    /** @internal */
+    inline const UCollationElements *toUCollationElements() const {
+        return reinterpret_cast<const UCollationElements *>(this);
+    }
+#endif  // U_HIDE_INTERNAL_API
+
+private:
+    friend class RuleBasedCollator;
+    friend class UCollationPCE;
+
+    /**
+    * CollationElementIterator constructor. This takes the source string and the 
+    * collation object. The cursor will walk thru the source string based on the 
+    * predefined collation rules. If the source string is empty, NULLORDER will 
+    * be returned on the calls to next().
+    * @param sourceText    the source string.
+    * @param order         the collation object.
+    * @param status        the error code status.
+    */
+    CollationElementIterator(const UnicodeString& sourceText,
+        const RuleBasedCollator* order, UErrorCode& status);
+    // Note: The constructors should take settings & tailoring, not a collator,
+    // to avoid circular dependencies.
+    // However, for operator==() we would need to be able to compare tailoring data for equality
+    // without making CollationData or CollationTailoring depend on TailoredSet.
+    // (See the implementation of RuleBasedCollator::operator==().)
+    // That might require creating an intermediate class that would be used
+    // by both CollationElementIterator and RuleBasedCollator
+    // but only contain the part of RBC== related to data and rules.
+
+    /**
+    * CollationElementIterator constructor. This takes the source string and the 
+    * collation object.  The cursor will walk thru the source string based on the 
+    * predefined collation rules.  If the source string is empty, NULLORDER will 
+    * be returned on the calls to next().
+    * @param sourceText    the source string.
+    * @param order         the collation object.
+    * @param status        the error code status.
+    */
+    CollationElementIterator(const CharacterIterator& sourceText,
+        const RuleBasedCollator* order, UErrorCode& status);
+
+    /**
+    * Assignment operator
+    *
+    * @param other    the object to be copied
+    */
+    const CollationElementIterator&
+        operator=(const CollationElementIterator& other);
+
+    CollationElementIterator(); // default constructor not implemented
+
+    /** Normalizes dir_=1 (just after setOffset()) to dir_=0 (just after reset()). */
+    inline int8_t normalizeDir() const { return dir_ == 1 ? 0 : dir_; }
+
+    static UHashtable *computeMaxExpansions(const CollationData *data, UErrorCode &errorCode);
+
+    static int32_t getMaxExpansion(const UHashtable *maxExpansions, int32_t order);
+
+    // CollationElementIterator private data members ----------------------------
+
+    CollationIterator *iter_;  // owned
+    const RuleBasedCollator *rbc_;  // aliased
+    uint32_t otherHalf_;
+    /**
+     * <0: backwards; 0: just after reset() (previous() begins from end);
+     * 1: just after setOffset(); >1: forward
+     */
+    int8_t dir_;
+    /**
+     * Stores offsets from expansions and from unsafe-backwards iteration,
+     * so that getOffset() returns intermediate offsets for the CEs
+     * that are consistent with forward iteration.
+     */
+    UVector32 *offsets_;
+
+    UnicodeString string_;
+};
+
+// CollationElementIterator inline method definitions --------------------------
+
+inline int32_t CollationElementIterator::primaryOrder(int32_t order)
+{
+    return (order >> 16) & 0xffff;
+}
+
+inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
+{
+    return (order >> 8) & 0xff;
+}
+
+inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
+{
+    return order & 0xff;
+}
+
+inline UBool CollationElementIterator::isIgnorable(int32_t order)
+{
+    return (order & 0xffff0000) == 0;
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif

+ 1269 - 0
sqlite/unicode/coll.h

@@ -0,0 +1,1269 @@
+/*
+******************************************************************************
+*   Copyright (C) 1996-2015, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+******************************************************************************
+*/
+
+/**
+ * \file 
+ * \brief C++ API: Collation Service.
+ */
+ 
+/**
+* File coll.h
+*
+* Created by: Helena Shih
+*
+* Modification History:
+*
+*  Date        Name        Description
+* 02/5/97      aliu        Modified createDefault to load collation data from
+*                          binary files when possible.  Added related methods
+*                          createCollationFromFile, chopLocale, createPathName.
+* 02/11/97     aliu        Added members addToCache, findInCache, and fgCache.
+* 02/12/97     aliu        Modified to create objects from RuleBasedCollator cache.
+*                          Moved cache out of Collation class.
+* 02/13/97     aliu        Moved several methods out of this class and into
+*                          RuleBasedCollator, with modifications.  Modified
+*                          createDefault() to call new RuleBasedCollator(Locale&)
+*                          constructor.  General clean up and documentation.
+* 02/20/97     helena      Added clone, operator==, operator!=, operator=, copy
+*                          constructor and getDynamicClassID.
+* 03/25/97     helena      Updated with platform independent data types.
+* 05/06/97     helena      Added memory allocation error detection.
+* 06/20/97     helena      Java class name change.
+* 09/03/97     helena      Added createCollationKeyValues().
+* 02/10/98     damiba      Added compare() with length as parameter.
+* 04/23/99     stephen     Removed EDecompositionMode, merged with
+*                          Normalizer::EMode.
+* 11/02/99     helena      Collator performance enhancements.  Eliminates the
+*                          UnicodeString construction and special case for NO_OP.
+* 11/23/99     srl         More performance enhancements. Inlining of
+*                          critical accessors.
+* 05/15/00     helena      Added version information API.
+* 01/29/01     synwee      Modified into a C++ wrapper which calls C apis
+*                          (ucol.h).
+* 2012-2014    markus      Rewritten in C++ again.
+*/
+
+#ifndef COLL_H
+#define COLL_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_COLLATION
+
+#include "unicode/uobject.h"
+#include "unicode/ucol.h"
+#include "unicode/normlzr.h"
+#include "unicode/locid.h"
+#include "unicode/uniset.h"
+#include "unicode/umisc.h"
+#include "unicode/uiter.h"
+#include "unicode/stringpiece.h"
+
+U_NAMESPACE_BEGIN
+
+class StringEnumeration;
+
+#if !UCONFIG_NO_SERVICE
+/**
+ * @stable ICU 2.6
+ */
+class CollatorFactory;
+#endif
+
+/**
+* @stable ICU 2.0
+*/
+class CollationKey;
+
+/**
+* The <code>Collator</code> class performs locale-sensitive string
+* comparison.<br>
+* You use this class to build searching and sorting routines for natural
+* language text.
+* <p>
+* <code>Collator</code> is an abstract base class. Subclasses implement
+* specific collation strategies. One subclass,
+* <code>RuleBasedCollator</code>, is currently provided and is applicable
+* to a wide set of languages. Other subclasses may be created to handle more
+* specialized needs.
+* <p>
+* Like other locale-sensitive classes, you can use the static factory method,
+* <code>createInstance</code>, to obtain the appropriate
+* <code>Collator</code> object for a given locale. You will only need to
+* look at the subclasses of <code>Collator</code> if you need to
+* understand the details of a particular collation strategy or if you need to
+* modify that strategy.
+* <p>
+* The following example shows how to compare two strings using the
+* <code>Collator</code> for the default locale.
+* \htmlonly<blockquote>\endhtmlonly
+* <pre>
+* \code
+* // Compare two strings in the default locale
+* UErrorCode success = U_ZERO_ERROR;
+* Collator* myCollator = Collator::createInstance(success);
+* if (myCollator->compare("abc", "ABC") < 0)
+*   cout << "abc is less than ABC" << endl;
+* else
+*   cout << "abc is greater than or equal to ABC" << endl;
+* \endcode
+* </pre>
+* \htmlonly</blockquote>\endhtmlonly
+* <p>
+* You can set a <code>Collator</code>'s <em>strength</em> attribute to
+* determine the level of difference considered significant in comparisons.
+* Five strengths are provided: <code>PRIMARY</code>, <code>SECONDARY</code>,
+* <code>TERTIARY</code>, <code>QUATERNARY</code> and <code>IDENTICAL</code>.
+* The exact assignment of strengths to language features is locale dependent.
+* For example, in Czech, "e" and "f" are considered primary differences,
+* while "e" and "\u00EA" are secondary differences, "e" and "E" are tertiary
+* differences and "e" and "e" are identical. The following shows how both case
+* and accents could be ignored for US English.
+* \htmlonly<blockquote>\endhtmlonly
+* <pre>
+* \code
+* //Get the Collator for US English and set its strength to PRIMARY
+* UErrorCode success = U_ZERO_ERROR;
+* Collator* usCollator = Collator::createInstance(Locale::getUS(), success);
+* usCollator->setStrength(Collator::PRIMARY);
+* if (usCollator->compare("abc", "ABC") == 0)
+*     cout << "'abc' and 'ABC' strings are equivalent with strength PRIMARY" << endl;
+* \endcode
+* </pre>
+* \htmlonly</blockquote>\endhtmlonly
+*
+* The <code>getSortKey</code> methods
+* convert a string to a series of bytes that can be compared bitwise against
+* other sort keys using <code>strcmp()</code>. Sort keys are written as
+* zero-terminated byte strings.
+*
+* Another set of APIs returns a <code>CollationKey</code> object that wraps
+* the sort key bytes instead of returning the bytes themselves.
+* </p>
+* <p>
+* <strong>Note:</strong> <code>Collator</code>s with different Locale,
+* and CollationStrength settings will return different sort
+* orders for the same set of strings. Locales have specific collation rules,
+* and the way in which secondary and tertiary differences are taken into
+* account, for example, will result in a different sorting order for same
+* strings.
+* </p>
+* @see         RuleBasedCollator
+* @see         CollationKey
+* @see         CollationElementIterator
+* @see         Locale
+* @see         Normalizer
+* @version     2.0 11/15/01
+*/
+
+class U_I18N_API Collator : public UObject {
+public:
+
+    // Collator public enums -----------------------------------------------
+
+    /**
+     * Base letter represents a primary difference. Set comparison level to
+     * PRIMARY to ignore secondary and tertiary differences.<br>
+     * Use this to set the strength of a Collator object.<br>
+     * Example of primary difference, "abc" &lt; "abd"
+     *
+     * Diacritical differences on the same base letter represent a secondary
+     * difference. Set comparison level to SECONDARY to ignore tertiary
+     * differences. Use this to set the strength of a Collator object.<br>
+     * Example of secondary difference, "&auml;" >> "a".
+     *
+     * Uppercase and lowercase versions of the same character represents a
+     * tertiary difference.  Set comparison level to TERTIARY to include all
+     * comparison differences. Use this to set the strength of a Collator
+     * object.<br>
+     * Example of tertiary difference, "abc" &lt;&lt;&lt; "ABC".
+     *
+     * Two characters are considered "identical" when they have the same unicode
+     * spellings.<br>
+     * For example, "&auml;" == "&auml;".
+     *
+     * UCollationStrength is also used to determine the strength of sort keys
+     * generated from Collator objects.
+     * @stable ICU 2.0
+     */
+    enum ECollationStrength
+    {
+        PRIMARY    = UCOL_PRIMARY,  // 0
+        SECONDARY  = UCOL_SECONDARY,  // 1
+        TERTIARY   = UCOL_TERTIARY,  // 2
+        QUATERNARY = UCOL_QUATERNARY,  // 3
+        IDENTICAL  = UCOL_IDENTICAL  // 15
+    };
+
+    /**
+     * LESS is returned if source string is compared to be less than target
+     * string in the compare() method.
+     * EQUAL is returned if source string is compared to be equal to target
+     * string in the compare() method.
+     * GREATER is returned if source string is compared to be greater than
+     * target string in the compare() method.
+     * @see Collator#compare
+     * @deprecated ICU 2.6. Use C enum UCollationResult defined in ucol.h
+     */
+    enum EComparisonResult
+    {
+        LESS = UCOL_LESS,  // -1
+        EQUAL = UCOL_EQUAL,  // 0
+        GREATER = UCOL_GREATER  // 1
+    };
+
+    // Collator public destructor -----------------------------------------
+
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~Collator();
+
+    // Collator public methods --------------------------------------------
+
+    /**
+     * Returns TRUE if "other" is the same as "this".
+     *
+     * The base class implementation returns TRUE if "other" has the same type/class as "this":
+     * <code>typeid(*this) == typeid(other)</code>.
+     *
+     * Subclass implementations should do something like the following:
+     * <pre>
+     *   if (this == &other) { return TRUE; }
+     *   if (!Collator::operator==(other)) { return FALSE; }  // not the same class
+     *
+     *   const MyCollator &o = (const MyCollator&)other;
+     *   (compare this vs. o's subclass fields)
+     * </pre>
+     * @param other Collator object to be compared
+     * @return TRUE if other is the same as this.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Collator& other) const;
+
+    /**
+     * Returns true if "other" is not the same as "this".
+     * Calls ! operator==(const Collator&) const which works for all subclasses.
+     * @param other Collator object to be compared
+     * @return TRUE if other is not the same as this.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator!=(const Collator& other) const;
+
+    /**
+     * Makes a copy of this object.
+     * @return a copy of this object, owned by the caller
+     * @stable ICU 2.0
+     */
+    virtual Collator* clone(void) const = 0;
+
+    /**
+     * Creates the Collator object for the current default locale.
+     * The default locale is determined by Locale::getDefault.
+     * The UErrorCode& err parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check the
+     * value of U_SUCCESS(err).  If you wish more detailed information, you can
+     * check for informational error results which still indicate success.
+     * U_USING_FALLBACK_ERROR indicates that a fall back locale was used. For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used. U_USING_DEFAULT_ERROR indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     *
+     * @param err    the error code status.
+     * @return       the collation object of the default locale.(for example, en_US)
+     * @see Locale#getDefault
+     * @stable ICU 2.0
+     */
+    static Collator* U_EXPORT2 createInstance(UErrorCode&  err);
+
+    /**
+     * Gets the collation object for the desired locale. The
+     * resource of the desired locale will be loaded.
+     *
+     * Locale::getRoot() is the base collation table and all other languages are
+     * built on top of it with additional language-specific modifications.
+     *
+     * For some languages, multiple collation types are available;
+     * for example, "de@collation=phonebook".
+     * Starting with ICU 54, collation attributes can be specified via locale keywords as well,
+     * in the old locale extension syntax ("el@colCaseFirst=upper")
+     * or in language tag syntax ("el-u-kf-upper").
+     * See <a href="http://userguide.icu-project.org/collation/api">User Guide: Collation API</a>.
+     *
+     * The UErrorCode& err parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_ERROR indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_ERROR indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     *
+     * The caller owns the returned object and is responsible for deleting it.
+     * @param loc    The locale ID for which to open a collator.
+     * @param err    the error code status.
+     * @return       the created table-based collation object based on the desired
+     *               locale.
+     * @see Locale
+     * @see ResourceLoader
+     * @stable ICU 2.2
+     */
+    static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err);
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different strings. Returns information about whether a string is less
+     * than, greater than or equal to another string.
+     * @param source the source string to be compared with.
+     * @param target the string that is to be compared with the source string.
+     * @return Returns a byte value. GREATER if source is greater
+     * than target; EQUAL if source is equal to target; LESS if source is less
+     * than target
+     * @deprecated ICU 2.6 use the overload with UErrorCode &
+     */
+    virtual EComparisonResult compare(const UnicodeString& source,
+                                      const UnicodeString& target) const;
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different strings. Returns information about whether a string is less
+     * than, greater than or equal to another string.
+     * @param source the source string to be compared with.
+     * @param target the string that is to be compared with the source string.
+     * @param status possible error code
+     * @return Returns an enum value. UCOL_GREATER if source is greater
+     * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
+     * than target
+     * @stable ICU 2.6
+     */
+    virtual UCollationResult compare(const UnicodeString& source,
+                                      const UnicodeString& target,
+                                      UErrorCode &status) const = 0;
+
+    /**
+     * Does the same thing as compare but limits the comparison to a specified
+     * length
+     * @param source the source string to be compared with.
+     * @param target the string that is to be compared with the source string.
+     * @param length the length the comparison is limited to
+     * @return Returns a byte value. GREATER if source (up to the specified
+     *         length) is greater than target; EQUAL if source (up to specified
+     *         length) is equal to target; LESS if source (up to the specified
+     *         length) is less  than target.
+     * @deprecated ICU 2.6 use the overload with UErrorCode &
+     */
+    virtual EComparisonResult compare(const UnicodeString& source,
+                                      const UnicodeString& target,
+                                      int32_t length) const;
+
+    /**
+     * Does the same thing as compare but limits the comparison to a specified
+     * length
+     * @param source the source string to be compared with.
+     * @param target the string that is to be compared with the source string.
+     * @param length the length the comparison is limited to
+     * @param status possible error code
+     * @return Returns an enum value. UCOL_GREATER if source (up to the specified
+     *         length) is greater than target; UCOL_EQUAL if source (up to specified
+     *         length) is equal to target; UCOL_LESS if source (up to the specified
+     *         length) is less  than target.
+     * @stable ICU 2.6
+     */
+    virtual UCollationResult compare(const UnicodeString& source,
+                                      const UnicodeString& target,
+                                      int32_t length,
+                                      UErrorCode &status) const = 0;
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different string arrays. Returns information about whether a string array
+     * is less than, greater than or equal to another string array.
+     * <p>Example of use:
+     * <pre>
+     * .       UChar ABC[] = {0x41, 0x42, 0x43, 0};  // = "ABC"
+     * .       UChar abc[] = {0x61, 0x62, 0x63, 0};  // = "abc"
+     * .       UErrorCode status = U_ZERO_ERROR;
+     * .       Collator *myCollation =
+     * .                         Collator::createInstance(Locale::getUS(), status);
+     * .       if (U_FAILURE(status)) return;
+     * .       myCollation->setStrength(Collator::PRIMARY);
+     * .       // result would be Collator::EQUAL ("abc" == "ABC")
+     * .       // (no primary difference between "abc" and "ABC")
+     * .       Collator::EComparisonResult result =
+     * .                             myCollation->compare(abc, 3, ABC, 3);
+     * .       myCollation->setStrength(Collator::TERTIARY);
+     * .       // result would be Collator::LESS ("abc" &lt;&lt;&lt; "ABC")
+     * .       // (with tertiary difference between "abc" and "ABC")
+     * .       result = myCollation->compare(abc, 3, ABC, 3);
+     * </pre>
+     * @param source the source string array to be compared with.
+     * @param sourceLength the length of the source string array.  If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @param target the string that is to be compared with the source string.
+     * @param targetLength the length of the target string array.  If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @return Returns a byte value. GREATER if source is greater than target;
+     *         EQUAL if source is equal to target; LESS if source is less than
+     *         target
+     * @deprecated ICU 2.6 use the overload with UErrorCode &
+     */
+    virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
+                                      const UChar* target, int32_t targetLength)
+                                      const;
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different string arrays. Returns information about whether a string array
+     * is less than, greater than or equal to another string array.
+     * @param source the source string array to be compared with.
+     * @param sourceLength the length of the source string array.  If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @param target the string that is to be compared with the source string.
+     * @param targetLength the length of the target string array.  If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @param status possible error code
+     * @return Returns an enum value. UCOL_GREATER if source is greater
+     * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
+     * than target
+     * @stable ICU 2.6
+     */
+    virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
+                                      const UChar* target, int32_t targetLength,
+                                      UErrorCode &status) const = 0;
+
+    /**
+     * Compares two strings using the Collator.
+     * Returns whether the first one compares less than/equal to/greater than
+     * the second one.
+     * This version takes UCharIterator input.
+     * @param sIter the first ("source") string iterator
+     * @param tIter the second ("target") string iterator
+     * @param status ICU status
+     * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER
+     * @stable ICU 4.2
+     */
+    virtual UCollationResult compare(UCharIterator &sIter,
+                                     UCharIterator &tIter,
+                                     UErrorCode &status) const;
+
+    /**
+     * Compares two UTF-8 strings using the Collator.
+     * Returns whether the first one compares less than/equal to/greater than
+     * the second one.
+     * This version takes UTF-8 input.
+     * Note that a StringPiece can be implicitly constructed
+     * from a std::string or a NUL-terminated const char * string.
+     * @param source the first UTF-8 string
+     * @param target the second UTF-8 string
+     * @param status ICU status
+     * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER
+     * @stable ICU 4.2
+     */
+    virtual UCollationResult compareUTF8(const StringPiece &source,
+                                         const StringPiece &target,
+                                         UErrorCode &status) const;
+
+    /**
+     * Transforms the string into a series of characters that can be compared
+     * with CollationKey::compareTo. It is not possible to restore the original
+     * string from the chars in the sort key.
+     * <p>Use CollationKey::equals or CollationKey::compare to compare the
+     * generated sort keys.
+     * If the source string is null, a null collation key will be returned.
+     *
+     * Note that sort keys are often less efficient than simply doing comparison.  
+     * For more details, see the ICU User Guide.
+     *
+     * @param source the source string to be transformed into a sort key.
+     * @param key the collation key to be filled in
+     * @param status the error code status.
+     * @return the collation key of the string based on the collation rules.
+     * @see CollationKey#compare
+     * @stable ICU 2.0
+     */
+    virtual CollationKey& getCollationKey(const UnicodeString&  source,
+                                          CollationKey& key,
+                                          UErrorCode& status) const = 0;
+
+    /**
+     * Transforms the string into a series of characters that can be compared
+     * with CollationKey::compareTo. It is not possible to restore the original
+     * string from the chars in the sort key.
+     * <p>Use CollationKey::equals or CollationKey::compare to compare the
+     * generated sort keys.
+     * <p>If the source string is null, a null collation key will be returned.
+     *
+     * Note that sort keys are often less efficient than simply doing comparison.  
+     * For more details, see the ICU User Guide.
+     *
+     * @param source the source string to be transformed into a sort key.
+     * @param sourceLength length of the collation key
+     * @param key the collation key to be filled in
+     * @param status the error code status.
+     * @return the collation key of the string based on the collation rules.
+     * @see CollationKey#compare
+     * @stable ICU 2.0
+     */
+    virtual CollationKey& getCollationKey(const UChar*source,
+                                          int32_t sourceLength,
+                                          CollationKey& key,
+                                          UErrorCode& status) const = 0;
+    /**
+     * Generates the hash code for the collation object
+     * @stable ICU 2.0
+     */
+    virtual int32_t hashCode(void) const = 0;
+
+    /**
+     * Gets the locale of the Collator
+     *
+     * @param type can be either requested, valid or actual locale. For more
+     *             information see the definition of ULocDataLocaleType in
+     *             uloc.h
+     * @param status the error code status.
+     * @return locale where the collation data lives. If the collator
+     *         was instantiated from rules, locale is empty.
+     * @deprecated ICU 2.8 This API is under consideration for revision
+     * in ICU 3.0.
+     */
+    virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;
+
+    /**
+     * Convenience method for comparing two strings based on the collation rules.
+     * @param source the source string to be compared with.
+     * @param target the target string to be compared with.
+     * @return true if the first string is greater than the second one,
+     *         according to the collation rules. false, otherwise.
+     * @see Collator#compare
+     * @stable ICU 2.0
+     */
+    UBool greater(const UnicodeString& source, const UnicodeString& target)
+                  const;
+
+    /**
+     * Convenience method for comparing two strings based on the collation rules.
+     * @param source the source string to be compared with.
+     * @param target the target string to be compared with.
+     * @return true if the first string is greater than or equal to the second
+     *         one, according to the collation rules. false, otherwise.
+     * @see Collator#compare
+     * @stable ICU 2.0
+     */
+    UBool greaterOrEqual(const UnicodeString& source,
+                         const UnicodeString& target) const;
+
+    /**
+     * Convenience method for comparing two strings based on the collation rules.
+     * @param source the source string to be compared with.
+     * @param target the target string to be compared with.
+     * @return true if the strings are equal according to the collation rules.
+     *         false, otherwise.
+     * @see Collator#compare
+     * @stable ICU 2.0
+     */
+    UBool equals(const UnicodeString& source, const UnicodeString& target) const;
+
+    /**
+     * Determines the minimum strength that will be used in comparison or
+     * transformation.
+     * <p>E.g. with strength == SECONDARY, the tertiary difference is ignored
+     * <p>E.g. with strength == PRIMARY, the secondary and tertiary difference
+     * are ignored.
+     * @return the current comparison level.
+     * @see Collator#setStrength
+     * @deprecated ICU 2.6 Use getAttribute(UCOL_STRENGTH...) instead
+     */
+    virtual ECollationStrength getStrength(void) const;
+
+    /**
+     * Sets the minimum strength to be used in comparison or transformation.
+     * <p>Example of use:
+     * <pre>
+     *  \code
+     *  UErrorCode status = U_ZERO_ERROR;
+     *  Collator*myCollation = Collator::createInstance(Locale::getUS(), status);
+     *  if (U_FAILURE(status)) return;
+     *  myCollation->setStrength(Collator::PRIMARY);
+     *  // result will be "abc" == "ABC"
+     *  // tertiary differences will be ignored
+     *  Collator::ComparisonResult result = myCollation->compare("abc", "ABC");
+     * \endcode
+     * </pre>
+     * @see Collator#getStrength
+     * @param newStrength the new comparison level.
+     * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead
+     */
+    virtual void setStrength(ECollationStrength newStrength);
+
+    /**
+     * Retrieves the reordering codes for this collator.
+     * @param dest The array to fill with the script ordering.
+     * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function
+     *  will only return the length of the result without writing any codes (pre-flighting).
+     * @param status A reference to an error code value, which must not indicate
+     * a failure before the function call.
+     * @return The length of the script ordering array.
+     * @see ucol_setReorderCodes
+     * @see Collator#getEquivalentReorderCodes
+     * @see Collator#setReorderCodes
+     * @see UScriptCode
+     * @see UColReorderCode
+     * @stable ICU 4.8 
+     */
+     virtual int32_t getReorderCodes(int32_t *dest,
+                                     int32_t destCapacity,
+                                     UErrorCode& status) const;
+
+    /**
+     * Sets the ordering of scripts for this collator.
+     *
+     * <p>The reordering codes are a combination of script codes and reorder codes.
+     * @param reorderCodes An array of script codes in the new order. This can be NULL if the 
+     * length is also set to 0. An empty array will clear any reordering codes on the collator.
+     * @param reorderCodesLength The length of reorderCodes.
+     * @param status error code
+     * @see ucol_setReorderCodes
+     * @see Collator#getReorderCodes
+     * @see Collator#getEquivalentReorderCodes
+     * @see UScriptCode
+     * @see UColReorderCode
+     * @stable ICU 4.8 
+     */
+     virtual void setReorderCodes(const int32_t* reorderCodes,
+                                  int32_t reorderCodesLength,
+                                  UErrorCode& status) ;
+
+    /**
+     * Retrieves the reorder codes that are grouped with the given reorder code. Some reorder
+     * codes will be grouped and must reorder together.
+     * Beginning with ICU 55, scripts only reorder together if they are primary-equal,
+     * for example Hiragana and Katakana.
+     *
+     * @param reorderCode The reorder code to determine equivalence for. 
+     * @param dest The array to fill with the script equivalence reordering codes.
+     * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the 
+     * function will only return the length of the result without writing any codes (pre-flighting).
+     * @param status A reference to an error code value, which must not indicate 
+     * a failure before the function call.
+     * @return The length of the of the reordering code equivalence array.
+     * @see ucol_setReorderCodes
+     * @see Collator#getReorderCodes
+     * @see Collator#setReorderCodes
+     * @see UScriptCode
+     * @see UColReorderCode
+     * @stable ICU 4.8 
+     */
+    static int32_t U_EXPORT2 getEquivalentReorderCodes(int32_t reorderCode,
+                                int32_t* dest,
+                                int32_t destCapacity,
+                                UErrorCode& status);
+
+    /**
+     * Get name of the object for the desired Locale, in the desired langauge
+     * @param objectLocale must be from getAvailableLocales
+     * @param displayLocale specifies the desired locale for output
+     * @param name the fill-in parameter of the return value
+     * @return display-able name of the object for the object locale in the
+     *         desired language
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
+                                         const Locale& displayLocale,
+                                         UnicodeString& name);
+
+    /**
+    * Get name of the object for the desired Locale, in the langauge of the
+    * default locale.
+    * @param objectLocale must be from getAvailableLocales
+    * @param name the fill-in parameter of the return value
+    * @return name of the object for the desired locale in the default language
+    * @stable ICU 2.0
+    */
+    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
+                                         UnicodeString& name);
+
+    /**
+     * Get the set of Locales for which Collations are installed.
+     *
+     * <p>Note this does not include locales supported by registered collators.
+     * If collators might have been registered, use the overload of getAvailableLocales
+     * that returns a StringEnumeration.</p>
+     *
+     * @param count the output parameter of number of elements in the locale list
+     * @return the list of available locales for which collations are installed
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+    /**
+     * Return a StringEnumeration over the locales available at the time of the call,
+     * including registered locales.  If a severe error occurs (such as out of memory
+     * condition) this will return null. If there is no locale data, an empty enumeration
+     * will be returned.
+     * @return a StringEnumeration over the locales available at the time of the call
+     * @stable ICU 2.6
+     */
+    static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
+
+    /**
+     * Create a string enumerator of all possible keywords that are relevant to
+     * collation. At this point, the only recognized keyword for this
+     * service is "collation".
+     * @param status input-output error code
+     * @return a string enumeration over locale strings. The caller is
+     * responsible for closing the result.
+     * @stable ICU 3.0
+     */
+    static StringEnumeration* U_EXPORT2 getKeywords(UErrorCode& status);
+
+    /**
+     * Given a keyword, create a string enumeration of all values
+     * for that keyword that are currently in use.
+     * @param keyword a particular keyword as enumerated by
+     * ucol_getKeywords. If any other keyword is passed in, status is set
+     * to U_ILLEGAL_ARGUMENT_ERROR.
+     * @param status input-output error code
+     * @return a string enumeration over collation keyword values, or NULL
+     * upon error. The caller is responsible for deleting the result.
+     * @stable ICU 3.0
+     */
+    static StringEnumeration* U_EXPORT2 getKeywordValues(const char *keyword, UErrorCode& status);
+
+    /**
+     * Given a key and a locale, returns an array of string values in a preferred
+     * order that would make a difference. These are all and only those values where
+     * the open (creation) of the service with the locale formed from the input locale
+     * plus input keyword and that value has different behavior than creation with the
+     * input locale alone.
+     * @param keyword        one of the keys supported by this service.  For now, only
+     *                      "collation" is supported.
+     * @param locale        the locale
+     * @param commonlyUsed  if set to true it will return only commonly used values
+     *                      with the given locale in preferred order.  Otherwise,
+     *                      it will return all the available values for the locale.
+     * @param status ICU status
+     * @return a string enumeration over keyword values for the given key and the locale.
+     * @stable ICU 4.2
+     */
+    static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* keyword, const Locale& locale,
+                                                                    UBool commonlyUsed, UErrorCode& status);
+
+    /**
+     * Return the functionally equivalent locale for the given
+     * requested locale, with respect to given keyword, for the
+     * collation service.  If two locales return the same result, then
+     * collators instantiated for these locales will behave
+     * equivalently.  The converse is not always true; two collators
+     * may in fact be equivalent, but return different results, due to
+     * internal details.  The return result has no other meaning than
+     * that stated above, and implies nothing as to the relationship
+     * between the two locales.  This is intended for use by
+     * applications who wish to cache collators, or otherwise reuse
+     * collators when possible.  The functional equivalent may change
+     * over time.  For more information, please see the <a
+     * href="http://userguide.icu-project.org/locale#TOC-Locales-and-Services">
+     * Locales and Services</a> section of the ICU User Guide.
+     * @param keyword a particular keyword as enumerated by
+     * ucol_getKeywords.
+     * @param locale the requested locale
+     * @param isAvailable reference to a fillin parameter that
+     * indicates whether the requested locale was 'available' to the
+     * collation service. A locale is defined as 'available' if it
+     * physically exists within the collation locale data.
+     * @param status reference to input-output error code
+     * @return the functionally equivalent collation locale, or the root
+     * locale upon error.
+     * @stable ICU 3.0
+     */
+    static Locale U_EXPORT2 getFunctionalEquivalent(const char* keyword, const Locale& locale,
+                                          UBool& isAvailable, UErrorCode& status);
+
+#if !UCONFIG_NO_SERVICE
+    /**
+     * Register a new Collator.  The collator will be adopted.
+     * Because ICU may choose to cache collators internally, this must be
+     * called at application startup, prior to any calls to
+     * Collator::createInstance to avoid undefined behavior.
+     * @param toAdopt the Collator instance to be adopted
+     * @param locale the locale with which the collator will be associated
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this collator
+     * @stable ICU 2.6
+     */
+    static URegistryKey U_EXPORT2 registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode& status);
+
+    /**
+     * Register a new CollatorFactory.  The factory will be adopted.
+     * Because ICU may choose to cache collators internally, this must be
+     * called at application startup, prior to any calls to
+     * Collator::createInstance to avoid undefined behavior.
+     * @param toAdopt the CollatorFactory instance to be adopted
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this collator
+     * @stable ICU 2.6
+     */
+    static URegistryKey U_EXPORT2 registerFactory(CollatorFactory* toAdopt, UErrorCode& status);
+
+    /**
+     * Unregister a previously-registered Collator or CollatorFactory
+     * using the key returned from the register call.  Key becomes
+     * invalid after a successful call and should not be used again.
+     * The object corresponding to the key will be deleted.
+     * Because ICU may choose to cache collators internally, this should
+     * be called during application shutdown, after all calls to
+     * Collator::createInstance to avoid undefined behavior.
+     * @param key the registry key returned by a previous call to registerInstance
+     * @param status the in/out status code, no special meanings are assigned
+     * @return TRUE if the collator for the key was successfully unregistered
+     * @stable ICU 2.6
+     */
+    static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
+#endif /* UCONFIG_NO_SERVICE */
+
+    /**
+     * Gets the version information for a Collator.
+     * @param info the version # information, the result will be filled in
+     * @stable ICU 2.0
+     */
+    virtual void getVersion(UVersionInfo info) const = 0;
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual method.
+     * This method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     * @return The class ID for this object. All objects of a given class have
+     *         the same class ID.  Objects of other classes have different class
+     *         IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+    /**
+     * Universal attribute setter
+     * @param attr attribute type
+     * @param value attribute value
+     * @param status to indicate whether the operation went on smoothly or
+     *        there were errors
+     * @stable ICU 2.2
+     */
+    virtual void setAttribute(UColAttribute attr, UColAttributeValue value,
+                              UErrorCode &status) = 0;
+
+    /**
+     * Universal attribute getter
+     * @param attr attribute type
+     * @param status to indicate whether the operation went on smoothly or
+     *        there were errors
+     * @return attribute value
+     * @stable ICU 2.2
+     */
+    virtual UColAttributeValue getAttribute(UColAttribute attr,
+                                            UErrorCode &status) const = 0;
+
+    /**
+     * Sets the variable top to the top of the specified reordering group.
+     * The variable top determines the highest-sorting character
+     * which is affected by UCOL_ALTERNATE_HANDLING.
+     * If that attribute is set to UCOL_NON_IGNORABLE, then the variable top has no effect.
+     *
+     * The base class implementation sets U_UNSUPPORTED_ERROR.
+     * @param group one of UCOL_REORDER_CODE_SPACE, UCOL_REORDER_CODE_PUNCTUATION,
+     *              UCOL_REORDER_CODE_SYMBOL, UCOL_REORDER_CODE_CURRENCY;
+     *              or UCOL_REORDER_CODE_DEFAULT to restore the default max variable group
+     * @param errorCode Standard ICU error code. Its input value must
+     *                  pass the U_SUCCESS() test, or else the function returns
+     *                  immediately. Check for U_FAILURE() on output or use with
+     *                  function chaining. (See User Guide for details.)
+     * @return *this
+     * @see getMaxVariable
+     * @stable ICU 53
+     */
+    virtual Collator &setMaxVariable(UColReorderCode group, UErrorCode &errorCode);
+
+    /**
+     * Returns the maximum reordering group whose characters are affected by UCOL_ALTERNATE_HANDLING.
+     *
+     * The base class implementation returns UCOL_REORDER_CODE_PUNCTUATION.
+     * @return the maximum variable reordering group.
+     * @see setMaxVariable
+     * @stable ICU 53
+     */
+    virtual UColReorderCode getMaxVariable() const;
+
+    /**
+     * Sets the variable top to the primary weight of the specified string.
+     *
+     * Beginning with ICU 53, the variable top is pinned to
+     * the top of one of the supported reordering groups,
+     * and it must not be beyond the last of those groups.
+     * See setMaxVariable().
+     * @param varTop one or more (if contraction) UChars to which the variable top should be set
+     * @param len length of variable top string. If -1 it is considered to be zero terminated.
+     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
+     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
+     *    U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
+     *    the last reordering group supported by setMaxVariable()
+     * @return variable top primary weight
+     * @deprecated ICU 53 Call setMaxVariable() instead.
+     */
+    virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
+
+    /**
+     * Sets the variable top to the primary weight of the specified string.
+     *
+     * Beginning with ICU 53, the variable top is pinned to
+     * the top of one of the supported reordering groups,
+     * and it must not be beyond the last of those groups.
+     * See setMaxVariable().
+     * @param varTop a UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set
+     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
+     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br>
+     *    U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond
+     *    the last reordering group supported by setMaxVariable()
+     * @return variable top primary weight
+     * @deprecated ICU 53 Call setMaxVariable() instead.
+     */
+    virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &status) = 0;
+
+    /**
+     * Sets the variable top to the specified primary weight.
+     *
+     * Beginning with ICU 53, the variable top is pinned to
+     * the top of one of the supported reordering groups,
+     * and it must not be beyond the last of those groups.
+     * See setMaxVariable().
+     * @param varTop primary weight, as returned by setVariableTop or ucol_getVariableTop
+     * @param status error code
+     * @deprecated ICU 53 Call setMaxVariable() instead.
+     */
+    virtual void setVariableTop(uint32_t varTop, UErrorCode &status) = 0;
+
+    /**
+     * Gets the variable top value of a Collator.
+     * @param status error code (not changed by function). If error code is set, the return value is undefined.
+     * @return the variable top primary weight
+     * @see getMaxVariable
+     * @stable ICU 2.0
+     */
+    virtual uint32_t getVariableTop(UErrorCode &status) const = 0;
+
+    /**
+     * Get a UnicodeSet that contains all the characters and sequences
+     * tailored in this collator.
+     * @param status      error code of the operation
+     * @return a pointer to a UnicodeSet object containing all the
+     *         code points and sequences that may sort differently than
+     *         in the root collator. The object must be disposed of by using delete
+     * @stable ICU 2.4
+     */
+    virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
+
+    /**
+     * Same as clone().
+     * The base class implementation simply calls clone().
+     * @return a copy of this object, owned by the caller
+     * @see clone()
+     * @deprecated ICU 50 no need to have two methods for cloning
+     */
+    virtual Collator* safeClone(void) const;
+
+    /**
+     * Get the sort key as an array of bytes from a UnicodeString.
+     * Sort key byte arrays are zero-terminated and can be compared using
+     * strcmp().
+     *
+     * Note that sort keys are often less efficient than simply doing comparison.  
+     * For more details, see the ICU User Guide.
+     *
+     * @param source string to be processed.
+     * @param result buffer to store result in. If NULL, number of bytes needed
+     *        will be returned.
+     * @param resultLength length of the result buffer. If if not enough the
+     *        buffer will be filled to capacity.
+     * @return Number of bytes needed for storing the sort key
+     * @stable ICU 2.2
+     */
+    virtual int32_t getSortKey(const UnicodeString& source,
+                              uint8_t* result,
+                              int32_t resultLength) const = 0;
+
+    /**
+     * Get the sort key as an array of bytes from a UChar buffer.
+     * Sort key byte arrays are zero-terminated and can be compared using
+     * strcmp().
+     *
+     * Note that sort keys are often less efficient than simply doing comparison.  
+     * For more details, see the ICU User Guide.
+     *
+     * @param source string to be processed.
+     * @param sourceLength length of string to be processed.
+     *        If -1, the string is 0 terminated and length will be decided by the
+     *        function.
+     * @param result buffer to store result in. If NULL, number of bytes needed
+     *        will be returned.
+     * @param resultLength length of the result buffer. If if not enough the
+     *        buffer will be filled to capacity.
+     * @return Number of bytes needed for storing the sort key
+     * @stable ICU 2.2
+     */
+    virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
+                               uint8_t*result, int32_t resultLength) const = 0;
+
+    /**
+     * Produce a bound for a given sortkey and a number of levels.
+     * Return value is always the number of bytes needed, regardless of
+     * whether the result buffer was big enough or even valid.<br>
+     * Resulting bounds can be used to produce a range of strings that are
+     * between upper and lower bounds. For example, if bounds are produced
+     * for a sortkey of string "smith", strings between upper and lower
+     * bounds with one level would include "Smith", "SMITH", "sMiTh".<br>
+     * There are two upper bounds that can be produced. If UCOL_BOUND_UPPER
+     * is produced, strings matched would be as above. However, if bound
+     * produced using UCOL_BOUND_UPPER_LONG is used, the above example will
+     * also match "Smithsonian" and similar.<br>
+     * For more on usage, see example in cintltst/capitst.c in procedure
+     * TestBounds.
+     * Sort keys may be compared using <TT>strcmp</TT>.
+     * @param source The source sortkey.
+     * @param sourceLength The length of source, or -1 if null-terminated.
+     *                     (If an unmodified sortkey is passed, it is always null
+     *                      terminated).
+     * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which
+     *                  produces a lower inclusive bound, UCOL_BOUND_UPPER, that
+     *                  produces upper bound that matches strings of the same length
+     *                  or UCOL_BOUND_UPPER_LONG that matches strings that have the
+     *                  same starting substring as the source string.
+     * @param noOfLevels  Number of levels required in the resulting bound (for most
+     *                    uses, the recommended value is 1). See users guide for
+     *                    explanation on number of levels a sortkey can have.
+     * @param result A pointer to a buffer to receive the resulting sortkey.
+     * @param resultLength The maximum size of result.
+     * @param status Used for returning error code if something went wrong. If the
+     *               number of levels requested is higher than the number of levels
+     *               in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is
+     *               issued.
+     * @return The size needed to fully store the bound.
+     * @see ucol_keyHashCode
+     * @stable ICU 2.1
+     */
+    static int32_t U_EXPORT2 getBound(const uint8_t       *source,
+            int32_t             sourceLength,
+            UColBoundMode       boundType,
+            uint32_t            noOfLevels,
+            uint8_t             *result,
+            int32_t             resultLength,
+            UErrorCode          &status);
+
+
+protected:
+
+    // Collator protected constructors -------------------------------------
+
+    /**
+    * Default constructor.
+    * Constructor is different from the old default Collator constructor.
+    * The task for determing the default collation strength and normalization
+    * mode is left to the child class.
+    * @stable ICU 2.0
+    */
+    Collator();
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+    * Constructor.
+    * Empty constructor, does not handle the arguments.
+    * This constructor is done for backward compatibility with 1.7 and 1.8.
+    * The task for handling the argument collation strength and normalization
+    * mode is left to the child class.
+    * @param collationStrength collation strength
+    * @param decompositionMode
+    * @deprecated ICU 2.4. Subclasses should use the default constructor
+    * instead and handle the strength and normalization mode themselves.
+    */
+    Collator(UCollationStrength collationStrength,
+             UNormalizationMode decompositionMode);
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+    * Copy constructor.
+    * @param other Collator object to be copied from
+    * @stable ICU 2.0
+    */
+    Collator(const Collator& other);
+
+public:
+   /**
+    * Used internally by registration to define the requested and valid locales.
+    * @param requestedLocale the requested locale
+    * @param validLocale the valid locale
+    * @param actualLocale the actual locale
+    * @internal
+    */
+    virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale);
+
+    /** Get the short definition string for a collator. This internal API harvests the collator's
+     *  locale and the attribute set and produces a string that can be used for opening 
+     *  a collator with the same attributes using the ucol_openFromShortString API.
+     *  This string will be normalized.
+     *  The structure and the syntax of the string is defined in the "Naming collators"
+     *  section of the users guide: 
+     *  http://userguide.icu-project.org/collation/concepts#TOC-Collator-naming-scheme
+     *  This function supports preflighting.
+     * 
+     *  This is internal, and intended to be used with delegate converters.
+     *
+     *  @param locale a locale that will appear as a collators locale in the resulting
+     *                short string definition. If NULL, the locale will be harvested 
+     *                from the collator.
+     *  @param buffer space to hold the resulting string
+     *  @param capacity capacity of the buffer
+     *  @param status for returning errors. All the preflighting errors are featured
+     *  @return length of the resulting string
+     *  @see ucol_openFromShortString
+     *  @see ucol_normalizeShortDefinitionString
+     *  @see ucol_getShortDefinitionString
+     *  @internal
+     */
+    virtual int32_t internalGetShortDefinitionString(const char *locale,
+                                                     char *buffer,
+                                                     int32_t capacity,
+                                                     UErrorCode &status) const;
+
+    /**
+     * Implements ucol_strcollUTF8().
+     * @internal
+     */
+    virtual UCollationResult internalCompareUTF8(
+            const char *left, int32_t leftLength,
+            const char *right, int32_t rightLength,
+            UErrorCode &errorCode) const;
+
+    /**
+     * Implements ucol_nextSortKeyPart().
+     * @internal
+     */
+    virtual int32_t
+    internalNextSortKeyPart(
+            UCharIterator *iter, uint32_t state[2],
+            uint8_t *dest, int32_t count, UErrorCode &errorCode) const;
+
+#ifndef U_HIDE_INTERNAL_API
+    /** @internal */
+    static inline Collator *fromUCollator(UCollator *uc) {
+        return reinterpret_cast<Collator *>(uc);
+    }
+    /** @internal */
+    static inline const Collator *fromUCollator(const UCollator *uc) {
+        return reinterpret_cast<const Collator *>(uc);
+    }
+    /** @internal */
+    inline UCollator *toUCollator() {
+        return reinterpret_cast<UCollator *>(this);
+    }
+    /** @internal */
+    inline const UCollator *toUCollator() const {
+        return reinterpret_cast<const UCollator *>(this);
+    }
+#endif  // U_HIDE_INTERNAL_API
+
+private:
+    /**
+     * Assignment operator. Private for now.
+     */
+    Collator& operator=(const Collator& other);
+
+    friend class CFactory;
+    friend class SimpleCFactory;
+    friend class ICUCollatorFactory;
+    friend class ICUCollatorService;
+    static Collator* makeInstance(const Locale& desiredLocale,
+                                  UErrorCode& status);
+};
+
+#if !UCONFIG_NO_SERVICE
+/**
+ * A factory, used with registerFactory, the creates multiple collators and provides
+ * display names for them.  A factory supports some number of locales-- these are the
+ * locales for which it can create collators.  The factory can be visible, in which
+ * case the supported locales will be enumerated by getAvailableLocales, or invisible,
+ * in which they are not.  Invisible locales are still supported, they are just not
+ * listed by getAvailableLocales.
+ * <p>
+ * If standard locale display names are sufficient, Collator instances can
+ * be registered using registerInstance instead.</p>
+ * <p>
+ * Note: if the collators are to be used from C APIs, they must be instances
+ * of RuleBasedCollator.</p>
+ *
+ * @stable ICU 2.6
+ */
+class U_I18N_API CollatorFactory : public UObject {
+public:
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~CollatorFactory();
+
+    /**
+     * Return true if this factory is visible.  Default is true.
+     * If not visible, the locales supported by this factory will not
+     * be listed by getAvailableLocales.
+     * @return true if the factory is visible.
+     * @stable ICU 2.6
+     */
+    virtual UBool visible(void) const;
+
+    /**
+     * Return a collator for the provided locale.  If the locale
+     * is not supported, return NULL.
+     * @param loc the locale identifying the collator to be created.
+     * @return a new collator if the locale is supported, otherwise NULL.
+     * @stable ICU 2.6
+     */
+    virtual Collator* createCollator(const Locale& loc) = 0;
+
+    /**
+     * Return the name of the collator for the objectLocale, localized for the displayLocale.
+     * If objectLocale is not supported, or the factory is not visible, set the result string
+     * to bogus.
+     * @param objectLocale the locale identifying the collator
+     * @param displayLocale the locale for which the display name of the collator should be localized
+     * @param result an output parameter for the display name, set to bogus if not supported.
+     * @return the display name
+     * @stable ICU 2.6
+     */
+    virtual  UnicodeString& getDisplayName(const Locale& objectLocale,
+                                           const Locale& displayLocale,
+                                           UnicodeString& result);
+
+    /**
+     * Return an array of all the locale names directly supported by this factory.
+     * The number of names is returned in count.  This array is owned by the factory.
+     * Its contents must never change.
+     * @param count output parameter for the number of locales supported by the factory
+     * @param status the in/out error code
+     * @return a pointer to an array of count UnicodeStrings.
+     * @stable ICU 2.6
+     */
+    virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) = 0;
+};
+#endif /* UCONFIG_NO_SERVICE */
+
+// Collator inline methods -----------------------------------------------
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif

+ 330 - 0
sqlite/unicode/compactdecimalformat.h

@@ -0,0 +1,330 @@
+/*
+********************************************************************************
+*   Copyright (C) 2012-2014, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File COMPACTDECIMALFORMAT.H
+********************************************************************************
+*/
+
+#ifndef __COMPACT_DECIMAL_FORMAT_H__
+#define __COMPACT_DECIMAL_FORMAT_H__
+
+#include "unicode/utypes.h"
+/**
+ * \file
+ * \brief C++ API: Formats decimal numbers in compact form.
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/decimfmt.h"
+
+struct UHashtable;
+
+U_NAMESPACE_BEGIN
+
+class PluralRules;
+
+/**
+ * The CompactDecimalFormat produces abbreviated numbers, suitable for display in
+ * environments will limited real estate. For example, 'Hits: 1.2B' instead of
+ * 'Hits: 1,200,000,000'. The format will be appropriate for the given language,
+ * such as "1,2 Mrd." for German.
+ * <p>
+ * For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345),
+ * the result will be short for supported languages. However, the result may
+ * sometimes exceed 7 characters, such as when there are combining marks or thin
+ * characters. In such cases, the visual width in fonts should still be short.
+ * <p>
+ * By default, there are 3 significant digits. After creation, if more than
+ * three significant digits are set (with setMaximumSignificantDigits), or if a
+ * fixed number of digits are set (with setMaximumIntegerDigits or
+ * setMaximumFractionDigits), then result may be wider.
+ * <p>
+ * At this time, parsing is not supported, and will produce a U_UNSUPPORTED_ERROR.
+ * Resetting the pattern prefixes or suffixes is not supported; the method calls
+ * are ignored.
+ * <p>
+ * @stable ICU 51
+ */
+class U_I18N_API CompactDecimalFormat : public DecimalFormat {
+public:
+
+     /**
+      * Returns a compact decimal instance for specified locale.
+      * @param inLocale the given locale.
+      * @param style whether to use short or long style.
+      * @param status error code returned  here.
+      * @stable ICU 51
+      */
+     static CompactDecimalFormat* U_EXPORT2 createInstance(
+          const Locale& inLocale, UNumberCompactStyle style, UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     *
+     * @param source    the DecimalFormat object to be copied from.
+     * @stable ICU 51
+      */
+    CompactDecimalFormat(const CompactDecimalFormat& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 51
+     */
+    virtual ~CompactDecimalFormat();
+
+    /**
+     * Assignment operator.
+     *
+     * @param rhs    the DecimalFormat object to be copied.
+     * @stable ICU 51
+     */
+    CompactDecimalFormat& operator=(const CompactDecimalFormat& rhs);
+
+    /**
+     * Clone this Format object polymorphically. The caller owns the
+     * result and should delete it when done.
+     *
+     * @return    a polymorphic copy of this CompactDecimalFormat.
+     * @stable ICU 51
+     */
+    virtual Format* clone() const;
+
+    /**
+     * Return TRUE if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     *
+     * @param other    the object to be compared with.
+     * @return         TRUE if the given Format objects are semantically equal.
+     * @stable ICU 51
+     */
+    virtual UBool operator==(const Format& other) const;
+
+
+    using DecimalFormat::format;
+
+    /**
+     * Format a double or long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 51
+     */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Format a double or long number using base-10 representation.
+     * Currently sets status to U_UNSUPPORTED_ERROR.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     *                  Can be NULL.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format an int64 number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 51
+     */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Format an int64 number using base-10 representation.
+     * Currently sets status to U_UNSUPPORTED_ERROR
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     *                  Can be NULL.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR
+     * The syntax of the unformatted number is a "numeric string"
+     * as defined in the Decimal Arithmetic Specification, available at
+     * http://speleotrove.com/decimal
+     *
+     * @param number    The unformatted number, as a string.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     *                  Can be NULL.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(const StringPiece &number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR
+     * The number is a DigitList wrapper onto a floating point decimal number.
+     * The default implementation in NumberFormat converts the decimal number
+     * to a double and formats that.
+     *
+     * @param number    The number, a DigitList format Decimal Floating Point.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(const DigitList &number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR.
+     * The number is a DigitList wrapper onto a floating point decimal number.
+     * The default implementation in NumberFormat converts the decimal number
+     * to a double and formats that.  
+     *
+     * @param number    The number, a DigitList format Decimal Floating Point.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(const DigitList &number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+   /**
+    * CompactDecimalFormat does not support parsing. This implementation
+    * does nothing.
+    * @param text           Unused.
+    * @param result         Does not change.
+    * @param parsePosition  Does not change.
+    * @see Formattable
+    * @stable ICU 51
+    */
+    virtual void parse(const UnicodeString& text,
+                       Formattable& result,
+                       ParsePosition& parsePosition) const;
+
+    /**
+     * CompactDecimalFormat does not support parsing. This implementation
+     * sets status to U_UNSUPPORTED_ERROR
+     *
+     * @param text      Unused. 
+     * @param result    Does not change.
+     * @param status    Always set to U_UNSUPPORTED_ERROR.
+     * @stable ICU 51
+     */
+    virtual void parse(const UnicodeString& text,
+                       Formattable& result,
+                       UErrorCode& status) const;
+
+    /**
+     * Parses text from the given string as a currency amount.  Unlike
+     * the parse() method, this method will attempt to parse a generic
+     * currency name, searching for a match of this object's locale's
+     * currency display names, or for a 3-letter ISO currency code.
+     * This method will fail if this format is not a currency format,
+     * that is, if it does not contain the currency pattern symbol
+     * (U+00A4) in its prefix or suffix. This implementation always returns
+     * NULL.
+     *
+     * @param text the string to parse
+     * @param pos  input-output position; on input, the position within text
+     *             to match; must have 0 <= pos.getIndex() < text.length();
+     *             on output, the position after the last matched character.
+     *             If the parse fails, the position in unchanged upon output.
+     * @return     if parse succeeds, a pointer to a newly-created CurrencyAmount
+     *             object (owned by the caller) containing information about
+     *             the parsed currency; if parse fails, this is NULL.
+     * @internal
+     */
+    virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
+                                          ParsePosition& pos) const;
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().  For example:
+     * <pre>
+     * .      Base* polymorphic_pointer = createPolymorphicObject();
+     * .      if (polymorphic_pointer->getDynamicClassID() ==
+     * .          Derived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 51
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
+     * This method is to implement a simple version of RTTI, since not all
+     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 51
+     */
+    virtual UClassID getDynamicClassID() const;
+
+private:
+
+    const UHashtable* _unitsByVariant;
+    const double* _divisors;
+    PluralRules* _pluralRules;
+
+    // Default constructor not implemented.
+    CompactDecimalFormat(const DecimalFormat &, const UHashtable* unitsByVariant, const double* divisors, PluralRules* pluralRules);
+
+    UBool eqHelper(const CompactDecimalFormat& that) const;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // __COMPACT_DECIMAL_FORMAT_H__
+//eof

+ 130 - 0
sqlite/unicode/curramt.h

@@ -0,0 +1,130 @@
+/*
+**********************************************************************
+* Copyright (c) 2004-2006, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+* Author: Alan Liu
+* Created: April 26, 2004
+* Since: ICU 3.0
+**********************************************************************
+*/
+#ifndef __CURRENCYAMOUNT_H__
+#define __CURRENCYAMOUNT_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/measure.h"
+#include "unicode/currunit.h"
+
+/**
+ * \file 
+ * \brief C++ API: Currency Amount Object.
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ *
+ * A currency together with a numeric amount, such as 200 USD.
+ *
+ * @author Alan Liu
+ * @stable ICU 3.0
+ */
+class U_I18N_API CurrencyAmount: public Measure {
+ public:
+    /**
+     * Construct an object with the given numeric amount and the given
+     * ISO currency code.
+     * @param amount a numeric object; amount.isNumeric() must be TRUE
+     * @param isoCode the 3-letter ISO 4217 currency code; must not be
+     * NULL and must have length 3
+     * @param ec input-output error code. If the amount or the isoCode
+     * is invalid, then this will be set to a failing value.
+     * @stable ICU 3.0
+     */
+    CurrencyAmount(const Formattable& amount, const UChar* isoCode,
+                   UErrorCode &ec);
+
+    /**
+     * Construct an object with the given numeric amount and the given
+     * ISO currency code.
+     * @param amount the amount of the given currency
+     * @param isoCode the 3-letter ISO 4217 currency code; must not be
+     * NULL and must have length 3
+     * @param ec input-output error code. If the isoCode is invalid,
+     * then this will be set to a failing value.
+     * @stable ICU 3.0
+     */
+    CurrencyAmount(double amount, const UChar* isoCode,
+                   UErrorCode &ec);
+
+    /**
+     * Copy constructor
+     * @stable ICU 3.0
+     */
+    CurrencyAmount(const CurrencyAmount& other);
+ 
+    /**
+     * Assignment operator
+     * @stable ICU 3.0
+     */
+    CurrencyAmount& operator=(const CurrencyAmount& other);
+
+    /**
+     * Return a polymorphic clone of this object.  The result will
+     * have the same class as returned by getDynamicClassID().
+     * @stable ICU 3.0
+     */
+    virtual UObject* clone() const;
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~CurrencyAmount();
+    
+    /**
+     * Returns a unique class ID for this object POLYMORPHICALLY.
+     * This method implements a simple form of RTTI used by ICU.
+     * @return The class ID for this object. All objects of a given
+     * class have the same class ID.  Objects of other classes have
+     * different class IDs.
+     * @stable ICU 3.0
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * Returns the class ID for this class. This is used to compare to
+     * the return value of getDynamicClassID().
+     * @return The class ID for all objects of this class.
+     * @stable ICU 3.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * Return the currency unit object of this object.
+     * @stable ICU 3.0
+     */
+    inline const CurrencyUnit& getCurrency() const;
+
+    /**
+     * Return the ISO currency code of this object.
+     * @stable ICU 3.0
+     */
+    inline const UChar* getISOCurrency() const;
+};
+
+inline const CurrencyUnit& CurrencyAmount::getCurrency() const {
+    return (const CurrencyUnit&) getUnit();
+}
+
+inline const UChar* CurrencyAmount::getISOCurrency() const {
+    return getCurrency().getISOCurrency();
+}
+
+U_NAMESPACE_END
+
+#endif // !UCONFIG_NO_FORMATTING
+#endif // __CURRENCYAMOUNT_H__

+ 258 - 0
sqlite/unicode/currpinf.h

@@ -0,0 +1,258 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 2009-2011, International Business Machines Corporation and         *
+ * others. All Rights Reserved.                                                *
+ *******************************************************************************
+ */
+#ifndef CURRPINF_H
+#define CURRPINF_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Currency Plural Information used by Decimal Format
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/unistr.h"
+
+U_NAMESPACE_BEGIN
+
+class Locale;
+class PluralRules;
+class Hashtable;
+
+/**
+ * This class represents the information needed by 
+ * DecimalFormat to format currency plural, 
+ * such as "3.00 US dollars" or "1.00 US dollar". 
+ * DecimalFormat creates for itself an instance of
+ * CurrencyPluralInfo from its locale data.  
+ * If you need to change any of these symbols, you can get the
+ * CurrencyPluralInfo object from your 
+ * DecimalFormat and modify it.
+ *
+ * Following are the information needed for currency plural format and parse:
+ * locale information,
+ * plural rule of the locale,
+ * currency plural pattern of the locale.
+ *
+ * @stable ICU 4.2
+ */
+class  U_I18N_API CurrencyPluralInfo : public UObject {
+public:
+
+    /**
+     * Create a CurrencyPluralInfo object for the default locale.
+     * @param status output param set to success/failure code on exit
+     * @stable ICU 4.2
+     */
+    CurrencyPluralInfo(UErrorCode& status);
+
+    /**
+     * Create a CurrencyPluralInfo object for the given locale.
+     * @param locale the locale
+     * @param status output param set to success/failure code on exit
+     * @stable ICU 4.2
+     */
+    CurrencyPluralInfo(const Locale& locale, UErrorCode& status); 
+
+    /**
+     * Copy constructor
+     *
+     * @stable ICU 4.2
+     */
+    CurrencyPluralInfo(const CurrencyPluralInfo& info);
+
+
+    /**
+     * Assignment operator
+     *
+     * @stable ICU 4.2
+     */
+    CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info);
+
+
+    /**
+     * Destructor
+     *
+     * @stable ICU 4.2
+     */
+    virtual ~CurrencyPluralInfo();
+
+
+    /**
+     * Equal operator.
+     *
+     * @stable ICU 4.2
+     */
+    UBool operator==(const CurrencyPluralInfo& info) const;
+
+
+    /**
+     * Not equal operator
+     *
+     * @stable ICU 4.2
+     */
+    UBool operator!=(const CurrencyPluralInfo& info) const;
+
+
+    /**
+     * Clone
+     *
+     * @stable ICU 4.2
+     */
+    CurrencyPluralInfo* clone() const;
+
+
+    /**
+     * Gets plural rules of this locale, used for currency plural format
+     *
+     * @return plural rule
+     * @stable ICU 4.2
+     */
+    const PluralRules* getPluralRules() const;
+
+    /**
+     * Given a plural count, gets currency plural pattern of this locale, 
+     * used for currency plural format
+     *
+     * @param  pluralCount currency plural count
+     * @param  result      output param to receive the pattern
+     * @return a currency plural pattern based on plural count
+     * @stable ICU 4.2
+     */
+    UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,
+                                            UnicodeString& result) const; 
+
+    /**
+     * Get locale 
+     *
+     * @return locale
+     * @stable ICU 4.2
+     */
+    const Locale& getLocale() const;
+
+    /**
+     * Set plural rules.
+     * The plural rule is set when CurrencyPluralInfo
+     * instance is created.
+     * You can call this method to reset plural rules only if you want
+     * to modify the default plural rule of the locale.
+     *
+     * @param ruleDescription new plural rule description
+     * @param status output param set to success/failure code on exit
+     * @stable ICU 4.2
+     */
+    void setPluralRules(const UnicodeString& ruleDescription,
+                        UErrorCode& status);
+
+    /**
+     * Set currency plural pattern.
+     * The currency plural pattern is set when CurrencyPluralInfo
+     * instance is created.
+     * You can call this method to reset currency plural pattern only if 
+     * you want to modify the default currency plural pattern of the locale.
+     *
+     * @param pluralCount the plural count for which the currency pattern will 
+     *                    be overridden.
+     * @param pattern     the new currency plural pattern
+     * @param status      output param set to success/failure code on exit
+     * @stable ICU 4.2
+     */
+    void setCurrencyPluralPattern(const UnicodeString& pluralCount, 
+                                  const UnicodeString& pattern,
+                                  UErrorCode& status);
+
+    /**
+     * Set locale
+     *
+     * @param loc     the new locale to set
+     * @param status  output param set to success/failure code on exit
+     * @stable ICU 4.2
+     */
+    void setLocale(const Locale& loc, UErrorCode& status);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 4.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 4.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+    friend class DecimalFormat;
+
+    void initialize(const Locale& loc, UErrorCode& status);
+   
+    void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
+
+    /*
+     * delete hash table
+     *
+     * @param hTable  hash table to be deleted
+     */
+    void deleteHash(Hashtable* hTable);
+
+
+    /*
+     * initialize hash table
+     *
+     * @param status   output param set to success/failure code on exit
+     * @return         hash table initialized
+     */
+    Hashtable* initHash(UErrorCode& status);
+
+
+
+    /**
+     * copy hash table
+     *
+     * @param source   the source to copy from
+     * @param target   the target to copy to
+     * @param status   error code
+     */
+    void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
+
+    //-------------------- private data member ---------------------
+    // map from plural count to currency plural pattern, for example
+    // a plural pattern defined in "CurrencyUnitPatterns" is
+    // "one{{0} {1}}", in which "one" is a plural count
+    // and "{0} {1}" is a currency plural pattern".
+    // The currency plural pattern saved in this mapping is the pattern
+    // defined in "CurrencyUnitPattern" by replacing
+    // {0} with the number format pattern,
+    // and {1} with 3 currency sign.
+    Hashtable* fPluralCountToCurrencyUnitPattern;
+
+    /*
+     * The plural rule is used to format currency plural name,
+     * for example: "3.00 US Dollars".
+     * If there are 3 currency signs in the currency patttern,
+     * the 3 currency signs will be replaced by currency plural name.
+     */
+    PluralRules* fPluralRules;
+
+    // locale
+    Locale* fLocale;
+};
+
+
+inline UBool
+CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const {              return !operator==(info);                                                   }  
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _CURRPINFO
+//eof

+ 110 - 0
sqlite/unicode/currunit.h

@@ -0,0 +1,110 @@
+/*
+**********************************************************************
+* Copyright (c) 2004-2014, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+* Author: Alan Liu
+* Created: April 26, 2004
+* Since: ICU 3.0
+**********************************************************************
+*/
+#ifndef __CURRENCYUNIT_H__
+#define __CURRENCYUNIT_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/measunit.h"
+
+/**
+ * \file 
+ * \brief C++ API: Currency Unit Information.
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
+ * yen).  This class is a thin wrapper over a UChar string that
+ * subclasses MeasureUnit, for use with Measure and MeasureFormat.
+ *
+ * @author Alan Liu
+ * @stable ICU 3.0
+ */
+class U_I18N_API CurrencyUnit: public MeasureUnit {
+ public:
+    /**
+     * Construct an object with the given ISO currency code.
+     * @param isoCode the 3-letter ISO 4217 currency code; must not be
+     * NULL and must have length 3
+     * @param ec input-output error code. If the isoCode is invalid,
+     * then this will be set to a failing value.
+     * @stable ICU 3.0
+     */
+    CurrencyUnit(const UChar* isoCode, UErrorCode &ec);
+
+    /**
+     * Copy constructor
+     * @stable ICU 3.0
+     */
+    CurrencyUnit(const CurrencyUnit& other);
+
+    /**
+     * Assignment operator
+     * @stable ICU 3.0
+     */
+    CurrencyUnit& operator=(const CurrencyUnit& other);
+
+    /**
+     * Return a polymorphic clone of this object.  The result will
+     * have the same class as returned by getDynamicClassID().
+     * @stable ICU 3.0
+     */
+    virtual UObject* clone() const;
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~CurrencyUnit();
+
+    /**
+     * Returns a unique class ID for this object POLYMORPHICALLY.
+     * This method implements a simple form of RTTI used by ICU.
+     * @return The class ID for this object. All objects of a given
+     * class have the same class ID.  Objects of other classes have
+     * different class IDs.
+     * @stable ICU 3.0
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * Returns the class ID for this class. This is used to compare to
+     * the return value of getDynamicClassID().
+     * @return The class ID for all objects of this class.
+     * @stable ICU 3.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * Return the ISO currency code of this object.
+     * @stable ICU 3.0
+     */
+    inline const UChar* getISOCurrency() const;
+
+ private:
+    /**
+     * The ISO 4217 code of this object.
+     */
+    UChar isoCode[4];
+};
+
+inline const UChar* CurrencyUnit::getISOCurrency() const {
+    return isoCode;
+}
+
+U_NAMESPACE_END
+
+#endif // !UCONFIG_NO_FORMATTING
+#endif // __CURRENCYUNIT_H__

+ 972 - 0
sqlite/unicode/datefmt.h

@@ -0,0 +1,972 @@
+/*
+ ********************************************************************************
+ *   Copyright (C) 1997-2015, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ ********************************************************************************
+ *
+ * File DATEFMT.H
+ *
+ * Modification History:
+ *
+ *   Date        Name        Description
+ *   02/19/97    aliu        Converted from java.
+ *   04/01/97    aliu        Added support for centuries.
+ *   07/23/98    stephen     JDK 1.2 sync
+ *   11/15/99    weiv        Added support for week of year/day of week formatting
+ ********************************************************************************
+ */
+
+#ifndef DATEFMT_H
+#define DATEFMT_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/udat.h"
+#include "unicode/calendar.h"
+#include "unicode/numfmt.h"
+#include "unicode/format.h"
+#include "unicode/locid.h"
+#include "unicode/enumset.h"
+#include "unicode/udisplaycontext.h"
+
+/**
+ * \file
+ * \brief C++ API: Abstract class for converting dates.
+ */
+
+U_NAMESPACE_BEGIN
+
+class TimeZone;
+class DateTimePatternGenerator;
+
+// explicit template instantiation. see digitlst.h
+#if defined (_MSC_VER)
+template class U_I18N_API EnumSet<UDateFormatBooleanAttribute,
+            0, 
+            UDAT_BOOLEAN_ATTRIBUTE_COUNT>;
+#endif
+
+/**
+ * DateFormat is an abstract class for a family of classes that convert dates and
+ * times from their internal representations to textual form and back again in a
+ * language-independent manner. Converting from the internal representation (milliseconds
+ * since midnight, January 1, 1970) to text is known as "formatting," and converting
+ * from text to millis is known as "parsing."  We currently define only one concrete
+ * subclass of DateFormat: SimpleDateFormat, which can handle pretty much all normal
+ * date formatting and parsing actions.
+ * <P>
+ * DateFormat helps you to format and parse dates for any locale. Your code can
+ * be completely independent of the locale conventions for months, days of the
+ * week, or even the calendar format: lunar vs. solar.
+ * <P>
+ * To format a date for the current Locale, use one of the static factory
+ * methods:
+ * <pre>
+ * \code
+ *      DateFormat* dfmt = DateFormat::createDateInstance();
+ *      UDate myDate = Calendar::getNow();
+ *      UnicodeString myString;
+ *      myString = dfmt->format( myDate, myString );
+ * \endcode
+ * </pre>
+ * If you are formatting multiple numbers, it is more efficient to get the
+ * format and use it multiple times so that the system doesn't have to fetch the
+ * information about the local language and country conventions multiple times.
+ * <pre>
+ * \code
+ *      DateFormat* df = DateFormat::createDateInstance();
+ *      UnicodeString myString;
+ *      UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
+ *      for (int32_t i = 0; i < 3; ++i) {
+ *          myString.remove();
+ *          cout << df->format( myDateArr[i], myString ) << endl;
+ *      }
+ * \endcode
+ * </pre>
+ * To get specific fields of a date, you can use UFieldPosition to
+ * get specific fields.
+ * <pre>
+ * \code
+ *      DateFormat* dfmt = DateFormat::createDateInstance();
+ *      FieldPosition pos(DateFormat::YEAR_FIELD);
+ *      UnicodeString myString;
+ *      myString = dfmt->format( myDate, myString );
+ *      cout << myString << endl;
+ *      cout << pos.getBeginIndex() << "," << pos. getEndIndex() << endl;
+ * \endcode
+ * </pre>
+ * To format a date for a different Locale, specify it in the call to
+ * createDateInstance().
+ * <pre>
+ * \code
+ *       DateFormat* df =
+ *           DateFormat::createDateInstance( DateFormat::SHORT, Locale::getFrance());
+ * \endcode
+ * </pre>
+ * You can use a DateFormat to parse also.
+ * <pre>
+ * \code
+ *       UErrorCode status = U_ZERO_ERROR;
+ *       UDate myDate = df->parse(myString, status);
+ * \endcode
+ * </pre>
+ * Use createDateInstance() to produce the normal date format for that country.
+ * There are other static factory methods available. Use createTimeInstance()
+ * to produce the normal time format for that country. Use createDateTimeInstance()
+ * to produce a DateFormat that formats both date and time. You can pass in
+ * different options to these factory methods to control the length of the
+ * result; from SHORT to MEDIUM to LONG to FULL. The exact result depends on the
+ * locale, but generally:
+ * <ul type=round>
+ *   <li>   SHORT is completely numeric, such as 12/13/52 or 3:30pm
+ *   <li>   MEDIUM is longer, such as Jan 12, 1952
+ *   <li>   LONG is longer, such as January 12, 1952 or 3:30:32pm
+ *   <li>   FULL is pretty completely specified, such as
+ *          Tuesday, April 12, 1952 AD or 3:30:42pm PST.
+ * </ul>
+ * You can also set the time zone on the format if you wish. If you want even
+ * more control over the format or parsing, (or want to give your users more
+ * control), you can try casting the DateFormat you get from the factory methods
+ * to a SimpleDateFormat. This will work for the majority of countries; just
+ * remember to chck getDynamicClassID() before carrying out the cast.
+ * <P>
+ * You can also use forms of the parse and format methods with ParsePosition and
+ * FieldPosition to allow you to
+ * <ul type=round>
+ *   <li>   Progressively parse through pieces of a string.
+ *   <li>   Align any particular field, or find out where it is for selection
+ *          on the screen.
+ * </ul>
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API DateFormat : public Format {
+public:
+
+    /**
+     * Constants for various style patterns. These reflect the order of items in
+     * the DateTimePatterns resource. There are 4 time patterns, 4 date patterns,
+     * the default date-time pattern, and 4 date-time patterns. Each block of 4 values
+     * in the resource occurs in the order full, long, medium, short.
+     * @stable ICU 2.4
+     */
+    enum EStyle
+    {
+        kNone   = -1,
+
+        kFull   = 0,
+        kLong   = 1,
+        kMedium = 2,
+        kShort  = 3,
+
+        kDateOffset   = kShort + 1,
+     // kFull   + kDateOffset = 4
+     // kLong   + kDateOffset = 5
+     // kMedium + kDateOffset = 6
+     // kShort  + kDateOffset = 7
+
+        kDateTime             = 8,
+     // Default DateTime
+
+        kDateTimeOffset = kDateTime + 1,
+     // kFull   + kDateTimeOffset = 9
+     // kLong   + kDateTimeOffset = 10
+     // kMedium + kDateTimeOffset = 11
+     // kShort  + kDateTimeOffset = 12
+
+        // relative dates
+        kRelative = (1 << 7),
+
+        kFullRelative = (kFull | kRelative),
+
+        kLongRelative = kLong | kRelative,
+
+        kMediumRelative = kMedium | kRelative,
+
+        kShortRelative = kShort | kRelative,
+
+
+        kDefault      = kMedium,
+
+
+
+    /**
+     * These constants are provided for backwards compatibility only.
+     * Please use the C++ style constants defined above.
+     */
+        FULL        = kFull,
+        LONG        = kLong,
+        MEDIUM        = kMedium,
+        SHORT        = kShort,
+        DEFAULT        = kDefault,
+        DATE_OFFSET    = kDateOffset,
+        NONE        = kNone,
+        DATE_TIME    = kDateTime
+    };
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~DateFormat();
+
+    /**
+     * Equality operator.  Returns true if the two formats have the same behavior.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format&) const;
+
+
+    using Format::format;
+
+    /**
+     * Format an object to produce a string. This method handles Formattable
+     * objects with a UDate type. If a the Formattable object type is not a Date,
+     * then it returns a failing UErrorCode.
+     *
+     * @param obj       The object to format. Must be a Date.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format an object to produce a string. This method handles Formattable
+     * objects with a UDate type. If a the Formattable object type is not a Date,
+     * then it returns a failing UErrorCode.
+     *
+     * @param obj       The object to format. Must be a Date.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.  Field values
+     *                  are defined in UDateFormatField.  Can be NULL.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 4.4
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+    /**
+     * Formats a date into a date/time string. This is an abstract method which
+     * concrete subclasses must implement.
+     * <P>
+     * On input, the FieldPosition parameter may have its "field" member filled with
+     * an enum value specifying a field.  On output, the FieldPosition will be filled
+     * in with the text offsets for that field.
+     * <P> For example, given a time text
+     * "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is
+     * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and
+     * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.
+     * <P> Notice
+     * that if the same time field appears more than once in a pattern, the status will
+     * be set for the first occurence of that time field. For instance,
+     * formatting a UDate to the time string "1 PM PDT (Pacific Daylight Time)"
+     * using the pattern "h a z (zzzz)" and the alignment field
+     * DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and
+     * fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first
+     * occurence of the timezone pattern character 'z'.
+     *
+     * @param cal           Calendar set to the date and time to be formatted
+     *                      into a date/time string.  When the calendar type is
+     *                      different from the internal calendar held by this
+     *                      DateFormat instance, the date and the time zone will
+     *                      be inherited from the input calendar, but other calendar
+     *                      field values will be calculated by the internal calendar.
+     * @param appendTo      Output parameter to receive result.
+     *                      Result is appended to existing contents.
+     * @param fieldPosition On input: an alignment field, if desired (see examples above)
+     *                      On output: the offsets of the alignment field (see examples above)
+     * @return              Reference to 'appendTo' parameter.
+     * @stable ICU 2.1
+     */
+    virtual UnicodeString& format(  Calendar& cal,
+                                    UnicodeString& appendTo,
+                                    FieldPosition& fieldPosition) const = 0;
+
+    /**
+     * Formats a date into a date/time string. Subclasses should implement this method.
+     *
+     * @param cal       Calendar set to the date and time to be formatted
+     *                  into a date/time string.  When the calendar type is
+     *                  different from the internal calendar held by this
+     *                  DateFormat instance, the date and the time zone will
+     *                  be inherited from the input calendar, but other calendar
+     *                  field values will be calculated by the internal calendar.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.  Field values
+     *                  are defined in UDateFormatField.  Can be NULL.
+     * @param status    error status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 4.4
+     */
+    virtual UnicodeString& format(Calendar& cal,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+    /**
+     * Formats a UDate into a date/time string.
+     * <P>
+     * On input, the FieldPosition parameter may have its "field" member filled with
+     * an enum value specifying a field.  On output, the FieldPosition will be filled
+     * in with the text offsets for that field.
+     * <P> For example, given a time text
+     * "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is
+     * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and
+     * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.
+     * <P> Notice
+     * that if the same time field appears more than once in a pattern, the status will
+     * be set for the first occurence of that time field. For instance,
+     * formatting a UDate to the time string "1 PM PDT (Pacific Daylight Time)"
+     * using the pattern "h a z (zzzz)" and the alignment field
+     * DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and
+     * fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first
+     * occurence of the timezone pattern character 'z'.
+     *
+     * @param date          UDate to be formatted into a date/time string.
+     * @param appendTo      Output parameter to receive result.
+     *                      Result is appended to existing contents.
+     * @param fieldPosition On input: an alignment field, if desired (see examples above)
+     *                      On output: the offsets of the alignment field (see examples above)
+     * @return              Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(  UDate date,
+                            UnicodeString& appendTo,
+                            FieldPosition& fieldPosition) const;
+
+    /**
+     * Formats a UDate into a date/time string.
+     *
+     * @param date      UDate to be formatted into a date/time string.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.  Field values
+     *                  are defined in UDateFormatField.  Can be NULL.
+     * @param status    error status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 4.4
+     */
+    UnicodeString& format(UDate date,
+                          UnicodeString& appendTo,
+                          FieldPositionIterator* posIter,
+                          UErrorCode& status) const;
+    /**
+     * Formats a UDate into a date/time string. If there is a problem, you won't
+     * know, using this method. Use the overloaded format() method which takes a
+     * FieldPosition& to detect formatting problems.
+     *
+     * @param date      The UDate value to be formatted into a string.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(UDate date, UnicodeString& appendTo) const;
+
+    /**
+     * Parse a date/time string. For example, a time text "07/10/96 4:5 PM, PDT"
+     * will be parsed into a UDate that is equivalent to Date(837039928046).
+     * Parsing begins at the beginning of the string and proceeds as far as
+     * possible.  Assuming no parse errors were encountered, this function
+     * doesn't return any information about how much of the string was consumed
+     * by the parsing.  If you need that information, use the version of
+     * parse() that takes a ParsePosition.
+     * <P>
+     * By default, parsing is lenient: If the input is not in the form used by
+     * this object's format method but can still be parsed as a date, then the
+     * parse succeeds. Clients may insist on strict adherence to the format by
+     * calling setLenient(false).
+     * @see DateFormat::setLenient(boolean)
+     * <P>
+     * Note that the normal date formats associated with some calendars - such
+     * as the Chinese lunar calendar - do not specify enough fields to enable
+     * dates to be parsed unambiguously. In the case of the Chinese lunar
+     * calendar, while the year within the current 60-year cycle is specified,
+     * the number of such cycles since the start date of the calendar (in the
+     * ERA field of the Calendar object) is not normally part of the format,
+     * and parsing may assume the wrong era. For cases such as this it is
+     * recommended that clients parse using the method
+     * parse(const UnicodeString&, Calendar& cal, ParsePosition&)
+     * with the Calendar passed in set to the current date, or to a date
+     * within the era/cycle that should be assumed if absent in the format.
+     *
+     * @param text      The date/time string to be parsed into a UDate value.
+     * @param status    Output param to be set to success/failure code. If
+     *                  'text' cannot be parsed, it will be set to a failure
+     *                  code.
+     * @return          The parsed UDate value, if successful.
+     * @stable ICU 2.0
+     */
+    virtual UDate parse( const UnicodeString& text,
+                        UErrorCode& status) const;
+
+    /**
+     * Parse a date/time string beginning at the given parse position. For
+     * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
+     * that is equivalent to Date(837039928046).
+     * <P>
+     * By default, parsing is lenient: If the input is not in the form used by
+     * this object's format method but can still be parsed as a date, then the
+     * parse succeeds. Clients may insist on strict adherence to the format by
+     * calling setLenient(false).
+     * @see DateFormat::setLenient(boolean)
+     *
+     * @param text  The date/time string to be parsed.
+     * @param cal   A Calendar set on input to the date and time to be used for
+     *              missing values in the date/time string being parsed, and set
+     *              on output to the parsed date/time. When the calendar type is
+     *              different from the internal calendar held by this DateFormat
+     *              instance, the internal calendar will be cloned to a work
+     *              calendar set to the same milliseconds and time zone as the
+     *              cal parameter, field values will be parsed based on the work
+     *              calendar, then the result (milliseconds and time zone) will
+     *              be set in this calendar.
+     * @param pos   On input, the position at which to start parsing; on
+     *              output, the position at which parsing terminated, or the
+     *              start position if the parse failed.
+     * @stable ICU 2.1
+     */
+    virtual void parse( const UnicodeString& text,
+                        Calendar& cal,
+                        ParsePosition& pos) const = 0;
+
+    /**
+     * Parse a date/time string beginning at the given parse position. For
+     * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
+     * that is equivalent to Date(837039928046).
+     * <P>
+     * By default, parsing is lenient: If the input is not in the form used by
+     * this object's format method but can still be parsed as a date, then the
+     * parse succeeds. Clients may insist on strict adherence to the format by
+     * calling setLenient(false).
+     * @see DateFormat::setLenient(boolean)
+     * <P>
+     * Note that the normal date formats associated with some calendars - such
+     * as the Chinese lunar calendar - do not specify enough fields to enable
+     * dates to be parsed unambiguously. In the case of the Chinese lunar
+     * calendar, while the year within the current 60-year cycle is specified,
+     * the number of such cycles since the start date of the calendar (in the
+     * ERA field of the Calendar object) is not normally part of the format,
+     * and parsing may assume the wrong era. For cases such as this it is
+     * recommended that clients parse using the method
+     * parse(const UnicodeString&, Calendar& cal, ParsePosition&)
+     * with the Calendar passed in set to the current date, or to a date
+     * within the era/cycle that should be assumed if absent in the format.
+     *
+     * @param text  The date/time string to be parsed into a UDate value.
+     * @param pos   On input, the position at which to start parsing; on
+     *              output, the position at which parsing terminated, or the
+     *              start position if the parse failed.
+     * @return      A valid UDate if the input could be parsed.
+     * @stable ICU 2.0
+     */
+    UDate parse( const UnicodeString& text,
+                 ParsePosition& pos) const;
+
+    /**
+     * Parse a string to produce an object. This methods handles parsing of
+     * date/time strings into Formattable objects with UDate types.
+     * <P>
+     * Before calling, set parse_pos.index to the offset you want to start
+     * parsing at in the source. After calling, parse_pos.index is the end of
+     * the text you parsed. If error occurs, index is unchanged.
+     * <P>
+     * When parsing, leading whitespace is discarded (with a successful parse),
+     * while trailing whitespace is left as is.
+     * <P>
+     * See Format::parseObject() for more.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param parse_pos The position to start parsing at. Upon return
+     *                  this param is set to the position after the
+     *                  last character successfully parsed. If the
+     *                  source is not parsed successfully, this param
+     *                  will remain unchanged.
+     * @stable ICU 2.0
+     */
+    virtual void parseObject(const UnicodeString& source,
+                             Formattable& result,
+                             ParsePosition& parse_pos) const;
+
+    /**
+     * Create a default date/time formatter that uses the SHORT style for both
+     * the date and the time.
+     *
+     * @return A date/time formatter which the caller owns.
+     * @stable ICU 2.0
+     */
+    static DateFormat* U_EXPORT2 createInstance(void);
+
+    /**
+     * Creates a time formatter with the given formatting style for the given
+     * locale.
+     *
+     * @param style     The given formatting style. For example,
+     *                  SHORT for "h:mm a" in the US locale. Relative
+     *                  time styles are not currently supported.
+     * @param aLocale   The given locale.
+     * @return          A time formatter which the caller owns.
+     * @stable ICU 2.0
+     */
+    static DateFormat* U_EXPORT2 createTimeInstance(EStyle style = kDefault,
+                                          const Locale& aLocale = Locale::getDefault());
+
+    /**
+     * Creates a date formatter with the given formatting style for the given
+     * const locale.
+     *
+     * @param style     The given formatting style. For example, SHORT for "M/d/yy" in the
+     *                  US locale. As currently implemented, relative date formatting only
+     *                  affects a limited range of calendar days before or after the
+     *                  current date, based on the CLDR &lt;field type="day"&gt;/&lt;relative&gt; data:
+     *                  For example, in English, "Yesterday", "Today", and "Tomorrow".
+     *                  Outside of this range, dates are formatted using the corresponding
+     *                  non-relative style.
+     * @param aLocale   The given locale.
+     * @return          A date formatter which the caller owns.
+     * @stable ICU 2.0
+     */
+    static DateFormat* U_EXPORT2 createDateInstance(EStyle style = kDefault,
+                                          const Locale& aLocale = Locale::getDefault());
+
+    /**
+     * Creates a date/time formatter with the given formatting styles for the
+     * given locale.
+     *
+     * @param dateStyle The given formatting style for the date portion of the result.
+     *                  For example, SHORT for "M/d/yy" in the US locale. As currently
+     *                  implemented, relative date formatting only affects a limited range
+     *                  of calendar days before or after the current date, based on the
+     *                  CLDR &lt;field type="day"&gt;/&lt;relative&gt; data: For example, in English,
+     *                  "Yesterday", "Today", and "Tomorrow". Outside of this range, dates
+     *                  are formatted using the corresponding non-relative style.
+     * @param timeStyle The given formatting style for the time portion of the result.
+     *                  For example, SHORT for "h:mm a" in the US locale. Relative
+     *                  time styles are not currently supported.
+     * @param aLocale   The given locale.
+     * @return          A date/time formatter which the caller owns.
+     * @stable ICU 2.0
+     */
+    static DateFormat* U_EXPORT2 createDateTimeInstance(EStyle dateStyle = kDefault,
+                                              EStyle timeStyle = kDefault,
+                                              const Locale& aLocale = Locale::getDefault());
+
+#ifndef U_HIDE_DRAFT_API
+
+    /**
+     * Creates a date/time formatter for the given skeleton and 
+     * default locale.
+     *
+     * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
+     *                 be in any order, and this method uses the locale to
+     *                 map the skeleton to a pattern that includes locale
+     *                 specific separators with the fields in the appropriate
+     *                 order for that locale.
+     * @param status   Any error returned here.
+     * @return         A date/time formatter which the caller owns.
+     * @draft ICU 55
+     */
+    static DateFormat* U_EXPORT2 createInstanceForSkeleton(
+            const UnicodeString& skeleton,
+            UErrorCode &status);
+
+    /**
+     * Creates a date/time formatter for the given skeleton and locale.
+     *
+     * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
+     *                 be in any order, and this method uses the locale to
+     *                 map the skeleton to a pattern that includes locale
+     *                 specific separators with the fields in the appropriate
+     *                 order for that locale.
+     * @param locale  The given locale.
+     * @param status   Any error returned here.
+     * @return         A date/time formatter which the caller owns.
+     * @draft ICU 55
+     */
+    static DateFormat* U_EXPORT2 createInstanceForSkeleton(
+            const UnicodeString& skeleton,
+            const Locale &locale,
+            UErrorCode &status);
+
+    /**
+     * Creates a date/time formatter for the given skeleton and locale.
+     *
+     * @param calendarToAdopt the calendar returned DateFormat is to use.
+     * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
+     *                 be in any order, and this method uses the locale to
+     *                 map the skeleton to a pattern that includes locale
+     *                 specific separators with the fields in the appropriate
+     *                 order for that locale.
+     * @param locale  The given locale.
+     * @param status   Any error returned here.
+     * @return         A date/time formatter which the caller owns.
+     * @draft ICU 55
+     */
+    static DateFormat* U_EXPORT2 createInstanceForSkeleton(
+            Calendar *calendarToAdopt,
+            const UnicodeString& skeleton,
+            const Locale &locale,
+            UErrorCode &status);
+
+#endif /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_INTERNAL_API 
+
+    /**
+     * Creates a date/time formatter for the given skeleton and locale and
+     * uses the given DateTimePatternGenerator to convert the skeleton to
+     * a format pattern. As creating a DateTimePatternGenerator is
+     * expensive, callers can supply it here (if they already have it) to save
+     * this method from creating its own.
+     *
+     * @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
+     *                 be in any order, and this method uses the provided
+     *                 DateTimePatternGenerator to map the skeleton to a
+     *                 pattern that includes appropriate separators with
+     *                 the fields in the appropriate order.
+     * @param locale  The given locale.
+     * @param dpng     The user supplied DateTimePatternGenerator. dpng
+     *                 must be created for the same locale as locale.
+     *                 Moreover, the caller must not modify dpng between
+     *                 creating it by locale and calling this method.
+     *                 Although dpng is a non-const reference, the caller
+     *                 must not regard it as an out or in-out parameter.
+     *                 The only reason dpng is a non-const reference is
+     *                 because its method, getBestPattern, which converts
+     *                 a skeleton to a date format pattern is non-const.
+     * @return         A date/time formatter which the caller owns.
+     * @internal For ICU use only
+     */
+    static DateFormat* U_EXPORT2 internalCreateInstanceForSkeleton(
+            const UnicodeString& skeleton,
+            const Locale &locale,
+            DateTimePatternGenerator &dpng,
+            UErrorCode &status);
+
+#endif /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Gets the set of locales for which DateFormats are installed.
+     * @param count Filled in with the number of locales in the list that is returned.
+     * @return the set of locales for which DateFormats are installed.  The caller
+     *  does NOT own this list and must not delete it.
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+    /**
+     * Returns whether both date/time parsing in the encapsulated Calendar object and DateFormat whitespace &
+     * numeric processing is lenient.
+     * @stable ICU 2.0
+     */
+    virtual UBool isLenient(void) const;
+
+    /**
+     * Specifies whether date/time parsing is to be lenient.  With
+     * lenient parsing, the parser may use heuristics to interpret inputs that
+     * do not precisely match this object's format.  Without lenient parsing,
+     * inputs must match this object's format more closely.
+     * 
+     * Note: ICU 53 introduced finer grained control of leniency (and added 
+     * new control points) making the preferred method a combination of 
+     * setCalendarLenient() & setBooleanAttribute() calls. 
+     * This method supports prior functionality but may not support all 
+     * future leniency control & behavior of DateFormat. For control of pre 53 leniency,  
+     * Calendar and DateFormat whitespace & numeric tolerance, this method is safe to 
+     * use. However, mixing leniency control via this method and modification of the 
+     * newer attributes via setBooleanAttribute() may produce undesirable 
+     * results.
+     *
+     * @param lenient  True specifies date/time interpretation to be lenient.
+     * @see Calendar::setLenient
+     * @stable ICU 2.0     
+     */
+    virtual void setLenient(UBool lenient);
+
+
+    /**
+     * Returns whether date/time parsing in the encapsulated Calendar object processing is lenient.
+     * @stable ICU 53
+     */
+    virtual UBool isCalendarLenient(void) const;
+
+
+    /**
+     * Specifies whether encapsulated Calendar date/time parsing is to be lenient.  With
+     * lenient parsing, the parser may use heuristics to interpret inputs that
+     * do not precisely match this object's format.  Without lenient parsing,
+     * inputs must match this object's format more closely.
+     * @param lenient when true, parsing is lenient
+     * @see com.ibm.icu.util.Calendar#setLenient
+     * @stable ICU 53
+     */
+    virtual void setCalendarLenient(UBool lenient);
+
+
+    /**
+     * Gets the calendar associated with this date/time formatter.
+     * The calendar is owned by the formatter and must not be modified.
+     * Also, the calendar does not reflect the results of a parse operation.
+     * To parse to a calendar, use {@link #parse(const UnicodeString&, Calendar& cal, ParsePosition&) const parse(const UnicodeString&, Calendar& cal, ParsePosition&)}
+     * @return the calendar associated with this date/time formatter.
+     * @stable ICU 2.0
+     */
+    virtual const Calendar* getCalendar(void) const;
+
+    /**
+     * Set the calendar to be used by this date format. Initially, the default
+     * calendar for the specified or default locale is used.  The caller should
+     * not delete the Calendar object after it is adopted by this call.
+     * Adopting a new calendar will change to the default symbols.
+     *
+     * @param calendarToAdopt    Calendar object to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptCalendar(Calendar* calendarToAdopt);
+
+    /**
+     * Set the calendar to be used by this date format. Initially, the default
+     * calendar for the specified or default locale is used.
+     *
+     * @param newCalendar Calendar object to be set.
+     * @stable ICU 2.0
+     */
+    virtual void setCalendar(const Calendar& newCalendar);
+
+
+    /**
+     * Gets the number formatter which this date/time formatter uses to format
+     * and parse the numeric portions of the pattern.
+     * @return the number formatter which this date/time formatter uses.
+     * @stable ICU 2.0
+     */
+    virtual const NumberFormat* getNumberFormat(void) const;
+
+    /**
+     * Allows you to set the number formatter.  The caller should
+     * not delete the NumberFormat object after it is adopted by this call.
+     * @param formatToAdopt     NumberFormat object to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptNumberFormat(NumberFormat* formatToAdopt);
+
+    /**
+     * Allows you to set the number formatter.
+     * @param newNumberFormat  NumberFormat object to be set.
+     * @stable ICU 2.0
+     */
+    virtual void setNumberFormat(const NumberFormat& newNumberFormat);
+
+    /**
+     * Returns a reference to the TimeZone used by this DateFormat's calendar.
+     * @return the time zone associated with the calendar of DateFormat.
+     * @stable ICU 2.0
+     */
+    virtual const TimeZone& getTimeZone(void) const;
+
+    /**
+     * Sets the time zone for the calendar of this DateFormat object. The caller
+     * no longer owns the TimeZone object and should not delete it after this call.
+     * @param zoneToAdopt the TimeZone to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptTimeZone(TimeZone* zoneToAdopt);
+
+    /**
+     * Sets the time zone for the calendar of this DateFormat object.
+     * @param zone the new time zone.
+     * @stable ICU 2.0
+     */
+    virtual void setTimeZone(const TimeZone& zone);
+
+    /**
+     * Set a particular UDisplayContext value in the formatter, such as
+     * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
+     * @param value The UDisplayContext value to set.
+     * @param status Input/output status. If at entry this indicates a failure
+     *               status, the function will do nothing; otherwise this will be
+     *               updated with any new status from the function. 
+     * @stable ICU 53
+     */
+    virtual void setContext(UDisplayContext value, UErrorCode& status);
+
+    /**
+     * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
+     * such as UDISPCTX_TYPE_CAPITALIZATION.
+     * @param type The UDisplayContextType whose value to return
+     * @param status Input/output status. If at entry this indicates a failure
+     *               status, the function will do nothing; otherwise this will be
+     *               updated with any new status from the function. 
+     * @return The UDisplayContextValue for the specified type.
+     * @stable ICU 53
+     */
+    virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
+
+   /**
+     * Sets an boolean attribute on this DateFormat.
+     * May return U_UNSUPPORTED_ERROR if this instance does not support
+     * the specified attribute.
+     * @param attr the attribute to set
+     * @param newvalue new value
+     * @param status the error type
+     * @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) )
+     * @stable ICU 53
+     */
+
+    virtual DateFormat&  U_EXPORT2 setBooleanAttribute(UDateFormatBooleanAttribute attr,
+    									UBool newvalue,
+    									UErrorCode &status);
+
+    /**
+     * Returns a boolean from this DateFormat
+     * May return U_UNSUPPORTED_ERROR if this instance does not support
+     * the specified attribute.
+     * @param attr the attribute to set
+     * @param status the error type
+     * @return the attribute value. Undefined if there is an error.
+     * @stable ICU 53
+     */
+    virtual UBool U_EXPORT2 getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &status) const;
+
+protected:
+    /**
+     * Default constructor.  Creates a DateFormat with no Calendar or NumberFormat
+     * associated with it.  This constructor depends on the subclasses to fill in
+     * the calendar and numberFormat fields.
+     * @stable ICU 2.0
+     */
+    DateFormat();
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    DateFormat(const DateFormat&);
+
+    /**
+     * Default assignment operator.
+     * @stable ICU 2.0
+     */
+    DateFormat& operator=(const DateFormat&);
+
+    /**
+     * The calendar that DateFormat uses to produce the time field values needed
+     * to implement date/time formatting. Subclasses should generally initialize
+     * this to the default calendar for the locale associated with this DateFormat.
+     * @stable ICU 2.4
+     */
+    Calendar* fCalendar;
+
+    /**
+     * The number formatter that DateFormat uses to format numbers in dates and
+     * times. Subclasses should generally initialize this to the default number
+     * format for the locale associated with this DateFormat.
+     * @stable ICU 2.4
+     */
+    NumberFormat* fNumberFormat;
+
+
+private:
+    /**
+     * Gets the date/time formatter with the given formatting styles for the
+     * given locale.
+     * @param dateStyle the given date formatting style.
+     * @param timeStyle the given time formatting style.
+     * @param inLocale the given locale.
+     * @return a date/time formatter, or 0 on failure.
+     */
+    static DateFormat* U_EXPORT2 create(EStyle timeStyle, EStyle dateStyle, const Locale& inLocale);
+
+     
+    /**
+     * enum set of active boolean attributes for this instance
+     */
+    EnumSet<UDateFormatBooleanAttribute, 0, UDAT_BOOLEAN_ATTRIBUTE_COUNT> fBoolFlags;
+
+
+    UDisplayContext fCapitalizationContext;
+    friend class DateFmtKeyByStyle;
+
+public:
+#ifndef U_HIDE_OBSOLETE_API
+    /**
+     * Field selector for FieldPosition for DateFormat fields.
+     * @obsolete ICU 3.4 use UDateFormatField instead, since this API will be
+     * removed in that release
+     */
+    enum EField
+    {
+        // Obsolete; use UDateFormatField instead
+        kEraField = UDAT_ERA_FIELD,
+        kYearField = UDAT_YEAR_FIELD,
+        kMonthField = UDAT_MONTH_FIELD,
+        kDateField = UDAT_DATE_FIELD,
+        kHourOfDay1Field = UDAT_HOUR_OF_DAY1_FIELD,
+        kHourOfDay0Field = UDAT_HOUR_OF_DAY0_FIELD,
+        kMinuteField = UDAT_MINUTE_FIELD,
+        kSecondField = UDAT_SECOND_FIELD,
+        kMillisecondField = UDAT_FRACTIONAL_SECOND_FIELD,
+        kDayOfWeekField = UDAT_DAY_OF_WEEK_FIELD,
+        kDayOfYearField = UDAT_DAY_OF_YEAR_FIELD,
+        kDayOfWeekInMonthField = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,
+        kWeekOfYearField = UDAT_WEEK_OF_YEAR_FIELD,
+        kWeekOfMonthField = UDAT_WEEK_OF_MONTH_FIELD,
+        kAmPmField = UDAT_AM_PM_FIELD,
+        kHour1Field = UDAT_HOUR1_FIELD,
+        kHour0Field = UDAT_HOUR0_FIELD,
+        kTimezoneField = UDAT_TIMEZONE_FIELD,
+        kYearWOYField = UDAT_YEAR_WOY_FIELD,
+        kDOWLocalField = UDAT_DOW_LOCAL_FIELD,
+        kExtendedYearField = UDAT_EXTENDED_YEAR_FIELD,
+        kJulianDayField = UDAT_JULIAN_DAY_FIELD,
+        kMillisecondsInDayField = UDAT_MILLISECONDS_IN_DAY_FIELD,
+
+        // Obsolete; use UDateFormatField instead
+        ERA_FIELD = UDAT_ERA_FIELD,
+        YEAR_FIELD = UDAT_YEAR_FIELD,
+        MONTH_FIELD = UDAT_MONTH_FIELD,
+        DATE_FIELD = UDAT_DATE_FIELD,
+        HOUR_OF_DAY1_FIELD = UDAT_HOUR_OF_DAY1_FIELD,
+        HOUR_OF_DAY0_FIELD = UDAT_HOUR_OF_DAY0_FIELD,
+        MINUTE_FIELD = UDAT_MINUTE_FIELD,
+        SECOND_FIELD = UDAT_SECOND_FIELD,
+        MILLISECOND_FIELD = UDAT_FRACTIONAL_SECOND_FIELD,
+        DAY_OF_WEEK_FIELD = UDAT_DAY_OF_WEEK_FIELD,
+        DAY_OF_YEAR_FIELD = UDAT_DAY_OF_YEAR_FIELD,
+        DAY_OF_WEEK_IN_MONTH_FIELD = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,
+        WEEK_OF_YEAR_FIELD = UDAT_WEEK_OF_YEAR_FIELD,
+        WEEK_OF_MONTH_FIELD = UDAT_WEEK_OF_MONTH_FIELD,
+        AM_PM_FIELD = UDAT_AM_PM_FIELD,
+        HOUR1_FIELD = UDAT_HOUR1_FIELD,
+        HOUR0_FIELD = UDAT_HOUR0_FIELD,
+        TIMEZONE_FIELD = UDAT_TIMEZONE_FIELD
+    };
+#endif  /* U_HIDE_OBSOLETE_API */
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DATEFMT
+//eof

+ 40 - 0
sqlite/unicode/dbbi.h

@@ -0,0 +1,40 @@
+/*
+**********************************************************************
+*   Copyright (C) 1999-2006,2013 IBM Corp. All rights reserved.
+**********************************************************************
+*   Date        Name        Description
+*   12/1/99    rgillam     Complete port from Java.
+*   01/13/2000 helena      Added UErrorCode to ctors.
+**********************************************************************
+*/
+
+#ifndef DBBI_H
+#define DBBI_H
+
+#include "unicode/rbbi.h"
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+/**
+ * \file
+ * \brief C++ API: Dictionary Based Break Iterator
+ */
+ 
+U_NAMESPACE_BEGIN
+
+#ifndef U_HIDE_DEPRECATED_API
+/**
+ * An obsolete subclass of RuleBasedBreakIterator. Handling of dictionary-
+ * based break iteration has been folded into the base class. This class
+ * is deprecated as of ICU 3.6.
+ * @deprecated ICU 3.6
+ */
+typedef RuleBasedBreakIterator DictionaryBasedBreakIterator;
+
+#endif  /* U_HIDE_DEPRECATED_API */
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
+
+#endif

+ 484 - 0
sqlite/unicode/dcfmtsym.h

@@ -0,0 +1,484 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2015, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File DCFMTSYM.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/18/97    clhuang     Updated per C++ implementation.
+*   03/27/97    helena      Updated to pass the simple test after code review.
+*   08/26/97    aliu        Added currency/intl currency symbol support.
+*   07/22/98    stephen     Changed to match C++ style
+*                            currencySymbol -> fCurrencySymbol
+*                            Constants changed from CAPS to kCaps
+*   06/24/99    helena      Integrated Alan's NF enhancements and Java2 bug fixes
+*   09/22/00    grhoten     Marked deprecation tags with a pointer to replacement
+*                            functions.
+********************************************************************************
+*/
+
+#ifndef DCFMTSYM_H
+#define DCFMTSYM_H
+
+#include "unicode/utypes.h"
+#include "unicode/uchar.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+#include "unicode/locid.h"
+#include "unicode/unum.h"
+
+/**
+ * \file
+ * \brief C++ API: Symbols for formatting numbers.
+ */
+
+
+U_NAMESPACE_BEGIN
+
+/**
+ * This class represents the set of symbols needed by DecimalFormat
+ * to format numbers. DecimalFormat creates for itself an instance of
+ * DecimalFormatSymbols from its locale data.  If you need to change any
+ * of these symbols, you can get the DecimalFormatSymbols object from
+ * your DecimalFormat and modify it.
+ * <P>
+ * Here are the special characters used in the parts of the
+ * subpattern, with notes on their usage.
+ * <pre>
+ * \code
+ *        Symbol   Meaning
+ *          0      a digit
+ *          #      a digit, zero shows as absent
+ *          .      placeholder for decimal separator
+ *          ,      placeholder for grouping separator.
+ *          ;      separates formats.
+ *          -      default negative prefix.
+ *          %      divide by 100 and show as percentage
+ *          X      any other characters can be used in the prefix or suffix
+ *          '      used to quote special characters in a prefix or suffix.
+ * \endcode
+ *  </pre>
+ * [Notes]
+ * <P>
+ * If there is no explicit negative subpattern, - is prefixed to the
+ * positive form. That is, "0.00" alone is equivalent to "0.00;-0.00".
+ * <P>
+ * The grouping separator is commonly used for thousands, but in some
+ * countries for ten-thousands. The interval is a constant number of
+ * digits between the grouping characters, such as 100,000,000 or 1,0000,0000.
+ * If you supply a pattern with multiple grouping characters, the interval
+ * between the last one and the end of the integer is the one that is
+ * used. So "#,##,###,####" == "######,####" == "##,####,####".
+ * <P>
+ * This class only handles localized digits where the 10 digits are
+ * contiguous in Unicode, from 0 to 9. Other digits sets (such as
+ * superscripts) would need a different subclass.
+ */
+class U_I18N_API DecimalFormatSymbols : public UObject {
+public:
+    /**
+     * Constants for specifying a number format symbol.
+     * @stable ICU 2.0
+     */
+    enum ENumberFormatSymbol {
+        /** The decimal separator */
+        kDecimalSeparatorSymbol,
+        /** The grouping separator */
+        kGroupingSeparatorSymbol,
+        /** The pattern separator */
+        kPatternSeparatorSymbol,
+        /** The percent sign */
+        kPercentSymbol,
+        /** Zero*/
+        kZeroDigitSymbol,
+        /** Character representing a digit in the pattern */
+        kDigitSymbol,
+        /** The minus sign */
+        kMinusSignSymbol,
+        /** The plus sign */
+        kPlusSignSymbol,
+        /** The currency symbol */
+        kCurrencySymbol,
+        /** The international currency symbol */
+        kIntlCurrencySymbol,
+        /** The monetary separator */
+        kMonetarySeparatorSymbol,
+        /** The exponential symbol */
+        kExponentialSymbol,
+        /** Per mill symbol - replaces kPermillSymbol */
+        kPerMillSymbol,
+        /** Escape padding character */
+        kPadEscapeSymbol,
+        /** Infinity symbol */
+        kInfinitySymbol,
+        /** Nan symbol */
+        kNaNSymbol,
+        /** Significant digit symbol
+         * @stable ICU 3.0 */
+        kSignificantDigitSymbol,
+        /** The monetary grouping separator
+         * @stable ICU 3.6
+         */
+        kMonetaryGroupingSeparatorSymbol,
+        /** One
+         * @stable ICU 4.6
+         */
+        kOneDigitSymbol,
+        /** Two
+         * @stable ICU 4.6
+         */
+        kTwoDigitSymbol,
+        /** Three
+         * @stable ICU 4.6
+         */
+        kThreeDigitSymbol,
+        /** Four
+         * @stable ICU 4.6
+         */
+        kFourDigitSymbol,
+        /** Five
+         * @stable ICU 4.6
+         */
+        kFiveDigitSymbol,
+        /** Six
+         * @stable ICU 4.6
+         */
+        kSixDigitSymbol,
+        /** Seven
+         * @stable ICU 4.6
+         */
+        kSevenDigitSymbol,
+        /** Eight
+         * @stable ICU 4.6
+         */
+        kEightDigitSymbol,
+        /** Nine
+         * @stable ICU 4.6
+         */
+        kNineDigitSymbol,
+#ifndef U_HIDE_DRAFT_API
+        /** Multiplication sign.
+         * @draft ICU 54
+         */
+        kExponentMultiplicationSymbol,
+#endif  /* U_HIDE_DRAFT_API */
+        /** count symbol constants */
+        kFormatSymbolCount = kNineDigitSymbol + 2
+    };
+
+    /**
+     * Create a DecimalFormatSymbols object for the given locale.
+     *
+     * @param locale    The locale to get symbols for.
+     * @param status    Input/output parameter, set to success or
+     *                  failure code upon return.
+     * @stable ICU 2.0
+     */
+    DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
+
+    /**
+     * Create a DecimalFormatSymbols object for the default locale.
+     * This constructor will not fail.  If the resource file data is
+     * not available, it will use hard-coded last-resort data and
+     * set status to U_USING_FALLBACK_ERROR.
+     *
+     * @param status    Input/output parameter, set to success or
+     *                  failure code upon return.
+     * @stable ICU 2.0
+     */
+    DecimalFormatSymbols(UErrorCode& status);
+
+    /**
+     * Creates a DecimalFormatSymbols object with last-resort data.
+     * Intended for callers who cache the symbols data and
+     * set all symbols on the resulting object.
+     *
+     * The last-resort symbols are similar to those for the root data,
+     * except that the grouping separators are empty,
+     * the NaN symbol is U+FFFD rather than "NaN",
+     * and the CurrencySpacing patterns are empty.
+     *
+     * @param status    Input/output parameter, set to success or
+     *                  failure code upon return.
+     * @return last-resort symbols
+     * @stable ICU 52
+     */
+    static DecimalFormatSymbols* createWithLastResortData(UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    DecimalFormatSymbols(const DecimalFormatSymbols&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 2.0
+     */
+    DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~DecimalFormatSymbols();
+
+    /**
+     * Return true if another object is semantically equal to this one.
+     *
+     * @param other    the object to be compared with.
+     * @return         true if another object is semantically equal to this one.
+     * @stable ICU 2.0
+     */
+    UBool operator==(const DecimalFormatSymbols& other) const;
+
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the object to be compared with.
+     * @return         true if another object is semantically unequal to this one.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
+
+    /**
+     * Get one of the format symbols by its enum constant.
+     * Each symbol is stored as a string so that graphemes
+     * (characters with modifier letters) can be used.
+     *
+     * @param symbol    Constant to indicate a number format symbol.
+     * @return    the format symbols by the param 'symbol'
+     * @stable ICU 2.0
+     */
+    inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
+
+    /**
+     * Set one of the format symbols by its enum constant.
+     * Each symbol is stored as a string so that graphemes
+     * (characters with modifier letters) can be used.
+     *
+     * @param symbol    Constant to indicate a number format symbol.
+     * @param value     value of the format symbol
+     * @param propogateDigits If false, setting the zero digit will not automatically set 1-9.
+     *     The default behavior is to automatically set 1-9 if zero is being set and the value
+     *     it is being set to corresponds to a known Unicode zero digit.
+     * @stable ICU 2.0
+     */
+    void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits);
+
+    /**
+     * Returns the locale for which this object was constructed.
+     * @stable ICU 2.6
+     */
+    inline Locale getLocale() const;
+
+    /**
+     * Returns the locale for this object. Two flavors are available:
+     * valid and actual locale.
+     * @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+    /**
+      * Get pattern string for 'CurrencySpacing' that can be applied to
+      * currency format.
+      * This API gets the CurrencySpacing data from ResourceBundle. The pattern can
+      * be empty if there is no data from current locale and its parent locales.
+      *
+      * @param type :  UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT.
+      * @param beforeCurrency : true if the pattern is for before currency symbol.
+      *                         false if the pattern is for after currency symbol.
+      * @param status: Input/output parameter, set to success or
+      *                  failure code upon return.
+      * @return pattern string for currencyMatch, surroundingMatch or spaceInsert.
+      *     Return empty string if there is no data for this locale and its parent
+      *     locales.
+      * @stable ICU 4.8
+      */
+     const UnicodeString& getPatternForCurrencySpacing(UCurrencySpacing type,
+                                                 UBool beforeCurrency,
+                                                 UErrorCode& status) const;
+     /**
+       * Set pattern string for 'CurrencySpacing' that can be applied to
+       * currency format.
+       *
+       * @param type : UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT.
+       * @param beforeCurrency : true if the pattern is for before currency symbol.
+       *                         false if the pattern is for after currency symbol.
+       * @param pattern : pattern string to override current setting.
+       * @stable ICU 4.8
+       */
+     void setPatternForCurrencySpacing(UCurrencySpacing type,
+                                       UBool beforeCurrency,
+                                       const UnicodeString& pattern);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+    DecimalFormatSymbols();
+
+    /**
+     * Initializes the symbols from the LocaleElements resource bundle.
+     * Note: The organization of LocaleElements badly needs to be
+     * cleaned up.
+     *
+     * @param locale               The locale to get symbols for.
+     * @param success              Input/output parameter, set to success or
+     *                             failure code upon return.
+     * @param useLastResortData    determine if use last resort data
+     */
+    void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
+
+    /**
+     * Initialize the symbols with default values.
+     */
+    void initialize();
+
+    void setCurrencyForSymbols();
+
+public:
+    /**
+     * _Internal_ function - more efficient version of getSymbol,
+     * returning a const reference to one of the symbol strings.
+     * The returned reference becomes invalid when the symbol is changed
+     * or when the DecimalFormatSymbols are destroyed.
+     * ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be really public.
+     * Note: moved #ifndef U_HIDE_INTERNAL_API after this, since this is needed for inline in DecimalFormat
+     *
+     * @param symbol Constant to indicate a number format symbol.
+     * @return the format symbol by the param 'symbol'
+     * @internal
+     */
+    inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Returns that pattern stored in currecy info. Internal API for use by NumberFormat API.
+     * @internal
+     */
+    inline const UChar* getCurrencyPattern(void) const;
+#endif  /* U_HIDE_INTERNAL_API */
+
+private:
+    /**
+     * Private symbol strings.
+     * They are either loaded from a resource bundle or otherwise owned.
+     * setSymbol() clones the symbol string.
+     * Readonly aliases can only come from a resource bundle, so that we can always
+     * use fastCopyFrom() with them.
+     *
+     * If DecimalFormatSymbols becomes subclassable and the status of fSymbols changes
+     * from private to protected,
+     * or when fSymbols can be set any other way that allows them to be readonly aliases
+     * to non-resource bundle strings,
+     * then regular UnicodeString copies must be used instead of fastCopyFrom().
+     *
+     * @internal
+     */
+    UnicodeString fSymbols[kFormatSymbolCount];
+
+    /**
+     * Non-symbol variable for getConstSymbol(). Always empty.
+     * @internal
+     */
+    UnicodeString fNoSymbol;
+
+    Locale locale;
+
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+    const UChar* currPattern;
+
+    UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT];
+    UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT];
+};
+
+// -------------------------------------
+
+inline UnicodeString
+DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
+    const UnicodeString *strPtr;
+    if(symbol < kFormatSymbolCount) {
+        strPtr = &fSymbols[symbol];
+    } else {
+        strPtr = &fNoSymbol;
+    }
+    return *strPtr;
+}
+
+//#ifndef U_HIDE_INTERNAL_API
+// See comments above for this function. Not hidden.
+inline const UnicodeString &
+DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
+    const UnicodeString *strPtr;
+    if(symbol < kFormatSymbolCount) {
+        strPtr = &fSymbols[symbol];
+    } else {
+        strPtr = &fNoSymbol;
+    }
+    return *strPtr;
+}
+
+//#endif  /* U_HIDE_INTERNAL_API */
+
+
+// -------------------------------------
+
+inline void
+DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits = TRUE) {
+    if(symbol<kFormatSymbolCount) {
+        fSymbols[symbol]=value;
+    }
+
+    // If the zero digit is being set to a known zero digit according to Unicode,
+    // then we automatically set the corresponding 1-9 digits
+    if ( propogateDigits && symbol == kZeroDigitSymbol && value.countChar32() == 1 ) {
+        UChar32 sym = value.char32At(0);
+        if ( u_charDigitValue(sym) == 0 ) {
+            for ( int8_t i = 1 ; i<= 9 ; i++ ) {
+                sym++;
+                fSymbols[(int)kOneDigitSymbol+i-1] = UnicodeString(sym);
+            }
+        }
+    }
+}
+
+// -------------------------------------
+
+inline Locale
+DecimalFormatSymbols::getLocale() const {
+    return locale;
+}
+
+#ifndef U_HIDE_INTERNAL_API
+inline const UChar*
+DecimalFormatSymbols::getCurrencyPattern() const {
+    return currPattern;
+}
+#endif /* U_HIDE_INTERNAL_API */
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DCFMTSYM
+//eof

+ 2478 - 0
sqlite/unicode/decimfmt.h

@@ -0,0 +1,2478 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2015, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File DECIMFMT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/20/97    clhuang     Updated per C++ implementation.
+*   04/03/97    aliu        Rewrote parsing and formatting completely, and
+*                           cleaned up and debugged.  Actually works now.
+*   04/17/97    aliu        Changed DigitCount to int per code review.
+*   07/10/97    helena      Made ParsePosition a class and get rid of the function
+*                           hiding problems.
+*   09/09/97    aliu        Ported over support for exponential formats.
+*   07/20/98    stephen     Changed documentation
+*   01/30/13    emmons      Added Scaling methods
+********************************************************************************
+*/
+
+#ifndef DECIMFMT_H
+#define DECIMFMT_H
+
+#include "unicode/utypes.h"
+/**
+ * \file
+ * \brief C++ API: Formats decimal numbers.
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/dcfmtsym.h"
+#include "unicode/numfmt.h"
+#include "unicode/locid.h"
+#include "unicode/fpositer.h"
+#include "unicode/stringpiece.h"
+#include "unicode/curramt.h"
+#include "unicode/enumset.h"
+
+/**
+ * \def UNUM_DECIMALFORMAT_INTERNAL_SIZE
+ * @internal
+ */
+#if UCONFIG_FORMAT_FASTPATHS_49
+#define UNUM_DECIMALFORMAT_INTERNAL_SIZE 16
+#endif
+
+U_NAMESPACE_BEGIN
+
+class DigitList;
+class ChoiceFormat;
+class CurrencyPluralInfo;
+class Hashtable;
+class UnicodeSet;
+class FieldPositionHandler;
+class DecimalFormatStaticSets;
+class FixedDecimal;
+
+// explicit template instantiation. see digitlst.h
+#if defined (_MSC_VER)
+template class U_I18N_API    EnumSet<UNumberFormatAttribute,
+            UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
+            UNUM_LIMIT_BOOLEAN_ATTRIBUTE>;
+#endif
+
+/**
+ * DecimalFormat is a concrete subclass of NumberFormat that formats decimal
+ * numbers. It has a variety of features designed to make it possible to parse
+ * and format numbers in any locale, including support for Western, Arabic, or
+ * Indic digits.  It also supports different flavors of numbers, including
+ * integers ("123"), fixed-point numbers ("123.4"), scientific notation
+ * ("1.23E4"), percentages ("12%"), and currency amounts ("$123", "USD123",
+ * "123 US dollars").  All of these flavors can be easily localized.
+ *
+ * <p>To obtain a NumberFormat for a specific locale (including the default
+ * locale) call one of NumberFormat's factory methods such as
+ * createInstance(). Do not call the DecimalFormat constructors directly, unless
+ * you know what you are doing, since the NumberFormat factory methods may
+ * return subclasses other than DecimalFormat.
+ *
+ * <p><strong>Example Usage</strong>
+ *
+ * \code
+ *     // Normally we would have a GUI with a menu for this
+ *     int32_t locCount;
+ *     const Locale* locales = NumberFormat::getAvailableLocales(locCount);
+ *
+ *     double myNumber = -1234.56;
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     NumberFormat* form;
+ *
+ *     // Print out a number with the localized number, currency and percent
+ *     // format for each locale.
+ *     UnicodeString countryName;
+ *     UnicodeString displayName;
+ *     UnicodeString str;
+ *     UnicodeString pattern;
+ *     Formattable fmtable;
+ *     for (int32_t j = 0; j < 3; ++j) {
+ *         cout << endl << "FORMAT " << j << endl;
+ *         for (int32_t i = 0; i < locCount; ++i) {
+ *             if (locales[i].getCountry(countryName).size() == 0) {
+ *                 // skip language-only
+ *                 continue;
+ *             }
+ *             switch (j) {
+ *             case 0:
+ *                 form = NumberFormat::createInstance(locales[i], success ); break;
+ *             case 1:
+ *                 form = NumberFormat::createCurrencyInstance(locales[i], success ); break;
+ *             default:
+ *                 form = NumberFormat::createPercentInstance(locales[i], success ); break;
+ *             }
+ *             if (form) {
+ *                 str.remove();
+ *                 pattern = ((DecimalFormat*)form)->toPattern(pattern);
+ *                 cout << locales[i].getDisplayName(displayName) << ": " << pattern;
+ *                 cout << "  ->  " << form->format(myNumber,str) << endl;
+ *                 form->parse(form->format(myNumber,str), fmtable, success);
+ *                 delete form;
+ *             }
+ *         }
+ *     }
+ * \endcode
+ * <P>
+ * Another example use createInstance(style)
+ * <P>
+ * <pre>
+ * <strong>// Print out a number using the localized number, currency,
+ * // percent, scientific, integer, iso currency, and plural currency
+ * // format for each locale</strong>
+ * Locale* locale = new Locale("en", "US");
+ * double myNumber = 1234.56;
+ * UErrorCode success = U_ZERO_ERROR;
+ * UnicodeString str;
+ * Formattable fmtable;
+ * for (int j=NumberFormat::kNumberStyle;
+ *      j<=NumberFormat::kPluralCurrencyStyle;
+ *      ++j) {
+ *     NumberFormat* format = NumberFormat::createInstance(locale, j, success);
+ *     str.remove();
+ *     cout << "format result " << form->format(myNumber, str) << endl;
+ *     format->parse(form->format(myNumber, str), fmtable, success);
+ * }</pre>
+ *
+ *
+ * <p><strong>Patterns</strong>
+ *
+ * <p>A DecimalFormat consists of a <em>pattern</em> and a set of
+ * <em>symbols</em>.  The pattern may be set directly using
+ * applyPattern(), or indirectly using other API methods which
+ * manipulate aspects of the pattern, such as the minimum number of integer
+ * digits.  The symbols are stored in a DecimalFormatSymbols
+ * object.  When using the NumberFormat factory methods, the
+ * pattern and symbols are read from ICU's locale data.
+ *
+ * <p><strong>Special Pattern Characters</strong>
+ *
+ * <p>Many characters in a pattern are taken literally; they are matched during
+ * parsing and output unchanged during formatting.  Special characters, on the
+ * other hand, stand for other characters, strings, or classes of characters.
+ * For example, the '#' character is replaced by a localized digit.  Often the
+ * replacement character is the same as the pattern character; in the U.S. locale,
+ * the ',' grouping character is replaced by ','.  However, the replacement is
+ * still happening, and if the symbols are modified, the grouping character
+ * changes.  Some special characters affect the behavior of the formatter by
+ * their presence; for example, if the percent character is seen, then the
+ * value is multiplied by 100 before being displayed.
+ *
+ * <p>To insert a special character in a pattern as a literal, that is, without
+ * any special meaning, the character must be quoted.  There are some exceptions to
+ * this which are noted below.
+ *
+ * <p>The characters listed here are used in non-localized patterns.  Localized
+ * patterns use the corresponding characters taken from this formatter's
+ * DecimalFormatSymbols object instead, and these characters lose
+ * their special status.  Two exceptions are the currency sign and quote, which
+ * are not localized.
+ *
+ * <table border=0 cellspacing=3 cellpadding=0>
+ *   <tr bgcolor="#ccccff">
+ *     <td align=left><strong>Symbol</strong>
+ *     <td align=left><strong>Location</strong>
+ *     <td align=left><strong>Localized?</strong>
+ *     <td align=left><strong>Meaning</strong>
+ *   <tr valign=top>
+ *     <td><code>0</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Digit
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>1-9</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>'1' through '9' indicate rounding.
+ *   <tr valign=top>
+ *     <td><code>\htmlonly&#x40;\endhtmlonly</code> <!--doxygen doesn't like @-->
+ *     <td>Number
+ *     <td>No
+ *     <td>Significant digit
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>#</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Digit, zero shows as absent
+ *   <tr valign=top>
+ *     <td><code>.</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Decimal separator or monetary decimal separator
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>-</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Minus sign
+ *   <tr valign=top>
+ *     <td><code>,</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Grouping separator
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>E</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Separates mantissa and exponent in scientific notation.
+ *         <em>Need not be quoted in prefix or suffix.</em>
+ *   <tr valign=top>
+ *     <td><code>+</code>
+ *     <td>Exponent
+ *     <td>Yes
+ *     <td>Prefix positive exponents with localized plus sign.
+ *         <em>Need not be quoted in prefix or suffix.</em>
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>;</code>
+ *     <td>Subpattern boundary
+ *     <td>Yes
+ *     <td>Separates positive and negative subpatterns
+ *   <tr valign=top>
+ *     <td><code>\%</code>
+ *     <td>Prefix or suffix
+ *     <td>Yes
+ *     <td>Multiply by 100 and show as percentage
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>\\u2030</code>
+ *     <td>Prefix or suffix
+ *     <td>Yes
+ *     <td>Multiply by 1000 and show as per mille
+ *   <tr valign=top>
+ *     <td><code>\htmlonly&curren;\endhtmlonly</code> (<code>\\u00A4</code>)
+ *     <td>Prefix or suffix
+ *     <td>No
+ *     <td>Currency sign, replaced by currency symbol.  If
+ *         doubled, replaced by international currency symbol.
+ *         If tripled, replaced by currency plural names, for example,
+ *         "US dollar" or "US dollars" for America.
+ *         If present in a pattern, the monetary decimal separator
+ *         is used instead of the decimal separator.
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>'</code>
+ *     <td>Prefix or suffix
+ *     <td>No
+ *     <td>Used to quote special characters in a prefix or suffix,
+ *         for example, <code>"'#'#"</code> formats 123 to
+ *         <code>"#123"</code>.  To create a single quote
+ *         itself, use two in a row: <code>"# o''clock"</code>.
+ *   <tr valign=top>
+ *     <td><code>*</code>
+ *     <td>Prefix or suffix boundary
+ *     <td>Yes
+ *     <td>Pad escape, precedes pad character
+ * </table>
+ *
+ * <p>A DecimalFormat pattern contains a postive and negative
+ * subpattern, for example, "#,##0.00;(#,##0.00)".  Each subpattern has a
+ * prefix, a numeric part, and a suffix.  If there is no explicit negative
+ * subpattern, the negative subpattern is the localized minus sign prefixed to the
+ * positive subpattern. That is, "0.00" alone is equivalent to "0.00;-0.00".  If there
+ * is an explicit negative subpattern, it serves only to specify the negative
+ * prefix and suffix; the number of digits, minimal digits, and other
+ * characteristics are ignored in the negative subpattern. That means that
+ * "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)".
+ *
+ * <p>The prefixes, suffixes, and various symbols used for infinity, digits,
+ * thousands separators, decimal separators, etc. may be set to arbitrary
+ * values, and they will appear properly during formatting.  However, care must
+ * be taken that the symbols and strings do not conflict, or parsing will be
+ * unreliable.  For example, either the positive and negative prefixes or the
+ * suffixes must be distinct for parse() to be able
+ * to distinguish positive from negative values.  Another example is that the
+ * decimal separator and thousands separator should be distinct characters, or
+ * parsing will be impossible.
+ *
+ * <p>The <em>grouping separator</em> is a character that separates clusters of
+ * integer digits to make large numbers more legible.  It commonly used for
+ * thousands, but in some locales it separates ten-thousands.  The <em>grouping
+ * size</em> is the number of digits between the grouping separators, such as 3
+ * for "100,000,000" or 4 for "1 0000 0000". There are actually two different
+ * grouping sizes: One used for the least significant integer digits, the
+ * <em>primary grouping size</em>, and one used for all others, the
+ * <em>secondary grouping size</em>.  In most locales these are the same, but
+ * sometimes they are different. For example, if the primary grouping interval
+ * is 3, and the secondary is 2, then this corresponds to the pattern
+ * "#,##,##0", and the number 123456789 is formatted as "12,34,56,789".  If a
+ * pattern contains multiple grouping separators, the interval between the last
+ * one and the end of the integer defines the primary grouping size, and the
+ * interval between the last two defines the secondary grouping size. All others
+ * are ignored, so "#,##,###,####" == "###,###,####" == "##,#,###,####".
+ *
+ * <p>Illegal patterns, such as "#.#.#" or "#.###,###", will cause
+ * DecimalFormat to set a failing UErrorCode.
+ *
+ * <p><strong>Pattern BNF</strong>
+ *
+ * <pre>
+ * pattern    := subpattern (';' subpattern)?
+ * subpattern := prefix? number exponent? suffix?
+ * number     := (integer ('.' fraction)?) | sigDigits
+ * prefix     := '\\u0000'..'\\uFFFD' - specialCharacters
+ * suffix     := '\\u0000'..'\\uFFFD' - specialCharacters
+ * integer    := '#'* '0'* '0'
+ * fraction   := '0'* '#'*
+ * sigDigits  := '#'* '@' '@'* '#'*
+ * exponent   := 'E' '+'? '0'* '0'
+ * padSpec    := '*' padChar
+ * padChar    := '\\u0000'..'\\uFFFD' - quote
+ * &nbsp;
+ * Notation:
+ *   X*       0 or more instances of X
+ *   X?       0 or 1 instances of X
+ *   X|Y      either X or Y
+ *   C..D     any character from C up to D, inclusive
+ *   S-T      characters in S, except those in T
+ * </pre>
+ * The first subpattern is for positive numbers. The second (optional)
+ * subpattern is for negative numbers.
+ *
+ * <p>Not indicated in the BNF syntax above:
+ *
+ * <ul><li>The grouping separator ',' can occur inside the integer and
+ * sigDigits elements, between any two pattern characters of that
+ * element, as long as the integer or sigDigits element is not
+ * followed by the exponent element.
+ *
+ * <li>Two grouping intervals are recognized: That between the
+ *     decimal point and the first grouping symbol, and that
+ *     between the first and second grouping symbols. These
+ *     intervals are identical in most locales, but in some
+ *     locales they differ. For example, the pattern
+ *     &quot;#,##,###&quot; formats the number 123456789 as
+ *     &quot;12,34,56,789&quot;.</li>
+ *
+ * <li>The pad specifier <code>padSpec</code> may appear before the prefix,
+ * after the prefix, before the suffix, after the suffix, or not at all.
+ *
+ * <li>In place of '0', the digits '1' through '9' may be used to
+ * indicate a rounding increment.
+ * </ul>
+ *
+ * <p><strong>Parsing</strong>
+ *
+ * <p>DecimalFormat parses all Unicode characters that represent
+ * decimal digits, as defined by u_charDigitValue().  In addition,
+ * DecimalFormat also recognizes as digits the ten consecutive
+ * characters starting with the localized zero digit defined in the
+ * DecimalFormatSymbols object.  During formatting, the
+ * DecimalFormatSymbols-based digits are output.
+ *
+ * <p>During parsing, grouping separators are ignored if in lenient mode;
+ * otherwise, if present, they must be in appropriate positions.
+ *
+ * <p>For currency parsing, the formatter is able to parse every currency
+ * style formats no matter which style the formatter is constructed with.
+ * For example, a formatter instance gotten from
+ * NumberFormat.getInstance(ULocale, NumberFormat.CURRENCYSTYLE) can parse
+ * formats such as "USD1.00" and "3.00 US dollars".
+ *
+ * <p>If parse(UnicodeString&,Formattable&,ParsePosition&)
+ * fails to parse a string, it leaves the parse position unchanged.
+ * The convenience method parse(UnicodeString&,Formattable&,UErrorCode&)
+ * indicates parse failure by setting a failing
+ * UErrorCode.
+ *
+ * <p><strong>Formatting</strong>
+ *
+ * <p>Formatting is guided by several parameters, all of which can be
+ * specified either using a pattern or using the API.  The following
+ * description applies to formats that do not use <a href="#sci">scientific
+ * notation</a> or <a href="#sigdig">significant digits</a>.
+ *
+ * <ul><li>If the number of actual integer digits exceeds the
+ * <em>maximum integer digits</em>, then only the least significant
+ * digits are shown.  For example, 1997 is formatted as "97" if the
+ * maximum integer digits is set to 2.
+ *
+ * <li>If the number of actual integer digits is less than the
+ * <em>minimum integer digits</em>, then leading zeros are added.  For
+ * example, 1997 is formatted as "01997" if the minimum integer digits
+ * is set to 5.
+ *
+ * <li>If the number of actual fraction digits exceeds the <em>maximum
+ * fraction digits</em>, then rounding is performed to the
+ * maximum fraction digits.  For example, 0.125 is formatted as "0.12"
+ * if the maximum fraction digits is 2.  This behavior can be changed
+ * by specifying a rounding increment and/or a rounding mode.
+ *
+ * <li>If the number of actual fraction digits is less than the
+ * <em>minimum fraction digits</em>, then trailing zeros are added.
+ * For example, 0.125 is formatted as "0.1250" if the mimimum fraction
+ * digits is set to 4.
+ *
+ * <li>Trailing fractional zeros are not displayed if they occur
+ * <em>j</em> positions after the decimal, where <em>j</em> is less
+ * than the maximum fraction digits. For example, 0.10004 is
+ * formatted as "0.1" if the maximum fraction digits is four or less.
+ * </ul>
+ *
+ * <p><strong>Special Values</strong>
+ *
+ * <p><code>NaN</code> is represented as a single character, typically
+ * <code>\\uFFFD</code>.  This character is determined by the
+ * DecimalFormatSymbols object.  This is the only value for which
+ * the prefixes and suffixes are not used.
+ *
+ * <p>Infinity is represented as a single character, typically
+ * <code>\\u221E</code>, with the positive or negative prefixes and suffixes
+ * applied.  The infinity character is determined by the
+ * DecimalFormatSymbols object.
+ *
+ * <a name="sci"><strong>Scientific Notation</strong></a>
+ *
+ * <p>Numbers in scientific notation are expressed as the product of a mantissa
+ * and a power of ten, for example, 1234 can be expressed as 1.234 x 10<sup>3</sup>. The
+ * mantissa is typically in the half-open interval [1.0, 10.0) or sometimes [0.0, 1.0),
+ * but it need not be.  DecimalFormat supports arbitrary mantissas.
+ * DecimalFormat can be instructed to use scientific
+ * notation through the API or through the pattern.  In a pattern, the exponent
+ * character immediately followed by one or more digit characters indicates
+ * scientific notation.  Example: "0.###E0" formats the number 1234 as
+ * "1.234E3".
+ *
+ * <ul>
+ * <li>The number of digit characters after the exponent character gives the
+ * minimum exponent digit count.  There is no maximum.  Negative exponents are
+ * formatted using the localized minus sign, <em>not</em> the prefix and suffix
+ * from the pattern.  This allows patterns such as "0.###E0 m/s".  To prefix
+ * positive exponents with a localized plus sign, specify '+' between the
+ * exponent and the digits: "0.###E+0" will produce formats "1E+1", "1E+0",
+ * "1E-1", etc.  (In localized patterns, use the localized plus sign rather than
+ * '+'.)
+ *
+ * <li>The minimum number of integer digits is achieved by adjusting the
+ * exponent.  Example: 0.00123 formatted with "00.###E0" yields "12.3E-4".  This
+ * only happens if there is no maximum number of integer digits.  If there is a
+ * maximum, then the minimum number of integer digits is fixed at one.
+ *
+ * <li>The maximum number of integer digits, if present, specifies the exponent
+ * grouping.  The most common use of this is to generate <em>engineering
+ * notation</em>, in which the exponent is a multiple of three, e.g.,
+ * "##0.###E0".  The number 12345 is formatted using "##0.####E0" as "12.345E3".
+ *
+ * <li>When using scientific notation, the formatter controls the
+ * digit counts using significant digits logic.  The maximum number of
+ * significant digits limits the total number of integer and fraction
+ * digits that will be shown in the mantissa; it does not affect
+ * parsing.  For example, 12345 formatted with "##0.##E0" is "12.3E3".
+ * See the section on significant digits for more details.
+ *
+ * <li>The number of significant digits shown is determined as
+ * follows: If areSignificantDigitsUsed() returns false, then the
+ * minimum number of significant digits shown is one, and the maximum
+ * number of significant digits shown is the sum of the <em>minimum
+ * integer</em> and <em>maximum fraction</em> digits, and is
+ * unaffected by the maximum integer digits.  If this sum is zero,
+ * then all significant digits are shown.  If
+ * areSignificantDigitsUsed() returns true, then the significant digit
+ * counts are specified by getMinimumSignificantDigits() and
+ * getMaximumSignificantDigits().  In this case, the number of
+ * integer digits is fixed at one, and there is no exponent grouping.
+ *
+ * <li>Exponential patterns may not contain grouping separators.
+ * </ul>
+ *
+ * <a name="sigdig"><strong>Significant Digits</strong></a>
+ *
+ * <code>DecimalFormat</code> has two ways of controlling how many
+ * digits are shows: (a) significant digits counts, or (b) integer and
+ * fraction digit counts.  Integer and fraction digit counts are
+ * described above.  When a formatter is using significant digits
+ * counts, the number of integer and fraction digits is not specified
+ * directly, and the formatter settings for these counts are ignored.
+ * Instead, the formatter uses however many integer and fraction
+ * digits are required to display the specified number of significant
+ * digits.  Examples:
+ *
+ * <table border=0 cellspacing=3 cellpadding=0>
+ *   <tr bgcolor="#ccccff">
+ *     <td align=left>Pattern
+ *     <td align=left>Minimum significant digits
+ *     <td align=left>Maximum significant digits
+ *     <td align=left>Number
+ *     <td align=left>Output of format()
+ *   <tr valign=top>
+ *     <td><code>\@\@\@</code>
+ *     <td>3
+ *     <td>3
+ *     <td>12345
+ *     <td><code>12300</code>
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>\@\@\@</code>
+ *     <td>3
+ *     <td>3
+ *     <td>0.12345
+ *     <td><code>0.123</code>
+ *   <tr valign=top>
+ *     <td><code>\@\@##</code>
+ *     <td>2
+ *     <td>4
+ *     <td>3.14159
+ *     <td><code>3.142</code>
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>\@\@##</code>
+ *     <td>2
+ *     <td>4
+ *     <td>1.23004
+ *     <td><code>1.23</code>
+ * </table>
+ *
+ * <ul>
+ * <li>Significant digit counts may be expressed using patterns that
+ * specify a minimum and maximum number of significant digits.  These
+ * are indicated by the <code>'@'</code> and <code>'#'</code>
+ * characters.  The minimum number of significant digits is the number
+ * of <code>'@'</code> characters.  The maximum number of significant
+ * digits is the number of <code>'@'</code> characters plus the number
+ * of <code>'#'</code> characters following on the right.  For
+ * example, the pattern <code>"@@@"</code> indicates exactly 3
+ * significant digits.  The pattern <code>"@##"</code> indicates from
+ * 1 to 3 significant digits.  Trailing zero digits to the right of
+ * the decimal separator are suppressed after the minimum number of
+ * significant digits have been shown.  For example, the pattern
+ * <code>"@##"</code> formats the number 0.1203 as
+ * <code>"0.12"</code>.
+ *
+ * <li>If a pattern uses significant digits, it may not contain a
+ * decimal separator, nor the <code>'0'</code> pattern character.
+ * Patterns such as <code>"@00"</code> or <code>"@.###"</code> are
+ * disallowed.
+ *
+ * <li>Any number of <code>'#'</code> characters may be prepended to
+ * the left of the leftmost <code>'@'</code> character.  These have no
+ * effect on the minimum and maximum significant digits counts, but
+ * may be used to position grouping separators.  For example,
+ * <code>"#,#@#"</code> indicates a minimum of one significant digits,
+ * a maximum of two significant digits, and a grouping size of three.
+ *
+ * <li>In order to enable significant digits formatting, use a pattern
+ * containing the <code>'@'</code> pattern character.  Alternatively,
+ * call setSignificantDigitsUsed(TRUE).
+ *
+ * <li>In order to disable significant digits formatting, use a
+ * pattern that does not contain the <code>'@'</code> pattern
+ * character. Alternatively, call setSignificantDigitsUsed(FALSE).
+ *
+ * <li>The number of significant digits has no effect on parsing.
+ *
+ * <li>Significant digits may be used together with exponential notation. Such
+ * patterns are equivalent to a normal exponential pattern with a minimum and
+ * maximum integer digit count of one, a minimum fraction digit count of
+ * <code>getMinimumSignificantDigits() - 1</code>, and a maximum fraction digit
+ * count of <code>getMaximumSignificantDigits() - 1</code>. For example, the
+ * pattern <code>"@@###E0"</code> is equivalent to <code>"0.0###E0"</code>.
+ *
+ * <li>If signficant digits are in use, then the integer and fraction
+ * digit counts, as set via the API, are ignored.  If significant
+ * digits are not in use, then the signficant digit counts, as set via
+ * the API, are ignored.
+ *
+ * </ul>
+ *
+ * <p><strong>Padding</strong>
+ *
+ * <p>DecimalFormat supports padding the result of
+ * format() to a specific width.  Padding may be specified either
+ * through the API or through the pattern syntax.  In a pattern the pad escape
+ * character, followed by a single pad character, causes padding to be parsed
+ * and formatted.  The pad escape character is '*' in unlocalized patterns, and
+ * can be localized using DecimalFormatSymbols::setSymbol() with a
+ * DecimalFormatSymbols::kPadEscapeSymbol
+ * selector.  For example, <code>"$*x#,##0.00"</code> formats 123 to
+ * <code>"$xx123.00"</code>, and 1234 to <code>"$1,234.00"</code>.
+ *
+ * <ul>
+ * <li>When padding is in effect, the width of the positive subpattern,
+ * including prefix and suffix, determines the format width.  For example, in
+ * the pattern <code>"* #0 o''clock"</code>, the format width is 10.
+ *
+ * <li>The width is counted in 16-bit code units (UChars).
+ *
+ * <li>Some parameters which usually do not matter have meaning when padding is
+ * used, because the pattern width is significant with padding.  In the pattern
+ * "* ##,##,#,##0.##", the format width is 14.  The initial characters "##,##,"
+ * do not affect the grouping size or maximum integer digits, but they do affect
+ * the format width.
+ *
+ * <li>Padding may be inserted at one of four locations: before the prefix,
+ * after the prefix, before the suffix, or after the suffix.  If padding is
+ * specified in any other location, applyPattern()
+ * sets a failing UErrorCode.  If there is no prefix,
+ * before the prefix and after the prefix are equivalent, likewise for the
+ * suffix.
+ *
+ * <li>When specified in a pattern, the 32-bit code point immediately
+ * following the pad escape is the pad character. This may be any character,
+ * including a special pattern character. That is, the pad escape
+ * <em>escapes</em> the following character. If there is no character after
+ * the pad escape, then the pattern is illegal.
+ *
+ * </ul>
+ *
+ * <p><strong>Rounding</strong>
+ *
+ * <p>DecimalFormat supports rounding to a specific increment.  For
+ * example, 1230 rounded to the nearest 50 is 1250.  1.234 rounded to the
+ * nearest 0.65 is 1.3.  The rounding increment may be specified through the API
+ * or in a pattern.  To specify a rounding increment in a pattern, include the
+ * increment in the pattern itself.  "#,#50" specifies a rounding increment of
+ * 50.  "#,##0.05" specifies a rounding increment of 0.05.
+ *
+ * <p>In the absense of an explicit rounding increment numbers are
+ * rounded to their formatted width.
+ *
+ * <ul>
+ * <li>Rounding only affects the string produced by formatting.  It does
+ * not affect parsing or change any numerical values.
+ *
+ * <li>A <em>rounding mode</em> determines how values are rounded; see
+ * DecimalFormat::ERoundingMode.  The default rounding mode is
+ * DecimalFormat::kRoundHalfEven.  The rounding mode can only be set
+ * through the API; it can not be set with a pattern.
+ *
+ * <li>Some locales use rounding in their currency formats to reflect the
+ * smallest currency denomination.
+ *
+ * <li>In a pattern, digits '1' through '9' specify rounding, but otherwise
+ * behave identically to digit '0'.
+ * </ul>
+ *
+ * <p><strong>Synchronization</strong>
+ *
+ * <p>DecimalFormat objects are not synchronized.  Multiple
+ * threads should not access one formatter concurrently.
+ *
+ * <p><strong>Subclassing</strong>
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API DecimalFormat: public NumberFormat {
+public:
+    /**
+     * Rounding mode.
+     * @stable ICU 2.4
+     */
+    enum ERoundingMode {
+        kRoundCeiling,  /**< Round towards positive infinity */
+        kRoundFloor,    /**< Round towards negative infinity */
+        kRoundDown,     /**< Round towards zero */
+        kRoundUp,       /**< Round away from zero */
+        kRoundHalfEven, /**< Round towards the nearest integer, or
+                             towards the nearest even integer if equidistant */
+        kRoundHalfDown, /**< Round towards the nearest integer, or
+                             towards zero if equidistant */
+        kRoundHalfUp,   /**< Round towards the nearest integer, or
+                             away from zero if equidistant */
+        /**
+          *  Return U_FORMAT_INEXACT_ERROR if number does not format exactly.
+          *  @stable ICU 4.8
+          */
+        kRoundUnnecessary
+    };
+
+    /**
+     * Pad position.
+     * @stable ICU 2.4
+     */
+    enum EPadPosition {
+        kPadBeforePrefix,
+        kPadAfterPrefix,
+        kPadBeforeSuffix,
+        kPadAfterSuffix
+    };
+
+    /**
+     * Create a DecimalFormat using the default pattern and symbols
+     * for the default locale. This is a convenient way to obtain a
+     * DecimalFormat when internationalization is not the main concern.
+     * <P>
+     * To obtain standard formats for a given locale, use the factory methods
+     * on NumberFormat such as createInstance. These factories will
+     * return the most appropriate sub-class of NumberFormat for a given
+     * locale.
+     * @param status    Output param set to success/failure code. If the
+     *                  pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(UErrorCode& status);
+
+    /**
+     * Create a DecimalFormat from the given pattern and the symbols
+     * for the default locale. This is a convenient way to obtain a
+     * DecimalFormat when internationalization is not the main concern.
+     * <P>
+     * To obtain standard formats for a given locale, use the factory methods
+     * on NumberFormat such as createInstance. These factories will
+     * return the most appropriate sub-class of NumberFormat for a given
+     * locale.
+     * @param pattern   A non-localized pattern string.
+     * @param status    Output param set to success/failure code. If the
+     *                  pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(const UnicodeString& pattern,
+                  UErrorCode& status);
+
+    /**
+     * Create a DecimalFormat from the given pattern and symbols.
+     * Use this constructor when you need to completely customize the
+     * behavior of the format.
+     * <P>
+     * To obtain standard formats for a given
+     * locale, use the factory methods on NumberFormat such as
+     * createInstance or createCurrencyInstance. If you need only minor adjustments
+     * to a standard format, you can modify the format returned by
+     * a NumberFormat factory method.
+     *
+     * @param pattern           a non-localized pattern string
+     * @param symbolsToAdopt    the set of symbols to be used.  The caller should not
+     *                          delete this object after making this call.
+     * @param status            Output param set to success/failure code. If the
+     *                          pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(  const UnicodeString& pattern,
+                    DecimalFormatSymbols* symbolsToAdopt,
+                    UErrorCode& status);
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * This API is for ICU use only.
+     * Create a DecimalFormat from the given pattern, symbols, and style.
+     *
+     * @param pattern           a non-localized pattern string
+     * @param symbolsToAdopt    the set of symbols to be used.  The caller should not
+     *                          delete this object after making this call.
+     * @param style             style of decimal format
+     * @param status            Output param set to success/failure code. If the
+     *                          pattern is invalid this will be set to a failure code.
+     * @internal
+     */
+    DecimalFormat(  const UnicodeString& pattern,
+                    DecimalFormatSymbols* symbolsToAdopt,
+                    UNumberFormatStyle style,
+                    UErrorCode& status);
+
+#if UCONFIG_HAVE_PARSEALLINPUT
+    /**
+     * @internal
+     */
+    void setParseAllInput(UNumberFormatAttributeValue value);
+#endif
+
+#endif  /* U_HIDE_INTERNAL_API */
+
+
+    /**
+     * Set an integer attribute on this DecimalFormat.
+     * May return U_UNSUPPORTED_ERROR if this instance does not support
+     * the specified attribute.
+     * @param attr the attribute to set
+     * @param newvalue new value
+     * @param status the error type
+     * @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) )
+     * @stable ICU 51
+     */
+    virtual DecimalFormat& setAttribute( UNumberFormatAttribute attr,
+                                       int32_t newvalue,
+                                       UErrorCode &status);
+
+    /**
+     * Get an integer
+     * May return U_UNSUPPORTED_ERROR if this instance does not support
+     * the specified attribute.
+     * @param attr the attribute to set
+     * @param status the error type
+     * @return the attribute value. Undefined if there is an error.
+     * @stable ICU 51
+     */
+    virtual int32_t getAttribute( UNumberFormatAttribute attr,
+                                  UErrorCode &status) const;
+
+    
+    /**
+     * Set whether or not grouping will be used in this format.
+     * @param newValue    True, grouping will be used in this format.
+     * @see getGroupingUsed
+     * @stable ICU 53
+     */
+    virtual void setGroupingUsed(UBool newValue);
+
+    /**
+     * Sets whether or not numbers should be parsed as integers only.
+     * @param value    set True, this format will parse numbers as integers
+     *                 only.
+     * @see isParseIntegerOnly
+     * @stable ICU 53
+     */
+    virtual void setParseIntegerOnly(UBool value);
+
+    /**
+     * Set a particular UDisplayContext value in the formatter, such as
+     * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
+     * @param value The UDisplayContext value to set.
+     * @param status Input/output status. If at entry this indicates a failure
+     *               status, the function will do nothing; otherwise this will be
+     *               updated with any new status from the function. 
+     * @stable ICU 53
+     */
+    virtual void setContext(UDisplayContext value, UErrorCode& status);
+
+    /**
+     * Create a DecimalFormat from the given pattern and symbols.
+     * Use this constructor when you need to completely customize the
+     * behavior of the format.
+     * <P>
+     * To obtain standard formats for a given
+     * locale, use the factory methods on NumberFormat such as
+     * createInstance or createCurrencyInstance. If you need only minor adjustments
+     * to a standard format, you can modify the format returned by
+     * a NumberFormat factory method.
+     *
+     * @param pattern           a non-localized pattern string
+     * @param symbolsToAdopt    the set of symbols to be used.  The caller should not
+     *                          delete this object after making this call.
+     * @param parseError        Output param to receive errors occured during parsing
+     * @param status            Output param set to success/failure code. If the
+     *                          pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(  const UnicodeString& pattern,
+                    DecimalFormatSymbols* symbolsToAdopt,
+                    UParseError& parseError,
+                    UErrorCode& status);
+    /**
+     * Create a DecimalFormat from the given pattern and symbols.
+     * Use this constructor when you need to completely customize the
+     * behavior of the format.
+     * <P>
+     * To obtain standard formats for a given
+     * locale, use the factory methods on NumberFormat such as
+     * createInstance or createCurrencyInstance. If you need only minor adjustments
+     * to a standard format, you can modify the format returned by
+     * a NumberFormat factory method.
+     *
+     * @param pattern           a non-localized pattern string
+     * @param symbols   the set of symbols to be used
+     * @param status            Output param set to success/failure code. If the
+     *                          pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(  const UnicodeString& pattern,
+                    const DecimalFormatSymbols& symbols,
+                    UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     *
+     * @param source    the DecimalFormat object to be copied from.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(const DecimalFormat& source);
+
+    /**
+     * Assignment operator.
+     *
+     * @param rhs    the DecimalFormat object to be copied.
+     * @stable ICU 2.0
+     */
+    DecimalFormat& operator=(const DecimalFormat& rhs);
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~DecimalFormat();
+
+    /**
+     * Clone this Format object polymorphically. The caller owns the
+     * result and should delete it when done.
+     *
+     * @return    a polymorphic copy of this DecimalFormat.
+     * @stable ICU 2.0
+     */
+    virtual Format* clone(void) const;
+
+    /**
+     * Return true if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     *
+     * @param other    the object to be compared with.
+     * @return         true if the given Format objects are semantically equal.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format& other) const;
+
+
+    using NumberFormat::format;
+
+    /**
+     * Format a double or long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+
+    /**
+     * Format a double or long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode &status) const;
+
+    /**
+     * Format a double or long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     *                  Can be NULL.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable 4.4
+     */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format a long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(int32_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Format a long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(int32_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode &status) const;
+
+    /**
+     * Format a long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     *                  Can be NULL.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable 4.4
+     */
+    virtual UnicodeString& format(int32_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format an int64 number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.8
+     */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Format an int64 number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode &status) const;
+
+    /**
+     * Format an int64 number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     *                  Can be NULL.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable 4.4
+     */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format a decimal number.
+     * The syntax of the unformatted number is a "numeric string"
+     * as defined in the Decimal Arithmetic Specification, available at
+     * http://speleotrove.com/decimal
+     *
+     * @param number    The unformatted number, as a string.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     *                  Can be NULL.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable 4.4
+     */
+    virtual UnicodeString& format(const StringPiece &number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+
+    /**
+     * Format a decimal number.
+     * The number is a DigitList wrapper onto a floating point decimal number.
+     * The default implementation in NumberFormat converts the decimal number
+     * to a double and formats that.
+     *
+     * @param number    The number, a DigitList format Decimal Floating Point.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(const DigitList &number,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Format a decimal number.
+     * The number is a DigitList wrapper onto a floating point decimal number.
+     * The default implementation in NumberFormat converts the decimal number
+     * to a double and formats that.
+     *
+     * @param number    The number, a DigitList format Decimal Floating Point.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @internal
+     */
+    virtual UnicodeString& format(const DigitList &number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+   using NumberFormat::parse;
+
+   /**
+    * Parse the given string using this object's choices. The method
+    * does string comparisons to try to find an optimal match.
+    * If no object can be parsed, index is unchanged, and NULL is
+    * returned.  The result is returned as the most parsimonious
+    * type of Formattable that will accomodate all of the
+    * necessary precision.  For example, if the result is exactly 12,
+    * it will be returned as a long.  However, if it is 1.5, it will
+    * be returned as a double.
+    *
+    * @param text           The text to be parsed.
+    * @param result         Formattable to be set to the parse result.
+    *                       If parse fails, return contents are undefined.
+    * @param parsePosition  The position to start parsing at on input.
+    *                       On output, moved to after the last successfully
+    *                       parse character. On parse failure, does not change.
+    * @see Formattable
+    * @stable ICU 2.0
+    */
+    virtual void parse(const UnicodeString& text,
+                       Formattable& result,
+                       ParsePosition& parsePosition) const;
+
+    /**
+     * Parses text from the given string as a currency amount.  Unlike
+     * the parse() method, this method will attempt to parse a generic
+     * currency name, searching for a match of this object's locale's
+     * currency display names, or for a 3-letter ISO currency code.
+     * This method will fail if this format is not a currency format,
+     * that is, if it does not contain the currency pattern symbol
+     * (U+00A4) in its prefix or suffix.
+     *
+     * @param text the string to parse
+     * @param pos  input-output position; on input, the position within text
+     *             to match; must have 0 <= pos.getIndex() < text.length();
+     *             on output, the position after the last matched character.
+     *             If the parse fails, the position in unchanged upon output.
+     * @return     if parse succeeds, a pointer to a newly-created CurrencyAmount
+     *             object (owned by the caller) containing information about
+     *             the parsed currency; if parse fails, this is NULL.
+     * @stable ICU 49
+     */
+    virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
+                                          ParsePosition& pos) const;
+
+    /**
+     * Returns the decimal format symbols, which is generally not changed
+     * by the programmer or user.
+     * @return desired DecimalFormatSymbols
+     * @see DecimalFormatSymbols
+     * @stable ICU 2.0
+     */
+    virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
+
+    /**
+     * Sets the decimal format symbols, which is generally not changed
+     * by the programmer or user.
+     * @param symbolsToAdopt DecimalFormatSymbols to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
+
+    /**
+     * Sets the decimal format symbols, which is generally not changed
+     * by the programmer or user.
+     * @param symbols DecimalFormatSymbols.
+     * @stable ICU 2.0
+     */
+    virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
+
+
+    /**
+     * Returns the currency plural format information,
+     * which is generally not changed by the programmer or user.
+     * @return desired CurrencyPluralInfo
+     * @stable ICU 4.2
+     */
+    virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;
+
+    /**
+     * Sets the currency plural format information,
+     * which is generally not changed by the programmer or user.
+     * @param toAdopt CurrencyPluralInfo to be adopted.
+     * @stable ICU 4.2
+     */
+    virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);
+
+    /**
+     * Sets the currency plural format information,
+     * which is generally not changed by the programmer or user.
+     * @param info Currency Plural Info.
+     * @stable ICU 4.2
+     */
+    virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);
+
+
+    /**
+     * Get the positive prefix.
+     *
+     * @param result    Output param which will receive the positive prefix.
+     * @return          A reference to 'result'.
+     * Examples: +123, $123, sFr123
+     * @stable ICU 2.0
+     */
+    UnicodeString& getPositivePrefix(UnicodeString& result) const;
+
+    /**
+     * Set the positive prefix.
+     *
+     * @param newValue    the new value of the the positive prefix to be set.
+     * Examples: +123, $123, sFr123
+     * @stable ICU 2.0
+     */
+    virtual void setPositivePrefix(const UnicodeString& newValue);
+
+    /**
+     * Get the negative prefix.
+     *
+     * @param result    Output param which will receive the negative prefix.
+     * @return          A reference to 'result'.
+     * Examples: -123, ($123) (with negative suffix), sFr-123
+     * @stable ICU 2.0
+     */
+    UnicodeString& getNegativePrefix(UnicodeString& result) const;
+
+    /**
+     * Set the negative prefix.
+     *
+     * @param newValue    the new value of the the negative prefix to be set.
+     * Examples: -123, ($123) (with negative suffix), sFr-123
+     * @stable ICU 2.0
+     */
+    virtual void setNegativePrefix(const UnicodeString& newValue);
+
+    /**
+     * Get the positive suffix.
+     *
+     * @param result    Output param which will receive the positive suffix.
+     * @return          A reference to 'result'.
+     * Example: 123%
+     * @stable ICU 2.0
+     */
+    UnicodeString& getPositiveSuffix(UnicodeString& result) const;
+
+    /**
+     * Set the positive suffix.
+     *
+     * @param newValue    the new value of the positive suffix to be set.
+     * Example: 123%
+     * @stable ICU 2.0
+     */
+    virtual void setPositiveSuffix(const UnicodeString& newValue);
+
+    /**
+     * Get the negative suffix.
+     *
+     * @param result    Output param which will receive the negative suffix.
+     * @return          A reference to 'result'.
+     * Examples: -123%, ($123) (with positive suffixes)
+     * @stable ICU 2.0
+     */
+    UnicodeString& getNegativeSuffix(UnicodeString& result) const;
+
+    /**
+     * Set the negative suffix.
+     *
+     * @param newValue    the new value of the negative suffix to be set.
+     * Examples: 123%
+     * @stable ICU 2.0
+     */
+    virtual void setNegativeSuffix(const UnicodeString& newValue);
+
+    /**
+     * Get the multiplier for use in percent, permill, etc.
+     * For a percentage, set the suffixes to have "%" and the multiplier to be 100.
+     * (For Arabic, use arabic percent symbol).
+     * For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000.
+     *
+     * @return    the multiplier for use in percent, permill, etc.
+     * Examples: with 100, 1.23 -> "123", and "123" -> 1.23
+     * @stable ICU 2.0
+     */
+    int32_t getMultiplier(void) const;
+
+    /**
+     * Set the multiplier for use in percent, permill, etc.
+     * For a percentage, set the suffixes to have "%" and the multiplier to be 100.
+     * (For Arabic, use arabic percent symbol).
+     * For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000.
+     *
+     * @param newValue    the new value of the multiplier for use in percent, permill, etc.
+     * Examples: with 100, 1.23 -> "123", and "123" -> 1.23
+     * @stable ICU 2.0
+     */
+    virtual void setMultiplier(int32_t newValue);
+
+    /**
+     * Get the rounding increment.
+     * @return A positive rounding increment, or 0.0 if a custom rounding
+     * increment is not in effect.
+     * @see #setRoundingIncrement
+     * @see #getRoundingMode
+     * @see #setRoundingMode
+     * @stable ICU 2.0
+     */
+    virtual double getRoundingIncrement(void) const;
+
+    /**
+     * Set the rounding increment.  In the absence of a rounding increment,
+     *    numbers will be rounded to the number of digits displayed.
+     * @param newValue A positive rounding increment, or 0.0 to
+     * use the default rounding increment.
+     * Negative increments are equivalent to 0.0.
+     * @see #getRoundingIncrement
+     * @see #getRoundingMode
+     * @see #setRoundingMode
+     * @stable ICU 2.0
+     */
+    virtual void setRoundingIncrement(double newValue);
+
+    /**
+     * Get the rounding mode.
+     * @return A rounding mode
+     * @see #setRoundingIncrement
+     * @see #getRoundingIncrement
+     * @see #setRoundingMode
+     * @stable ICU 2.0
+     */
+    virtual ERoundingMode getRoundingMode(void) const;
+
+    /**
+     * Set the rounding mode.
+     * @param roundingMode A rounding mode
+     * @see #setRoundingIncrement
+     * @see #getRoundingIncrement
+     * @see #getRoundingMode
+     * @stable ICU 2.0
+     */
+    virtual void setRoundingMode(ERoundingMode roundingMode);
+
+    /**
+     * Get the width to which the output of format() is padded.
+     * The width is counted in 16-bit code units.
+     * @return the format width, or zero if no padding is in effect
+     * @see #setFormatWidth
+     * @see #getPadCharacterString
+     * @see #setPadCharacter
+     * @see #getPadPosition
+     * @see #setPadPosition
+     * @stable ICU 2.0
+     */
+    virtual int32_t getFormatWidth(void) const;
+
+    /**
+     * Set the width to which the output of format() is padded.
+     * The width is counted in 16-bit code units.
+     * This method also controls whether padding is enabled.
+     * @param width the width to which to pad the result of
+     * format(), or zero to disable padding.  A negative
+     * width is equivalent to 0.
+     * @see #getFormatWidth
+     * @see #getPadCharacterString
+     * @see #setPadCharacter
+     * @see #getPadPosition
+     * @see #setPadPosition
+     * @stable ICU 2.0
+     */
+    virtual void setFormatWidth(int32_t width);
+
+    /**
+     * Get the pad character used to pad to the format width.  The
+     * default is ' '.
+     * @return a string containing the pad character. This will always
+     * have a length of one 32-bit code point.
+     * @see #setFormatWidth
+     * @see #getFormatWidth
+     * @see #setPadCharacter
+     * @see #getPadPosition
+     * @see #setPadPosition
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString getPadCharacterString() const;
+
+    /**
+     * Set the character used to pad to the format width.  If padding
+     * is not enabled, then this will take effect if padding is later
+     * enabled.
+     * @param padChar a string containing the pad charcter. If the string
+     * has length 0, then the pad characer is set to ' '.  Otherwise
+     * padChar.char32At(0) will be used as the pad character.
+     * @see #setFormatWidth
+     * @see #getFormatWidth
+     * @see #getPadCharacterString
+     * @see #getPadPosition
+     * @see #setPadPosition
+     * @stable ICU 2.0
+     */
+    virtual void setPadCharacter(const UnicodeString &padChar);
+
+    /**
+     * Get the position at which padding will take place.  This is the location
+     * at which padding will be inserted if the result of format()
+     * is shorter than the format width.
+     * @return the pad position, one of kPadBeforePrefix,
+     * kPadAfterPrefix, kPadBeforeSuffix, or
+     * kPadAfterSuffix.
+     * @see #setFormatWidth
+     * @see #getFormatWidth
+     * @see #setPadCharacter
+     * @see #getPadCharacterString
+     * @see #setPadPosition
+     * @see #EPadPosition
+     * @stable ICU 2.0
+     */
+    virtual EPadPosition getPadPosition(void) const;
+
+    /**
+     * Set the position at which padding will take place.  This is the location
+     * at which padding will be inserted if the result of format()
+     * is shorter than the format width.  This has no effect unless padding is
+     * enabled.
+     * @param padPos the pad position, one of kPadBeforePrefix,
+     * kPadAfterPrefix, kPadBeforeSuffix, or
+     * kPadAfterSuffix.
+     * @see #setFormatWidth
+     * @see #getFormatWidth
+     * @see #setPadCharacter
+     * @see #getPadCharacterString
+     * @see #getPadPosition
+     * @see #EPadPosition
+     * @stable ICU 2.0
+     */
+    virtual void setPadPosition(EPadPosition padPos);
+
+    /**
+     * Return whether or not scientific notation is used.
+     * @return TRUE if this object formats and parses scientific notation
+     * @see #setScientificNotation
+     * @see #getMinimumExponentDigits
+     * @see #setMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual UBool isScientificNotation(void) const;
+
+    /**
+     * Set whether or not scientific notation is used. When scientific notation
+     * is used, the effective maximum number of integer digits is <= 8.  If the
+     * maximum number of integer digits is set to more than 8, the effective
+     * maximum will be 1.  This allows this call to generate a 'default' scientific
+     * number format without additional changes.
+     * @param useScientific TRUE if this object formats and parses scientific
+     * notation
+     * @see #isScientificNotation
+     * @see #getMinimumExponentDigits
+     * @see #setMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual void setScientificNotation(UBool useScientific);
+
+    /**
+     * Return the minimum exponent digits that will be shown.
+     * @return the minimum exponent digits that will be shown
+     * @see #setScientificNotation
+     * @see #isScientificNotation
+     * @see #setMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual int8_t getMinimumExponentDigits(void) const;
+
+    /**
+     * Set the minimum exponent digits that will be shown.  This has no
+     * effect unless scientific notation is in use.
+     * @param minExpDig a value >= 1 indicating the fewest exponent digits
+     * that will be shown.  Values less than 1 will be treated as 1.
+     * @see #setScientificNotation
+     * @see #isScientificNotation
+     * @see #getMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual void setMinimumExponentDigits(int8_t minExpDig);
+
+    /**
+     * Return whether the exponent sign is always shown.
+     * @return TRUE if the exponent is always prefixed with either the
+     * localized minus sign or the localized plus sign, false if only negative
+     * exponents are prefixed with the localized minus sign.
+     * @see #setScientificNotation
+     * @see #isScientificNotation
+     * @see #setMinimumExponentDigits
+     * @see #getMinimumExponentDigits
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual UBool isExponentSignAlwaysShown(void) const;
+
+    /**
+     * Set whether the exponent sign is always shown.  This has no effect
+     * unless scientific notation is in use.
+     * @param expSignAlways TRUE if the exponent is always prefixed with either
+     * the localized minus sign or the localized plus sign, false if only
+     * negative exponents are prefixed with the localized minus sign.
+     * @see #setScientificNotation
+     * @see #isScientificNotation
+     * @see #setMinimumExponentDigits
+     * @see #getMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual void setExponentSignAlwaysShown(UBool expSignAlways);
+
+    /**
+     * Return the grouping size. Grouping size is the number of digits between
+     * grouping separators in the integer portion of a number.  For example,
+     * in the number "123,456.78", the grouping size is 3.
+     *
+     * @return    the grouping size.
+     * @see setGroupingSize
+     * @see NumberFormat::isGroupingUsed
+     * @see DecimalFormatSymbols::getGroupingSeparator
+     * @stable ICU 2.0
+     */
+    int32_t getGroupingSize(void) const;
+
+    /**
+     * Set the grouping size. Grouping size is the number of digits between
+     * grouping separators in the integer portion of a number.  For example,
+     * in the number "123,456.78", the grouping size is 3.
+     *
+     * @param newValue    the new value of the grouping size.
+     * @see getGroupingSize
+     * @see NumberFormat::setGroupingUsed
+     * @see DecimalFormatSymbols::setGroupingSeparator
+     * @stable ICU 2.0
+     */
+    virtual void setGroupingSize(int32_t newValue);
+
+    /**
+     * Return the secondary grouping size. In some locales one
+     * grouping interval is used for the least significant integer
+     * digits (the primary grouping size), and another is used for all
+     * others (the secondary grouping size).  A formatter supporting a
+     * secondary grouping size will return a positive integer unequal
+     * to the primary grouping size returned by
+     * getGroupingSize().  For example, if the primary
+     * grouping size is 4, and the secondary grouping size is 2, then
+     * the number 123456789 formats as "1,23,45,6789", and the pattern
+     * appears as "#,##,###0".
+     * @return the secondary grouping size, or a value less than
+     * one if there is none
+     * @see setSecondaryGroupingSize
+     * @see NumberFormat::isGroupingUsed
+     * @see DecimalFormatSymbols::getGroupingSeparator
+     * @stable ICU 2.4
+     */
+    int32_t getSecondaryGroupingSize(void) const;
+
+    /**
+     * Set the secondary grouping size. If set to a value less than 1,
+     * then secondary grouping is turned off, and the primary grouping
+     * size is used for all intervals, not just the least significant.
+     *
+     * @param newValue    the new value of the secondary grouping size.
+     * @see getSecondaryGroupingSize
+     * @see NumberFormat#setGroupingUsed
+     * @see DecimalFormatSymbols::setGroupingSeparator
+     * @stable ICU 2.4
+     */
+    virtual void setSecondaryGroupingSize(int32_t newValue);
+
+    /**
+     * Allows you to get the behavior of the decimal separator with integers.
+     * (The decimal separator will always appear with decimals.)
+     *
+     * @return    TRUE if the decimal separator always appear with decimals.
+     * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
+     * @stable ICU 2.0
+     */
+    UBool isDecimalSeparatorAlwaysShown(void) const;
+
+    /**
+     * Allows you to set the behavior of the decimal separator with integers.
+     * (The decimal separator will always appear with decimals.)
+     *
+     * @param newValue    set TRUE if the decimal separator will always appear with decimals.
+     * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
+     * @stable ICU 2.0
+     */
+    virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
+
+#ifndef U_HIDE_DRAFT_API
+    /**
+     * Allows you to get the parse behavior of the pattern decimal mark.
+     *
+     * @return    TRUE if input must contain a match to decimal mark in pattern
+     * @draft ICU 54
+     */
+    UBool isDecimalPatternMatchRequired(void) const;
+#endif  /* U_HIDE_DRAFT_API */
+
+    /**
+     * Allows you to set the behavior of the pattern decimal mark.
+     * 
+     * if TRUE, the input must have a decimal mark if one was specified in the pattern. When
+     * FALSE the decimal mark may be omitted from the input.
+     *
+     * @param newValue    set TRUE if input must contain a match to decimal mark in pattern
+     * @draft ICU 54
+     */
+    virtual void setDecimalPatternMatchRequired(UBool newValue);
+
+
+    /**
+     * Synthesizes a pattern string that represents the current state
+     * of this Format object.
+     *
+     * @param result    Output param which will receive the pattern.
+     *                  Previous contents are deleted.
+     * @return          A reference to 'result'.
+     * @see applyPattern
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toPattern(UnicodeString& result) const;
+
+    /**
+     * Synthesizes a localized pattern string that represents the current
+     * state of this Format object.
+     *
+     * @param result    Output param which will receive the localized pattern.
+     *                  Previous contents are deleted.
+     * @return          A reference to 'result'.
+     * @see applyPattern
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
+
+    /**
+     * Apply the given pattern to this Format object.  A pattern is a
+     * short-hand specification for the various formatting properties.
+     * These properties can also be changed individually through the
+     * various setter methods.
+     * <P>
+     * There is no limit to integer digits are set
+     * by this routine, since that is the typical end-user desire;
+     * use setMaximumInteger if you want to set a real value.
+     * For negative numbers, use a second pattern, separated by a semicolon
+     * <pre>
+     * .      Example "#,#00.0#" -> 1,234.56
+     * </pre>
+     * This means a minimum of 2 integer digits, 1 fraction digit, and
+     * a maximum of 2 fraction digits.
+     * <pre>
+     * .      Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses.
+     * </pre>
+     * In negative patterns, the minimum and maximum counts are ignored;
+     * these are presumed to be set in the positive pattern.
+     *
+     * @param pattern    The pattern to be applied.
+     * @param parseError Struct to recieve information on position
+     *                   of error if an error is encountered
+     * @param status     Output param set to success/failure code on
+     *                   exit. If the pattern is invalid, this will be
+     *                   set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                             UParseError& parseError,
+                             UErrorCode& status);
+    /**
+     * Sets the pattern.
+     * @param pattern   The pattern to be applied.
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                             UErrorCode& status);
+
+    /**
+     * Apply the given pattern to this Format object.  The pattern
+     * is assumed to be in a localized notation. A pattern is a
+     * short-hand specification for the various formatting properties.
+     * These properties can also be changed individually through the
+     * various setter methods.
+     * <P>
+     * There is no limit to integer digits are set
+     * by this routine, since that is the typical end-user desire;
+     * use setMaximumInteger if you want to set a real value.
+     * For negative numbers, use a second pattern, separated by a semicolon
+     * <pre>
+     * .      Example "#,#00.0#" -> 1,234.56
+     * </pre>
+     * This means a minimum of 2 integer digits, 1 fraction digit, and
+     * a maximum of 2 fraction digits.
+     *
+     * Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses.
+     *
+     * In negative patterns, the minimum and maximum counts are ignored;
+     * these are presumed to be set in the positive pattern.
+     *
+     * @param pattern   The localized pattern to be applied.
+     * @param parseError Struct to recieve information on position
+     *                   of error if an error is encountered
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyLocalizedPattern(const UnicodeString& pattern,
+                                       UParseError& parseError,
+                                       UErrorCode& status);
+
+    /**
+     * Apply the given pattern to this Format object.
+     *
+     * @param pattern   The localized pattern to be applied.
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyLocalizedPattern(const UnicodeString& pattern,
+                                       UErrorCode& status);
+
+
+    /**
+     * Sets the maximum number of digits allowed in the integer portion of a
+     * number. This override limits the integer digit count to 309.
+     *
+     * @param newValue    the new value of the maximum number of digits
+     *                      allowed in the integer portion of a number.
+     * @see NumberFormat#setMaximumIntegerDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMaximumIntegerDigits(int32_t newValue);
+
+    /**
+     * Sets the minimum number of digits allowed in the integer portion of a
+     * number. This override limits the integer digit count to 309.
+     *
+     * @param newValue    the new value of the minimum number of digits
+     *                      allowed in the integer portion of a number.
+     * @see NumberFormat#setMinimumIntegerDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMinimumIntegerDigits(int32_t newValue);
+
+    /**
+     * Sets the maximum number of digits allowed in the fraction portion of a
+     * number. This override limits the fraction digit count to 340.
+     *
+     * @param newValue    the new value of the maximum number of digits
+     *                    allowed in the fraction portion of a number.
+     * @see NumberFormat#setMaximumFractionDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMaximumFractionDigits(int32_t newValue);
+
+    /**
+     * Sets the minimum number of digits allowed in the fraction portion of a
+     * number. This override limits the fraction digit count to 340.
+     *
+     * @param newValue    the new value of the minimum number of digits
+     *                    allowed in the fraction portion of a number.
+     * @see NumberFormat#setMinimumFractionDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMinimumFractionDigits(int32_t newValue);
+
+    /**
+     * Returns the minimum number of significant digits that will be
+     * displayed. This value has no effect unless areSignificantDigitsUsed()
+     * returns true.
+     * @return the fewest significant digits that will be shown
+     * @stable ICU 3.0
+     */
+    int32_t getMinimumSignificantDigits() const;
+
+    /**
+     * Returns the maximum number of significant digits that will be
+     * displayed. This value has no effect unless areSignificantDigitsUsed()
+     * returns true.
+     * @return the most significant digits that will be shown
+     * @stable ICU 3.0
+     */
+    int32_t getMaximumSignificantDigits() const;
+
+    /**
+     * Sets the minimum number of significant digits that will be
+     * displayed.  If <code>min</code> is less than one then it is set
+     * to one.  If the maximum significant digits count is less than
+     * <code>min</code>, then it is set to <code>min</code>.
+     * This function also enables the use of significant digits
+     * by this formatter - areSignificantDigitsUsed() will return TRUE.
+     * @see #areSignificantDigitsUsed
+     * @param min the fewest significant digits to be shown
+     * @stable ICU 3.0
+     */
+    void setMinimumSignificantDigits(int32_t min);
+
+    /**
+     * Sets the maximum number of significant digits that will be
+     * displayed.  If <code>max</code> is less than one then it is set
+     * to one.  If the minimum significant digits count is greater
+     * than <code>max</code>, then it is set to <code>max</code>.
+     * This function also enables the use of significant digits
+     * by this formatter - areSignificantDigitsUsed() will return TRUE.
+     * @see #areSignificantDigitsUsed
+     * @param max the most significant digits to be shown
+     * @stable ICU 3.0
+     */
+    void setMaximumSignificantDigits(int32_t max);
+
+    /**
+     * Returns true if significant digits are in use, or false if
+     * integer and fraction digit counts are in use.
+     * @return true if significant digits are in use
+     * @stable ICU 3.0
+     */
+    UBool areSignificantDigitsUsed() const;
+
+    /**
+     * Sets whether significant digits are in use, or integer and
+     * fraction digit counts are in use.
+     * @param useSignificantDigits true to use significant digits, or
+     * false to use integer and fraction digit counts
+     * @stable ICU 3.0
+     */
+    void setSignificantDigitsUsed(UBool useSignificantDigits);
+
+ public:
+    /**
+     * Sets the currency used to display currency
+     * amounts.  This takes effect immediately, if this format is a
+     * currency format.  If this format is not a currency format, then
+     * the currency is used if and when this object becomes a
+     * currency format through the application of a new pattern.
+     * @param theCurrency a 3-letter ISO code indicating new currency
+     * to use.  It need not be null-terminated.  May be the empty
+     * string or NULL to indicate no currency.
+     * @param ec input-output error code
+     * @stable ICU 3.0
+     */
+    virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
+
+    /**
+     * Sets the currency used to display currency amounts.  See
+     * setCurrency(const UChar*, UErrorCode&).
+     * @deprecated ICU 3.0. Use setCurrency(const UChar*, UErrorCode&).
+     */
+    virtual void setCurrency(const UChar* theCurrency);
+
+#ifndef U_HIDE_DRAFT_API
+    /**
+     * Sets the <tt>Currency Context</tt> object used to display currency.
+     * This takes effect immediately, if this format is a
+     * currency format.  
+     * @param currencyContext new currency context object to use.  
+     * @draft ICU 54
+     */
+    void setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec);
+
+    /**
+     * Returns the <tt>Currency Context</tt> object used to display currency
+     * @draft ICU 54
+     */
+    UCurrencyUsage getCurrencyUsage() const;
+#endif  /* U_HIDE_DRAFT_API */
+
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * The resource tags we use to retrieve decimal format data from
+     * locale resource bundles.
+     * @deprecated ICU 3.4. This string has no public purpose. Please don't use it.
+     */
+    static const char fgNumberPatterns[];
+#endif  /* U_HIDE_DEPRECATED_API */
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     *  Get a FixedDecimal corresponding to a double as it would be
+     *  formatted by this DecimalFormat.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     FixedDecimal getFixedDecimal(double number, UErrorCode &status) const;
+
+    /**
+     *  Get a FixedDecimal corresponding to a formattable as it would be
+     *  formatted by this DecimalFormat.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     FixedDecimal getFixedDecimal(const Formattable &number, UErrorCode &status) const;
+
+    /**
+     *  Get a FixedDecimal corresponding to a DigitList as it would be
+     *  formatted by this DecimalFormat. Note: the DigitList may be modified.
+     *  Internal, not intended for public use.
+     *  @internal
+     */
+     FixedDecimal getFixedDecimal(DigitList &number, UErrorCode &status) const;
+#endif  /* U_HIDE_INTERNAL_API */
+
+public:
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().  For example:
+     * <pre>
+     * .      Base* polymorphic_pointer = createPolymorphicObject();
+     * .      if (polymorphic_pointer->getDynamicClassID() ==
+     * .          Derived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
+     * This method is to implement a simple version of RTTI, since not all
+     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+private:
+
+    DecimalFormat(); // default constructor not implemented
+
+    int32_t precision() const;
+
+    /**
+     *   Initialize all fields of a new DecimalFormatter to a safe default value.
+     *      Common code for use by constructors.
+     */
+    void init();
+
+    /**
+     * Do real work of constructing a new DecimalFormat.
+     */
+    void construct(UErrorCode&              status,
+                   UParseError&             parseErr,
+                   const UnicodeString*     pattern = 0,
+                   DecimalFormatSymbols*    symbolsToAdopt = 0
+                   );
+
+    /**
+     * Does the real work of generating a pattern.
+     *
+     * @param result     Output param which will receive the pattern.
+     *                   Previous contents are deleted.
+     * @param localized  TRUE return localized pattern.
+     * @return           A reference to 'result'.
+     */
+    UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
+
+    /**
+     * Does the real work of applying a pattern.
+     * @param pattern    The pattern to be applied.
+     * @param localized  If true, the pattern is localized; else false.
+     * @param parseError Struct to recieve information on position
+     *                   of error if an error is encountered
+     * @param status     Output param set to success/failure code on
+     *                   exit. If the pattern is invalid, this will be
+     *                   set to a failure result.
+     */
+    void applyPattern(const UnicodeString& pattern,
+                            UBool localized,
+                            UParseError& parseError,
+                            UErrorCode& status);
+
+    /*
+     * similar to applyPattern, but without re-gen affix for currency
+     */
+    void applyPatternInternally(const UnicodeString& pluralCount,
+                                const UnicodeString& pattern,
+                                UBool localized,
+                                UParseError& parseError,
+                                UErrorCode& status);
+
+    /*
+     * only apply pattern without expand affixes
+     */
+    void applyPatternWithoutExpandAffix(const UnicodeString& pattern,
+                                        UBool localized,
+                                        UParseError& parseError,
+                                        UErrorCode& status);
+
+
+    /*
+     * expand affixes (after apply patter) and re-compute fFormatWidth
+     */
+    void expandAffixAdjustWidth(const UnicodeString* pluralCount);
+
+
+    /**
+     * Do the work of formatting a number, either a double or a long.
+     *
+     * @param appendTo       Output parameter to receive result.
+     *                       Result is appended to existing contents.
+     * @param handler        Records information about field positions.
+     * @param digits         the digits to be formatted.
+     * @param isInteger      if TRUE format the digits as Integer.
+     * @return               Reference to 'appendTo' parameter.
+     */
+    UnicodeString& subformat(UnicodeString& appendTo,
+                             FieldPositionHandler& handler,
+                             DigitList&     digits,
+                             UBool          isInteger,
+                             UErrorCode &status) const;
+
+
+    void parse(const UnicodeString& text,
+               Formattable& result,
+               ParsePosition& pos,
+               UChar* currency) const;
+
+    enum {
+        fgStatusInfinite,
+        fgStatusLength      // Leave last in list.
+    } StatusFlags;
+
+    UBool subparse(const UnicodeString& text,
+                   const UnicodeString* negPrefix,
+                   const UnicodeString* negSuffix,
+                   const UnicodeString* posPrefix,
+                   const UnicodeString* posSuffix,
+                   UBool complexCurrencyParsing,
+                   int8_t type,
+                   ParsePosition& parsePosition,
+                   DigitList& digits, UBool* status,
+                   UChar* currency) const;
+
+    // Mixed style parsing for currency.
+    // It parses against the current currency pattern
+    // using complex affix comparison
+    // parses against the currency plural patterns using complex affix comparison,
+    // and parses against the current pattern using simple affix comparison.
+    UBool parseForCurrency(const UnicodeString& text,
+                           ParsePosition& parsePosition,
+                           DigitList& digits,
+                           UBool* status,
+                           UChar* currency) const;
+
+    int32_t skipPadding(const UnicodeString& text, int32_t position) const;
+
+    int32_t compareAffix(const UnicodeString& input,
+                         int32_t pos,
+                         UBool isNegative,
+                         UBool isPrefix,
+                         const UnicodeString* affixPat,
+                         UBool complexCurrencyParsing,
+                         int8_t type,
+                         UChar* currency) const;
+
+    static UnicodeString& trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix);
+
+    UBool equalWithSignCompatibility(UChar32 lhs, UChar32 rhs) const;
+
+    int32_t compareSimpleAffix(const UnicodeString& affix,
+                                      const UnicodeString& input,
+                                      int32_t pos,
+                                      UBool lenient) const;
+
+    static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);
+
+    static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
+
+    static int32_t skipUWhiteSpaceAndMarks(const UnicodeString& text, int32_t pos);
+
+    static int32_t skipBidiMarks(const UnicodeString& text, int32_t pos);
+
+    int32_t compareComplexAffix(const UnicodeString& affixPat,
+                                const UnicodeString& input,
+                                int32_t pos,
+                                int8_t type,
+                                UChar* currency) const;
+
+    static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
+
+    static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
+
+    static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol,
+                             UnicodeSet *sset, UChar32 schar);
+
+    static UBool matchDecimal(UChar32 symbolChar,
+                            UBool sawDecimal,  UChar32 sawDecimalChar,
+                             const UnicodeSet *sset, UChar32 schar);
+
+    static UBool matchGrouping(UChar32 groupingChar,
+                            UBool sawGrouping, UChar32 sawGroupingChar,
+                             const UnicodeSet *sset,
+                             UChar32 decimalChar, const UnicodeSet *decimalSet,
+                             UChar32 schar);
+
+    /**
+     * Get a decimal format symbol.
+     * Returns a const reference to the symbol string.
+     * @internal
+     */
+    inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
+
+    int32_t appendAffix(UnicodeString& buf,
+                        double number,
+                        FieldPositionHandler& handler,
+                        UBool isNegative,
+                        UBool isPrefix) const;
+
+    /**
+     * Append an affix to the given UnicodeString, using quotes if
+     * there are special characters.  Single quotes themselves must be
+     * escaped in either case.
+     */
+    void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,
+                            UBool localized) const;
+
+    void appendAffixPattern(UnicodeString& appendTo,
+                            const UnicodeString* affixPattern,
+                            const UnicodeString& expAffix, UBool localized) const;
+
+    void expandAffix(const UnicodeString& pattern,
+                     UnicodeString& affix,
+                     double number,
+                     FieldPositionHandler& handler,
+                     UBool doFormat,
+                     const UnicodeString* pluralCount) const;
+
+    void expandAffixes(const UnicodeString* pluralCount);
+
+    void addPadding(UnicodeString& appendTo,
+                    FieldPositionHandler& handler,
+                    int32_t prefixLen, int32_t suffixLen) const;
+
+    UBool isGroupingPosition(int32_t pos) const;
+
+    void setCurrencyForSymbols();
+
+    // similar to setCurrency without re-compute the affixes for currency.
+    // If currency changes, the affix pattern for currency is not changed,
+    // but the affix will be changed. So, affixes need to be
+    // re-computed in setCurrency(), but not in setCurrencyInternally().
+    virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);
+
+    // set up currency affix patterns for mix parsing.
+    // The patterns saved here are the affix patterns of default currency
+    // pattern and the unique affix patterns of the plural currency patterns.
+    // Those patterns are used by parseForCurrency().
+    void setupCurrencyAffixPatterns(UErrorCode& status);
+
+    // set up the currency affixes used in currency plural formatting.
+    // It sets up both fAffixesForCurrency for currency pattern if the current
+    // pattern contains 3 currency signs,
+    // and it sets up fPluralAffixesForCurrency for currency plural patterns.
+    void setupCurrencyAffixes(const UnicodeString& pattern,
+                              UBool setupForCurrentPattern,
+                              UBool setupForPluralPattern,
+                              UErrorCode& status);
+	
+    // get the currency rounding with respect to currency usage
+    double getCurrencyRounding(const UChar* currency,
+                               UErrorCode* ec) const;
+	
+    // get the currency fraction with respect to currency usage
+    int getCurrencyFractionDigits(const UChar* currency,
+                                  UErrorCode* ec) const;
+
+    // hashtable operations
+    Hashtable* initHashForAffixPattern(UErrorCode& status);
+    Hashtable* initHashForAffix(UErrorCode& status);
+
+    void deleteHashForAffixPattern();
+    void deleteHashForAffix(Hashtable*& table);
+
+    void copyHashForAffixPattern(const Hashtable* source,
+                                 Hashtable* target, UErrorCode& status);
+    void copyHashForAffix(const Hashtable* source,
+                          Hashtable* target, UErrorCode& status);
+
+    UnicodeString& _format(int64_t number,
+                           UnicodeString& appendTo,
+                           FieldPositionHandler& handler,
+                           UErrorCode &status) const;
+    UnicodeString& _format(double number,
+                           UnicodeString& appendTo,
+                           FieldPositionHandler& handler,
+                           UErrorCode &status) const;
+    UnicodeString& _format(const DigitList &number,
+                           UnicodeString& appendTo,
+                           FieldPositionHandler& handler,
+                           UErrorCode &status) const;
+
+    /**
+     * Constants.
+     */
+
+    UnicodeString           fPositivePrefix;
+    UnicodeString           fPositiveSuffix;
+    UnicodeString           fNegativePrefix;
+    UnicodeString           fNegativeSuffix;
+    UnicodeString*          fPosPrefixPattern;
+    UnicodeString*          fPosSuffixPattern;
+    UnicodeString*          fNegPrefixPattern;
+    UnicodeString*          fNegSuffixPattern;
+
+    /**
+     * Formatter for ChoiceFormat-based currency names.  If this field
+     * is not null, then delegate to it to format currency symbols.
+     * @since ICU 2.6
+     */
+    ChoiceFormat*           fCurrencyChoice;
+
+    DigitList *             fMultiplier;   // NULL for multiplier of one
+    int32_t                 fScale;
+    int32_t                 fGroupingSize;
+    int32_t                 fGroupingSize2;
+    UBool                   fDecimalSeparatorAlwaysShown;
+    DecimalFormatSymbols*   fSymbols;
+
+    UBool                   fUseSignificantDigits;
+    int32_t                 fMinSignificantDigits;
+    int32_t                 fMaxSignificantDigits;
+
+    UBool                   fUseExponentialNotation;
+    int8_t                  fMinExponentDigits;
+    UBool                   fExponentSignAlwaysShown;
+
+    EnumSet<UNumberFormatAttribute,
+            UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
+            UNUM_LIMIT_BOOLEAN_ATTRIBUTE>
+                            fBoolFlags;
+
+    DigitList*              fRoundingIncrement;  // NULL if no rounding increment specified.
+    ERoundingMode           fRoundingMode;
+
+    UChar32                 fPad;
+    int32_t                 fFormatWidth;
+    EPadPosition            fPadPosition;
+
+    /*
+     * Following are used for currency format
+     */
+    // pattern used in this formatter
+    UnicodeString fFormatPattern;
+    // style is only valid when decimal formatter is constructed by
+    // DecimalFormat(pattern, decimalFormatSymbol, style)
+    int fStyle;
+    /*
+     * Represents whether this is a currency format, and which
+     * currency format style.
+     * 0: not currency format type;
+     * 1: currency style -- symbol name, such as "$" for US dollar.
+     * 2: currency style -- ISO name, such as USD for US dollar.
+     * 3: currency style -- plural long name, such as "US Dollar" for
+     *                      "1.00 US Dollar", or "US Dollars" for
+     *                      "3.00 US Dollars".
+     */
+    int fCurrencySignCount;
+
+
+    /* For currency parsing purose,
+     * Need to remember all prefix patterns and suffix patterns of
+     * every currency format pattern,
+     * including the pattern of default currecny style
+     * and plural currency style. And the patterns are set through applyPattern.
+     */
+    // TODO: innerclass?
+    /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
+    struct AffixPatternsForCurrency : public UMemory {
+        // negative prefix pattern
+        UnicodeString negPrefixPatternForCurrency;
+        // negative suffix pattern
+        UnicodeString negSuffixPatternForCurrency;
+        // positive prefix pattern
+        UnicodeString posPrefixPatternForCurrency;
+        // positive suffix pattern
+        UnicodeString posSuffixPatternForCurrency;
+        int8_t patternType;
+
+        AffixPatternsForCurrency(const UnicodeString& negPrefix,
+                                 const UnicodeString& negSuffix,
+                                 const UnicodeString& posPrefix,
+                                 const UnicodeString& posSuffix,
+                                 int8_t type) {
+            negPrefixPatternForCurrency = negPrefix;
+            negSuffixPatternForCurrency = negSuffix;
+            posPrefixPatternForCurrency = posPrefix;
+            posSuffixPatternForCurrency = posSuffix;
+            patternType = type;
+        }
+    };
+    */
+
+    /* affix for currency formatting when the currency sign in the pattern
+     * equals to 3, such as the pattern contains 3 currency sign or
+     * the formatter style is currency plural format style.
+     */
+    /* This is not needed in the class declaration, so it is moved into decimfmp.cpp
+    struct AffixesForCurrency : public UMemory {
+        // negative prefix
+        UnicodeString negPrefixForCurrency;
+        // negative suffix
+        UnicodeString negSuffixForCurrency;
+        // positive prefix
+        UnicodeString posPrefixForCurrency;
+        // positive suffix
+        UnicodeString posSuffixForCurrency;
+
+        int32_t formatWidth;
+
+        AffixesForCurrency(const UnicodeString& negPrefix,
+                           const UnicodeString& negSuffix,
+                           const UnicodeString& posPrefix,
+                           const UnicodeString& posSuffix) {
+            negPrefixForCurrency = negPrefix;
+            negSuffixForCurrency = negSuffix;
+            posPrefixForCurrency = posPrefix;
+            posSuffixForCurrency = posSuffix;
+        }
+    };
+    */
+
+    // Affix pattern set for currency.
+    // It is a set of AffixPatternsForCurrency,
+    // each element of the set saves the negative prefix pattern,
+    // negative suffix pattern, positive prefix pattern,
+    // and positive suffix  pattern of a pattern.
+    // It is used for currency mixed style parsing.
+    // It is actually is a set.
+    // The set contains the default currency pattern from the locale,
+    // and the currency plural patterns.
+    // Since it is a set, it does not contain duplicated items.
+    // For example, if 2 currency plural patterns are the same, only one pattern
+    // is included in the set. When parsing, we do not check whether the plural
+    // count match or not.
+    Hashtable* fAffixPatternsForCurrency;
+
+    // Following 2 are affixes for currency.
+    // It is a hash map from plural count to AffixesForCurrency.
+    // AffixesForCurrency saves the negative prefix,
+    // negative suffix, positive prefix, and positive suffix of a pattern.
+    // It is used during currency formatting only when the currency sign count
+    // is 3. In which case, the affixes are getting from here, not
+    // from the fNegativePrefix etc.
+    Hashtable* fAffixesForCurrency;  // for current pattern
+    Hashtable* fPluralAffixesForCurrency;  // for plural pattern
+
+    // Information needed for DecimalFormat to format/parse currency plural.
+    CurrencyPluralInfo* fCurrencyPluralInfo;
+
+#if UCONFIG_HAVE_PARSEALLINPUT
+    UNumberFormatAttributeValue fParseAllInput;
+#endif
+
+    // Decimal Format Static Sets singleton.
+    const DecimalFormatStaticSets *fStaticSets;
+	
+    // Currency Usage(STANDARD vs CASH)
+    UCurrencyUsage fCurrencyUsage;
+
+protected:
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Rounds a value according to the rules of this object.
+     * @internal
+     */
+    DigitList& _round(const DigitList& number, DigitList& adjustedNum, UBool& isNegative, UErrorCode& status) const;
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Returns the currency in effect for this formatter.  Subclasses
+     * should override this method as needed.  Unlike getCurrency(),
+     * this method should never return "".
+     * @result output parameter for null-terminated result, which must
+     * have a capacity of at least 4
+     * @internal
+     */
+    virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
+
+  /** number of integer digits
+   * @stable ICU 2.4
+   */
+    static const int32_t  kDoubleIntegerDigits;
+  /** number of fraction digits
+   * @stable ICU 2.4
+   */
+    static const int32_t  kDoubleFractionDigits;
+
+    /**
+     * When someone turns on scientific mode, we assume that more than this
+     * number of digits is due to flipping from some other mode that didn't
+     * restrict the maximum, and so we force 1 integer digit.  We don't bother
+     * to track and see if someone is using exponential notation with more than
+     * this number, it wouldn't make sense anyway, and this is just to make sure
+     * that someone turning on scientific mode with default settings doesn't
+     * end up with lots of zeroes.
+     * @stable ICU 2.8
+     */
+    static const int32_t  kMaxScientificIntegerDigits;
+
+#if UCONFIG_FORMAT_FASTPATHS_49
+ private:
+    /**
+     * Internal state.
+     * @internal
+     */
+    uint8_t fReserved[UNUM_DECIMALFORMAT_INTERNAL_SIZE];
+
+
+    /**
+     * Called whenever any state changes. Recomputes whether fastpath is OK to use.
+     */
+    void handleChanged();
+#endif
+};
+
+inline const UnicodeString &
+DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
+    return fSymbols->getConstSymbol(symbol);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DECIMFMT
+//eof

+ 215 - 0
sqlite/unicode/docmain.h

@@ -0,0 +1,215 @@
+/********************************************************************
+ * COPYRIGHT: 
+ * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *
+ *  FILE NAME: DOCMAIN.h
+ *
+ *   Date          Name        Description
+ *   12/11/2000    Ram        Creation.
+ */
+
+/**
+ * \file
+ * \brief (Non API- contains Doxygen definitions)
+ *
+ * This file contains documentation for Doxygen and doesnot have
+ * any significance with respect to C or C++ API
+ */
+
+/*! \mainpage
+ *
+ * \section API API Reference Usage
+ * 
+ * <h3>C++ Programmers:</h3>
+ * <p>Use <a href="hierarchy.html">Class Hierarchy</a> or <a href="classes.html"> Alphabetical List </a>
+ * or <a href="annotated.html"> Compound List</a>
+ * to find the class you are interested in. For example, to find BreakIterator,
+ * you can go to the <a href="classes.html"> Alphabetical List</a>, then click on
+ * "BreakIterator". Once you are at the class, you will find an inheritance
+ * chart, a list of the public members, a detailed description of the class,
+ * then detailed member descriptions.</p>
+ * 
+ * <h3>C Programmers:</h3>
+ * <p>Use <a href="#Module">Module List</a> or <a href="globals.html">File Members</a>
+ * to find a list of all the functions and constants.
+ * For example, to find BreakIterator functions you would click on
+ * <a href="files.html"> File List</a>,
+ * then find "ubrk.h" and click on it. You will find descriptions of Defines,
+ * Typedefs, Enumerations, and Functions, with detailed descriptions below.
+ * If you want to find a specific function, such as ubrk_next(), then click
+ * first on <a href="globals.html"> File Members</a>, then use your browser
+ * Find dialog to search for "ubrk_next()".</p>
+ *
+ *
+ * <h3>API References for Previous Releases</h3>
+ * <p>The API References for each release of ICU are also available as
+ * a zip file from the ICU 
+ * <a href="http://site.icu-project.org/download">download page</a>.</p>
+ *
+ * <hr>
+ *
+ * <h2>Architecture (User's Guide)</h2>
+ * <ul>
+ *   <li><a href="http://userguide.icu-project.org/">Introduction</a></li>
+ *   <li><a href="http://userguide.icu-project.org/i18n">Internationalization</a></li>
+ *   <li><a href="http://userguide.icu-project.org/design">Locale Model, Multithreading, Error Handling, etc.</a></li>
+ *   <li><a href="http://userguide.icu-project.org/conversion">Conversion</a></li>
+ * </ul>
+ *
+ * <hr>
+ *\htmlonly <h2><a NAME="Module">Module List</a></h2> \endhtmlonly
+ * <table border="1" cols="3" align="center">
+ *   <tr>
+ *     <td><strong>Module Name</strong></td>
+ *     <td><strong>C</strong></td>
+ *     <td><strong>C++</strong></td>
+ *   </tr>
+ *   <tr>
+ *     <td>Basic Types and Constants</td>
+ *     <td>utypes.h</td>
+ *     <td>utypes.h</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Strings and Character Iteration</td>
+ *     <td>ustring.h, utf8.h, utf16.h, UText, UCharIterator</td>
+ *     <td>icu::UnicodeString, icu::CharacterIterator, icu::Appendable, icu::StringPiece,icu::ByteSink</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Unicode Character<br/>Properties and Names</td>
+ *     <td>uchar.h, uscript.h</td>
+ *     <td>C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Sets of Unicode Code Points and Strings</td>
+ *     <td>uset.h</td>
+ *     <td>icu::UnicodeSet</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Maps from Strings to Integer Values</td>
+ *     <td>(no C API)</td>
+ *     <td>icu::BytesTrie, icu::UCharsTrie</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Codepage Conversion</td>
+ *     <td>ucnv.h, ucnvsel.hb</td>
+ *     <td>C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Unicode Text Compression</td>
+ *     <td>ucnv.h<br/>(encoding name "SCSU" or "BOCU-1")</td>
+ *     <td>C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Locales </td>
+ *     <td>uloc.h</a></td>
+ *     <td>icu::Locale</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Resource Bundles</td>
+ *     <td>ures.h</td>
+ *     <td>icu::ResourceBundle</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Normalization</td>
+ *     <td>unorm2.h</td>
+ *     <td>icu::Normalizer2</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Calendars</td>
+ *     <td>ucal.h</td>
+ *     <td>icu::Calendar</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Date and Time Formatting</td>
+ *     <td>udat.h</td>
+ *     <td>icu::DateFormat</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Message Formatting</td>
+ *     <td>umsg.h</td>
+ *     <td>icu::MessageFormat</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Number Formatting</td>
+ *     <td>unum.h</td>
+ *     <td>icu::NumberFormat</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Number Spellout<br/>(Rule Based Number Formatting)</td>
+ *     <td>unum.h<br/>(use UNUM_SPELLOUT)</td>
+ *     <td>icu::RuleBasedNumberFormat</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Text Transformation<br/>(Transliteration)</td>
+ *     <td>utrans.h</td>
+ *     <td>icu::Transliterator</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Bidirectional Algorithm</td>
+ *     <td>ubidi.h</td>
+ *     <td>C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Arabic Shaping</td>
+ *     <td>ushape.h</td>
+ *     <td>C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Collation</td>
+ *     <td>ucol.h</td>
+ *     <td>icu::Collator</td>
+ *   </tr>
+ *   <tr>
+ *     <td>String Searching</td>
+ *     <td>usearch.h</td>
+ *     <td>icu::StringSearch</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Index Characters/<br/>Bucketing for Sorted Lists</td>
+ *     <td>(no C API)</td>
+ *     <td>icu::AlphabeticIndex</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Text Boundary Analysis<br/>(Break Iteration)</td>
+ *     <td>ubrk.h</td>
+ *     <td>icu::BreakIterator</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Regular Expressions</td>
+ *     <td>uregex.h</td>
+ *     <td>icu::RegexPattern, icu::RegexMatcher</td>
+ *   </tr>
+ *   <tr>
+ *     <td>StringPrep</td>
+ *     <td>usprep.h</td>
+ *     <td>C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>International Domain Names in Applications:<br/>
+ *         UTS #46 in C/C++, IDNA2003 only via C API</td>
+ *     <td>uidna.h</td>
+ *     <td>idna.h</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Identifier Spoofing & Confusability</td>
+ *     <td>uspoof.h</td>
+ *     <td>C API</td>
+ *   <tr>
+ *     <td>Universal Time Scale</td>
+ *     <td>utmscale.h</td>
+ *     <td>C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Layout Engine/Complex Text Layout</td>
+ *     <td>loengine.h</td>
+ *     <td>icu::LayoutEngine,icu::ParagraphLayout</td>
+ *   </tr>
+ *   <tr>
+ *     <td>ICU I/O</td>
+ *     <td>ustdio.h</td>
+ *     <td>ustream.h</td>
+ *   </tr>
+ * </table>
+ * <i>This main page is generated from docmain.h</i>
+ */

+ 971 - 0
sqlite/unicode/dtfmtsym.h

@@ -0,0 +1,971 @@
+/*  
+********************************************************************************
+*   Copyright (C) 1997-2015, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File DTFMTSYM.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*    07/21/98    stephen        Added getZoneIndex()
+*                            Changed to match C++ conventions
+********************************************************************************
+*/
+     
+#ifndef DTFMTSYM_H
+#define DTFMTSYM_H
+ 
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/calendar.h"
+#include "unicode/uobject.h"
+#include "unicode/locid.h"
+#include "unicode/udat.h"
+#include "unicode/ures.h"
+
+/**
+ * \file 
+ * \brief C++ API: Symbols for formatting dates.
+ */
+
+U_NAMESPACE_BEGIN
+
+/* forward declaration */
+class SimpleDateFormat;
+class Hashtable;
+
+/**
+ * DateFormatSymbols is a public class for encapsulating localizable date-time
+ * formatting data -- including timezone data. DateFormatSymbols is used by
+ * DateFormat and SimpleDateFormat.
+ * <P>
+ * Rather than first creating a DateFormatSymbols to get a date-time formatter
+ * by using a SimpleDateFormat constructor, clients are encouraged to create a
+ * date-time formatter using the getTimeInstance(), getDateInstance(), or
+ * getDateTimeInstance() method in DateFormat. Each of these methods can return a
+ * date/time formatter initialized with a default format pattern along with the
+ * date-time formatting data for a given or default locale. After a formatter is
+ * created, clients may modify the format pattern using the setPattern function
+ * as so desired. For more information on using these formatter factory
+ * functions, see DateFormat.
+ * <P>
+ * If clients decide to create a date-time formatter with a particular format
+ * pattern and locale, they can do so with new SimpleDateFormat(aPattern,
+ * new DateFormatSymbols(aLocale)).  This will load the appropriate date-time
+ * formatting data from the locale.
+ * <P>
+ * DateFormatSymbols objects are clonable. When clients obtain a
+ * DateFormatSymbols object, they can feel free to modify the date-time
+ * formatting data as necessary. For instance, clients can
+ * replace the localized date-time format pattern characters with the ones that
+ * they feel easy to remember. Or they can change the representative cities
+ * originally picked by default to using their favorite ones.
+ * <P>
+ * DateFormatSymbols are not expected to be subclassed. Data for a calendar is
+ * loaded out of resource bundles.  The 'type' parameter indicates the type of
+ * calendar, for example, "gregorian" or "japanese".  If the type is not gregorian
+ * (or NULL, or an empty string) then the type is appended to the resource name,
+ * for example,  'Eras_japanese' instead of 'Eras'.   If the resource 'Eras_japanese' did
+ * not exist (even in root), then this class will fall back to just 'Eras', that is,
+ * Gregorian data.  Therefore, the calendar implementor MUST ensure that the root
+ * locale at least contains any resources that are to be particularized for the
+ * calendar type.
+ */
+class U_I18N_API DateFormatSymbols U_FINAL : public UObject  {
+public:
+    /**
+     * Construct a DateFormatSymbols object by loading format data from
+     * resources for the default locale, in the default calendar (Gregorian).
+     * <P>
+     * NOTE: This constructor will never fail; if it cannot get resource
+     * data for the default locale, it will return a last-resort object
+     * based on hard-coded strings.
+     *
+     * @param status    Status code.  Failure
+     *                  results if the resources for the default cannot be
+     *                  found or cannot be loaded
+     * @stable ICU 2.0
+     */
+    DateFormatSymbols(UErrorCode& status);
+
+    /**
+     * Construct a DateFormatSymbols object by loading format data from
+     * resources for the given locale, in the default calendar (Gregorian).
+     *
+     * @param locale    Locale to load format data from.
+     * @param status    Status code.  Failure
+     *                  results if the resources for the locale cannot be
+     *                  found or cannot be loaded
+     * @stable ICU 2.0
+     */
+    DateFormatSymbols(const Locale& locale,
+                      UErrorCode& status);
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Construct a DateFormatSymbols object by loading format data from
+     * resources for the default locale, in the default calendar (Gregorian).
+     * <P>
+     * NOTE: This constructor will never fail; if it cannot get resource
+     * data for the default locale, it will return a last-resort object
+     * based on hard-coded strings.
+     *
+     * @param type      Type of calendar (as returned by Calendar::getType). 
+     *                  Will be used to access the correct set of strings.
+     *                  (NULL or empty string defaults to "gregorian".)
+     * @param status    Status code.  Failure
+     *                  results if the resources for the default cannot be
+     *                  found or cannot be loaded
+     * @internal
+     */
+    DateFormatSymbols(const char *type, UErrorCode& status);
+
+    /**
+     * Construct a DateFormatSymbols object by loading format data from
+     * resources for the given locale, in the default calendar (Gregorian).
+     *
+     * @param locale    Locale to load format data from.
+     * @param type      Type of calendar (as returned by Calendar::getType). 
+     *                  Will be used to access the correct set of strings.
+     *                  (NULL or empty string defaults to "gregorian".)
+     * @param status    Status code.  Failure
+     *                  results if the resources for the locale cannot be
+     *                  found or cannot be loaded
+     * @internal
+     */
+    DateFormatSymbols(const Locale& locale,
+                      const char *type,
+                      UErrorCode& status);
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    DateFormatSymbols(const DateFormatSymbols&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 2.0
+     */
+    DateFormatSymbols& operator=(const DateFormatSymbols&);
+
+    /**
+     * Destructor. This is nonvirtual because this class is not designed to be
+     * subclassed.
+     * @stable ICU 2.0
+     */
+    virtual ~DateFormatSymbols();
+
+    /**
+     * Return true if another object is semantically equal to this one.
+     *
+     * @param other    the DateFormatSymbols object to be compared with.
+     * @return         true if other is semantically equal to this.
+     * @stable ICU 2.0
+     */
+    UBool operator==(const DateFormatSymbols& other) const;
+
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the DateFormatSymbols object to be compared with.
+     * @return         true if other is semantically unequal to this.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
+
+    /**
+     * Gets abbreviated era strings. For example: "AD" and "BC".
+     *
+     * @param count    Filled in with length of the array.
+     * @return         the era strings.
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getEras(int32_t& count) const;
+
+    /**
+     * Sets abbreviated era strings. For example: "AD" and "BC".
+     * @param eras  Array of era strings (DateFormatSymbols retains ownership.)
+     * @param count Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setEras(const UnicodeString* eras, int32_t count);
+
+    /**
+     * Gets era name strings. For example: "Anno Domini" and "Before Christ".
+     *
+     * @param count    Filled in with length of the array.
+     * @return         the era name strings.
+     * @stable ICU 3.4
+     */
+    const UnicodeString* getEraNames(int32_t& count) const;
+
+    /**
+     * Sets era name strings. For example: "Anno Domini" and "Before Christ".
+     * @param eraNames  Array of era name strings (DateFormatSymbols retains ownership.)
+     * @param count Filled in with length of the array.
+     * @stable ICU 3.6
+     */
+    void setEraNames(const UnicodeString* eraNames, int32_t count);
+
+    /**
+     * Gets narrow era strings. For example: "A" and "B".
+     *
+     * @param count    Filled in with length of the array.
+     * @return         the narrow era strings.
+     * @stable ICU 4.2
+     */
+    const UnicodeString* getNarrowEras(int32_t& count) const;
+
+    /**
+     * Sets narrow era strings. For example: "A" and "B".
+     * @param narrowEras  Array of narrow era strings (DateFormatSymbols retains ownership.)
+     * @param count Filled in with length of the array.
+     * @stable ICU 4.2
+     */
+    void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
+
+    /**
+     * Gets month strings. For example: "January", "February", etc.
+     * @param count Filled in with length of the array.
+     * @return the month strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getMonths(int32_t& count) const;
+
+    /**
+     * Sets month strings. For example: "January", "February", etc.
+     *
+     * @param months    the new month strings. (not adopted; caller retains ownership)
+     * @param count     Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setMonths(const UnicodeString* months, int32_t count);
+
+    /**
+     * Gets short month strings. For example: "Jan", "Feb", etc.
+     *
+     * @param count Filled in with length of the array.
+     * @return the short month strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getShortMonths(int32_t& count) const;
+
+    /**
+     * Sets short month strings. For example: "Jan", "Feb", etc.
+     * @param count        Filled in with length of the array.
+     * @param shortMonths  the new short month strings. (not adopted; caller retains ownership)
+     * @stable ICU 2.0
+     */
+    void setShortMonths(const UnicodeString* shortMonths, int32_t count);
+
+    /**
+     * Selector for date formatting context
+     * @stable ICU 3.6
+     */
+    enum DtContextType {
+         FORMAT,
+         STANDALONE,
+         DT_CONTEXT_COUNT
+    };
+
+    /**
+     * Selector for date formatting width
+     * @stable ICU 3.6
+     */
+    enum DtWidthType {
+         ABBREVIATED,
+         WIDE,
+         NARROW,
+         /**
+          * Short width is currently only supported for weekday names.
+          * @stable ICU 51
+          */
+         SHORT,
+         /**
+          */
+         DT_WIDTH_COUNT = 4
+    };
+
+    /**
+     * Gets month strings by width and context. For example: "January", "February", etc.
+     * @param count Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
+     * @return the month strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 3.4
+     */
+    const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
+
+    /**
+     * Sets month strings by width and context. For example: "January", "February", etc.
+     *
+     * @param months  The new month strings. (not adopted; caller retains ownership)
+     * @param count   Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
+     * @stable ICU 3.6
+     */
+    void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
+
+    /**
+     * Gets wide weekday strings. For example: "Sunday", "Monday", etc.
+     * @param count        Filled in with length of the array.
+     * @return the weekday strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getWeekdays(int32_t& count) const;
+
+
+    /**
+     * Sets wide weekday strings. For example: "Sunday", "Monday", etc.
+     * @param weekdays     the new weekday strings. (not adopted; caller retains ownership)
+     * @param count        Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setWeekdays(const UnicodeString* weekdays, int32_t count);
+
+    /**
+     * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
+     * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
+     * @param count        Filled in with length of the array.
+     * @return             the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getShortWeekdays(int32_t& count) const;
+
+    /**
+     * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
+     * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
+     * @param abbrevWeekdays  the new abbreviated weekday strings. (not adopted; caller retains ownership)
+     * @param count           Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
+
+    /**
+     * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
+     * @param count   Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
+     * @return the month strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 3.4
+     */
+    const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
+
+    /**
+     * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
+     * @param weekdays  The new weekday strings. (not adopted; caller retains ownership)
+     * @param count     Filled in with length of the array.
+     * @param context   The formatting context, either FORMAT or STANDALONE
+     * @param width     The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
+     * @stable ICU 3.6
+     */
+    void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
+
+    /**
+     * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
+     * @param count Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE or ABBREVIATED. There
+     *                are no NARROW quarters.
+     * @return the quarter strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 3.6
+     */
+    const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
+
+    /**
+     * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
+     *
+     * @param quarters  The new quarter strings. (not adopted; caller retains ownership)
+     * @param count   Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE or ABBREVIATED. There
+     *                are no NARROW quarters.
+     * @stable ICU 3.6
+     */
+    void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
+
+    /**
+     * Gets AM/PM strings. For example: "AM" and "PM".
+     * @param count        Filled in with length of the array.
+     * @return             the weekday strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getAmPmStrings(int32_t& count) const;
+
+    /**
+     * Sets ampm strings. For example: "AM" and "PM".
+     * @param ampms        the new ampm strings. (not adopted; caller retains ownership)
+     * @param count        Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setAmPmStrings(const UnicodeString* ampms, int32_t count);
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * This default time separator is used for formatting when the locale
+     * doesn't specify any time separator, and always recognized when parsing.
+     * @internal
+     */
+    static const UChar DEFAULT_TIME_SEPARATOR = 0x003a;  // ':'
+
+    /**
+     * This alternate time separator is always recognized when parsing.
+     * @internal
+     */
+    static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e;  // '.'
+#endif  /* U_HIDE_INTERNAL_API */
+
+#ifndef U_HIDE_DRAFT_API
+    /**
+     * Gets the time separator string. For example: ":".
+     * @param result Output param which will receive the time separator string.
+     * @return       A reference to 'result'.
+     * @draft ICU 55
+     */
+    UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
+
+    /**
+     * Sets the time separator string. For example: ":".
+     * @param newTimeSeparator the new time separator string.
+     * @draft ICU 55
+     */
+    void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
+#endif  /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_DRAFT_API
+    /**
+     * Gets cyclic year name strings if the calendar has them, by width and context.
+     * For example: "jia-zi", "yi-chou", etc.
+     * @param count     Filled in with length of the array.
+     * @param context   The usage context: FORMAT, STANDALONE.
+     * @param width     The requested name width: WIDE, ABBREVIATED, NARROW.
+     * @return          The year name strings (DateFormatSymbols retains ownership),
+     *                  or null if they are not available for this calendar.
+     * @draft ICU 54
+     */
+    const UnicodeString* getYearNames(int32_t& count,
+                            DtContextType context, DtWidthType width) const;
+
+    /**
+     * Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
+     *
+     * @param yearNames The new cyclic year name strings (not adopted; caller retains ownership).
+     * @param count     The length of the array.
+     * @param context   The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
+     * @param width     The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
+     * @draft ICU 54
+     */
+    void setYearNames(const UnicodeString* yearNames, int32_t count,
+                            DtContextType context, DtWidthType width);
+
+    /**
+     * Gets calendar zodiac name strings if the calendar has them, by width and context.
+     * For example: "Rat", "Ox", "Tiger", etc.
+     * @param count     Filled in with length of the array.
+     * @param context   The usage context: FORMAT, STANDALONE.
+     * @param width     The requested name width: WIDE, ABBREVIATED, NARROW.
+     * @return          The zodiac name strings (DateFormatSymbols retains ownership),
+     *                  or null if they are not available for this calendar.
+     * @draft ICU 54
+     */
+    const UnicodeString* getZodiacNames(int32_t& count,
+                            DtContextType context, DtWidthType width) const;
+
+    /**
+     * Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
+     *
+     * @param zodiacNames The new zodiac name strings (not adopted; caller retains ownership).
+     * @param count     The length of the array.
+     * @param context   The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
+     * @param width     The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
+     * @draft ICU 54
+     */
+    void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
+                            DtContextType context, DtWidthType width);
+
+#endif  /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Somewhat temporary constants for leap month pattern types, adequate for supporting
+     * just leap month patterns as needed for Chinese lunar calendar.
+     * Eventually we will add full support for different month pattern types (needed for
+     * other calendars such as Hindu) at which point this approach will be replaced by a
+     * more complete approach.
+     * @internal
+     */
+    enum EMonthPatternType
+    {
+        kLeapMonthPatternFormatWide,
+        kLeapMonthPatternFormatAbbrev,
+        kLeapMonthPatternFormatNarrow,
+        kLeapMonthPatternStandaloneWide,
+        kLeapMonthPatternStandaloneAbbrev,
+        kLeapMonthPatternStandaloneNarrow,
+        kLeapMonthPatternNumeric,
+        kMonthPatternsCount
+    };
+
+    /**
+     * Somewhat temporary function for getting complete set of leap month patterns for all
+     * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar
+     * does not have leap month patterns. Note, there is currently no setter for this.
+     * Eventually we will add full support for different month pattern types (needed for
+     * other calendars such as Hindu) at which point this approach will be replaced by a
+     * more complete approach.
+     * @param count        Filled in with length of the array (may be 0).
+     * @return             The leap month patterns (DateFormatSymbols retains ownership).
+     *                     May be NULL if there are no leap month patterns for this calendar.
+     * @internal
+     */
+    const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
+
+#endif  /* U_HIDE_INTERNAL_API */
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Gets timezone strings. These strings are stored in a 2-dimensional array.
+     * @param rowCount      Output param to receive number of rows.
+     * @param columnCount   Output param to receive number of columns.
+     * @return              The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
+     * @deprecated ICU 3.6
+     */
+    const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
+#endif  /* U_HIDE_DEPRECATED_API */
+
+    /**
+     * Sets timezone strings. These strings are stored in a 2-dimensional array.
+     * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in
+     * a DateFormatSymbols. Therefore, the time zone strings set by this mthod
+     * have no effects in an instance of SimpleDateFormat for formatting time
+     * zones.
+     * @param strings       The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
+     * @param rowCount      The number of rows (count of first index).
+     * @param columnCount   The number of columns (count of second index).
+     * @stable ICU 2.0
+     */
+    void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
+
+    /**
+     * Get the non-localized date-time pattern characters.
+     * @return    the non-localized date-time pattern characters
+     * @stable ICU 2.0
+     */
+    static const UChar * U_EXPORT2 getPatternUChars(void);
+
+    /**
+     * Gets localized date-time pattern characters. For example: 'u', 't', etc.
+     * <p>
+     * Note: ICU no longer provides localized date-time pattern characters for a locale
+     * starting ICU 3.8.  This method returns the non-localized date-time pattern
+     * characters unless user defined localized data is set by setLocalPatternChars.
+     * @param result    Output param which will receive the localized date-time pattern characters.
+     * @return          A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    UnicodeString& getLocalPatternChars(UnicodeString& result) const;
+
+    /**
+     * Sets localized date-time pattern characters. For example: 'u', 't', etc.
+     * @param newLocalPatternChars the new localized date-time
+     * pattern characters.
+     * @stable ICU 2.0
+     */
+    void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
+
+    /**
+     * Returns the locale for this object. Two flavors are available:
+     * valid and actual locale.
+     * @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+    /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
+       they are needed for .h file declarations. */ 
+    /**
+     * Constants for capitalization context usage types.
+     * @internal
+     */
+    enum ECapitalizationContextUsageType
+    {
+#ifndef U_HIDE_INTERNAL_API
+        kCapContextUsageOther = 0,
+        kCapContextUsageMonthFormat,     /* except narrow */
+        kCapContextUsageMonthStandalone, /* except narrow */
+        kCapContextUsageMonthNarrow,
+        kCapContextUsageDayFormat,     /* except narrow */
+        kCapContextUsageDayStandalone, /* except narrow */
+        kCapContextUsageDayNarrow,
+        kCapContextUsageEraWide,
+        kCapContextUsageEraAbbrev,
+        kCapContextUsageEraNarrow,
+        kCapContextUsageZoneLong,
+        kCapContextUsageZoneShort,
+        kCapContextUsageMetazoneLong,
+        kCapContextUsageMetazoneShort,
+#endif /* U_HIDE_INTERNAL_API */
+        kCapContextUsageTypeCount = 14
+    };
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+
+    friend class SimpleDateFormat;
+    friend class DateFormatSymbolsSingleSetter; // see udat.cpp
+
+    /**
+     * Abbreviated era strings. For example: "AD" and "BC".
+     */
+    UnicodeString*  fEras;
+    int32_t         fErasCount;
+
+    /**
+     * Era name strings. For example: "Anno Domini" and "Before Christ".
+     */
+    UnicodeString*  fEraNames;
+    int32_t         fEraNamesCount;
+
+    /**
+     * Narrow era strings. For example: "A" and "B".
+     */
+    UnicodeString*  fNarrowEras;
+    int32_t         fNarrowErasCount;
+
+    /**
+     * Month strings. For example: "January", "February", etc.
+     */
+    UnicodeString*  fMonths;
+    int32_t         fMonthsCount;
+
+    /**
+     * Short month strings. For example: "Jan", "Feb", etc.
+     */
+    UnicodeString*  fShortMonths;
+    int32_t         fShortMonthsCount;
+
+    /**
+     * Narrow month strings. For example: "J", "F", etc.
+     */
+    UnicodeString*  fNarrowMonths;
+    int32_t         fNarrowMonthsCount;
+
+    /**
+     * Standalone Month strings. For example: "January", "February", etc.
+     */
+    UnicodeString*  fStandaloneMonths;
+    int32_t         fStandaloneMonthsCount;
+
+    /**
+     * Standalone Short month strings. For example: "Jan", "Feb", etc.
+     */
+    UnicodeString*  fStandaloneShortMonths;
+    int32_t         fStandaloneShortMonthsCount;
+
+    /**
+     * Standalone Narrow month strings. For example: "J", "F", etc.
+     */
+    UnicodeString*  fStandaloneNarrowMonths;
+    int32_t         fStandaloneNarrowMonthsCount;
+
+    /**
+     * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
+     */
+    UnicodeString*  fWeekdays;
+    int32_t         fWeekdaysCount;
+
+    /**
+     * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
+     */
+    UnicodeString*  fShortWeekdays;
+    int32_t         fShortWeekdaysCount;
+
+    /**
+     * CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
+     */
+    UnicodeString*  fShorterWeekdays;
+    int32_t         fShorterWeekdaysCount;
+
+    /**
+     * CLDR-style format narrow weekday strings. For example: "S", "M", etc.
+     */
+    UnicodeString*  fNarrowWeekdays;
+    int32_t         fNarrowWeekdaysCount;
+
+    /**
+     * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
+     */
+    UnicodeString*  fStandaloneWeekdays;
+    int32_t         fStandaloneWeekdaysCount;
+
+    /**
+     * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
+     */
+    UnicodeString*  fStandaloneShortWeekdays;
+    int32_t         fStandaloneShortWeekdaysCount;
+
+    /**
+     * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
+     */
+    UnicodeString*  fStandaloneShorterWeekdays;
+    int32_t         fStandaloneShorterWeekdaysCount;
+
+    /**
+     * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
+     */
+    UnicodeString*  fStandaloneNarrowWeekdays;
+    int32_t         fStandaloneNarrowWeekdaysCount;
+
+    /**
+     * Ampm strings. For example: "AM" and "PM".
+     */
+    UnicodeString*  fAmPms;
+    int32_t         fAmPmsCount;
+
+    /**
+     * Narrow Ampm strings. For example: "a" and "p".
+     */
+    UnicodeString*  fNarrowAmPms;
+    int32_t         fNarrowAmPmsCount;
+
+    /**
+     * Time separator string. For example: ":".
+     */
+    UnicodeString   fTimeSeparator;
+
+    /**
+     * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
+     */
+    UnicodeString  *fQuarters;
+    int32_t         fQuartersCount;
+
+    /**
+     * Short quarters. For example: "Q1", "Q2", etc.
+     */
+    UnicodeString  *fShortQuarters;
+    int32_t         fShortQuartersCount;
+
+    /**
+     * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
+     */
+    UnicodeString  *fStandaloneQuarters;
+    int32_t         fStandaloneQuartersCount;
+
+    /**
+     * Standalone short quarter strings. For example: "Q1", "Q2", etc.
+     */
+    UnicodeString  *fStandaloneShortQuarters;
+    int32_t         fStandaloneShortQuartersCount;
+
+    /**
+     * All leap month patterns, for example "{0}bis".
+     */
+    UnicodeString  *fLeapMonthPatterns;
+    int32_t         fLeapMonthPatternsCount;
+
+    /**
+     * Cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai";
+     * currently we only have data for format/abbreviated.
+     * For the others, just get from format/abbreviated, ignore set.
+     */
+    UnicodeString  *fShortYearNames;
+    int32_t         fShortYearNamesCount;
+
+    /**
+     * Cyclic zodiac names, for example "Rat", "Ox", "Tiger", etc.;
+     * currently we only have data for format/abbreviated.
+     * For the others, just get from format/abbreviated, ignore set.
+     */
+    UnicodeString  *fShortZodiacNames;
+    int32_t         fShortZodiacNamesCount;
+
+    /**
+     * Localized names of time zones in this locale.  This is a
+     * two-dimensional array of strings of size n by m,
+     * where m is at least 5 and up to 7.  Each of the n rows is an
+     * entry containing the localized names for a single TimeZone.
+     *
+     * Each such row contains (with i ranging from 0..n-1):
+     * 
+     * zoneStrings[i][0] - time zone ID
+     *  example: America/Los_Angeles
+     * zoneStrings[i][1] - long name of zone in standard time
+     *  example: Pacific Standard Time
+     * zoneStrings[i][2] - short name of zone in standard time
+     *  example: PST
+     * zoneStrings[i][3] - long name of zone in daylight savings time
+     *  example: Pacific Daylight Time
+     * zoneStrings[i][4] - short name of zone in daylight savings time
+     *  example: PDT
+     * zoneStrings[i][5] - location name of zone
+     *  example: United States (Los Angeles)
+     * zoneStrings[i][6] - long generic name of zone
+     *  example: Pacific Time
+     * zoneStrings[i][7] - short generic of zone
+     *  example: PT
+     *
+     * The zone ID is not localized; it corresponds to the ID
+     * value associated with a system time zone object.  All other entries
+     * are localized names.  If a zone does not implement daylight savings
+     * time, the daylight savings time names are ignored.
+     *
+     * Note:CLDR 1.5 introduced metazone and its historical mappings.
+     * This simple two-dimensional array is no longer sufficient to represent
+     * localized names and its historic changes.  Since ICU 3.8.1, localized
+     * zone names extracted from ICU locale data is stored in a ZoneStringFormat
+     * instance.  But we still need to support the old way of customizing
+     * localized zone names, so we keep this field for the purpose.
+     */
+    UnicodeString   **fZoneStrings;         // Zone string array set by setZoneStrings
+    UnicodeString   **fLocaleZoneStrings;   // Zone string array created by the locale
+    int32_t         fZoneStringsRowCount;
+    int32_t         fZoneStringsColCount;
+
+    Locale                  fZSFLocale;         // Locale used for getting ZoneStringFormat
+
+    /**
+     * Localized date-time pattern characters. For example: use 'u' as 'y'.
+     */
+    UnicodeString   fLocalPatternChars;
+
+    /**
+     * Capitalization transforms. For each usage type, the first array element indicates
+     * whether to titlecase for uiListOrMenu context, the second indicates whether to
+     * titlecase for stand-alone context.
+     */
+     UBool fCapitalization[kCapContextUsageTypeCount][2];
+
+private:
+    /** valid/actual locale information 
+     *  these are always ICU locales, so the length should not be a problem
+     */
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+
+    DateFormatSymbols(); // default constructor not implemented
+
+    /**
+     * Called by the constructors to actually load data from the resources
+     *
+     * @param locale               The locale to get symbols for.
+     * @param type                 Calendar Type (as from Calendar::getType())
+     * @param status               Input/output parameter, set to success or
+     *                             failure code upon return.
+     * @param useLastResortData    determine if use last resort data
+     */
+    void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
+
+    /**
+     * Copy or alias an array in another object, as appropriate.
+     *
+     * @param dstArray    the copy destination array.
+     * @param dstCount    fill in with the lenth of 'dstArray'.
+     * @param srcArray    the source array to be copied.
+     * @param srcCount    the length of items to be copied from the 'srcArray'.
+     */
+    static void assignArray(UnicodeString*& dstArray,
+                            int32_t& dstCount,
+                            const UnicodeString* srcArray,
+                            int32_t srcCount);
+
+    /**
+     * Return true if the given arrays' contents are equal, or if the arrays are
+     * identical (pointers are equal).
+     *
+     * @param array1   one array to be compared with.
+     * @param array2   another array to be compared with.
+     * @param count    the length of items to be copied.
+     * @return         true if the given arrays' contents are equal, or if the arrays are
+     *                 identical (pointers are equal).
+     */
+    static UBool arrayCompare(const UnicodeString* array1,
+                             const UnicodeString* array2,
+                             int32_t count);
+
+    /**
+     * Create a copy, in fZoneStrings, of the given zone strings array. The
+     * member variables fZoneStringsRowCount and fZoneStringsColCount should be
+     * set already by the caller.
+     */
+    void createZoneStrings(const UnicodeString *const * otherStrings);
+
+    /**
+     * Delete all the storage owned by this object.
+     */
+    void dispose(void);
+
+    /**
+     * Copy all of the other's data to this.
+     * @param other the object to be copied.
+     */
+    void copyData(const DateFormatSymbols& other);
+
+    /**
+     * Create zone strings array by locale if not yet available
+     */
+    void initZoneStringsArray(void);
+
+    /**
+     * Delete just the zone strings.
+     */
+    void disposeZoneStrings(void);
+
+    /**
+     * Returns the date format field index of the pattern character c,
+     * or UDAT_FIELD_COUNT if c is not a pattern character.
+     */
+    static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
+
+    /**
+     * Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
+     */
+    static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
+
+    /**
+     * Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
+     */
+    static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
+public:
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Gets a DateFormatSymbols by locale.
+     * Unlike the constructors which always use gregorian calendar, this
+     * method uses the calendar in the locale. If the locale contains no
+     * explicit calendar, this method uses the default calendar for that
+     * locale.
+     * @param locale the locale.
+     * @param status error returned here.
+     * @return the new DateFormatSymbols which the caller owns.
+     * @internal For ICU use only.
+     */
+    static DateFormatSymbols * U_EXPORT2 createForLocale(
+            const Locale &locale, UErrorCode &status);
+#endif  /* U_HIDE_INTERNAL_API */
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DTFMTSYM
+//eof

+ 158 - 0
sqlite/unicode/dtintrv.h

@@ -0,0 +1,158 @@
+/*
+*******************************************************************************
+* Copyright (C) 2008-2009, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*
+* File DTINTRV.H 
+*
+*******************************************************************************
+*/
+
+#ifndef __DTINTRV_H__
+#define __DTINTRV_H__
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+
+/**
+ * \file
+ * \brief C++ API: Date Interval data type
+ */
+
+
+U_NAMESPACE_BEGIN
+
+
+/**
+ * This class represents a date interval.
+ * It is a pair of UDate representing from UDate 1 to UDate 2.
+ * @stable ICU 4.0
+**/
+class U_COMMON_API DateInterval : public UObject {
+public:
+
+    /** 
+     * Construct a DateInterval given a from date and a to date.
+     * @param fromDate  The from date in date interval.
+     * @param toDate    The to date in date interval.
+     * @stable ICU 4.0
+     */
+    DateInterval(UDate fromDate, UDate toDate);
+
+    /**
+     * destructor
+     * @stable ICU 4.0
+     */
+    virtual ~DateInterval();
+ 
+    /** 
+     * Get the from date.
+     * @return  the from date in dateInterval.
+     * @stable ICU 4.0
+     */
+    UDate getFromDate() const;
+
+    /** 
+     * Get the to date.
+     * @return  the to date in dateInterval.
+     * @stable ICU 4.0
+     */
+    UDate getToDate() const;
+
+
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    
+    /**
+     * Copy constructor.
+     * @stable ICU 4.0
+     */
+    DateInterval(const DateInterval& other);
+
+    /**
+     * Default assignment operator
+     * @stable ICU 4.0
+     */
+    DateInterval& operator=(const DateInterval&);
+
+    /**
+     * Equality operator.
+     * @return TRUE if the two DateIntervals are the same
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const DateInterval& other) const;
+
+    /**
+     * Non-equality operator
+     * @return TRUE if the two DateIntervals are not the same
+     * @stable ICU 4.0
+     */
+    UBool operator!=(const DateInterval& other) const;
+
+
+    /**
+     * clone this object. 
+     * The caller owns the result and should delete it when done.
+     * @return a cloned DateInterval
+     * @stable ICU 4.0
+     */
+     virtual DateInterval* clone() const;
+
+private:
+    /** 
+     * Default constructor, not implemented.
+     */
+    DateInterval();
+
+    UDate fromDate;
+    UDate toDate;
+
+} ;// end class DateInterval
+
+
+inline UDate 
+DateInterval::getFromDate() const { 
+    return fromDate; 
+}
+
+
+inline UDate 
+DateInterval::getToDate() const { 
+    return toDate; 
+}
+
+
+inline UBool 
+DateInterval::operator!=(const DateInterval& other) const { 
+    return ( !operator==(other) );
+}
+
+
+U_NAMESPACE_END
+
+#endif

+ 985 - 0
sqlite/unicode/dtitvfmt.h

@@ -0,0 +1,985 @@
+/********************************************************************************
+* Copyright (C) 2008-2013, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*
+* File DTITVFMT.H
+*
+*******************************************************************************
+*/
+
+#ifndef __DTITVFMT_H__
+#define __DTITVFMT_H__
+
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Format and parse date interval in a language-independent manner.
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/ucal.h"
+#include "unicode/smpdtfmt.h"
+#include "unicode/dtintrv.h"
+#include "unicode/dtitvinf.h"
+#include "unicode/dtptngen.h"
+
+U_NAMESPACE_BEGIN
+
+
+
+/**
+ * DateIntervalFormat is a class for formatting and parsing date
+ * intervals in a language-independent manner.
+ * Only formatting is supported, parsing is not supported.
+ *
+ * <P>
+ * Date interval means from one date to another date,
+ * for example, from "Jan 11, 2008" to "Jan 18, 2008".
+ * We introduced class DateInterval to represent it.
+ * DateInterval is a pair of UDate, which is
+ * the standard milliseconds since 24:00 GMT, Jan 1, 1970.
+ *
+ * <P>
+ * DateIntervalFormat formats a DateInterval into
+ * text as compactly as possible.
+ * For example, the date interval format from "Jan 11, 2008" to "Jan 18,. 2008"
+ * is "Jan 11-18, 2008" for English.
+ * And it parses text into DateInterval,
+ * although initially, parsing is not supported.
+ *
+ * <P>
+ * There is no structural information in date time patterns.
+ * For any punctuations and string literals inside a date time pattern,
+ * we do not know whether it is just a separator, or a prefix, or a suffix.
+ * Without such information, so, it is difficult to generate a sub-pattern
+ * (or super-pattern) by algorithm.
+ * So, formatting a DateInterval is pattern-driven. It is very
+ * similar to formatting in SimpleDateFormat.
+ * We introduce class DateIntervalInfo to save date interval
+ * patterns, similar to date time pattern in SimpleDateFormat.
+ *
+ * <P>
+ * Logically, the interval patterns are mappings
+ * from (skeleton, the_largest_different_calendar_field)
+ * to (date_interval_pattern).
+ *
+ * <P>
+ * A skeleton
+ * <ol>
+ * <li>
+ * only keeps the field pattern letter and ignores all other parts
+ * in a pattern, such as space, punctuations, and string literals.
+ * </li>
+ * <li>
+ * hides the order of fields.
+ * </li>
+ * <li>
+ * might hide a field's pattern letter length.
+ * </li>
+ * </ol>
+ *
+ * For those non-digit calendar fields, the pattern letter length is
+ * important, such as MMM, MMMM, and MMMMM; EEE and EEEE,
+ * and the field's pattern letter length is honored.
+ *
+ * For the digit calendar fields,  such as M or MM, d or dd, yy or yyyy,
+ * the field pattern length is ignored and the best match, which is defined
+ * in date time patterns, will be returned without honor the field pattern
+ * letter length in skeleton.
+ *
+ * <P>
+ * The calendar fields we support for interval formatting are:
+ * year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute.
+ * Those calendar fields can be defined in the following order:
+ * year >  month > date > hour (in day) >  minute
+ *
+ * The largest different calendar fields between 2 calendars is the
+ * first different calendar field in above order.
+ *
+ * For example: the largest different calendar fields between "Jan 10, 2007"
+ * and "Feb 20, 2008" is year.
+ *
+ * <P>
+ * For other calendar fields, the compact interval formatting is not
+ * supported. And the interval format will be fall back to fall-back
+ * patterns, which is mostly "{date0} - {date1}".
+ *
+ * <P>
+ * There is a set of pre-defined static skeleton strings.
+ * There are pre-defined interval patterns for those pre-defined skeletons
+ * in locales' resource files.
+ * For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is  &quot;yMMMd&quot;,
+ * in  en_US, if the largest different calendar field between date1 and date2
+ * is &quot;year&quot;, the date interval pattern  is &quot;MMM d, yyyy - MMM d, yyyy&quot;,
+ * such as &quot;Jan 10, 2007 - Jan 10, 2008&quot;.
+ * If the largest different calendar field between date1 and date2 is &quot;month&quot;,
+ * the date interval pattern is &quot;MMM d - MMM d, yyyy&quot;,
+ * such as &quot;Jan 10 - Feb 10, 2007&quot;.
+ * If the largest different calendar field between date1 and date2 is &quot;day&quot;,
+ * the date interval pattern is &quot;MMM d-d, yyyy&quot;, such as &quot;Jan 10-20, 2007&quot;.
+ *
+ * For date skeleton, the interval patterns when year, or month, or date is
+ * different are defined in resource files.
+ * For time skeleton, the interval patterns when am/pm, or hour, or minute is
+ * different are defined in resource files.
+ *
+ * <P>
+ * If a skeleton is not found in a locale's DateIntervalInfo, which means
+ * the interval patterns for the skeleton is not defined in resource file,
+ * the interval pattern will falls back to the interval "fallback" pattern
+ * defined in resource file.
+ * If the interval "fallback" pattern is not defined, the default fall-back
+ * is "{date0} - {data1}".
+ *
+ * <P>
+ * For the combination of date and time,
+ * The rule to generate interval patterns are:
+ * <ol>
+ * <li>
+ *    when the year, month, or day differs, falls back to fall-back
+ *    interval pattern, which mostly is the concatenate the two original
+ *    expressions with a separator between,
+ *    For example, interval pattern from "Jan 10, 2007 10:10 am"
+ *    to "Jan 11, 2007 10:10am" is
+ *    "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
+ * </li>
+ * <li>
+ *    otherwise, present the date followed by the range expression
+ *    for the time.
+ *    For example, interval pattern from "Jan 10, 2007 10:10 am"
+ *    to "Jan 10, 2007 11:10am" is "Jan 10, 2007 10:10 am - 11:10am"
+ * </li>
+ * </ol>
+ *
+ *
+ * <P>
+ * If two dates are the same, the interval pattern is the single date pattern.
+ * For example, interval pattern from "Jan 10, 2007" to "Jan 10, 2007" is
+ * "Jan 10, 2007".
+ *
+ * Or if the presenting fields between 2 dates have the exact same values,
+ * the interval pattern is the  single date pattern.
+ * For example, if user only requests year and month,
+ * the interval pattern from "Jan 10, 2007" to "Jan 20, 2007" is "Jan 2007".
+ *
+ * <P>
+ * DateIntervalFormat needs the following information for correct
+ * formatting: time zone, calendar type, pattern, date format symbols,
+ * and date interval patterns.
+ * It can be instantiated in 2 ways:
+ * <ol>
+ * <li>
+ *    create an instance using default or given locale plus given skeleton.
+ *    Users are encouraged to created date interval formatter this way and
+ *    to use the pre-defined skeleton macros, such as
+ *    UDAT_YEAR_NUM_MONTH, which consists the calendar fields and
+ *    the format style.
+ * </li>
+ * <li>
+ *    create an instance using default or given locale plus given skeleton
+ *    plus a given DateIntervalInfo.
+ *    This factory method is for powerful users who want to provide their own
+ *    interval patterns.
+ *    Locale provides the timezone, calendar, and format symbols information.
+ *    Local plus skeleton provides full pattern information.
+ *    DateIntervalInfo provides the date interval patterns.
+ * </li>
+ * </ol>
+ *
+ * <P>
+ * For the calendar field pattern letter, such as G, y, M, d, a, h, H, m, s etc.
+ * DateIntervalFormat uses the same syntax as that of
+ * DateTime format.
+ *
+ * <P>
+ * Code Sample: general usage
+ * <pre>
+ * \code
+ *   // the date interval object which the DateIntervalFormat formats on
+ *   // and parses into
+ *   DateInterval*  dtInterval = new DateInterval(1000*3600*24, 1000*3600*24*2);
+ *   UErrorCode status = U_ZERO_ERROR;
+ *   DateIntervalFormat* dtIntervalFmt = DateIntervalFormat::createInstance(
+ *                           UDAT_YEAR_MONTH_DAY,
+ *                           Locale("en", "GB", ""), status);
+ *   UnicodeUnicodeString dateIntervalString;
+ *   FieldPosition pos = 0;
+ *   // formatting
+ *   dtIntervalFmt->format(dtInterval, dateIntervalUnicodeString, pos, status);
+ *   delete dtIntervalFmt;
+ * \endcode
+ * </pre>
+ */
+
+class U_I18N_API DateIntervalFormat : public Format {
+public:
+
+    /**
+     * Construct a DateIntervalFormat from skeleton and  the default locale.
+     *
+     * This is a convenient override of
+     * createInstance(const UnicodeString& skeleton, const Locale& locale,
+     *                UErrorCode&)
+     * with the value of locale as default locale.
+     *
+     * @param skeleton  the skeleton on which interval format based.
+     * @param status    output param set to success/failure code on exit
+     * @return          a date time interval formatter which the caller owns.
+     * @stable ICU 4.0
+     */
+    static DateIntervalFormat* U_EXPORT2 createInstance(
+                                               const UnicodeString& skeleton,
+                                               UErrorCode& status);
+
+    /**
+     * Construct a DateIntervalFormat from skeleton and a given locale.
+     * <P>
+     * In this factory method,
+     * the date interval pattern information is load from resource files.
+     * Users are encouraged to created date interval formatter this way and
+     * to use the pre-defined skeleton macros.
+     *
+     * <P>
+     * There are pre-defined skeletons (defined in udate.h) having predefined
+     * interval patterns in resource files.
+     * Users are encouraged to use those macros.
+     * For example:
+     * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
+     *
+     * The given Locale provides the interval patterns.
+     * For example, for en_GB, if skeleton is UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY,
+     * which is "yMMMEEEd",
+     * the interval patterns defined in resource file to above skeleton are:
+     * "EEE, d MMM, yyyy - EEE, d MMM, yyyy" for year differs,
+     * "EEE, d MMM - EEE, d MMM, yyyy" for month differs,
+     * "EEE, d - EEE, d MMM, yyyy" for day differs,
+     * @param skeleton  the skeleton on which the interval format is based.
+     * @param locale    the given locale
+     * @param status    output param set to success/failure code on exit
+     * @return          a date time interval formatter which the caller owns.
+     * @stable ICU 4.0
+	 * <p>
+	 * <h4>Sample code</h4>
+	 * \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined1
+	 * \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined
+	 * <p>
+     */
+
+    static DateIntervalFormat* U_EXPORT2 createInstance(
+                                               const UnicodeString& skeleton,
+                                               const Locale& locale,
+                                               UErrorCode& status);
+
+    /**
+     * Construct a DateIntervalFormat from skeleton
+     *  DateIntervalInfo, and default locale.
+     *
+     * This is a convenient override of
+     * createInstance(const UnicodeString& skeleton, const Locale& locale,
+     *                const DateIntervalInfo& dtitvinf, UErrorCode&)
+     * with the locale value as default locale.
+     *
+     * @param skeleton  the skeleton on which interval format based.
+     * @param dtitvinf  the DateIntervalInfo object.
+     * @param status    output param set to success/failure code on exit
+     * @return          a date time interval formatter which the caller owns.
+     * @stable ICU 4.0
+     */
+    static DateIntervalFormat* U_EXPORT2 createInstance(
+                                              const UnicodeString& skeleton,
+                                              const DateIntervalInfo& dtitvinf,
+                                              UErrorCode& status);
+
+    /**
+     * Construct a DateIntervalFormat from skeleton
+     * a DateIntervalInfo, and the given locale.
+     *
+     * <P>
+     * In this factory method, user provides its own date interval pattern
+     * information, instead of using those pre-defined data in resource file.
+     * This factory method is for powerful users who want to provide their own
+     * interval patterns.
+     * <P>
+     * There are pre-defined skeletons (defined in udate.h) having predefined
+     * interval patterns in resource files.
+     * Users are encouraged to use those macros.
+     * For example:
+     * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
+     *
+     * The DateIntervalInfo provides the interval patterns.
+     * and the DateIntervalInfo ownership remains to the caller.
+     *
+     * User are encouraged to set default interval pattern in DateIntervalInfo
+     * as well, if they want to set other interval patterns ( instead of
+     * reading the interval patterns from resource files).
+     * When the corresponding interval pattern for a largest calendar different
+     * field is not found ( if user not set it ), interval format fallback to
+     * the default interval pattern.
+     * If user does not provide default interval pattern, it fallback to
+     * "{date0} - {date1}"
+     *
+     * @param skeleton  the skeleton on which interval format based.
+     * @param locale    the given locale
+     * @param dtitvinf  the DateIntervalInfo object.
+     * @param status    output param set to success/failure code on exit
+     * @return          a date time interval formatter which the caller owns.
+     * @stable ICU 4.0
+	 * <p>
+	 * <h4>Sample code</h4>
+	 * \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined1
+	 * \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtCustomized
+	 * <p>
+     */
+    static DateIntervalFormat* U_EXPORT2 createInstance(
+                                              const UnicodeString& skeleton,
+                                              const Locale& locale,
+                                              const DateIntervalInfo& dtitvinf,
+                                              UErrorCode& status);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~DateIntervalFormat();
+
+    /**
+     * Clone this Format object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return    A copy of the object.
+     * @stable ICU 4.0
+     */
+    virtual Format* clone(void) const;
+
+    /**
+     * Return true if the given Format objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param other    the object to be compared with.
+     * @return         true if the given Format objects are semantically equal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Return true if the given Format objects are not semantically equal.
+     * Objects of different subclasses are considered unequal.
+     * @param other the object to be compared with.
+     * @return      true if the given Format objects are not semantically equal.
+     * @stable ICU 4.0
+     */
+    UBool operator!=(const Format& other) const;
+
+
+    using Format::format;
+
+    /**
+     * Format an object to produce a string. This method handles Formattable
+     * objects with a DateInterval type.
+     * If a the Formattable object type is not a DateInterval,
+     * then it returns a failing UErrorCode.
+     *
+     * @param obj               The object to format.
+     *                          Must be a DateInterval.
+     * @param appendTo          Output parameter to receive result.
+     *                          Result is appended to existing contents.
+     * @param fieldPosition     On input: an alignment field, if desired.
+     *                          On output: the offsets of the alignment field.
+     * @param status            Output param filled with success/failure status.
+     * @return                  Reference to 'appendTo' parameter.
+     * @stable ICU 4.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& fieldPosition,
+                                  UErrorCode& status) const ;
+
+
+
+    /**
+     * Format a DateInterval to produce a string.
+     *
+     * @param dtInterval        DateInterval to be formatted.
+     * @param appendTo          Output parameter to receive result.
+     *                          Result is appended to existing contents.
+     * @param fieldPosition     On input: an alignment field, if desired.
+     *                          On output: the offsets of the alignment field.
+     * @param status            Output param filled with success/failure status.
+     * @return                  Reference to 'appendTo' parameter.
+     * @stable ICU 4.0
+     */
+    UnicodeString& format(const DateInterval* dtInterval,
+                          UnicodeString& appendTo,
+                          FieldPosition& fieldPosition,
+                          UErrorCode& status) const ;
+
+
+    /**
+     * Format 2 Calendars to produce a string.
+     *
+     * Note: "fromCalendar" and "toCalendar" are not const,
+     * since calendar is not const in  SimpleDateFormat::format(Calendar&),
+     *
+     * @param fromCalendar      calendar set to the from date in date interval
+     *                          to be formatted into date interval string
+     * @param toCalendar        calendar set to the to date in date interval
+     *                          to be formatted into date interval string
+     * @param appendTo          Output parameter to receive result.
+     *                          Result is appended to existing contents.
+     * @param fieldPosition     On input: an alignment field, if desired.
+     *                          On output: the offsets of the alignment field.
+     * @param status            Output param filled with success/failure status.
+     *                          Caller needs to make sure it is SUCCESS
+     *                          at the function entrance
+     * @return                  Reference to 'appendTo' parameter.
+     * @stable ICU 4.0
+     */
+    UnicodeString& format(Calendar& fromCalendar,
+                          Calendar& toCalendar,
+                          UnicodeString& appendTo,
+                          FieldPosition& fieldPosition,
+                          UErrorCode& status) const ;
+
+    /**
+     * Date interval parsing is not supported. Please do not use.
+     * <P>
+     * This method should handle parsing of
+     * date time interval strings into Formattable objects with
+     * DateInterval type, which is a pair of UDate.
+     * <P>
+     * Before calling, set parse_pos.index to the offset you want to start
+     * parsing at in the source. After calling, parse_pos.index is the end of
+     * the text you parsed. If error occurs, index is unchanged.
+     * <P>
+     * When parsing, leading whitespace is discarded (with a successful parse),
+     * while trailing whitespace is left as is.
+     * <P>
+     * See Format::parseObject() for more.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param parse_pos The position to start parsing at. Since no parsing
+     *                  is supported, upon return this param is unchanged.
+     * @return          A newly created Formattable* object, or NULL
+     *                  on failure.  The caller owns this and should
+     *                  delete it when done.
+     * @internal ICU 4.0
+     */
+    virtual void parseObject(const UnicodeString& source,
+                             Formattable& result,
+                             ParsePosition& parse_pos) const;
+
+
+    /**
+     * Gets the date time interval patterns.
+     * @return the date time interval patterns associated with
+     * this date interval formatter.
+     * @stable ICU 4.0
+     */
+    const DateIntervalInfo* getDateIntervalInfo(void) const;
+
+
+    /**
+     * Set the date time interval patterns.
+     * @param newIntervalPatterns   the given interval patterns to copy.
+     * @param status          output param set to success/failure code on exit
+     * @stable ICU 4.0
+     */
+    void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,
+                             UErrorCode& status);
+
+
+    /**
+     * Gets the date formatter
+     * @return the date formatter associated with this date interval formatter.
+     * @stable ICU 4.0
+     */
+    const DateFormat* getDateFormat(void) const;
+
+    /**
+     * Returns a reference to the TimeZone used by this DateIntervalFormat's calendar.
+     * @return the time zone associated with the calendar of DateIntervalFormat.
+     * @stable ICU 4.8
+     */
+    virtual const TimeZone& getTimeZone(void) const;
+
+    /**
+     * Sets the time zone for the calendar used by this DateIntervalFormat object. The
+     * caller no longer owns the TimeZone object and should not delete it after this call.
+     * @param zoneToAdopt the TimeZone to be adopted.
+     * @stable ICU 4.8
+     */
+    virtual void adoptTimeZone(TimeZone* zoneToAdopt);
+
+    /**
+     * Sets the time zone for the calendar used by this DateIntervalFormat object.
+     * @param zone the new time zone.
+     * @stable ICU 4.8
+     */
+    virtual void setTimeZone(const TimeZone& zone);
+
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+protected:
+
+    /**
+     * Copy constructor.
+     * @stable ICU 4.0
+     */
+    DateIntervalFormat(const DateIntervalFormat&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 4.0
+     */
+    DateIntervalFormat& operator=(const DateIntervalFormat&);
+
+private:
+
+    /*
+     * This is for ICU internal use only. Please do not use.
+     * Save the interval pattern information.
+     * Interval pattern consists of 2 single date patterns and the separator.
+     * For example, interval pattern "MMM d - MMM d, yyyy" consists
+     * a single date pattern "MMM d", another single date pattern "MMM d, yyyy",
+     * and a separator "-".
+     * The pattern is divided into 2 parts. For above example,
+     * the first part is "MMM d - ", and the second part is "MMM d, yyyy".
+     * Also, the first date appears in an interval pattern could be
+     * the earlier date or the later date.
+     * And such information is saved in the interval pattern as well.
+     */
+    struct PatternInfo {
+        UnicodeString firstPart;
+        UnicodeString secondPart;
+        /**
+         * Whether the first date in interval pattern is later date or not.
+         * Fallback format set the default ordering.
+         * And for a particular interval pattern, the order can be
+         * overriden by prefixing the interval pattern with "latestFirst:" or
+         * "earliestFirst:"
+         * For example, given 2 date, Jan 10, 2007 to Feb 10, 2007.
+         * if the fallback format is "{0} - {1}",
+         * and the pattern is "d MMM - d MMM yyyy", the interval format is
+         * "10 Jan - 10 Feb, 2007".
+         * If the pattern is "latestFirst:d MMM - d MMM yyyy",
+         * the interval format is "10 Feb - 10 Jan, 2007"
+         */
+        UBool         laterDateFirst;
+    };
+
+
+    /**
+     * default constructor
+     * @internal ICU 4.0
+     */
+    DateIntervalFormat();
+
+    /**
+     * Construct a DateIntervalFormat from DateFormat,
+     * a DateIntervalInfo, and skeleton.
+     * DateFormat provides the timezone, calendar,
+     * full pattern, and date format symbols information.
+     * It should be a SimpleDateFormat object which
+     * has a pattern in it.
+     * the DateIntervalInfo provides the interval patterns.
+     *
+     * Note: the DateIntervalFormat takes ownership of both
+     * DateFormat and DateIntervalInfo objects.
+     * Caller should not delete them.
+     *
+     * @param locale    the locale of this date interval formatter.
+     * @param dtItvInfo the DateIntervalInfo object to be adopted.
+     * @param skeleton  the skeleton of the date formatter
+     * @param status    output param set to success/failure code on exit
+     */
+    DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,
+                       const UnicodeString* skeleton, UErrorCode& status);
+
+
+    /**
+     * Construct a DateIntervalFormat from DateFormat
+     * and a DateIntervalInfo.
+     *
+     * It is a wrapper of the constructor.
+     *
+     * @param locale    the locale of this date interval formatter.
+     * @param dtitvinf  the DateIntervalInfo object to be adopted.
+     * @param skeleton  the skeleton of this formatter.
+     * @param status    Output param set to success/failure code.
+     * @return          a date time interval formatter which the caller owns.
+     */
+    static DateIntervalFormat* U_EXPORT2 create(const Locale& locale,
+                                                DateIntervalInfo* dtitvinf,
+                                                const UnicodeString* skeleton,
+                                                UErrorCode& status);
+
+    /**
+     * Create a simple date/time formatter from skeleton, given locale,
+     * and date time pattern generator.
+     *
+     * @param skeleton  the skeleton on which date format based.
+     * @param locale    the given locale.
+     * @param dtpng     the date time pattern generator.
+     * @param status    Output param to be set to success/failure code.
+     *                  If it is failure, the returned date formatter will
+     *                  be NULL.
+     * @return          a simple date formatter which the caller owns.
+     */
+    static SimpleDateFormat* U_EXPORT2 createSDFPatternInstance(
+                                        const UnicodeString& skeleton,
+                                        const Locale& locale,
+                                        DateTimePatternGenerator* dtpng,
+                                        UErrorCode& status);
+
+
+    /**
+     *  Below are for generating interval patterns local to the formatter
+     */
+
+
+    /**
+     * Format 2 Calendars using fall-back interval pattern
+     *
+     * The full pattern used in this fall-back format is the
+     * full pattern of the date formatter.
+     *
+     * @param fromCalendar      calendar set to the from date in date interval
+     *                          to be formatted into date interval string
+     * @param toCalendar        calendar set to the to date in date interval
+     *                          to be formatted into date interval string
+     * @param appendTo          Output parameter to receive result.
+     *                          Result is appended to existing contents.
+     * @param pos               On input: an alignment field, if desired.
+     *                          On output: the offsets of the alignment field.
+     * @param status            output param set to success/failure code on exit
+     * @return                  Reference to 'appendTo' parameter.
+     */
+    UnicodeString& fallbackFormat(Calendar& fromCalendar,
+                                  Calendar& toCalendar,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+
+
+    /**
+     * Initialize interval patterns locale to this formatter
+     *
+     * This code is a bit complicated since
+     * 1. the interval patterns saved in resource bundle files are interval
+     *    patterns based on date or time only.
+     *    It does not have interval patterns based on both date and time.
+     *    Interval patterns on both date and time are algorithm generated.
+     *
+     *    For example, it has interval patterns on skeleton "dMy" and "hm",
+     *    but it does not have interval patterns on skeleton "dMyhm".
+     *
+     *    The rule to generate interval patterns for both date and time skeleton are
+     *    1) when the year, month, or day differs, concatenate the two original
+     *    expressions with a separator between,
+     *    For example, interval pattern from "Jan 10, 2007 10:10 am"
+     *    to "Jan 11, 2007 10:10am" is
+     *    "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
+     *
+     *    2) otherwise, present the date followed by the range expression
+     *    for the time.
+     *    For example, interval pattern from "Jan 10, 2007 10:10 am"
+     *    to "Jan 10, 2007 11:10am" is
+     *    "Jan 10, 2007 10:10 am - 11:10am"
+     *
+     * 2. even a pattern does not request a certain calendar field,
+     *    the interval pattern needs to include such field if such fields are
+     *    different between 2 dates.
+     *    For example, a pattern/skeleton is "hm", but the interval pattern
+     *    includes year, month, and date when year, month, and date differs.
+     *
+     *
+     * @param status    output param set to success/failure code on exit
+     */
+    void initializePattern(UErrorCode& status);
+
+
+
+    /**
+     * Set fall back interval pattern given a calendar field,
+     * a skeleton, and a date time pattern generator.
+     * @param field      the largest different calendar field
+     * @param skeleton   a skeleton
+     * @param status     output param set to success/failure code on exit
+     */
+    void setFallbackPattern(UCalendarDateFields field,
+                            const UnicodeString& skeleton,
+                            UErrorCode& status);
+
+
+
+    /**
+     * get separated date and time skeleton from a combined skeleton.
+     *
+     * The difference between date skeleton and normalizedDateSkeleton are:
+     * 1. both 'y' and 'd' are appeared only once in normalizeDateSkeleton
+     * 2. 'E' and 'EE' are normalized into 'EEE'
+     * 3. 'MM' is normalized into 'M'
+     *
+     ** the difference between time skeleton and normalizedTimeSkeleton are:
+     * 1. both 'H' and 'h' are normalized as 'h' in normalized time skeleton,
+     * 2. 'a' is omitted in normalized time skeleton.
+     * 3. there is only one appearance for 'h', 'm','v', 'z' in normalized time
+     *    skeleton
+     *
+     *
+     *  @param skeleton               given combined skeleton.
+     *  @param date                   Output parameter for date only skeleton.
+     *  @param normalizedDate         Output parameter for normalized date only
+     *
+     *  @param time                   Output parameter for time only skeleton.
+     *  @param normalizedTime         Output parameter for normalized time only
+     *                                skeleton.
+     *
+     */
+    static void  U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
+                                    UnicodeString& date,
+                                    UnicodeString& normalizedDate,
+                                    UnicodeString& time,
+                                    UnicodeString& normalizedTime);
+
+
+
+    /**
+     * Generate date or time interval pattern from resource,
+     * and set them into the interval pattern locale to this formatter.
+     *
+     * It needs to handle the following:
+     * 1. need to adjust field width.
+     *    For example, the interval patterns saved in DateIntervalInfo
+     *    includes "dMMMy", but not "dMMMMy".
+     *    Need to get interval patterns for dMMMMy from dMMMy.
+     *    Another example, the interval patterns saved in DateIntervalInfo
+     *    includes "hmv", but not "hmz".
+     *    Need to get interval patterns for "hmz' from 'hmv'
+     *
+     * 2. there might be no pattern for 'y' differ for skeleton "Md",
+     *    in order to get interval patterns for 'y' differ,
+     *    need to look for it from skeleton 'yMd'
+     *
+     * @param dateSkeleton   normalized date skeleton
+     * @param timeSkeleton   normalized time skeleton
+     * @return               whether the resource is found for the skeleton.
+     *                       TRUE if interval pattern found for the skeleton,
+     *                       FALSE otherwise.
+     */
+    UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
+                                 const UnicodeString& timeSkeleton);
+
+
+
+
+    /**
+     * Generate interval pattern from existing resource
+     *
+     * It not only save the interval patterns,
+     * but also return the extended skeleton and its best match skeleton.
+     *
+     * @param field           largest different calendar field
+     * @param skeleton        skeleton
+     * @param bestSkeleton    the best match skeleton which has interval pattern
+     *                        defined in resource
+     * @param differenceInfo  the difference between skeleton and best skeleton
+     *         0 means the best matched skeleton is the same as input skeleton
+     *         1 means the fields are the same, but field width are different
+     *         2 means the only difference between fields are v/z,
+     *        -1 means there are other fields difference
+     *
+     * @param extendedSkeleton      extended skeleton
+     * @param extendedBestSkeleton  extended best match skeleton
+     * @return                      whether the interval pattern is found
+     *                              through extending skeleton or not.
+     *                              TRUE if interval pattern is found by
+     *                              extending skeleton, FALSE otherwise.
+     */
+    UBool setIntervalPattern(UCalendarDateFields field,
+                             const UnicodeString* skeleton,
+                             const UnicodeString* bestSkeleton,
+                             int8_t differenceInfo,
+                             UnicodeString* extendedSkeleton = NULL,
+                             UnicodeString* extendedBestSkeleton = NULL);
+
+    /**
+     * Adjust field width in best match interval pattern to match
+     * the field width in input skeleton.
+     *
+     * TODO (xji) make a general solution
+     * The adjusting rule can be:
+     * 1. always adjust
+     * 2. never adjust
+     * 3. default adjust, which means adjust according to the following rules
+     * 3.1 always adjust string, such as MMM and MMMM
+     * 3.2 never adjust between string and numeric, such as MM and MMM
+     * 3.3 always adjust year
+     * 3.4 do not adjust 'd', 'h', or 'm' if h presents
+     * 3.5 do not adjust 'M' if it is numeric(?)
+     *
+     * Since date interval format is well-formed format,
+     * date and time skeletons are normalized previously,
+     * till this stage, the adjust here is only "adjust strings, such as MMM
+     * and MMMM, EEE and EEEE.
+     *
+     * @param inputSkeleton            the input skeleton
+     * @param bestMatchSkeleton        the best match skeleton
+     * @param bestMatchIntervalPattern the best match interval pattern
+     * @param differenceInfo           the difference between 2 skeletons
+     *                                 1 means only field width differs
+     *                                 2 means v/z exchange
+     * @param adjustedIntervalPattern  adjusted interval pattern
+     */
+    static void U_EXPORT2 adjustFieldWidth(
+                            const UnicodeString& inputSkeleton,
+                            const UnicodeString& bestMatchSkeleton,
+                            const UnicodeString& bestMatchIntervalPattern,
+                            int8_t differenceInfo,
+                            UnicodeString& adjustedIntervalPattern);
+
+    /**
+     * Concat a single date pattern with a time interval pattern,
+     * set it into the intervalPatterns, while field is time field.
+     * This is used to handle time interval patterns on skeleton with
+     * both time and date. Present the date followed by
+     * the range expression for the time.
+     * @param format         date and time format
+     * @param formatLen      format string length
+     * @param datePattern    date pattern
+     * @param field          time calendar field: AM_PM, HOUR, MINUTE
+     * @param status         output param set to success/failure code on exit
+     */
+    void concatSingleDate2TimeInterval(const UChar* format,
+                                       int32_t formatLen,
+                                       const UnicodeString& datePattern,
+                                       UCalendarDateFields field,
+                                       UErrorCode& status);
+
+    /**
+     * check whether a calendar field present in a skeleton.
+     * @param field      calendar field need to check
+     * @param skeleton   given skeleton on which to check the calendar field
+     * @return           true if field present in a skeleton.
+     */
+    static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
+                                                 const UnicodeString& skeleton);
+
+
+    /**
+     * Split interval patterns into 2 part.
+     * @param intervalPattern  interval pattern
+     * @return the index in interval pattern which split the pattern into 2 part
+     */
+    static int32_t  U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);
+
+
+    /**
+     * Break interval patterns as 2 part and save them into pattern info.
+     * @param field            calendar field
+     * @param intervalPattern  interval pattern
+     */
+    void setIntervalPattern(UCalendarDateFields field,
+                            const UnicodeString& intervalPattern);
+
+
+    /**
+     * Break interval patterns as 2 part and save them into pattern info.
+     * @param field            calendar field
+     * @param intervalPattern  interval pattern
+     * @param laterDateFirst   whether later date appear first in interval pattern
+     */
+    void setIntervalPattern(UCalendarDateFields field,
+                            const UnicodeString& intervalPattern,
+                            UBool laterDateFirst);
+
+
+    /**
+     * Set pattern information.
+     *
+     * @param field            calendar field
+     * @param firstPart        the first part in interval pattern
+     * @param secondPart       the second part in interval pattern
+     * @param laterDateFirst   whether the first date in intervalPattern
+     *                         is earlier date or later date
+     */
+    void setPatternInfo(UCalendarDateFields field,
+                        const UnicodeString* firstPart,
+                        const UnicodeString* secondPart,
+                        UBool laterDateFirst);
+
+
+    // from calendar field to pattern letter
+    static const UChar fgCalendarFieldToPatternLetter[];
+
+
+    /**
+     * The interval patterns for this locale.
+     */
+    DateIntervalInfo*     fInfo;
+
+    /**
+     * The DateFormat object used to format single pattern
+     */
+    SimpleDateFormat*     fDateFormat;
+
+    /**
+     * The 2 calendars with the from and to date.
+     * could re-use the calendar in fDateFormat,
+     * but keeping 2 calendars make it clear and clean.
+     */
+    Calendar* fFromCalendar;
+    Calendar* fToCalendar;
+
+    /**
+     * Date time pattern generator
+     */
+    DateTimePatternGenerator* fDtpng;
+
+    /**
+     * Following are interval information relavent (locale) to this formatter.
+     */
+    UnicodeString fSkeleton;
+    PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
+};
+
+inline UBool
+DateIntervalFormat::operator!=(const Format& other) const  {
+    return !operator==(other);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DTITVFMT_H__
+//eof

+ 514 - 0
sqlite/unicode/dtitvinf.h

@@ -0,0 +1,514 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 2008-2014, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ *
+ * File DTITVINF.H
+ *
+ *******************************************************************************
+ */
+
+#ifndef __DTITVINF_H__
+#define __DTITVINF_H__
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Date/Time interval patterns for formatting date/time interval
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/udat.h"
+#include "unicode/locid.h"
+#include "unicode/ucal.h"
+#include "unicode/dtptngen.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * DateIntervalInfo is a public class for encapsulating localizable
+ * date time interval patterns. It is used by DateIntervalFormat.
+ *
+ * <P>
+ * For most users, ordinary use of DateIntervalFormat does not need to create
+ * DateIntervalInfo object directly.
+ * DateIntervalFormat will take care of it when creating a date interval
+ * formatter when user pass in skeleton and locale.
+ *
+ * <P>
+ * For power users, who want to create their own date interval patterns,
+ * or want to re-set date interval patterns, they could do so by
+ * directly creating DateIntervalInfo and manupulating it.
+ *
+ * <P>
+ * Logically, the interval patterns are mappings
+ * from (skeleton, the_largest_different_calendar_field)
+ * to (date_interval_pattern).
+ *
+ * <P>
+ * A skeleton 
+ * <ol>
+ * <li>
+ * only keeps the field pattern letter and ignores all other parts 
+ * in a pattern, such as space, punctuations, and string literals.
+ * <li>
+ * hides the order of fields. 
+ * <li>
+ * might hide a field's pattern letter length.
+ *
+ * For those non-digit calendar fields, the pattern letter length is 
+ * important, such as MMM, MMMM, and MMMMM; EEE and EEEE, 
+ * and the field's pattern letter length is honored.
+ *    
+ * For the digit calendar fields,  such as M or MM, d or dd, yy or yyyy, 
+ * the field pattern length is ignored and the best match, which is defined 
+ * in date time patterns, will be returned without honor the field pattern
+ * letter length in skeleton.
+ * </ol>
+ *
+ * <P>
+ * The calendar fields we support for interval formatting are:
+ * year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute.
+ * Those calendar fields can be defined in the following order:
+ * year >  month > date > am-pm > hour >  minute 
+ *  
+ * The largest different calendar fields between 2 calendars is the
+ * first different calendar field in above order.
+ *
+ * For example: the largest different calendar fields between &quot;Jan 10, 2007&quot; 
+ * and &quot;Feb 20, 2008&quot; is year.
+ *   
+ * <P>
+ * There is a set of pre-defined static skeleton strings.
+ * There are pre-defined interval patterns for those pre-defined skeletons
+ * in locales' resource files.
+ * For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is  &quot;yMMMd&quot;,
+ * in  en_US, if the largest different calendar field between date1 and date2 
+ * is &quot;year&quot;, the date interval pattern  is &quot;MMM d, yyyy - MMM d, yyyy&quot;, 
+ * such as &quot;Jan 10, 2007 - Jan 10, 2008&quot;.
+ * If the largest different calendar field between date1 and date2 is &quot;month&quot;,
+ * the date interval pattern is &quot;MMM d - MMM d, yyyy&quot;,
+ * such as &quot;Jan 10 - Feb 10, 2007&quot;.
+ * If the largest different calendar field between date1 and date2 is &quot;day&quot;,
+ * the date interval pattern is &quot;MMM d-d, yyyy&quot;, such as &quot;Jan 10-20, 2007&quot;.
+ *
+ * For date skeleton, the interval patterns when year, or month, or date is 
+ * different are defined in resource files.
+ * For time skeleton, the interval patterns when am/pm, or hour, or minute is
+ * different are defined in resource files.
+ *
+ *
+ * <P>
+ * There are 2 dates in interval pattern. For most locales, the first date
+ * in an interval pattern is the earlier date. There might be a locale in which
+ * the first date in an interval pattern is the later date.
+ * We use fallback format for the default order for the locale.
+ * For example, if the fallback format is &quot;{0} - {1}&quot;, it means
+ * the first date in the interval pattern for this locale is earlier date.
+ * If the fallback format is &quot;{1} - {0}&quot;, it means the first date is the 
+ * later date.
+ * For a particular interval pattern, the default order can be overriden
+ * by prefixing &quot;latestFirst:&quot; or &quot;earliestFirst:&quot; to the interval pattern.
+ * For example, if the fallback format is &quot;{0}-{1}&quot;,
+ * but for skeleton &quot;yMMMd&quot;, the interval pattern when day is different is 
+ * &quot;latestFirst:d-d MMM yy&quot;, it means by default, the first date in interval
+ * pattern is the earlier date. But for skeleton &quot;yMMMd&quot;, when day is different,
+ * the first date in &quot;d-d MMM yy&quot; is the later date.
+ * 
+ * <P>
+ * The recommended way to create a DateIntervalFormat object is to pass in 
+ * the locale. 
+ * By using a Locale parameter, the DateIntervalFormat object is 
+ * initialized with the pre-defined interval patterns for a given or 
+ * default locale.
+ * <P>
+ * Users can also create DateIntervalFormat object 
+ * by supplying their own interval patterns.
+ * It provides flexibility for power users.
+ *
+ * <P>
+ * After a DateIntervalInfo object is created, clients may modify
+ * the interval patterns using setIntervalPattern function as so desired.
+ * Currently, users can only set interval patterns when the following 
+ * calendar fields are different: ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, 
+ * DAY_OF_WEEK, AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE.
+ * Interval patterns when other calendar fields are different is not supported.
+ * <P>
+ * DateIntervalInfo objects are cloneable. 
+ * When clients obtain a DateIntervalInfo object, 
+ * they can feel free to modify it as necessary.
+ * <P>
+ * DateIntervalInfo are not expected to be subclassed. 
+ * Data for a calendar is loaded out of resource bundles. 
+ * Through ICU 4.4, date interval patterns are only supported in the Gregorian
+ * calendar; non-Gregorian calendars are supported from ICU 4.4.1. 
+ * @stable ICU 4.0
+**/
+
+class U_I18N_API DateIntervalInfo U_FINAL : public UObject {
+public:
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Default constructor.
+     * It does not initialize any interval patterns except
+     * that it initialize default fall-back pattern as "{0} - {1}",
+     * which can be reset by setFallbackIntervalPattern().
+     * It should be followed by setFallbackIntervalPattern() and 
+     * setIntervalPattern(), 
+     * and is recommended to be used only for power users who
+     * wants to create their own interval patterns and use them to create
+     * date interval formatter.
+     * @param status   output param set to success/failure code on exit
+     * @internal ICU 4.0
+     */
+    DateIntervalInfo(UErrorCode& status);
+#endif  /* U_HIDE_INTERNAL_API */
+
+
+    /** 
+     * Construct DateIntervalInfo for the given locale,
+     * @param locale  the interval patterns are loaded from the appropriate calendar
+     *                data (specified calendar or default calendar) in this locale.
+     * @param status  output param set to success/failure code on exit
+     * @stable ICU 4.0
+     */
+    DateIntervalInfo(const Locale& locale, UErrorCode& status);
+
+
+    /**
+     * Copy constructor.
+     * @stable ICU 4.0
+     */
+    DateIntervalInfo(const DateIntervalInfo&);
+
+    /**
+     * Assignment operator
+     * @stable ICU 4.0
+     */
+    DateIntervalInfo& operator=(const DateIntervalInfo&);
+
+    /**
+     * Clone this object polymorphically.
+     * The caller owns the result and should delete it when done.
+     * @return   a copy of the object
+     * @stable ICU 4.0
+     */
+    virtual DateIntervalInfo* clone(void) const;
+
+    /**
+     * Destructor.
+     * It is virtual to be safe, but it is not designed to be subclassed.
+     * @stable ICU 4.0
+     */
+    virtual ~DateIntervalInfo();
+
+
+    /**
+     * Return true if another object is semantically equal to this one.
+     *
+     * @param other    the DateIntervalInfo object to be compared with.
+     * @return         true if other is semantically equal to this.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const DateIntervalInfo& other) const;
+
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the DateIntervalInfo object to be compared with.
+     * @return         true if other is semantically unequal to this.
+     * @stable ICU 4.0
+     */
+    UBool operator!=(const DateIntervalInfo& other) const;
+
+
+
+    /** 
+     * Provides a way for client to build interval patterns.
+     * User could construct DateIntervalInfo by providing a list of skeletons
+     * and their patterns.
+     * <P>
+     * For example:
+     * <pre>
+     * UErrorCode status = U_ZERO_ERROR;
+     * DateIntervalInfo dIntervalInfo = new DateIntervalInfo();
+     * dIntervalInfo->setFallbackIntervalPattern("{0} ~ {1}");
+     * dIntervalInfo->setIntervalPattern("yMd", UCAL_YEAR, "'from' yyyy-M-d 'to' yyyy-M-d", status); 
+     * dIntervalInfo->setIntervalPattern("yMMMd", UCAL_MONTH, "'from' yyyy MMM d 'to' MMM d", status);
+     * dIntervalInfo->setIntervalPattern("yMMMd", UCAL_DAY, "yyyy MMM d-d", status, status);
+     * </pre>
+     *
+     * Restriction: 
+     * Currently, users can only set interval patterns when the following 
+     * calendar fields are different: ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, 
+     * DAY_OF_WEEK, AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE.
+     * Interval patterns when other calendar fields are different are 
+     * not supported.
+     *
+     * @param skeleton         the skeleton on which interval pattern based
+     * @param lrgDiffCalUnit   the largest different calendar unit.
+     * @param intervalPattern  the interval pattern on the largest different
+     *                         calendar unit.
+     *                         For example, if lrgDiffCalUnit is 
+     *                         "year", the interval pattern for en_US when year
+     *                         is different could be "'from' yyyy 'to' yyyy".
+     * @param status           output param set to success/failure code on exit
+     * @stable ICU 4.0
+     */
+    void setIntervalPattern(const UnicodeString& skeleton, 
+                            UCalendarDateFields lrgDiffCalUnit, 
+                            const UnicodeString& intervalPattern,
+                            UErrorCode& status);
+
+    /**
+     * Get the interval pattern given skeleton and 
+     * the largest different calendar field.
+     * @param skeleton   the skeleton
+     * @param field      the largest different calendar field
+     * @param result     output param to receive the pattern
+     * @param status     output param set to success/failure code on exit
+     * @return a reference to 'result'
+     * @stable ICU 4.0 
+     */
+    UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
+                                      UCalendarDateFields field,
+                                      UnicodeString& result,
+                                      UErrorCode& status) const; 
+
+    /**
+     * Get the fallback interval pattern.
+     * @param  result   output param to receive the pattern
+     * @return a reference to 'result'
+     * @stable ICU 4.0 
+     */
+    UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
+
+
+    /**
+     * Re-set the fallback interval pattern.
+     *
+     * In construction, default fallback pattern is set as "{0} - {1}".
+     * And constructor taking locale as parameter will set the
+     * fallback pattern as what defined in the locale resource file.
+     *
+     * This method provides a way for user to replace the fallback pattern.
+     *
+     * @param fallbackPattern  fall-back interval pattern.
+     * @param status           output param set to success/failure code on exit
+     * @stable ICU 4.0 
+     */
+    void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
+                                    UErrorCode& status);
+
+
+    /** Get default order -- whether the first date in pattern is later date
+                             or not.
+     * return default date ordering in interval pattern. TRUE if the first date
+     *        in pattern is later date, FALSE otherwise.
+     * @stable ICU 4.0 
+     */
+    UBool getDefaultOrder() const;
+
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+
+private:
+    /**
+     * DateIntervalFormat will need access to
+     * getBestSkeleton(), parseSkeleton(), enum IntervalPatternIndex,
+     * and calendarFieldToPatternIndex().
+     *
+     * Instead of making above public,
+     * make DateIntervalFormat a friend of DateIntervalInfo.
+     */
+    friend class DateIntervalFormat;
+
+    /**
+     * Following is for saving the interval patterns.
+     * We only support interval patterns on
+     * ERA, YEAR, MONTH, DAY, AM_PM, HOUR, and MINUTE
+     */
+    enum IntervalPatternIndex
+    {
+        kIPI_ERA,
+        kIPI_YEAR,
+        kIPI_MONTH,
+        kIPI_DATE,
+        kIPI_AM_PM,
+        kIPI_HOUR,
+        kIPI_MINUTE,
+        kIPI_MAX_INDEX
+    };
+public:
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Max index for stored interval patterns
+     * @internal ICU 4.4 
+     */
+     enum {
+         kMaxIntervalPatternIndex = kIPI_MAX_INDEX
+     };
+#endif  /* U_HIDE_INTERNAL_API */
+private:
+
+
+    /** 
+     * Initialize the DateIntervalInfo from locale
+     * @param locale   the given locale.
+     * @param status   output param set to success/failure code on exit
+     */
+    void initializeData(const Locale& locale, UErrorCode& status);
+
+
+    /* Set Interval pattern.
+     *
+     * It sets interval pattern into the hash map.
+     *
+     * @param skeleton         skeleton on which the interval pattern based
+     * @param lrgDiffCalUnit   the largest different calendar unit.
+     * @param intervalPattern  the interval pattern on the largest different
+     *                         calendar unit.
+     * @param status           output param set to success/failure code on exit
+     */
+    void setIntervalPatternInternally(const UnicodeString& skeleton,
+                                      UCalendarDateFields lrgDiffCalUnit,
+                                      const UnicodeString& intervalPattern,
+                                      UErrorCode& status); 
+
+
+    /**given an input skeleton, get the best match skeleton 
+     * which has pre-defined interval pattern in resource file.
+     * Also return the difference between the input skeleton
+     * and the best match skeleton.
+     *
+     * TODO (xji): set field weight or
+     *             isolate the funtionality in DateTimePatternGenerator
+     * @param  skeleton               input skeleton
+     * @param  bestMatchDistanceInfo  the difference between input skeleton
+     *                                and best match skeleton.
+     *         0, if there is exact match for input skeleton
+     *         1, if there is only field width difference between 
+     *            the best match and the input skeleton
+     *         2, the only field difference is 'v' and 'z'
+     *        -1, if there is calendar field difference between
+     *            the best match and the input skeleton
+     * @return                        best match skeleton
+     */
+    const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
+                                         int8_t& bestMatchDistanceInfo) const;
+
+
+    /**
+     * Parse skeleton, save each field's width.
+     * It is used for looking for best match skeleton,
+     * and adjust pattern field width.
+     * @param skeleton            skeleton to be parsed
+     * @param skeletonFieldWidth  parsed skeleton field width
+     */
+    static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton, 
+                                        int32_t* skeletonFieldWidth);
+
+
+    /**
+     * Check whether one field width is numeric while the other is string.
+     *
+     * TODO (xji): make it general
+     *
+     * @param fieldWidth          one field width
+     * @param anotherFieldWidth   another field width
+     * @param patternLetter       pattern letter char
+     * @return true if one field width is numeric and the other is string,
+     *         false otherwise.
+     */
+    static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
+                                         int32_t anotherFieldWidth,
+                                         char patternLetter);
+
+
+    /** 
+     * Convert calendar field to the interval pattern index in 
+     * hash table.
+     *
+     * Since we only support the following calendar fields: 
+     * ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, DAY_OF_WEEK, 
+     * AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE,
+     * We reserve only 4 interval patterns for a skeleton.
+     *
+     * @param field    calendar field
+     * @param status   output param set to success/failure code on exit
+     * @return  interval pattern index in hash table
+     */
+    static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
+                                                      UCalendarDateFields field,
+                                                      UErrorCode& status);
+
+
+    /**
+     * delete hash table (of type fIntervalPatterns).
+     *
+     * @param hTable  hash table to be deleted
+     */
+    void deleteHash(Hashtable* hTable);
+
+
+    /**
+     * initialize hash table (of type fIntervalPatterns).
+     *
+     * @param status   output param set to success/failure code on exit
+     * @return         hash table initialized
+     */
+    Hashtable* initHash(UErrorCode& status);
+
+
+
+    /**
+     * copy hash table (of type fIntervalPatterns).
+     *
+     * @param source   the source to copy from
+     * @param target   the target to copy to
+     * @param status   output param set to success/failure code on exit
+     */
+    void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
+
+
+    // data members
+    // fallback interval pattern 
+    UnicodeString fFallbackIntervalPattern;
+    // default order
+    UBool fFirstDateInPtnIsLaterDate;
+
+    // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
+    // HashMap( skeleton, pattern[largest_different_field] )
+    Hashtable* fIntervalPatterns;
+
+};// end class DateIntervalInfo
+
+
+inline UBool
+DateIntervalInfo::operator!=(const DateIntervalInfo& other) const {
+    return !operator==(other);
+}
+
+
+U_NAMESPACE_END
+
+#endif
+
+#endif
+

+ 512 - 0
sqlite/unicode/dtptngen.h

@@ -0,0 +1,512 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2015, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*
+* File DTPTNGEN.H
+*
+*******************************************************************************
+*/
+
+#ifndef __DTPTNGEN_H__
+#define __DTPTNGEN_H__
+
+#include "unicode/datefmt.h"
+#include "unicode/locid.h"
+#include "unicode/udat.h"
+#include "unicode/udatpg.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * \file
+ * \brief C++ API: Date/Time Pattern Generator
+ */
+
+
+class Hashtable;
+class FormatParser;
+class DateTimeMatcher;
+class DistanceInfo;
+class PatternMap;
+class PtnSkeleton;
+class SharedDateTimePatternGenerator;
+
+/**
+ * This class provides flexible generation of date format patterns, like "yy-MM-dd". 
+ * The user can build up the generator by adding successive patterns. Once that 
+ * is done, a query can be made using a "skeleton", which is a pattern which just
+ * includes the desired fields and lengths. The generator will return the "best fit" 
+ * pattern corresponding to that skeleton.
+ * <p>The main method people will use is getBestPattern(String skeleton),
+ * since normally this class is pre-built with data from a particular locale. 
+ * However, generators can be built directly from other data as well.
+ * <p><i>Issue: may be useful to also have a function that returns the list of 
+ * fields in a pattern, in order, since we have that internally.
+ * That would be useful for getting the UI order of field elements.</i>
+ * @stable ICU 3.8
+**/
+class U_I18N_API DateTimePatternGenerator : public UObject {
+public:
+    /**
+     * Construct a flexible generator according to default locale.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @stable ICU 3.8
+     */
+    static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status);
+
+    /**
+     * Construct a flexible generator according to data for a given locale.
+     * @param uLocale
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @stable ICU 3.8
+     */
+    static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);
+
+#ifndef U_HIDE_INTERNAL_API
+
+    /**
+     * For ICU use only
+     *
+     * @internal
+     */
+    static DateTimePatternGenerator* U_EXPORT2 internalMakeInstance(const Locale& uLocale, UErrorCode& status);
+
+#endif /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Create an empty generator, to be constructed with addPattern(...) etc.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @stable ICU 3.8
+     */
+     static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status);
+     
+    /**
+     * Destructor.
+     * @stable ICU 3.8
+     */
+    virtual ~DateTimePatternGenerator();
+
+    /**
+     * Clone DateTimePatternGenerator object. Clients are responsible for 
+     * deleting the DateTimePatternGenerator object cloned.
+     * @stable ICU 3.8
+     */
+    DateTimePatternGenerator* clone() const;
+
+     /**
+      * Return true if another object is semantically equal to this one.
+      *
+      * @param other    the DateTimePatternGenerator object to be compared with.
+      * @return         true if other is semantically equal to this.
+      * @stable ICU 3.8
+      */
+    UBool operator==(const DateTimePatternGenerator& other) const;
+    
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the DateTimePatternGenerator object to be compared with.
+     * @return         true if other is semantically unequal to this.
+     * @stable ICU 3.8
+     */
+    UBool operator!=(const DateTimePatternGenerator& other) const;
+
+    /**
+     * Utility to return a unique skeleton from a given pattern. For example,
+     * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd".
+     *
+     * @param pattern   Input pattern, such as "dd/MMM"
+     * @param status  Output param set to success/failure code on exit,
+     *                  which must not indicate a failure before the function call.
+     * @return skeleton such as "MMMdd"
+     * @stable ICU 3.8
+     */
+    UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status);
+
+    /**
+     * Utility to return a unique base skeleton from a given pattern. This is
+     * the same as the skeleton, except that differences in length are minimized
+     * so as to only preserve the difference between string and numeric form. So
+     * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd"
+     * (notice the single d).
+     *
+     * @param pattern  Input pattern, such as "dd/MMM"
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return base skeleton, such as "Md"
+     * @stable ICU 3.8
+     */
+    UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status);
+
+    /**
+     * Adds a pattern to the generator. If the pattern has the same skeleton as
+     * an existing pattern, and the override parameter is set, then the previous
+     * value is overriden. Otherwise, the previous value is retained. In either
+     * case, the conflicting status is set and previous vale is stored in 
+     * conflicting pattern.
+     * <p>
+     * Note that single-field patterns (like "MMM") are automatically added, and
+     * don't need to be added explicitly!
+     *
+     * @param pattern   Input pattern, such as "dd/MMM"
+     * @param override  When existing values are to be overridden use true, 
+     *                   otherwise use false.
+     * @param conflictingPattern  Previous pattern with the same skeleton.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return conflicting status.  The value could be UDATPG_NO_CONFLICT, 
+     *                             UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
+     * @stable ICU 3.8
+	 * <p>
+	 * <h4>Sample code</h4>
+	 * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
+	 * \snippet samples/dtptngsample/dtptngsample.cpp addPatternExample
+	 * <p>
+     */
+    UDateTimePatternConflict addPattern(const UnicodeString& pattern, 
+                                        UBool override, 
+                                        UnicodeString& conflictingPattern,
+                                        UErrorCode& status);
+
+    /**
+     * An AppendItem format is a pattern used to append a field if there is no
+     * good match. For example, suppose that the input skeleton is "GyyyyMMMd",
+     * and there is no matching pattern internally, but there is a pattern
+     * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the
+     * G. The way these two are conjoined is by using the AppendItemFormat for G
+     * (era). So if that value is, say "{0}, {1}" then the final resulting
+     * pattern is "d-MM-yyyy, G".
+     * <p>
+     * There are actually three available variables: {0} is the pattern so far,
+     * {1} is the element we are adding, and {2} is the name of the element.
+     * <p>
+     * This reflects the way that the CLDR data is organized.
+     *
+     * @param field  such as UDATPG_ERA_FIELD.
+     * @param value  pattern, such as "{0}, {1}"
+     * @stable ICU 3.8
+     */
+    void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value);
+
+    /**
+     * Getter corresponding to setAppendItemFormat. Values below 0 or at or
+     * above UDATPG_FIELD_COUNT are illegal arguments.
+     *
+     * @param  field  such as UDATPG_ERA_FIELD.
+     * @return append pattern for field
+     * @stable ICU 3.8
+     */
+    const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const;
+
+    /**
+     * Sets the names of field, eg "era" in English for ERA. These are only
+     * used if the corresponding AppendItemFormat is used, and if it contains a
+     * {2} variable.
+     * <p>
+     * This reflects the way that the CLDR data is organized.
+     *
+     * @param field   such as UDATPG_ERA_FIELD.
+     * @param value   name of the field
+     * @stable ICU 3.8
+     */
+    void setAppendItemName(UDateTimePatternField field, const UnicodeString& value);
+
+    /**
+     * Getter corresponding to setAppendItemNames. Values below 0 or at or above
+     * UDATPG_FIELD_COUNT are illegal arguments.
+     *
+     * @param field  such as UDATPG_ERA_FIELD.
+     * @return name for field
+     * @stable ICU 3.8
+     */
+    const UnicodeString& getAppendItemName(UDateTimePatternField field) const;
+
+    /**
+     * The DateTimeFormat is a message format pattern used to compose date and
+     * time patterns. The default pattern in the root locale is "{1} {0}", where
+     * {1} will be replaced by the date pattern and {0} will be replaced by the
+     * time pattern; however, other locales may specify patterns such as
+     * "{1}, {0}" or "{1} 'at' {0}", etc.
+     * <p>
+     * This is used when the input skeleton contains both date and time fields,
+     * but there is not a close match among the added patterns. For example,
+     * suppose that this object was created by adding "dd-MMM" and "hh:mm", and
+     * its datetimeFormat is the default "{1} {0}". Then if the input skeleton
+     * is "MMMdhmm", there is not an exact match, so the input skeleton is
+     * broken up into two components "MMMd" and "hmm". There are close matches
+     * for those two skeletons, so the result is put together with this pattern,
+     * resulting in "d-MMM h:mm".
+     *
+     * @param dateTimeFormat
+     *            message format pattern, here {1} will be replaced by the date
+     *            pattern and {0} will be replaced by the time pattern.
+     * @stable ICU 3.8
+     */
+    void setDateTimeFormat(const UnicodeString& dateTimeFormat);
+
+    /**
+     * Getter corresponding to setDateTimeFormat.
+     * @return DateTimeFormat.
+     * @stable ICU 3.8
+     */
+    const UnicodeString& getDateTimeFormat() const;
+
+    /**
+     * Return the best pattern matching the input skeleton. It is guaranteed to
+     * have all of the fields in the skeleton.
+     *
+     * @param skeleton
+     *            The skeleton is a pattern containing only the variable fields.
+     *            For example, "MMMdd" and "mmhh" are skeletons.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return bestPattern
+     *            The best pattern found from the given skeleton.
+     * @stable ICU 3.8
+	 * <p>
+	 * <h4>Sample code</h4>
+	 * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
+	 * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample
+	 * <p>
+     */
+     UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
+
+
+    /**
+     * Return the best pattern matching the input skeleton. It is guaranteed to
+     * have all of the fields in the skeleton.
+     *
+     * @param skeleton
+     *            The skeleton is a pattern containing only the variable fields.
+     *            For example, "MMMdd" and "mmhh" are skeletons.
+     * @param options
+     *            Options for forcing the length of specified fields in the
+     *            returned pattern to match those in the skeleton (when this
+     *            would not happen otherwise). For default behavior, use
+     *            UDATPG_MATCH_NO_OPTIONS.
+     * @param status
+     *            Output param set to success/failure code on exit,
+     *            which must not indicate a failure before the function call.
+     * @return bestPattern
+     *            The best pattern found from the given skeleton.
+     * @stable ICU 4.4
+     */
+     UnicodeString getBestPattern(const UnicodeString& skeleton,
+                                  UDateTimePatternMatchOptions options,
+                                  UErrorCode& status);
+
+
+    /**
+     * Adjusts the field types (width and subtype) of a pattern to match what is
+     * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
+     * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
+     * "dd-MMMM hh:mm". This is used internally to get the best match for the
+     * input skeleton, but can also be used externally.
+     *
+     * @param pattern Input pattern
+     * @param skeleton
+     *            The skeleton is a pattern containing only the variable fields.
+     *            For example, "MMMdd" and "mmhh" are skeletons.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return pattern adjusted to match the skeleton fields widths and subtypes.
+     * @stable ICU 3.8
+	 * <p>
+	 * <h4>Sample code</h4>
+	 * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
+	 * \snippet samples/dtptngsample/dtptngsample.cpp replaceFieldTypesExample
+	 * <p>
+     */
+     UnicodeString replaceFieldTypes(const UnicodeString& pattern, 
+                                     const UnicodeString& skeleton, 
+                                     UErrorCode& status);
+
+    /**
+     * Adjusts the field types (width and subtype) of a pattern to match what is
+     * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
+     * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
+     * "dd-MMMM hh:mm". This is used internally to get the best match for the
+     * input skeleton, but can also be used externally.
+     *
+     * @param pattern Input pattern
+     * @param skeleton
+     *            The skeleton is a pattern containing only the variable fields.
+     *            For example, "MMMdd" and "mmhh" are skeletons.
+     * @param options
+     *            Options controlling whether the length of specified fields in the
+     *            pattern are adjusted to match those in the skeleton (when this
+     *            would not happen otherwise). For default behavior, use
+     *            UDATPG_MATCH_NO_OPTIONS.
+     * @param status
+     *            Output param set to success/failure code on exit,
+     *            which must not indicate a failure before the function call.
+     * @return pattern adjusted to match the skeleton fields widths and subtypes.
+     * @stable ICU 4.4
+     */
+     UnicodeString replaceFieldTypes(const UnicodeString& pattern, 
+                                     const UnicodeString& skeleton, 
+                                     UDateTimePatternMatchOptions options,
+                                     UErrorCode& status);
+
+    /**
+     * Return a list of all the skeletons (in canonical form) from this class.
+     *
+     * Call getPatternForSkeleton() to get the corresponding pattern.
+     *
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return StringEnumeration with the skeletons.
+     *         The caller must delete the object.
+     * @stable ICU 3.8
+     */
+     StringEnumeration* getSkeletons(UErrorCode& status) const;
+
+     /**
+      * Get the pattern corresponding to a given skeleton.
+      * @param skeleton 
+      * @return pattern corresponding to a given skeleton.
+      * @stable ICU 3.8
+      */
+     const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;
+     
+    /**
+     * Return a list of all the base skeletons (in canonical form) from this class.
+     *
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return a StringEnumeration with the base skeletons.
+     *         The caller must delete the object.
+     * @stable ICU 3.8
+     */
+     StringEnumeration* getBaseSkeletons(UErrorCode& status) const;
+
+#ifndef U_HIDE_INTERNAL_API
+     /**
+      * Return a list of redundant patterns are those which if removed, make no 
+      * difference in the resulting getBestPattern values. This method returns a 
+      * list of them, to help check the consistency of the patterns used to build 
+      * this generator.
+      * 
+      * @param status  Output param set to success/failure code on exit,
+      *               which must not indicate a failure before the function call.
+      * @return a StringEnumeration with the redundant pattern.
+      *         The caller must delete the object.
+      * @internal ICU 3.8
+      */
+     StringEnumeration* getRedundants(UErrorCode& status);
+#endif  /* U_HIDE_INTERNAL_API */
+
+    /**
+     * The decimal value is used in formatting fractions of seconds. If the
+     * skeleton contains fractional seconds, then this is used with the
+     * fractional seconds. For example, suppose that the input pattern is
+     * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and
+     * the decimal string is ",". Then the resulting pattern is modified to be
+     * "H:mm:ss,SSSS"
+     *
+     * @param decimal 
+     * @stable ICU 3.8
+     */
+    void setDecimal(const UnicodeString& decimal);
+
+    /**
+     * Getter corresponding to setDecimal.
+     * @return UnicodeString corresponding to the decimal point
+     * @stable ICU 3.8
+     */
+    const UnicodeString& getDecimal() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 3.8
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 3.8
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+private:
+    /**
+     * Constructor.
+     * @stable ICU 3.8
+     */
+    DateTimePatternGenerator(UErrorCode & status);
+
+    /**
+     * Constructor.
+     * @stable ICU 3.8
+     */
+    DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
+
+    /**
+     * Copy constructor.
+     * @param other DateTimePatternGenerator to copy
+     * @stable ICU 3.8
+     */
+    DateTimePatternGenerator(const DateTimePatternGenerator& other);
+
+    /**
+     * Default assignment operator.
+     * @param other DateTimePatternGenerator to copy
+     * @stable ICU 3.8
+     */
+    DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
+
+    Locale pLocale;  // pattern locale
+    FormatParser *fp;
+    DateTimeMatcher* dtMatcher;
+    DistanceInfo *distanceInfo;
+    PatternMap *patternMap;
+    UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
+    UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
+    UnicodeString dateTimeFormat;
+    UnicodeString decimal;
+    DateTimeMatcher *skipMatcher;
+    Hashtable *fAvailableFormatKeyHash;
+    UnicodeString hackPattern;
+    UnicodeString emptyString;
+    UChar fDefaultHourFormatChar;
+    
+    /* internal flags masks for adjustFieldTypes etc. */
+    enum {
+        kDTPGNoFlags = 0,
+        kDTPGFixFractionalSeconds = 1,
+        kDTPGSkeletonUsesCapJ = 2
+    };
+
+    void initData(const Locale &locale, UErrorCode &status);
+    void addCanonicalItems();
+    void addICUPatterns(const Locale& locale, UErrorCode& status);
+    void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
+    void addCLDRData(const Locale& locale, UErrorCode& status);
+    UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);
+    void initHashtable(UErrorCode& status);
+    void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
+    void setDecimalSymbols(const Locale& locale, UErrorCode& status);
+    UDateTimePatternField getAppendFormatNumber(const char* field) const;
+    UDateTimePatternField getAppendNameNumber(const char* field) const;
+    void getAppendName(UDateTimePatternField field, UnicodeString& value);
+    int32_t getCanonicalIndex(const UnicodeString& field);
+    const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0);
+    UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
+    UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);
+    int32_t getTopBitNumber(int32_t foundMask);
+    void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
+    UBool isAvailableFormatSet(const UnicodeString &key) const;
+    void copyHashtable(Hashtable *other, UErrorCode &status);
+    UBool isCanonicalItem(const UnicodeString& item) const;
+} ;// end class DateTimePatternGenerator
+
+U_NAMESPACE_END
+
+#endif

+ 250 - 0
sqlite/unicode/dtrule.h

@@ -0,0 +1,250 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and         *
+* others. All Rights Reserved.                                                *
+*******************************************************************************
+*/
+#ifndef DTRULE_H
+#define DTRULE_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Rule for specifying date and time in an year
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+
+U_NAMESPACE_BEGIN
+/**
+ * <code>DateTimeRule</code> is a class representing a time in a year by
+ * a rule specified by month, day of month, day of week and
+ * time in the day.
+ * 
+ * @stable ICU 3.8
+ */
+class U_I18N_API DateTimeRule : public UObject {
+public:
+
+    /**
+     * Date rule type constants.
+     * @stable ICU 3.8
+     */
+    enum DateRuleType {
+        DOM = 0,        /**< The exact day of month,
+                             for example, March 11. */
+        DOW,            /**< The Nth occurence of the day of week,
+                             for example, 2nd Sunday in March. */
+        DOW_GEQ_DOM,    /**< The first occurence of the day of week on or after the day of monnth,
+                             for example, first Sunday on or after March 8. */
+        DOW_LEQ_DOM     /**< The last occurence of the day of week on or before the day of month,
+                             for example, first Sunday on or before March 14. */
+    };
+
+    /**
+     * Time rule type constants.
+     * @stable ICU 3.8
+     */
+    enum TimeRuleType {
+        WALL_TIME = 0,  /**< The local wall clock time */
+        STANDARD_TIME,  /**< The local standard time */
+        UTC_TIME        /**< The UTC time */
+    };
+
+    /**
+     * Constructs a <code>DateTimeRule</code> by the day of month and
+     * the time rule.  The date rule type for an instance created by
+     * this constructor is <code>DOM</code>.
+     * 
+     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>
+     * @param dayOfMonth    The day of month, 1-based.
+     * @param millisInDay   The milliseconds in the rule date.
+     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
+     *                      or <code>UTC_TIME</code>.
+     * @stable ICU 3.8
+     */
+    DateTimeRule(int32_t month, int32_t dayOfMonth,
+        int32_t millisInDay, TimeRuleType timeType);
+
+    /**
+     * Constructs a <code>DateTimeRule</code> by the day of week and its oridinal
+     * number and the time rule.  The date rule type for an instance created
+     * by this constructor is <code>DOW</code>.
+     * 
+     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>.
+     * @param weekInMonth   The ordinal number of the day of week.  Negative number
+     *                      may be used for specifying a rule date counted from the
+     *                      end of the rule month.
+     * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.
+     * @param millisInDay   The milliseconds in the rule date.
+     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
+     *                      or <code>UTC_TIME</code>.
+     * @stable ICU 3.8
+     */
+    DateTimeRule(int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
+        int32_t millisInDay, TimeRuleType timeType);
+
+    /**
+     * Constructs a <code>DateTimeRule</code> by the first/last day of week
+     * on or after/before the day of month and the time rule.  The date rule
+     * type for an instance created by this constructor is either
+     * <code>DOM_GEQ_DOM</code> or <code>DOM_LEQ_DOM</code>.
+     * 
+     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>
+     * @param dayOfMonth    The day of month, 1-based.
+     * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.
+     * @param after         true if the rule date is on or after the day of month.
+     * @param millisInDay   The milliseconds in the rule date.
+     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
+     *                      or <code>UTC_TIME</code>.
+     * @stable ICU 3.8
+     */
+    DateTimeRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, UBool after,
+        int32_t millisInDay, TimeRuleType timeType);
+
+    /**
+     * Copy constructor.
+     * @param source    The DateTimeRule object to be copied.
+     * @stable ICU 3.8
+     */
+    DateTimeRule(const DateTimeRule& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 3.8
+     */
+    ~DateTimeRule();
+
+    /**
+     * Clone this DateTimeRule object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return    A copy of the object.
+     * @stable ICU 3.8
+     */
+    DateTimeRule* clone(void) const;
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 3.8
+     */
+    DateTimeRule& operator=(const DateTimeRule& right);
+
+    /**
+     * Return true if the given DateTimeRule objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given DateTimeRule objects are semantically equal.
+     * @stable ICU 3.8
+     */
+    UBool operator==(const DateTimeRule& that) const;
+
+    /**
+     * Return true if the given DateTimeRule objects are semantically unequal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given DateTimeRule objects are semantically unequal.
+     * @stable ICU 3.8
+     */
+    UBool operator!=(const DateTimeRule& that) const;
+
+    /**
+     * Gets the date rule type, such as <code>DOM</code>
+     * @return The date rule type.
+     * @stable ICU 3.8
+     */
+    DateRuleType getDateRuleType(void) const;
+
+    /**
+     * Gets the time rule type
+     * @return The time rule type, either <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
+     *         or <code>UTC_TIME</code>.
+     * @stable ICU 3.8
+     */
+    TimeRuleType getTimeRuleType(void) const;
+
+    /**
+     * Gets the rule month.
+     * @return The rule month.
+     * @stable ICU 3.8
+     */
+    int32_t getRuleMonth(void) const;
+
+    /**
+     * Gets the rule day of month.  When the date rule type
+     * is <code>DOW</code>, the value is always 0.
+     * @return The rule day of month
+     * @stable ICU 3.8
+     */
+    int32_t getRuleDayOfMonth(void) const;
+
+    /**
+     * Gets the rule day of week.  When the date rule type
+     * is <code>DOM</code>, the value is always 0.
+     * @return The rule day of week.
+     * @stable ICU 3.8
+     */
+    int32_t getRuleDayOfWeek(void) const;
+
+    /**
+     * Gets the ordinal number of the occurence of the day of week
+     * in the month.  When the date rule type is not <code>DOW</code>,
+     * the value is always 0.
+     * @return The rule day of week ordinal number in the month.
+     * @stable ICU 3.8
+     */
+    int32_t getRuleWeekInMonth(void) const;
+
+    /**
+     * Gets the rule time in the rule day.
+     * @return The time in the rule day in milliseconds.
+     * @stable ICU 3.8
+     */
+    int32_t getRuleMillisInDay(void) const;
+
+private:
+    int32_t fMonth;
+    int32_t fDayOfMonth;
+    int32_t fDayOfWeek;
+    int32_t fWeekInMonth;
+    int32_t fMillisInDay;
+    DateRuleType fDateRuleType;
+    TimeRuleType fTimeRuleType;
+
+public:
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 3.8
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 3.8
+     */
+    virtual UClassID getDynamicClassID(void) const;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // DTRULE_H
+//eof

+ 64 - 0
sqlite/unicode/enumset.h

@@ -0,0 +1,64 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 2012,2014 International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*/
+
+/**
+ * \file
+ * \brief C++: internal template EnumSet<>
+ */
+
+#ifndef ENUMSET_H
+#define ENUMSET_H
+
+#include "unicode/utypes.h"
+
+#if U_SHOW_CPLUSPLUS_API
+
+U_NAMESPACE_BEGIN
+
+/* Can't use #ifndef U_HIDE_INTERNAL_API for the entire EnumSet class, needed in .h file declarations */
+/**
+ * enum bitset for boolean fields. Similar to Java EnumSet<>. 
+ * Needs to range check. Used for private instance variables.
+ * @internal
+ */
+template<typename T, uint32_t minValue, uint32_t limitValue>
+class EnumSet {
+public:
+    inline EnumSet() : fBools(0) {}
+    inline EnumSet(const EnumSet<T,minValue,limitValue>& other) : fBools(other.fBools) {}
+    inline ~EnumSet() {}
+#ifndef U_HIDE_INTERNAL_API
+    inline void clear() { fBools=0; }
+    inline void add(T toAdd) { set(toAdd, 1); }
+    inline void remove(T toRemove) { set(toRemove, 0); }
+    inline int32_t contains(T toCheck) const { return get(toCheck); }
+    inline void set(T toSet, int32_t v) { fBools=(fBools&(~flag(toSet)))|(v?(flag(toSet)):0); }
+    inline int32_t get(T toCheck) const { return (fBools & flag(toCheck))?1:0; }
+    inline UBool isValidEnum(T toCheck) const {  return (toCheck>=minValue&&toCheck<limitValue); }
+    inline UBool isValidValue(int32_t v) const { return (v==0||v==1); }
+    inline const EnumSet<T,minValue,limitValue>& operator=(const EnumSet<T,minValue,limitValue>& other) {
+        fBools = other.fBools;
+        return *this;
+    }
+  
+    inline uint32_t getAll() const {
+        return fBools; 
+    }
+#endif /* U_HIDE_INTERNAL_API */
+
+private:
+    inline uint32_t flag(T toCheck) const { return (1<<(toCheck-minValue)); }
+private:
+    uint32_t fBools;
+};
+
+U_NAMESPACE_END
+
+#endif /* U_SHOW_CPLUSPLUS_API */
+#endif /* ENUMSET_H */

+ 137 - 0
sqlite/unicode/errorcode.h

@@ -0,0 +1,137 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2009-2011, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  errorcode.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2009mar10
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __ERRORCODE_H__
+#define __ERRORCODE_H__
+
+/**
+ * \file 
+ * \brief C++ API: ErrorCode class intended to make it easier to use
+ *                 ICU C and C++ APIs from C++ user code.
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Wrapper class for UErrorCode, with conversion operators for direct use
+ * in ICU C and C++ APIs.
+ * Intended to be used as a base class, where a subclass overrides
+ * the handleFailure() function so that it throws an exception,
+ * does an assert(), logs an error, etc.
+ * This is not an abstract base class. This class can be used and instantiated
+ * by itself, although it will be more useful when subclassed.
+ *
+ * Features:
+ * - The constructor initializes the internal UErrorCode to U_ZERO_ERROR,
+ *   removing one common source of errors.
+ * - Same use in C APIs taking a UErrorCode * (pointer)
+ *   and C++ taking UErrorCode & (reference) via conversion operators.
+ * - Possible automatic checking for success when it goes out of scope.
+ *
+ * Note: For automatic checking for success in the destructor, a subclass
+ * must implement such logic in its own destructor because the base class
+ * destructor cannot call a subclass function (like handleFailure()).
+ * The ErrorCode base class destructor does nothing.
+ *
+ * Note also: While it is possible for a destructor to throw an exception,
+ * it is generally unsafe to do so. This means that in a subclass the destructor
+ * and the handleFailure() function may need to take different actions.
+ *
+ * Sample code:
+ * \code
+ *   class IcuErrorCode: public icu::ErrorCode {
+ *   public:
+ *     virtual ~IcuErrorCode() {  // should be defined in .cpp as "key function"
+ *       // Safe because our handleFailure() does not throw exceptions.
+ *       if(isFailure()) { handleFailure(); }
+ *     }
+ *   protected:
+ *     virtual void handleFailure() const {
+ *       log_failure(u_errorName(errorCode));
+ *       exit(errorCode);
+ *     }
+ *   };
+ *   IcuErrorCode error_code;
+ *   UConverter *cnv = ucnv_open("Shift-JIS", error_code);
+ *   length = ucnv_fromUChars(dest, capacity, src, length, error_code);
+ *   ucnv_close(cnv);
+ *   // IcuErrorCode destructor checks for success.
+ * \endcode
+ *
+ * @stable ICU 4.2
+ */
+class U_COMMON_API ErrorCode: public UMemory {
+public:
+    /**
+     * Default constructor. Initializes its UErrorCode to U_ZERO_ERROR.
+     * @stable ICU 4.2
+     */
+    ErrorCode() : errorCode(U_ZERO_ERROR) {}
+    /** Destructor, does nothing. See class documentation for details. @stable ICU 4.2 */
+    virtual ~ErrorCode();
+    /** Conversion operator, returns a reference. @stable ICU 4.2 */
+    operator UErrorCode & () { return errorCode; }
+    /** Conversion operator, returns a pointer. @stable ICU 4.2 */
+    operator UErrorCode * () { return &errorCode; }
+    /** Tests for U_SUCCESS(). @stable ICU 4.2 */
+    UBool isSuccess() const { return U_SUCCESS(errorCode); }
+    /** Tests for U_FAILURE(). @stable ICU 4.2 */
+    UBool isFailure() const { return U_FAILURE(errorCode); }
+    /** Returns the UErrorCode value. @stable ICU 4.2 */
+    UErrorCode get() const { return errorCode; }
+    /** Sets the UErrorCode value. @stable ICU 4.2 */
+    void set(UErrorCode value) { errorCode=value; }
+    /** Returns the UErrorCode value and resets it to U_ZERO_ERROR. @stable ICU 4.2 */
+    UErrorCode reset();
+    /**
+     * Asserts isSuccess().
+     * In other words, this method checks for a failure code,
+     * and the base class handles it like this:
+     * \code
+     *   if(isFailure()) { handleFailure(); }
+     * \endcode
+     * @stable ICU 4.4
+     */
+    void assertSuccess() const;
+    /**
+     * Return a string for the UErrorCode value.
+     * The string will be the same as the name of the error code constant
+     * in the UErrorCode enum.
+     * @stable ICU 4.4
+     */
+    const char* errorName() const;
+
+protected:
+    /**
+     * Internal UErrorCode, accessible to subclasses.
+     * @stable ICU 4.2
+     */
+    UErrorCode errorCode;
+    /**
+     * Called by assertSuccess() if isFailure() is true.
+     * A subclass should override this function to deal with a failure code:
+     * Throw an exception, log an error, terminate the program, or similar.
+     * @stable ICU 4.2
+     */
+    virtual void handleFailure() const {}
+};
+
+U_NAMESPACE_END
+
+#endif  // __ERRORCODE_H__

+ 291 - 0
sqlite/unicode/fieldpos.h

@@ -0,0 +1,291 @@
+/*
+ ********************************************************************************
+ *   Copyright (C) 1997-2006, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ ********************************************************************************
+ *
+ * File FIELDPOS.H
+ *
+ * Modification History:
+ *
+ *   Date        Name        Description
+ *   02/25/97    aliu        Converted from java.
+ *   03/17/97    clhuang     Updated per Format implementation.
+ *    07/17/98    stephen        Added default/copy ctors, and operators =, ==, !=
+ ********************************************************************************
+ */
+
+// *****************************************************************************
+// This file was generated from the java source file FieldPosition.java
+// *****************************************************************************
+ 
+#ifndef FIELDPOS_H
+#define FIELDPOS_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: FieldPosition identifies the fields in a formatted output.
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * <code>FieldPosition</code> is a simple class used by <code>Format</code>
+ * and its subclasses to identify fields in formatted output. Fields are
+ * identified by constants, whose names typically end with <code>_FIELD</code>,
+ * defined in the various subclasses of <code>Format</code>. See
+ * <code>ERA_FIELD</code> and its friends in <code>DateFormat</code> for
+ * an example.
+ *
+ * <p>
+ * <code>FieldPosition</code> keeps track of the position of the
+ * field within the formatted output with two indices: the index
+ * of the first character of the field and the index of the last
+ * character of the field.
+ *
+ * <p>
+ * One version of the <code>format</code> method in the various
+ * <code>Format</code> classes requires a <code>FieldPosition</code>
+ * object as an argument. You use this <code>format</code> method
+ * to perform partial formatting or to get information about the
+ * formatted output (such as the position of a field).
+ *
+ * The FieldPosition class is not suitable for subclassing.
+ *
+ * <p>
+ * Below is an example of using <code>FieldPosition</code> to aid
+ * alignment of an array of formatted floating-point numbers on
+ * their decimal points:
+ * <pre>
+ * \code
+ *       double doubleNum[] = {123456789.0, -12345678.9, 1234567.89, -123456.789,
+ *                  12345.6789, -1234.56789, 123.456789, -12.3456789, 1.23456789};
+ *       int dNumSize = (int)(sizeof(doubleNum)/sizeof(double));
+ *       
+ *       UErrorCode status = U_ZERO_ERROR;
+ *       DecimalFormat* fmt = (DecimalFormat*) NumberFormat::createInstance(status);
+ *       fmt->setDecimalSeparatorAlwaysShown(true);
+ *       
+ *       const int tempLen = 20;
+ *       char temp[tempLen];
+ *       
+ *       for (int i=0; i<dNumSize; i++) {
+ *           FieldPosition pos(NumberFormat::INTEGER_FIELD);
+ *           UnicodeString buf;
+ *           char fmtText[tempLen];
+ *           ToCharString(fmt->format(doubleNum[i], buf, pos), fmtText);
+ *           for (int j=0; j<tempLen; j++) temp[j] = ' '; // clear with spaces
+ *           temp[__min(tempLen, tempLen-pos.getEndIndex())] = '\0';
+ *           cout << temp << fmtText   << endl;
+ *       }
+ *       delete fmt;
+ * \endcode
+ * </pre>
+ * <p>
+ * The code will generate the following output:
+ * <pre>
+ * \code
+ *           123,456,789.000
+ *           -12,345,678.900
+ *             1,234,567.880
+ *              -123,456.789
+ *                12,345.678
+ *                -1,234.567
+ *                   123.456
+ *                   -12.345
+ *                     1.234
+ *  \endcode
+ * </pre>
+ */
+class U_I18N_API FieldPosition : public UObject {
+public:
+    /**
+     * DONT_CARE may be specified as the field to indicate that the
+     * caller doesn't need to specify a field.  Do not subclass.
+     */
+    enum { DONT_CARE = -1 };
+
+    /**
+     * Creates a FieldPosition object with a non-specified field.
+     * @stable ICU 2.0
+     */
+    FieldPosition() 
+        : UObject(), fField(DONT_CARE), fBeginIndex(0), fEndIndex(0) {}
+
+    /**
+     * Creates a FieldPosition object for the given field.  Fields are
+     * identified by constants, whose names typically end with _FIELD,
+     * in the various subclasses of Format.
+     *
+     * @see NumberFormat#INTEGER_FIELD
+     * @see NumberFormat#FRACTION_FIELD
+     * @see DateFormat#YEAR_FIELD
+     * @see DateFormat#MONTH_FIELD
+     * @stable ICU 2.0
+     */
+    FieldPosition(int32_t field) 
+        : UObject(), fField(field), fBeginIndex(0), fEndIndex(0) {}
+
+    /**
+     * Copy constructor
+     * @param copy the object to be copied from.
+     * @stable ICU 2.0
+     */
+    FieldPosition(const FieldPosition& copy) 
+        : UObject(copy), fField(copy.fField), fBeginIndex(copy.fBeginIndex), fEndIndex(copy.fEndIndex) {}
+
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~FieldPosition();
+
+    /**
+     * Assignment operator
+     * @param copy the object to be copied from.
+     * @stable ICU 2.0
+     */
+    FieldPosition&      operator=(const FieldPosition& copy);
+
+    /** 
+     * Equality operator.
+     * @param that    the object to be compared with.
+     * @return        TRUE if the two field positions are equal, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool              operator==(const FieldPosition& that) const;
+
+    /** 
+     * Equality operator.
+     * @param that    the object to be compared with.
+     * @return        TRUE if the two field positions are not equal, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool              operator!=(const FieldPosition& that) const;
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    FieldPosition *clone() const;
+
+    /**
+     * Retrieve the field identifier.
+     * @return    the field identifier.
+     * @stable ICU 2.0
+     */
+    int32_t getField(void) const { return fField; }
+
+    /**
+     * Retrieve the index of the first character in the requested field.
+     * @return    the index of the first character in the requested field.
+     * @stable ICU 2.0
+     */
+    int32_t getBeginIndex(void) const { return fBeginIndex; }
+
+    /**
+     * Retrieve the index of the character following the last character in the
+     * requested field.
+     * @return    the index of the character following the last character in the
+     *            requested field.
+     * @stable ICU 2.0
+     */
+    int32_t getEndIndex(void) const { return fEndIndex; }
+ 
+    /**
+     * Set the field.
+     * @param f    the new value of the field.
+     * @stable ICU 2.0
+     */
+    void setField(int32_t f) { fField = f; }
+
+    /**
+     * Set the begin index.  For use by subclasses of Format.
+     * @param bi    the new value of the begin index
+     * @stable ICU 2.0
+     */
+    void setBeginIndex(int32_t bi) { fBeginIndex = bi; }
+
+    /**
+     * Set the end index.  For use by subclasses of Format.
+     * @param ei    the new value of the end index
+     * @stable ICU 2.0
+     */
+    void setEndIndex(int32_t ei) { fEndIndex = ei; }
+    
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+    /**
+     * Input: Desired field to determine start and end offsets for.
+     * The meaning depends on the subclass of Format.
+     */
+    int32_t fField;
+
+    /**
+     * Output: Start offset of field in text.
+     * If the field does not occur in the text, 0 is returned.
+     */
+    int32_t fBeginIndex;
+
+    /**
+     * Output: End offset of field in text.
+     * If the field does not occur in the text, 0 is returned.
+     */
+    int32_t fEndIndex;
+};
+
+inline FieldPosition&
+FieldPosition::operator=(const FieldPosition& copy)
+{
+    fField         = copy.fField;
+    fEndIndex     = copy.fEndIndex;
+    fBeginIndex = copy.fBeginIndex;
+    return *this;
+}
+
+inline UBool
+FieldPosition::operator==(const FieldPosition& copy) const
+{
+    return (fField == copy.fField &&
+        fEndIndex == copy.fEndIndex &&
+        fBeginIndex == copy.fBeginIndex);
+}
+
+inline UBool
+FieldPosition::operator!=(const FieldPosition& copy) const
+{
+    return !operator==(copy);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _FIELDPOS
+//eof

+ 760 - 0
sqlite/unicode/fmtable.h

@@ -0,0 +1,760 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2014, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File FMTABLE.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/29/97    aliu        Creation.
+********************************************************************************
+*/
+#ifndef FMTABLE_H
+#define FMTABLE_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Formattable is a thin wrapper for primitive types used for formatting and parsing
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/unistr.h"
+#include "unicode/stringpiece.h"
+#include "unicode/uformattable.h"
+
+U_NAMESPACE_BEGIN
+
+class CharString;
+class DigitList;
+
+/**
+ * \def UNUM_INTERNAL_STACKARRAY_SIZE
+ * @internal
+ */
+#if U_PLATFORM == U_PF_OS400
+#define UNUM_INTERNAL_STACKARRAY_SIZE 144
+#else
+#define UNUM_INTERNAL_STACKARRAY_SIZE 128
+#endif
+
+/**
+ * Formattable objects can be passed to the Format class or
+ * its subclasses for formatting.  Formattable is a thin wrapper
+ * class which interconverts between the primitive numeric types
+ * (double, long, etc.) as well as UDate and UnicodeString.
+ *
+ * <p>Internally, a Formattable object is a union of primitive types.
+ * As such, it can only store one flavor of data at a time.  To
+ * determine what flavor of data it contains, use the getType method.
+ *
+ * <p>As of ICU 3.0, Formattable may also wrap a UObject pointer,
+ * which it owns.  This allows an instance of any ICU class to be
+ * encapsulated in a Formattable.  For legacy reasons and for
+ * efficiency, primitive numeric types are still stored directly
+ * within a Formattable.
+ *
+ * <p>The Formattable class is not suitable for subclassing.
+ *
+ * <p>See UFormattable for a C wrapper.
+ */
+class U_I18N_API Formattable : public UObject {
+public:
+    /**
+     * This enum is only used to let callers distinguish between
+     * the Formattable(UDate) constructor and the Formattable(double)
+     * constructor; the compiler cannot distinguish the signatures,
+     * since UDate is currently typedefed to be either double or long.
+     * If UDate is changed later to be a bonafide class
+     * or struct, then we no longer need this enum.
+     * @stable ICU 2.4
+     */
+    enum ISDATE { kIsDate };
+
+    /**
+     * Default constructor
+     * @stable ICU 2.4
+     */
+    Formattable(); // Type kLong, value 0
+
+    /**
+     * Creates a Formattable object with a UDate instance.
+     * @param d the UDate instance.
+     * @param flag the flag to indicate this is a date. Always set it to kIsDate
+     * @stable ICU 2.0
+     */
+    Formattable(UDate d, ISDATE flag);
+
+    /**
+     * Creates a Formattable object with a double number.
+     * @param d the double number.
+     * @stable ICU 2.0
+     */
+    Formattable(double d);
+
+    /**
+     * Creates a Formattable object with a long number.
+     * @param l the long number.
+     * @stable ICU 2.0
+     */
+    Formattable(int32_t l);
+
+    /**
+     * Creates a Formattable object with an int64_t number
+     * @param ll the int64_t number.
+     * @stable ICU 2.8
+     */
+    Formattable(int64_t ll);
+
+#if !UCONFIG_NO_CONVERSION
+    /**
+     * Creates a Formattable object with a char string pointer.
+     * Assumes that the char string is null terminated.
+     * @param strToCopy the char string.
+     * @stable ICU 2.0
+     */
+    Formattable(const char* strToCopy);
+#endif
+
+    /**
+     * Creates a Formattable object of an appropriate numeric type from a
+     * a decimal number in string form.  The Formattable will retain the
+     * full precision of the input in decimal format, even when it exceeds
+     * what can be represented by a double or int64_t.
+     *
+     * @param number  the unformatted (not localized) string representation
+     *                     of the Decimal number.
+     * @param status  the error code.  Possible errors include U_INVALID_FORMAT_ERROR
+     *                if the format of the string does not conform to that of a
+     *                decimal number.
+     * @stable ICU 4.4
+     */
+    Formattable(const StringPiece &number, UErrorCode &status);
+
+    /**
+     * Creates a Formattable object with a UnicodeString object to copy from.
+     * @param strToCopy the UnicodeString string.
+     * @stable ICU 2.0
+     */
+    Formattable(const UnicodeString& strToCopy);
+
+    /**
+     * Creates a Formattable object with a UnicodeString object to adopt from.
+     * @param strToAdopt the UnicodeString string.
+     * @stable ICU 2.0
+     */
+    Formattable(UnicodeString* strToAdopt);
+
+    /**
+     * Creates a Formattable object with an array of Formattable objects.
+     * @param arrayToCopy the Formattable object array.
+     * @param count the array count.
+     * @stable ICU 2.0
+     */
+    Formattable(const Formattable* arrayToCopy, int32_t count);
+
+    /**
+     * Creates a Formattable object that adopts the given UObject.
+     * @param objectToAdopt the UObject to set this object to
+     * @stable ICU 3.0
+     */
+    Formattable(UObject* objectToAdopt);
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    Formattable(const Formattable&);
+
+    /**
+     * Assignment operator.
+     * @param rhs   The Formattable object to copy into this object.
+     * @stable ICU 2.0
+     */
+    Formattable&    operator=(const Formattable &rhs);
+
+    /**
+     * Equality comparison.
+     * @param other    the object to be compared with.
+     * @return        TRUE if other are equal to this, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool          operator==(const Formattable &other) const;
+
+    /**
+     * Equality operator.
+     * @param other    the object to be compared with.
+     * @return        TRUE if other are unequal to this, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool          operator!=(const Formattable& other) const
+      { return !operator==(other); }
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual         ~Formattable();
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    Formattable *clone() const;
+
+    /**
+     * Selector for flavor of data type contained within a
+     * Formattable object.  Formattable is a union of several
+     * different types, and at any time contains exactly one type.
+     * @stable ICU 2.4
+     */
+    enum Type {
+        /**
+         * Selector indicating a UDate value.  Use getDate to retrieve
+         * the value.
+         * @stable ICU 2.4
+         */
+        kDate,
+
+        /**
+         * Selector indicating a double value.  Use getDouble to
+         * retrieve the value.
+         * @stable ICU 2.4
+         */
+        kDouble,
+
+        /**
+         * Selector indicating a 32-bit integer value.  Use getLong to
+         * retrieve the value.
+         * @stable ICU 2.4
+         */
+        kLong,
+
+        /**
+         * Selector indicating a UnicodeString value.  Use getString
+         * to retrieve the value.
+         * @stable ICU 2.4
+         */
+        kString,
+
+        /**
+         * Selector indicating an array of Formattables.  Use getArray
+         * to retrieve the value.
+         * @stable ICU 2.4
+         */
+        kArray,
+
+        /**
+         * Selector indicating a 64-bit integer value.  Use getInt64
+         * to retrieve the value.
+         * @stable ICU 2.8
+         */
+        kInt64,
+
+        /**
+         * Selector indicating a UObject value.  Use getObject to
+         * retrieve the value.
+         * @stable ICU 3.0
+         */
+        kObject
+   };
+
+    /**
+     * Gets the data type of this Formattable object.
+     * @return    the data type of this Formattable object.
+     * @stable ICU 2.0
+     */
+    Type            getType(void) const;
+
+    /**
+     * Returns TRUE if the data type of this Formattable object
+     * is kDouble, kLong, or kInt64
+     * @return TRUE if this is a pure numeric object
+     * @stable ICU 3.0
+     */
+    UBool           isNumeric() const;
+
+    /**
+     * Gets the double value of this object. If this object is not of type
+     * kDouble then the result is undefined.
+     * @return    the double value of this object.
+     * @stable ICU 2.0
+     */
+    double          getDouble(void) const { return fValue.fDouble; }
+
+    /**
+     * Gets the double value of this object. If this object is of type
+     * long, int64 or Decimal Number then a conversion is peformed, with
+     * possible loss of precision.  If the type is kObject and the
+     * object is a Measure, then the result of
+     * getNumber().getDouble(status) is returned.  If this object is
+     * neither a numeric type nor a Measure, then 0 is returned and
+     * the status is set to U_INVALID_FORMAT_ERROR.
+     * @param status the error code
+     * @return the double value of this object.
+     * @stable ICU 3.0
+     */
+    double          getDouble(UErrorCode& status) const;
+
+    /**
+     * Gets the long value of this object. If this object is not of type
+     * kLong then the result is undefined.
+     * @return    the long value of this object.
+     * @stable ICU 2.0
+     */
+    int32_t         getLong(void) const { return (int32_t)fValue.fInt64; }
+
+    /**
+     * Gets the long value of this object. If the magnitude is too
+     * large to fit in a long, then the maximum or minimum long value,
+     * as appropriate, is returned and the status is set to
+     * U_INVALID_FORMAT_ERROR.  If this object is of type kInt64 and
+     * it fits within a long, then no precision is lost.  If it is of
+     * type kDouble, then a conversion is peformed, with
+     * truncation of any fractional part.  If the type is kObject and
+     * the object is a Measure, then the result of
+     * getNumber().getLong(status) is returned.  If this object is
+     * neither a numeric type nor a Measure, then 0 is returned and
+     * the status is set to U_INVALID_FORMAT_ERROR.
+     * @param status the error code
+     * @return    the long value of this object.
+     * @stable ICU 3.0
+     */
+    int32_t         getLong(UErrorCode& status) const;
+
+    /**
+     * Gets the int64 value of this object. If this object is not of type
+     * kInt64 then the result is undefined.
+     * @return    the int64 value of this object.
+     * @stable ICU 2.8
+     */
+    int64_t         getInt64(void) const { return fValue.fInt64; }
+
+    /**
+     * Gets the int64 value of this object. If this object is of a numeric
+     * type and the magnitude is too large to fit in an int64, then
+     * the maximum or minimum int64 value, as appropriate, is returned
+     * and the status is set to U_INVALID_FORMAT_ERROR.  If the
+     * magnitude fits in an int64, then a casting conversion is
+     * peformed, with truncation of any fractional part.  If the type
+     * is kObject and the object is a Measure, then the result of
+     * getNumber().getDouble(status) is returned.  If this object is
+     * neither a numeric type nor a Measure, then 0 is returned and
+     * the status is set to U_INVALID_FORMAT_ERROR.
+     * @param status the error code
+     * @return    the int64 value of this object.
+     * @stable ICU 3.0
+     */
+    int64_t         getInt64(UErrorCode& status) const;
+
+    /**
+     * Gets the Date value of this object. If this object is not of type
+     * kDate then the result is undefined.
+     * @return    the Date value of this object.
+     * @stable ICU 2.0
+     */
+    UDate           getDate() const { return fValue.fDate; }
+
+    /**
+     * Gets the Date value of this object.  If the type is not a date,
+     * status is set to U_INVALID_FORMAT_ERROR and the return value is
+     * undefined.
+     * @param status the error code.
+     * @return    the Date value of this object.
+     * @stable ICU 3.0
+     */
+     UDate          getDate(UErrorCode& status) const;
+
+    /**
+     * Gets the string value of this object. If this object is not of type
+     * kString then the result is undefined.
+     * @param result    Output param to receive the Date value of this object.
+     * @return          A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getString(UnicodeString& result) const
+      { result=*fValue.fString; return result; }
+
+    /**
+     * Gets the string value of this object. If the type is not a
+     * string, status is set to U_INVALID_FORMAT_ERROR and a bogus
+     * string is returned.
+     * @param result    Output param to receive the Date value of this object.
+     * @param status    the error code.
+     * @return          A reference to 'result'.
+     * @stable ICU 3.0
+     */
+    UnicodeString&  getString(UnicodeString& result, UErrorCode& status) const;
+
+    /**
+     * Gets a const reference to the string value of this object. If
+     * this object is not of type kString then the result is
+     * undefined.
+     * @return   a const reference to the string value of this object.
+     * @stable ICU 2.0
+     */
+    inline const UnicodeString& getString(void) const;
+
+    /**
+     * Gets a const reference to the string value of this object.  If
+     * the type is not a string, status is set to
+     * U_INVALID_FORMAT_ERROR and the result is a bogus string.
+     * @param status    the error code.
+     * @return   a const reference to the string value of this object.
+     * @stable ICU 3.0
+     */
+    const UnicodeString& getString(UErrorCode& status) const;
+
+    /**
+     * Gets a reference to the string value of this object. If this
+     * object is not of type kString then the result is undefined.
+     * @return   a reference to the string value of this object.
+     * @stable ICU 2.0
+     */
+    inline UnicodeString& getString(void);
+
+    /**
+     * Gets a reference to the string value of this object. If the
+     * type is not a string, status is set to U_INVALID_FORMAT_ERROR
+     * and the result is a bogus string.
+     * @param status    the error code.
+     * @return   a reference to the string value of this object.
+     * @stable ICU 3.0
+     */
+    UnicodeString& getString(UErrorCode& status);
+
+    /**
+     * Gets the array value and count of this object. If this object
+     * is not of type kArray then the result is undefined.
+     * @param count    fill-in with the count of this object.
+     * @return         the array value of this object.
+     * @stable ICU 2.0
+     */
+    const Formattable* getArray(int32_t& count) const
+      { count=fValue.fArrayAndCount.fCount; return fValue.fArrayAndCount.fArray; }
+
+    /**
+     * Gets the array value and count of this object. If the type is
+     * not an array, status is set to U_INVALID_FORMAT_ERROR, count is
+     * set to 0, and the result is NULL.
+     * @param count    fill-in with the count of this object.
+     * @param status the error code.
+     * @return         the array value of this object.
+     * @stable ICU 3.0
+     */
+    const Formattable* getArray(int32_t& count, UErrorCode& status) const;
+
+    /**
+     * Accesses the specified element in the array value of this
+     * Formattable object. If this object is not of type kArray then
+     * the result is undefined.
+     * @param index the specified index.
+     * @return the accessed element in the array.
+     * @stable ICU 2.0
+     */
+    Formattable&    operator[](int32_t index) { return fValue.fArrayAndCount.fArray[index]; }
+
+    /**
+     * Returns a pointer to the UObject contained within this
+     * formattable, or NULL if this object does not contain a UObject.
+     * @return a UObject pointer, or NULL
+     * @stable ICU 3.0
+     */
+    const UObject*  getObject() const;
+
+    /**
+     * Returns a numeric string representation of the number contained within this
+     * formattable, or NULL if this object does not contain numeric type.
+     * For values obtained by parsing, the returned decimal number retains
+     * the full precision and range of the original input, unconstrained by
+     * the limits of a double floating point or a 64 bit int.
+     *
+     * This function is not thread safe, and therfore is not declared const,
+     * even though it is logically const.
+     *
+     * Possible errors include U_MEMORY_ALLOCATION_ERROR, and
+     * U_INVALID_STATE if the formattable object has not been set to
+     * a numeric type.
+     *
+     * @param status the error code.
+     * @return the unformatted string representation of a number.
+     * @stable ICU 4.4
+     */
+    StringPiece getDecimalNumber(UErrorCode &status);
+
+     /**
+     * Sets the double value of this object and changes the type to
+     * kDouble.
+     * @param d    the new double value to be set.
+     * @stable ICU 2.0
+     */
+    void            setDouble(double d);
+
+    /**
+     * Sets the long value of this object and changes the type to
+     * kLong.
+     * @param l    the new long value to be set.
+     * @stable ICU 2.0
+     */
+    void            setLong(int32_t l);
+
+    /**
+     * Sets the int64 value of this object and changes the type to
+     * kInt64.
+     * @param ll    the new int64 value to be set.
+     * @stable ICU 2.8
+     */
+    void            setInt64(int64_t ll);
+
+    /**
+     * Sets the Date value of this object and changes the type to
+     * kDate.
+     * @param d    the new Date value to be set.
+     * @stable ICU 2.0
+     */
+    void            setDate(UDate d);
+
+    /**
+     * Sets the string value of this object and changes the type to
+     * kString.
+     * @param stringToCopy    the new string value to be set.
+     * @stable ICU 2.0
+     */
+    void            setString(const UnicodeString& stringToCopy);
+
+    /**
+     * Sets the array value and count of this object and changes the
+     * type to kArray.
+     * @param array    the array value.
+     * @param count    the number of array elements to be copied.
+     * @stable ICU 2.0
+     */
+    void            setArray(const Formattable* array, int32_t count);
+
+    /**
+     * Sets and adopts the string value and count of this object and
+     * changes the type to kArray.
+     * @param stringToAdopt    the new string value to be adopted.
+     * @stable ICU 2.0
+     */
+    void            adoptString(UnicodeString* stringToAdopt);
+
+    /**
+     * Sets and adopts the array value and count of this object and
+     * changes the type to kArray.
+     * @stable ICU 2.0
+     */
+    void            adoptArray(Formattable* array, int32_t count);
+
+    /**
+     * Sets and adopts the UObject value of this object and changes
+     * the type to kObject.  After this call, the caller must not
+     * delete the given object.
+     * @param objectToAdopt the UObject value to be adopted
+     * @stable ICU 3.0
+     */
+    void            adoptObject(UObject* objectToAdopt);
+
+    /**
+     * Sets the the numeric value from a decimal number string, and changes
+     * the type to to a numeric type appropriate for the number.
+     * The syntax of the number is a "numeric string"
+     * as defined in the Decimal Arithmetic Specification, available at
+     * http://speleotrove.com/decimal
+     * The full precision and range of the input number will be retained,
+     * even when it exceeds what can be represented by a double or an int64.
+     *
+     * @param numberString  a string representation of the unformatted decimal number.
+     * @param status        the error code.  Set to U_INVALID_FORMAT_ERROR if the
+     *                      incoming string is not a valid decimal number.
+     * @stable ICU 4.4
+     */
+    void             setDecimalNumber(const StringPiece &numberString,
+                                      UErrorCode &status);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * Convert the UFormattable to a Formattable.  Internally, this is a reinterpret_cast.
+     * @param fmt a valid UFormattable
+     * @return the UFormattable as a Formattable object pointer.  This is an alias to the original
+     * UFormattable, and so is only valid while the original argument remains in scope.
+     * @stable ICU 52
+     */
+    static inline Formattable *fromUFormattable(UFormattable *fmt);
+
+    /**
+     * Convert the const UFormattable to a const Formattable.  Internally, this is a reinterpret_cast.
+     * @param fmt a valid UFormattable
+     * @return the UFormattable as a Formattable object pointer.  This is an alias to the original
+     * UFormattable, and so is only valid while the original argument remains in scope.
+     * @stable ICU 52
+     */
+    static inline const Formattable *fromUFormattable(const UFormattable *fmt);
+
+    /**
+     * Convert this object pointer to a UFormattable.
+     * @return this object as a UFormattable pointer.   This is an alias to this object,
+     * and so is only valid while this object remains in scope.
+     * @stable ICU 52
+     */
+    inline UFormattable *toUFormattable();
+
+    /**
+     * Convert this object pointer to a UFormattable.
+     * @return this object as a UFormattable pointer.   This is an alias to this object,
+     * and so is only valid while this object remains in scope.
+     * @stable ICU 52
+     */
+    inline const UFormattable *toUFormattable() const;
+
+#ifndef U_HIDE_DEPRECATED_API
+    /**
+     * Deprecated variant of getLong(UErrorCode&).
+     * @param status the error code
+     * @return the long value of this object.
+     * @deprecated ICU 3.0 use getLong(UErrorCode&) instead
+     */
+    inline int32_t getLong(UErrorCode* status) const;
+#endif  /* U_HIDE_DEPRECATED_API */
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * Internal function, do not use.
+     * TODO:  figure out how to make this be non-public.
+     *        NumberFormat::format(Formattable, ...
+     *        needs to get at the DigitList, if it exists, for
+     *        big decimal formatting.
+     *  @internal
+     */
+    DigitList *getDigitList() const { return fDecimalNum;}
+
+    /**
+     *  @internal
+     */
+    DigitList *getInternalDigitList();
+
+    /**
+     *  Adopt, and set value from, a DigitList
+     *     Internal Function, do not use.
+     *  @param dl the Digit List to be adopted
+     *  @internal
+     */
+    void adoptDigitList(DigitList *dl);
+
+    /**
+     * Internal function to return the CharString pointer.
+     * @param status error code
+     * @return pointer to the CharString - may become invalid if the object is modified
+     * @internal
+     */
+    CharString *internalGetCharString(UErrorCode &status);
+
+#endif  /* U_HIDE_INTERNAL_API */
+
+private:
+    /**
+     * Cleans up the memory for unwanted values.  For example, the adopted
+     * string or array objects.
+     */
+    void            dispose(void);
+
+    /**
+     * Common initialization, for use by constructors.
+     */
+    void            init();
+
+    UnicodeString* getBogus() const;
+
+    union {
+        UObject*        fObject;
+        UnicodeString*  fString;
+        double          fDouble;
+        int64_t         fInt64;
+        UDate           fDate;
+        struct {
+          Formattable*  fArray;
+          int32_t       fCount;
+        }               fArrayAndCount;
+    } fValue;
+
+    CharString           *fDecimalStr;
+
+    DigitList            *fDecimalNum;
+
+    char                fStackData[UNUM_INTERNAL_STACKARRAY_SIZE]; // must be big enough for DigitList
+
+    Type                fType;
+    UnicodeString       fBogus; // Bogus string when it's needed.
+};
+
+inline UDate Formattable::getDate(UErrorCode& status) const {
+    if (fType != kDate) {
+        if (U_SUCCESS(status)) {
+            status = U_INVALID_FORMAT_ERROR;
+        }
+        return 0;
+    }
+    return fValue.fDate;
+}
+
+inline const UnicodeString& Formattable::getString(void) const {
+    return *fValue.fString;
+}
+
+inline UnicodeString& Formattable::getString(void) {
+    return *fValue.fString;
+}
+
+#ifndef U_HIDE_DEPRECATED_API
+inline int32_t Formattable::getLong(UErrorCode* status) const {
+    return getLong(*status);
+}
+#endif  /* U_HIDE_DEPRECATED_API */
+
+inline UFormattable* Formattable::toUFormattable() {
+  return reinterpret_cast<UFormattable*>(this);
+}
+
+inline const UFormattable* Formattable::toUFormattable() const {
+  return reinterpret_cast<const UFormattable*>(this);
+}
+
+inline Formattable* Formattable::fromUFormattable(UFormattable *fmt) {
+  return reinterpret_cast<Formattable *>(fmt);
+}
+
+inline const Formattable* Formattable::fromUFormattable(const UFormattable *fmt) {
+  return reinterpret_cast<const Formattable *>(fmt);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif //_FMTABLE
+//eof

+ 305 - 0
sqlite/unicode/format.h

@@ -0,0 +1,305 @@
+/*
+********************************************************************************
+* Copyright (C) 1997-2011, International Business Machines Corporation and others.
+* All Rights Reserved.
+********************************************************************************
+*
+* File FORMAT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/17/97    clhuang     Updated per C++ implementation.
+*   03/27/97    helena      Updated to pass the simple test after code review.
+********************************************************************************
+*/
+// *****************************************************************************
+// This file was generated from the java source file Format.java
+// *****************************************************************************
+
+#ifndef FORMAT_H
+#define FORMAT_H
+
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Base class for all formats. 
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/unistr.h"
+#include "unicode/fmtable.h"
+#include "unicode/fieldpos.h"
+#include "unicode/fpositer.h"
+#include "unicode/parsepos.h"
+#include "unicode/parseerr.h" 
+#include "unicode/locid.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Base class for all formats.  This is an abstract base class which
+ * specifies the protocol for classes which convert other objects or
+ * values, such as numeric values and dates, and their string
+ * representations.  In some cases these representations may be
+ * localized or contain localized characters or strings.  For example,
+ * a numeric formatter such as DecimalFormat may convert a numeric
+ * value such as 12345 to the string "$12,345".  It may also parse
+ * the string back into a numeric value.  A date and time formatter
+ * like SimpleDateFormat may represent a specific date, encoded
+ * numerically, as a string such as "Wednesday, February 26, 1997 AD".
+ * <P>
+ * Many of the concrete subclasses of Format employ the notion of
+ * a pattern.  A pattern is a string representation of the rules which
+ * govern the interconversion between values and strings.  For example,
+ * a DecimalFormat object may be associated with the pattern
+ * "$#,##0.00;($#,##0.00)", which is a common US English format for
+ * currency values, yielding strings such as "$1,234.45" for 1234.45,
+ * and "($987.65)" for 987.6543.  The specific syntax of a pattern
+ * is defined by each subclass.
+ * <P>
+ * Even though many subclasses use patterns, the notion of a pattern
+ * is not inherent to Format classes in general, and is not part of
+ * the explicit base class protocol.
+ * <P>
+ * Two complex formatting classes bear mentioning.  These are
+ * MessageFormat and ChoiceFormat.  ChoiceFormat is a subclass of
+ * NumberFormat which allows the user to format different number ranges
+ * as strings.  For instance, 0 may be represented as "no files", 1 as
+ * "one file", and any number greater than 1 as "many files".
+ * MessageFormat is a formatter which utilizes other Format objects to
+ * format a string containing with multiple values.  For instance,
+ * A MessageFormat object might produce the string "There are no files
+ * on the disk MyDisk on February 27, 1997." given the arguments 0,
+ * "MyDisk", and the date value of 2/27/97.  See the ChoiceFormat
+ * and MessageFormat headers for further information.
+ * <P>
+ * If formatting is unsuccessful, a failing UErrorCode is returned when
+ * the Format cannot format the type of object, otherwise if there is
+ * something illformed about the the Unicode replacement character
+ * 0xFFFD is returned.
+ * <P>
+ * If there is no match when parsing, a parse failure UErrorCode is
+ * retured for methods which take no ParsePosition.  For the method
+ * that takes a ParsePosition, the index parameter is left unchanged.
+ * <P>
+ * <em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API Format : public UObject {
+public:
+
+    /** Destructor
+     * @stable ICU 2.4
+     */
+    virtual ~Format();
+
+    /**
+     * Return true if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     * @param other    the object to be compared with.
+     * @return         Return true if the given Format objects are semantically equal.
+     *                 Objects of different subclasses are considered unequal.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format& other) const = 0;
+
+    /**
+     * Return true if the given Format objects are not semantically
+     * equal.
+     * @param other    the object to be compared with.
+     * @return         Return true if the given Format objects are not semantically.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const Format& other) const { return !operator==(other); }
+
+    /**
+     * Clone this object polymorphically.  The caller is responsible
+     * for deleting the result when done.
+     * @return    A copy of the object
+     * @stable ICU 2.0
+     */
+    virtual Format* clone() const = 0;
+
+    /**
+     * Formats an object to produce a string.
+     *
+     * @param obj       The object to format.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Output parameter filled in with success or failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(const Formattable& obj,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+
+    /**
+     * Format an object to produce a string.  This is a pure virtual method which
+     * subclasses must implement. This method allows polymorphic formatting
+     * of Formattable objects. If a subclass of Format receives a Formattable
+     * object type it doesn't handle (e.g., if a numeric Formattable is passed
+     * to a DateFormat object) then it returns a failing UErrorCode.
+     *
+     * @param obj       The object to format.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const = 0;
+    /**
+     * Format an object to produce a string.  Subclasses should override this
+     * method. This method allows polymorphic formatting of Formattable objects.
+     * If a subclass of Format receives a Formattable object type it doesn't
+     * handle (e.g., if a numeric Formattable is passed to a DateFormat object)
+     * then it returns a failing UErrorCode.
+     *
+     * @param obj       The object to format.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param posIter   On return, can be used to iterate over positions
+     *                  of fields generated by this format call.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 4.4
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPositionIterator* posIter,
+                                  UErrorCode& status) const;
+
+    /**
+     * Parse a string to produce an object.  This is a pure virtual
+     * method which subclasses must implement.  This method allows
+     * polymorphic parsing of strings into Formattable objects.
+     * <P>
+     * Before calling, set parse_pos.index to the offset you want to
+     * start parsing at in the source.  After calling, parse_pos.index
+     * is the end of the text you parsed.  If error occurs, index is
+     * unchanged.
+     * <P>
+     * When parsing, leading whitespace is discarded (with successful
+     * parse), while trailing whitespace is left as is.
+     * <P>
+     * Example:
+     * <P>
+     * Parsing "_12_xy" (where _ represents a space) for a number,
+     * with index == 0 will result in the number 12, with
+     * parse_pos.index updated to 3 (just before the second space).
+     * Parsing a second time will result in a failing UErrorCode since
+     * "xy" is not a number, and leave index at 3.
+     * <P>
+     * Subclasses will typically supply specific parse methods that
+     * return different types of values. Since methods can't overload
+     * on return types, these will typically be named "parse", while
+     * this polymorphic method will always be called parseObject.  Any
+     * parse method that does not take a parse_pos should set status
+     * to an error value when no text in the required format is at the
+     * start position.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param parse_pos The position to start parsing at. Upon return
+     *                  this param is set to the position after the
+     *                  last character successfully parsed. If the
+     *                  source is not parsed successfully, this param
+     *                  will remain unchanged.
+     * @stable ICU 2.0
+     */
+    virtual void parseObject(const UnicodeString& source,
+                             Formattable& result,
+                             ParsePosition& parse_pos) const = 0;
+
+    /**
+     * Parses a string to produce an object. This is a convenience method
+     * which calls the pure virtual parseObject() method, and returns a
+     * failure UErrorCode if the ParsePosition indicates failure.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param status    Output param to be filled with success/failure
+     *                  result code.
+     * @stable ICU 2.0
+     */
+    void parseObject(const UnicodeString& source,
+                     Formattable& result,
+                     UErrorCode& status) const;
+
+    /** Get the locale for this format object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual) 
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+#ifndef U_HIDE_INTERNAL_API
+    /** Get the locale for this format object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual) 
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @internal
+     */
+    const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
+#endif  /* U_HIDE_INTERNAL_API */
+
+ protected:
+    /** @stable ICU 2.8 */
+    void setLocaleIDs(const char* valid, const char* actual);
+
+protected:
+    /**
+     * Default constructor for subclass use only.  Does nothing.
+     * @stable ICU 2.0
+     */
+    Format();
+
+    /**
+     * @stable ICU 2.0
+     */
+    Format(const Format&); // Does nothing; for subclasses only
+
+    /**
+     * @stable ICU 2.0
+     */
+    Format& operator=(const Format&); // Does nothing; for subclasses
+
+       
+    /**
+     * Simple function for initializing a UParseError from a UnicodeString.
+     *
+     * @param pattern The pattern to copy into the parseError
+     * @param pos The position in pattern where the error occured
+     * @param parseError The UParseError object to fill in
+     * @stable ICU 2.4
+     */
+    static void syntaxError(const UnicodeString& pattern,
+                            int32_t pos,
+                            UParseError& parseError);
+
+ private:
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _FORMAT
+//eof

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor