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


C++ DataReader类代码示例

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


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

示例1: CSVDataReader

bool TestDataReaders::TestCSVDataReader(SourceReader* sourceReader, vector<CSVDataType*> results) {
	bool ok = true;
	DataReader* dataReader = new CSVDataReader(sourceReader);

	for (int i = 0; i < results.size(); ++i) {
		CSVDataType* csvDataType = (CSVDataType*) dataReader->GetNextData();

		if (csvDataType == NULL || results[i] == NULL) {
			if (csvDataType != NULL || results[i] != NULL)
				ok = false;
		} else {
			if (csvDataType->GetColNames() != results[i]->GetColNames())
				ok = false;
			else {
				int size = csvDataType->GetColNames().size();
				for (int j = 0; j < size; ++j) {
					if (csvDataType->GetValue(j) != results[i]->GetValue(j)) {
						ok = false;
					}
				}
			}

			delete csvDataType;
		}
	}

	delete dataReader;
	return ok;
}
开发者ID:quom,项目名称:oculus-trading-desk,代码行数:29,代码来源:TestDataReaders.cpp

示例2: read

void SamplingProvider::read(DataReader &reader) {
    reader.read(this->m_sampling_radius);
    reader.read(this->m_curvatures);
    reader.read(this->m_barycentric_areas);
    reader.read(this->m_geodesics);
    reader.read(this->m_samples);
}
开发者ID:NagaoKagetora,项目名称:geometric-terminal,代码行数:7,代码来源:SamplingProvider.cpp

示例3: main

int
main(void)
{
	DataReader reader;
	std::vector<fv_t> data;
	std::vector<fv_t> test_data;
	std::vector<label_t> labels;
	std::vector<label_t> test_labels;
	category_index_t category_index;
	NearestCentroidClassifier centroid_classifier;
	TFIDFTransformer tfidf;
	long t = tick();
	long t_all = tick();
	Evaluation evaluation;
	
	if (!reader.open(TRAIN_DATA)) {
		fprintf(stderr, "cant read file\n");
		return -1;
	}
	reader.read(data, labels);
	printf("read %ld, %ld, %ldms\n", data.size(), labels.size(), tick() - t);
	reader.close();
	
	t = tick();
	srand(VT_SEED);
	build_category_index(category_index, data, labels);
	split_data(test_data, test_labels, data, labels, category_index, 0.05f);
	build_category_index(category_index, data, labels);
	printf("split train:%ld, test:%ld\n", data.size(), test_data.size());
	
	t = tick();
	tfidf.train(data);
	tfidf.transform(data);
	tfidf.transform(test_data);
	centroid_classifier.train(category_index, data);
	printf("build index %ldms\n", tick() -t );
	
	t = tick();
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic, 1)	
#endif
	for (int i = 0; i < (int)test_data.size(); ++i) {
		std::vector<int> topn_labels;
		centroid_classifier.predict(topn_labels, K, test_data[i]);
#ifdef _OPENMP
#pragma omp critical
#endif
		{
			evaluation.update(topn_labels, test_labels[i]);
			if (i % 1000 == 0) {
				print_evaluation(evaluation, i, t);
				t = tick();
			}
		}
	}
	printf("----\n");
	print_evaluation(evaluation, test_data.size(), t_all);
	
	return 0;
}
开发者ID:StevenLOL,项目名称:kaggle-lshtc-1,代码行数:60,代码来源:vt_ncc.cpp

示例4: fprintf

    void
SAMReader::readHeader(
    const char* fileName,
    ReaderContext& context)
{
    DataReader* data = DataSupplier::Default[false]->getDataReader(maxLineLen);
    if (! data->init(fileName)) {
        fprintf(stderr, "Unable to read file %s\n", fileName);
        soft_exit(1);
    }
    // todo: allow for larger headers
    _int64 headerSize = 1024 * 1024; // 1M header max
    char* buffer = data->readHeader(&headerSize);
    if (!parseHeader(fileName, buffer, buffer + headerSize, context.genome, &headerSize, &context.headerMatchesIndex)) {
        fprintf(stderr,"SAMReader: failed to parse header on '%s'\n",fileName);
        soft_exit(1);
    }
    _ASSERT(context.header == NULL);
    char* p = new char[headerSize + 1];
    memcpy(p, buffer, headerSize);
    p[headerSize] = 0;
    context.header = p;
    context.headerBytes = context.headerLength = headerSize;
    delete data;
}
开发者ID:Martinsos,项目名称:snap,代码行数:25,代码来源:SAM.cpp

示例5: readVolumeData

std::unique_ptr<float []>
readVolumeData(const std::string& dtype, const std::string& fpath,
    size_t volx, size_t voly, size_t volz)
{
  bd::DataType t = bd::to_dataType(dtype);
  float* rawdata = nullptr;
  switch (t) {
  case bd::DataType::Float:
    {
      bd::DataReader<float, float> reader;
      reader.loadRaw3d(fpath, volx, voly, volz, false);
      rawdata = reader.takeOwnership();
      break;
    }
  case bd::DataType::UnsignedCharacter:
    {
      bd::DataReader<unsigned char, float> reader;
      reader.loadRaw3d(fpath, volx, voly, volz, false);
      rawdata = reader.takeOwnership();
      break;
    }
  case bd::DataType::UnsignedShort:
    {
      DataReader<unsigned short, float> reader;
      reader.loadRaw3d(fpath, volx, voly, volz, false);
      rawdata = reader.takeOwnership();
      break;
    }
  default:
    break;
  }

  return std::unique_ptr<float[]>(rawdata);
}
开发者ID:MEC402,项目名称:cruft,代码行数:34,代码来源:util.cpp

