summaryrefslogtreecommitdiff
path: root/item/source/simple/CntOUString.cxx
blob: 4f7bbfea6d4faece85ab195369b74c6d818ab112 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <cassert>
#include <item/simple/CntOUString.hxx>

///////////////////////////////////////////////////////////////////////////////

namespace Item
{
    CntOUString::CntOUString(const rtl::OUString& rValue)
    :   CntOUStringStaticHelper(),
        m_aValue(rValue)
    {
    }

    CntOUString::~CntOUString()
    {
        // needs to be called from here to have the fully derived implementation type
        // in the helper method - do NOT move to a imaginable general
        // implementation in IBaseStaticHelper (!)
        if(IsAdministrated())
        {
            GetStaticAdmin().HintExpired(this);
        }
    }

    std::shared_ptr<const CntOUString> CntOUString::Create(const rtl::OUString& rValue)
    {
        // use ::Create(...) method with local incarnation, it will handle
        // - detection of being default (will delete local incarnation)
        // - detection of reuse (will delete local incarnation)
        // - detectiomn of new use - will create shared_ptr for local incarnation and buffer
        return std::static_pointer_cast<const CntOUString>(GetStaticAdmin().Create(new CntOUString(rValue)));
    }

    bool CntOUString::operator==(const IBase& rCandidate) const
    {
        assert(IBase::operator==(rCandidate));
        return (GetValue() == static_cast<const CntOUString&>(rCandidate).GetValue());
    }

    size_t CntOUString::GetUniqueKey() const
    {
        return static_cast<const CntOUString*>(this)->GetValue().hashCode();
    }

    const rtl::OUString& CntOUString::GetValue() const
    {
        return m_aValue;
    }
} // end of namespace Item

///////////////////////////////////////////////////////////////////////////////

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */