本文整理汇总了C++中copyData函数的典型用法代码示例。如果您正苦于以下问题:C++ copyData函数的具体用法?C++ copyData怎么用?C++ copyData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copyData函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: processBuffer
/*
* processBuffer() - Process audio data once it has been received.
*/
void processBuffer(void)
{
Uint32 pingPong;
/* Get contents of mailbox posted by edmaHwi */
pingPong = SWI_getmbox();
/* Copy data from transmit to receive, could process audio here */
if (pingPong == PING) {
/* Toggle LED #3 as a visual cue */
DSK6713_LED_toggle(3);
/* Copy receive PING buffer to transmit PING buffer */
copyData(gBufferRcvPing, gBufferXmtPing, BUFFSIZE);
} else {
/* Toggle LED #2 as a visual cue */
DSK6713_LED_toggle(2);
/* Copy receive PONG buffer to transmit PONG buffer */
copyData(gBufferRcvPong, gBufferXmtPong, BUFFSIZE);
}
}
开发者ID:jacyzon,项目名称:DSP-LAB,代码行数:25,代码来源:Exp2.c
示例17: lbfgsCallback
static double lbfgsCallback(void* instance, const double* x, double* g,
const int n, const double step)
{
const CostAndGradientFunction* callback =
reinterpret_cast<const CostAndGradientFunction*>(instance);
auto weights = callback->getUninitializedDataStructure();
auto gradient = callback->getUninitializedDataStructure();
assert(weights.size() > 0);
assert(gradient.size() > 0);
// TODO: get rid of these copies
copyData(weights, x);
//copyData(gradient, g); // can we comment this guy out?
float cost = callback->computeCostAndGradient(gradient, weights);
copyData(g, gradient);
return cost;
}
开发者ID:nudles,项目名称:video-classifier,代码行数:22,代码来源:LimitedMemoryBroydenFletcherGoldfarbShannoSolver.cpp
示例18: inFile
/**OK
* Estrae il file fileName, contenuto nell'oggetto zip, con il nome fileDest.
* Se la funzione fallisce restituisce false e cancella il file che si e tentato di estrarre.
*
* La funzione fallisce se:
* * zip==NULL;
* * l'oggetto zip e stato aperto in una modalita non compatibile con l'estrazione di file;
* * non e possibile aprire il file all'interno dell'oggetto zip;
* * non e possibile creare il file estratto;
* * si e rilevato un errore nella copia dei dati (1);
* * non e stato possibile chiudere il file all'interno dell'oggetto zip (1);
*
* (1): prima di uscire dalla funzione cancella il file estratto.
*/
bool JlCompress::extractFile(QuaZip* zip, QString fileName, QString fileDest) {
// zip: oggetto dove aggiungere il file
// filename: nome del file reale
// fileincompress: nome del file all'interno del file compresso
// Controllo l'apertura dello zip
if (!zip) return false;
if (zip->getMode()!=QuaZip::mdUnzip) return false;
// Apro il file compresso
if (!fileName.isEmpty())
zip->setCurrentFile(fileName);
QuaZipFile inFile(zip);
if(!inFile.open(QIODevice::ReadOnly) || inFile.getZipError()!=UNZ_OK) return false;
// Controllo esistenza cartella file risultato
QDir curDir;
if (!curDir.mkpath(QFileInfo(fileDest).absolutePath())) {
return false;
}
QuaZipFileInfo info;
if (!zip->getCurrentFileInfo(&info))
return false;
if (fileDest.endsWith('/') && QFileInfo(fileDest).isDir()) {
return QFile(fileDest).setPermissions(info.getPermissions());
}
// Apro il file risultato
QFile outFile;
outFile.setFileName(fileDest);
if(!outFile.open(QIODevice::WriteOnly)) return false;
// Copio i dati
if (!copyData(inFile, outFile) || inFile.getZipError()!=UNZ_OK) {
outFile.close();
removeFile(QStringList(fileDest));
return false;
}
outFile.close();
// Chiudo i file
inFile.close();
if (inFile.getZipError()!=UNZ_OK) {
removeFile(QStringList(fileDest));
return false;
}
return outFile.setPermissions(info.getPermissions());
}
开发者ID:9DSmart,项目名称:apm_planner,代码行数:65,代码来源:JlCompress.cpp
示例19: outFile
/**OK
* Comprime il file fileName, nell'oggetto zip, con il nome fileDest.
*
* La funzione fallisce se:
* * zip==NULL;
* * l'oggetto zip e stato aperto in una modalita non compatibile con l'aggiunta di file;
* * non e possibile aprire il file d'origine;
* * non e possibile creare il file all'interno dell'oggetto zip;
* * si e rilevato un errore nella copia dei dati;
* * non e stato possibile chiudere il file all'interno dell'oggetto zip;
*/
bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest)
{
// zip: oggetto dove aggiungere il file
// fileName: nome del file reale
// fileDest: nome del file all'interno del file compresso
// Controllo l'apertura dello zip
if(!zip)
{
return false;
}
if(zip->getMode() != QuaZip::mdCreate &&
zip->getMode() != QuaZip::mdAppend &&
zip->getMode() != QuaZip::mdAdd)
{
return false;
}
// Apro il file originale
QFile inFile;
inFile.setFileName(fileName);
if(!inFile.open(QIODevice::ReadOnly))
{
return false;
}
// Apro il file risulato
QuaZipFile outFile(zip);
if(!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileDest, inFile.fileName())))
{
return false;
}
// Copio i dati
if(!copyData(inFile, outFile) || outFile.getZipError() != UNZ_OK)
{
return false;
}
// Chiudo i file
outFile.close();
if(outFile.getZipError() != UNZ_OK)
{
return false;
}
inFile.close();
return true;
}
开发者ID:Kojirion,项目名称:ChessX,代码行数:60,代码来源:JlCompress.cpp
示例20: getCreateQueryImpl
static ASTPtr getCreateQueryImpl(const String & path, const String & table_name)
{
String table_name_escaped = escapeForFileName(table_name);
String table_metadata_path = path + "/" + table_name_escaped + ".sql";
String query;
{
ReadBufferFromFile in(table_metadata_path, 4096);
WriteBufferFromString out(query);
copyData(in, out);
}
ParserCreateQuery parser;
return parseQuery(parser, query.data(), query.data() + query.size(), "in file " + table_metadata_path);
}
开发者ID:DieHertz,项目名称:ClickHouse,代码行数:15,代码来源:DatabaseOrdinary.cpp
注:本文中的copyData函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论