Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* libcdr
3 : * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
17 : *
18 : *
19 : * All Rights Reserved.
20 : *
21 : * For minor contributions see the git repository.
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
25 : * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
26 : * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
27 : * instead of those above.
28 : */
29 :
30 : #include <vector>
31 : #include "CDRStringVector.h"
32 :
33 : namespace libcdr
34 : {
35 0 : class CDRStringVectorImpl
36 : {
37 : public:
38 0 : CDRStringVectorImpl() : m_strings() {}
39 0 : ~CDRStringVectorImpl() {}
40 : std::vector<WPXString> m_strings;
41 : };
42 :
43 : } // namespace libcdr
44 :
45 0 : libcdr::CDRStringVector::CDRStringVector()
46 0 : : m_pImpl(new CDRStringVectorImpl())
47 : {
48 0 : }
49 :
50 0 : libcdr::CDRStringVector::CDRStringVector(const CDRStringVector &vec)
51 0 : : m_pImpl(new CDRStringVectorImpl(*(vec.m_pImpl)))
52 : {
53 0 : }
54 :
55 0 : libcdr::CDRStringVector::~CDRStringVector()
56 : {
57 0 : delete m_pImpl;
58 0 : }
59 :
60 0 : libcdr::CDRStringVector &libcdr::CDRStringVector::operator=(const CDRStringVector &vec)
61 : {
62 : // Check for self-assignment
63 0 : if (this == &vec)
64 0 : return *this;
65 0 : if (m_pImpl)
66 0 : delete m_pImpl;
67 0 : m_pImpl = new CDRStringVectorImpl(*(vec.m_pImpl));
68 0 : return *this;
69 : }
70 :
71 0 : unsigned libcdr::CDRStringVector::size() const
72 : {
73 0 : return (unsigned)(m_pImpl->m_strings.size());
74 : }
75 :
76 0 : bool libcdr::CDRStringVector::empty() const
77 : {
78 0 : return m_pImpl->m_strings.empty();
79 : }
80 :
81 0 : const WPXString &libcdr::CDRStringVector::operator[](unsigned idx) const
82 : {
83 0 : return m_pImpl->m_strings[idx];
84 : }
85 :
86 0 : void libcdr::CDRStringVector::append(const WPXString &str)
87 : {
88 0 : m_pImpl->m_strings.push_back(str);
89 0 : }
90 :
91 0 : void libcdr::CDRStringVector::clear()
92 : {
93 0 : m_pImpl->m_strings.clear();
94 0 : }
95 :
96 : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|