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


C++ Tuple::get方法代码示例

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


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

示例1: shdt_test_send_tuples

		void shdt_test_send_tuples() {
			
			Shdt::Writer w(&sender, buffer_, bufsize_,
					Shdt::write_callback_t::from_method<ExampleApplication, &ExampleApplication::shdt_test_receive_tuples>(this));
			w.write_header(table_size_, 3);
			
			for(block_data_t** t = test_tuples_; t[0]; t += 3) {
				Tuple tuple;
				
				#if USE_CODEC
					block_data_t *s = Codec::encode(t[0]);
					tuple.set(0, s); cstr_size_ += strlen((char*)s) + 1;
					s = Codec::encode(t[1]);
					tuple.set(1, s); cstr_size_ += strlen((char*)s) + 1;
					s = Codec::encode(t[2]);
					tuple.set(2, s); cstr_size_ += strlen((char*)s) + 1;
				
				#else
					tuple.set(0, t[0]); cstr_size_ += strlen((char*)t[0]) + 1;
					tuple.set(1, t[1]); cstr_size_ += strlen((char*)t[1]) + 1;
					tuple.set(2, t[2]); cstr_size_ += strlen((char*)t[2]) + 1;
				#endif
				
				w.write_tuple(tuple);
				
				#if USE_CODEC
					::get_allocator().free_array(tuple.get(0));
					::get_allocator().free_array(tuple.get(1));
					::get_allocator().free_array(tuple.get(2));
				#endif
			}
			
			w.flush();
		}
开发者ID:Darma,项目名称:wiselib,代码行数:34,代码来源:example_app.cpp

示例2: toVector

bool toVector(PyObjectPtr obj, std::vector<double>& result)
{
    bool knownType = true;

    if(NdArray::check(obj))
    {
        NdArray ndarray = {obj};
        const unsigned size = ndarray.size();
        result.resize(size);

        const int ndim = ndarray.ndim();
        if(ndim != 1)
            throw std::runtime_error("Array object has " + std::to_string(ndim)
                                     + " dimensions, expected 1");
        if(!ndarray.isDouble())
            throw std::runtime_error("Array object does not contain doubles");

        for(unsigned i = 0; i < size; i++)
            result[i] = ndarray.get(i);
    }
    else if(List::check(obj))
    {
        List list = {obj};
        const unsigned size = list.size();
        result.resize(size);

        for(unsigned i = 0; i < size; i++)
        {
            if(!list.isDouble(i))
                throw std::runtime_error(
                    "List object contains item that is not a double at index "
                    + std::to_string(i));
            result[i] = list.get(i);
            throwPythonException();
        }
    }
    else if(Tuple::check(obj))
    {
        Tuple tuple = {obj};
        const unsigned size = tuple.size();
        result.resize(size);

        for(unsigned i = 0; i < size; i++)
        {
            if(!tuple.isDouble(i))
                throw std::runtime_error(
                    "Tuple object contains item that is not a double at index "
                    + std::to_string(i));
            result[i] = tuple.get(i);
            throwPythonException();
        }
    }
    else
    {
        knownType = false;
    }

    return knownType;
}
开发者ID:AlexanderFabisch,项目名称:numpy-c-api,代码行数:59,代码来源:python_interpreter.cpp

示例3: shdt_test_receive_tuples

		void shdt_test_receive_tuples(Shdt::Writer& w) { //block_data_t *buffer, size_type buffer_size) {
			//debug_buffer<Os, 16, Os::Debug>(debug_, w.buffer(), w.buffer_used());
			
			packets_++;
			shdt_size_ += w.buffer_used();
			Shdt::Reader r(&receiver, w.buffer(), w.buffer_used());
			
			bool found;
			
			while(true) {
				Tuple t;
				found = r.read_tuple(t);
				if(!found) { break; }
				
				for(size_type i = 0; i < 3; i++, verify_idx_++) {
					char *s;
					#if USE_CODEC
						s = (char*)Codec::decode(t.get(i));
					#else
						s = (char*)t.get(i);
					#endif
					
					
					//DBG("t[%d]=%s test[%d]=%s", i, t.get(i), verify_idx_, test_tuples_[verify_idx_]);
					if(strcmp(s, (char*)test_tuples_[verify_idx_]) != 0) {
						debug_->debug("\x1b[31merror: t[%d]=%s != vrfy[%d]=%s\x1b[m", (int)i, (char*)t.get(i),
								(int)verify_idx_, (char*)test_tuples_[verify_idx_]);
						assert(false);
					}
					
					#if USE_CODEC
						::get_allocator().free_array(s);
					#endif
				}
			}
			
			w.reuse_buffer();
		}
开发者ID:Darma,项目名称:wiselib,代码行数:38,代码来源:example_app.cpp


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