本文整理汇总了C++中encoder函数的典型用法代码示例。如果您正苦于以下问题:C++ encoder函数的具体用法?C++ encoder怎么用?C++ encoder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encoder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_argument_value
void write_argument_value(tstring const& data)
{
// http://www.w3.org/TR/REC-xml/#NT-AttValue
// says that in att value, we escape " ' < and &
static const tstring patterns = "\"'<&";
static const tstring replacements[] = {
""", "'", "<", "&"
};
xml_content_encoder encoder(data, patterns, replacements);
while( encoder.has_next() ) {
tinfra::tstring chunk = encoder.next();
out_->write(chunk.data(), chunk.size());
}
}
示例2: createHeader
const std::string createHeader()
{
// TODO: Some sane code to represent JSON objects
std::string header = "{\"alg\":\""+_alg+"\",\"typ\":\""+_typ+"\"}";
Log::info("JWT Header: " + header);
std::ostringstream ostr;
Poco::OutputLineEndingConverter lineEndingConv(ostr, "");
Poco::Base64Encoder encoder(lineEndingConv);
encoder << header;
encoder.close();
return ostr.str();
}
示例3: encoder
void ArchExecutor::EncodeFiles(Options* options)
{
int filesCount = options->Files->GetCount();
if (options->Stdin || filesCount == 0)
{
LzwEncoder encoder(stdin, stdout);
encoder.Encode("");
return;
}
for(int i = 0; i < filesCount; i++)
{
char* path = options->Files->GetElement(i);
FILE* inputFile = fopen(path, "rb");
if (IsCompressedFile(inputFile))
{
fclose(inputFile);
continue;
}
char* compressedPath = new char[PATH_MAX];
int pathLength = sprintf (compressedPath, "%s.ar", path);
if (pathLength >= PATH_MAX)
{
printf ("Path length has got too long.\n");
continue;
}
FILE* outputFile = fopen(compressedPath, "wb");
LzwEncoder encoder(inputFile, outputFile);
encoder.Encode(GetName(path));
fclose(inputFile);
remove(path);
}
}
示例4: newChunk
void VlrCompressor::done()
{
// Close and clear the point encoder.
m_encoder->done();
m_encoder.reset();
newChunk();
// Save our current position. Go to the location where we need
// to write the chunk table offset at the beginning of the point data.
uint64_t chunkTablePos = htole64((uint64_t) m_stream.m_buf.size());
// We need to add the offset given a construction time since
// we did not use a stream to write the header and vlrs
uint64_t trueChunkTablePos = htole64((uint64_t) m_stream.m_buf.size() + m_offsetToData);
// Equivalent of stream.seekp(m_chunkInfoPos); stream << chunkTablePos
memcpy(&m_stream.m_buf[m_chunkInfoPos], (char*) &trueChunkTablePos, sizeof(uint64_t));
// Move to the start of the chunk table.
// Which in our case is the end of the m_stream vector
// Write the chunk table header in two steps
// 1. Push bytes into the stream
// 2. memcpy the data into the pushed bytes
unsigned char skip[2 * sizeof(uint32_t)] = {0};
m_stream.putBytes(skip, sizeof(skip));
uint32_t version = htole32(0);
uint32_t chunkTableSize = htole32((uint32_t) m_chunkTable.size());
memcpy(&m_stream.m_buf[chunkTablePos], &version, sizeof(uint32_t));
memcpy(&m_stream.m_buf[chunkTablePos + sizeof(uint32_t)], &chunkTableSize, sizeof(uint32_t));
// Encode and write the chunk table.
// OutputStream outputStream(m_stream);
TypedLazPerfBuf<uint8_t> outputStream(m_stream);
Encoder encoder(outputStream);
laszip::compressors::integer compressor(32, 2);
compressor.init();
uint32_t predictor = 0;
for (uint32_t chunkSize : m_chunkTable)
{
chunkSize = htole32(chunkSize);
compressor.compress(encoder, predictor, chunkSize, 1);
predictor = chunkSize;
}
encoder.done();
}
示例5: _WIMTRACE2
// -----------------------------------------------------------------------------
// CWimCertHandler::ParseCertPublicKeyL
// Parse public key from certificate.
// -----------------------------------------------------------------------------
//
void CWimCertHandler::ParseCertPublicKeyL(
const TDesC8& aCertData,
TDes8& aPublicKey,
const TUint8 aCertType ) const
{
_WIMTRACE2(_L("WIM | WIMServer | CWimPublicKeyHandler::ParseCertPublicKeyL | Begin, type %d"), aCertType);
CCertificate* certificate = NULL;
CRSAPublicKey* publicKey = NULL;
switch ( aCertType )
{
case WIMI_CT_WTLS:
{
certificate = CWTLSCertificate::NewLC( aCertData );
publicKey = CWTLSRSAPublicKey::NewLC( certificate->PublicKey().KeyData() );
break;
}
case WIMI_CT_X509:
{
certificate = CX509Certificate::NewLC( aCertData );
publicKey = CX509RSAPublicKey::NewLC( certificate->PublicKey().KeyData() );
break;
}
default:
{
_WIMTRACE2(_L("WIM|WIMServer|CWimCertHandler::ParseCertPublicKeyL, type %d not supported"), aCertType);
User::Leave( KErrNotSupported );
break;
}
}
TX509RSAKeyEncoder encoder( *publicKey, ESHA1 );
CASN1EncBase* encoded = encoder.EncodeKeyLC();
TUint pos = 0;
aPublicKey.SetLength( KPublicKeyLength );
// Check that Max. length is not exceeded
if ( encoded->LengthDER() > static_cast< TUint >( KPublicKeyLength ) )
{
_WIMTRACE(_L("WIM|WIMServer|CWimCertHandler::ParseCertPublicKeyL, too long public key"));
User::Leave( KErrBadDescriptor );
}
// Write encoded key to prealloced buffer
encoded->WriteDERL( aPublicKey, pos );
CleanupStack::PopAndDestroy( 3, certificate ); // encoded, publicKey, certificate
_WIMTRACE(_L("WIM | WIMServer | CWimPublicKeyHandler::ParseCertPublicKeyL | End"));
}
示例6: run_codec_test
/*
encoder - decoder
cbr or cq
ppinloop
rebuild.yuv size.txt ssim.txt
*/
void run_codec_test(char argc, char** argv)
{
CX264Encoder e;
set_default_cmd();
parse_cmd_enc( argc, argv);
if(1==verfy_cmd())
{
cmd_help();
}
init_encoder( &e );
encoder( &e, &gCmd);
}
示例7: lzwTest
std::string lzwTest(const std::string& str) {
std::ostringstream oss;
LzwEncoder encoder(std::make_shared<Writer>(&oss));
for (auto c : str) {
encoder.encode(c);
}
encoder.flush();
std::istringstream iss(oss.str());
LzwDecoder decoder(std::make_shared<Reader>(&iss));
std::ostringstream result;
decoder.decode(result);
return result.str();
}
示例8: encoder
void URLEncoderTest::DecodeTest()
{
URLEncoder encoder("encoder");
String Request = "Dies%20ist%0A%20%22%25%26%3F%2F%5C%23%7B%7DeinTestString";
String Answer, expected;
encoder.DoDecode(Answer, Request);
expected = "Dies ist\n ";
expected.Append('"').Append("%&?/\\#{}einTestString");
assertEqual( expected, Answer );
Request = "Dies+ist%0A+%22%25%26%3F%2F%5C%23%7B%7Dein+Test+String";
encoder.DoDecode(Answer, Request);
expected = "Dies ist\n ";
expected.Append('"').Append("%&?/\\#{}ein Test String");
assertEqual( expected, Answer );
}
示例9: write_content_bytes
void write_content_bytes(tstring const& data)
{
// http://www.w3.org/TR/REC-xml/#dt-chardata
// says that only < and & are escaped
// in normal text
static const tstring patterns = "<&";
static const tstring replacements[] = {
"<", "&"
};
xml_content_encoder encoder(data, patterns, replacements);
while( encoder.has_next() ) {
tinfra::tstring chunk = encoder.next();
out_->write(chunk.data(), chunk.size());
}
}
示例10: switch
void MailMessage::writeEncoded(std::istream& istr, std::ostream& ostr, ContentTransferEncoding encoding) const
{
switch (encoding)
{
case ENCODING_7BIT:
case ENCODING_8BIT:
StreamCopier::copyStream(istr, ostr);
break;
case ENCODING_QUOTED_PRINTABLE:
{
QuotedPrintableEncoder encoder(ostr);
StreamCopier::copyStream(istr, encoder);
encoder.close();
}
break;
case ENCODING_BASE64:
{
Base64Encoder encoder(ostr);
StreamCopier::copyStream(istr, encoder);
encoder.close();
}
break;
}
}
示例11: compressAdaptive
void compressAdaptive(std::istream& in, std::ostream& out) {
const char* header = "AC\x00";
out.write(header, 3);
ArithmeticEncoder encoder(std::make_shared<BitStreamWriter>(&out));
AdaptiveDataModel dataModel(NUM_SYMBOLS);
for (;;) {
int c = in.get();
if (c == std::char_traits<char>::eof()) {
encoder.encode(NUM_SYMBOLS - 1, &dataModel);
break;
}
encoder.encode(c, &dataModel);
}
}
示例12: makeBlock
static Block
makeBlock(uint32_t type, Iterator first, Iterator last)
{
EncodingEstimator estimator;
size_t valueLength = last - first;
size_t totalLength = valueLength;
totalLength += estimator.prependVarNumber(valueLength);
totalLength += estimator.prependVarNumber(type);
EncodingBuffer encoder(totalLength, 0);
encoder.prependRange(first, last);
encoder.prependVarNumber(valueLength);
encoder.prependVarNumber(type);
return encoder.block();
}
示例13: main
void main(int argc, char *argv[])
{
void encoder();
static void usage(char*);
if (argc != 3)
usage(argv[0]);
#ifdef __ADSP21000__
initx();
#else
ifile_name = argv[1];
xfile_name = argv[2];
#endif
ffase = -4;
encoder();
}
示例14: saveImage
void saveImage (const unsigned char* pixels,const unsigned char* palette,size_t width,size_t height,size_t channels,const std::string& strFile)
{
std::auto_ptr<ImageEncoder> encoder ( getImageEncoder (strFile) );
if (!encoder.get())
throw std::runtime_error("Unsupported file format "+strFile);
encoder->setWidth (width);
encoder->setHeight (height);
encoder->setChannels (channels);
encoder->setPalette (palette);
encoder->write_open(strFile);
encoder->write_header();
encoder->write_data (pixels,palette);
encoder->write_close ();
}
示例15: createPayload
const std::string createPayload()
{
std::time_t curtime = Poco::Timestamp().epochTime();
std::string exptime = std::to_string(curtime + 3600);
// TODO: Some sane code to represent JSON objects
std::string payload = "{\"iss\":\""+_iss+"\",\"sub\":\""+_sub+"\",\"aud\":\""+_aud+"\",\"nme\":\""+_name+"\",\"exp\":\""+exptime+"\"}";
Log::info("JWT Payload: " + payload);
std::ostringstream ostr;
Poco::OutputLineEndingConverter lineEndingConv(ostr, "");
Poco::Base64Encoder encoder(lineEndingConv);
encoder << payload;
encoder.close();
return ostr.str();
}