CodeSonar C++ API
[For improved navigation, enable JavaScript.]
cs_sfile.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, an unpublished work by CodeSecure, Inc.
3  * ALL RIGHTS RESERVED
4  *
5  * Copyright (c) 2013-2023, an unpublished work by GrammaTech, Inc.
6  * ALL RIGHTS RESERVED
7  *
8  * This software is furnished under a license and may be used and
9  * copied only in accordance with the terms of such license and the
10  * inclusion of the above copyright notice. This software or any
11  * other copies thereof may not be provided or otherwise made
12  * available to any other person. Title to and ownership of the
13  * software is retained by CodeSecure, Inc.
14  */
15 
16 #ifndef CS_SF_HPP
17 #define CS_SF_HPP
18 
19 #include "cs_sfile_decl.hpp"
20 #include "cs_directory_decl.hpp"
21 #include "cs_xref.hpp"
22 
25 namespace cs{
27  line_number line,
28  csuint64 token_namehash,
29  xr_def_iter_flags flags) const
30  {
32  xr_definition_iterator_policy_container(
33  *this,
34  line,
35  token_namehash,
36  flags));
37  }
38 
40  line_number line,
41  const std::string &token,
42  xr_def_iter_flags flags) const
43  {
45  line,
46  xr_namehash(token),
47  flags);
48  }
49 
51 
53  line_number line,
54  csuint64 token_namehash,
55  xr_kind_role kr_filter,
56  size_t limit_per_kind_role,
57  xr_occ_iter_flags flags) const
58  {
60  xr_occurrence_iterator_policy_container(
61  *this, line, token_namehash,
62  cglue<xr_kind_role>::unwrap(kr_filter), limit_per_kind_role, flags));
63  }
64 
66  line_number line,
67  const std::string &token,
68  xr_kind_role kr_filter,
69  size_t limit_per_kind_role,
70  xr_occ_iter_flags flags) const
71  {
73  xr_occurrence_iterator_policy_container(
74  *this, line, xr_namehash(token),
75  cglue<xr_kind_role>::unwrap(kr_filter), limit_per_kind_role, flags));
76  }
77 
79  line_number line,
80  csuint64 token_namehash,
81  size_t limit_per_kind_role,
82  xr_occ_iter_flags flags) const
83  {
85  xr_occurrence_iterator_policy_container(
86  *this, line, token_namehash,
87  csxrkr_count, limit_per_kind_role, flags));
88  }
89 
91  line_number line,
92  const std::string &token,
93  size_t limit_per_kind_role,
94  xr_occ_iter_flags flags) const
95  {
97  xr_occurrence_iterator_policy_container(
98  *this, line, xr_namehash(token),
99  csxrkr_count, limit_per_kind_role, flags));
100  }
101 
103 
105  line_number line,
106  csuint64 token_namehash,
107  xr_kind kind_filter,
108  size_t limit_per_kind,
109  xr_occ_iter_flags flags) const
110  {
111  return xr_homonym_iterator(
112  xr_homonym_iterator_policy_container(
113  *this, line, token_namehash,
114  cglue<xr_kind_role>::unwrap(xr_kind_role(kind_filter, xr_role::DEFINITION)), limit_per_kind, flags));
115  }
116 
118  line_number line,
119  const std::string &token,
120  xr_kind kind_filter,
121  size_t limit_per_kind,
122  xr_occ_iter_flags flags) const
123  {
124  return xr_homonym_iterator(
125  xr_homonym_iterator_policy_container(
126  *this, line, xr_namehash(token),
127  cglue<xr_kind_role>::unwrap(xr_kind_role(kind_filter, xr_role::DEFINITION)), limit_per_kind, flags));
128  }
129 
131  line_number line,
132  csuint64 token_namehash,
133  size_t limit_per_kind,
134  xr_occ_iter_flags flags) const
135  {
136  return xr_homonym_iterator(
137  xr_homonym_iterator_policy_container(
138  *this, line, token_namehash,
139  csxrkr_count, limit_per_kind, flags));
140  }
141 
143  line_number line,
144  const std::string &token,
145  size_t limit_per_kind,
146  xr_occ_iter_flags flags) const
147  {
148  return xr_homonym_iterator(
149  xr_homonym_iterator_policy_container(
150  *this, line, xr_namehash(token),
151  csxrkr_count, limit_per_kind, flags));
152  }
153 
155 
157  line_number lb,
158  line_number ub) const
159  {
161  xr_intra_definition_iterator_policy_container(
162  *this, lb, ub));
163  }
164 
165  inline directory sfile::parent() const
166  {
167  cs_directory rv;
168  check(cs_sf_get_parent(inner, &rv));
169  return directory::;
170  }
171 }
172 
173 #endif /* CS_SFILE_HPP */
cs_line line_number
A line number in a source file (sfile) or source file instance (sfileinst).
Definition: cs_types.hpp:387
Namespace for CodeSonar/CodeSurfer API.
Definition: cs_ast.hpp:33
xr_intra_definition_iterator range_definition_iterator(line_number lb, line_number ub) const
Given a code region in a source file, get an iterator over the definitions of all source entities wit...
Definition: cs_sfile.hpp:156
xr_definition_iterator token_definition_iterator(line_number line, csuint64 token_namehash, xr_def_iter_flags flags=xr_def_iter_flags::NONE) const
Given a token occurrence in a source file, get an iterator over all definitions of the corresponding ...
Definition: cs_sfile.hpp:26
Iterator over the definitions (xr_tuple) of a token.
Definition: cs_tplt_instantiations.hpp:1140
A directory.
Definition: cs_directory_decl.hpp:91
Iterator over the definitions (xr_tuple) of a token.
Definition: cs_tplt_instantiations.hpp:1182
static const xr_role DEFINITION
...when defined.
Definition: cs_xr_kind_role.hpp:42
Flag class: properties for xr_occurrence_iterator and xr_homonym_iterator iterators.
Definition: cs_xref_fwd.hpp:70
Iterator over the homonyms (xr_tuple) of a token.
Definition: cs_tplt_instantiations.hpp:1248
directory parent() const
Get the parent directory for a source file.
Definition: cs_sfile.hpp:165
Iterator over the occurrences (xr_tuple) of a token.
Definition: cs_tplt_instantiations.hpp:1215
csuint64 xr_namehash(const std::string &s)
Hash a token name.
Definition: cs_xr_kind_role.hpp:20
xr_occurrence_iterator token_occurrence_iterator(line_number line, csuint64 token_namehash, xr_kind_role kr_filter, size_t limit_per_kind_role=0, xr_occ_iter_flags flags=xr_occ_iter_flags::DROP_LIBMODEL_DEFS|xr_occ_iter_flags::DROP_LIBMODEL_OCCS) const
Given a token occurrence in a source file, where the token is specified by namehash, get an iterator over all occurrences of the corresponding source entity in a specific kind/role.
Definition: cs_sfile.hpp:52
Enumeration class: describes the kind of a (non-keyword) token.
Definition: cs_xr_kind_role.hpp:31
xr_homonym_iterator token_homonym_iterator(line_number line, csuint64 token_namehash, xr_kind kind_filter, size_t limit_per_kind_role=0, xr_occ_iter_flags flags=xr_occ_iter_flags::DROP_LIBMODEL_DEFS|xr_occ_iter_flags::DROP_LIBMODEL_OCCS) const
Given a token occurrence (the "focal occurrence") in a source file, where the token is specified by n...
Definition: cs_sfile.hpp:104
Enumeration class: describes a valid token kind-role (kind-usage) pair.
Definition: cs_xr_kind_role.hpp:67
Flag class: properties for an xr_definition_iterator.
Definition: cs_xref_fwd.hpp:38