Пример #1
0
        /// <summary>
        /// Attempts to read a Name predicate starting from the current position. The name predicate <b>must</b> be followed
        /// by a white space. If the Name predicate is succesfully parsed the function returns true and the <b>name</b>
        /// parameter will be intialized with the name read. If the predicate is nor recognized then the function returns false,
        /// <b>name</b> output parameter will have a value of <b>null</b> and the position will be restored to the current
        /// possition before the function was called. If the predicate is recognized and parsed the position remains on the
        /// white space immediately after the predicate.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected override unsafe bool ReadNamePredicate(out string name)
        {
            //[4]    NameChar    ::=    Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
            //[5]    Name        ::=    (Letter | '_' | ':') (NameChar)*

            name = null;

            long startPos = (long)m_RawDataPtr;

            if (!CharacterClasses.IsLetter(m_RawDataPtr) && *m_RawDataPtr != '_' && *m_RawDataPtr != ':')
            {
                // Restore the starting position as the parsing was unsuccesfull
                m_RawDataPtr = (char *)startPos;
                return(false);
            }


            if (ReadChar())
            {
                while (CharacterClasses.IsNameChar(m_RawDataPtr))
                {
                    if (!ReadChar())
                    {
                        // Restore the starting position as the parsing was unsuccesfull
                        m_RawDataPtr = (char *)startPos;
                        return(false);
                    }
                }

                name = GetParsedDataString((char *)startPos);
            }

            return(true);
        }