1
//////////////////////////////////////////////////////////////////////////////
2
//////////////////////////////////////////////////////////////////////////////
4
// copyright : (C) 2008 by Eran Ifrah
7
// -------------------------------------------------------------------------
10
// / __ \ | | | | (_) |
11
// | / \/ ___ __| | ___| | _| |_ ___
12
// | | / _ \ / _ |/ _ \ | | | __/ _ )
13
// | \__/\ (_) | (_| | __/ |___| | || __/
14
// \____/\___/ \__,_|\___\_____/_|\__\___|
18
// This program is free software; you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation; either version 2 of the License, or
21
// (at your option) any later version.
23
//////////////////////////////////////////////////////////////////////////////
24
//////////////////////////////////////////////////////////////////////////////
25
#ifndef CODELITE_ENTRY_H
26
#define CODELITE_ENTRY_H
28
#include "db_record.h"
29
#include <wx/treectrl.h>
31
#include <wx/string.h>
33
#include "smart_ptr.h"
35
#ifdef WXMAKINGDLL_CODELITE
36
# define WXDLLIMPEXP_CL WXEXPORT
37
#elif defined(WXUSINGDLL_CODELITE)
38
# define WXDLLIMPEXP_CL WXIMPORT
39
#else /* not making nor using FNB as DLL */
40
# define WXDLLIMPEXP_CL
46
* TagEntry is a persistent object which is capable of storing and loading itself from
48
* - tagEntry (ctags structure)
49
* - wxSQLite3ResultSet - from the database
51
* It contains all the knowledge of storing and retrieving itself from the database
60
class WXDLLIMPEXP_CL TagEntry : public DbRecord
62
wxString m_path; ///< Tag full path
63
wxString m_file; ///< File this tag is found
64
int m_lineNumber; ///< Line number
65
wxString m_pattern; ///< A pattern that can be used to locate the tag in the file
66
wxString m_kind; ///< Member, function, class, typedef etc.
67
wxString m_parent; ///< Direct parent
68
wxTreeItemId m_hti; ///< Handle to tree item, not persistent item
69
wxString m_name; ///< Tag name (short name, excluding any scope names)
70
std::map<wxString, wxString> m_extFields; ///< Additional extension fields
73
bool m_differOnByLineNumber;
77
* Construct a TagEntry from tagEntry struct
78
* \param entry Tag entry
80
TagEntry(const tagEntry& entry);
83
* Default constructor.
90
TagEntry(const TagEntry& rhs);
93
* Construct a tag entry from db record.
94
* \param rs Result set
96
TagEntry(wxSQLite3ResultSet& rs);
99
* \param rhs Source to copy from (right hand side)
102
TagEntry& operator=(const TagEntry& rhs);
105
* Compare two TagEntry objects.
106
* \param rhs Right hand side
107
* \return true if identical, false otherwise
109
bool operator==(const TagEntry& rhs);
117
* Construct a TagEntry from tagEntry struct.
118
* \param entry Tag entry
120
void Create(const tagEntry& entry);
123
* Construct a TagEntry from values.
124
* \param fileName File name
125
* \param name Tag name
126
* \param lineNumber Tag line number
127
* \param pattern Pattern
128
* \param kind Tag kind (class, struct, etc)
129
* \param extFields Map of extenstion fields (key:value)
130
* \param project Project name
132
void Create(const wxString &fileName,
133
const wxString &name,
135
const wxString &pattern,
136
const wxString &kind,
137
std::map<wxString, wxString>& extFields);
140
* Test if this entry has been initialised.
141
* \return true if this tag entry has been initialised
143
const bool IsOk() const { return GetKind() != _T("<unknown>"); }
146
* Test of this tag is a container (class, union, struct or namespace
148
const bool IsContainer() const;
150
//------------------------------------------
152
//------------------------------------------
153
bool GetDifferOnByLineNumber() const {return m_differOnByLineNumber;}
155
int GetId() const { return m_id; }
156
void SetId(int id) { m_id = id;}
158
const wxString& GetName() const { return m_name;}
159
void SetName(const wxString& name) { m_name = name; }
161
const wxString& GetPath() const { return m_path;}
162
void SetPath(const wxString& path) { m_path = path; }
164
const wxString& GetFile() const { return m_file;}
165
void SetFile(const wxString& file) { m_file = file;}
167
int GetLine() const { return m_lineNumber;}
168
void SetLine(int line) { m_lineNumber = line; }
170
wxString GetPattern();
171
void SetPattern(const wxString& pattern) { m_pattern = pattern; }
173
wxString GetKind() const;
174
void SetKind(const wxString& kind) { m_kind = kind; }
176
const wxString& GetParent() const { return m_parent; }
177
void SetParent(const wxString& parent) { m_parent = parent; }
179
wxTreeItemId& GetTreeItemId() { return m_hti; }
180
void SetTreeItemId(wxTreeItemId& hti) { m_hti = hti; }
182
wxString GetAccess() const { return GetExtField(_T("access"));}
183
void SetAccess(const wxString &access){m_extFields[wxT("access")] = access;}
185
wxString GetSignature() const { return GetExtField(_T("signature")); }
186
void SetSignature(const wxString &sig) { m_extFields[wxT("signature")] = sig; }
188
wxString GetInherits() const { return GetExtField(_T("inherits")); }
189
wxString GetTyperef() const { return GetExtField(_T("typeref")); }
191
const wxString &GetScope() const {return m_scope;}
192
void SetScope(const wxString &scope){m_scope = scope;}
195
* \return Scope name of the tag.
196
* If path is empty in db or contains just the project name, it will return the literal <global>.
197
* For project tags, an empty string is returned.
199
wxString GetScopeName() const;
202
* Generate a Key for this tag based on its attributes
205
wxString Key() const;
208
* Generate a display name for this tag to be used by the symbol tree
209
* \return tag display name
211
wxString GetDisplayName() const;
214
* Generate a full display name for this tag that includes:
215
* full scope + name + signature
216
* \return tag full display name
218
wxString GetFullDisplayName() const;
221
* Return the actual name as described in the 'typeref' field
222
* \return real name or wxEmptyString
224
wxString NameFromTyperef(wxString &templateInitList);
227
* Return the actual type as described in the 'typeref' field
228
* \return real name or wxEmptyString
230
wxString TypeFromTyperef() const;
231
//------------------------------------------
233
//------------------------------------------
234
wxString GetExtField(const wxString& extField) const
236
std::map<wxString, wxString>::const_iterator iter = m_extFields.find(extField);
237
if(iter == m_extFields.end())
238
return wxEmptyString;
242
//------------------------------------------
244
//------------------------------------------
248
//------------------------------------------
249
// Database operations
250
//------------------------------------------
252
* Save this record into db.
253
* \param insertPreparedStmnt Prepared statement for insert operation
254
* \return TagOk, TagExist, TagError
256
virtual int Store(wxSQLite3Statement& insertPreparedStmnt, TagsDatabase *db);
259
* Update this record into db.
260
* \param insertPreparedStmnt Prepared statement for insert operation
261
* \return TagOk, TagError
263
virtual int Update(wxSQLite3Statement& updatePreparedStmnt);
266
* Delete this record from db.
267
* \param deletePreparedStmnt Prepared statement for delete operation
268
* \return TagOk, TagError
270
virtual int Delete(wxSQLite3Statement& deletePreparedStmnt);
273
* \return delete preapred statement
275
virtual wxString GetDeleteOneStatement();
278
* \return update preapred statement
280
virtual wxString GetUpdateOneStatement();
283
* \return insert preapred statement
285
virtual wxString GetInsertOneStatement();
290
* Update the path with full path (e.g. namespace::class)
291
* \param path path to add
293
void UpdatePath(wxString & path);
294
bool TypedefFromPattern(const wxString &tagPattern, const wxString &typedefName, wxString &name, wxString &templateInit);
297
typedef SmartPtr<TagEntry> TagEntryPtr;
298
#endif // CODELITE_ENTRY_H