MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / fromString

Method fromString

src/utilities/filetypes/WorkflowStepResult.cpp:721–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719 : m_impl(std::shared_ptr<detail::WorkflowStepValue_Impl>(new detail::WorkflowStepValue_Impl(name, Variant(value)))) {}
720
721boost::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
757std::string WorkflowStepValue::string() const {
758 return getImpl<detail::WorkflowStepValue_Impl>()->string();

Callers

nothing calls this directly

Calls 15

isMemberMethod · 0.80
setStartedAtMethod · 0.80
setCompletedAtMethod · 0.80
setMeasureNameMethod · 0.80
setMeasureIdMethod · 0.80
setMeasureVersionIdMethod · 0.80
setMeasureXmlChecksumMethod · 0.80
setMeasureClassNameMethod · 0.80
setMeasureDisplayNameMethod · 0.80
setMeasureTaxonomyMethod · 0.80
setStepResultMethod · 0.80

Tested by

no test coverage detected