| 125 | .Bind("version"_s, &QueryRoot::version, VersionHelper, true); |
| 126 | |
| 127 | bool cmInstrumentationQuery::ReadJSON(std::string const& filename, |
| 128 | std::string& errorMessage, |
| 129 | std::set<Option>& options, |
| 130 | std::set<Hook>& hooks, |
| 131 | std::vector<Callback>& callbacks) |
| 132 | { |
| 133 | Json::Value root; |
| 134 | this->parseState = cmJSONState(filename, &root); |
| 135 | if (!this->parseState.errors.empty()) { |
| 136 | errorMessage = this->parseState.GetErrorMessage(true); |
| 137 | return false; |
| 138 | } |
| 139 | if (!QueryRootVersionOnlyHelper(this->queryRoot, &root, &this->parseState)) { |
| 140 | errorMessage = this->parseState.GetErrorMessage(true); |
| 141 | return false; |
| 142 | } |
| 143 | if (!ValidDataVersion(this->queryRoot.version)) { |
| 144 | // Ignore invalid data versions |
| 145 | return true; |
| 146 | } |
| 147 | if (!QueryRootHelper(this->queryRoot, &root, &this->parseState)) { |
| 148 | errorMessage = this->parseState.GetErrorMessage(true); |
| 149 | return false; |
| 150 | } |
| 151 | std::move(this->queryRoot.options.begin(), this->queryRoot.options.end(), |
| 152 | std::inserter(options, options.end())); |
| 153 | std::move(this->queryRoot.hooks.begin(), this->queryRoot.hooks.end(), |
| 154 | std::inserter(hooks, hooks.end())); |
| 155 | for (auto const& callback : this->queryRoot.callbacks) { |
| 156 | callbacks.push_back({ callback, this->queryRoot.version }); |
| 157 | } |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | bool cmInstrumentationQuery::ValidDataVersion(Version version) |
| 162 | { |
no test coverage detected