MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / toString

Method toString

src/openms/source/DATASTRUCTURES/ParamValue.cpp:551–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549 }
550
551 std::string ParamValue::toString(bool full_precision) const
552 {
553 std::string str;
554 switch (value_type_)
555 {
556 case EMPTY_VALUE:
557 return "";
558 break;
559 case STRING_VALUE:
560 return *data_.str_;
561 break;
562 case INT_VALUE:
563 return std::to_string(data_.ssize_);
564 break;
565 case DOUBLE_VALUE:
566 {
567 return doubleToString(data_.dou_, full_precision);
568 }
569 break;
570 case STRING_LIST:
571 str = "[";
572 if (!data_.str_list_->empty())
573 {
574 for (std::vector<std::string>::const_iterator it = data_.str_list_->begin();
575 it != data_.str_list_->end() - 1; ++it)
576 {
577 str += *it + ", ";
578 }
579 str += data_.str_list_->back();
580 }
581 str += "]";
582 break;
583 case INT_LIST:
584 str = "[";
585 if (!data_.int_list_->empty()) {
586 for (std::vector<int>::const_iterator it = data_.int_list_->begin();
587 it != data_.int_list_->end() - 1; ++it)
588 {
589 str += std::to_string(*it) + ", ";
590 }
591 str += std::to_string(data_.int_list_->back());
592 }
593 str += "]";
594 break;
595 case DOUBLE_LIST:
596 str = "[";
597 if (!data_.dou_list_->empty()) {
598 for (std::vector<double>::const_iterator it = data_.dou_list_->begin();
599 it != data_.dou_list_->end() - 1; ++it) {
600 str += doubleToString(*it, full_precision) + ", ";
601 }
602 str += doubleToString(data_.dou_list_->back(), full_precision);
603 }
604 str += "]";
605 break;
606 default:
607 throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Could not convert ParamValue to String");
608 break;

Callers

nothing calls this directly

Calls 4

backMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected