MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / read_array_1d

Function read_array_1d

Src/Base/AMReX_ParmParse.cpp:916–946  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

914
915template <typename T>
916void 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
948bool is_escaped_quote (std::string const& str, std::string::size_type pos)
949{

Callers 3

read_array_2dFunction · 0.85
squeryvalFunction · 0.85
squeryarrFunction · 0.85

Calls 4

is_escaped_quoteFunction · 0.85
AbortFunction · 0.85
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected