当前位置: 首页>>代码示例>>C++>>正文


C++ copyData函数代码示例

本文整理汇总了C++中copyData函数的典型用法代码示例。如果您正苦于以下问题:C++ copyData函数的具体用法?C++ copyData怎么用?C++ copyData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了copyData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: copyData

//_____________________________________________________________________________
// Copy assignment.
Force& Force::operator=(const Force& source)
{
    if (&source != this) {
        Super::operator=(source);
        copyData(source);
    }
    return *this;
}
开发者ID:fcanderson,项目名称:opensim-core,代码行数:10,代码来源:Force.cpp

示例2: main

int main(int argc, char *argv[])
{
	int	soc;
	struct sockaddr_un sa;
	size_t	addrLen;


	unlink(SOCKNAME);


	soc = socket(PF_LOCAL, SOCK_STREAM, 0);
	if (soc < 0)
	{
		printf("Bad Sock\n");
		exit(1);
	}

	unlink(SOCKNAME);

	sa.sun_family = AF_UNIX;
	strcpy(sa.sun_path, SOCKNAME);

	addrLen = sizeof(sa.sun_family) + strlen(sa.sun_path);

	int	ret;

	ret = bind(soc, (struct sockaddr *)&sa, addrLen);
	if (ret < 0)
	{
		printf("Bad Bind\n");
		exit(1);
	}

	ret = listen(soc, 5);
	if (ret < 0)
	{
		printf("Bad Listen\n");
		exit(1);
	}



	int fd;

	fd = accept(soc, (struct sockaddr *)&sa, &addrLen);
	if (fd < 0)
	{
		printf("Bad accept\n");
		exit(1);
	}


	copyData(fd, 1);

	unlink(SOCKNAME);

	return 0;
}	
开发者ID:samanz,项目名称:Fribbler-PS-Driver,代码行数:58,代码来源:SocServer.cpp

示例3: rowCount

