コード例 #1
0
        ///CLOVER:ON

        ///// protected methods -----------------------------------------------

        /// <summary>
        /// Parses the input stream and stores its trie content into a index and
        /// data array
        /// </summary>
        /// <param name="bytes">Data buffer containing trie data.</param>
        protected override sealed void Unserialize(ByteBuffer bytes)
        {
            base.Unserialize(bytes);
            // one used for initial value
            m_data_         = ICUBinary.GetInts(bytes, m_dataLength_, 0);
            m_initialValue_ = m_data_[0];
        }
コード例 #2
0
ファイル: UBiDiProps.cs プロジェクト: SilentCC/ICU4N
        private void ReadData(ByteBuffer bytes)
        {
            // read the header
            ICUBinary.ReadHeader(bytes, FMT, new IsAcceptable());

            // read indexes[]
            int i, count;

            count = bytes.GetInt32();
            if (count < IX_TOP)
            {
                throw new IOException("indexes[0] too small in " + DATA_FILE_NAME);
            }
            indexes = new int[count];

            indexes[0] = count;
            for (i = 1; i < count; ++i)
            {
                indexes[i] = bytes.GetInt32();
            }

            // read the trie
            trie = Trie2_16.CreateFromSerialized(bytes);
            int expectedTrieLength = indexes[IX_TRIE_SIZE];
            int trieLength         = trie.GetSerializedLength();

            if (trieLength > expectedTrieLength)
            {
                throw new IOException(DATA_FILE_NAME + ": not enough bytes for the trie");
            }
            // skip padding after trie bytes
            ICUBinary.SkipBytes(bytes, expectedTrieLength - trieLength);

            // read mirrors[]
            count = indexes[IX_MIRROR_LENGTH];
            if (count > 0)
            {
                mirrors = ICUBinary.GetInts(bytes, count, 0);
            }

            // read jgArray[]
            count   = indexes[IX_JG_LIMIT] - indexes[IX_JG_START];
            jgArray = new byte[count];
            bytes.Get(jgArray);

            // read jgArray2[]
            count    = indexes[IX_JG_LIMIT2] - indexes[IX_JG_START2];
            jgArray2 = new byte[count];
            bytes.Get(jgArray2);
        }
コード例 #3
0
ファイル: UPropertyAliases.cs プロジェクト: SilentCC/ICU4N
        private static readonly int DATA_FORMAT            = 0x706E616D; // "pnam"

        private void Load(ByteBuffer bytes)
        {
            //dataVersion=ICUBinary.readHeaderAndDataVersion(bytes, DATA_FORMAT, IS_ACCEPTABLE);
            ICUBinary.ReadHeader(bytes, DATA_FORMAT, IS_ACCEPTABLE);
            int indexesLength = bytes.GetInt32() / 4;  // inIndexes[IX_VALUE_MAPS_OFFSET]/4

            if (indexesLength < 8)
            {  // formatVersion 2 initially has 8 indexes
                throw new IOException("pnames.icu: not enough indexes");
            }
            int[]
            inIndexes = new int[indexesLength];
            inIndexes[0] = indexesLength * 4;
            for (int i = 1; i < indexesLength; ++i)
            {
                inIndexes[i] = bytes.GetInt32();
            }

            // Read the valueMaps.
            int offset     = inIndexes[IX_VALUE_MAPS_OFFSET];
            int nextOffset = inIndexes[IX_BYTE_TRIES_OFFSET];
            int numInts    = (nextOffset - offset) / 4;

            valueMaps = ICUBinary.GetInts(bytes, numInts, 0);

            // Read the bytesTries.
            offset     = nextOffset;
            nextOffset = inIndexes[IX_NAME_GROUPS_OFFSET];
            int numBytes = nextOffset - offset;

            bytesTries = new byte[numBytes];
            bytes.Get(bytesTries);

            // Read the nameGroups and turn them from ASCII bytes into a .NET string.
            offset     = nextOffset;
            nextOffset = inIndexes[IX_RESERVED3_OFFSET];
            numBytes   = nextOffset - offset;
            StringBuilder sb = new StringBuilder(numBytes);

            for (int i = 0; i < numBytes; ++i)
            {
                sb.Append((char)bytes.Get());
            }
            nameGroups = sb.ToString();
        }