Ejemplo n.º 1
0
 public void CopyTest()
 {
     var str1 = new StrWithCursor("te");
     var str2 = new StrWithCursor(str1);
     str2++;
     Assert.AreEqual(true, str1 != str2);
 }
Ejemplo n.º 2
0
 public void EqualWithCharOperatorTest()
 {
     var str1 = new StrWithCursor("t");
     var symbol = 't';
     Assert.AreEqual(true, str1 == symbol);
     symbol = 'e';
     Assert.AreEqual(false, str1 == symbol);
 }
Ejemplo n.º 3
0
 public void EqualOperatorTest()
 {
     var str1 = new StrWithCursor("te");
     var str2 = new StrWithCursor("te");
     Assert.AreEqual(true,str1==str2);
     str2++;
     Assert.AreEqual(false, str1 == str2);
 }
Ejemplo n.º 4
0
 public void NonResultIncrementTest()
 {
     var str = new StrWithCursor("te");
     Assert.AreEqual('t', str.Value);
     str++;
     Assert.AreEqual('e', str.Value);
     str++;
     Assert.AreEqual('e', str.Value);
 }
Ejemplo n.º 5
0
 private void DeterminateTag(StrWithCursor pattern, StringBuilder tag)
 {
     do
     {
         tag.Append(pattern.Value);
         pattern++;
     }while (pattern != '>' && pattern != '*');
     tag.Append(pattern.Value);
     pattern++;
 }
Ejemplo n.º 6
0
        private void DeterminateNextTag(StrWithCursor fileName, StrWithCursor pattern, out Dictionary <FrameType, string> frames)
        {
            //TODO ::  Why do we need to use a copy constructor?
            fileName = new StrWithCursor(fileName);
            pattern  = new StrWithCursor(pattern);

            var tag   = new StringBuilder();                                 //Detreminated tag
            var value = new StringBuilder();                                 //Determinated value

            while (fileName != '*' && pattern != '*' && fileName == pattern) //Go to first different symbol
            {
                fileName++;
                pattern++;
            }

            if (pattern == '<')
            {
                DeterminateTag(pattern, tag);
            }
            else
            {
                frames = null;
                return; //If this is not tag - error => return null
            }

            while (fileName != '*' || pattern == '*')
            {
                if (pattern == fileName) //Maybe it first symbol after tag
                {
                    if (fileName == '*') //if end of string than this valid string
                    {
                        frames = new Dictionary <FrameType, string> {
                            { Frame.GetEnum(tag.ToString()), value.ToString() }
                        };                                                                                              //Create and eturn them
                        return;
                    }

                    DeterminateNextTag(fileName, pattern, out frames);               //If not end of string, determinate next
                    if (frames != null)                                              //If recusive method returned non-null dictionary its actualy end of tag
                    {
                        frames.Add(Frame.GetEnum(tag.ToString()), value.ToString()); //We should return them
                        return;
                    } //If returned null, then this not end of string. Continue reading
                }
                value.Append(fileName.Value);
                fileName++;
            }

            frames = null;
        }
Ejemplo n.º 7
0
        private void DeterminateNextTag(StrWithCursor fileName, StrWithCursor pattern, out Dictionary<FrameType, string> frames)
        {
            //TODO ::  Why do we need to use a copy constructor?
            fileName = new StrWithCursor(fileName);
            pattern = new StrWithCursor(pattern);

            var tag = new StringBuilder(); //Detreminated tag
            var value = new StringBuilder(); //Determinated value

            while(fileName != '*' && pattern != '*' && fileName == pattern) //Go to first different symbol
            {
                fileName++;
                pattern++;
            }

            if (pattern == '<')
                DeterminateTag(pattern, tag);
            else
            {
                frames = null;
                return; //If this is not tag - error => return null
            }

            while (fileName!='*' || pattern=='*')
            {
                if(pattern==fileName) //Maybe it first symbol after tag
                {
                    if (fileName == '*') //if end of string than this valid string
                    {
                        frames = new Dictionary<FrameType, string> {{Frame.GetEnum(tag.ToString()), value.ToString()}}; //Create and eturn them
                        return;
                    }

                    DeterminateNextTag(fileName,pattern, out frames); //If not end of string, determinate next
                    if (frames != null) //If recusive method returned non-null dictionary its actualy end of tag
                    {
                        frames.Add(Frame.GetEnum(tag.ToString()), value.ToString()); //We should return them
                        return;
                    } //If returned null, then this not end of string. Continue reading
                }
                value.Append(fileName.Value);
                fileName++;
            }

            frames = null;
        }
Ejemplo n.º 8
0
        public List<FrameType> GetTags()
        {
            var pattern = new StrWithCursor(Pattern);
            var parsedTags = new SortedSet<FrameType>();
            var tag = new StringBuilder();

            while (pattern!='*')
            {
                if (pattern == '<')
                {
                    DeterminateTag(pattern, tag);
                    parsedTags.Add(Frame.GetEnum(tag.ToString()));
                    tag.Clear();
                }
                else
                    pattern++;
            }

            return parsedTags.Count != 0 ? parsedTags.ToList() : null;
        }
Ejemplo n.º 9
0
        public List <FrameType> GetTags()
        {
            var pattern    = new StrWithCursor(Pattern);
            var parsedTags = new SortedSet <FrameType>();
            var tag        = new StringBuilder();

            while (pattern != '*')
            {
                if (pattern == '<')
                {
                    DeterminateTag(pattern, tag);
                    parsedTags.Add(Frame.GetEnum(tag.ToString()));
                    tag.Clear();
                }
                else
                {
                    pattern++;
                }
            }

            return(parsedTags.Count != 0 ? parsedTags.ToList() : null);
        }
Ejemplo n.º 10
0
 public StrWithCursor(StrWithCursor input)
 {
     _str = input._str;
     _cursor = input._cursor;
 }
Ejemplo n.º 11
0
 protected bool Equals(StrWithCursor other)
 {
     return string.Equals(_str, other._str) && _cursor == other._cursor;
 }
Ejemplo n.º 12
0
 protected bool Equals(StrWithCursor other)
 {
     return(string.Equals(_str, other._str) && _cursor == other._cursor);
 }
Ejemplo n.º 13
0
 public StrWithCursor(StrWithCursor input)
 {
     _str    = input._str;
     _cursor = input._cursor;
 }
Ejemplo n.º 14
0
 private void DeterminateTag(StrWithCursor pattern, StringBuilder tag)
 {
     do
     {
         tag.Append(pattern.Value);
         pattern++;
     }
     while (pattern != '>' && pattern != '*');
     tag.Append(pattern.Value);
     pattern++;
 }