public override BitStringValue CreateBitStringValue(BitStringValue o, Antlr.Runtime.Tree.ITree antlr) { return new SCCBitStringValue(o, antlr); }
public static List<byte> ConvertToOctetArray(BitStringValue tmp, bool forOctStrUse) { List<byte> ret = new List<byte>(); string bitString = tmp.Value; int nBitsToInsert = 0; if (bitString.Length % 4 > 0) nBitsToInsert = 4 - bitString.Length % 4; else nBitsToInsert = 0; for (int i = 0; i < nBitsToInsert; i++) bitString += "0"; List<byte> nibles = new List<byte>(); while (bitString.Length > 0) { string nible = bitString.Substring(0, 4); nibles.Add(lookup[nible]); bitString = bitString.Substring(4); } if (nibles.Count % 2 != 0) { if (forOctStrUse) nibles.Insert(0, 0); else nibles.Add(0); } while (nibles.Count > 0) { byte curByte = (byte)(nibles[0] << 4); curByte |= nibles[1]; ret.Add(curByte); nibles.RemoveAt(0); nibles.RemoveAt(0); } return ret; }
public SCCBitStringValue(BitStringValue o, ITree antlr) : base(o, antlr) { }