• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 *******************************************************************************
3 * Copyright (C) 2013-2014, International Business Machines
4 * Corporation and others.  All Rights Reserved.
5 *******************************************************************************
6 * collationinfo.cpp
7 *
8 * created on: 2013aug05
9 * created by: Markus W. Scherer
10 */
11 
12 #include <stdio.h>
13 #include <string.h>
14 
15 #include "unicode/utypes.h"
16 
17 #if !UCONFIG_NO_COLLATION
18 
19 #include "collationdatareader.h"
20 #include "collationinfo.h"
21 #include "uassert.h"
22 
23 U_NAMESPACE_BEGIN
24 
25 void
printSizes(int32_t sizeWithHeader,const int32_t indexes[])26 CollationInfo::printSizes(int32_t sizeWithHeader, const int32_t indexes[]) {
27     int32_t totalSize = indexes[CollationDataReader::IX_TOTAL_SIZE];
28     if(sizeWithHeader > totalSize) {
29         printf("  header size:                  %6ld\n", (long)(sizeWithHeader - totalSize));
30     }
31 
32     int32_t length = indexes[CollationDataReader::IX_INDEXES_LENGTH];
33     printf("  indexes:          %6ld *4 = %6ld\n", (long)length, (long)length * 4);
34 
35     length = getDataLength(indexes, CollationDataReader::IX_REORDER_CODES_OFFSET);
36     if(length != 0) {
37         printf("  reorder codes:    %6ld *4 = %6ld\n", (long)length / 4, (long)length);
38     }
39 
40     length = getDataLength(indexes, CollationDataReader::IX_REORDER_TABLE_OFFSET);
41     if(length != 0) {
42         U_ASSERT(length >= 256);
43         printf("  reorder table:                %6ld\n", (long)length);
44     }
45 
46     length = getDataLength(indexes, CollationDataReader::IX_TRIE_OFFSET);
47     if(length != 0) {
48         printf("  trie size:                    %6ld\n", (long)length);
49     }
50 
51     length = getDataLength(indexes, CollationDataReader::IX_RESERVED8_OFFSET);
52     if(length != 0) {
53         printf("  reserved (offset 8):          %6ld\n", (long)length);
54     }
55 
56     length = getDataLength(indexes, CollationDataReader::IX_CES_OFFSET);
57     if(length != 0) {
58         printf("  CEs:              %6ld *8 = %6ld\n", (long)length / 8, (long)length);
59     }
60 
61     length = getDataLength(indexes, CollationDataReader::IX_RESERVED10_OFFSET);
62     if(length != 0) {
63         printf("  reserved (offset 10):         %6ld\n", (long)length);
64     }
65 
66     length = getDataLength(indexes, CollationDataReader::IX_CE32S_OFFSET);
67     if(length != 0) {
68         printf("  CE32s:            %6ld *4 = %6ld\n", (long)length / 4, (long)length);
69     }
70 
71     length = getDataLength(indexes, CollationDataReader::IX_ROOT_ELEMENTS_OFFSET);
72     if(length != 0) {
73         printf("  rootElements:     %6ld *4 = %6ld\n", (long)length / 4, (long)length);
74     }
75 
76     length = getDataLength(indexes, CollationDataReader::IX_CONTEXTS_OFFSET);
77     if(length != 0) {
78         printf("  contexts:         %6ld *2 = %6ld\n", (long)length / 2, (long)length);
79     }
80 
81     length = getDataLength(indexes, CollationDataReader::IX_UNSAFE_BWD_OFFSET);
82     if(length != 0) {
83         printf("  unsafeBwdSet:     %6ld *2 = %6ld\n", (long)length / 2, (long)length);
84     }
85 
86     length = getDataLength(indexes, CollationDataReader::IX_FAST_LATIN_TABLE_OFFSET);
87     if(length != 0) {
88         printf("  fastLatin table:  %6ld *2 = %6ld\n", (long)length / 2, (long)length);
89     }
90 
91     length = getDataLength(indexes, CollationDataReader::IX_SCRIPTS_OFFSET);
92     if(length != 0) {
93         printf("  scripts data:     %6ld *2 = %6ld\n", (long)length / 2, (long)length);
94     }
95 
96     length = getDataLength(indexes, CollationDataReader::IX_COMPRESSIBLE_BYTES_OFFSET);
97     if(length != 0) {
98         U_ASSERT(length >= 256);
99         printf("  compressibleBytes:            %6ld\n", (long)length);
100     }
101 
102     length = getDataLength(indexes, CollationDataReader::IX_RESERVED18_OFFSET);
103     if(length != 0) {
104         printf("  reserved (offset 18):         %6ld\n", (long)length);
105     }
106 
107     printf(" collator binary total size:    %6ld\n", (long)sizeWithHeader);
108 }
109 
110 int32_t
getDataLength(const int32_t indexes[],int32_t startIndex)111 CollationInfo::getDataLength(const int32_t indexes[], int32_t startIndex) {
112     return indexes[startIndex + 1] - indexes[startIndex];
113 }
114 
115 U_NAMESPACE_END
116 
117 #endif  // !UCONFIG_NO_COLLATION
118