Change-Id: Ifdaea3bf0969f15eb70629a92c0293ddeee33491
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
///
const std::vector<uint8_t> message_t::get_data_vector(int start, int end) const
{
///
const std::vector<uint8_t> message_t::get_data_vector(int start, int end) const
{
- std::vector<uint8_t> ret;
- if(start >= 0)
- {
- if(end<length_)
- {
- for(int i=start;i<=end;i++)
- {
- ret.push_back(data_[i]);
- }
- }
- else
- {
- for(int i=start;i<length_;i++)
- {
- ret.push_back(data_[i]);
- }
- }
- }
- else
+ if ( start > length_ || end > length_ )
{
AFB_ERROR("Error index to get data vector, [%d-%d] - for length %d", start, end, length_);
{
AFB_ERROR("Error index to get data vector, [%d-%d] - for length %d", start, end, length_);
+
+ std::vector<uint8_t>::const_iterator first = data_.begin() + start;
+ std::vector<uint8_t>::const_iterator last = data_.begin() + end;
+ std::vector<uint8_t> ret(first, last);
+