コード例 #1
0
ファイル: writer.cpp プロジェクト: Rambo2015/Drawpile
void Writer::writeMessage(const protocol::Message &msg)
{
	Q_ASSERT(m_file->isOpen());

	if(msg.isRecordable()) {
		// Write Interval message if sufficient time has passed since last message was written
		if(m_minInterval>0) {
			qint64 now = QDateTime::currentMSecsSinceEpoch();
			qint64 interval = now - m_interval;
			if(interval >= m_minInterval) {
				protocol::Interval imsg(0, qMin(qint64(0xffff), interval));
				QVarLengthArray<char> ibuf(imsg.length());
				int ilen = imsg.serialize(ibuf.data());
				m_file->write(ibuf.data(), ilen);
			}
			m_interval = now;
		}

		// Write the actual message
		QVarLengthArray<char> buf(msg.length());
		int len = msg.serialize(buf.data());
		Q_ASSERT(len == buf.length());
		m_file->write(buf.data(), len);
	}
}
コード例 #2
0
ファイル: ex07.cpp プロジェクト: djkovrik/eckel_cpp
int main() {

	/*Declarations instead of command line args*/
    std::ifstream source("source.txt", std::ios::in);
    std::ofstream result("result_07.txt", std::ios::out);

    istring from = "%Tag%";
    istring to = "John";

    std::string buf;
    size_t pos;

    while (getline(source, buf)) {

    	istring ibuf(buf.begin(), buf.end());

        pos = ibuf.find(from);
        while (pos != std::string::npos) {
            ibuf.replace(pos, from.size(), to);
            pos = ibuf.find(from, pos);
        }
        result << ibuf << '\n';
    }

return 0;
}
コード例 #3
0
ファイル: DrawOp.cpp プロジェクト: ultimatepp/mirror
void Painter::DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count,
                                  const int *subpolygon_counts, int scc, const int *disjunct_polygon_counts,
                                  int dpcc, Color color, int width, Color outline, uint64 pattern, Color doxor)
{
	Image fill_img;
	if(pattern && !IsNull(color)) {
		ImageBuffer ibuf(8, 8);
		RGBA r[2] = { color, RGBAZero() };
		for(RGBA *out = ibuf, *end = out + 64; out < end; pattern >>= 1)
			*out++ = r[(byte)pattern & 1];
		fill_img = ibuf;
	}
コード例 #4
0
ファイル: json.cpp プロジェクト: 1514louluo/acl
static bool test(const char* in, bool once, const char* name)
{
	acl::json json;
	const char* ptr = NULL, *p1 = in;
	char  buf[2];
       
	if (once)
		ptr = json.update(p1);
	else
	{
		while (*p1)
		{
			buf[0] = *p1;
			buf[1] = 0;
			ptr = json.update(buf);
			p1++;
		}
	}

	printf("------------------  input json ------------------------\r\n");
	printf("%s\r\n", in);
	printf("-------------------------------------------------------\r\n");

	printf("json finish: %s, left: |%s|, len: %d\r\n",
		json.finish() ? "yes" : "no", ptr, (int) strlen(ptr));

	printf("------------------ rebuild json -----------------------\r\n");
	printf("%s\r\n", json.to_string().c_str());
	printf("-------------------------------------------------------\r\n");

	acl::string ibuf(in);
	ibuf.trim_space().trim_right_line();

	acl::string obuf = json.to_string();
	obuf.trim_space();

	if (ibuf == obuf)
		printf("\r\n-----OK----\r\n\r\n");
	else
		printf("\r\n-----Error----\r\n\r\n");

	if (name && *name)
		test_type(json, name);

	return true;
}
コード例 #5
0
ファイル: obj_imm.cpp プロジェクト: Angeldude/pd
	virtual V m_bang() 
	{ 
		if(!ref.Ok() || !ref.Check()) {
/*
			if(!frms) 
				post("%s - No length defined!",thisName());
			else 
*/
			{
				ImmBuf ibuf(frms,zero);
				Vasp ret(frms,Vasp::Ref(ibuf));
                ToOutVasp(0,ret);
			}
		}
		else if(ref.Vectors() > 1) 
			post("%s - More than one vector in vasp!",thisName());
		else {
			VBuffer *buf = ref.Buffer(0);
			const I len = buf->Length(),chns = buf->Channels();

			// size of memory reservation (at least frms samples)
			const I rlen = frms > len?frms:len; 
			
			ImmBuf imm(rlen,false);

			BS *dst = imm.Pointer();
			const BS *src = buf->Pointer();

//			post("!copy: src: %p,%i,%i -> dst: %p,%i",src,len,chns,dst,rlen);

			register int i;
			_DE_LOOP(i,len, ( dst[i] = *src,src += chns ) )
			if(zero && rlen > len) ZeroSamples(dst+len,rlen-len);

			Vasp::Ref vr(imm);

//			post("!vr: %s,%i",vr.Ok()?vr.Symbol().Name():"***",vr.Offset());

			Vasp ret(len,vr);
			ToOutVasp(0,ret);

            delete buf;
		}
	}
コード例 #6
0
ファイル: msgdataset.cpp プロジェクト: 0004c/node-gdal
CPLErr MSGRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
                                  void * pImage )

