| 350 | } |
| 351 | |
| 352 | bool Validate(std::size_t count) override |
| 353 | { |
| 354 | this->Start = this->NormalizeIndex(this->Start, count); |
| 355 | this->Stop = this->NormalizeIndex(this->Stop, count); |
| 356 | |
| 357 | // Does stepping move us further from the end? |
| 358 | if (this->Start > this->Stop) { |
| 359 | throw transform_error( |
| 360 | cmStrCat("sub-command TRANSFORM, selector FOR " |
| 361 | "expects <start> to be no greater than <stop> (", |
| 362 | this->Start, " > ", this->Stop, ')')); |
| 363 | } |
| 364 | |
| 365 | // compute indexes |
| 366 | auto size = (this->Stop - this->Start + 1) / this->Step; |
| 367 | if ((this->Stop - this->Start + 1) % this->Step != 0) { |
| 368 | size += 1; |
| 369 | } |
| 370 | |
| 371 | this->Indexes.resize(size); |
| 372 | auto start = this->Start; |
| 373 | auto step = this->Step; |
| 374 | std::generate(this->Indexes.begin(), this->Indexes.end(), |
| 375 | [&start, step]() -> index_type { |
| 376 | auto r = start; |
| 377 | start += step; |
| 378 | return r; |
| 379 | }); |
| 380 | |
| 381 | return true; |
| 382 | } |
| 383 | |
| 384 | private: |
| 385 | index_type Start, Stop, Step; |
nothing calls this directly
no test coverage detected