GCStringVector.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /****************************************************************************
  2. (c) 2005 by STEMMER IMAGING
  3. // License: This file is published under the license of the EMVA GenICam Standard Group.
  4. // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
  5. // If for some reason you are missing this file please contact the EMVA or visit the website
  6. // (http://www.genicam.org) for a full copy.
  7. //
  8. // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
  9. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  10. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11. // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
  12. // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  13. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  15. // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  16. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  17. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  18. // POSSIBILITY OF SUCH DAMAGE.
  19. ****************************************************************************/
  20. /// \file
  21. /// \brief Portable string vector implementation
  22. /// \ingroup Base_PublicUtilities
  23. #ifndef GENICAM_GCSTRINGLIST_H
  24. #define GENICAM_GCSTRINGLIST_H
  25. #include <Base/GCTypes.h>
  26. #include <Base/GCString.h>
  27. #pragma pack(push, 8)
  28. #if defined (_WIN32) || (defined (__GNUC__) && (defined (__linux__) || defined(__APPLE__) || defined(VXWORKS)))
  29. namespace GENICAM_NAMESPACE
  30. {
  31. /**
  32. \brief A vector of gcstrings which is a clone of std::vector<std::string>
  33. \ingroup Base_PublicUtilities
  34. */
  35. class GCBASE_API gcstring_vector
  36. {
  37. // Nested types
  38. // ---------------------------------------------------------------------------
  39. public:
  40. class GCBASE_API const_iterator
  41. {
  42. // Ctor / Dtor
  43. // -------------------------------------------------------------------------
  44. public:
  45. const_iterator(gcstring *pStr = 0);
  46. // Operators
  47. // -------------------------------------------------------------------------
  48. public:
  49. const gcstring & operator * (void) const;
  50. const gcstring * operator -> (void) const;
  51. const_iterator & operator ++ (void);
  52. const_iterator operator ++ (int);
  53. const_iterator & operator -- (void);
  54. const_iterator operator -- (int);
  55. const_iterator & operator += (intptr_t iInc);
  56. const_iterator operator + (intptr_t iInc) const;
  57. const_iterator & operator -= (intptr_t iDec);
  58. intptr_t operator - (const const_iterator &iter) const;
  59. const_iterator operator - (intptr_t iDec) const;
  60. const gcstring & operator [] (intptr_t iIndex) const;
  61. bool operator == (const const_iterator &iter) const;
  62. bool operator != (const const_iterator &iter) const;
  63. bool operator < (const const_iterator &iter) const;
  64. bool operator > (const const_iterator &iter) const;
  65. bool operator <= (const const_iterator &iter) const;
  66. bool operator >= (const const_iterator &iter) const;
  67. GCBASE_API
  68. friend const_iterator operator + (intptr_t iInc, const const_iterator &iter);
  69. // Member
  70. // -------------------------------------------------------------------------
  71. protected:
  72. gcstring * _ps;
  73. };
  74. class GCBASE_API iterator :
  75. public const_iterator
  76. {
  77. // Ctor / Dtor
  78. // -------------------------------------------------------------------------
  79. public:
  80. iterator(gcstring *pStr = 0);
  81. // Operators
  82. // -------------------------------------------------------------------------
  83. public:
  84. gcstring & operator * (void) const;
  85. gcstring * operator -> (void) const;
  86. iterator & operator ++ (void);
  87. iterator operator ++ (int);
  88. iterator & operator -- (void);
  89. iterator operator -- (int);
  90. iterator & operator += (intptr_t iInc);
  91. iterator operator + (intptr_t iInc) const;
  92. iterator & operator -= (intptr_t iDec);
  93. intptr_t operator - (const iterator &iter) const;
  94. iterator operator - (intptr_t iDec) const;
  95. gcstring & operator [] (intptr_t iIndex) const;
  96. GCBASE_API
  97. friend iterator operator + (intptr_t iInc, const iterator &iter);
  98. };
  99. // Ctor / Dtor
  100. // ---------------------------------------------------------------------------
  101. public:
  102. gcstring_vector(void);
  103. explicit gcstring_vector(size_t uiSize, const gcstring &str = gcstring());
  104. gcstring_vector(const gcstring_vector &obj);
  105. virtual ~gcstring_vector(void);
  106. // Element access
  107. // ---------------------------------------------------------------------------
  108. public:
  109. virtual void assign(size_t n, const gcstring &val);
  110. virtual void clear(void);
  111. virtual iterator erase(iterator pos);
  112. virtual gcstring & at(size_t uiIndex);
  113. virtual const gcstring & at(size_t uiIndex) const;
  114. virtual gcstring & back(void);
  115. virtual const gcstring & back(void) const;
  116. virtual iterator begin(void);
  117. virtual const_iterator begin(void) const;
  118. virtual size_t capacity(void) const;
  119. virtual iterator end(void);
  120. virtual const_iterator end(void) const;
  121. virtual gcstring & front(void);
  122. virtual const gcstring & front(void) const;
  123. virtual size_t max_size(void) const;
  124. virtual size_t size(void) const;
  125. virtual iterator insert(iterator pos, const gcstring &str);
  126. virtual bool empty(void) const;
  127. virtual void pop_back(void);
  128. virtual void push_back(const gcstring &str);
  129. virtual void resize(size_t uiSize, const gcstring &str = gcstring());
  130. virtual void reserve(size_t uiSize);
  131. virtual bool contains(const gcstring &str) const;
  132. // Do not use the methods below - they only exist for
  133. // backwards compatibility
  134. virtual gcstring_vector & assign(const gcstring_vector &obj);
  135. virtual void erase(size_t uiIndex);
  136. virtual void insert(size_t uiIndex, const gcstring &str);
  137. // Operators
  138. // ---------------------------------------------------------------------------
  139. public:
  140. gcstring_vector & operator = (const gcstring_vector &obj);
  141. gcstring & operator [] (size_t uiIndex);
  142. const gcstring & operator [] (size_t uiIndex) const;
  143. void operator delete (void *pWhere);
  144. void * operator new (size_t uiSize);
  145. // Member
  146. // ---------------------------------------------------------------------------
  147. private:
  148. void * _pv;
  149. };
  150. }
  151. #else
  152. # error No known support for shared libraries
  153. #endif
  154. #pragma pack(pop)
  155. #endif // GENICAM_GCSTRINGLIST_H