diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-06-26 00:39:00 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-06-26 00:39:00 +0000 |
commit | 25c10ed028da5c547b11f1f461916897272b0e6d (patch) | |
tree | 350a5858f8970b6e28b2dc395625d74d8bd597b2 /indra/llinventory | |
parent | 6dd125d375b38455997a0c4b8747659f4c2351aa (diff) |
QAR-628 merge string-cleanup-5 -r 90476:90508 -> release
dataserver-is-deprecated
Diffstat (limited to 'indra/llinventory')
-rw-r--r-- | indra/llinventory/llinventory.cpp | 194 | ||||
-rw-r--r-- | indra/llinventory/llinventory.h | 20 | ||||
-rw-r--r-- | indra/llinventory/llinventorytype.cpp | 4 | ||||
-rw-r--r-- | indra/llinventory/llinventorytype.h | 2 | ||||
-rw-r--r-- | indra/llinventory/llnotecard.cpp | 14 | ||||
-rw-r--r-- | indra/llinventory/llnotecard.h | 9 | ||||
-rw-r--r-- | indra/llinventory/llparcel.cpp | 274 | ||||
-rw-r--r-- | indra/llinventory/llparcel.h | 50 | ||||
-rw-r--r-- | indra/llinventory/llpermissions.cpp | 34 | ||||
-rw-r--r-- | indra/llinventory/llsaleinfo.cpp | 2 | ||||
-rw-r--r-- | indra/llinventory/lltransactionflags.cpp | 35 | ||||
-rw-r--r-- | indra/llinventory/lltransactionflags.h | 4 |
12 files changed, 312 insertions, 330 deletions
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index 7dbc72e7a5..0cdc445069 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -78,16 +78,16 @@ LLInventoryObject::LLInventoryObject( const LLUUID& uuid, const LLUUID& parent_uuid, LLAssetType::EType type, - const LLString& name) : + const std::string& name) : mUUID(uuid), mParentUUID(parent_uuid), mType(type), mName(name) { - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); - LLString::trim(mName); - LLString::truncate(mName, DB_INV_ITEM_NAME_STR_LEN); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); + LLStringUtil::trim(mName); + LLStringUtil::truncate(mName, DB_INV_ITEM_NAME_STR_LEN); } LLInventoryObject::LLInventoryObject() : @@ -117,7 +117,7 @@ const LLUUID& LLInventoryObject::getParentUUID() const return mParentUUID; } -const LLString& LLInventoryObject::getName() const +const std::string& LLInventoryObject::getName() const { return mName; } @@ -132,13 +132,13 @@ void LLInventoryObject::setUUID(const LLUUID& new_uuid) mUUID = new_uuid; } -void LLInventoryObject::rename(const LLString& n) +void LLInventoryObject::rename(const std::string& n) { - LLString new_name(n); - LLString::replaceNonstandardASCII(new_name, ' '); - LLString::replaceChar(new_name, '|', ' '); - LLString::trim(new_name); - LLString::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN); + std::string new_name(n); + LLStringUtil::replaceNonstandardASCII(new_name, ' '); + LLStringUtil::replaceChar(new_name, '|', ' '); + LLStringUtil::trim(new_name); + LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN); if( new_name != mName ) { @@ -201,10 +201,10 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream) " %254s %254[^|]", keyword, valuestr); mName.assign(valuestr); - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); - LLString::trim(mName); - LLString::truncate(mName, DB_INV_ITEM_NAME_STR_LEN); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); + LLStringUtil::trim(mName); + LLStringUtil::truncate(mName, DB_INV_ITEM_NAME_STR_LEN); } else { @@ -219,12 +219,12 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream) // not sure whether exportLegacyStream(llofstream(fp)) would work, fp may need to get icramented... BOOL LLInventoryObject::exportFile(LLFILE* fp, BOOL) const { - char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string uuid_str; fprintf(fp, "\tinv_object\t0\n\t{\n"); mUUID.toString(uuid_str); - fprintf(fp, "\t\tobj_id\t%s\n", uuid_str); + fprintf(fp, "\t\tobj_id\t%s\n", uuid_str.c_str()); mParentUUID.toString(uuid_str); - fprintf(fp, "\t\tparent_id\t%s\n", uuid_str); + fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str()); fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType)); fprintf(fp, "\t\tname\t%s|\n", mName.c_str()); fprintf(fp,"\t}\n"); @@ -233,7 +233,7 @@ BOOL LLInventoryObject::exportFile(LLFILE* fp, BOOL) const BOOL LLInventoryObject::exportLegacyStream(std::ostream& output_stream, BOOL) const { - char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string uuid_str; output_stream << "\tinv_object\t0\n\t{\n"; mUUID.toString(uuid_str); output_stream << "\t\tobj_id\t" << uuid_str << "\n"; @@ -276,8 +276,8 @@ LLInventoryItem::LLInventoryItem( const LLUUID& asset_uuid, LLAssetType::EType type, LLInventoryType::EType inv_type, - const LLString& name, - const LLString& desc, + const std::string& name, + const std::string& desc, const LLSaleInfo& sale_info, U32 flags, S32 creation_date_utc) : @@ -290,8 +290,8 @@ LLInventoryItem::LLInventoryItem( mFlags(flags), mCreationDate(creation_date_utc) { - LLString::replaceNonstandardASCII(mDescription, ' '); - LLString::replaceChar(mDescription, '|', ' '); + LLStringUtil::replaceNonstandardASCII(mDescription, ' '); + LLStringUtil::replaceChar(mDescription, '|', ' '); } LLInventoryItem::LLInventoryItem() : @@ -359,7 +359,7 @@ void LLInventoryItem::setAssetUUID(const LLUUID& asset_id) } -const LLString& LLInventoryItem::getDescription() const +const std::string& LLInventoryItem::getDescription() const { return mDescription; } @@ -396,11 +396,11 @@ U32 LLInventoryItem::getCRC32() const } -void LLInventoryItem::setDescription(const LLString& d) +void LLInventoryItem::setDescription(const std::string& d) { - LLString new_desc(d); - LLString::replaceNonstandardASCII(new_desc, ' '); - LLString::replaceChar(new_desc, '|', ' '); + std::string new_desc(d); + LLStringUtil::replaceNonstandardASCII(new_desc, ' '); + LLStringUtil::replaceChar(new_desc, '|', ' '); if( new_desc != mDescription ) { mDescription = new_desc; @@ -486,15 +486,11 @@ BOOL LLInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32 mSaleInfo.unpackMultiMessage(msg, block, block_num); - char name[DB_INV_ITEM_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(block, _PREHASH_Name, DB_INV_ITEM_NAME_BUF_SIZE, name, block_num); - mName.assign(name); - LLString::replaceNonstandardASCII(mName, ' '); + msg->getStringFast(block, _PREHASH_Name, mName, block_num); + LLStringUtil::replaceNonstandardASCII(mName, ' '); - char desc[DB_INV_ITEM_DESC_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(block, _PREHASH_Description, DB_INV_ITEM_DESC_BUF_SIZE, desc, block_num); - mDescription.assign(desc); - LLString::replaceNonstandardASCII(mDescription, ' '); + msg->getStringFast(block, _PREHASH_Description, mDescription, block_num); + LLStringUtil::replaceNonstandardASCII(mDescription, ' '); S32 date; msg->getS32(block, "CreationDate", date, block_num); @@ -604,7 +600,7 @@ BOOL LLInventoryItem::importFile(LLFILE* fp) } else if(0 == strcmp("inv_type", keyword)) { - mInventoryType = LLInventoryType::lookup(valuestr); + mInventoryType = LLInventoryType::lookup(std::string(valuestr)); } else if(0 == strcmp("flags", keyword)) { @@ -626,8 +622,8 @@ BOOL LLInventoryItem::importFile(LLFILE* fp) } mName.assign(valuestr); - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); } else if(0 == strcmp("desc", keyword)) { @@ -644,7 +640,7 @@ BOOL LLInventoryItem::importFile(LLFILE* fp) } mDescription.assign(valuestr); - LLString::replaceNonstandardASCII(mDescription, ' '); + LLStringUtil::replaceNonstandardASCII(mDescription, ' '); /* TODO -- ask Ian about this code const char *donkey = mDescription.c_str(); if (donkey[0] == '|') @@ -680,12 +676,12 @@ BOOL LLInventoryItem::importFile(LLFILE* fp) BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const { - char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string uuid_str; fprintf(fp, "\tinv_item\t0\n\t{\n"); mUUID.toString(uuid_str); - fprintf(fp, "\t\titem_id\t%s\n", uuid_str); + fprintf(fp, "\t\titem_id\t%s\n", uuid_str.c_str()); mParentUUID.toString(uuid_str); - fprintf(fp, "\t\tparent_id\t%s\n", uuid_str); + fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str()); mPermissions.exportFile(fp); // Check for permissions to see the asset id, and if so write it @@ -697,7 +693,7 @@ BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const || (mAssetUUID.isNull())) { mAssetUUID.toString(uuid_str); - fprintf(fp, "\t\tasset_id\t%s\n", uuid_str); + fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str()); } else { @@ -705,13 +701,13 @@ BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES); cipher.encrypt(shadow_id.mData, UUID_BYTES); shadow_id.toString(uuid_str); - fprintf(fp, "\t\tshadow_id\t%s\n", uuid_str); + fprintf(fp, "\t\tshadow_id\t%s\n", uuid_str.c_str()); } } else { LLUUID::null.toString(uuid_str); - fprintf(fp, "\t\tasset_id\t%s\n", uuid_str); + fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str()); } fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType)); const char* inv_type_str = LLInventoryType::lookup(mInventoryType); @@ -807,7 +803,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) } else if(0 == strcmp("inv_type", keyword)) { - mInventoryType = LLInventoryType::lookup(valuestr); + mInventoryType = LLInventoryType::lookup(std::string(valuestr)); } else if(0 == strcmp("flags", keyword)) { @@ -829,8 +825,8 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) } mName.assign(valuestr); - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); } else if(0 == strcmp("desc", keyword)) { @@ -847,7 +843,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) } mDescription.assign(valuestr); - LLString::replaceNonstandardASCII(mDescription, ' '); + LLStringUtil::replaceNonstandardASCII(mDescription, ' '); /* TODO -- ask Ian about this code const char *donkey = mDescription.c_str(); if (donkey[0] == '|') @@ -883,7 +879,7 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key) const { - char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string uuid_str; output_stream << "\tinv_item\t0\n\t{\n"; mUUID.toString(uuid_str); output_stream << "\t\titem_id\t" << uuid_str << "\n"; @@ -920,8 +916,8 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu const char* inv_type_str = LLInventoryType::lookup(mInventoryType); if(inv_type_str) output_stream << "\t\tinv_type\t" << inv_type_str << "\n"; - char buffer[32]; /* Flawfinder: ignore */ - snprintf(buffer, sizeof(buffer), "\t\tflags\t%08x\n", mFlags); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat( "\t\tflags\t%08x\n", mFlags); output_stream << buffer; mSaleInfo.exportLegacyStream(output_stream); output_stream << "\t\tname\t" << mName.c_str() << "|\n"; @@ -1030,12 +1026,12 @@ bool LLInventoryItem::fromLLSD(LLSD& sd) w = INV_ASSET_TYPE_LABEL; if (sd.has(w)) { - mType = LLAssetType::lookup(sd[w].asString().c_str()); + mType = LLAssetType::lookup(sd[w].asString()); } w = INV_INVENTORY_TYPE_LABEL; if (sd.has(w)) { - mInventoryType = LLInventoryType::lookup(sd[w].asString().c_str()); + mInventoryType = LLInventoryType::lookup(sd[w].asString()); } w = INV_FLAGS_LABEL; if (sd.has(w)) @@ -1046,14 +1042,14 @@ bool LLInventoryItem::fromLLSD(LLSD& sd) if (sd.has(w)) { mName = sd[w].asString(); - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); } w = INV_DESC_LABEL; if (sd.has(w)) { mDescription = sd[w].asString(); - LLString::replaceNonstandardASCII(mDescription, ' '); + LLStringUtil::replaceNonstandardASCII(mDescription, ' '); } w = INV_CREATION_DATE_LABEL; if (sd.has(w)) @@ -1107,21 +1103,21 @@ LLXMLNode *LLInventoryItem::exportFileXML(BOOL include_asset_key) const } } - LLString type_str = LLAssetType::lookup(mType); - LLString inv_type_str = LLInventoryType::lookup(mInventoryType); + std::string type_str = LLAssetType::lookup(mType); + std::string inv_type_str = LLInventoryType::lookup(mInventoryType); - ret->createChild("asset_type", FALSE)->setStringValue(1, &type_str); - ret->createChild("inventory_type", FALSE)->setStringValue(1, &inv_type_str); + ret->createChild("asset_type", FALSE)->setStringValue(type_str); + ret->createChild("inventory_type", FALSE)->setStringValue(inv_type_str); S32 tmp_flags = (S32) mFlags; ret->createChild("flags", FALSE)->setByteValue(4, (U8*)(&tmp_flags), LLXMLNode::ENCODING_HEX); mSaleInfo.exportFileXML()->setParent(ret); - LLString temp; + std::string temp; temp.assign(mName); - ret->createChild("name", FALSE)->setStringValue(1, &temp); + ret->createChild("name", FALSE)->setStringValue(temp); temp.assign(mDescription); - ret->createChild("description", FALSE)->setStringValue(1, &temp); + ret->createChild("description", FALSE)->setStringValue(temp); S32 date = mCreationDate; ret->createChild("creation_date", FALSE)->setIntValue(1, &date); @@ -1150,9 +1146,9 @@ BOOL LLInventoryItem::importXML(LLXMLNode* node) cipher.decrypt(mAssetUUID.mData, UUID_BYTES); } if (node->getChild("asset_type", sub_node)) - mType = LLAssetType::lookup(sub_node->getValue().c_str()); + mType = LLAssetType::lookup(sub_node->getValue()); if (node->getChild("inventory_type", sub_node)) - mInventoryType = LLInventoryType::lookup(sub_node->getValue().c_str()); + mInventoryType = LLInventoryType::lookup(sub_node->getValue()); if (node->getChild("flags", sub_node)) { S32 tmp_flags = 0; @@ -1198,32 +1194,32 @@ S32 LLInventoryItem::packBinaryBucket(U8* bin_bucket, LLPermissions* perm_overri // describe the inventory item char* buffer = (char*) bin_bucket; - char creator_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string creator_id_str; perm.getCreator().toString(creator_id_str); - char owner_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string owner_id_str; perm.getOwner().toString(owner_id_str); - char last_owner_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string last_owner_id_str; perm.getLastOwner().toString(last_owner_id_str); - char group_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string group_id_str; perm.getGroup().toString(group_id_str); - char asset_id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string asset_id_str; getAssetUUID().toString(asset_id_str); S32 size = sprintf(buffer, /* Flawfinder: ignore */ "%d|%d|%s|%s|%s|%s|%s|%x|%x|%x|%x|%x|%s|%s|%d|%d|%x", getType(), getInventoryType(), getName().c_str(), - creator_id_str, - owner_id_str, - last_owner_id_str, - group_id_str, + creator_id_str.c_str(), + owner_id_str.c_str(), + last_owner_id_str.c_str(), + group_id_str.c_str(), perm.getMaskBase(), perm.getMaskOwner(), perm.getMaskGroup(), perm.getMaskEveryone(), perm.getMaskNextOwner(), - asset_id_str, + asset_id_str.c_str(), getDescription().c_str(), getSaleInfo().getSaleType(), getSaleInfo().getSalePrice(), @@ -1274,7 +1270,7 @@ void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size) inv_type = (LLInventoryType::EType)(atoi((*(iter++)).c_str())); setInventoryType( inv_type ); - LLString name((*(iter++)).c_str()); + std::string name((*(iter++)).c_str()); rename( name ); LLUUID creator_id((*(iter++)).c_str()); @@ -1295,7 +1291,7 @@ void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size) LLUUID asset_id((*(iter++)).c_str()); setAssetUUID(asset_id); - LLString desc((*(iter++)).c_str()); + std::string desc((*(iter++)).c_str()); setDescription(desc); LLSaleInfo::EForSale sale_type; @@ -1314,7 +1310,7 @@ void LLInventoryItem::unpackBinaryBucket(U8* bin_bucket, S32 bin_bucket_size) // returns TRUE if a should appear before b BOOL item_dictionary_sort( LLInventoryItem* a, LLInventoryItem* b ) { - return (LLString::compareDict( a->getName().c_str(), b->getName().c_str() ) < 0); + return (LLStringUtil::compareDict( a->getName().c_str(), b->getName().c_str() ) < 0); } // returns TRUE if a should appear before b @@ -1332,7 +1328,7 @@ LLInventoryCategory::LLInventoryCategory( const LLUUID& uuid, const LLUUID& parent_uuid, LLAssetType::EType preferred_type, - const LLString& name) : + const std::string& name) : LLInventoryObject(uuid, parent_uuid, LLAssetType::AT_CATEGORY, name), mPreferredType(preferred_type) { @@ -1418,8 +1414,8 @@ bool LLInventoryCategory::fromLLSD(LLSD& sd) if (sd.has(w)) { mName = sd[w].asString(); - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); } return true; } @@ -1434,10 +1430,8 @@ void LLInventoryCategory::unpackMessage(LLMessageSystem* msg, S8 type; msg->getS8Fast(block, _PREHASH_Type, type, block_num); mPreferredType = static_cast<LLAssetType::EType>(type); - char name[DB_INV_ITEM_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(block, _PREHASH_Name, DB_INV_ITEM_NAME_BUF_SIZE, name, block_num); - mName.assign(name); - LLString::replaceNonstandardASCII(mName, ' '); + msg->getStringFast(block, _PREHASH_Name, mName, block_num); + LLStringUtil::replaceNonstandardASCII(mName, ' '); } // virtual @@ -1495,8 +1489,8 @@ BOOL LLInventoryCategory::importFile(LLFILE* fp) " %254s %254[^|]", keyword, valuestr); mName.assign(valuestr); - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); } else { @@ -1509,12 +1503,12 @@ BOOL LLInventoryCategory::importFile(LLFILE* fp) BOOL LLInventoryCategory::exportFile(LLFILE* fp, BOOL) const { - char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string uuid_str; fprintf(fp, "\tinv_category\t0\n\t{\n"); mUUID.toString(uuid_str); - fprintf(fp, "\t\tcat_id\t%s\n", uuid_str); + fprintf(fp, "\t\tcat_id\t%s\n", uuid_str.c_str()); mParentUUID.toString(uuid_str); - fprintf(fp, "\t\tparent_id\t%s\n", uuid_str); + fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str()); fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType)); fprintf(fp, "\t\tpref_type\t%s\n", LLAssetType::lookup(mPreferredType)); fprintf(fp, "\t\tname\t%s|\n", mName.c_str()); @@ -1574,8 +1568,8 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream) " %254s %254[^|]", keyword, valuestr); mName.assign(valuestr); - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); } else { @@ -1588,7 +1582,7 @@ BOOL LLInventoryCategory::importLegacyStream(std::istream& input_stream) BOOL LLInventoryCategory::exportLegacyStream(std::ostream& output_stream, BOOL) const { - char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string uuid_str; output_stream << "\tinv_category\t0\n\t{\n"; mUUID.toString(uuid_str); output_stream << "\t\tcat_id\t" << uuid_str << "\n"; @@ -1638,7 +1632,7 @@ LLPointer<LLInventoryItem> ll_create_item_from_sd(const LLSD& sd_item) rv->setParent(sd_item[INV_PARENT_ID_LABEL].asUUID()); rv->rename(sd_item[INV_NAME_LABEL].asString()); rv->setType( - LLAssetType::lookup(sd_item[INV_ASSET_TYPE_LABEL].asString().c_str())); + LLAssetType::lookup(sd_item[INV_ASSET_TYPE_LABEL].asString())); if (sd_item.has("shadow_id")) { LLUUID asset_id = sd_item["shadow_id"]; @@ -1655,7 +1649,7 @@ LLPointer<LLInventoryItem> ll_create_item_from_sd(const LLSD& sd_item) rv->setPermissions(ll_permissions_from_sd(sd_item[INV_PERMISSIONS_LABEL])); rv->setInventoryType( LLInventoryType::lookup( - sd_item[INV_INVENTORY_TYPE_LABEL].asString().c_str())); + sd_item[INV_INVENTORY_TYPE_LABEL].asString())); rv->setFlags((U32)(sd_item[INV_FLAGS_LABEL].asInteger())); rv->setCreationDate(sd_item[INV_CREATION_DATE_LABEL].asInteger()); return rv; @@ -1690,9 +1684,9 @@ LLPointer<LLInventoryCategory> ll_create_category_from_sd(const LLSD& sd_cat) rv->setParent(sd_cat[INV_PARENT_ID_LABEL].asUUID()); rv->rename(sd_cat[INV_NAME_LABEL].asString()); rv->setType( - LLAssetType::lookup(sd_cat[INV_ASSET_TYPE_LABEL].asString().c_str())); + LLAssetType::lookup(sd_cat[INV_ASSET_TYPE_LABEL].asString())); rv->setPreferredType( LLAssetType::lookup( - sd_cat[INV_PREFERRED_TYPE_LABEL].asString().c_str())); + sd_cat[INV_PREFERRED_TYPE_LABEL].asString())); return rv; } diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h index 6655d6f215..af4b85e9a1 100644 --- a/indra/llinventory/llinventory.h +++ b/indra/llinventory/llinventory.h @@ -75,7 +75,7 @@ protected: LLUUID mUUID; LLUUID mParentUUID; LLAssetType::EType mType; - LLString mName; + std::string mName; protected: virtual ~LLInventoryObject( void ); @@ -83,19 +83,19 @@ protected: public: MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY); LLInventoryObject(const LLUUID& uuid, const LLUUID& parent_uuid, - LLAssetType::EType type, const LLString& name); + LLAssetType::EType type, const std::string& name); LLInventoryObject(); void copyObject(const LLInventoryObject* other); // LLRefCount requires custom copy // accessors const LLUUID& getUUID() const; const LLUUID& getParentUUID() const; - const LLString& getName() const; + const std::string& getName() const; LLAssetType::EType getType() const; // mutators - will not call updateServer(); void setUUID(const LLUUID& new_uuid); - void rename(const LLString& new_name); + void rename(const std::string& new_name); void setParent(const LLUUID& new_parent); void setType(LLAssetType::EType type); @@ -128,7 +128,7 @@ public: protected: LLPermissions mPermissions; LLUUID mAssetUUID; - LLString mDescription; + std::string mDescription; LLSaleInfo mSaleInfo; LLInventoryType::EType mInventoryType; U32 mFlags; @@ -212,8 +212,8 @@ public: const LLUUID& asset_uuid, LLAssetType::EType type, LLInventoryType::EType inv_type, - const LLString& name, - const LLString& desc, + const std::string& name, + const std::string& desc, const LLSaleInfo& sale_info, U32 flags, S32 creation_date_utc); @@ -233,7 +233,7 @@ public: const LLPermissions& getPermissions() const; const LLUUID& getCreatorUUID() const; const LLUUID& getAssetUUID() const; - const LLString& getDescription() const; + const std::string& getDescription() const; const LLSaleInfo& getSaleInfo() const; LLInventoryType::EType getInventoryType() const; U32 getFlags() const; @@ -243,7 +243,7 @@ public: // mutators - will not call updateServer(), and will never fail // (though it may correct to sane values) void setAssetUUID(const LLUUID& asset_id); - void setDescription(const LLString& new_desc); + void setDescription(const std::string& new_desc); void setSaleInfo(const LLSaleInfo& sale_info); void setPermissions(const LLPermissions& perm); void setInventoryType(LLInventoryType::EType inv_type); @@ -303,7 +303,7 @@ public: MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY); LLInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid, LLAssetType::EType preferred_type, - const LLString& name); + const std::string& name); LLInventoryCategory(); LLInventoryCategory(const LLInventoryCategory* other); void copyCategory(const LLInventoryCategory* other); // LLRefCount requires custom copy diff --git a/indra/llinventory/llinventorytype.cpp b/indra/llinventory/llinventorytype.cpp index ac16cea499..1ffda0b059 100644 --- a/indra/llinventory/llinventorytype.cpp +++ b/indra/llinventory/llinventorytype.cpp @@ -162,12 +162,12 @@ const char* LLInventoryType::lookup(EType type) } // static -LLInventoryType::EType LLInventoryType::lookup(const char* name) +LLInventoryType::EType LLInventoryType::lookup(const std::string& name) { for(S32 i = 0; i < IT_COUNT; ++i) { if((INVENTORY_TYPE_NAMES[i]) - && (0 == strcmp(name, INVENTORY_TYPE_NAMES[i]))) + && (name == INVENTORY_TYPE_NAMES[i])) { // match return (EType)i; diff --git a/indra/llinventory/llinventorytype.h b/indra/llinventory/llinventorytype.h index dcc25028ae..15dfa08203 100644 --- a/indra/llinventory/llinventorytype.h +++ b/indra/llinventory/llinventorytype.h @@ -72,7 +72,7 @@ public: }; // machine transation between type and strings - static EType lookup(const char* name); + static EType lookup(const std::string& name); static const char* lookup(EType type); // translation from a type to a human readable form. diff --git a/indra/llinventory/llnotecard.cpp b/indra/llinventory/llnotecard.cpp index 733a5673c5..60eba2decd 100644 --- a/indra/llinventory/llnotecard.cpp +++ b/indra/llinventory/llnotecard.cpp @@ -222,7 +222,7 @@ bool LLNotecard::importStream(std::istream& str) if(success) { // Actually set the text - mText = text; + mText = std::string(text); } delete[] text; @@ -281,22 +281,12 @@ bool LLNotecard::exportStream( std::ostream& out_stream ) //////////////////////////////////////////////////////////////////////////// -const std::vector<LLPointer<LLInventoryItem> >& LLNotecard::getItems() const -{ - return mItems; -} - -LLString& LLNotecard::getText() -{ - return mText; -} - void LLNotecard::setItems(const std::vector<LLPointer<LLInventoryItem> >& items) { mItems = items; } -void LLNotecard::setText(const LLString& text) +void LLNotecard::setText(const std::string& text) { mText = text; } diff --git a/indra/llinventory/llnotecard.h b/indra/llinventory/llnotecard.h index 369bf784a1..9940a4ca69 100644 --- a/indra/llinventory/llnotecard.h +++ b/indra/llinventory/llnotecard.h @@ -52,11 +52,12 @@ public: bool importStream(std::istream& str); bool exportStream(std::ostream& str); - const std::vector<LLPointer<LLInventoryItem> >& getItems() const; - LLString& getText(); + const std::vector<LLPointer<LLInventoryItem> >& getItems() const { return mItems; } + const std::string& getText() const { return mText; } + std::string& getText() { return mText; } void setItems(const std::vector<LLPointer<LLInventoryItem> >& items); - void setText(const LLString& text); + void setText(const std::string& text); S32 getVersion() { return mVersion; } S32 getEmbeddedVersion() { return mEmbeddedVersion; } @@ -64,7 +65,7 @@ private: bool importEmbeddedItemsStream(std::istream& str); bool exportEmbeddedItemsStream(std::ostream& str); std::vector<LLPointer<LLInventoryItem> > mItems; - LLString mText; + std::string mText; S32 mMaxText; S32 mVersion; S32 mEmbeddedVersion; diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index 0b11b6009e..ecf013f042 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -48,17 +48,18 @@ static const F32 SOME_BIG_NUMBER = 1000.0f; static const F32 SOME_BIG_NEG_NUMBER = -1000.0f; -static const char* PARCEL_OWNERSHIP_STATUS_STRING[LLParcel::OS_COUNT] = +static const std::string PARCEL_OWNERSHIP_STATUS_STRING[LLParcel::OS_COUNT+1] = { "leased", "lease_pending", - "abandoned" + "abandoned", + "none" }; // NOTE: Adding parcel categories also requires updating: // * newview/app_settings/floater_directory.xml category combobox // * Web site "create event" tools -static const char* PARCEL_CATEGORY_STRING[LLParcel::C_COUNT] = +static const std::string PARCEL_CATEGORY_STRING[LLParcel::C_COUNT] = { "none", "linden", @@ -75,7 +76,7 @@ static const char* PARCEL_CATEGORY_STRING[LLParcel::C_COUNT] = "stage", "other", }; -static const char* PARCEL_CATEGORY_UI_STRING[LLParcel::C_COUNT + 1] = +static const std::string PARCEL_CATEGORY_UI_STRING[LLParcel::C_COUNT + 1] = { "None", "Linden Location", @@ -94,7 +95,7 @@ static const char* PARCEL_CATEGORY_UI_STRING[LLParcel::C_COUNT + 1] = "Any", // valid string for parcel searches }; -static const char* PARCEL_ACTION_STRING[LLParcel::A_COUNT + 1] = +static const std::string PARCEL_ACTION_STRING[LLParcel::A_COUNT + 1] = { "create", "release", @@ -132,14 +133,14 @@ const U64 SEVEN_DAYS_IN_USEC = U64L(604800000000); const S32 EXTEND_GRACE_IF_MORE_THAN_SEC = 100000; -const char* ownership_status_to_string(LLParcel::EOwnershipStatus status); -LLParcel::EOwnershipStatus ownership_string_to_status(const char* s); +const std::string& ownership_status_to_string(LLParcel::EOwnershipStatus status); +LLParcel::EOwnershipStatus ownership_string_to_status(const std::string& s); //const char* revert_action_to_string(LLParcel::ESaleTimerExpireAction action); //LLParcel::ESaleTimerExpireAction revert_string_to_action(const char* s); -const char* category_to_string(LLParcel::ECategory category); -const char* category_to_ui_string(LLParcel::ECategory category); -LLParcel::ECategory category_string_to_category(const char* s); -LLParcel::ECategory category_ui_string_to_category(const char* s); +const std::string& category_to_string(LLParcel::ECategory category); +const std::string& category_to_ui_string(LLParcel::ECategory category); +LLParcel::ECategory category_string_to_category(const std::string& s); +LLParcel::ECategory category_ui_string_to_category(const std::string& s); LLParcel::LLParcel() { @@ -207,12 +208,12 @@ void LLParcel::init(const LLUUID &owner_id, setParcelFlag(PF_ALLOW_DAMAGE, damage); mSalePrice = 10000; - setName(NULL); - setDesc(NULL); - setMusicURL(NULL); - setMediaURL(NULL); - setMediaDesc(NULL); - setMediaType(NULL); + setName(LLStringUtil::null); + setDesc(LLStringUtil::null); + setMusicURL(LLStringUtil::null); + setMediaURL(LLStringUtil::null); + setMediaDesc(LLStringUtil::null); + setMediaType(LLStringUtil::null); mMediaID.setNull(); mMediaAutoScale = 0; mMediaLoop = TRUE; @@ -271,22 +272,7 @@ void LLParcel::overrideParcelFlags(U32 flags) { mParcelFlags = flags; } -void set_std_string(const char* src, std::string& dest) -{ - if(src) - { - dest.assign(src); - } - else - { -#if (LL_LINUX && __GNUC__ < 3) - dest.assign(std::string("")); -#else - dest.clear(); -#endif - } -} -void LLParcel::setName(const LLString& name) +void LLParcel::setName(const std::string& name) { // The escaping here must match the escaping in the database // abstraction layer. @@ -294,7 +280,7 @@ void LLParcel::setName(const LLString& name) LLStringFn::replace_nonprintable(mName, LL_UNKNOWN_CHAR); } -void LLParcel::setDesc(const LLString& desc) +void LLParcel::setDesc(const std::string& desc) { // The escaping here must match the escaping in the database // abstraction layer. @@ -302,7 +288,7 @@ void LLParcel::setDesc(const LLString& desc) mDesc = rawstr_to_utf8(mDesc); } -void LLParcel::setMusicURL(const LLString& url) +void LLParcel::setMusicURL(const std::string& url) { mMusicURL = url; // The escaping here must match the escaping in the database @@ -312,7 +298,7 @@ void LLParcel::setMusicURL(const LLString& url) LLStringFn::replace_nonprintable(mMusicURL, LL_UNKNOWN_CHAR); } -void LLParcel::setMediaURL(const LLString& url) +void LLParcel::setMediaURL(const std::string& url) { mMediaURL = url; // The escaping here must match the escaping in the database @@ -322,24 +308,24 @@ void LLParcel::setMediaURL(const LLString& url) LLStringFn::replace_nonprintable(mMediaURL, LL_UNKNOWN_CHAR); } -void LLParcel::setMediaDesc(const char* desc) +void LLParcel::setMediaDesc(const std::string& desc) { // The escaping here must match the escaping in the database // abstraction layer. - set_std_string(desc, mMediaDesc); + mMediaDesc = desc; mMediaDesc = rawstr_to_utf8(mMediaDesc); } -void LLParcel::setMediaType(const char* type) +void LLParcel::setMediaType(const std::string& type) { // The escaping here must match the escaping in the database // abstraction layer. - set_std_string(type, mMediaType); + mMediaType = type; mMediaType = rawstr_to_utf8(mMediaType); // This code attempts to preserve legacy movie functioning if(mMediaType.empty() && ! mMediaURL.empty()) { - setMediaType("video/vnd.secondlife.qt.legacy"); + setMediaType(std::string("video/vnd.secondlife.qt.legacy")); } } void LLParcel::setMediaWidth(S32 width) @@ -578,7 +564,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) while (input_stream.good()) { skip_comments_and_emptyspace(input_stream); - LLString line, keyword, value; + std::string line, keyword, value; get_line(line, input_stream, MAX_STRING); get_keyword_and_value(keyword, value, line); @@ -588,19 +574,19 @@ BOOL LLParcel::importStream(std::istream& input_stream) } else if ("parcel_id" == keyword) { - mID.set(value.c_str()); + mID.set(value); } else if ("status" == keyword) { - mStatus = ownership_string_to_status(value.c_str()); + mStatus = ownership_string_to_status(value); } else if ("category" == keyword) { - mCategory = category_string_to_category(value.c_str()); + mCategory = category_string_to_category(value); } else if ("local_id" == keyword) { - LLString::convertToS32(value, mLocalID); + LLStringUtil::convertToS32(value, mLocalID); } else if ("name" == keyword) { @@ -620,65 +606,65 @@ BOOL LLParcel::importStream(std::istream& input_stream) } else if ("media_desc" == keyword) { - setMediaDesc( value.c_str() ); + setMediaDesc( value ); } else if ("media_type" == keyword) { - setMediaType( value.c_str() ); + setMediaType( value ); } else if ("media_width" == keyword) { S32 width; - LLString::convertToS32(value, width); + LLStringUtil::convertToS32(value, width); setMediaWidth( width ); } else if ("media_height" == keyword) { S32 height; - LLString::convertToS32(value, height); + LLStringUtil::convertToS32(value, height); setMediaHeight( height ); } else if ("media_id" == keyword) { - mMediaID.set( value.c_str() ); + mMediaID.set( value ); } else if ("media_auto_scale" == keyword) { - LLString::convertToU8(value, mMediaAutoScale); + LLStringUtil::convertToU8(value, mMediaAutoScale); } else if ("media_loop" == keyword) { - LLString::convertToU8(value, mMediaLoop); + LLStringUtil::convertToU8(value, mMediaLoop); } else if ("obscure_media" == keyword) { - LLString::convertToU8(value, mObscureMedia); + LLStringUtil::convertToU8(value, mObscureMedia); } else if ("obscure_music" == keyword) { - LLString::convertToU8(value, mObscureMusic); + LLStringUtil::convertToU8(value, mObscureMusic); } else if ("owner_id" == keyword) { - mOwnerID.set( value.c_str() ); + mOwnerID.set( value ); } else if ("group_owned" == keyword) { - LLString::convertToBOOL(value, mGroupOwned); + LLStringUtil::convertToBOOL(value, mGroupOwned); } else if ("clean_other_time" == keyword) { S32 time; - LLString::convertToS32(value, time); + LLStringUtil::convertToS32(value, time); setCleanOtherTime(time); } else if ("auth_buyer_id" == keyword) { - mAuthBuyerID.set(value.c_str()); + mAuthBuyerID.set(value); } else if ("snapshot_id" == keyword) { - mSnapshotID.set(value.c_str()); + mSnapshotID.set(value); } else if ("user_location" == keyword) { @@ -697,7 +683,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) else if ("landing_type" == keyword) { S32 landing_type = 0; - LLString::convertToS32(value, landing_type); + LLStringUtil::convertToS32(value, landing_type); mLandingType = (ELandingType) landing_type; } else if ("join_neighbors" == keyword) @@ -706,7 +692,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) } else if ("revert_sale" == keyword) { - LLString::convertToS32(value, secs_until_revert); + LLStringUtil::convertToS32(value, secs_until_revert); if (secs_until_revert > 0) { mSaleTimerExpires.start(); @@ -715,7 +701,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) } else if("extended_grace" == keyword) { - LLString::convertToS32(value, mGraceExtension); + LLStringUtil::convertToS32(value, mGraceExtension); } else if ("user_list_type" == keyword) { @@ -723,147 +709,147 @@ BOOL LLParcel::importStream(std::istream& input_stream) } else if("auction_id" == keyword) { - LLString::convertToU32(value, mAuctionID); + LLStringUtil::convertToU32(value, mAuctionID); } else if ("allow_modify" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_CREATE_OBJECTS, setting); } else if ("allow_group_modify" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_CREATE_GROUP_OBJECTS, setting); } else if ("allow_all_object_entry" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_ALL_OBJECT_ENTRY, setting); } else if ("allow_group_object_entry" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_GROUP_OBJECT_ENTRY, setting); } else if ("allow_deed_to_group" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_DEED_TO_GROUP, setting); } else if("contribute_with_deed" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_CONTRIBUTE_WITH_DEED, setting); } else if ("allow_terraform" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_TERRAFORM, setting); } else if ("allow_damage" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_DAMAGE, setting); } else if ("allow_fly" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_FLY, setting); } else if ("allow_landmark" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_LANDMARK, setting); } else if ("sound_local" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_SOUND_LOCAL, setting); } else if ("allow_group_scripts" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_GROUP_SCRIPTS, setting); } else if ("allow_voice_chat" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_VOICE_CHAT, setting); } else if ("use_estate_voice_chan" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_USE_ESTATE_VOICE_CHAN, setting); } else if ("allow_scripts" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_OTHER_SCRIPTS, setting); } else if ("for_sale" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_FOR_SALE, setting); } else if ("sell_w_objects" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_SELL_PARCEL_OBJECTS, setting); } else if ("use_pass_list" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_USE_PASS_LIST, setting); } else if ("show_directory" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_SHOW_DIRECTORY, setting); } else if ("allow_publish" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_ALLOW_PUBLISH, setting); } else if ("mature_publish" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_MATURE_PUBLISH, setting); } else if ("claim_date" == keyword) { // BUG: This will fail when time rolls over in 2038. S32 time; - LLString::convertToS32(value, time); + LLStringUtil::convertToS32(value, time); mClaimDate = time; } else if ("claim_price" == keyword) { - LLString::convertToS32(value, mClaimPricePerMeter); + LLStringUtil::convertToS32(value, mClaimPricePerMeter); } else if ("rent_price" == keyword) { - LLString::convertToS32(value, mRentPricePerMeter); + LLStringUtil::convertToS32(value, mRentPricePerMeter); } else if ("discount_rate" == keyword) { - LLString::convertToF32(value, mDiscountRate); + LLStringUtil::convertToF32(value, mDiscountRate); } else if ("draw_distance" == keyword) { - LLString::convertToF32(value, mDrawDistance); + LLStringUtil::convertToF32(value, mDrawDistance); } else if ("sale_price" == keyword) { - LLString::convertToS32(value, mSalePrice); + LLStringUtil::convertToS32(value, mSalePrice); } else if ("pass_price" == keyword) { - LLString::convertToS32(value, mPassPrice); + LLStringUtil::convertToS32(value, mPassPrice); } else if ("pass_hours" == keyword) { - LLString::convertToF32(value, mPassHours); + LLStringUtil::convertToF32(value, mPassHours); } else if ("box" == keyword) { @@ -876,17 +862,17 @@ BOOL LLParcel::importStream(std::istream& input_stream) } else if ("use_access_group" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_USE_ACCESS_GROUP, setting); } else if ("use_access_list" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_USE_ACCESS_LIST, setting); } else if ("use_ban_list" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_USE_BAN_LIST, setting); } else if ("group_name" == keyword) @@ -895,7 +881,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) } else if ("group_id" == keyword) { - mGroupID.set( value.c_str() ); + mGroupID.set( value ); } // TODO: DEPRECATED FLAG // Flag removed from simstate files in 1.11.1 @@ -903,7 +889,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) // no longer exists anywhere in simstate files. else if ("require_identified" == keyword) { - // LLString::convertToU32(value, setting); + // LLStringUtil::convertToU32(value, setting); // setParcelFlag(PF_DENY_ANONYMOUS, setting); } // TODO: DEPRECATED FLAG @@ -912,39 +898,39 @@ BOOL LLParcel::importStream(std::istream& input_stream) // no longer exists anywhere in simstate files. else if ("require_transacted" == keyword) { - // LLString::convertToU32(value, setting); + // LLStringUtil::convertToU32(value, setting); // setParcelFlag(PF_DENY_ANONYMOUS, setting); // setParcelFlag(PF_DENY_IDENTIFIED, setting); } else if ("restrict_pushobject" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_RESTRICT_PUSHOBJECT, setting); } else if ("deny_anonymous" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_DENY_ANONYMOUS, setting); } else if ("deny_identified" == keyword) { -// LLString::convertToU32(value, setting); +// LLStringUtil::convertToU32(value, setting); // setParcelFlag(PF_DENY_IDENTIFIED, setting); } else if ("deny_transacted" == keyword) { -// LLString::convertToU32(value, setting); +// LLStringUtil::convertToU32(value, setting); // setParcelFlag(PF_DENY_TRANSACTED, setting); } else if ("deny_age_unverified" == keyword) { - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); setParcelFlag(PF_DENY_AGEUNVERIFIED, setting); } else if ("access_list" == keyword) { S32 entry_count = 0; - LLString::convertToS32(value, entry_count); + LLStringUtil::convertToS32(value, entry_count); for (S32 i = 0; i < entry_count; i++) { LLAccessEntry entry; @@ -957,7 +943,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) else if ("ban_list" == keyword) { S32 entry_count = 0; - LLString::convertToS32(value, entry_count); + LLStringUtil::convertToS32(value, entry_count); for (S32 i = 0; i < entry_count; i++) { LLAccessEntry entry; @@ -971,7 +957,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) { /* S32 entry_count = 0; - LLString::convertToS32(value, entry_count); + LLStringUtil::convertToS32(value, entry_count); for (S32 i = 0; i < entry_count; i++) { LLAccessEntry entry; @@ -985,7 +971,7 @@ BOOL LLParcel::importStream(std::istream& input_stream) { // legacy - put into access list S32 entry_count = 0; - LLString::convertToS32(value, entry_count); + LLStringUtil::convertToS32(value, entry_count); for (S32 i = 0; i < entry_count; i++) { LLAccessEntry entry; @@ -1061,7 +1047,7 @@ BOOL LLParcel::importAccessEntry(std::istream& input_stream, LLAccessEntry* entr while (input_stream.good()) { skip_comments_and_emptyspace(input_stream); - LLString line, keyword, value; + std::string line, keyword, value; get_line(line, input_stream, MAX_STRING); get_keyword_and_value(keyword, value, line); @@ -1071,7 +1057,7 @@ BOOL LLParcel::importAccessEntry(std::istream& input_stream, LLAccessEntry* entr } else if ("id" == keyword) { - entry->mID.set( value.c_str() ); + entry->mID.set( value ); } else if ("name" == keyword) { @@ -1080,13 +1066,13 @@ BOOL LLParcel::importAccessEntry(std::istream& input_stream, LLAccessEntry* entr else if ("time" == keyword) { S32 when; - LLString::convertToS32(value, when); + LLStringUtil::convertToS32(value, when); entry->mTime = when; } else if ("flags" == keyword) { U32 setting; - LLString::convertToU32(value, setting); + LLStringUtil::convertToU32(value, setting); entry->mFlags = setting; } else @@ -1101,7 +1087,7 @@ BOOL LLParcel::importAccessEntry(std::istream& input_stream, LLAccessEntry* entr BOOL LLParcel::exportStream(std::ostream& output_stream) { S32 setting; - char id_string[MAX_STRING]; /* Flawfinder: ignore */ + std::string id_string; std::ios::fmtflags old_flags = output_stream.flags(); output_stream.setf(std::ios::showpoint); @@ -1377,17 +1363,17 @@ void LLParcel::packMessage(LLSD& msg) void LLParcel::unpackMessage(LLMessageSystem* msg) { - char buffer[256]; /* Flawfinder: ignore */ + std::string buffer; msg->getU32Fast( _PREHASH_ParcelData,_PREHASH_ParcelFlags, mParcelFlags ); msg->getS32Fast( _PREHASH_ParcelData,_PREHASH_SalePrice, mSalePrice ); - msg->getStringFast( _PREHASH_ParcelData,_PREHASH_Name, 256, buffer ); + msg->getStringFast( _PREHASH_ParcelData,_PREHASH_Name, buffer ); setName(buffer); - msg->getStringFast( _PREHASH_ParcelData,_PREHASH_Desc, 256, buffer ); + msg->getStringFast( _PREHASH_ParcelData,_PREHASH_Desc, buffer ); setDesc(buffer); - msg->getStringFast( _PREHASH_ParcelData,_PREHASH_MusicURL, 256, buffer ); + msg->getStringFast( _PREHASH_ParcelData,_PREHASH_MusicURL, buffer ); setMusicURL(buffer); - msg->getStringFast( _PREHASH_ParcelData,_PREHASH_MediaURL, 256, buffer ); + msg->getStringFast( _PREHASH_ParcelData,_PREHASH_MediaURL, buffer ); setMediaURL(buffer); // non-optimized version @@ -1412,9 +1398,9 @@ void LLParcel::unpackMessage(LLMessageSystem* msg) // Note: the message has been converted to TCP if(msg->getNumberOfBlocks("MediaData") > 0) { - msg->getString("MediaData", "MediaDesc", 256, buffer); + msg->getString("MediaData", "MediaDesc", buffer); setMediaDesc(buffer); - msg->getString("MediaData", "MediaType", 256, buffer); + msg->getString("MediaData", "MediaType", buffer); setMediaType(buffer); msg->getS32("MediaData", "MediaWidth", mMediaWidth); msg->getS32("MediaData", "MediaHeight", mMediaHeight); @@ -1424,8 +1410,8 @@ void LLParcel::unpackMessage(LLMessageSystem* msg) } else { - setMediaType("video/vnd.secondlife.qt.legacy"); - setMediaDesc("No Description available without Server Upgrade"); + setMediaType(std::string("video/vnd.secondlife.qt.legacy")); + setMediaDesc(std::string("No Description available without Server Upgrade")); mMediaLoop = true; mObscureMedia = true; mObscureMusic = true; @@ -1688,37 +1674,37 @@ BOOL LLParcel::removeFromBanList(const LLUUID& agent_id) } // static -const char* LLParcel::getOwnershipStatusString(EOwnershipStatus status) +const std::string& LLParcel::getOwnershipStatusString(EOwnershipStatus status) { return ownership_status_to_string(status); } // static -const char* LLParcel::getCategoryString(ECategory category) +const std::string& LLParcel::getCategoryString(ECategory category) { return category_to_string(category); } // static -const char* LLParcel::getCategoryUIString(ECategory category) +const std::string& LLParcel::getCategoryUIString(ECategory category) { return category_to_ui_string(category); } // static -LLParcel::ECategory LLParcel::getCategoryFromString(const char* string) +LLParcel::ECategory LLParcel::getCategoryFromString(const std::string& string) { return category_string_to_category(string); } // static -LLParcel::ECategory LLParcel::getCategoryFromUIString(const char* string) +LLParcel::ECategory LLParcel::getCategoryFromUIString(const std::string& string) { return category_ui_string_to_category(string); } // static -const char* LLParcel::getActionString(LLParcel::EAction action) +const std::string& LLParcel::getActionString(LLParcel::EAction action) { S32 index = 0; if((action >= 0) && (action < LLParcel::A_COUNT)) @@ -1851,19 +1837,19 @@ BOOL LLParcel::isBuyerAuthorized(const LLUUID& buyer_id) const void LLParcel::clearParcel() { overrideParcelFlags(PF_DEFAULT); - setName(NULL); - setDesc(NULL); - setMediaURL(NULL); - setMediaType(NULL); + setName(LLStringUtil::null); + setDesc(LLStringUtil::null); + setMediaURL(LLStringUtil::null); + setMediaType(LLStringUtil::null); setMediaID(LLUUID::null); - setMediaDesc(NULL); + setMediaDesc(LLStringUtil::null); setMediaAutoScale(0); setMediaLoop(TRUE); mObscureMedia = 1; mObscureMusic = 1; mMediaWidth = 0; mMediaHeight = 0; - setMusicURL(NULL); + setMusicURL(LLStringUtil::null); setInEscrow(FALSE); setAuthorizedBuyerID(LLUUID::null); setCategory(C_NONE); @@ -1887,20 +1873,20 @@ void LLParcel::dump() llinfos << " desc <" << mDesc << ">" << llendl; } -const char* ownership_status_to_string(LLParcel::EOwnershipStatus status) +const std::string& ownership_status_to_string(LLParcel::EOwnershipStatus status) { if(status >= 0 && status < LLParcel::OS_COUNT) { return PARCEL_OWNERSHIP_STATUS_STRING[status]; } - return "none"; + return PARCEL_OWNERSHIP_STATUS_STRING[LLParcel::OS_COUNT]; } -LLParcel::EOwnershipStatus ownership_string_to_status(const char* s) +LLParcel::EOwnershipStatus ownership_string_to_status(const std::string& s) { for(S32 i = 0; i < LLParcel::OS_COUNT; ++i) { - if(0 == strcmp(s, PARCEL_OWNERSHIP_STATUS_STRING[i])) + if(s == PARCEL_OWNERSHIP_STATUS_STRING[i]) { return (LLParcel::EOwnershipStatus)i; } @@ -1930,7 +1916,7 @@ LLParcel::EOwnershipStatus ownership_string_to_status(const char* s) // return LLParcel::STEA_REVERT; //} -const char* category_to_string(LLParcel::ECategory category) +const std::string& category_to_string(LLParcel::ECategory category) { S32 index = 0; if((category >= 0) && (category < LLParcel::C_COUNT)) @@ -1940,7 +1926,7 @@ const char* category_to_string(LLParcel::ECategory category) return PARCEL_CATEGORY_STRING[index]; } -const char* category_to_ui_string(LLParcel::ECategory category) +const std::string& category_to_ui_string(LLParcel::ECategory category) { S32 index = 0; if((category >= 0) && (category < LLParcel::C_COUNT)) @@ -1955,11 +1941,11 @@ const char* category_to_ui_string(LLParcel::ECategory category) return PARCEL_CATEGORY_UI_STRING[index]; } -LLParcel::ECategory category_string_to_category(const char* s) +LLParcel::ECategory category_string_to_category(const std::string& s) { for(S32 i = 0; i < LLParcel::C_COUNT; ++i) { - if(0 == strcmp(s, PARCEL_CATEGORY_STRING[i])) + if(s == PARCEL_CATEGORY_STRING[i]) { return (LLParcel::ECategory)i; } @@ -1968,11 +1954,11 @@ LLParcel::ECategory category_string_to_category(const char* s) return LLParcel::C_NONE; } -LLParcel::ECategory category_ui_string_to_category(const char* s) +LLParcel::ECategory category_ui_string_to_category(const std::string& s) { for(S32 i = 0; i < LLParcel::C_COUNT; ++i) { - if(0 == strcmp(s, PARCEL_CATEGORY_UI_STRING[i])) + if(s == PARCEL_CATEGORY_UI_STRING[i]) { return (LLParcel::ECategory)i; } diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h index 5d3a2b01ec..716802b2dc 100644 --- a/indra/llinventory/llparcel.h +++ b/indra/llinventory/llparcel.h @@ -207,12 +207,12 @@ public: // MANIPULATORS void generateNewID() { mID.generate(); } - void setName(const LLString& name); - void setDesc(const LLString& desc); - void setMusicURL(const LLString& url); - void setMediaURL(const LLString& url); - void setMediaType(const char* type); - void setMediaDesc(const char* desc); + void setName(const std::string& name); + void setDesc(const std::string& desc); + void setMusicURL(const std::string& url); + void setMediaURL(const std::string& url); + void setMediaType(const std::string& type); + void setMediaDesc(const std::string& desc); void setMediaID(const LLUUID& id) { mMediaID = id; } void setMediaAutoScale ( U8 flagIn ) { mMediaAutoScale = flagIn; } void setMediaLoop (U8 loop) { mMediaLoop = loop; } @@ -266,7 +266,7 @@ public: void setDrawDistance(F32 dist) { mDrawDistance = dist; } void setSalePrice(S32 price) { mSalePrice = price; } void setGroupID(const LLUUID& id) { mGroupID = id; } - //void setGroupName(const LLString& s) { mGroupName.assign(s); } + //void setGroupName(const std::string& s) { mGroupName.assign(s); } void setPassPrice(S32 price) { mPassPrice = price; } void setPassHours(F32 hours) { mPassHours = hours; } @@ -303,12 +303,12 @@ public: // ACCESSORS const LLUUID& getID() const { return mID; } - const LLString& getName() const { return mName; } - const LLString& getDesc() const { return mDesc; } - const LLString& getMusicURL() const { return mMusicURL; } - const LLString& getMediaURL() const { return mMediaURL; } - const char* getMediaDesc() const { return mMediaDesc.c_str(); } - const char* getMediaType() const { return mMediaType.c_str(); } + const std::string& getName() const { return mName; } + const std::string& getDesc() const { return mDesc; } + const std::string& getMusicURL() const { return mMusicURL; } + const std::string& getMediaURL() const { return mMediaURL; } + const std::string& getMediaDesc() const { return mMediaDesc; } + const std::string& getMediaType() const { return mMediaType; } const LLUUID& getMediaID() const { return mMediaID; } S32 getMediaWidth() const { return mMediaWidth; } S32 getMediaHeight() const { return mMediaHeight; } @@ -351,18 +351,18 @@ public: // functions to deal with ownership status. EOwnershipStatus getOwnershipStatus() const { return mStatus; } - static const char* getOwnershipStatusString(EOwnershipStatus status); + static const std::string& getOwnershipStatusString(EOwnershipStatus status); void setOwnershipStatus(EOwnershipStatus status) { mStatus = status; } // dealing with parcel category information ECategory getCategory() const {return mCategory; } - static const char* getCategoryString(ECategory category); - static const char* getCategoryUIString(ECategory category); - static ECategory getCategoryFromString(const char* string); - static ECategory getCategoryFromUIString(const char* string); + static const std::string& getCategoryString(ECategory category); + static const std::string& getCategoryUIString(ECategory category); + static ECategory getCategoryFromString(const std::string& string); + static ECategory getCategoryFromUIString(const std::string& string); // functions for parcel action (used for logging) - static const char* getActionString(EAction action); + static const std::string& getActionString(EAction action); // dealing with sales and parcel conversion. // @@ -587,12 +587,12 @@ protected: F32 mDrawDistance; U32 mParcelFlags; S32 mSalePrice; // linden dollars - LLString mName; - LLString mDesc; - LLString mMusicURL; - LLString mMediaURL; - std::string mMediaDesc; - std::string mMediaType; + std::string mName; + std::string mDesc; + std::string mMusicURL; + std::string mMediaURL; + std::string mMediaDesc; + std::string mMediaType; S32 mMediaWidth; S32 mMediaHeight; U8 mMediaAutoScale; diff --git a/indra/llinventory/llpermissions.cpp b/indra/llinventory/llpermissions.cpp index b137eeff33..cf9937629a 100644 --- a/indra/llinventory/llpermissions.cpp +++ b/indra/llinventory/llpermissions.cpp @@ -650,7 +650,7 @@ BOOL LLPermissions::importFile(LLFILE* fp) BOOL LLPermissions::exportFile(LLFILE* fp) const { - char uuid_str[256]; /* Flawfinder: ignore */ + std::string uuid_str; fprintf(fp, "\tpermissions 0\n"); fprintf(fp, "\t{\n"); @@ -662,16 +662,16 @@ BOOL LLPermissions::exportFile(LLFILE* fp) const fprintf(fp, "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner); mCreator.toString(uuid_str); - fprintf(fp, "\t\tcreator_id\t%s\n", uuid_str); + fprintf(fp, "\t\tcreator_id\t%s\n", uuid_str.c_str()); mOwner.toString(uuid_str); - fprintf(fp, "\t\towner_id\t%s\n", uuid_str); + fprintf(fp, "\t\towner_id\t%s\n", uuid_str.c_str()); mLastOwner.toString(uuid_str); - fprintf(fp, "\t\tlast_owner_id\t%s\n", uuid_str); + fprintf(fp, "\t\tlast_owner_id\t%s\n", uuid_str.c_str()); mGroup.toString(uuid_str); - fprintf(fp, "\t\tgroup_id\t%s\n", uuid_str); + fprintf(fp, "\t\tgroup_id\t%s\n", uuid_str.c_str()); if(mIsGroupOwned) { @@ -784,21 +784,21 @@ BOOL LLPermissions::importLegacyStream(std::istream& input_stream) BOOL LLPermissions::exportLegacyStream(std::ostream& output_stream) const { - char uuid_str[256]; /* Flawfinder: ignore */ + std::string uuid_str; output_stream << "\tpermissions 0\n"; output_stream << "\t{\n"; - char buffer[256]; /* Flawfinder: ignore */ - snprintf(buffer, sizeof(buffer), "\t\tbase_mask\t%08x\n", mMaskBase); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat( "\t\tbase_mask\t%08x\n", mMaskBase); output_stream << buffer; - snprintf(buffer, sizeof(buffer), "\t\towner_mask\t%08x\n", mMaskOwner); /* Flawfinder: ignore */ + buffer = llformat( "\t\towner_mask\t%08x\n", mMaskOwner); output_stream << buffer; - snprintf(buffer, sizeof(buffer), "\t\tgroup_mask\t%08x\n", mMaskGroup); /* Flawfinder: ignore */ + buffer = llformat( "\t\tgroup_mask\t%08x\n", mMaskGroup); output_stream << buffer; - snprintf(buffer, sizeof(buffer), "\t\teveryone_mask\t%08x\n", mMaskEveryone); /* Flawfinder: ignore */ + buffer = llformat( "\t\teveryone_mask\t%08x\n", mMaskEveryone); output_stream << buffer; - snprintf(buffer, sizeof(buffer), "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner); /* Flawfinder: ignore */ + buffer = llformat( "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner); output_stream << buffer; mCreator.toString(uuid_str); @@ -1118,12 +1118,12 @@ void LLAggregatePermissions::unpackMessage(LLMessageSystem* msg, const char* blo mBits[PI_TRANSFER] = bits & TWO_BITS; } -const LLString AGGREGATE_VALUES[4] = +const std::string AGGREGATE_VALUES[4] = { - LLString( "Empty" ), - LLString( "None" ), - LLString( "Some" ), - LLString( "All" ) + std::string( "Empty" ), + std::string( "None" ), + std::string( "Some" ), + std::string( "All" ) }; std::ostream& operator<<(std::ostream &s, const LLAggregatePermissions &perm) diff --git a/indra/llinventory/llsaleinfo.cpp b/indra/llinventory/llsaleinfo.cpp index 0c2ba82302..111167ae27 100644 --- a/indra/llinventory/llsaleinfo.cpp +++ b/indra/llinventory/llsaleinfo.cpp @@ -128,7 +128,7 @@ bool LLSaleInfo::fromLLSD(LLSD& sd, BOOL& has_perm_mask, U32& perm_mask) LLXMLNode *LLSaleInfo::exportFileXML() const { LLXMLNode *ret = new LLXMLNode("sale_info", FALSE); - LLString type_str = lookup(mSaleType); + std::string type_str = ll_safe_string( lookup(mSaleType)); ret->createChild("type", TRUE)->setStringValue(1, &type_str); ret->createChild("price", TRUE)->setIntValue(1, &mSalePrice); return ret; diff --git a/indra/llinventory/lltransactionflags.cpp b/indra/llinventory/lltransactionflags.cpp index 6b90fbdc5a..3f82ad46ae 100644 --- a/indra/llinventory/lltransactionflags.cpp +++ b/indra/llinventory/lltransactionflags.cpp @@ -69,12 +69,12 @@ BOOL is_tf_owner_group(TransactionFlags flags) void append_reason( std::ostream& ostr, S32 transaction_type, - const char* description) + const std::string& description) { switch( transaction_type ) { case TRANS_OBJECT_SALE: - ostr << " for " << (description ? description : "<unknown>"); + ostr << " for " << (description.length() > 0 ? description : std::string("<unknown>")); break; case TRANS_LAND_SALE: ostr << " for a parcel of land"; @@ -95,16 +95,21 @@ std::string build_transfer_message_to_source( const LLUUID& dest_id, const std::string& dest_name, S32 transaction_type, - const char* desc) + const std::string& description) { - std::string description(ll_safe_string(desc)); lldebugs << "build_transfer_message_to_source: " << amount << " " << source_id << " " << dest_id << " " << dest_name << " " << transaction_type << " " - << (description.empty()?"(no desc)":description.c_str()) + << (description.empty() ? "(no desc)" : description) << llendl; - if(source_id.isNull()) return description; - if((0 == amount) && description.empty()) return description; + if(source_id.isNull()) + { + return description; + } + if((0 == amount) && description.empty()) + { + return description; + } std::ostringstream ostr; if(dest_id.isNull()) { @@ -127,7 +132,7 @@ std::string build_transfer_message_to_source( else { ostr << "You paid " << dest_name << " L$" << amount; - append_reason(ostr, transaction_type, description.c_str()); + append_reason(ostr, transaction_type, description); } ostr << "."; return ostr.str(); @@ -139,14 +144,20 @@ std::string build_transfer_message_to_destination( const LLUUID& source_id, const std::string& source_name, S32 transaction_type, - const char* description) + const std::string& description) { lldebugs << "build_transfer_message_to_dest: " << amount << " " << dest_id << " " << source_id << " " << source_name << " " - << transaction_type << " " << (description?description:"(no desc)") + << transaction_type << " " << (description.empty() ? "(no desc)" : description) << llendl; - if(0 == amount) return std::string(); - if(dest_id.isNull()) return ll_safe_string(description); + if(0 == amount) + { + return std::string(); + } + if(dest_id.isNull()) + { + return description; + } std::ostringstream ostr; ostr << source_name << " paid you L$" << amount; append_reason(ostr, transaction_type, description); diff --git a/indra/llinventory/lltransactionflags.h b/indra/llinventory/lltransactionflags.h index 3bf08af282..4fe1503ff0 100644 --- a/indra/llinventory/lltransactionflags.h +++ b/indra/llinventory/lltransactionflags.h @@ -57,7 +57,7 @@ std::string build_transfer_message_to_source( const LLUUID& dest_id, const std::string& dest_name, S32 transaction_type, - const char* description); + const std::string& description); std::string build_transfer_message_to_destination( S32 amount, @@ -65,6 +65,6 @@ std::string build_transfer_message_to_destination( const LLUUID& source_id, const std::string& source_name, S32 transaction_type, - const char* description); + const std::string& description); #endif // LL_LLTRANSACTIONFLAGS_H |