コード例 #1
0
        private static bool IsPrecededByWhitespace(ref TextPtr ptr)
        {
            TextPtr ptr2 = ptr - 1;
            char    c    = ptr2.Char;

            return(ptr2.IsOutOfBounds() || (char.IsWhiteSpace(c) || !char.IsLetterOrDigit(c)));
        }
コード例 #2
0
        private static bool IsPrecededByWhitespace(ref TextPtr ptr)
        {
            TextPtr ptr2 = ptr - 1;
            char    c    = ptr2.Char;

            if (!ptr2.IsOutOfBounds() && !char.IsWhiteSpace(c))
            {
                return(!char.IsLetterOrDigit(c));
            }
            return(true);
        }
コード例 #3
0
        public static void FindAll(string source, List <MyWaypointInfo> gpsList)
        {
            TextPtr ptr = new TextPtr(source);

            gpsList.Clear();
            while (!ptr.IsOutOfBounds())
            {
                MyWaypointInfo info;
                if (((char.ToUpperInvariant(ptr.Char) != 'G') || !IsPrecededByWhitespace(ref ptr)) || !TryParse(ref ptr, out info))
                {
                    ptr += 1;
                    continue;
                }
                gpsList.Add(info);
            }
        }
コード例 #4
0
        public static bool TryParse(string text, out MyWaypointInfo gps)
        {
            if (text == null)
            {
                gps = Empty;
                return(false);
            }
            TextPtr ptr  = new TextPtr(text);
            bool    flag = TryParse(ref ptr, out gps);

            if (flag && !ptr.IsOutOfBounds())
            {
                gps = Empty;
                return(false);
            }
            return(flag);
        }
コード例 #5
0
        public static void FindAll(string source, List <MyWaypointInfo> gpsList)
        {
            TextPtr ptr = new TextPtr(source);

            gpsList.Clear();
            while (!ptr.IsOutOfBounds())
            {
                MyWaypointInfo info;
                if (((char.ToUpperInvariant(ptr.Char) == 'G') && IsPrecededByWhitespace(ref ptr)) && TryParse(ref ptr, out info))
                {
                    gpsList.Add(info);
                }
                else
                {
                    ptr = TextPtr.op_Increment(ptr);
                }
            }
        }
コード例 #6
0
        private static bool GrabSegment(ref TextPtr ptr, out StringSegment segment)
        {
            if (ptr.IsOutOfBounds())
            {
                segment = new StringSegment();
                return(false);
            }
            TextPtr ptr2 = ptr;

            while (!ptr.IsOutOfBounds() && (ptr.Char != ':'))
            {
                ptr = TextPtr.op_Increment(ptr);
            }
            if (ptr.Char != ':')
            {
                segment = new StringSegment();
                return(false);
            }
            segment = new StringSegment(ptr2.Content, ptr2.Index, ptr.Index - ptr2.Index);
            ptr     = TextPtr.op_Increment(ptr);
            return(true);
        }
コード例 #7
0
        private static bool TryParse(ref TextPtr ptr, out MyWaypointInfo gps)
        {
            StringSegment segment;
            StringSegment segment2;
            StringSegment segment3;
            StringSegment segment4;

            while (char.IsWhiteSpace(ptr.Char))
            {
                ptr = TextPtr.op_Increment(ptr);
            }
            if (!ptr.StartsWithCaseInsensitive("gps:"))
            {
                gps = Empty;
                return(false);
            }
            ptr += 4;
            if (!GrabSegment(ref ptr, out segment))
            {
                gps = Empty;
                return(false);
            }
            if (!GrabSegment(ref ptr, out segment2))
            {
                gps = Empty;
                return(false);
            }
            if (!GrabSegment(ref ptr, out segment3))
            {
                gps = Empty;
                return(false);
            }
            if (GrabSegment(ref ptr, out segment4))
            {
                double num;
                double num2;
                double num3;
                while (char.IsWhiteSpace(ptr.Char))
                {
                    ptr = TextPtr.op_Increment(ptr);
                }
                if (!double.TryParse(segment2.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out num))
                {
                    gps = Empty;
                    return(false);
                }
                if (!double.TryParse(segment3.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out num2))
                {
                    gps = Empty;
                    return(false);
                }
                if (!double.TryParse(segment4.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out num3))
                {
                    gps = Empty;
                    return(false);
                }
                string name = segment.ToString();
                gps = new MyWaypointInfo(name, num, num2, num3);
                return(true);
            }
            gps = Empty;
            return(false);
        }