protected override bool TryWrite(Span <byte> destination, ulong value, out int written) { return(Base128.TryWriteUInt64(destination: destination, value: value, written: out written)); }
protected override int GetRequiredBytes(int value) { return(Base128.GetRequiredBytesInt32(value)); }
private Base GetMethod() { Base method = null; string alphabet = tbAlphabet.Text; if (tbSpecialChar.Text.Length > 1) throw new ArgumentException("Special char should contains one symbol"); char special = string.IsNullOrWhiteSpace(tbSpecialChar.Text) ? (char)0 : tbSpecialChar.Text[0]; Encoding textEncoding = cmbTextEncoding.SelectedItem != null ? (Encoding)((ComboBoxItem)cmbTextEncoding.SelectedItem).Value : null; bool parallel = cbParallel.Checked; switch (cmbMethod.SelectedItem.ToString()) { case "Base32": method = new Base32(alphabet, special, textEncoding); break; case "Base64": method = new Base64(alphabet, special, textEncoding, parallel); break; case "Base128": method = new Base128(alphabet, special, textEncoding); break; case "Base256": method = new Base256(alphabet, special, textEncoding); break; case "Base1024": method = new Base1024(alphabet, special, textEncoding); break; case "Base4096": method = new Base4096(alphabet, special, textEncoding); break; case "ZBase32": method = new ZBase32(alphabet, special, textEncoding); break; case "Base85": method = new Base85(alphabet, special, cbPrefixPostfix.Checked, textEncoding); break; case "Base91": method = new Base91(alphabet, special, textEncoding); break; case "BaseN": method = new BaseN(alphabet, (uint)nudMaxBitsCount.Value, textEncoding, cbReverseOrder.Checked, parallel); break; case "BaseBigN": method = new BaseBigN(alphabet, (uint)nudMaxBitsCount.Value, textEncoding, cbReverseOrder.Checked, parallel, cbMaxCompression.Checked); break; } tbBitsPerChars.Text = method.BlockBitsCount + "/" + method.BlockCharsCount; tbRatio.Text = ((double)method.BlockBitsCount / method.BlockCharsCount).ToString("0.000000"); nudAlphabetLength.Value = method.CharsCount; return method; }
protected override bool TryRead(Span <byte> source, out int value, out int read) { return(Base128.TryReadInt32ZigZag(source: source, value: out value, read: out read)); }
protected override bool TryWrite(Span <byte> destination, int value, int minBytesToWrite, out int written) { return(Base128.TryWriteInt32ZigZag(destination: destination, value: value, minBytesToWrite: minBytesToWrite, written: out written)); }
public void SetUp() { Converter = new Base128(); }
private Base GetMethod() { Base method = null; string alphabet = tbAlphabet.Text; if (tbSpecialChar.Text.Length > 1) { throw new ArgumentException("Special char should contains one symbol"); } char special = string.IsNullOrWhiteSpace(tbSpecialChar.Text) ? (char)0 : tbSpecialChar.Text[0]; Encoding textEncoding = cmbTextEncoding.SelectedItem != null ? (Encoding)((ComboBoxItem)cmbTextEncoding.SelectedItem).Value : null; bool parallel = cbParallel.Checked; switch (cmbMethod.SelectedItem.ToString()) { case "Base32": method = new Base32(alphabet, special, textEncoding); break; case "Base64": method = new Base64(alphabet, special, textEncoding, parallel); break; case "Base128": method = new Base128(alphabet, special, textEncoding); break; case "Base256": method = new Base256(alphabet, special, textEncoding); break; case "Base1024": method = new Base1024(alphabet, special, textEncoding); break; case "Base4096": method = new Base4096(alphabet, special, textEncoding); break; case "ZBase32": method = new ZBase32(alphabet, special, textEncoding); break; case "Base85": method = new Base85(alphabet, special, cbPrefixPostfix.Checked, textEncoding); break; case "Base91": method = new Base91(alphabet, special, textEncoding); break; case "BaseN": method = new BaseN(alphabet, (uint)nudMaxBitsCount.Value, textEncoding, cbReverseOrder.Checked, parallel); break; case "BaseBigN": method = new BaseBigN(alphabet, (uint)nudMaxBitsCount.Value, textEncoding, cbReverseOrder.Checked, parallel, cbMaxCompression.Checked); break; } tbBitsPerChars.Text = method.BlockBitsCount + "/" + method.BlockCharsCount; tbRatio.Text = ((double)method.BlockBitsCount / method.BlockCharsCount).ToString("0.000000"); nudAlphabetLength.Value = method.CharsCount; return(method); }
protected override bool TryWrite(Span <byte> destination, short value, out int written) { return(Base128.TryWriteInt32(destination: destination, value: value, written: out written)); }