示例6: pushDataPacket

void Listener::pushDataPacket(DataReader& reader) {
	if (!_pDataWriter && !init())
		return;

	if(publication.publisher()) {
		if(ICE::ProcessSDPPacket(reader,(Peer&)*publication.publisher(),publication.publisher()->writer(),(Peer&)client,*_pDataWriter))
			return;
	}

	if(_pDataTypeName == typeid(reader).name()) {
		if(!_pDataWriter->writeMedia(Writer::DATA,0,reader.packet,*this))
			init();
		return;
	}

	shared_ptr<DataWriter> pWriter;
	_pDataWriter->createWriter(pWriter);
	if (!pWriter) {
		if(!_pDataWriter->writeMedia(Writer::DATA,0,reader.packet,*this))
			init();
		return;
	}
	
	UInt32 offset = pWriter->packet.size();
	reader.read(*pWriter);
	reader.reset();
	PacketReader packet(pWriter->packet.data(),pWriter->packet.size());
	packet.next(offset);
	if(!_pDataWriter->writeMedia(Writer::DATA,0,packet,*this))
		init();
}
开发者ID:taililong,项目名称:MonaServer,代码行数:31,代码来源:Listener.cpp

示例7: read

void GeodesicProvider::read(DataReader &reader) {
	reader.read(this->m_source_vertices);
	reader.read(this->m_target_vertices);
	reader.read(this->m_algorithm_option);
	reader.read(this->m_subdivision_level);
	reader.read(this->m_geodesics);
}
开发者ID:NagaoKagetora,项目名称:geometric-terminal,代码行数:7,代码来源:GeodesicProvider.cpp

示例8: read_results

bool Solver::read_results() {

    try {

        DataReader dr;

        dr.readAll(gyro::RESULT_FILE, *result_data);

        load(*result_data);

        msg = "Successfully finished!";
    }
    catch (ios_base::failure& ) {

        msg += "failed to read the output of the solver!";
        return FAILED;
    }
    catch (exception& e) {

        msg += "unexpected error ";
        msg += e.what();
        return FAILED;
    }

    return SUCCESS;
}
开发者ID:szte-wsn,项目名称:szte-wsn,代码行数:26,代码来源:Solver.cpp

示例9: readName

void ClientSocket::readName(DataReader r){
    int id = r.readInt();
    char buf[33];
    r.read(buf,32);
    if(g.names.size()<=id)g.names.resize(id+20);
    g.names[id] = buf;
    std::cout<<id<<" is "<<buf<<"\n";
}
开发者ID:sisu,项目名称:taisto2,代码行数:8,代码来源:ClientSocket.cpp

示例10:

int VertexLoaderX64::RunVertices(DataReader src, DataReader dst, int count)
{
	m_numLoadedVertices += count;
	return ((int (*)(u8*, u8*, int, const void*))region)(
		src.GetPointer(),
		dst.GetPointer(),
		count,
		memory_base_ptr);
}
开发者ID:feitingen,项目名称:dolphin,代码行数:9,代码来源:VertexLoaderX64.cpp

示例11: Extract

void TextAssetExtractor::Extract(FileWriter& writer, DataReader& reader, size_t length)
{
	uint32_t len = reader.ReadNumber<uint32_t>();
	reader.Skip(len);
	reader.Align(4);

	len = reader.ReadNumber<uint32_t>();
	reader.WriteFile(writer, reader.Tell(), len);
}
开发者ID:AmbBAI,项目名称:UnityAssetTool,代码行数:9,代码来源:textasset_extractor.cpp

示例12: loadMem

	int Wav::loadMem(unsigned char *aMem, int aLength)
	{
		if (aMem == NULL || aLength <= 0)
			return INVALID_PARAMETER;

		DataReader dr;
        dr.open(aMem, aLength);
		return testAndLoadFile(&dr);
	}
开发者ID:kvisle,项目名称:soloud,代码行数:9,代码来源:soloud_wav.cpp

示例13: load

	int Wav::load(const char *aFilename)
	{
		DataReader dr;
		if (!dr.open(aFilename))
        {
			return FILE_NOT_FOUND;
        }
		return testAndLoadFile(&dr);
	}
开发者ID:kvisle,项目名称:soloud,代码行数:9,代码来源:soloud_wav.cpp

示例14: readItems

void ClientSocket::readItems(DataReader r)
{
	int n=r.readInt();
	Item it;
	for(int i=0; i<n; ++i) {
		r.read(&it, sizeof(it));
		g.items_map.insert(it);
	}
}
开发者ID:sisu,项目名称:taisto2,代码行数:9,代码来源:ClientSocket.cpp

示例15: Nikita

void Nikita()
{
    DataReader<int, string> reader;
    
    FibonacciTable<int, string> table;
    
    reader.getData( table );
    
    system( "pause" );
}
开发者ID:Stivens73,项目名称:2016_hash_project,代码行数:10,代码来源:final.cpp


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