summaryrefslogtreecommitdiff
path: root/src/inc/stringarraylist.inl
blob: 2103806bbb9c9ca63b3e73e8fa8ec33deb0aca2b (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

#include "ex.h"

inline SString& StringArrayList::operator[] (DWORD idx) const
{
    WRAPPER_NO_CONTRACT;
    return Get(idx);
} 

inline SString& StringArrayList::Get (DWORD idx) const
{
    WRAPPER_NO_CONTRACT;
    PTR_SString ppRet=(PTR_SString)m_Elements.Get(idx);
    return *ppRet;
} 

inline DWORD StringArrayList::GetCount() const
{
    WRAPPER_NO_CONTRACT;
    return m_Elements.GetCount();
}

#ifndef DACCESS_COMPILE
inline void StringArrayList::Append(const SString& string)
{
    CONTRACTL
    {
        THROWS;
        GC_NOTRIGGER;
    }
    CONTRACTL_END;    
    NewHolder<SString> pAdd=new SString(string);
    pAdd->Normalize();
    IfFailThrow(m_Elements.Append(pAdd));
    pAdd.SuppressRelease();
}

inline void StringArrayList::AppendIfNotThere(const SString& string)
{
    CONTRACTL
    {
        THROWS;
        GC_NOTRIGGER;
    }
    CONTRACTL_END;    
    for (DWORD i=0;i<GetCount();i++)
    {
        if(Get(i).Equals(string))
            return;
    }
    Append(string);
}

#endif


inline StringArrayList::~StringArrayList()
{
    CONTRACTL
    {
        DESTRUCTOR_CHECK;
        NOTHROW;
        GC_NOTRIGGER;
    }
    CONTRACTL_END;
#ifndef DACCESS_COMPILE    
    for (DWORD i=0;i< GetCount() ;i++)
    {
        delete (SString*)m_Elements.Get(i);
    }
#endif    
}