Nemiver  0.3
nmv-loc.h
Go to the documentation of this file.
1 //Author: Dodji Seketeli
2 /*
3  *This file is part of the Nemiver project
4  *
5  *Nemiver is free software; you can redistribute
6  *it and/or modify it under the terms of
7  *the GNU General Public License as published by the
8  *Free Software Foundation; either version 2,
9  *or (at your option) any later version.
10  *
11  *Nemiver is distributed in the hope that it will
12  *be useful, but WITHOUT ANY WARRANTY;
13  *without even the implied warranty of
14  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *See the GNU General Public License for more details.
16  *
17  *You should have received a copy of the
18  *GNU General Public License along with Nemiver;
19  *see the file COPYING.
20  *If not, write to the Free Software Foundation,
21  *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  *See COPYRIGHT file copyright information.
24  */
25 
26 #ifndef __NMV_LOC_H__
27 #define __NMV_LOC_H__
28 
29 #include "nmv-ustring.h"
30 #include "nmv-address.h"
31 #include "nmv-api-macros.h"
32 
37 
38 NEMIVER_BEGIN_NAMESPACE (nemiver)
39 NEMIVER_BEGIN_NAMESPACE (common)
40 
41 class NEMIVER_API Loc
43 {
44 
45  public:
47  enum Kind
48  {
52  ADDRESS_LOC_KIND
53  };
54 
55  protected:
57 
58  Loc ()
59  : m_kind (UNDEFINED_LOC_KIND)
60  {
61  }
62 
63  Loc (const Loc &a)
64  : m_kind (a.m_kind)
65  {
66  }
67 
68  public:
69 
70  Kind kind () const {return m_kind;}
71  virtual ~Loc () {};
72 }; // end class Loc
73 
78 class NEMIVER_API SourceLoc : public Loc
79 {
80  UString m_file_path;
81  int m_line_number;
82 
83  public:
84 
85  SourceLoc (const UString &a_file_path,
86  int a_line_number)
87  : m_file_path (a_file_path),
88  m_line_number (a_line_number)
89  {
90  m_kind = SOURCE_LOC_KIND;
91  }
92 
93  SourceLoc (const SourceLoc &a)
94  : Loc (a)
95  {
96  m_file_path = a.m_file_path;
97  m_line_number = a.m_line_number;
98  }
99 
100  const UString& file_path () const {return m_file_path;}
101  void file_path (const UString &a) {m_file_path = a;}
102  int line_number () const {return m_line_number;}
103  void line_number (int a) {m_line_number = a;}
104 };// end class SourceLoc;
105 
110 {
111  UString m_function_name;
112 
113  public:
114 
115  FunctionLoc (const UString &a_function_name)
116  : m_function_name (a_function_name)
117  {
118  m_kind = FUNCTION_LOC_KIND;
119  }
120 
122  : Loc (a),
123  m_function_name (a.m_function_name)
124  {
125  }
126 
127  const UString& function_name () const {return m_function_name;}
128  void function_name (const UString &a) {m_function_name = a;}
129 };
130 
134 class NEMIVER_API AddressLoc : public Loc
135 {
136  Address m_address;
137 
138  public:
139 
140  AddressLoc (const Address &a)
141  : m_address (a)
142  {
143  m_kind = ADDRESS_LOC_KIND;
144  }
145 
147  : Loc (a),
148  m_address (a.m_address)
149  {
150  }
151 
152  const Address& address () const {return m_address;}
153  void address (const Address &a) {m_address = a;}
154 };
155 
156 NEMIVER_END_NAMESPACE (common)
157 NEMIVER_END_NAMESPACE (nemiver)
158 
159 #endif //__NMV_LOC_H__
nmv-address.h
nemiver::common::AddressLoc::AddressLoc
AddressLoc(const AddressLoc &a)
Definition: nmv-loc.h:146
nemiver::common::FunctionLoc::function_name
const UString & function_name() const
Definition: nmv-loc.h:127
nemiver::common::SourceLoc::file_path
const UString & file_path() const
Definition: nmv-loc.h:100
nemiver
Definition: nmv-address.h:31
nemiver::common::SourceLoc::line_number
void line_number(int a)
Definition: nmv-loc.h:103
nmv-ustring.h
NEMIVER_API
#define NEMIVER_API
Definition: nmv-api-macros.h:53
nemiver::common::FunctionLoc::FunctionLoc
FunctionLoc(const FunctionLoc &a)
Definition: nmv-loc.h:121
nemiver::common::Loc::m_kind
Kind m_kind
Definition: nmv-loc.h:56
nemiver::common::Loc::kind
Kind kind() const
Definition: nmv-loc.h:70
nmv-api-macros.h
nemiver::common::Loc::ADDRESS_LOC_KIND
@ ADDRESS_LOC_KIND
Definition: nmv-loc.h:52
nemiver::common::AddressLoc::address
const Address & address() const
Definition: nmv-loc.h:152
nemiver::common::Loc::UNDEFINED_LOC_KIND
@ UNDEFINED_LOC_KIND
Definition: nmv-loc.h:49
nemiver::common::FunctionLoc::FunctionLoc
FunctionLoc(const UString &a_function_name)
Definition: nmv-loc.h:115
nemiver::common::UString
Definition: nmv-ustring.h:45
nemiver::common::FunctionLoc::function_name
void function_name(const UString &a)
Definition: nmv-loc.h:128
nemiver::common::Loc::Loc
Loc(const Loc &a)
Definition: nmv-loc.h:63
nemiver::common::AddressLoc
Definition: nmv-loc.h:134
nemiver::common::SourceLoc::line_number
int line_number() const
Definition: nmv-loc.h:102
nemiver::common::SourceLoc
Definition: nmv-loc.h:78
nemiver::common::AddressLoc::AddressLoc
AddressLoc(const Address &a)
Definition: nmv-loc.h:140
nemiver::common::FunctionLoc
Definition: nmv-loc.h:109
nemiver::common::Loc::Loc
Loc()
Definition: nmv-loc.h:58
nemiver::common::SourceLoc::file_path
void file_path(const UString &a)
Definition: nmv-loc.h:101
nemiver::common::Loc
The base type presenting a location.
Definition: nmv-loc.h:42
nemiver::common::Address
Definition: nmv-address.h:34
nemiver::common::SourceLoc::SourceLoc
SourceLoc(const UString &a_file_path, int a_line_number)
Definition: nmv-loc.h:85
nemiver::common::Loc::Kind
Kind
The different possible kinds of locations.
Definition: nmv-loc.h:47
nemiver::common::SourceLoc::SourceLoc
SourceLoc(const SourceLoc &a)
Definition: nmv-loc.h:93
nemiver::common::Loc::~Loc
virtual ~Loc()
Definition: nmv-loc.h:71
nemiver::common::AddressLoc::address
void address(const Address &a)
Definition: nmv-loc.h:153
nemiver::common::Loc::FUNCTION_LOC_KIND
@ FUNCTION_LOC_KIND
Definition: nmv-loc.h:51
nemiver::common::Loc::SOURCE_LOC_KIND
@ SOURCE_LOC_KIND
Definition: nmv-loc.h:50
common
Definition: nmv-proc-list-dialog.h:32