File: CxxVariable.h

package info (click to toggle)
codelite 10.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 71,364 kB
  • sloc: cpp: 415,397; ansic: 18,277; php: 9,547; lex: 4,181; yacc: 2,820; python: 2,294; sh: 383; makefile: 51; xml: 13
file content (69 lines) | stat: -rw-r--r-- 1,809 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef CXXVARIABLE_H
#define CXXVARIABLE_H

#include "codelite_exports.h"
#include "smart_ptr.h"
#include <list>
#include <set>
#include <map>
#include <wx/string.h>
#include "CxxLexerAPI.h"

class WXDLLIMPEXP_CL CxxVariable
{
public:
    struct LexerToken {
        int type;
        wxString text;
        wxString comment;

        LexerToken()
            : type(0)
        {
        }

        LexerToken(const CxxLexerToken& token) { FromCxxLexerToken(token); }

        void FromCxxLexerToken(const CxxLexerToken& token)
        {
            this->type = token.type;
            this->comment = token.comment;
            this->text = token.text;
        }
        typedef std::list<CxxVariable::LexerToken> List_t;
    };

protected:
    wxString m_name;
    CxxVariable::LexerToken::List_t m_type;

public:
    typedef SmartPtr<CxxVariable> Ptr_t;
    typedef std::list<CxxVariable::Ptr_t> List_t;
    typedef std::map<wxString, CxxVariable::Ptr_t> Map_t;

public:
    CxxVariable();
    virtual ~CxxVariable();

    void SetName(const wxString& name) { this->m_name = name; }
    void SetType(const CxxVariable::LexerToken::List_t& type) { this->m_type = type; }
    const wxString& GetName() const { return m_name; }
    const CxxVariable::LexerToken::List_t& GetType() const { return m_type; }
    wxString GetTypeAsString() const;

    /**
     * @brief return true if this variable was constructed from a statement like:
     * using MyInt = int;
     */
    bool IsUsing() const { return GetTypeAsString() == "using"; }

    /**
     * @brief is this a valid variable?
     */
    bool IsOk() const { return !m_name.IsEmpty() && !m_type.empty(); }

    wxString ToString() const { return (wxString() << "Name: " << GetName() << ", Type: " << GetTypeAsString()); }
};

#endif // CXXVARIABLE_H