{
        
    MSGDataset  *poGDS = (MSGDataset *) poDS;


    int iBytesPerPixel = 1;
    if (eDataType == GDT_UInt16)
      iBytesPerPixel = 2;
    else if (eDataType == GDT_Float32)
      iBytesPerPixel = 4;
/* -------------------------------------------------------------------- */
/*      Calculate the correct input file name based on nBlockYOff       */
/* -------------------------------------------------------------------- */

    int strip_number;
    int iChannel = poGDS->command.iChannel(1 + ((nBand - 1) % poGDS->command.iNrChannels()));

    if (fScanNorth)
      strip_number = nBlockYOff + 1;
    else
      strip_number = poGDS->command.iNrStrips(iChannel) - nBlockYOff;

    std::string strip_input_file = poGDS->command.sFileName(iSatellite, nBand, strip_number);
    
/* -------------------------------------------------------------------- */
/*      Open the input file                                             */
/* -------------------------------------------------------------------- */
    if (access(strip_input_file.c_str(), 0) == 0) // does it exist?
    {
      std::ifstream i_file (strip_input_file.c_str(), std::ios::in|std::ios::binary);

      if (i_file.good())
      {
        XRITHeaderParser xhp (i_file);

        if (xhp.isValid())
        {
          std::vector <short> QualityInfo;
          unsigned short chunck_height = xhp.nrRows();
          unsigned short chunck_bpp = xhp.nrBitsPerPixel();
          unsigned short chunck_width = xhp.nrColumns();
          unsigned __int8 NR = (unsigned __int8)chunck_bpp;
          unsigned int nb_ibytes = xhp.dataSize();
          int iShift = 0;
          bool fSplitStrip = false; // in the split strip the "shift" only happens before the split "row"
          int iSplitRow = 0;
          if (iChannel == 12)
          {
            iSplitRow = iSplitLine % xhp.nrRows();
            int iSplitBlock = iSplitLine / xhp.nrRows();
            fSplitStrip = (nBlockYOff == iSplitBlock); // in the split strip the "shift" only happens before the split "row"

            // When iLowerShift > 0, the lower HRV image is shifted to the right
            // When iLowerShift < 0, the lower HRV image is shifted to the left
            // The available raster may be wider than needed, so that time series don't fall outside the raster.
            
            if (nBlockYOff <= iSplitBlock)
              iShift = -iLowerShift;
            // iShift < 0 means upper image moves to the left
            // iShift > 0 means upper image moves to the right
          }
          
          std::auto_ptr< unsigned char > ibuf( new unsigned char[nb_ibytes]);
          
          if (ibuf.get() == 0)
          {
             CPLError( CE_Failure, CPLE_AppDefined, 
                  "Not enough memory to perform wavelet decompression\n");
            return CE_Failure;
          }

          i_file.read( (char *)(ibuf.get()), nb_ibytes);
          
          Util::CDataFieldCompressedImage  img_compressed(ibuf.release(),
                                  nb_ibytes*8,
                                  (unsigned char)chunck_bpp,
                                  chunck_width,
                                  chunck_height      );
          
          Util::CDataFieldUncompressedImage img_uncompressed;

          //****************************************************
          //*** Here comes the wavelets decompression routine
          COMP::DecompressWT(img_compressed, NR, img_uncompressed, QualityInfo);
          //****************************************************

          // convert:
          // Depth:
          // 8 bits -> 8 bits
          // 10 bits -> 16 bits (img_uncompressed contains the 10 bits data in packed form)
          // Geometry:
          // chunck_width x chunck_height to nBlockXSize x nBlockYSize

          // cases:
          // combination of the following:
          // - scan direction can be north or south
          // - eDataType can be GDT_Byte, GDT_UInt16 or GDT_Float32
          // - nBlockXSize == chunck_width or nBlockXSize > chunck_width
          // - when nBlockXSize > chunck_width, fSplitStrip can be true or false
          // we won't distinguish the following cases:
          // - NR can be == 8 or != 8
          // - when nBlockXSize > chunck_width, iShift iMinCOff-iMaxCOff <= iShift <= 0

          int nBlockSize = nBlockXSize * nBlockYSize;
          int y = chunck_width * chunck_height;
          int iStep = -1;
          if (fScanNorth) // image is the other way around
          {
            y = -1; // See how y is used below: += happens first, the result is used in the []
            iStep = 1;
          }

          COMP::CImage cimg (img_uncompressed); // unpack
          if (eDataType == GDT_Byte)
          {
            if (nBlockXSize == chunck_width) // optimized version
            {
              if (poGDS->command.cDataConversion == 'B')
              {
                for( int i = 0; i < nBlockSize; ++i )
                    ((GByte *)pImage)[i] = cimg.Get()[y+=iStep] / 4;
              }
              else
              {
                for( int i = 0; i < nBlockSize; ++i )
                    ((GByte *)pImage)[i] = cimg.Get()[y+=iStep];
              }
            }
            else
            {
              // initialize to 0's (so that it does not have to be done in an 'else' statement <performance>)
              memset(pImage, 0, nBlockXSize * nBlockYSize * iBytesPerPixel);
              if (poGDS->command.cDataConversion == 'B')
              {
                for( int j = 0; j < chunck_height; ++j ) // assumption: nBlockYSize == chunck_height
                { 
                  int iXOffset = j * nBlockXSize + iShift;
                  iXOffset += nBlockXSize - iLowerWestColumnPlanned - 1; // Position the HRV part in the frame; -1 to compensate the pre-increment in the for-loop
                  if (fSplitStrip && (j >= iSplitRow)) // In splitstrip, below splitline, thus do not shift!!
                    iXOffset -= iShift;
                  for (int i = 0; i < chunck_width; ++i)
                    ((GByte *)pImage)[++iXOffset] = cimg.Get()[y+=iStep] / 4;
                }
              }
              else
              {
                for( int j = 0; j < chunck_height; ++j ) // assumption: nBlockYSize == chunck_height
                { 
                  int iXOffset = j * nBlockXSize + iShift;
                  iXOffset += nBlockXSize - iLowerWestColumnPlanned - 1; // Position the HRV part in the frame; -1 to compensate the pre-increment in the for-loop
                  if (fSplitStrip && (j >= iSplitRow)) // In splitstrip, below splitline, thus do not shift!!
                    iXOffset -= iShift;
                  for (int i = 0; i < chunck_width; ++i)
                    ((GByte *)pImage)[++iXOffset] = cimg.Get()[y+=iStep];
                }
              }
            }
          }
          else if (eDataType == GDT_UInt16) // this is our "normal case" if scan direction is South: 10 bit MSG data became 2 bytes per pixel
          {
            if (nBlockXSize == chunck_width) // optimized version
            {
              for( int i = 0; i < nBlockSize; ++i )
                  ((GUInt16 *)pImage)[i] = cimg.Get()[y+=iStep];
            }
            else
            {
              // initialize to 0's (so that it does not have to be done in an 'else' statement <performance>)
              memset(pImage, 0, nBlockXSize * nBlockYSize * iBytesPerPixel);
              for( int j = 0; j < chunck_height; ++j ) // assumption: nBlockYSize == chunck_height
              {
                int iXOffset = j * nBlockXSize + iShift;
                iXOffset += nBlockXSize - iLowerWestColumnPlanned - 1; // Position the HRV part in the frame; -1 to compensate the pre-increment in the for-loop
                if (fSplitStrip && (j >= iSplitRow)) // In splitstrip, below splitline, thus do not shift!!
                  iXOffset -= iShift;
                for (int i = 0; i < chunck_width; ++i)
                  ((GUInt16 *)pImage)[++iXOffset] = cimg.Get()[y+=iStep];
              }
            }
          }
          else if (eDataType == GDT_Float32) // radiometric calibration is requested
          {
            if (nBlockXSize == chunck_width) // optimized version
            {
              for( int i = 0; i < nBlockSize; ++i )
                ((float *)pImage)[i] = (float)rRadiometricCorrection(cimg.Get()[y+=iStep], iChannel, nBlockYOff * nBlockYSize + i / nBlockXSize, i % nBlockXSize, poGDS);
            }
            else
            {
              // initialize to 0's (so that it does not have to be done in an 'else' statement <performance>)
              memset(pImage, 0, nBlockXSize * nBlockYSize * iBytesPerPixel);
              for( int j = 0; j < chunck_height; ++j ) // assumption: nBlockYSize == chunck_height
              {
                int iXOffset = j * nBlockXSize + iShift;
                iXOffset += nBlockXSize - iLowerWestColumnPlanned - 1; // Position the HRV part in the frame; -1 to compensate the pre-increment in the for-loop
                if (fSplitStrip && (j >= iSplitRow)) // In splitstrip, below splitline, thus do not shift!!
                  iXOffset -= iShift;
                int iXFrom = nBlockXSize - iLowerWestColumnPlanned + iShift; // i is used as the iCol parameter in rRadiometricCorrection
                int iXTo = nBlockXSize - iLowerWestColumnPlanned + chunck_width + iShift;
                for (int i = iXFrom; i < iXTo; ++i) // range always equal to chunck_width .. this is to utilize i to get iCol
                  ((float *)pImage)[++iXOffset] = (float)rRadiometricCorrection(cimg.Get()[y+=iStep], iChannel, nBlockYOff * nBlockYSize + j, (fSplitStrip && (j >= iSplitRow))?(i - iShift):i, poGDS);
              }
            }
          }
        }
        else // header could not be opened .. make sure block contains 0's
          memset(pImage, 0, nBlockXSize * nBlockYSize * iBytesPerPixel);
      }
      else // file could not be opened .. make sure block contains 0's
        memset(pImage, 0, nBlockXSize * nBlockYSize * iBytesPerPixel);

      i_file.close();
    }
    else // file does not exist .. make sure block contains 0's
      memset(pImage, 0, nBlockXSize * nBlockYSize * iBytesPerPixel);

    return CE_None;
}
コード例 #7
0
ファイル: cpio.hpp プロジェクト: HiroyukiSeki/qtplatz
 template<class T> static bool copyout( T& t, adfs::folium& f ) {
     detail::cpio ibuf( f.size() );
     std::istream is( &ibuf );
     return f.read( ibuf.size(), ibuf.get() ) && archive_type::restore( is, t );
 }
