| 719 | : m_impl(std::shared_ptr<detail::WorkflowStepValue_Impl>(new detail::WorkflowStepValue_Impl(name, Variant(value)))) {} |
| 720 | |
| 721 | boost::optional<WorkflowStepValue> WorkflowStepValue::fromString(const std::string& s) { |
| 722 | // We let it fail with a warning message |
| 723 | const Json::CharReaderBuilder rbuilder; |
| 724 | std::istringstream ss(s); |
| 725 | std::string formattedErrors; |
| 726 | Json::Value value; |
| 727 | const bool parsingSuccessful = Json::parseFromStream(rbuilder, ss, &value, &formattedErrors); |
| 728 | if (!parsingSuccessful) { |
| 729 | LOG(Warn, "Couldn't parse WorkflowStepValue from string s='" << s << "'. Error: '" << formattedErrors << "'."); |
| 730 | return boost::none; |
| 731 | } |
| 732 | |
| 733 | boost::optional<WorkflowStepValue> result; |
| 734 | |
| 735 | try { |
| 736 | const std::string name = value["name"].asString(); |
| 737 | const Json::Value v = value["value"]; |
| 738 | if (v.isString()) { |
| 739 | result = WorkflowStepValue(name, v.asString()); |
| 740 | } else if (v.isIntegral()) { |
| 741 | result = WorkflowStepValue(name, v.asInt()); |
| 742 | } else if (v.isDouble()) { |
| 743 | result = WorkflowStepValue(name, v.asDouble()); |
| 744 | } else if (v.isBool()) { |
| 745 | result = WorkflowStepValue(name, v.asBool()); |
| 746 | } else { |
| 747 | //error |
| 748 | } |
| 749 | |
| 750 | } catch (const std::exception&) { |
| 751 | return boost::none; |
| 752 | } |
| 753 | |
| 754 | return result; |
| 755 | } |
| 756 | |
| 757 | std::string WorkflowStepValue::string() const { |
| 758 | return getImpl<detail::WorkflowStepValue_Impl>()->string(); |
nothing calls this directly
no test coverage detected