|
| 1 | +/* |
| 2 | + * Cppcheck - A tool for static C/C++ code analysis |
| 3 | + * Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team. |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with this program. If not, see <http://www.gnu.org/licenses/ |
| 17 | + */ |
| 18 | + |
| 19 | + |
| 20 | +//--------------------------------------------------------------------------- |
| 21 | +#ifndef classInfoH |
| 22 | +#define classInfoH |
| 23 | +//--------------------------------------------------------------------------- |
| 24 | + |
| 25 | +#include <string> |
| 26 | +#include <vector> |
| 27 | +#include "token.h" |
| 28 | + |
| 29 | +/// @addtogroup Core |
| 30 | +/// @{ |
| 31 | + |
| 32 | +/** @brief Holds information about a single class in checked source code. Contains member function and member variable lists. */ |
| 33 | +class ClassInfo |
| 34 | +{ |
| 35 | +public: |
| 36 | + |
| 37 | + enum MemberType {PRIVATE, PROTECTED, PUBLIC}; |
| 38 | + |
| 39 | + /** |
| 40 | + * Base class for both member functions and member variables. |
| 41 | + * Contains variable name, token where name was declared and type |
| 42 | + * private/protected/public. |
| 43 | + */ |
| 44 | + class MemberInfo |
| 45 | + { |
| 46 | + public: |
| 47 | + |
| 48 | + MemberInfo() : _declaration(0), _name(), _type(ClassInfo::PRIVATE) |
| 49 | + { |
| 50 | + |
| 51 | + } |
| 52 | + |
| 53 | + virtual ~MemberInfo() {} |
| 54 | + |
| 55 | + const Token *_declaration; |
| 56 | + std::string _name; |
| 57 | + ClassInfo::MemberType _type; |
| 58 | + }; |
| 59 | + |
| 60 | + /** |
| 61 | + * Information about a single member function of a class. |
| 62 | + */ |
| 63 | + class MemberFunctionInfo : public MemberInfo |
| 64 | + { |
| 65 | + public: |
| 66 | + MemberFunctionInfo() : _implementation(0) |
| 67 | + { |
| 68 | + |
| 69 | + } |
| 70 | + |
| 71 | + const Token *_implementation; |
| 72 | + }; |
| 73 | + |
| 74 | + /** |
| 75 | + * Information about a single member variable of a class. |
| 76 | + */ |
| 77 | + class MemberVariableInfo : public MemberInfo |
| 78 | + { |
| 79 | + }; |
| 80 | + |
| 81 | + /** |
| 82 | + * List of member functions |
| 83 | + */ |
| 84 | + std::vector<MemberFunctionInfo> _memberFunctions; |
| 85 | + |
| 86 | + /** |
| 87 | + * List of member variables |
| 88 | + */ |
| 89 | + std::vector<MemberVariableInfo> _memberVariables; |
| 90 | +}; |
| 91 | + |
| 92 | + |
| 93 | +/// @} |
| 94 | + |
| 95 | +//--------------------------------------------------------------------------- |
| 96 | +#endif |
0 commit comments