OSDN Git Service

Fix when setting ssh client is null. GIT_SSH environment variable is not clear
[tortoisegit/TortoiseGitJp.git] / src / Utils / stdex_vector.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2006 - Stefan Kueng\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 #include <vector>\r
22 \r
23 namespace stdex {\r
24 \r
25         /**\r
26          * Subclass of the STL's vector class that allows the class to be used more\r
27          * freely in place of a C-style array.\r
28          * @author Damian Powell\r
29          */\r
30         template <class T, class Al = std::allocator<T> >\r
31         class vector : public std::vector<T, Al> {\r
32 \r
33           public:\r
34 \r
35                 /**\r
36                  * Default constructor creates an empty vector.\r
37                  */\r
38                 inline vector()\r
39                 { }\r
40 \r
41                 /**\r
42                  * Creates a vector of n items where each item is initialized to its\r
43                  * default value as defined by 'T()'\r
44                  * @param n The number of items to allocate in the new vector.\r
45                  */\r
46                 inline vector(size_type n)\r
47                         : std::vector<T, Al> (n)\r
48                 { }\r
49 \r
50                 /**\r
51                  * Creates a vector of n items where each item is initialized to the\r
52                  * specified value t.\r
53                  * @param n The number of items to allocate in the new vector.\r
54                  * @param t The value that each new item shall be initialized to.\r
55                  */\r
56                 inline vector(size_type n, const T& t)\r
57                         : std::vector<T, Al> (n, t)\r
58                 { }\r
59 \r
60                 /**\r
61                  * Index operator returns reference to the specified immutable item.\r
62                  * No additional bounds checking is performed.\r
63                  * @param i The index of the value to return a reference to.\r
64                  * @return An immutable reference to the item at index i.\r
65                  */\r
66                 inline const_reference operator [] (size_type i) const {\r
67                         ASSERT(i < size());\r
68                         return std::vector<T, Al>::operator [] (i);\r
69                 }\r
70 \r
71                 /**\r
72                  * Index operator returns a reference to the specified item. No\r
73                  * additional bounds checking is performed.\r
74                  * @param i The index of the value to return a reference to.\r
75                  * @return A reference to the item at index i.\r
76                  */\r
77                 inline reference operator [] (size_type i) {\r
78                         ASSERT(i < size());\r
79                         return std::vector<T, Al>::operator [] (i);\r
80                 }\r
81 \r
82                 /**\r
83                  * Conversion operator returns pointer to the immutable item at the\r
84                  * beginning of this array of NULL if the array is empty.\r
85                  * @param i The index of the value to return a reference to.\r
86                  * @return A pointer to an immutable item or NULL.\r
87                  */\r
88                 inline operator const_pointer () const {\r
89                         return empty() ? NULL : &operator[](0);\r
90                 }\r
91 \r
92                 /**\r
93                  * Conversion operator returns pointer to the item at the beginning of\r
94                  * this array of NULL if the array is empty.\r
95                  * @param i The index of the value to return a reference to.\r
96                  * @return A pointer to an item or NULL.\r
97                  */\r
98                 inline operator pointer () {\r
99                         return empty() ? NULL : &operator[](0);\r
100                 }\r
101 \r
102         };\r
103 \r
104 }\r