Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
vector_base.h
00001 ///\file 00002 00003 /****************************************************************************** 00004 The MIT License(MIT) 00005 00006 Embedded Template Library. 00007 https://github.com/ETLCPP/etl 00008 http://www.etlcpp.com 00009 00010 Copyright(c) 2014 jwellbelove 00011 00012 Permission is hereby granted, free of charge, to any person obtaining a copy 00013 of this software and associated documentation files(the "Software"), to deal 00014 in the Software without restriction, including without limitation the rights 00015 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell 00016 copies of the Software, and to permit persons to whom the Software is 00017 furnished to do so, subject to the following conditions : 00018 00019 The above copyright notice and this permission notice shall be included in all 00020 copies or substantial portions of the Software. 00021 00022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00023 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00024 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 00025 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00026 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00027 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00028 SOFTWARE. 00029 ******************************************************************************/ 00030 00031 #if !defined(__ETL_IN_VECTOR_H__) && !defined(__ETL_IN_PVOIDVECTOR__) 00032 #error This header is a private element of etl::vector & etl::pvoidvector 00033 #endif 00034 00035 #ifndef __ETL_VECTOR_BASE__ 00036 #define __ETL_VECTOR_BASE__ 00037 00038 #include <stddef.h> 00039 00040 #include "../platform.h" 00041 #include "../exception.h" 00042 #include "../error_handler.h" 00043 #include "../debug_count.h" 00044 00045 #define ETL_FILE "17" 00046 00047 namespace etl 00048 { 00049 //*************************************************************************** 00050 ///\ingroup vector 00051 /// Exception base for vectors 00052 //*************************************************************************** 00053 class vector_exception : public exception 00054 { 00055 public: 00056 00057 vector_exception(string_type reason_, string_type file_name_, numeric_type line_number_) 00058 : exception(reason_, file_name_, line_number_) 00059 { 00060 } 00061 }; 00062 00063 //*************************************************************************** 00064 ///\ingroup vector 00065 /// Vector full exception. 00066 //*************************************************************************** 00067 class vector_full : public vector_exception 00068 { 00069 public: 00070 00071 vector_full(string_type file_name_, numeric_type line_number_) 00072 : vector_exception(ETL_ERROR_TEXT("vector:full", ETL_FILE"A"), file_name_, line_number_) 00073 { 00074 } 00075 }; 00076 00077 //*************************************************************************** 00078 ///\ingroup vector 00079 /// Vector empty exception. 00080 //*************************************************************************** 00081 class vector_empty : public vector_exception 00082 { 00083 public: 00084 00085 vector_empty(string_type file_name_, numeric_type line_number_) 00086 : vector_exception(ETL_ERROR_TEXT("vector:empty", ETL_FILE"B"), file_name_, line_number_) 00087 { 00088 } 00089 }; 00090 00091 //*************************************************************************** 00092 ///\ingroup vector 00093 /// Vector out of bounds exception. 00094 //*************************************************************************** 00095 class vector_out_of_bounds : public vector_exception 00096 { 00097 public: 00098 00099 vector_out_of_bounds(string_type file_name_, numeric_type line_number_) 00100 : vector_exception(ETL_ERROR_TEXT("vector:bounds", ETL_FILE"C"), file_name_, line_number_) 00101 { 00102 } 00103 }; 00104 00105 //*************************************************************************** 00106 ///\ingroup vector 00107 /// Vector incompatible type exception. 00108 //*************************************************************************** 00109 class vector_incompatible_type : public vector_exception 00110 { 00111 public: 00112 00113 vector_incompatible_type(string_type file_name_, numeric_type line_number_) 00114 : vector_exception(ETL_ERROR_TEXT("vector:type", ETL_FILE"D"), file_name_, line_number_) 00115 { 00116 } 00117 }; 00118 00119 //*************************************************************************** 00120 ///\ingroup vector 00121 /// The base class for all templated vector types. 00122 //*************************************************************************** 00123 class vector_base 00124 { 00125 public: 00126 00127 typedef size_t size_type; 00128 00129 //************************************************************************* 00130 /// Returns the capacity of the vector. 00131 ///\return The capacity of the vector. 00132 //************************************************************************* 00133 size_type capacity() const 00134 { 00135 return CAPACITY; 00136 } 00137 00138 //************************************************************************* 00139 /// Returns the maximum possible size of the vector. 00140 ///\return The maximum size of the vector. 00141 //************************************************************************* 00142 size_type max_size() const 00143 { 00144 return CAPACITY; 00145 } 00146 00147 protected: 00148 00149 //************************************************************************* 00150 /// Constructor. 00151 //************************************************************************* 00152 vector_base(size_type max_size_) 00153 : CAPACITY(max_size_) 00154 { 00155 } 00156 00157 const size_type CAPACITY; ///<The maximum number of elements in the vector. 00158 etl::debug_count construct_count; ///< Internal debugging. 00159 }; 00160 } 00161 00162 #undef ETL_FILE 00163 00164 #endif 00165
Generated on Tue Jul 12 2022 14:05:46 by
