`base64 encode` C++ Examples

7 C++ code examples are found related to "base64 encode". You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Example 1
Source File: base64.cpp    From foo_mediacontrol with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void base64_encode_append(pfc::string_base & out, const void * in, t_size inSize) {
		static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
		int shift = 0;
		int accum = 0;
		const t_uint8 * inPtr = reinterpret_cast<const t_uint8*>(in);

		for(t_size walk = 0; walk < inSize; ++walk) {
			accum <<= 8;
			shift += 8;
			accum |= inPtr[walk];
			while ( shift >= 6 ) {
				shift -= 6;
				out << format_char( alphabet[(accum >> shift) & 0x3F] );
			}
		}
		if (shift == 4) {
			out << format_char( alphabet[(accum & 0xF)<<2] ) << "=";
		} else if 
Example 2
Source File: tb-rateestim.cc    From echo with MIT License 6 votes vote down vote up
float Algo_TB_RateEstimation_Exact::encode_transform_unit(encoder_context* ectx,
                                                          context_model_table& ctxModel,
                                                          const enc_tb* tb, const enc_cb* cb,
                                                          int x0,int y0, int xBase,int yBase,
                                                          int log2TrafoSize, int trafoDepth,
                                                          int blkIdx)
{
  CABAC_encoder_estim estim;
  estim.set_context_models(&ctxModel);

  leaf(cb, NULL);

  ::encode_transform_unit(ectx, &estim, tb,cb, x0,y0, xBase,yBase,
                          log2TrafoSize, trafoDepth, blkIdx);

  return estim.getRDBits();
} 
Example 3
Source File: tinyxml.cpp    From SEIMS with GNU General Public License v3.0 5 votes vote down vote up
void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
{
	int i=0;

	while( i<(int)str.length() )
	{
		unsigned char c = (unsigned char) str[i];

		if (    c == '&' 
		     && i < ( (int)str.length() - 2 )
			 && str[i+1] == '#'
			 && str[i+2] == 'x' )
		{
			// Hexadecimal character reference.
			// Pass through unchanged.
			// &#xA9;	-- copyright symbol, for example.
			//
			// The -1 is a bug fix from Rob Laveaux. It keeps
			// an overflow from happening if there is no ';'.
			// There are actually 2 ways to exit this loop -
			// while fails (error case) and break (semicolon found).
			// However, there is no mechanism (currently) for
			// this function to return an error.
			while ( i<(int)str.length()-1 )
			{
				outString->append( str.c_str() + i, 1 );
				++i;
				if ( str[i] == ';' )
					break;
			}
		}
		else if ( c == '&' )
		{
			outString->append( entity[0].str, entity[0].strLength );
			++i;
		}
		else if 
Example 4
Source File: tinyxml.cpp    From rubyclient with GNU General Public License v2.0 5 votes vote down vote up
void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
{
    int i=0;

    while( i<(int)str.length() )
    {
        unsigned char c = (unsigned char) str[i];

        if (    c == '&'
             && i < ( (int)str.length() - 2 )
             && str[i+1] == '#'
             && str[i+2] == 'x' )
        {
            // Hexadecimal character reference.
            // Pass through unchanged.
            // &#xA9;    -- copyright symbol, for example.
            //
            // The -1 is a bug fix from Rob Laveaux. It keeps
            // an overflow from happening if there is no ';'.
            // There are actually 2 ways to exit this loop -
            // while fails (error case) and break (semicolon found).
            // However, there is no mechanism (currently) for
            // this function to return an error.
            while ( i<(int)str.length()-1 )
            {
                outString->append( str.c_str() + i, 1 );
                ++i;
                if ( str[i] == ';' )
                    break;
            }
        }
        else if ( c == '&' )
        {
            outString->append( entity[0].str, entity[0].strLength );
            ++i;
        }
        else if 
Example 5
Source File: tinyxml.cpp    From DualSPHysics with GNU Lesser General Public License v2.1 5 votes vote down vote up
void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
{
    int i=0;

    while( i<(int)str.length() )
    {
        unsigned char c = (unsigned char) str[i];

        if (    c == '&' 
             && i < ( (int)str.length() - 2 )
             && str[i+1] == '#'
             && str[i+2] == 'x' )
        {
            // Hexadecimal character reference.
            // Pass through unchanged.
            // &#xA9;   -- copyright symbol, for example.
            //
            // The -1 is a bug fix from Rob Laveaux. It keeps
            // an overflow from happening if there is no ';'.
            // There are actually 2 ways to exit this loop -
            // while fails (error case) and break (semicolon found).
            // However, there is no mechanism (currently) for
            // this function to return an error.
            while ( i<(int)str.length()-1 )
            {
                outString->append( str.c_str() + i, 1 );
                ++i;
                if ( str[i] == ';' )
                    break;
            }
        }
        else if ( c == '&' )
        {
            outString->append( entity[0].str, entity[0].strLength );
            ++i;
        }
        else if