示例#1
0
文件: Trie.cs 项目: introfog/ICU4N
        // protected constructor -------------------------------------------

        /// <summary>
        /// Trie constructor for <see cref="CharTrie"/> use.
        /// </summary>
        /// <param name="bytes">Data of an ICU data file, containing the trie.</param>
        /// <param name="dataManipulate">Object containing the information to parse the trie data.</param>
        protected Trie(ByteBuffer bytes, ITrieDataManipulate dataManipulate) // ICU4N TODO: API Change to use byte[]
        {
            // Magic number to authenticate the data.
            int signature = bytes.GetInt32();

            m_options_ = bytes.GetInt32();

            if (!CheckHeader(signature))
            {
                throw new ArgumentException("ICU data file error: Trie header authentication failed, please check if you have the most updated ICU data file");
            }

            if (dataManipulate != null)
            {
                m_dataManipulate = dataManipulate;
            }
            else
            {
                m_dataManipulate = new DefaultGetFoldingOffset();
            }
            m_isLatin1Linear_ = (m_options_ &
                                 HeaderOptionsLatin1IsLinearMask) != 0;
            m_dataOffset = bytes.GetInt32();
            m_dataLength = bytes.GetInt32();
            Unserialize(bytes);
        }
示例#2
0
        // protected constructor -------------------------------------------

        /// <summary>
        /// Trie constructor for <see cref="CharTrie"/> use.
        /// </summary>
        /// <param name="bytes">Data of an ICU data file, containing the trie.</param>
        /// <param name="dataManipulate">Object containing the information to parse the trie data.</param>
        protected Trie(ByteBuffer bytes, IDataManipulate dataManipulate)
        {
            // Magic number to authenticate the data.
            int signature = bytes.GetInt32();

            m_options_ = bytes.GetInt32();

            if (!CheckHeader(signature))
            {
                throw new ArgumentException("ICU data file error: Trie header authentication failed, please check if you have the most updated ICU data file");
            }

            if (dataManipulate != null)
            {
                m_dataManipulate_ = dataManipulate;
            }
            else
            {
                m_dataManipulate_ = new DefaultGetFoldingOffset();
            }
            m_isLatin1Linear_ = (m_options_ &
                                 HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_) != 0;
            m_dataOffset_ = bytes.GetInt32();
            m_dataLength_ = bytes.GetInt32();
            Unserialize(bytes);
        }
示例#3
0
文件: Trie.cs 项目: introfog/ICU4N
 /// <summary>
 /// Trie constructor.
 /// </summary>
 /// <param name="index">Array to be used for index.</param>
 /// <param name="options">Options used by the trie.</param>
 /// <param name="dataManipulate">Object containing the information to parse the trie data.</param>
 protected Trie(char[] index, int options, ITrieDataManipulate dataManipulate) // ICU4N TODO: API - change to use [Flags] enum for options ?
 {
     m_options_ = options;
     if (dataManipulate != null)
     {
         m_dataManipulate = dataManipulate;
     }
     else
     {
         m_dataManipulate = new DefaultGetFoldingOffset();
     }
     m_isLatin1Linear_ = (m_options_ &
                          HeaderOptionsLatin1IsLinearMask) != 0;
     m_index      = index;
     m_dataOffset = m_index.Length;
 }
示例#4
0
 /// <summary>
 /// Trie constructor.
 /// </summary>
 /// <param name="index">Array to be used for index.</param>
 /// <param name="options">Options used by the trie.</param>
 /// <param name="dataManipulate">Object containing the information to parse the trie data.</param>
 protected Trie(char[] index, int options, IDataManipulate dataManipulate) // ICU4N TODO: API - change to use [Flags] enum for options ?
 {
     m_options_ = options;
     if (dataManipulate != null)
     {
         m_dataManipulate_ = dataManipulate;
     }
     else
     {
         m_dataManipulate_ = new DefaultGetFoldingOffset();
     }
     m_isLatin1Linear_ = (m_options_ &
                          HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_) != 0;
     m_index_      = index;
     m_dataOffset_ = m_index_.Length;
 }