Example #1
0
 public void OnMap(int size)
 {
     if (size == 0)
     {
         CborMap map = new CborMap();
         map.Tag = currentTag;
         currentTag = null;
         OnObject(map);
     }
     else
     {
         stack.Push(DynamicParseState.ParseMap(size, currentTag));
         currentTag = null;
     }
 }
Example #2
0
 public void OnArray(int size)
 {
     if (size == 0)
     {
         CborArray array = new CborArray(0);
         array.Tag = currentTag;
         currentTag = null;
         OnObject(array);
     }
     else
     {
         stack.Push(DynamicParseState.ParseArray(size, currentTag));
         currentTag = null;
     }
 }
Example #3
0
 public CborSpecial(CborNumber value)
 {
     Value = value;
 }
Example #4
0
        public void OnObject(CborObject obj)
        {
            if (currentTag != null)
            {
                obj.Tag = currentTag;
                currentTag = null;
            }

            if (stack.Any())
            {
                DynamicParseState state = stack.Peek();
                if (state.type == ParseType.MAP)
                {
                    if (state.currentKey == null)
                    {
                        state.currentKey = obj;
                    }
                    else
                    {
                        state.currentMap.Add(state.currentKey, obj);
                        state.currentKey = null;
                        state.currentIndex++;

                        if (state.currentIndex == state.maximumIndex)
                        {
                            stack.Pop();
                            OnObject(new CborMap(state.currentMap) {Tag = state.currentTag});
                        }
                    }
                }
                else // array
                {
                    state.currentArray[state.currentIndex] = obj;

                    state.currentIndex++;

                    if (state.currentIndex == state.maximumIndex)
                    {
                        stack.Pop();
                        CborArray array = new CborArray(state.currentArray);
                        array.Tag = state.currentTag;
                        OnObject(array);
                    }
                }
            }
            else
            {
                OnRootObject(obj);
            }
        }
Example #5
0
 public static DynamicParseState ParseMap(int size, CborNumber tag)
 {
     DynamicParseState state = new DynamicParseState();
     state.type = ParseType.MAP;
     state.currentMap = new Dictionary<CborObject, CborObject>();
     state.currentIndex = 0;
     state.maximumIndex = size;
     state.currentTag = tag;
     return state;
 }
Example #6
0
 public static DynamicParseState ParseArray(int size, CborNumber tag)
 {
     DynamicParseState state = new DynamicParseState();
     state.type = ParseType.ARRAY;
     state.currentArray = new CborObject[size];
     state.currentIndex = 0;
     state.maximumIndex = size;
     state.currentTag = tag;
     return state;
 }
Example #7
0
 public void OnTag(uint tag)
 {
     currentTag = new CborNumber32(1, tag);
 }