File: xrefdata.h

package info (click to toggle)
oxref 2.02.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 692 kB
  • sloc: cpp: 1,282; makefile: 131; sh: 48
file content (104 lines) | stat: -rw-r--r-- 3,132 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef INCLUDED_XREFDATA_
#define INCLUDED_XREFDATA_

#include <iostream>
#include <string>
#include <vector>

// see store.h for a description of the data-storage organization

class XrefData
{
    std::string d_sourceFile;           // defined, unless empty
    std::string d_objFile;

    bool d_isFunction;                  // true: function, false: object

    std::string d_refName;              // full name of object or function
    std::string d_cooked;               // name as processed by -a

    size_t d_nameIndex;                 // index where the proper name (after
                                        // its class/namespace) starts

    std::vector<size_t> d_calledFrom;

    bool d_source;
    bool d_object;
    bool d_fullSymbol;

    public:
        using XrefVector = std::vector<XrefData>;

        XrefData();
        XrefData(std::string const &sourceFile, 
                 std::string const &objFile, 
                 bool isFunction, std::string const &symbol);
        XrefData(std::string const &symbol);

        void setLocation(std::string const &sourceFile, 
                 std::string const &objFile);
   
        bool isDefined(std::string const &symbol) const;
        bool hasSymbol(std::string const &symbol) const;
    
        void calledFrom(size_t currentIdx); // the current function is called
                                            // from the function at
                                            // 'currentIdx', which is an index
                                            // in Store::d_xrefVector


        void defined(std::ostream &out) const;

        std::string const &fullName() const;    // returns d_refName    //  .h
        std::string const &symbol() const;// returns d_cooked           //  .h
        char const *name() const;         // returns d_cooked[d_nameIndex]  .h
        std::string const &sourceFile() const;                          //  .h
        std::vector<size_t> const &usedBy() const;                      //  .h
        bool isFunction() const;                                        //  .h

    private:
        void ctor();
        void setCooked();
        void keepFirst(size_t openParIdx);
        void reduceLen(size_t openParIdx, size_t len);
        void reduceToCount(size_t openParIdx, size_t end);
        size_t skipTemplate(size_t begin) const;    // index of 1st '<'
                                                    // returns idx of last '>'

        size_t eraseParam(size_t begin);    // returns , or ) position
        size_t eraseParam(size_t begin, size_t len);
};

using  XrefVector = XrefData::XrefVector;

inline std::vector<size_t> const &XrefData::usedBy() const
{
    return d_calledFrom;
}

inline  char const *XrefData::name() const
{
    return d_cooked.c_str() + d_nameIndex;
}

inline std::string const &XrefData::sourceFile() const
{
    return d_sourceFile;
}

inline  std::string const &XrefData::symbol() const
{
    return d_cooked;
}

inline  std::string const &XrefData::fullName() const
{
    return d_refName;
}

inline  bool XrefData::isFunction() const
{
    return d_isFunction;
}

#endif