void WAbstractItemModel::dropEvent(const WDropEvent& e, DropAction action,
				   int row, int column,
				   const WModelIndex& parent)
{
  // TODO: For now, we assumes selectionBehavior() == RowSelection !

  WItemSelectionModel *selectionModel
    = dynamic_cast<WItemSelectionModel *>(e.source());
  if (selectionModel) {
    WAbstractItemModel *sourceModel = selectionModel->model();

    /*
     * (1) Insert new rows (or later: cells ?)
     */
    if (action == MoveAction || row == -1) {
      if (row == -1)
	row = rowCount(parent);

      insertRows(row, selectionModel->selectedIndexes().size(), parent);
    }

    /*
     * (2) Copy data
     */
    WModelIndexSet selection = selectionModel->selectedIndexes();

    int r = row;
    for (WModelIndexSet::const_iterator i = selection.begin();
	 i != selection.end(); ++i) {
      WModelIndex sourceIndex = *i;
      if (selectionModel->selectionBehavior() == SelectRows) {
	WModelIndex sourceParent = sourceIndex.parent();

	for (int col = 0; col < sourceModel->columnCount(sourceParent); ++col) {
	  WModelIndex s = sourceModel->index(sourceIndex.row(), col,
					     sourceParent);
	  WModelIndex d = index(r, col, parent);
	  copyData(sourceModel, s, this, d);
	}

	++r;
      } else {
	  
      }
    }

    /*
     * (3) Remove original data
     */
    if (action == MoveAction) {
      while (!selectionModel->selectedIndexes().empty()) {
	WModelIndex i = Utils::last(selectionModel->selectedIndexes());

	sourceModel->removeRow(i.row(), i.parent());
      }
    }
  }
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:58,代码来源:WAbstractItemModel.C

示例4: copyData

bool MemoryBuffer::copy(const MemoryBuffer& buf)
{
    bool ret;
    if ((ret = resize(buf.size()))) {
        copyData(buf.dataPtr<uint8_t>(), buf.size());
    }

    return ret;
}
开发者ID:UIKit0,项目名称:resinlib,代码行数:9,代码来源:MemoryBuffer.cpp

示例5: path

StatusFile::StatusFile(const std::string & path_)
	: path(path_)
{
	/// Если файл уже существует. NOTE Незначительный race condition.
	if (Poco::File(path).exists())
	{
		std::string contents;
		{
			ReadBufferFromFile in(path, 1024);
			LimitReadBuffer limit_in(in, 1024);
			WriteBufferFromString out(contents);
			copyData(limit_in, out);
		}

		if (!contents.empty())
			LOG_INFO(&Logger::get("StatusFile"), "Status file " << path << " already exists - unclean restart. Contents:\n" << contents);
		else
			LOG_INFO(&Logger::get("StatusFile"), "Status file " << path << " already exists and is empty - probably unclean hardware restart.");
	}

	fd = open(path.c_str(), O_WRONLY | O_CREAT, 0666);

	if (-1 == fd)
		throwFromErrno("Cannot open file " + path);

	try
	{
		int flock_ret = flock(fd, LOCK_EX | LOCK_NB);
		if (-1 == flock_ret)
		{
			if (errno == EWOULDBLOCK)
				throw Exception("Cannot lock file " + path + ". Another server instance in same directory is already running.");
			else
				throwFromErrno("Cannot lock file " + path);
		}

		if (0 != ftruncate(fd, 0))
			throwFromErrno("Cannot ftruncate " + path);

		if (0 != lseek(fd, 0, SEEK_SET))
			throwFromErrno("Cannot lseek " + path);

		/// Записываем в файл информацию о текущем экземпляре сервера.
		{
			WriteBufferFromFileDescriptor out(fd, 1024);
			out
				<< "PID: " << getpid() << "\n"
				<< "Started at: " << LocalDateTime(time(0)) << "\n"
				<< "Revision: " << ClickHouseRevision::get() << "\n";
		}
	}
	catch (...)
	{
		close(fd);
		throw;
	}
}
开发者ID:Aahart911,项目名称:ClickHouse,代码行数:57,代码来源:StatusFile.cpp

示例6: debugC

void VideoDecoder::update() {
	if (getTimeToNextFrame() > 0)
		return;

	debugC(Common::kDebugVideo, 9, "New video frame");

	processData();
	copyData();
}
开发者ID:ehalls,项目名称:xoreos,代码行数:9,代码来源:decoder.cpp

示例7: main

int main(int argc, char *argv[]) {
	if (argc < 2) {
		printf("Usage: %s [exe folder]\n", argv[0]);
		printf("Where [exe folder] contains the following files:\n");
		printf("- M3_EN_127.exe: English v1.27 Window binary from the DVD release\n");
		printf("- M3_FR_122.exe: French v1.22 Window binary from the update patch\n");
		printf("- M3_FR_122.exe: English v1.22 Window binary from the update patch\n");
		printf("- M3_XBOX_PAL.xbe: PAL XBox binary\n");
		printf("- M3_XBOX_NTSC.xbe: NTSC XBox binary\n");
		return -1;
	}

	std::string path = argv[1];
	std::string dvdExe = path + "M3_EN_127.exe";
	std::string cdIntlExe = path + "M3_FR_122.exe";
	std::string cdEnglishExe = path + "M3_EN_122.exe";
	std::string xboxPalExe = path + "M3_XBOX_PAL.xbe";
	std::string xboxNtscExe = path + "M3_XBOX_NTSC.xbe";

	Common::File temp;
	if (!temp.open("data.tmp", Common::kFileWriteMode)) {
		error("Unable to open '%s'", "data.tmp");
	}

	writeScriptData(dvdExe.c_str(), temp, roomScripts, ARRAYSIZE(roomScripts));
	writeScriptData(dvdExe.c_str(), temp, menuScriptsDvd, ARRAYSIZE(menuScriptsDvd));
	writeScriptData(cdIntlExe.c_str(), temp, menuScriptsCdIntl, ARRAYSIZE(menuScriptsCdIntl));
	writeScriptData(cdEnglishExe.c_str(), temp, menuScriptsCdEnglish, ARRAYSIZE(menuScriptsCdEnglish));
	writeScriptData(xboxPalExe.c_str(), temp, roomScriptsXBox, ARRAYSIZE(roomScriptsXBox));
	writeScriptData(xboxPalExe.c_str(), temp, menuScriptsXboxIntl, ARRAYSIZE(menuScriptsXboxIntl));
	writeScriptData(xboxNtscExe.c_str(), temp, menuScriptsXboxEnglish, ARRAYSIZE(menuScriptsXboxEnglish));

	Common::File target;
	if (!target.open("myst3.dat", Common::kFileWriteMode)) {
		error("Unable to open '%s'", "myst3.dat");
	}
	target.writeLong(MKTAG('M', 'Y', 'S', 'T'));
	target.writeLong(kVersion);

	writeScriptIndex(target, roomScripts, ARRAYSIZE(roomScripts));
	writeScriptIndex(target, menuScriptsDvd, ARRAYSIZE(menuScriptsDvd));
	writeScriptIndex(target, menuScriptsCdIntl, ARRAYSIZE(menuScriptsCdIntl));
	writeScriptIndex(target, menuScriptsCdEnglish, ARRAYSIZE(menuScriptsCdEnglish));
	writeScriptIndex(target, roomScriptsXBox, ARRAYSIZE(roomScriptsXBox));
	writeScriptIndex(target, menuScriptsXboxIntl, ARRAYSIZE(menuScriptsXboxIntl));
	writeScriptIndex(target, menuScriptsXboxEnglish, ARRAYSIZE(menuScriptsXboxEnglish));

	writeSoundNames(dvdExe.c_str(), target, 549360);
	writeSoundNames(xboxPalExe.c_str(), target, 913960);

	copyData(temp, target);

	temp.close();
	target.close();

	return 0;
}
开发者ID:gordonacocella,项目名称:residualvm,代码行数:57,代码来源:create_myst3.cpp

示例8: copyData

KNoneFilter::Result KNoneFilter::uncompress()
{
#ifndef NDEBUG
    if (d->mode != QIODevice::ReadOnly) {
        return KFilterBase::Error;
    }
#endif
    return copyData();
}
开发者ID:dbzhang800,项目名称:karchive,代码行数:9,代码来源:knonefilter.cpp

示例9: aggregateTemplateData

/**
 * Buffer passed flow in Hashtable @c ht
 */
void aggregateTemplateData(Hashtable* ht, TemplateInfo* ti, FieldData* data)
{
	int i;

	/* Create data block to be inserted into buffer... */
	FieldData* htdata = (FieldData*)malloc(ht->fieldLength);

	for (i = 0; i < ht->dataTemplate->fieldCount; i++) {
		FieldInfo* hfi = &ht->dataTemplate->fieldInfo[i];
		FieldInfo* tfi = getTemplateFieldInfo(ti, &hfi->type);

		if(!tfi) {
			DPRINTF("Flow to be buffered did not contain %s field\n", typeid2string(hfi->type.id));
			continue;
		}

		copyData(&hfi->type, htdata + hfi->offset, &tfi->type, data + tfi->offset, ht->fieldModifier[i]);

		/* copy associated mask, should there be one */
		switch (hfi->type.id) {
		case IPFIX_TYPEID_sourceIPv4Address:
			tfi = getTemplateFieldInfo(ti, &(FieldType){.id = IPFIX_TYPEID_sourceIPv4Mask, .eid = 0});

			if(tfi) {
				if(hfi->type.length != 5) {
					DPRINTF("Tried to set mask of length %d IP address\n", hfi->type.length);
				} else {
					if(tfi->type.length == 1) {
						*(uint8_t*)(htdata + hfi->offset + 4) = *(uint8_t*)(data + tfi->offset);
					} else {
						DPRINTF("Cannot process associated mask with invalid length %d\n", tfi->type.length);
					}
				}
			}
			break;

		case IPFIX_TYPEID_destinationIPv4Address:
			tfi = getTemplateFieldInfo(ti, &(FieldType){.id = IPFIX_TYPEID_destinationIPv4Mask, .eid = 0});

			if(tfi) {
				if(hfi->type.length != 5) {
					DPRINTF("Tried to set mask of length %d IP address\n", hfi->type.length);
				} else {
					if(tfi->type.length == 1) {
						*(uint8_t*)(htdata + hfi->offset + 4) = *(uint8_t*)(data + tfi->offset);
					} else {
						DPRINTF("Cannot process associated mask with invalid length %d\n", tfi->type.length);
					}
				}
			}
			break;

		default:
			break;
		}
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:58,代码来源:hashing.c

示例10: insertNewElement

errorCode insertNewElement(limSizeCache * lsc, unsigned int slot, void * key, void * data){
  copyData(lsc, slot, data);
  //setCnt(lsc, slot, 1);
  updateAccessTime(lsc, slot);
  ACCNT_USED(lsc, slot) = 1;
  ACCNT_KEY(lsc, slot) = key;
  ACCNT_BH(lsc, slot) = NULL;
  ACCNT_EVICT(lsc, slot) = 0;

  return STATUS_OK;
}
开发者ID:codereview0,项目名称:fault-injection-driver,代码行数:11,代码来源:limitedSizeCache.c

示例11: copyData

TcpStreamData& TcpStreamData::operator=(const TcpStreamData& other)
{
	if (this == &other)
		return *this;

	if (m_DeleteDataOnDestruction && m_Data != NULL)
		delete [] m_Data;

	copyData(other);
	return *this;
}
开发者ID:mkaes,项目名称:PcapPlusPlus,代码行数:11,代码来源:TcpReassembly.cpp

示例12: throw

void Attribute<DimensionStruct>::reflectAttribute(const RTI::AttributeHandleValuePairSet& theAttributes, int idx) throw (RTI::FederateInternalError)
{
    unsigned char data[12];
    copyData(theAttributes, idx, data, sizeof(data));
    value.XAxisLength = fromNet<float>(data+0);
    value.YAxisLength = fromNet<float>(data+4);
    value.ZAxisLength = fromNet<float>(data+8);
    std::cout << "Dimension " << value.XAxisLength;
    std::cout << " " << value.YAxisLength;
    std::cout << " " << value.ZAxisLength;
    std::cout << std::endl;
}
开发者ID:LXiong,项目名称:ccn,代码行数:12,代码来源:rpr_types.cpp

示例13: toCVTImage

            static void toCVTImage( Image& dst, const openni::VideoFrameRef& frame )
            {
                dst.reallocate( frame.getWidth(), frame.getHeight(), Openni2Helper::toIFormat( frame.getVideoMode().getPixelFormat() ) );

                switch( frame.getVideoMode().getPixelFormat() ){
                    case openni::PIXEL_FORMAT_RGB888:
                        copyRGB( dst, ( const uint8_t* )frame.getData(), frame.getStrideInBytes() );
                        break;
                    default:
                        copyData( dst, ( const uint8_t* )frame.getData(), frame.getStrideInBytes() );
                }
            }
开发者ID:hksonngan,项目名称:cvt,代码行数:12,代码来源:OpenNI2Camera.cpp

示例14: throw

// Based on libarchive's public example code.
// https://github.com/libarchive/libarchive/wiki/Examples#wiki-Constructing_Objects_On_Disk
void GuiZipper::unpackFile(const char *zipFile, const char *outputDir)
    throw (ZipperException*) {
  // TODO: use archive_write_disk_open instead (if/when it exists)
  char cwd[4096];
  getcwd(cwd, 4096);
  char *absZipFile = fileManager_->getAbsFilePath(zipFile);
  platformstl::filesystem_traits<char> traits;
  traits.set_current_directory(outputDir);
  
  struct archive *a;
  struct archive *ext;
  struct archive_entry *entry;
  int flags;
  int r;
  
  flags = ARCHIVE_EXTRACT_TIME;
  flags |= ARCHIVE_EXTRACT_PERM;
  flags |= ARCHIVE_EXTRACT_ACL;
  flags |= ARCHIVE_EXTRACT_FFLAGS;
  
  a = archive_read_new();
  archive_read_support_format_tar(a);
  archive_read_support_filter_gzip(a);
  ext = archive_write_disk_new();
  archive_write_disk_set_options(ext, flags);
  archive_write_disk_set_standard_lookup(ext);
  r = archive_read_open_filename(a, absZipFile, 10240);
  checkForErrors("Error opening archive for reading", a, r);
  for (;;) {
    r = archive_read_next_header(a, &entry);
    if (r == ARCHIVE_EOF) {
      break;
    }
    checkForErrors("Error reading next archive header", a, r);
    r = archive_write_header(ext, entry);
    checkForErrors("Error writing next archive header", a, r);
    copyData(a, ext, outputDir);
    r = archive_write_finish_entry(ext);
    checkForErrors("Error writing archive finish entry", a, r);
  }
  r = archive_read_close(a);
  checkForErrors("Error closing read archive", a, r);
  r = archive_read_free(a);
  checkForErrors("Error freeing read archive", a, r);
  r = archive_write_close(ext);
  checkForErrors("Error closing write archive", a, r);
  r = archive_write_free(ext);
  checkForErrors("Error freeing write archive", a, r);

  traits.set_current_directory(cwd);
  delete absZipFile;
}
开发者ID:Voidious,项目名称:BerryBots,代码行数:54,代码来源:guizipper.cpp

示例15: copyData

LLKeywords::WStringMapIndex::WStringMapIndex(const WStringMapIndex& other)
{
	if(other.mOwner)
	{
		copyData(other.mData, other.mLength);
	}
	else
	{
		mOwner = false;
		mLength = other.mLength;
		mData = other.mData;
	}
}
开发者ID:1234-,项目名称:SingularityViewer,代码行数:13,代码来源:llkeywords.cpp


注:本文中的copyData函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。