/// <summary> /// Returns a list of integers corresponding to an input string that is Base64 VLQ encoded /// </summary> internal static List <int> Decode(string input) { List <int> result = new List <int>(); Base64CharProvider charProvider = new Base64CharProvider(input); while (!charProvider.IsEmpty()) { result.Add(DecodeNextInteger(charProvider)); } return(result); }
/// <summary> /// Reads characters from the Base64CharProvider until a complete integer value has been extracted. /// </summary> private static int DecodeNextInteger(Base64CharProvider charProvider) { int result = 0; bool continuation; int shift = 0; do { char c = charProvider.GetNextCharacter(); int digit = Base64Converter.FromBase64(c); continuation = (digit & Base64VlqConstants.VlqContinuationBit) != 0; digit &= Base64VlqConstants.VlqBaseMask; result = result + (digit << shift); shift = shift + Base64VlqConstants.VlqBaseShift; } while (continuation); return(FromVlqSigned(result)); }