| 910 | } |
| 911 | |
| 912 | void get() { |
| 913 | std::string line; |
| 914 | if (done) |
| 915 | return; |
| 916 | for (;;) { |
| 917 | if (value != nullptr) { |
| 918 | cson_free_value(value); |
| 919 | value = nullptr; |
| 920 | } |
| 921 | if (!std::getline(file, line)) { |
| 922 | done = true; |
| 923 | return; |
| 924 | } |
| 925 | linenum++; |
| 926 | if (line.empty()) |
| 927 | continue; |
| 928 | int rc = cson_parse_string(&value, line.c_str(), line.length()); |
| 929 | if (rc) { |
| 930 | std::cerr << "Error: Malformed input on line " << linenum << std::endl; |
| 931 | continue; |
| 932 | } |
| 933 | if (!cson_value_is_object(value)) { |
| 934 | std::cerr << "Error: Not an object on line " << linenum << std::endl; |
| 935 | continue; |
| 936 | } |
| 937 | const char *type = get_strprop(value, "type"); |
| 938 | // skip anything with no type field (we don't know what it is) or timestamp (we don't know the order of replay) |
| 939 | if (type == nullptr || strcmp(type, "sql") != 0) |
| 940 | continue; |
| 941 | if (!get_intprop(value, "time", ×tamp)) |
| 942 | continue; |
| 943 | break; |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | bool is_done() const { |
| 948 | return done; |
nothing calls this directly
no test coverage detected