1 //===-- SBLineEntry.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/SBLineEntry.h"
11 #include "lldb/Symbol/LineEntry.h"
12 
13 using namespace lldb;
14 
15 
16 SBLineEntry::SBLineEntry () :
17     m_lldb_object_ap ()
18 {
19 }
20 
21 SBLineEntry::SBLineEntry (const SBLineEntry &rhs) :
22     m_lldb_object_ap ()
23 {
24     if (rhs.IsValid())
25     {
26         m_lldb_object_ap.reset (new lldb_private::LineEntry (*rhs));
27     }
28 }
29 
30 
31 
32 SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) :
33     m_lldb_object_ap ()
34 {
35     if (lldb_object_ptr)
36         m_lldb_object_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr));
37 }
38 
39 const SBLineEntry &
40 SBLineEntry::operator = (const SBLineEntry &rhs)
41 {
42     if (this != &rhs)
43     {
44         if (rhs.IsValid())
45             m_lldb_object_ap.reset (new lldb_private::LineEntry(*rhs));
46     }
47     return *this;
48 }
49 
50 void
51 SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref)
52 {
53     if (m_lldb_object_ap.get())
54         (*m_lldb_object_ap.get()) = lldb_object_ref;
55     else
56         m_lldb_object_ap.reset (new lldb_private::LineEntry (lldb_object_ref));
57 }
58 
59 
60 SBLineEntry::~SBLineEntry ()
61 {
62 }
63 
64 
65 SBAddress
66 SBLineEntry::GetStartAddress () const
67 {
68     SBAddress sb_address;
69     if (m_lldb_object_ap.get())
70         sb_address.SetAddress(&m_lldb_object_ap->range.GetBaseAddress());
71     return sb_address;
72 }
73 
74 SBAddress
75 SBLineEntry::GetEndAddress () const
76 {
77     SBAddress sb_address;
78     if (m_lldb_object_ap.get())
79     {
80         sb_address.SetAddress(&m_lldb_object_ap->range.GetBaseAddress());
81         sb_address.OffsetAddress(m_lldb_object_ap->range.GetByteSize());
82     }
83     return sb_address;
84 }
85 
86 bool
87 SBLineEntry::IsValid () const
88 {
89     return m_lldb_object_ap.get() != NULL;
90 }
91 
92 
93 SBFileSpec
94 SBLineEntry::GetFileSpec () const
95 {
96     SBFileSpec sb_file_spec;
97     if (m_lldb_object_ap.get() && m_lldb_object_ap->file)
98         sb_file_spec.SetFileSpec(m_lldb_object_ap->file);
99     return sb_file_spec;
100 }
101 
102 uint32_t
103 SBLineEntry::GetLine () const
104 {
105     if (m_lldb_object_ap.get())
106         return m_lldb_object_ap->line;
107     return 0;
108 }
109 
110 
111 uint32_t
112 SBLineEntry::GetColumn () const
113 {
114     if (m_lldb_object_ap.get())
115         return m_lldb_object_ap->column;
116     return 0;
117 }
118 
119 bool
120 SBLineEntry::operator == (const SBLineEntry &rhs) const
121 {
122     lldb_private::LineEntry *lhs_ptr = m_lldb_object_ap.get();
123     lldb_private::LineEntry *rhs_ptr = rhs.m_lldb_object_ap.get();
124 
125     if (lhs_ptr && rhs_ptr)
126         return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) == 0;
127 
128     return lhs_ptr == rhs_ptr;
129 }
130 
131 bool
132 SBLineEntry::operator != (const SBLineEntry &rhs) const
133 {
134     lldb_private::LineEntry *lhs_ptr = m_lldb_object_ap.get();
135     lldb_private::LineEntry *rhs_ptr = rhs.m_lldb_object_ap.get();
136 
137     if (lhs_ptr && rhs_ptr)
138         return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) != 0;
139 
140     return lhs_ptr != rhs_ptr;
141 }
142 
143 const lldb_private::LineEntry *
144 SBLineEntry::operator->() const
145 {
146     return m_lldb_object_ap.get();
147 }
148 
149 const lldb_private::LineEntry &
150 SBLineEntry::operator*() const
151 {
152     return *m_lldb_object_ap;
153 }
154 
155 
156 
157 
158 
159