src/energyplus/MapFields.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "MapFields.hpp" | ||
| 7 | |||
| 8 | #include "../utilities/idf/IdfObject.hpp" | ||
| 9 | #include "../utilities/core/Optional.hpp" | ||
| 10 | |||
| 11 | namespace openstudio { | ||
| 12 | namespace energyplus { | ||
| 13 | |||
| 14 | ✗ | bool mapFields(const IdfObject& oldObject, IdfObject& newObject) { | |
| 15 | ✗ | bool result = true; | |
| 16 | ✗ | unsigned numFields = oldObject.numFields(); | |
| 17 | ✗ | for (unsigned i = 0; i < numFields; ++i) { | |
| 18 | ✗ | if (auto s_ = oldObject.getString(i)) { | |
| 19 | ✗ | result = result && newObject.setString(i, s_.get()); | |
| 20 | ✗ | } | |
| 21 | } | ||
| 22 | ✗ | return result; | |
| 23 | } | ||
| 24 | |||
| 25 | 85 | bool mapFields(const IdfObject& oldObject, IdfObject& newObject, const std::vector<std::pair<unsigned, unsigned>>& fieldMap) { | |
| 26 | 85 | bool result = true; | |
| 27 |
2/2✓ Branch 7 taken 295 times.
✓ Branch 8 taken 85 times.
|
380 | for (const auto& [oriIndex, targetIndex] : fieldMap) { |
| 28 |
2/3✓ Branch 1 taken 295 times.
✓ Branch 3 taken 295 times.
✗ Branch 4 not taken.
|
590 | if (auto s_ = oldObject.getString(oriIndex)) { |
| 29 |
4/6✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 295 times.
✓ Branch 6 taken 295 times.
✓ Branch 8 taken 295 times.
✗ Branch 9 not taken.
|
295 | result = result && newObject.setString(targetIndex, s_.get()); |
| 30 | 295 | } | |
| 31 | } | ||
| 32 | 85 | return result; | |
| 33 | } | ||
| 34 | |||
| 35 | } // namespace energyplus | ||
| 36 | } // namespace openstudio | ||
| 37 |