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
3875a586
Commit
3875a586
authored
14 years ago
by
Adam Wardynski
Browse files
Options
Downloads
Patches
Plain Diff
Sentence context argument check in Operator's apply.
parent
a6435107
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libwccl/ops/operator.h
+23
-8
23 additions, 8 deletions
libwccl/ops/operator.h
with
23 additions
and
8 deletions
libwccl/ops/operator.h
+
23
−
8
View file @
3875a586
...
...
@@ -57,7 +57,7 @@ public:
/**
* Applies the functional operator to given sentence context.
* @returns Result of the application of this operator.
* @param s
c
SentenceContext of the Sentence to apply the operator to.
* @param s
entence_context
SentenceContext of the Sentence to apply the operator to.
* @note The result is conciously marked as const, so a copy of operator data
* is not created unless necessary.
* @see apply() - equivalent method; the \link operator()() operator() \endlink allows
...
...
@@ -77,12 +77,12 @@ public:
* for you to modify as you may see fit if you need it;
* this is convenience method over having to create a copy yourself.
*/
boost
::
shared_ptr
<
const
T
>
operator
()(
const
SentenceContext
&
s
c
);
boost
::
shared_ptr
<
const
T
>
operator
()(
const
SentenceContext
&
s
entence_context
);
/**
* Applies the functional operator to given sentence context.
* @returns Result of the application of this operator.
* @param s
c
SentenceContext of the Sentence to apply the operator to.
* @param s
entence_context
SentenceContext of the Sentence to apply the operator to.
* @note The result is conciously marked as const, so a copy of operator data
* is not created unless necessary.
* @see \link operator()() operator() \endlink - an equivalent of this method that allows for functional
...
...
@@ -91,13 +91,13 @@ public:
* for you to modify as you may see fit if you need it;
* this is convenience method over having to create a copy yourself.
*/
boost
::
shared_ptr
<
const
T
>
apply
(
const
SentenceContext
&
s
c
);
boost
::
shared_ptr
<
const
T
>
apply
(
const
SentenceContext
&
s
entence_context
);
/**
* Applies the functional operator to given sentence context, returning pointer
* to a mutable Value.
* @returns Result of the application of this operator.
* @param s
c
SentenceContext of the Sentence to apply the operator to.
* @param s
entence_context
SentenceContext of the Sentence to apply the operator to.
* @see \link operator()() operator() \endlink, apply - you may still be
* better off using them if you expect to work on a raw value rather
* than a pointer, as in e.g.
...
...
@@ -110,7 +110,7 @@ public:
* shared_ptr<StrSet> s_ptr2 = op_ptr->copy_apply(sc);
* \endcode
*/
boost
::
shared_ptr
<
T
>
copy_apply
(
const
SentenceContext
&
s
c
);
boost
::
shared_ptr
<
T
>
copy_apply
(
const
SentenceContext
&
s
entence_context
);
/**
* Applies the functional operator to given sentence context.
...
...
@@ -211,7 +211,12 @@ private:
boost
::
shared_ptr
<
const
Function
<
T
>
>
function_body_
;
};
//
//--- implementation details ---
//
inline
FunctionalOperator
::
FunctionalOperator
(
...
...
@@ -244,8 +249,18 @@ Operator<T>::Operator(
}
template
<
class
T
>
inline
boost
::
shared_ptr
<
const
T
>
Operator
<
T
>::
apply
(
const
SentenceContext
&
sc
)
{
return
function_body_
->
apply
(
FunExecContext
(
sc
,
variables_
));
boost
::
shared_ptr
<
const
T
>
Operator
<
T
>::
apply
(
const
SentenceContext
&
sentence_context
)
{
if
(
sentence_context
.
size
()
==
0
)
{
throw
InvalidArgument
(
"sentence_context"
,
"Received an empty sentence."
);
}
if
(
!
sentence_context
.
is_current_inside
())
{
throw
InvalidArgument
(
"sentence_context"
,
"Current position is outside boundaries of the sentence."
);
}
return
function_body_
->
apply
(
FunExecContext
(
sentence_context
,
variables_
));
}
template
<
class
T
>
inline
...
...
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