blob: b4cfb9b0c75dd73a0f2e7930a6796a5c1623ef1d [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- SBStringList.cpp ----------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/API/SBStringList.h"
11
12#include "lldb/Core/StringList.h"
13
14using namespace lldb;
15using namespace lldb_private;
16
17SBStringList::SBStringList () :
18 m_lldb_object_ap ()
19{
20}
21
22SBStringList::SBStringList (const lldb_private::StringList *lldb_strings_ptr) :
23 m_lldb_object_ap ()
24{
25 if (lldb_strings_ptr)
26 m_lldb_object_ap.reset (new lldb_private::StringList (*lldb_strings_ptr));
27}
28
29SBStringList::SBStringList (const SBStringList &rhs) :
30 m_lldb_object_ap ()
31{
32 if (rhs.IsValid())
33 m_lldb_object_ap.reset (new lldb_private::StringList(*rhs));
34}
35
36
37
38SBStringList::~SBStringList ()
39{
40}
41
42
43const SBStringList &
44SBStringList::operator = (const SBStringList &rhs)
45{
46 if (rhs.IsValid())
47 m_lldb_object_ap.reset (new lldb_private::StringList(*rhs));
48
49 return *this;
50}
51
52const lldb_private::StringList *
53SBStringList::operator->() const
54{
55 return m_lldb_object_ap.get();
56}
57
58const lldb_private::StringList &
59SBStringList::operator*() const
60{
61 return *m_lldb_object_ap;
62}
63
64bool
65SBStringList::IsValid() const
66{
67 return (m_lldb_object_ap.get() != NULL);
68}
69
70void
71SBStringList::AppendString (const char *str)
72{
73 if (str != NULL)
74 {
75 if (IsValid())
76 m_lldb_object_ap->AppendString (str);
77 else
78 m_lldb_object_ap.reset (new lldb_private::StringList (str));
79 }
80
81}
82
83void
84SBStringList::AppendList (const char **strv, int strc)
85{
86 if ((strv != NULL)
87 && (strc > 0))
88 {
89 if (IsValid())
90 m_lldb_object_ap->AppendList (strv, strc);
91 else
92 m_lldb_object_ap.reset (new lldb_private::StringList (strv, strc));
93 }
94}
95
96void
97SBStringList::AppendList (SBStringList strings)
98{
99 if (strings.IsValid())
100 {
101 if (! IsValid())
102 m_lldb_object_ap.reset (new lldb_private::StringList());
103 m_lldb_object_ap->AppendList (*(strings.m_lldb_object_ap));
104 }
105}
106
107uint32_t
108SBStringList::GetSize () const
109{
110 if (IsValid())
111 {
112 return m_lldb_object_ap->GetSize();
113 }
114 return 0;
115}
116
117const char *
118SBStringList::GetStringAtIndex (size_t idx)
119{
120 if (IsValid())
121 {
122 return m_lldb_object_ap->GetStringAtIndex (idx);
123 }
124 return NULL;
125}
126
127void
128SBStringList::Clear ()
129{
130 if (IsValid())
131 {
132 m_lldb_object_ap->Clear();
133 }
134}