Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
bool *ok parameter removed from enum helper methods (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkormalev authored Jun 5, 2019
1 parent d1ddad2 commit d90249e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ProofUtils Changelog

## Not Released
#### Features
* --
* `bool *ok` parameter removed from enum helper methods

#### Bug Fixing
* --
Expand Down
2 changes: 1 addition & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Changes that one must make to applications based on Proof between versions.
* --

#### API modifications/removals/deprecations
* --
* `bool *ok` parameter removed from enum helper methods

#### Config changes
* --
Expand Down
10 changes: 5 additions & 5 deletions include/proofnetwork/mis/apihelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ PROOF_NETWORK_MIS_EXPORT QString workflowActionToString(WorkflowAction action);
PROOF_NETWORK_MIS_EXPORT QString transitionEventToString(TransitionEvent event);
PROOF_NETWORK_MIS_EXPORT QString paperSideToString(PaperSide side);

PROOF_NETWORK_MIS_EXPORT EntityStatus entityStatusFromString(QString statusString, bool *ok = nullptr);
PROOF_NETWORK_MIS_EXPORT WorkflowStatus workflowStatusFromString(QString statusString, bool *ok = nullptr);
PROOF_NETWORK_MIS_EXPORT WorkflowAction workflowActionFromString(QString actionString, bool *ok = nullptr);
PROOF_NETWORK_MIS_EXPORT TransitionEvent transitionEventFromString(QString eventString, bool *ok = nullptr);
PROOF_NETWORK_MIS_EXPORT PaperSide paperSideFromString(QString sideString, bool *ok = nullptr);
PROOF_NETWORK_MIS_EXPORT EntityStatus entityStatusFromString(const QString &statusString);
PROOF_NETWORK_MIS_EXPORT WorkflowStatus workflowStatusFromString(const QString &statusString);
PROOF_NETWORK_MIS_EXPORT WorkflowAction workflowActionFromString(const QString &actionString);
PROOF_NETWORK_MIS_EXPORT TransitionEvent transitionEventFromString(const QString &eventString);
PROOF_NETWORK_MIS_EXPORT PaperSide paperSideFromString(const QString &sideString);

PROOF_NETWORK_MIS_EXPORT WorkflowStatus workflowStatusAfterTransitionEvent(Proof::Mis::TransitionEvent event);

Expand Down
33 changes: 9 additions & 24 deletions src/proofnetwork/mis/apihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,44 +139,29 @@ QString paperSideToString(PaperSide side)
return PAPER_SIDES->key(side, QString());
}

EntityStatus entityStatusFromString(QString statusString, bool *ok)
EntityStatus entityStatusFromString(const QString &statusString)
{
statusString = statusString.toLower();
if (ok != nullptr)
*ok = ENTITY_STATUSES->contains(statusString);
return ENTITY_STATUSES->value(statusString, EntityStatus::InvalidEntity);
return ENTITY_STATUSES->value(statusString.toLower(), EntityStatus::InvalidEntity);
}

WorkflowStatus workflowStatusFromString(QString statusString, bool *ok)
WorkflowStatus workflowStatusFromString(const QString &statusString)
{
statusString = statusString.toLower();
if (ok != nullptr)
*ok = WORKFLOW_STATUSES->contains(statusString);
return WORKFLOW_STATUSES->value(statusString, WorkflowStatus::UnknownStatus);
return WORKFLOW_STATUSES->value(statusString.toLower(), WorkflowStatus::UnknownStatus);
}

WorkflowAction workflowActionFromString(QString actionString, bool *ok)
WorkflowAction workflowActionFromString(const QString &actionString)
{
actionString = actionString.toLower();
if (ok != nullptr)
*ok = WORKFLOW_ACTIONS->contains(actionString);
return WORKFLOW_ACTIONS->value(actionString, WorkflowAction::UnknownAction);
return WORKFLOW_ACTIONS->value(actionString.toLower(), WorkflowAction::UnknownAction);
}

TransitionEvent transitionEventFromString(QString eventString, bool *ok)
TransitionEvent transitionEventFromString(const QString &eventString)
{
eventString = eventString.toLower();
if (ok != nullptr)
*ok = TRANSITION_EVENTS->contains(eventString);
return TRANSITION_EVENTS->value(eventString, TransitionEvent::UnknownEvent);
}

PaperSide paperSideFromString(QString sideString, bool *ok)
PaperSide paperSideFromString(const QString &sideString)
{
sideString = sideString.toLower();
if (ok != nullptr)
*ok = PAPER_SIDES->contains(sideString);
return PAPER_SIDES->value(sideString, PaperSide::NotSetSide);
return PAPER_SIDES->value(sideString.toLower(), PaperSide::NotSetSide);
}

WorkflowStatus workflowStatusAfterTransitionEvent(Proof::Mis::TransitionEvent event)
Expand Down

0 comments on commit d90249e

Please sign in to comment.