]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/API/SBStringList.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / API / SBStringList.cpp
1 //===-- 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/Utility/StringList.h"
13
14 using namespace lldb;
15 using namespace lldb_private;
16
17 SBStringList::SBStringList() : m_opaque_ap() {}
18
19 SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr)
20     : m_opaque_ap() {
21   if (lldb_strings_ptr)
22     m_opaque_ap.reset(new lldb_private::StringList(*lldb_strings_ptr));
23 }
24
25 SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_ap() {
26   if (rhs.IsValid())
27     m_opaque_ap.reset(new lldb_private::StringList(*rhs));
28 }
29
30 const SBStringList &SBStringList::operator=(const SBStringList &rhs) {
31   if (this != &rhs) {
32     if (rhs.IsValid())
33       m_opaque_ap.reset(new lldb_private::StringList(*rhs));
34     else
35       m_opaque_ap.reset();
36   }
37   return *this;
38 }
39
40 SBStringList::~SBStringList() {}
41
42 const lldb_private::StringList *SBStringList::operator->() const {
43   return m_opaque_ap.get();
44 }
45
46 const lldb_private::StringList &SBStringList::operator*() const {
47   return *m_opaque_ap;
48 }
49
50 bool SBStringList::IsValid() const { return (m_opaque_ap != NULL); }
51
52 void SBStringList::AppendString(const char *str) {
53   if (str != NULL) {
54     if (IsValid())
55       m_opaque_ap->AppendString(str);
56     else
57       m_opaque_ap.reset(new lldb_private::StringList(str));
58   }
59 }
60
61 void SBStringList::AppendList(const char **strv, int strc) {
62   if ((strv != NULL) && (strc > 0)) {
63     if (IsValid())
64       m_opaque_ap->AppendList(strv, strc);
65     else
66       m_opaque_ap.reset(new lldb_private::StringList(strv, strc));
67   }
68 }
69
70 void SBStringList::AppendList(const SBStringList &strings) {
71   if (strings.IsValid()) {
72     if (!IsValid())
73       m_opaque_ap.reset(new lldb_private::StringList());
74     m_opaque_ap->AppendList(*(strings.m_opaque_ap));
75   }
76 }
77
78 void SBStringList::AppendList(const StringList &strings) {
79   if (!IsValid())
80     m_opaque_ap.reset(new lldb_private::StringList());
81   m_opaque_ap->AppendList(strings);
82 }
83
84 uint32_t SBStringList::GetSize() const {
85   if (IsValid()) {
86     return m_opaque_ap->GetSize();
87   }
88   return 0;
89 }
90
91 const char *SBStringList::GetStringAtIndex(size_t idx) {
92   if (IsValid()) {
93     return m_opaque_ap->GetStringAtIndex(idx);
94   }
95   return NULL;
96 }
97
98 const char *SBStringList::GetStringAtIndex(size_t idx) const {
99   if (IsValid()) {
100     return m_opaque_ap->GetStringAtIndex(idx);
101   }
102   return NULL;
103 }
104
105 void SBStringList::Clear() {
106   if (IsValid()) {
107     m_opaque_ap->Clear();
108   }
109 }