コード例 #8
0
ファイル: textfile.cpp プロジェクト: lulu00147/qaac
std::wstring load_text_file(const std::wstring &path, uint32_t codepage)
{
    struct F {
        static void release(IUnknown *x) {  x->Release(); }
    };

    IStream *stream;
    HRESULT hr = SHCreateStreamOnFileW(path.c_str(),
                                       STGM_READ | STGM_SHARE_DENY_WRITE,
                                       &stream);
    if (FAILED(hr)) win32::throw_error(path, hr);
    std::shared_ptr<IStream> streamPtr(stream, F::release);

    LARGE_INTEGER li = { 0 };
    ULARGE_INTEGER ui;
    HR(stream->Seek(li, STREAM_SEEK_END, &ui));
    if (ui.QuadPart > 0x100000) {
        throw std::runtime_error(strutil::w2us(path + L": file too big"));
    }
    size_t fileSize = ui.LowPart;
    HR(stream->Seek(li, STREAM_SEEK_SET, &ui));

    IMultiLanguage2 *mlang;
    HR(CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_INPROC_SERVER,
                IID_IMultiLanguage2, (void**)(&mlang)));
    std::shared_ptr<IMultiLanguage2> mlangPtr(mlang, F::release);

    if (!codepage) {
        DetectEncodingInfo encoding[5];
        INT nscores = 5;
        HR(mlang->DetectCodepageInIStream(0, GetACP(),
                                          stream, encoding, &nscores));
        /*
         * Usually DetectCodepageInIStream() puts the most appropriate choice
         * in the first place.
         * However, it tends to pick 8bit locale charset for the first place,
         * even if it is really an UTF-8 encoded file.
         */
        codepage = encoding[0].nCodePage;
        for (size_t i = 0; i < nscores; ++i)
            if (encoding[i].nCodePage == 65001) {
                codepage = 65001;
                break;
            }
        HR(stream->Seek(li, STREAM_SEEK_SET, &ui));
    }
    std::vector<char> ibuf(fileSize);
    ULONG nread;
    HR(stream->Read(&ibuf[0], ibuf.size(), &nread));

    DWORD ctx = 0;
    UINT size = ibuf.size(), cnt;
    HR(mlang->ConvertStringToUnicode(&ctx, codepage,
                                     &ibuf[0], &size, 0, &cnt));
    std::vector<wchar_t> obuf(cnt);
    size = ibuf.size();
    HR(mlang->ConvertStringToUnicode(&ctx, codepage,
                                     &ibuf[0], &size, &obuf[0], &cnt));
    obuf.push_back(0);
    // chop off BOM
    size_t bom = obuf.size() && obuf[0] == 0xfeff;
    return strutil::normalize_crlf(&obuf[bom], L"\n");
}
コード例 #9
0
int main()
try {
    // -------------------------------------------------------------------------
    std::cout << "Read standard Ifd from data buffer\n";

    const long len = 77;
    Exiv2::byte buf[]
        = { 0xff, // Filler
            // No
            0x00,0x04,
            // Tag       Type          Components          Offset/Data
            0x00,0x01, 0x00,0x02, 0x00,0x00,0x00,0x04, 'T', 'h', 'e', '\0',
            0x00,0x02, 0x00,0x02, 0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x37,
            0x00,0x03, 0x00,0x02, 0x00,0x00,0x00,0x07, 0x00,0x00,0x00,0x3d,
            0x00,0x04, 0x00,0x02, 0x00,0x00,0x00,0x09, 0x00,0x00,0x00,0x44,
            // Next
            0x00,0x00,0x00,0x00,
            // Data
            'K', 'u', 'a', 'l', 'a', '\0',
            'L', 'u', 'm', 'p', 'u', 'r', '\0',
            'M', 'a', 'l', 'a', 'y', 's', 'i', 'a', '\0'
        };

    Exiv2::Ifd ifd(Exiv2::ifd0Id, 0, false);
    int rc = ifd.read(buf, len, 1, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (1) failed, rc = " << rc << "\n";
        return rc;
    }
    ifd.print(std::cout);

    Exiv2::Ifd::iterator pos = ifd.findTag(0x0004);
    if (pos == ifd.end()) {
        std::cout << "Tag not found!\n";
        return 1;
    }
    Exiv2::byte data[] = { 'T', 'H', 'R', 'E', 'E', '\0' };

    std::cout << "Setting value of entry 3...\n";
    pos->setValue(2, 6, data, 6);

    Exiv2::DataBuf db(1024);
    rc = ifd.copy(db.pData_ + 1, Exiv2::bigEndian);
    std::cout << "Wrote " << rc << " characters to data buffer\n";
    rc = ifd.read(db.pData_, len, 1, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (1a) failed, rc = " << rc << "\n";
        return rc;
    }
    ifd.print(std::cout);

    // -------------------------------------------------------------------------
    std::cout << "\nRead non-standard Ifd from data buffer\n";

    const long len2 = 76;
    Exiv2::byte buf2[]
        = { // Data
            'K', 'u', 'a', 'l', 'a', '\0',
            'L', 'u', 'm', 'p', 'u', 'r', '\0',
            'M', 'a', 'l', 'a', 'y', 's', 'i', 'a', '\0',
            // No
            0x00,0x04,
            // Tag       Type          Components          Offset/Data
            0x00,0x01, 0x00,0x02, 0x00,0x00,0x00,0x04, 'T', 'h', 'e', '\0',
            0x00,0x02, 0x00,0x02, 0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x00,
            0x00,0x03, 0x00,0x02, 0x00,0x00,0x00,0x07, 0x00,0x00,0x00,0x06,
            0x00,0x04, 0x00,0x02, 0x00,0x00,0x00,0x09, 0x00,0x00,0x00,0x0d,
            // Next
            0x00,0x00,0x00,0x00
        };

    Exiv2::Ifd ifd2(Exiv2::ifd0Id, 0, false);
    rc = ifd2.read(buf2, len2, 22, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (2) failed, rc = " << rc << "\n";
        return rc;
    }
    ifd2.print(std::cout);

    pos = ifd2.findTag(0x0004);
    if (pos == ifd2.end()) {
        std::cout << "Tag not found!\n";
        return 1;
    }
    Exiv2::byte data2[] = { 'T', 'H', 'R', 'E', 'E', '\0' };

    std::cout << "Setting value of entry 3...\n";
    pos->setValue(2, 6, data2, 6);

    ifd2.print(std::cout);

    // -------------------------------------------------------------------------
    std::cout << "\nTest boundary checks, the following reads should generate warnings or errors\n";

    std::cout << "--- read (3)" << std::endl;
    rc = ifd.read(buf, len-1, 1, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (3) failed, rc = " << rc << "\n";
    }

    std::cout << "--- read (4)" << std::endl;
    rc = ifd.read(buf, len-17, 1, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (4) failed, rc = " << rc << "\n";
    }

    std::cout << "--- read (5)" << std::endl;
    rc = ifd.read(buf, len-16, 1, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (5) failed, rc = " << rc << "\n";
    }

    std::cout << "--- read (6)" << std::endl;
    rc = ifd.read(buf, len-23, 1, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (6) failed, rc = " << rc << "\n";
    }

    std::cout << "--- read (7)" << std::endl;
    rc = ifd2.read(buf2, len2-1, 22, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (7) failed, rc = " << rc << "\n";
    }

    // -------------------------------------------------------------------------
    std::cout << "\nCreate Ifd from scratch\n";

    Exiv2::Ifd ifd3(Exiv2::ifd0Id);
    Exiv2::Entry e;
    e.setIfdId(Exiv2::ifd0Id);
    e.setIdx(0);

    e.setTag(0x0001);
    e.setOffset(0);  // will be calculated when the IFD is written
    Exiv2::byte data0x01[] = { 'T', 'h', 'e', '\0' };
    e.setValue(2, 4, data0x01, 4);
    ifd3.add(e);

    e.setTag(0x0002);
    e.setOffset(0);  // will be calculated when the IFD is written
    Exiv2::byte data0x02[] = { 'K', 'u', 'a', 'l', 'a', '\0' };
    e.setValue(2, 6, data0x02, 6);
    ifd3.add(e);

    e.setTag(0x0003);
    e.setOffset(0);  // will be calculated when the IFD is written
    Exiv2::byte data0x03[] = { 'L', 'u', 'm', 'p', 'u', 'r', '\0' };
    e.setValue(2, 7, data0x03, 7);
    ifd3.add(e);

    e.setTag(0x0004);
    e.setOffset(0);  // will be calculated when the IFD is written
    Exiv2::byte data0x04[] = { 'M', 'a', 'l', 'a', 'y', 's', 'i', 'a', '\0' };
    e.setValue(2, 9, data0x04, 9);
    ifd3.add(e);

    Exiv2::DataBuf ibuf(256);
    long len3 = ifd3.copy(ibuf.pData_, Exiv2::bigEndian);

    Exiv2::Ifd ifd4(Exiv2::ifd0Id, 0, false);
    rc = ifd4.read(ibuf.pData_, len3, 0, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (8) failed, rc = " << rc << "\n";
    }
    ifd4.print(std::cout);

    // -------------------------------------------------------------------------
    std::cout << "\nMove data buffer\n";

    Exiv2::Ifd ifd5(Exiv2::ifd0Id, 0, false);
    rc = ifd5.read(buf, len, 1, Exiv2::bigEndian);
    if (rc) {
        std::cout << "Ifd::read (1) failed, rc = " << rc << "\n";
        return rc;
    }
    ifd5.print(std::cout);

    Exiv2::byte* newBuf = new Exiv2::byte[len];
    std::memset(newBuf, 0x00, len);
    std::memcpy(newBuf, buf, len);
    std::memset(buf, 0x0, len);
    ifd5.updateBase(newBuf);
    ifd5.print(std::cout);
    delete[] newBuf;

    return 0;
}
catch (const Exiv2::AnyError& e) {
    std::cout << "Caught Exiv2 exception '" << e << "'\n";
    return 1;
}