------------------------------------------------------------------------------------------------
| 230 | |
| 231 | // ------------------------------------------------------------------------------------------------ |
| 232 | const aiScene *aiImportFileFromMemoryWithProperties( |
| 233 | const char *pBuffer, |
| 234 | unsigned int pLength, |
| 235 | unsigned int pFlags, |
| 236 | const char *pHint, |
| 237 | const aiPropertyStore *props) { |
| 238 | if (pBuffer == nullptr) { |
| 239 | return nullptr; |
| 240 | } |
| 241 | |
| 242 | if (pLength == 0u) { |
| 243 | return nullptr; |
| 244 | } |
| 245 | |
| 246 | const aiScene *scene = nullptr; |
| 247 | ASSIMP_BEGIN_EXCEPTION_REGION(); |
| 248 | |
| 249 | // create an Importer for this file |
| 250 | Assimp::Importer *imp = new Assimp::Importer(); |
| 251 | |
| 252 | // copy properties |
| 253 | if (props) { |
| 254 | const PropertyMap *pp = reinterpret_cast<const PropertyMap *>(props); |
| 255 | ImporterPimpl *pimpl = imp->Pimpl(); |
| 256 | pimpl->mIntProperties = pp->ints; |
| 257 | pimpl->mFloatProperties = pp->floats; |
| 258 | pimpl->mStringProperties = pp->strings; |
| 259 | pimpl->mMatrixProperties = pp->matrices; |
| 260 | } |
| 261 | |
| 262 | // and have it read the file from the memory buffer |
| 263 | scene = imp->ReadFileFromMemory(pBuffer, pLength, pFlags, pHint); |
| 264 | |
| 265 | // if succeeded, store the importer in the scene and keep it alive |
| 266 | if (scene) { |
| 267 | ScenePrivateData *priv = const_cast<ScenePrivateData *>(ScenePriv(scene)); |
| 268 | priv->mOrigImporter = imp; |
| 269 | } else { |
| 270 | // if failed, extract error code and destroy the import |
| 271 | gLastErrorString = imp->GetErrorString(); |
| 272 | delete imp; |
| 273 | } |
| 274 | // return imported data. If the import failed the pointer is nullptr anyways |
| 275 | ASSIMP_END_EXCEPTION_REGION(const aiScene *); |
| 276 | return scene; |
| 277 | } |
| 278 | |
| 279 | // ------------------------------------------------------------------------------------------------ |
| 280 | // Releases all resources associated with the given import process. |
no test coverage detected