1 : |
agomez |
1 |
#ifndef charptrvector_h
|
2 : |
|
|
#define charptrvector_h
|
3 : |
|
|
|
4 : |
|
|
/**
|
5 : |
|
|
* \class CharPtrVector
|
6 : |
|
|
* \brief This class implements a dynamic vector of char values
|
7 : |
|
|
*/
|
8 : |
|
|
class CharPtrVector {
|
9 : |
|
|
public:
|
10 : |
|
|
/**
|
11 : |
|
|
* \brief This is the default CharPtrVector constructor
|
12 : |
|
|
*/
|
13 : |
|
|
CharPtrVector() { size = 0; v = 0; };
|
14 : |
|
|
/**
|
15 : |
|
|
* \brief This is the CharPtrVector constructor that creates a copy of an existing CharPtrVector
|
16 : |
|
|
* \param initial is the CharPtrVector to copy
|
17 : |
|
|
*/
|
18 : |
|
|
CharPtrVector(const CharPtrVector& initial);
|
19 : |
|
|
/**
|
20 : |
|
|
* \brief This is the CharPtrVector destructor
|
21 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
22 : |
|
|
*/
|
23 : |
|
|
~CharPtrVector();
|
24 : |
|
|
/**
|
25 : |
|
|
* \brief This will add new blank (ie. NULL) entries to the vector
|
26 : |
|
|
* \param addsize is the number of blank entries that will be entered
|
27 : |
|
|
*/
|
28 : |
|
|
void resizeBlank(int addsize);
|
29 : |
|
|
/**
|
30 : |
|
|
* \brief This will add one new entry to the vector
|
31 : |
|
|
* \param value is the value that will be entered for the new entry
|
32 : |
|
|
*/
|
33 : |
|
|
void resize(char* value);
|
34 : |
|
|
/**
|
35 : |
|
|
* \brief This will delete an entry from the vector
|
36 : |
|
|
* \param pos is the element of the vector to be deleted
|
37 : |
|
|
* \note This will free the memory allocated to the deleted element of the vector
|
38 : |
|
|
*/
|
39 : |
|
|
void Delete(int pos);
|
40 : |
|
|
/**
|
41 : |
|
|
* \brief This will return the size of the vector
|
42 : |
|
|
* \return the size of the vector
|
43 : |
|
|
*/
|
44 : |
|
|
int Size() const { return size; };
|
45 : |
|
|
/**
|
46 : |
|
|
* \brief This will return the value of an element of the vector
|
47 : |
|
|
* \param pos is the element of the vector to be returned
|
48 : |
|
|
* \return the value of the specified element
|
49 : |
|
|
*/
|
50 : |
|
|
char*& operator [] (int pos) { return v[pos]; };
|
51 : |
|
|
/**
|
52 : |
|
|
* \brief This will return the value of an element of the vector
|
53 : |
|
|
* \param pos is the element of the vector to be returned
|
54 : |
|
|
* \return the value of the specified element
|
55 : |
|
|
*/
|
56 : |
|
|
char* const& operator [] (int pos) const { return v[pos]; };
|
57 : |
|
|
/**
|
58 : |
|
|
* \brief This will reset the vector
|
59 : |
|
|
* \note This will delete every entry from the vector and set the size to zero
|
60 : |
|
|
*/
|
61 : |
|
|
void Reset();
|
62 : |
|
|
/**
|
63 : |
|
|
* \brief This operator will set the vector equal to an existing CharPtrVector
|
64 : |
|
|
* \param cv is the CharPtrVector to copy
|
65 : |
|
|
*/
|
66 : |
|
|
CharPtrVector& operator = (const CharPtrVector& cv);
|
67 : |
|
|
protected:
|
68 : |
|
|
/**
|
69 : |
|
|
* \brief This is the vector of char values
|
70 : |
|
|
*/
|
71 : |
|
|
char** v;
|
72 : |
|
|
/**
|
73 : |
|
|
* \brief This is the size of the vector
|
74 : |
|
|
*/
|
75 : |
|
|
int size;
|
76 : |
|
|
};
|
77 : |
|
|
|
78 : |
|
|
#endif
|