Embedded Template Library
1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vector_base.h
Go to the documentation of this file.
1
2
3
/******************************************************************************
4
The MIT License(MIT)
5
6
Embedded Template Library.
7
https://github.com/ETLCPP/etl
8
https://www.etlcpp.com
9
10
Copyright(c) 2014 John Wellbelove
11
12
Permission is hereby granted, free of charge, to any person obtaining a copy
13
of this software and associated documentation files(the "Software"), to deal
14
in the Software without restriction, including without limitation the rights
15
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16
copies of the Software, and to permit persons to whom the Software is
17
furnished to do so, subject to the following conditions :
18
19
The above copyright notice and this permission notice shall be included in all
20
copies or substantial portions of the Software.
21
22
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
SOFTWARE.
29
******************************************************************************/
30
31
#if !defined(ETL_IN_VECTOR_H) && !defined(ETL_IN_PVOIDVECTOR)
32
#error This header is a private element of etl::vector & etl::pvoidvector
33
#endif
34
35
#ifndef ETL_VECTOR_BASE_INCLUDED
36
#define ETL_VECTOR_BASE_INCLUDED
37
38
#include "
../platform.h
"
39
#include "
../debug_count.h
"
40
#include "
../error_handler.h
"
41
#include "
../exception.h
"
42
43
#include <stddef.h>
44
45
namespace
etl
46
{
47
//***************************************************************************
50
//***************************************************************************
51
class
vector_exception :
public
exception
52
{
53
public
:
54
55
vector_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
56
:
exception
(reason_, file_name_, line_number_)
57
{
58
}
59
};
60
61
//***************************************************************************
64
//***************************************************************************
65
class
vector_full :
public
vector_exception
66
{
67
public
:
68
69
vector_full(string_type file_name_, numeric_type line_number_)
70
: vector_exception(ETL_ERROR_TEXT(
"vector:full"
, ETL_VECTOR_FILE_ID
"A"
), file_name_, line_number_)
71
{
72
}
73
};
74
75
//***************************************************************************
78
//***************************************************************************
79
class
vector_empty :
public
vector_exception
80
{
81
public
:
82
83
vector_empty(string_type file_name_, numeric_type line_number_)
84
: vector_exception(ETL_ERROR_TEXT(
"vector:empty"
, ETL_VECTOR_FILE_ID
"B"
), file_name_, line_number_)
85
{
86
}
87
};
88
89
//***************************************************************************
92
//***************************************************************************
93
class
vector_out_of_bounds :
public
vector_exception
94
{
95
public
:
96
97
vector_out_of_bounds(string_type file_name_, numeric_type line_number_)
98
: vector_exception(ETL_ERROR_TEXT(
"vector:bounds"
, ETL_VECTOR_FILE_ID
"C"
), file_name_, line_number_)
99
{
100
}
101
};
102
103
//***************************************************************************
106
//***************************************************************************
107
class
vector_incompatible_type :
public
vector_exception
108
{
109
public
:
110
111
vector_incompatible_type(string_type file_name_, numeric_type line_number_)
112
: vector_exception(ETL_ERROR_TEXT(
"vector:type"
, ETL_VECTOR_FILE_ID
"D"
), file_name_, line_number_)
113
{
114
}
115
};
116
117
//***************************************************************************
120
//***************************************************************************
121
class
vector_base
122
{
123
public
:
124
125
typedef
size_t
size_type;
126
127
//*************************************************************************
130
//*************************************************************************
131
size_type
capacity
()
const
132
{
133
return
CAPACITY
;
134
}
135
136
//*************************************************************************
139
//*************************************************************************
140
size_type
max_size
()
const
141
{
142
return
CAPACITY
;
143
}
144
145
protected
:
146
147
//*************************************************************************
149
//*************************************************************************
150
vector_base
(
size_t
max_size_)
151
:
CAPACITY
(max_size_)
152
{
153
}
154
155
//*************************************************************************
157
//*************************************************************************
158
#if defined(ETL_POLYMORPHIC_VECTOR) || defined(ETL_POLYMORPHIC_CONTAINERS) || defined(ETL_IVECTOR_REPAIR_ENABLE)
159
160
public
:
161
162
virtual
~vector_base
() {}
163
#else
164
165
protected
:
166
167
~vector_base
() {}
168
#endif
169
170
const
size_type
CAPACITY
;
171
ETL_DECLARE_DEBUG_COUNT
;
172
};
173
}
// namespace etl
174
175
#endif
debug_count.h
error_handler.h
exception.h
etl::exception::exception
ETL_EXCEPTION_CONSTEXPR exception(string_type reason_, string_type, numeric_type)
Constructor.
Definition
exception.h:81
etl::vector_base::max_size
size_type max_size() const
Definition
vector_base.h:140
etl::vector_base::capacity
size_type capacity() const
Definition
vector_base.h:131
etl::vector_base::vector_base
vector_base(size_t max_size_)
Constructor.
Definition
vector_base.h:150
etl::vector_base::CAPACITY
const size_type CAPACITY
The maximum number of elements in the vector.
Definition
vector_base.h:170
etl::vector_base::ETL_DECLARE_DEBUG_COUNT
ETL_DECLARE_DEBUG_COUNT
Internal debugging.
Definition
vector_base.h:171
etl::vector_base::~vector_base
~vector_base()
Destructor.
Definition
vector_base.h:167
etl
Definition
absolute.h:40
platform.h
include
etl
private
vector_base.h
Generated on
for Embedded Template Library by
1.17.0