Exemplo n.º 1
0
    /// Append a single microslice using given descriptor and content.
    uint64_t append_microslice(uint32_t component, uint64_t microslice,
                               MicrosliceDescriptor descriptor,
                               const uint8_t* content)
    {
        assert(component < timeslice_descriptor_.num_components);
        std::vector<uint8_t>& this_data = data_[component];
        TimesliceComponentDescriptor& this_desc = desc_[component];

        assert(microslice < this_desc.num_microslices);
        uint8_t* desc_bytes = reinterpret_cast<uint8_t*>(&descriptor);

        // set offset relative to first microslice
        if (microslice > 0) {
            uint64_t offset =
                this_data.size() -
                this_desc.num_microslices * sizeof(MicrosliceDescriptor);
            uint64_t first_offset =
                reinterpret_cast<MicrosliceDescriptor*>(this_data.data())
                    ->offset;
            descriptor.offset = offset + first_offset;
        }

        std::copy(desc_bytes, desc_bytes + sizeof(MicrosliceDescriptor),
                  &this_data[microslice * sizeof(MicrosliceDescriptor)]);

        this_data.insert(this_data.end(), content, content + descriptor.size);
        this_desc.size = this_data.size();

        init_pointers();
        return microslice;
    }
Exemplo n.º 2
0
Toolbar::Toolbar(QWidget *parent)
    :   QMenuBar(parent)
{
    init_pointers();
    init();
    
}
Exemplo n.º 3
0
    void serialize(Archive& ar, const unsigned int /* version */)
    {
        ar& timeslice_descriptor_;
        ar& data_;
        ar& desc_;

        init_pointers();
    }
Exemplo n.º 4
0
StorableTimeslice::StorableTimeslice(const Timeslice& ts)
    : data_(ts.timeslice_descriptor_.num_components),
      desc_(ts.timeslice_descriptor_.num_components)
{
    timeslice_descriptor_ = ts.timeslice_descriptor_;
    for (std::size_t component = 0;
         component < ts.timeslice_descriptor_.num_components; ++component) {
        uint64_t size = ts.desc_ptr_[component]->size;
        data_[component].resize(size);
        std::copy_n(ts.data_ptr_[component], size, data_[component].begin());
        desc_[component] = *ts.desc_ptr_[component];
    }

    init_pointers();
}
Exemplo n.º 5
0
    /// Append a single component to fill using append_microslice.
    uint32_t append_component(uint64_t num_microslices,
                              uint64_t /* dummy */ = 0)
    {
        TimesliceComponentDescriptor ts_desc = TimesliceComponentDescriptor();
        ts_desc.ts_num = timeslice_descriptor_.index;
        ts_desc.offset = 0;
        ts_desc.num_microslices = num_microslices;

        std::vector<uint8_t> data;
        for (uint64_t m = 0; m < num_microslices; ++m) {
            MicrosliceDescriptor desc = MicrosliceDescriptor();
            uint8_t* desc_bytes = reinterpret_cast<uint8_t*>(&desc);
            data.insert(data.end(), desc_bytes,
                        desc_bytes + sizeof(MicrosliceDescriptor));
        }

        ts_desc.size = data.size();
        desc_.push_back(ts_desc);
        data_.push_back(data);
        uint32_t component = timeslice_descriptor_.num_components++;

        init_pointers();
        return component;
    }
Exemplo n.º 6
0
StorableTimeslice::StorableTimeslice(const StorableTimeslice& ts)
    : Timeslice(ts), data_(ts.data_), desc_(ts.desc_)
{
    init_pointers();
}
Exemplo n.º 7
0
StorableTimeslice::StorableTimeslice(StorableTimeslice&& ts)
    : Timeslice(std::move(ts)), data_(std::move(ts.data_)),
      desc_(std::move(ts.desc_))
{
    init_pointers();
}
Exemplo n.º 8
0
char* parse_string(char* input_str) 
{
	char* begin_str; 
	char* end_str;
	char* out_buf = malloc(sizeof(char) * strlen(input_str) * BIZZBUZZ_LEN);
	int is_begin = 0, is_div = 0, lenght = 0, last_char = 0;
	unsigned long long sum = 0;
	
	while (input_str[0] != '\0')
	{
		if (!(input_str[0] >= '0' && input_str[0] <= '9'))
		{
			if (is_begin)
	 		{
	 			if (is_div = check_sum(sum, lenght, last_char))
				{
					fill_out_buf(is_div, &out_buf);	 				
	 				deinit_params(&is_begin, &sum, &lenght);
	 			}
	 			else
	 			{
					init_pointers(&input_str, &begin_str, &end_str);
					deinit_params(&is_begin, &sum, &lenght);					
					
					while (input_str != end_str)
					{
			 			out_buf[strlen(out_buf)] = input_str[0];
			 			input_str++;
					}				 
						
				}	 			
	 		}
	 		else
	 		{
				out_buf[strlen(out_buf)] = input_str[0];
	 			input_str++;
	 		}
	 	}
		else
	 	{
			if (!is_begin)
	 		{
	 			begin_str = input_str;
	 			is_begin = 1;
	 		}

	 		init_params(&lenght, input_str[0], &sum, &last_char);
	 			 
	 		if (input_str[1] == '\0') 
			{
				if (is_div = check_sum(sum, lenght, last_char))
				{
					fill_out_buf(is_div, &out_buf);	 				
	 				deinit_params(&is_begin, &sum, &lenght);
				}
				else
				{
					init_pointers(&input_str, &begin_str, &end_str);

					while (input_str != end_str )
					{
			 			out_buf[strlen(out_buf)] = input_str[0];
			 			input_str++;
					}				
				 		
			 		out_buf[strlen(out_buf)] = input_str[0];
				}	
			}
				
			input_str++;
		}	
	}
	
	return out_buf;
}