Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
ae2dc0d9
Commit
ae2dc0d9
authored
14 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
MatchVector indexing operators and size() member
parent
d0a52fb3
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libwccl/values/matchvector.cpp
+9
-0
9 additions, 0 deletions
libwccl/values/matchvector.cpp
libwccl/values/matchvector.h
+18
-0
18 additions, 0 deletions
libwccl/values/matchvector.h
with
27 additions
and
0 deletions
libwccl/values/matchvector.cpp
+
9
−
0
View file @
ae2dc0d9
#include
<libwccl/values/matchvector.h>
#include
<libpwrutils/foreach.h>
#include
<sstream>
#include
<libwccl/exception.h>
namespace
Wccl
{
...
...
@@ -74,5 +75,13 @@ void MatchVector::append(const boost::shared_ptr<Match> &m)
matches_
.
push_back
(
m
);
}
const
boost
::
shared_ptr
<
Match
>&
MatchVector
::
submatch
(
size_t
idx
)
{
if
(
idx
<
matches_
.
size
())
{
return
matches_
[
size
];
}
else
{
throw
Wccl
::
WcclError
(
"Match vector index out of range"
);
}
}
}
/* end ns Wccl */
This diff is collapsed.
Click to expand it.
libwccl/values/matchvector.h
+
18
−
0
View file @
ae2dc0d9
...
...
@@ -32,6 +32,24 @@ public:
/// Append a sub-match
void
append
(
const
boost
::
shared_ptr
<
Match
>&
m
);
/// Size (number of direct sub-matches)
size_t
size
()
const
{
return
matches_
.
size
();
}
/**
* Submatch accesor with bounds checking, throws if out of bounds
*/
const
boost
::
shared_ptr
<
Match
>&
submatch
(
size_t
idx
);
/**
* Submatch indexing operator. Per C++ container tradition, no bounds
* checking is done.
*/
const
boost
::
shared_ptr
<
Match
>&
operator
[](
size_t
idx
)
const
{
return
matches_
[
idx
];
}
private
:
std
::
vector
<
boost
::
shared_ptr
<
Match
>
>
matches_
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment