Doxygen
Loading...
Searching...
No Matches
arguments.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2015 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef ARGUMENTS_H
17#define ARGUMENTS_H
18
19#include <vector>
20#include "dstring.h"
21
22/*! \brief This class contains the information about the argument of a
23 * function or template
24 *
25 */
27{
28 public:
29 /*! return true if this argument is documentation and the argument has a
30 * non empty name.
31 */
32 bool hasDocumentation(bool allowEmptyName=false) const
33 {
34 return (allowEmptyName || !name.empty()) && !docs.empty();
35 }
36
38 {
39 return (!name.empty() || !type.empty()) && !docs.empty();
40 }
41
42 DString attrib; /*!< Argument's attribute (IDL only) */
43 DString type; /*!< Argument's type */
44 DString canType; /*!< Cached value of canonical type (after type resolution). Empty initially. */
45 DString name; /*!< Argument's name (may be empty) */
46 DString array; /*!< Argument's array specifier (may be empty) */
47 DString defval; /*!< Argument's default value (may be empty) */
48 DString docs; /*!< Argument's documentation (may be empty) */
49 DString typeConstraint; /*!< Used for Java generics: <T extends C> */
50};
51
58
59/*! \brief This class represents an function or template argument list.
60 *
61 * This class also stores some information about member that is typically
62 * put after the argument list, such as whether the member is const,
63 * volatile or pure virtual.
64 */
66{
67 public:
68 using Vec = std::vector<Argument>;
69 using iterator = typename Vec::iterator;
70 using const_iterator = typename Vec::const_iterator;
71
72 /*! Does any argument of this list have documentation? */
73 bool hasDocumentation(bool allowEmptyNames=false) const;
74 /*! Does any template argument of this list have documentation? */
75 bool hasTemplateDocumentation() const;
76 /*! Does this list have zero or more parameters */
77 bool hasParameters() const
78 {
79 return !empty() || m_noParameters;
80 }
81 void reset()
82 {
83 clear();
84 m_constSpecifier = false;
85 m_volatileSpecifier = false;
86 m_pureSpecifier = false;
88 m_isDeleted = false;
90 m_noParameters = false;
91 }
92
93 // make vector accessible
94 iterator begin() { return m_args.begin(); }
95 iterator end() { return m_args.end(); }
96 const_iterator begin() const { return m_args.cbegin(); }
97 const_iterator end() const { return m_args.cend(); }
98 const_iterator cbegin() const { return m_args.cbegin(); }
99 const_iterator cend() const { return m_args.cend(); }
100 bool empty() const { return m_args.empty(); }
101 size_t size() const { return m_args.size(); }
102 void clear() { m_args.clear(); }
103 void push_back(const Argument &a) { m_args.push_back(a); }
104 Argument &back() { return m_args.back(); }
105 const Argument &back() const { return m_args.back(); }
106 Argument &front() { return m_args.front(); }
107 const Argument &front() const { return m_args.front(); }
108 Argument &at(size_t i) { return m_args.at(i); }
109 const Argument &at(size_t i) const { return m_args.at(i); }
110
111 // getters for list wide attributes
112 bool constSpecifier() const { return m_constSpecifier; }
113 bool volatileSpecifier() const { return m_volatileSpecifier; }
114 bool pureSpecifier() const { return m_pureSpecifier; }
116 bool isDeleted() const { return m_isDeleted; }
118 bool noParameters() const { return m_noParameters; }
119
122 void setPureSpecifier(bool b) { m_pureSpecifier = b; }
123 void setTrailingReturnType(const DString &s);
124 void appendTrailingReturnType(const DString &s);
126 void setIsDeleted(bool b) { m_isDeleted = b; }
128 void setNoParameters(bool b) { m_noParameters = b; }
129
130 private:
131 std::vector<Argument> m_args;
132 /*! Does the member modify the state of the class? */
133 bool m_constSpecifier = false;
134 /*! Is the member volatile? */
136 /*! Is this a pure virtual member? */
137 bool m_pureSpecifier = false;
138 /*! C++11 style Trailing return type? */
140 /*! method with =delete */
141 bool m_isDeleted = false;
142 /*! C++11 ref qualifier */
144 /*! is it an explicit empty list */
145 bool m_noParameters = false;
146};
147
148class ArgumentLists : public std::vector<ArgumentList>
149{
150};
151
152#endif
RefQualifierType
Definition arguments.h:53
This class contains the information about the argument of a function or template.
Definition arguments.h:27
bool hasDocumentation(bool allowEmptyName=false) const
Definition arguments.h:32
DString docs
Definition arguments.h:48
DString typeConstraint
Definition arguments.h:49
DString attrib
Definition arguments.h:42
DString defval
Definition arguments.h:47
DString array
Definition arguments.h:46
DString name
Definition arguments.h:45
DString type
Definition arguments.h:43
DString canType
Definition arguments.h:44
bool hasTemplateDocumentation() const
Definition arguments.h:37
This class represents an function or template argument list.
Definition arguments.h:66
Argument & back()
Definition arguments.h:104
bool m_isDeleted
Definition arguments.h:141
RefQualifierType refQualifier() const
Definition arguments.h:117
bool noParameters() const
Definition arguments.h:118
const_iterator end() const
Definition arguments.h:97
bool pureSpecifier() const
Definition arguments.h:114
iterator end()
Definition arguments.h:95
bool hasParameters() const
Definition arguments.h:77
bool m_constSpecifier
Definition arguments.h:133
const Argument & at(size_t i) const
Definition arguments.h:109
Argument & front()
Definition arguments.h:106
const_iterator cend() const
Definition arguments.h:99
const_iterator cbegin() const
Definition arguments.h:98
DString trailingReturnType() const
Definition arguments.h:115
bool isDeleted() const
Definition arguments.h:116
std::vector< Argument > m_args
Definition arguments.h:131
const Argument & back() const
Definition arguments.h:105
size_t size() const
Definition arguments.h:101
void setPureSpecifier(bool b)
Definition arguments.h:122
typename Vec::const_iterator const_iterator
Definition arguments.h:70
RefQualifierType m_refQualifier
Definition arguments.h:143
bool constSpecifier() const
Definition arguments.h:112
DString m_trailingReturnType
Definition arguments.h:139
bool m_noParameters
Definition arguments.h:145
void appendTrailingReturnType(const DString &s)
Definition arguments.cpp:41
bool m_volatileSpecifier
Definition arguments.h:135
bool hasDocumentation(bool allowEmptyNames=false) const
Definition arguments.cpp:22
bool m_pureSpecifier
Definition arguments.h:137
void setTrailingReturnType(const DString &s)
Definition arguments.cpp:36
void push_back(const Argument &a)
Definition arguments.h:103
std::vector< Argument > Vec
Definition arguments.h:68
bool empty() const
Definition arguments.h:100
void setConstSpecifier(bool b)
Definition arguments.h:120
void setRefQualifier(RefQualifierType t)
Definition arguments.h:127
void clear()
Definition arguments.h:102
void setIsDeleted(bool b)
Definition arguments.h:126
bool hasTemplateDocumentation() const
Definition arguments.cpp:30
typename Vec::iterator iterator
Definition arguments.h:69
void finishTrailingReturnType()
Definition arguments.cpp:46
Argument & at(size_t i)
Definition arguments.h:108
iterator begin()
Definition arguments.h:94
bool volatileSpecifier() const
Definition arguments.h:113
const_iterator begin() const
Definition arguments.h:96
void setNoParameters(bool b)
Definition arguments.h:128
const Argument & front() const
Definition arguments.h:107
void setVolatileSpecifier(bool b)
Definition arguments.h:121
void reset()
Definition arguments.h:81
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
void clear()
Definition dstring.h:218
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152