MaterialSystem.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /*
  2. Open Asset Import Library (ASSIMP)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2010, ASSIMP Development Team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the ASSIMP team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the ASSIMP Development Team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file MaterialSystem.cpp
  34. * @brief Implementation of the material system of the library
  35. */
  36. #include "AssimpPCH.h"
  37. #include "Hash.h"
  38. #include "fast_atof.h"
  39. #include "ParsingUtils.h"
  40. using namespace Assimp;
  41. // ------------------------------------------------------------------------------------------------
  42. // Get a specific property from a material
  43. aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
  44. const char* pKey,
  45. unsigned int type,
  46. unsigned int index,
  47. const aiMaterialProperty** pPropOut)
  48. {
  49. ai_assert (pMat != NULL);
  50. ai_assert (pKey != NULL);
  51. ai_assert (pPropOut != NULL);
  52. /* Just search for a property with exactly this name ..
  53. * could be improved by hashing, but it's possibly
  54. * no worth the effort (we're bound to C structures,
  55. * thus std::map or derivates are not applicable. */
  56. for (unsigned int i = 0; i < pMat->mNumProperties;++i) {
  57. aiMaterialProperty* prop = pMat->mProperties[i];
  58. if (prop /* just for safety ... */
  59. && 0 == strcmp( prop->mKey.data, pKey )
  60. && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wildcard, but this is undocumented :-) */
  61. && (UINT_MAX == index || prop->mIndex == index))
  62. {
  63. *pPropOut = pMat->mProperties[i];
  64. return AI_SUCCESS;
  65. }
  66. }
  67. *pPropOut = NULL;
  68. return AI_FAILURE;
  69. }
  70. // ------------------------------------------------------------------------------------------------
  71. // Get an array of floating-point values from the material.
  72. aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
  73. const char* pKey,
  74. unsigned int type,
  75. unsigned int index,
  76. float* pOut,
  77. unsigned int* pMax)
  78. {
  79. ai_assert (pOut != NULL);
  80. ai_assert (pMat != NULL);
  81. const aiMaterialProperty* prop;
  82. aiGetMaterialProperty(pMat,pKey,type,index, (const aiMaterialProperty**) &prop);
  83. if (!prop) {
  84. return AI_FAILURE;
  85. }
  86. // data is given in floats, simply copy it
  87. unsigned int iWrite;
  88. if( aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) {
  89. iWrite = prop->mDataLength / sizeof(float);
  90. if (pMax) {
  91. iWrite = std::min(*pMax,iWrite); ;
  92. }
  93. for (unsigned int a = 0; a < iWrite;++a) {
  94. pOut[a] = static_cast<float> ( reinterpret_cast<float*>(prop->mData)[a] );
  95. }
  96. if (pMax) {
  97. *pMax = iWrite;
  98. }
  99. }
  100. // data is given in ints, convert to float
  101. else if( aiPTI_Integer == prop->mType) {
  102. iWrite = prop->mDataLength / sizeof(int32_t);
  103. if (pMax) {
  104. iWrite = std::min(*pMax,iWrite); ;
  105. }
  106. for (unsigned int a = 0; a < iWrite;++a) {
  107. pOut[a] = static_cast<float> ( reinterpret_cast<int32_t*>(prop->mData)[a] );
  108. }
  109. if (pMax) {
  110. *pMax = iWrite;
  111. }
  112. }
  113. // a string ... read floats separated by spaces
  114. else {
  115. if (pMax) {
  116. iWrite = *pMax;
  117. }
  118. // strings are zero-terminated with a 32 bit length prefix, so this is safe
  119. const char* cur = prop->mData+4;
  120. ai_assert(prop->mDataLength>=5 && !prop->mData[prop->mDataLength-1]);
  121. for (unsigned int a = 0; ;++a) {
  122. cur = fast_atof_move(cur,pOut[a]);
  123. if(a==iWrite-1) {
  124. break;
  125. }
  126. if(!IsSpace(*cur)) {
  127. DefaultLogger::get()->error("Material property" + std::string(pKey) +
  128. " is a string; failed to parse a float array out of it.");
  129. return AI_FAILURE;
  130. }
  131. }
  132. if (pMax) {
  133. *pMax = iWrite;
  134. }
  135. }
  136. return AI_SUCCESS;
  137. }
  138. // ------------------------------------------------------------------------------------------------
  139. // Get an array if integers from the material
  140. aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
  141. const char* pKey,
  142. unsigned int type,
  143. unsigned int index,
  144. int* pOut,
  145. unsigned int* pMax)
  146. {
  147. ai_assert (pOut != NULL);
  148. ai_assert (pMat != NULL);
  149. const aiMaterialProperty* prop;
  150. aiGetMaterialProperty(pMat,pKey,type,index,(const aiMaterialProperty**) &prop);
  151. if (!prop) {
  152. return AI_FAILURE;
  153. }
  154. // data is given in ints, simply copy it
  155. unsigned int iWrite;
  156. if( aiPTI_Integer == prop->mType || aiPTI_Buffer == prop->mType) {
  157. iWrite = prop->mDataLength / sizeof(int32_t);
  158. if (pMax) {
  159. iWrite = std::min(*pMax,iWrite); ;
  160. }
  161. for (unsigned int a = 0; a < iWrite;++a) {
  162. pOut[a] = static_cast<int>(reinterpret_cast<int32_t*>(prop->mData)[a]);
  163. }
  164. if (pMax) {
  165. *pMax = iWrite;
  166. }
  167. }
  168. // data is given in floats convert to int
  169. else if( aiPTI_Float == prop->mType) {
  170. iWrite = prop->mDataLength / sizeof(float);
  171. if (pMax) {
  172. iWrite = std::min(*pMax,iWrite); ;
  173. }
  174. for (unsigned int a = 0; a < iWrite;++a) {
  175. pOut[a] = static_cast<int>(reinterpret_cast<float*>(prop->mData)[a]);
  176. }
  177. if (pMax) {
  178. *pMax = iWrite;
  179. }
  180. }
  181. // it is a string ... no way to read something out of this
  182. else {
  183. if (pMax) {
  184. iWrite = *pMax;
  185. }
  186. // strings are zero-terminated with a 32 bit length prefix, so this is safe
  187. const char* cur = prop->mData+4;
  188. ai_assert(prop->mDataLength>=5 && !prop->mData[prop->mDataLength-1]);
  189. for (unsigned int a = 0; ;++a) {
  190. pOut[a] = strtol10(cur,&cur);
  191. if(a==iWrite-1) {
  192. break;
  193. }
  194. if(!IsSpace(*cur)) {
  195. DefaultLogger::get()->error("Material property" + std::string(pKey) +
  196. " is a string; failed to parse an integer array out of it.");
  197. return AI_FAILURE;
  198. }
  199. }
  200. if (pMax) {
  201. *pMax = iWrite;
  202. }
  203. }
  204. return AI_SUCCESS;
  205. }
  206. // ------------------------------------------------------------------------------------------------
  207. // Get a color (3 or 4 floats) from the material
  208. aiReturn aiGetMaterialColor(const aiMaterial* pMat,
  209. const char* pKey,
  210. unsigned int type,
  211. unsigned int index,
  212. aiColor4D* pOut)
  213. {
  214. unsigned int iMax = 4;
  215. const aiReturn eRet = aiGetMaterialFloatArray(pMat,pKey,type,index,(float*)pOut,&iMax);
  216. // if no alpha channel is defined: set it to 1.0
  217. if (3 == iMax) {
  218. pOut->a = 1.0f;
  219. }
  220. return eRet;
  221. }
  222. // ------------------------------------------------------------------------------------------------
  223. // Get a string from the material
  224. aiReturn aiGetMaterialString(const aiMaterial* pMat,
  225. const char* pKey,
  226. unsigned int type,
  227. unsigned int index,
  228. aiString* pOut)
  229. {
  230. ai_assert (pOut != NULL);
  231. const aiMaterialProperty* prop;
  232. aiGetMaterialProperty(pMat,pKey,type,index,(const aiMaterialProperty**)&prop);
  233. if (!prop) {
  234. return AI_FAILURE;
  235. }
  236. if( aiPTI_String == prop->mType) {
  237. ai_assert(prop->mDataLength>=5);
  238. // The string is stored as 32 but length prefix followed by zero-terminated UTF8 data
  239. pOut->length = static_cast<unsigned int>(*reinterpret_cast<uint32_t*>(prop->mData));
  240. ai_assert(pOut->length+1+4==prop->mDataLength && !prop->mData[prop->mDataLength-1]);
  241. memcpy(pOut->data,prop->mData+4,pOut->length+1);
  242. }
  243. else {
  244. // TODO - implement lexical cast as well
  245. DefaultLogger::get()->error("Material property" + std::string(pKey) +
  246. " was found, but is no string" );
  247. return AI_FAILURE;
  248. }
  249. return AI_SUCCESS;
  250. }
  251. // ------------------------------------------------------------------------------------------------
  252. // Get the number of textures on a particular texture stack
  253. ASSIMP_API unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat,
  254. C_ENUM aiTextureType type)
  255. {
  256. ai_assert (pMat != NULL);
  257. /* Textures are always stored with ascending indices (ValidateDS provides a check, so we don't need to do it again) */
  258. unsigned int max = 0;
  259. for (unsigned int i = 0; i < pMat->mNumProperties;++i) {
  260. aiMaterialProperty* prop = pMat->mProperties[i];
  261. if (prop /* just a sanity check ... */
  262. && 0 == strcmp( prop->mKey.data, _AI_MATKEY_TEXTURE_BASE )
  263. && prop->mSemantic == type) {
  264. max = std::max(max,prop->mIndex+1);
  265. }
  266. }
  267. return max;
  268. }
  269. // ------------------------------------------------------------------------------------------------
  270. aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
  271. aiTextureType type,
  272. unsigned int index,
  273. C_STRUCT aiString* path,
  274. aiTextureMapping* _mapping /*= NULL*/,
  275. unsigned int* uvindex /*= NULL*/,
  276. float* blend /*= NULL*/,
  277. aiTextureOp* op /*= NULL*/,
  278. aiTextureMapMode* mapmode /*= NULL*/,
  279. unsigned int* flags /*= NULL*/
  280. )
  281. {
  282. ai_assert(NULL != mat && NULL != path);
  283. // Get the path to the texture
  284. if (AI_SUCCESS != aiGetMaterialString(mat,AI_MATKEY_TEXTURE(type,index),path)) {
  285. return AI_FAILURE;
  286. }
  287. // Determine mapping type
  288. aiTextureMapping mapping = aiTextureMapping_UV;
  289. aiGetMaterialInteger(mat,AI_MATKEY_MAPPING(type,index),(int*)&mapping);
  290. if (_mapping)
  291. *_mapping = mapping;
  292. // Get UV index
  293. if (aiTextureMapping_UV == mapping && uvindex) {
  294. aiGetMaterialInteger(mat,AI_MATKEY_UVWSRC(type,index),(int*)uvindex);
  295. }
  296. // Get blend factor
  297. if (blend) {
  298. aiGetMaterialFloat(mat,AI_MATKEY_TEXBLEND(type,index),blend);
  299. }
  300. // Get texture operation
  301. if (op){
  302. aiGetMaterialInteger(mat,AI_MATKEY_TEXOP(type,index),(int*)op);
  303. }
  304. // Get texture mapping modes
  305. if (mapmode) {
  306. aiGetMaterialInteger(mat,AI_MATKEY_MAPPINGMODE_U(type,index),(int*)&mapmode[0]);
  307. aiGetMaterialInteger(mat,AI_MATKEY_MAPPINGMODE_V(type,index),(int*)&mapmode[1]);
  308. }
  309. // Get texture flags
  310. if (flags){
  311. aiGetMaterialInteger(mat,AI_MATKEY_TEXFLAGS(type,index),(int*)flags);
  312. }
  313. return AI_SUCCESS;
  314. }
  315. // ------------------------------------------------------------------------------------------------
  316. // Construction. Actually the one and only way to get an aiMaterial instance
  317. MaterialHelper::MaterialHelper()
  318. {
  319. // Allocate 5 entries by default
  320. mNumProperties = 0;
  321. mNumAllocated = 5;
  322. mProperties = new aiMaterialProperty*[5];
  323. }
  324. // ------------------------------------------------------------------------------------------------
  325. MaterialHelper::~MaterialHelper()
  326. {
  327. _InternDestruct();
  328. }
  329. // ------------------------------------------------------------------------------------------------
  330. aiMaterial::~aiMaterial()
  331. {
  332. // HACK (Aramis): This is safe: aiMaterial has a private constructor,
  333. // so instances must be created indirectly via MaterialHelper. We can't
  334. // use a virtual d'tor because we need to preserve binary compatibility
  335. // with good old C ...
  336. ((MaterialHelper*)this)->_InternDestruct();
  337. }
  338. // ------------------------------------------------------------------------------------------------
  339. // Manual destructor
  340. void MaterialHelper::_InternDestruct()
  341. {
  342. // First clean up all properties
  343. Clear();
  344. // Then delete the array that stored them
  345. delete[] mProperties;
  346. AI_DEBUG_INVALIDATE_PTR(mProperties);
  347. // Update members
  348. mNumAllocated = 0;
  349. }
  350. // ------------------------------------------------------------------------------------------------
  351. void MaterialHelper::Clear()
  352. {
  353. for (unsigned int i = 0; i < mNumProperties;++i) {
  354. // delete this entry
  355. delete mProperties[i];
  356. AI_DEBUG_INVALIDATE_PTR(mProperties[i]);
  357. }
  358. mNumProperties = 0;
  359. // The array remains allocated, we just invalidated its contents
  360. }
  361. // ------------------------------------------------------------------------------------------------
  362. uint32_t MaterialHelper::ComputeHash(bool includeMatName /*= false*/)
  363. {
  364. uint32_t hash = 1503; // magic start value, choosen to be my birthday :-)
  365. for (unsigned int i = 0; i < mNumProperties;++i) {
  366. aiMaterialProperty* prop;
  367. // Exclude all properties whose first character is '?' from the hash
  368. // See doc for aiMaterialProperty.
  369. if ((prop = mProperties[i]) && (includeMatName || prop->mKey.data[0] != '?')) {
  370. hash = SuperFastHash(prop->mKey.data,(unsigned int)prop->mKey.length,hash);
  371. hash = SuperFastHash(prop->mData,prop->mDataLength,hash);
  372. // Combine the semantic and the index with the hash
  373. hash = SuperFastHash((const char*)&prop->mSemantic,sizeof(unsigned int),hash);
  374. hash = SuperFastHash((const char*)&prop->mIndex,sizeof(unsigned int),hash);
  375. }
  376. }
  377. return hash;
  378. }
  379. // ------------------------------------------------------------------------------------------------
  380. aiReturn MaterialHelper::RemoveProperty (const char* pKey,unsigned int type,
  381. unsigned int index
  382. )
  383. {
  384. ai_assert(NULL != pKey);
  385. for (unsigned int i = 0; i < mNumProperties;++i) {
  386. aiMaterialProperty* prop = mProperties[i];
  387. if (prop && !strcmp( prop->mKey.data, pKey ) &&
  388. prop->mSemantic == type && prop->mIndex == index)
  389. {
  390. // Delete this entry
  391. delete mProperties[i];
  392. // collapse the array behind --.
  393. --mNumProperties;
  394. for (unsigned int a = i; a < mNumProperties;++a) {
  395. mProperties[a] = mProperties[a+1];
  396. }
  397. return AI_SUCCESS;
  398. }
  399. }
  400. return AI_FAILURE;
  401. }
  402. // ------------------------------------------------------------------------------------------------
  403. aiReturn MaterialHelper::AddBinaryProperty (const void* pInput,
  404. unsigned int pSizeInBytes,
  405. const char* pKey,
  406. unsigned int type,
  407. unsigned int index,
  408. aiPropertyTypeInfo pType
  409. )
  410. {
  411. ai_assert (pInput != NULL);
  412. ai_assert (pKey != NULL);
  413. ai_assert (0 != pSizeInBytes);
  414. // first search the list whether there is already an entry with this key
  415. unsigned int iOutIndex = UINT_MAX;
  416. for (unsigned int i = 0; i < mNumProperties;++i) {
  417. aiMaterialProperty* prop = mProperties[i];
  418. if (prop /* just for safety */ && !strcmp( prop->mKey.data, pKey ) &&
  419. prop->mSemantic == type && prop->mIndex == index){
  420. delete mProperties[i];
  421. iOutIndex = i;
  422. }
  423. }
  424. // Allocate a new material property
  425. aiMaterialProperty* pcNew = new aiMaterialProperty();
  426. // .. and fill it
  427. pcNew->mType = pType;
  428. pcNew->mSemantic = type;
  429. pcNew->mIndex = index;
  430. pcNew->mDataLength = pSizeInBytes;
  431. pcNew->mData = new char[pSizeInBytes];
  432. memcpy (pcNew->mData,pInput,pSizeInBytes);
  433. pcNew->mKey.length = ::strlen(pKey);
  434. ai_assert ( MAXLEN > pcNew->mKey.length);
  435. strcpy( pcNew->mKey.data, pKey );
  436. if (UINT_MAX != iOutIndex) {
  437. mProperties[iOutIndex] = pcNew;
  438. return AI_SUCCESS;
  439. }
  440. // resize the array ... double the storage allocated
  441. if (mNumProperties == mNumAllocated) {
  442. const unsigned int iOld = mNumAllocated;
  443. mNumAllocated *= 2;
  444. aiMaterialProperty** ppTemp;
  445. try {
  446. ppTemp = new aiMaterialProperty*[mNumAllocated];
  447. } catch (std::bad_alloc&) {
  448. return AI_OUTOFMEMORY;
  449. }
  450. // just copy all items over; then replace the old array
  451. memcpy (ppTemp,mProperties,iOld * sizeof(void*));
  452. delete[] mProperties;
  453. mProperties = ppTemp;
  454. }
  455. // push back ...
  456. mProperties[mNumProperties++] = pcNew;
  457. return AI_SUCCESS;
  458. }
  459. // ------------------------------------------------------------------------------------------------
  460. aiReturn MaterialHelper::AddProperty (const aiString* pInput,
  461. const char* pKey,
  462. unsigned int type,
  463. unsigned int index)
  464. {
  465. // We don't want to add the whole buffer .. write a 32 bit length
  466. // prefix followed by the zero-terminated UTF8 string.
  467. // (HACK) I don't want to break the ABI now, but we definitely
  468. // ought to change aiString::mLength to uint32_t one day.
  469. if (sizeof(size_t) == 8) {
  470. aiString copy = *pInput;
  471. uint32_t* s = reinterpret_cast<uint32_t*>(&copy.length);
  472. s[1] = static_cast<uint32_t>(pInput->length);
  473. return AddBinaryProperty(s+1,
  474. pInput->length+1+4,
  475. pKey,
  476. type,
  477. index,
  478. aiPTI_String);
  479. }
  480. ai_assert(sizeof(size_t)==4);
  481. return AddBinaryProperty(pInput,
  482. pInput->length+1+4,
  483. pKey,
  484. type,
  485. index,
  486. aiPTI_String);
  487. }
  488. // ------------------------------------------------------------------------------------------------
  489. void MaterialHelper::CopyPropertyList(MaterialHelper* pcDest,
  490. const MaterialHelper* pcSrc
  491. )
  492. {
  493. ai_assert(NULL != pcDest);
  494. ai_assert(NULL != pcSrc);
  495. unsigned int iOldNum = pcDest->mNumProperties;
  496. pcDest->mNumAllocated += pcSrc->mNumAllocated;
  497. pcDest->mNumProperties += pcSrc->mNumProperties;
  498. aiMaterialProperty** pcOld = pcDest->mProperties;
  499. pcDest->mProperties = new aiMaterialProperty*[pcDest->mNumAllocated];
  500. if (iOldNum && pcOld) {
  501. for (unsigned int i = 0; i < iOldNum;++i) {
  502. pcDest->mProperties[i] = pcOld[i];
  503. }
  504. delete[] pcOld;
  505. }
  506. for (unsigned int i = iOldNum; i< pcDest->mNumProperties;++i) {
  507. aiMaterialProperty* propSrc = pcSrc->mProperties[i];
  508. // search whether we have already a property with this name -> if yes, overwrite it
  509. aiMaterialProperty* prop;
  510. for (unsigned int q = 0; q < iOldNum;++q) {
  511. prop = pcDest->mProperties[q];
  512. if (prop /* just for safety */ && prop->mKey == propSrc->mKey && prop->mSemantic == propSrc->mSemantic
  513. && prop->mIndex == propSrc->mIndex) {
  514. delete prop;
  515. // collapse the whole array ...
  516. memmove(&pcDest->mProperties[q],&pcDest->mProperties[q+1],i-q);
  517. i--;
  518. pcDest->mNumProperties--;
  519. }
  520. }
  521. // Allocate the output property and copy the source property
  522. prop = pcDest->mProperties[i] = new aiMaterialProperty();
  523. prop->mKey = propSrc->mKey;
  524. prop->mDataLength = propSrc->mDataLength;
  525. prop->mType = propSrc->mType;
  526. prop->mSemantic = propSrc->mSemantic;
  527. prop->mIndex = propSrc->mIndex;
  528. prop->mData = new char[propSrc->mDataLength];
  529. memcpy(prop->mData,propSrc->mData,prop->mDataLength);
  530. }
  531. return;
  532. }