diff options
Diffstat (limited to 'indra/llinventory')
| -rw-r--r-- | indra/llinventory/llinventory.cpp | 41 | ||||
| -rw-r--r-- | indra/llinventory/llinventory.h | 2 | ||||
| -rw-r--r-- | indra/llinventory/tests/inventorymisc_test.cpp | 5 | 
3 files changed, 45 insertions, 3 deletions
| diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index fcc2e1d173..18bc1b5a91 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -41,7 +41,7 @@  /// Exported functions  ///----------------------------------------------------------------------------  static const std::string INV_ITEM_ID_LABEL("item_id"); -static const std::string INV_FOLDER_ID_LABEL("folder_id"); +static const std::string INV_FOLDER_ID_LABEL("cat_id");  static const std::string INV_PARENT_ID_LABEL("parent_id");  static const std::string INV_ASSET_TYPE_LABEL("type");  static const std::string INV_PREFERRED_TYPE_LABEL("preferred_type"); @@ -1317,6 +1317,45 @@ BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL)  	return TRUE;  } +LLSD LLInventoryCategory::exportLLSD() const +{ +	LLSD cat_data; +	cat_data[INV_FOLDER_ID_LABEL] = mUUID; +	cat_data[INV_PARENT_ID_LABEL] = mParentUUID; +	cat_data[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(mType); +	cat_data[INV_PREFERRED_TYPE_LABEL] = LLFolderType::lookup(mPreferredType); +	cat_data[INV_NAME_LABEL] = mName; + +	return cat_data; +} + +bool LLInventoryCategory::importLLSD(const LLSD& cat_data) +{ +	if (cat_data.has(INV_FOLDER_ID_LABEL)) +	{ +		setUUID(cat_data[INV_FOLDER_ID_LABEL].asUUID()); +	} +	if (cat_data.has(INV_PARENT_ID_LABEL)) +	{ +		setParent(cat_data[INV_PARENT_ID_LABEL].asUUID()); +	} +	if (cat_data.has(INV_ASSET_TYPE_LABEL)) +	{ +		setType(LLAssetType::lookup(cat_data[INV_ASSET_TYPE_LABEL].asString())); +	} +	if (cat_data.has(INV_PREFERRED_TYPE_LABEL)) +	{ +		setPreferredType(LLFolderType::lookup(cat_data[INV_PREFERRED_TYPE_LABEL].asString())); +	} +	if (cat_data.has(INV_NAME_LABEL)) +	{ +		mName = cat_data[INV_NAME_LABEL].asString(); +		LLStringUtil::replaceNonstandardASCII(mName, ' '); +		LLStringUtil::replaceChar(mName, '|', ' '); +	} + +	return true; +}  ///----------------------------------------------------------------------------  /// Local function definitions  ///---------------------------------------------------------------------------- diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h index d00c4d43ee..024afc109c 100644 --- a/indra/llinventory/llinventory.h +++ b/indra/llinventory/llinventory.h @@ -269,6 +269,8 @@ public:  	virtual BOOL importLegacyStream(std::istream& input_stream);  	virtual BOOL exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key = TRUE) const; +	LLSD exportLLSD() const; +	bool importLLSD(const LLSD& cat_data);  	//--------------------------------------------------------------------  	// Member Variables  	//-------------------------------------------------------------------- diff --git a/indra/llinventory/tests/inventorymisc_test.cpp b/indra/llinventory/tests/inventorymisc_test.cpp index 6eb3f04827..e8b063bffe 100644 --- a/indra/llinventory/tests/inventorymisc_test.cpp +++ b/indra/llinventory/tests/inventorymisc_test.cpp @@ -478,7 +478,7 @@ namespace tut  		}  		LLPointer<LLInventoryCategory> src1 = create_random_inventory_cat(); -		fileXML << LLSDOStreamer<LLSDNotationFormatter>(ll_create_sd_from_inventory_category(src1)) << std::endl; +		fileXML << LLSDOStreamer<LLSDNotationFormatter>(src1->exportLLSD()) << std::endl;  		fileXML.close();  		llifstream file(filename.c_str()); @@ -500,7 +500,8 @@ namespace tut  		file.close(); -		LLPointer<LLInventoryCategory> src2 = ll_create_category_from_sd(s_item); +		LLPointer<LLInventoryCategory> src2 = new LLInventoryCategory(); +		src2->importLLSD(s_item);  		ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());  		ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID()); | 
