Set a an argument's value from a string. Throws an arg_error exception if \a s can't be converted to the argument's type. \note Not intended to be called from user code. \param s Value to set. */
| 766 | \param s Value to set. |
| 767 | */ |
| 768 | virtual void setValue(const std::string& s) |
| 769 | { |
| 770 | T var; |
| 771 | |
| 772 | m_rawVal = s; |
| 773 | auto status = Utils::fromString(s, var); |
| 774 | if (!status) |
| 775 | { |
| 776 | std::string error(m_error); |
| 777 | |
| 778 | if (error.empty()) |
| 779 | { |
| 780 | if (status.what().size()) |
| 781 | error = "Invalid value for argument '" + m_longname + |
| 782 | "': " + status.what(); |
| 783 | else |
| 784 | error = "Invalid value '" + s + "' for argument '" + |
| 785 | m_longname + "'."; |
| 786 | } |
| 787 | throw arg_val_error(error); |
| 788 | } |
| 789 | if (!m_set) |
| 790 | m_var.clear(); |
| 791 | m_var.push_back(std::move(var)); |
| 792 | m_set = true; |
| 793 | } |
| 794 | |
| 795 | /** |
| 796 | Reset the argument's state. |
nothing calls this directly
no test coverage detected