src/utilities/idd/IddObjectProperties.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 "IddObjectProperties.hpp" | ||
| 7 | |||
| 8 | #include <sstream> | ||
| 9 | |||
| 10 | namespace openstudio { | ||
| 11 | |||
| 12 | /// default constructor | ||
| 13 | 1323343 | IddObjectProperties::IddObjectProperties() | |
| 14 | 1323343 | : unique(false), | |
| 15 | 1323343 | required(false), | |
| 16 | 1323343 | obsolete(false), | |
| 17 | 1323343 | hasURL(false), | |
| 18 | 1323343 | extensible(false), | |
| 19 | 1323343 | numExtensible(0), | |
| 20 | 1323343 | numExtensibleGroupsRequired(0), | |
| 21 | 1323343 | minFields(0) {} | |
| 22 | |||
| 23 | // ETH@20100329 Is the purpose to identify exactly equal properties, or objects that behave | ||
| 24 | // the same? If the latter, might ignore memo, and even numExtensibleGroupsRequired, and | ||
| 25 | // minFields. Keeping it simple for now. | ||
| 26 | /// equality operator | ||
| 27 | 184 | bool IddObjectProperties::operator==(const IddObjectProperties& other) const { | |
| 28 | |||
| 29 | return ((this == &other) | ||
| 30 |
7/10✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 182 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 182 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 182 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 182 times.
✗ Branch 10 not taken.
|
366 | || ((memo == other.memo) && (unique == other.unique) && (required == other.required) && (obsolete == other.obsolete) |
| 31 |
3/6✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 182 times.
✗ Branch 5 not taken.
|
182 | && (hasURL == other.hasURL) && (extensible == other.extensible) && (numExtensible == other.numExtensible) |
| 32 |
4/6✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 182 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 181 times.
✓ Branch 6 taken 1 time.
|
182 | && (numExtensibleGroupsRequired == other.numExtensibleGroupsRequired) && (format == other.format) && (minFields == other.minFields) |
| 33 |
1/2✓ Branch 1 taken 181 times.
✗ Branch 2 not taken.
|
365 | && (maxFields == other.maxFields))); |
| 34 | } | ||
| 35 | |||
| 36 | 181 | bool IddObjectProperties::operator!=(const IddObjectProperties& other) const { | |
| 37 | 181 | return !(*this == other); | |
| 38 | } | ||
| 39 | |||
| 40 | |||
| 41 | 57587 | std::ostream& IddObjectProperties::print(std::ostream& os) const { | |
| 42 |
2/2✓ Branch 1 taken 36069 times.
✓ Branch 2 taken 21518 times.
|
57587 | if (!memo.empty()) { |
| 43 |
1/1✓ Branch 2 taken 36069 times.
|
36069 | std::stringstream ss(memo); |
| 44 | 36069 | std::string line; | |
| 45 |
3/3✓ Branch 1 taken 133586 times.
✓ Branch 3 taken 97517 times.
✓ Branch 4 taken 36069 times.
|
133586 | while (!ss.eof()) { |
| 46 |
1/1✓ Branch 1 taken 97517 times.
|
97517 | std::getline(ss, line); |
| 47 |
3/3✓ Branch 1 taken 97517 times.
✓ Branch 4 taken 97517 times.
✓ Branch 7 taken 97517 times.
|
97517 | os << " \\memo " << line << '\n'; |
| 48 | } | ||
| 49 | 36069 | } | |
| 50 | |||
| 51 |
2/2✓ Branch 0 taken 5259 times.
✓ Branch 1 taken 52328 times.
|
57587 | if (unique) { |
| 52 | 5259 | os << " \\unique-object" << '\n'; | |
| 53 | } | ||
| 54 | |||
| 55 |
2/2✓ Branch 0 taken 302 times.
✓ Branch 1 taken 57285 times.
|
57587 | if (required) { |
| 56 | 302 | os << " \\required-object" << '\n'; | |
| 57 | } | ||
| 58 | |||
| 59 |
2/2✓ Branch 0 taken 100 times.
✓ Branch 1 taken 57487 times.
|
57587 | if (obsolete) { |
| 60 | 100 | os << " \\obsolete" << '\n'; | |
| 61 | } | ||
| 62 | |||
| 63 |
2/2✓ Branch 0 taken 401 times.
✓ Branch 1 taken 57186 times.
|
57587 | if (hasURL) { |
| 64 | 401 | os << " \\url-object" << '\n'; | |
| 65 | } | ||
| 66 |
2/2✓ Branch 0 taken 8772 times.
✓ Branch 1 taken 48815 times.
|
57587 | if (extensible) { |
| 67 | 8772 | os << " \\extensible:" << numExtensible << '\n'; | |
| 68 | } | ||
| 69 | |||
| 70 |
2/2✓ Branch 1 taken 2642 times.
✓ Branch 2 taken 54945 times.
|
57587 | if (!format.empty()) { |
| 71 | 2642 | os << " \\format " << format << '\n'; | |
| 72 | } | ||
| 73 | |||
| 74 |
2/2✓ Branch 0 taken 42263 times.
✓ Branch 1 taken 15324 times.
|
57587 | if (minFields > 0) { |
| 75 | 42263 | os << " \\min-fields " << minFields << '\n'; | |
| 76 | } | ||
| 77 | |||
| 78 |
2/2✓ Branch 1 taken 1648 times.
✓ Branch 2 taken 55939 times.
|
115174 | if (maxFields) { |
| 79 | 1648 | os << " \\max-fields " << *maxFields << '\n'; | |
| 80 | } | ||
| 81 | |||
| 82 | 57587 | return os; | |
| 83 | } | ||
| 84 | |||
| 85 | } // namespace openstudio | ||
| 86 |