| 188 | } |
| 189 | |
| 190 | boost::optional<std::string> WorkspaceObject_Impl::getField(unsigned index, bool returnDefault) const { |
| 191 | boost::optional<std::string> result; |
| 192 | |
| 193 | // IdfObject_Impl::getString won't work if this is a source field... since m_fields will be blank |
| 194 | // So we handle that case too |
| 195 | |
| 196 | // If it's a source field: |
| 197 | if (canBeSource(index) && (index < numFields())) { |
| 198 | if (!initialized()) { |
| 199 | return boost::none; |
| 200 | } |
| 201 | |
| 202 | if (m_sourceData) { |
| 203 | // find index and return target if handle not null |
| 204 | auto fpIt = getConstIteratorAtFieldIndex<SourceData>(m_sourceData->pointers, index); |
| 205 | if (fpIt != m_sourceData->pointers.end()) { |
| 206 | Handle th = fpIt->targetHandle; |
| 207 | if (!th.isNull()) { |
| 208 | result = openstudio::toString(th); |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | } else { |
| 213 | // If not source, then call getString |
| 214 | result = IdfObject_Impl::getString(index, returnDefault, false); |
| 215 | } |
| 216 | |
| 217 | return result; |
| 218 | } |
| 219 | |
| 220 | OptionalWorkspaceObject WorkspaceObject_Impl::getTarget(unsigned index) const { |
| 221 | if (!initialized()) { |
no test coverage detected