-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathArrayView.h
More file actions
60 lines (44 loc) · 1.45 KB
/
ArrayView.h
File metadata and controls
60 lines (44 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Copyright (c) 2017 HERE Europe B.V.
* See the LICENSE file in the root of this project for license details.
*/
#pragma once
#include "internal/ArrayViewIterator.h"
#include <cstddef>
#include <cstdlib>
#include <sstream>
namespace flatdata
{
template < typename T >
class ArrayView
{
public:
using ConstValueType = typename T::AccessorType;
using ConstStreamType = typename T::AccessorType::StreamType;
using const_iterator = ArrayViewIterator< T >;
public:
explicit ArrayView( ConstStreamType data_begin = nullptr, ConstStreamType data_end = nullptr );
ConstValueType operator[]( size_t i ) const;
const_iterator begin( ) const;
const_iterator end( ) const;
ConstStreamType data( ) const;
ConstValueType front( ) const;
ConstValueType back( ) const;
ArrayView slice( size_t pos, size_t length ) const;
ArrayView slice( std::pair< size_t /*start*/, size_t /*end*/ > range ) const;
ArrayView slice_before( size_t pos ) const;
ArrayView slice_after( size_t pos ) const;
ArrayView skip( size_t count ) const;
ArrayView skip_last( size_t count ) const;
explicit operator bool( ) const;
size_t size_in_bytes( ) const;
size_t size( ) const;
std::string describe( size_t nest_level = 0u ) const;
bool empty( ) const;
private:
ArrayView( ConstStreamType data, size_t size );
ConstStreamType m_data;
size_t m_size;
};
} // namespace flatdata
#include "internal/ArrayView.inl"