QuickFix.ByteSizeString.GetNextTag C# (CSharp) Method

GetNextTag() public method

public GetNextTag ( int &pos ) : int
pos int
return int
        public int GetNextTag(ref int pos)
        {
            int start = pos;
            pos = IndexOf(EQ, start);
            int ret = 0;
            int factor = 1;
            for( int i =(pos-1); i >= start; i--)
            {
                ret += (_str[i]-48) * factor;
                factor *= 10;
            }
            pos += 1;
            return ret;
        }

Usage Example

コード例 #1
0
        public void NextTagTest()
        {
            byte[] str = new byte[5];
            str = Encoding.UTF8.GetBytes("35=8\u0001");
            ByteSizeString utf8str = new ByteSizeString(str, 5);
            
            int pos = 0;
            int tag = utf8str.GetNextTag(ref pos);
            Assert.That(pos, Is.EqualTo(3));
            ByteSizeString val = utf8str.GetNextValue(ref pos);

            Assert.That(tag, Is.EqualTo(35));
            Assert.That(pos, Is.EqualTo(5));
            Assert.That(val.ByteArray, Is.EqualTo(Encoding.UTF8.GetBytes("8")));
            Assert.That(val.ToString(), Is.EqualTo("8"));
        }