| 1115 | } |
| 1116 | |
| 1117 | boost::optional<Handle> WorkspaceObject_Impl::convertToTargetHandle(const std::string& name, const std::set<std::string>& referenceLists, |
| 1118 | bool checkValidity) const { |
| 1119 | OS_ASSERT(!m_handle.isNull()); |
| 1120 | |
| 1121 | if (name.empty()) { |
| 1122 | return Handle(); |
| 1123 | } // null pointer |
| 1124 | |
| 1125 | // name is already handle |
| 1126 | if (boost::regex_match(name, uuidInString())) { |
| 1127 | Handle handle = toUUID(name); |
| 1128 | boost::optional<WorkspaceObject> object = m_workspace->getObject(handle); |
| 1129 | if (object) { |
| 1130 | return handle; |
| 1131 | } else { |
| 1132 | // name is a UUID but no object with that handle exists in the workspace, continue checking if this is a name? |
| 1133 | } |
| 1134 | } |
| 1135 | |
| 1136 | WorkspaceObjectVector candidates = m_workspace->getObjectsByName(name); |
| 1137 | |
| 1138 | if (candidates.empty()) { |
| 1139 | return boost::none; |
| 1140 | } |
| 1141 | if (candidates.size() == 1) { |
| 1142 | return candidates[0].handle(); |
| 1143 | } |
| 1144 | |
| 1145 | // multiple. choose first in appropriate reference list. |
| 1146 | for (const WorkspaceObject& candidate : candidates) { |
| 1147 | if (m_workspace->canBeTarget(candidate.handle(), referenceLists)) { |
| 1148 | return candidate.handle(); |
| 1149 | } |
| 1150 | } |
| 1151 | // none found. connect to first candidate if no strictness. |
| 1152 | if ((!checkValidity) || (m_workspace->strictnessLevel() < StrictnessLevel::Draft)) { |
| 1153 | return candidates[0].handle(); |
| 1154 | } |
| 1155 | return boost::none; |
| 1156 | } |
| 1157 | |
| 1158 | void WorkspaceObject_Impl::restoreOriginalNumFields(unsigned n) { |
| 1159 | bool popResult = true; |
nothing calls this directly
no test coverage detected