| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ |
| 2 | /* librevenge |
| 3 | * Version: MPL 2.0 / LGPLv2.1+ |
| 4 | * |
| 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 | * |
| 9 | * Major Contributor(s): |
| 10 | * Copyright (C) 2012 Fridrich Strba ([email protected]) |
| 11 | * |
| 12 | * For minor contributions see the git repository. |
| 13 | * |
| 14 | * Alternatively, the contents of this file may be used under the terms |
| 15 | * of the GNU Lesser General Public License Version 2.1 or later |
| 16 | * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are |
| 17 | * applicable instead of those above. |
| 18 | */ |
| 19 | |
| 20 | #include <librevenge/librevenge.h> |
| 21 | |
| 22 | #include <vector> |
| 23 | |
| 24 | namespace librevenge |
| 25 | { |
| 26 | |
| 27 | class RVNGStringVectorImpl |
| 28 | { |
| 29 | public: |
| 30 | RVNGStringVectorImpl() : m_strings() {} |
| 31 | ~RVNGStringVectorImpl() {} |
| 32 | std::vector<RVNGString> m_strings; |
| 33 | }; |
| 34 | |
| 35 | RVNGStringVector::RVNGStringVector() |
| 36 | : m_pImpl(new RVNGStringVectorImpl()) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | RVNGStringVector::RVNGStringVector(const RVNGStringVector &vec) |
| 41 | : m_pImpl(new RVNGStringVectorImpl(*(vec.m_pImpl))) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | RVNGStringVector::~RVNGStringVector() |
| 46 | { |
| 47 | delete m_pImpl; |
| 48 | } |
| 49 | |
| 50 | RVNGStringVector &RVNGStringVector::operator=(const RVNGStringVector &vec) |
| 51 | { |
| 52 | // Check for self-assignment |
| 53 | if (this == &vec) |
| 54 | return *this; |
| 55 | if (m_pImpl) |
| 56 | delete m_pImpl; |
| 57 | m_pImpl = new RVNGStringVectorImpl(*(vec.m_pImpl)); |
| 58 | return *this; |
| 59 | } |
| 60 | |
| 61 | unsigned RVNGStringVector::size() const |
| 62 | { |
| 63 | return (unsigned)(m_pImpl->m_strings.size()); |
| 64 | } |
| 65 | |
| 66 | bool RVNGStringVector::empty() const |
| 67 | { |
| 68 | return m_pImpl->m_strings.empty(); |
| 69 | } |
| 70 | |
| 71 | const RVNGString &RVNGStringVector::operator[](unsigned idx) const |
| 72 | { |
| 73 | return m_pImpl->m_strings[idx]; |
| 74 | } |
| 75 | |
| 76 | void RVNGStringVector::append(const RVNGString &str) |
| 77 | { |
| 78 | m_pImpl->m_strings.push_back(str); |
| 79 | } |
| 80 | |
| 81 | void RVNGStringVector::clear() |
| 82 | { |
| 83 | m_pImpl->m_strings.clear(); |
| 84 | } |
| 85 | |
| 86 | } |
| 87 | |
| 88 | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |