| 914 | |
| 915 | template <typename T> |
| 916 | void read_array_1d (std::vector<T>& ref, std::string const& str) |
| 917 | { |
| 918 | ref.clear(); |
| 919 | std::istringstream is(str); |
| 920 | auto throw_parse_error = [&str]() { |
| 921 | throw std::runtime_error("ParmParse: failed to parse array element in " + str); |
| 922 | }; |
| 923 | T v{}; |
| 924 | is.ignore(100000, '['); |
| 925 | if (!(is >> v)) { |
| 926 | throw_parse_error(); |
| 927 | } |
| 928 | ref.push_back(v); |
| 929 | while (true) { |
| 930 | is >> std::ws; |
| 931 | auto nc = is.peek(); |
| 932 | if (nc == ',') { |
| 933 | is.ignore(1, ','); |
| 934 | is >> std::ws; |
| 935 | nc = is.peek(); |
| 936 | if (nc == ']') { return; } |
| 937 | if (!(is >> v)) { |
| 938 | throw_parse_error(); |
| 939 | } |
| 940 | ref.push_back(v); |
| 941 | continue; |
| 942 | } else { |
| 943 | break; |
| 944 | } |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | bool is_escaped_quote (std::string const& str, std::string::size_type pos) |
| 949 | { |
no test coverage detected