File: xrefdata.h

package info (click to toggle)
oxref 0.90.10-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 400 kB
  • sloc: cpp: 786; makefile: 141
file content (83 lines) | stat: -rw-r--r-- 2,329 bytes parent folder | download | duplicates (4)
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
#ifndef INCLUDED_XREFDATA_
#define INCLUDED_XREFDATA_

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

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:
        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);

        void defined(std::ostream &out) const;
        std::string const &symbol() const;// returns d_cooked
        char const *name() const;         // returns d_cooked[d_nameIndex] 

        std::string const &sourceFile() const;

        std::vector<size_t> const &usedBy() const;

    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);
};

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;
}

#endif