blob: f15200061f622906fc9531af6945c5406193c791 [file] [log] [blame]
Chris Lattner24943d22010-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 () :
Greg Clayton63094e02010-06-23 01:19:29 +000018 m_opaque_ap ()
Chris Lattner24943d22010-06-08 16:52:24 +000019{
20}
21
22SBStringList::SBStringList (const lldb_private::StringList *lldb_strings_ptr) :
Greg Clayton63094e02010-06-23 01:19:29 +000023 m_opaque_ap ()
Chris Lattner24943d22010-06-08 16:52:24 +000024{
25 if (lldb_strings_ptr)
Greg Clayton63094e02010-06-23 01:19:29 +000026 m_opaque_ap.reset (new lldb_private::StringList (*lldb_strings_ptr));
Chris Lattner24943d22010-06-08 16:52:24 +000027}
28
29SBStringList::SBStringList (const SBStringList &rhs) :
Greg Clayton63094e02010-06-23 01:19:29 +000030 m_opaque_ap ()
Chris Lattner24943d22010-06-08 16:52:24 +000031{
32 if (rhs.IsValid())
Greg Clayton63094e02010-06-23 01:19:29 +000033 m_opaque_ap.reset (new lldb_private::StringList(*rhs));
Chris Lattner24943d22010-06-08 16:52:24 +000034}
35
36
37
38SBStringList::~SBStringList ()
39{
40}
41
42
43const SBStringList &
44SBStringList::operator = (const SBStringList &rhs)
45{
46 if (rhs.IsValid())
Greg Clayton63094e02010-06-23 01:19:29 +000047 m_opaque_ap.reset (new lldb_private::StringList(*rhs));
Chris Lattner24943d22010-06-08 16:52:24 +000048
49 return *this;
50}
51
52const lldb_private::StringList *
53SBStringList::operator->() const
54{
Greg Clayton63094e02010-06-23 01:19:29 +000055 return m_opaque_ap.get();
Chris Lattner24943d22010-06-08 16:52:24 +000056}
57
58const lldb_private::StringList &
59SBStringList::operator*() const
60{
Greg Clayton63094e02010-06-23 01:19:29 +000061 return *m_opaque_ap;
Chris Lattner24943d22010-06-08 16:52:24 +000062}
63
64bool
65SBStringList::IsValid() const
66{
Greg Clayton63094e02010-06-23 01:19:29 +000067 return (m_opaque_ap.get() != NULL);
Chris Lattner24943d22010-06-08 16:52:24 +000068}
69
70void
71SBStringList::AppendString (const char *str)
72{
73 if (str != NULL)
74 {
75 if (IsValid())
Greg Clayton63094e02010-06-23 01:19:29 +000076 m_opaque_ap->AppendString (str);
Chris Lattner24943d22010-06-08 16:52:24 +000077 else
Greg Clayton63094e02010-06-23 01:19:29 +000078 m_opaque_ap.reset (new lldb_private::StringList (str));
Chris Lattner24943d22010-06-08 16:52:24 +000079 }
80
81}
82
83void
84SBStringList::AppendList (const char **strv, int strc)
85{
86 if ((strv != NULL)
87 && (strc > 0))
88 {
89 if (IsValid())
Greg Clayton63094e02010-06-23 01:19:29 +000090 m_opaque_ap->AppendList (strv, strc);
Chris Lattner24943d22010-06-08 16:52:24 +000091 else
Greg Clayton63094e02010-06-23 01:19:29 +000092 m_opaque_ap.reset (new lldb_private::StringList (strv, strc));
Chris Lattner24943d22010-06-08 16:52:24 +000093 }
94}
95
96void
97SBStringList::AppendList (SBStringList strings)
98{
99 if (strings.IsValid())
100 {
101 if (! IsValid())
Greg Clayton63094e02010-06-23 01:19:29 +0000102 m_opaque_ap.reset (new lldb_private::StringList());
103 m_opaque_ap->AppendList (*(strings.m_opaque_ap));
Chris Lattner24943d22010-06-08 16:52:24 +0000104 }
105}
106
107uint32_t
108SBStringList::GetSize () const
109{
110 if (IsValid())
111 {
Greg Clayton63094e02010-06-23 01:19:29 +0000112 return m_opaque_ap->GetSize();
Chris Lattner24943d22010-06-08 16:52:24 +0000113 }
114 return 0;
115}
116
117const char *
118SBStringList::GetStringAtIndex (size_t idx)
119{
120 if (IsValid())
121 {
Greg Clayton63094e02010-06-23 01:19:29 +0000122 return m_opaque_ap->GetStringAtIndex (idx);
Chris Lattner24943d22010-06-08 16:52:24 +0000123 }
124 return NULL;
125}
126
127void
128SBStringList::Clear ()
129{
130 if (IsValid())
131 {
Greg Clayton63094e02010-06-23 01:19:29 +0000132 m_opaque_ap->Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000133 }
134}