本文整理汇总了C#中com.getMaxLineLength方法的典型用法代码示例。如果您正苦于以下问题:C# com.getMaxLineLength方法的具体用法?C# com.getMaxLineLength怎么用?C# com.getMaxLineLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com
的用法示例。
在下文中一共展示了com.getMaxLineLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _writeBinary
/*
/**********************************************************
/* Internal methods, low-level writing, base64 encoded
/**********************************************************
*/
/// <exception cref="System.IO.IOException"/>
/// <exception cref="com.fasterxml.jackson.core.JsonGenerationException"/>
protected internal void _writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant
, byte[] input, int inputPtr, int inputEnd)
{
// Encoding is by chunks of 3 input, 4 output chars, so:
int safeInputEnd = inputEnd - 3;
// Let's also reserve room for possible (and quoted) lf char each round
int safeOutputEnd = _outputEnd - 6;
int chunksBeforeLF = b64variant.getMaxLineLength() >> 2;
// Ok, first we loop through all full triplets of data:
while (inputPtr <= safeInputEnd)
{
if (_outputTail > safeOutputEnd)
{
// need to flush
_flushBuffer();
}
// First, mash 3 bytes into lsb of 32-bit int
int b24 = ((int)input[inputPtr++]) << 8;
b24 |= ((int)input[inputPtr++]) & unchecked((int)(0xFF));
b24 = (b24 << 8) | (((int)input[inputPtr++]) & unchecked((int)(0xFF)));
_outputTail = b64variant.encodeBase64Chunk(b24, _outputBuffer, _outputTail);
if (--chunksBeforeLF <= 0)
{
// note: must quote in JSON value
_outputBuffer[_outputTail++] = (byte)('\\');
_outputBuffer[_outputTail++] = (byte)('n');
chunksBeforeLF = b64variant.getMaxLineLength() >> 2;
}
}
// And then we may have 1 or 2 leftover bytes to encode
int inputLeft = inputEnd - inputPtr;
// 0, 1 or 2
if (inputLeft > 0)
{
// yes, but do we have room for output?
if (_outputTail > safeOutputEnd)
{
// don't really need 6 bytes but...
_flushBuffer();
}
int b24 = ((int)input[inputPtr++]) << 16;
if (inputLeft == 2)
{
b24 |= (((int)input[inputPtr++]) & unchecked((int)(0xFF))) << 8;
}
_outputTail = b64variant.encodeBase64Partial(b24, inputLeft, _outputBuffer, _outputTail
);
}
}
示例2: _writeBinary
// write-method called when length is definitely known
/// <exception cref="System.IO.IOException"/>
/// <exception cref="com.fasterxml.jackson.core.JsonGenerationException"/>
protected internal int _writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant
, Sharpen.InputStream data, byte[] readBuffer, int bytesLeft)
{
int inputPtr = 0;
int inputEnd = 0;
int lastFullOffset = -3;
// Let's also reserve room for possible (and quoted) lf char each round
int safeOutputEnd = _outputEnd - 6;
int chunksBeforeLF = b64variant.getMaxLineLength() >> 2;
while (bytesLeft > 2)
{
// main loop for full triplets
if (inputPtr > lastFullOffset)
{
inputEnd = _readMore(data, readBuffer, inputPtr, inputEnd, bytesLeft);
inputPtr = 0;
if (inputEnd < 3)
{
// required to try to read to have at least 3 bytes
break;
}
lastFullOffset = inputEnd - 3;
}
if (_outputTail > safeOutputEnd)
{
// need to flush
_flushBuffer();
}
int b24 = ((int)readBuffer[inputPtr++]) << 8;
b24 |= ((int)readBuffer[inputPtr++]) & unchecked((int)(0xFF));
b24 = (b24 << 8) | (((int)readBuffer[inputPtr++]) & unchecked((int)(0xFF)));
bytesLeft -= 3;
_outputTail = b64variant.encodeBase64Chunk(b24, _outputBuffer, _outputTail);
if (--chunksBeforeLF <= 0)
{
_outputBuffer[_outputTail++] = '\\';
_outputBuffer[_outputTail++] = 'n';
chunksBeforeLF = b64variant.getMaxLineLength() >> 2;
}
}
// And then we may have 1 or 2 leftover bytes to encode
if (bytesLeft > 0)
{
inputEnd = _readMore(data, readBuffer, inputPtr, inputEnd, bytesLeft);
inputPtr = 0;
if (inputEnd > 0)
{
// yes, but do we have room for output?
if (_outputTail > safeOutputEnd)
{
// don't really need 6 bytes but...
_flushBuffer();
}
int b24 = ((int)readBuffer[inputPtr++]) << 16;
int amount;
if (inputPtr < inputEnd)
{
b24 |= (((int)readBuffer[inputPtr]) & unchecked((int)(0xFF))) << 8;
amount = 2;
}
else
{
amount = 1;
}
_outputTail = b64variant.encodeBase64Partial(b24, amount, _outputBuffer, _outputTail
);
bytesLeft -= amount;
}
}
return bytesLeft;
}