diff options
590 files changed, 8052 insertions, 9384 deletions
diff --git a/indra/linux_crash_logger/llcrashloggerlinux.cpp b/indra/linux_crash_logger/llcrashloggerlinux.cpp index e0a6e2608e..9a88c32e51 100644 --- a/indra/linux_crash_logger/llcrashloggerlinux.cpp +++ b/indra/linux_crash_logger/llcrashloggerlinux.cpp @@ -132,7 +132,7 @@ bool LLCrashLoggerLinux::mainLoop() return true; } -void LLCrashLoggerLinux::updateApplication(LLString message) +void LLCrashLoggerLinux::updateApplication(const std::string& message) { LLCrashLogger::updateApplication(message); } diff --git a/indra/linux_crash_logger/llcrashloggerlinux.h b/indra/linux_crash_logger/llcrashloggerlinux.h index a84ee00e1c..2f03e55bd2 100644 --- a/indra/linux_crash_logger/llcrashloggerlinux.h +++ b/indra/linux_crash_logger/llcrashloggerlinux.h @@ -42,7 +42,7 @@ public: LLCrashLoggerLinux(void); ~LLCrashLoggerLinux(void); virtual bool mainLoop(); - virtual void updateApplication(LLString message = ""); + virtual void updateApplication(const std::string& = LLStringUtil::null); virtual void gatherPlatformSpecificFiles(); }; diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index ed4feff012..d45026c2df 100644 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -70,7 +70,7 @@ public: LLPointer<LLVorbisDecodeState> mDecoder; }; - LLVorbisDecodeState(const LLUUID &uuid, const LLString &out_filename); + LLVorbisDecodeState(const LLUUID &uuid, const std::string &out_filename); BOOL initDecode(); BOOL decodeSection(); // Return TRUE if done. @@ -93,7 +93,7 @@ protected: std::vector<U8> mWAVBuffer; #if !defined(USE_WAV_VFILE) - LLString mOutFilename; + std::string mOutFilename; LLLFSThread::handle_t mFileHandle; #endif @@ -166,7 +166,7 @@ long vfs_tell (void *datasource) return file->tell(); } -LLVorbisDecodeState::LLVorbisDecodeState(const LLUUID &uuid, const LLString &out_filename) +LLVorbisDecodeState::LLVorbisDecodeState(const LLUUID &uuid, const std::string &out_filename) { mDone = FALSE; mValid = FALSE; @@ -583,14 +583,14 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs) lldebugs << "Decoding " << uuid << " from audio queue!" << llendl; - char uuid_str[64]; /*Flawfinder: ignore*/ - char d_path[LL_MAX_PATH]; /*Flawfinder: ignore*/ + std::string uuid_str; + std::string d_path; LLTimer timer; timer.reset(); uuid.toString(uuid_str); - snprintf(d_path, LL_MAX_PATH, "%s.dsf", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str()); /* Flawfinder: ignore */ + d_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + ".dsf"; mCurrentDecodep = new LLVorbisDecodeState(uuid, d_path); if (!mCurrentDecodep->initDecode()) diff --git a/indra/llcharacter/llanimationstates.cpp b/indra/llcharacter/llanimationstates.cpp index 415b945e88..f41b2038de 100644 --- a/indra/llcharacter/llanimationstates.cpp +++ b/indra/llcharacter/llanimationstates.cpp @@ -228,10 +228,10 @@ const char *LLAnimationLibrary::animStateToString( const LLUUID& state ) //----------------------------------------------------------------------------- // Return the animation state for a given name //----------------------------------------------------------------------------- -LLUUID LLAnimationLibrary::stringToAnimState( const char *name, BOOL allow_ids ) +LLUUID LLAnimationLibrary::stringToAnimState( const std::string& name, BOOL allow_ids ) { - LLString lower_case_name(name); - LLString::toLower(lower_case_name); + std::string lower_case_name(name); + LLStringUtil::toLower(lower_case_name); char *true_name = mAnimStringTable.checkString(lower_case_name.c_str()); diff --git a/indra/llcharacter/llanimationstates.h b/indra/llcharacter/llanimationstates.h index ae3f6894db..abb7578cc9 100644 --- a/indra/llcharacter/llanimationstates.h +++ b/indra/llcharacter/llanimationstates.h @@ -222,7 +222,7 @@ public: // Return the animation state for the given name. // Retun NULL if the name is invalid. //----------------------------------------------------------------------------- - LLUUID stringToAnimState( const char *name, BOOL allow_ids = TRUE ); + LLUUID stringToAnimState( const std::string& name, BOOL allow_ids = TRUE ); }; struct LLAnimStateEntry diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp index 95147ba842..54b3ec98eb 100644 --- a/indra/llcharacter/llbvhloader.cpp +++ b/indra/llcharacter/llbvhloader.cpp @@ -175,11 +175,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //-------------------------------------------------------------------- // open file //-------------------------------------------------------------------- - char path[LL_MAX_PATH]; /* Flawfinder: ignore */ - - snprintf( path, sizeof(path), "%s", /* Flawfinder: ignore */ - gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName).c_str()); - + std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName); apr_file_t *fp = ll_apr_file_open(path, LL_APR_R); if (!fp) @@ -243,7 +239,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for optional emote //---------------------------------------------------------------- - if (loadingGlobals && LLString::compareInsensitive(token, "emote")==0) + if (loadingGlobals && LLStringUtil::compareInsensitive(token, "emote")==0) { char emote_str[1024]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %1023s", emote_str) != 1 ) /* Flawfinder: ignore */ @@ -258,7 +254,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for global priority setting //---------------------------------------------------------------- - if (loadingGlobals && LLString::compareInsensitive(token, "priority")==0) + if (loadingGlobals && LLStringUtil::compareInsensitive(token, "priority")==0) { S32 priority; if ( sscanf(mLine, " %*s = %d", &priority) != 1 ) @@ -272,7 +268,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for global loop setting //---------------------------------------------------------------- - if (loadingGlobals && LLString::compareInsensitive(token, "loop")==0) + if (loadingGlobals && LLStringUtil::compareInsensitive(token, "loop")==0) { char trueFalse[128]; /* Flawfinder: ignore */ trueFalse[0] = '\0'; @@ -286,7 +282,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) } else if ( sscanf(mLine, " %*s = %127s", trueFalse) == 1 ) /* Flawfinder: ignore */ { - mLoop = (LLString::compareInsensitive(trueFalse, "true")==0); + mLoop = (LLStringUtil::compareInsensitive(trueFalse, "true")==0); } else { @@ -302,7 +298,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for global easeIn setting //---------------------------------------------------------------- - if (loadingGlobals && LLString::compareInsensitive(token, "easein")==0) + if (loadingGlobals && LLStringUtil::compareInsensitive(token, "easein")==0) { F32 duration; char type[128]; /* Flawfinder: ignore */ @@ -316,7 +312,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for global easeOut setting //---------------------------------------------------------------- - if (loadingGlobals && LLString::compareInsensitive(token, "easeout")==0) + if (loadingGlobals && LLStringUtil::compareInsensitive(token, "easeout")==0) { F32 duration; char type[128]; /* Flawfinder: ignore */ @@ -330,7 +326,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for global handMorph setting //---------------------------------------------------------------- - if (loadingGlobals && LLString::compareInsensitive(token, "hand")==0) + if (loadingGlobals && LLStringUtil::compareInsensitive(token, "hand")==0) { S32 handMorph; if (sscanf(mLine, " %*s = %d", &handMorph) != 1) @@ -340,7 +336,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) continue; } - if (loadingGlobals && LLString::compareInsensitive(token, "constraint")==0) + if (loadingGlobals && LLStringUtil::compareInsensitive(token, "constraint")==0) { Constraint constraint; @@ -400,7 +396,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) continue; } - if (loadingGlobals && LLString::compareInsensitive(token, "planar_constraint")==0) + if (loadingGlobals && LLStringUtil::compareInsensitive(token, "planar_constraint")==0) { Constraint constraint; @@ -470,20 +466,20 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for ignore flag //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "ignore")==0 ) + if ( LLStringUtil::compareInsensitive(token, "ignore")==0 ) { char trueFalse[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", trueFalse) != 1 ) /* Flawfinder: ignore */ return ST_NO_XLT_IGNORE; - trans->mIgnore = (LLString::compareInsensitive(trueFalse, "true")==0); + trans->mIgnore = (LLStringUtil::compareInsensitive(trueFalse, "true")==0); continue; } //---------------------------------------------------------------- // check for relativepos flag //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "relativepos")==0 ) + if ( LLStringUtil::compareInsensitive(token, "relativepos")==0 ) { F32 x, y, z; char relpos[128]; /* Flawfinder: ignore */ @@ -493,7 +489,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) } else if ( sscanf(mLine, " %*s = %127s", relpos) == 1 ) /* Flawfinder: ignore */ { - if ( LLString::compareInsensitive(relpos, "firstkey")==0 ) + if ( LLStringUtil::compareInsensitive(relpos, "firstkey")==0 ) { trans->mRelativePositionKey = TRUE; } @@ -513,13 +509,13 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for relativerot flag //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "relativerot")==0 ) + if ( LLStringUtil::compareInsensitive(token, "relativerot")==0 ) { //F32 x, y, z; char relpos[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", relpos) == 1 ) /* Flawfinder: ignore */ { - if ( LLString::compareInsensitive(relpos, "firstkey")==0 ) + if ( LLStringUtil::compareInsensitive(relpos, "firstkey")==0 ) { trans->mRelativeRotationKey = TRUE; } @@ -539,7 +535,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for outname value //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "outname")==0 ) + if ( LLStringUtil::compareInsensitive(token, "outname")==0 ) { char outName[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", outName) != 1 ) /* Flawfinder: ignore */ @@ -552,7 +548,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for frame matrix value //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "frame")==0 ) + if ( LLStringUtil::compareInsensitive(token, "frame")==0 ) { LLMatrix3 fm; if ( sscanf(mLine, " %*s = %f %f %f, %f %f %f, %f %f %f", @@ -568,7 +564,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for offset matrix value //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "offset")==0 ) + if ( LLStringUtil::compareInsensitive(token, "offset")==0 ) { LLMatrix3 om; if ( sscanf(mLine, " %*s = %f %f %f, %f %f %f, %f %f %f", @@ -584,7 +580,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for mergeparent value //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "mergeparent")==0 ) + if ( LLStringUtil::compareInsensitive(token, "mergeparent")==0 ) { char mergeParentName[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", mergeParentName) != 1 ) /* Flawfinder: ignore */ @@ -597,7 +593,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for mergechild value //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "mergechild")==0 ) + if ( LLStringUtil::compareInsensitive(token, "mergechild")==0 ) { char mergeChildName[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", mergeChildName) != 1 ) /* Flawfinder: ignore */ @@ -610,7 +606,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) //---------------------------------------------------------------- // check for per-joint priority //---------------------------------------------------------------- - if ( LLString::compareInsensitive(token, "priority")==0 ) + if ( LLStringUtil::compareInsensitive(token, "priority")==0 ) { S32 priority; if ( sscanf(mLine, " %*s = %d", &priority) != 1 ) @@ -1304,7 +1300,7 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp) dp.packU16(KEYFRAME_MOTION_SUBVERSION, "sub_version"); dp.packS32(mPriority, "base_priority"); dp.packF32(mDuration, "duration"); - dp.packString(mEmoteName.c_str(), "emote_name"); + dp.packString(mEmoteName, "emote_name"); dp.packF32(mLoopInPoint, "loop_in_point"); dp.packF32(mLoopOutPoint, "loop_out_point"); dp.packS32(mLoop, "loop"); @@ -1325,7 +1321,7 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp) LLQuaternion first_frame_rot; LLQuaternion fixup_rot; - dp.packString(joint->mOutName.c_str(), "joint_name"); + dp.packString(joint->mOutName, "joint_name"); dp.packS32(joint->mPriority, "joint_priority"); // compute coordinate frame rotation diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index 0b9732a718..033ac16274 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -280,8 +280,8 @@ BOOL LLCharacter::setVisualParamWeight(LLVisualParam* which_param, F32 weight, B //----------------------------------------------------------------------------- BOOL LLCharacter::setVisualParamWeight(const char* param_name, F32 weight, BOOL set_by_user) { - LLString tname(param_name); - LLString::toLower(tname); + std::string tname(param_name); + LLStringUtil::toLower(tname); char *tableptr = sVisualParamNames.checkString(tname); VisualParamNameMap_t::iterator name_iter = mVisualParamNameMap.find(tableptr); if (name_iter != mVisualParamNameMap.end()) @@ -331,8 +331,8 @@ F32 LLCharacter::getVisualParamWeight(LLVisualParam *which_param) //----------------------------------------------------------------------------- F32 LLCharacter::getVisualParamWeight(const char* param_name) { - LLString tname(param_name); - LLString::toLower(tname); + std::string tname(param_name); + LLStringUtil::toLower(tname); char *tableptr = sVisualParamNames.checkString(tname); VisualParamNameMap_t::iterator name_iter = mVisualParamNameMap.find(tableptr); if (name_iter != mVisualParamNameMap.end()) @@ -402,8 +402,8 @@ BOOL LLCharacter::visualParamWeightsAreDefault() //----------------------------------------------------------------------------- LLVisualParam* LLCharacter::getVisualParam(const char *param_name) { - LLString tname(param_name); - LLString::toLower(tname); + std::string tname(param_name); + LLStringUtil::toLower(tname); char *tableptr = sVisualParamNames.checkString(tname); VisualParamNameMap_t::iterator name_iter = mVisualParamNameMap.find(tableptr); if (name_iter != mVisualParamNameMap.end()) @@ -460,8 +460,8 @@ void LLCharacter::addVisualParam(LLVisualParam *param) if (param->getInfo()) { // Add name map - LLString tname(param->getName()); - LLString::toLower(tname); + std::string tname(param->getName()); + LLStringUtil::toLower(tname); char *tableptr = sVisualParamNames.addString(tname); std::pair<VisualParamNameMap_t::iterator, bool> nameres; nameres = mVisualParamNameMap.insert(VisualParamNameMap_t::value_type(tableptr, param)); diff --git a/indra/llcharacter/llgesture.cpp b/indra/llcharacter/llgesture.cpp index 283a06e37f..842fe0a9a8 100644 --- a/indra/llcharacter/llgesture.cpp +++ b/indra/llcharacter/llgesture.cpp @@ -191,11 +191,11 @@ LLGestureList::LLGestureList() mList.put(gesture); gesture = new LLGesture(KEY_F4, MASK_NONE, "/boogie", - LLUUID::null, "dance4", LLString::null ); + LLUUID::null, "dance4", LLStringUtil::null ); mList.put(gesture); gesture = new LLGesture(KEY_F5, MASK_SHIFT, "/tongue", - LLUUID::null, "Express_Tongue_Out", LLString::null ); + LLUUID::null, "Express_Tongue_Out", LLStringUtil::null ); mList.put(gesture); */ } @@ -219,9 +219,9 @@ void LLGestureList::deleteAll() // Iterates through space delimited tokens in string, triggering any gestures found. // Generates a revised string that has the found tokens replaced by their replacement strings // and (as a minor side effect) has multiple spaces in a row replaced by single spaces. -BOOL LLGestureList::triggerAndReviseString(const LLString &string, LLString* revised_string) +BOOL LLGestureList::triggerAndReviseString(const std::string &string, std::string* revised_string) { - LLString tokenized = string; + std::string tokenized = string; BOOL found_gestures = FALSE; BOOL first_token = TRUE; @@ -237,8 +237,8 @@ BOOL LLGestureList::triggerAndReviseString(const LLString &string, LLString* rev if( !found_gestures ) // Only pay attention to the first gesture in the string. { - LLString cur_token_lower = *token_iter; - LLString::toLower(cur_token_lower); + std::string cur_token_lower = *token_iter; + LLStringUtil::toLower(cur_token_lower); for (S32 i = 0; i < mList.count(); i++) { @@ -254,15 +254,15 @@ BOOL LLGestureList::triggerAndReviseString(const LLString &string, LLString* rev // Don't muck with the user's capitalization if we don't have to. const std::string& output = gesture->getOutputString(); - LLString output_lower = LLString(output.c_str()); - LLString::toLower(output_lower); + std::string output_lower = std::string(output.c_str()); + LLStringUtil::toLower(output_lower); if( cur_token_lower == output_lower ) { revised_string->append(*token_iter); } else { - revised_string->append(output.c_str()); + revised_string->append(output); } } diff --git a/indra/llcharacter/llgesture.h b/indra/llcharacter/llgesture.h index bab7fd0cc0..8e5aac94ba 100644 --- a/indra/llcharacter/llgesture.h +++ b/indra/llcharacter/llgesture.h @@ -93,7 +93,7 @@ public: BOOL trigger(KEY key, MASK mask); // Triggers if substring matches and generates revised string. - BOOL triggerAndReviseString(const LLString &string, LLString* revised_string); + BOOL triggerAndReviseString(const std::string &string, std::string* revised_string); // Used for construction from UI S32 count() const { return mList.count(); } diff --git a/indra/llcharacter/llhandmotion.cpp b/indra/llcharacter/llhandmotion.cpp index 511ccc7a88..2ddbaeccf9 100644 --- a/indra/llcharacter/llhandmotion.cpp +++ b/indra/llcharacter/llhandmotion.cpp @@ -201,16 +201,16 @@ void LLHandMotion::onDeactivate() //----------------------------------------------------------------------------- // LLHandMotion::getHandPoseName() //----------------------------------------------------------------------------- -LLString LLHandMotion::getHandPoseName(eHandPose pose) +std::string LLHandMotion::getHandPoseName(eHandPose pose) { if ((S32)pose < LLHandMotion::NUM_HAND_POSES && (S32)pose >= 0) { - return gHandPoseNames[pose]; + return std::string(gHandPoseNames[pose]); } - return ""; + return LLStringUtil::null; } -LLHandMotion::eHandPose LLHandMotion::getHandPose(LLString posename) +LLHandMotion::eHandPose LLHandMotion::getHandPose(std::string posename) { for (S32 pose = 0; pose < LLHandMotion::NUM_HAND_POSES; ++pose) { diff --git a/indra/llcharacter/llhandmotion.h b/indra/llcharacter/llhandmotion.h index 662800784b..8aed2f7101 100644 --- a/indra/llcharacter/llhandmotion.h +++ b/indra/llcharacter/llhandmotion.h @@ -126,8 +126,8 @@ public: virtual BOOL canDeprecate() { return FALSE; } - static LLString getHandPoseName(eHandPose pose); - static eHandPose getHandPose(LLString posename); + static std::string getHandPoseName(eHandPose pose); + static eHandPose getHandPose(std::string posename); public: //------------------------------------------------------------------------- diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index ce59349d55..d9e8407d44 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -657,7 +657,7 @@ BOOL LLKeyframeMotion::onActivate() // If the keyframe anim has an associated emote, trigger it. if( mEmoteName.length() > 0 ) { - mCharacter->startMotion( gAnimLibrary.stringToAnimState(mEmoteName.c_str()) ); + mCharacter->startMotion( gAnimLibrary.stringToAnimState(mEmoteName) ); } mLastLoopedTime = 0.f; @@ -1710,7 +1710,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const success &= dp.packU16(KEYFRAME_MOTION_SUBVERSION, "sub_version"); success &= dp.packS32(mJointMotionList->mBasePriority, "base_priority"); success &= dp.packF32(mJointMotionList->mDuration, "duration"); - success &= dp.packString(mEmoteName.c_str(), "emote_name"); + success &= dp.packString(mEmoteName, "emote_name"); success &= dp.packF32(mJointMotionList->mLoopInPoint, "loop_in_point"); success &= dp.packF32(mJointMotionList->mLoopOutPoint, "loop_out_point"); success &= dp.packS32(mJointMotionList->mLoop, "loop"); @@ -1722,7 +1722,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const for (U32 i = 0; i < mJointMotionList->getNumJointMotions(); i++) { JointMotion* joint_motionp = mJointMotionList->getJointMotion(i); - success &= dp.packString(joint_motionp->mJointName.c_str(), "joint_name"); + success &= dp.packString(joint_motionp->mJointName, "joint_name"); success &= dp.packS32(joint_motionp->mPriority, "joint_priority"); success &= dp.packS32(joint_motionp->mRotationCurve.mNumKeys, "num_rot_keys"); diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp index 30edc29c6e..513b7688ce 100644 --- a/indra/llcharacter/llkeyframemotionparam.cpp +++ b/indra/llcharacter/llkeyframemotionparam.cpp @@ -345,10 +345,8 @@ BOOL LLKeyframeMotionParam::loadMotions() // Load named file by concatenating the character prefix with the motion name. // Load data into a buffer to be parsed. //------------------------------------------------------------------------- - char path[LL_MAX_PATH]; /* Flawfinder: ignore */ - snprintf( path,sizeof(path), "%s_%s.llp", - gDirUtilp->getExpandedFilename(LL_PATH_MOTIONS,mCharacter->getAnimationPrefix()).c_str(), - getName().c_str() ); + std::string path = gDirUtilp->getExpandedFilename(LL_PATH_MOTIONS,mCharacter->getAnimationPrefix()) + + "_" + getName() + ".llp"; //------------------------------------------------------------------------- // open the file @@ -435,7 +433,7 @@ BOOL LLKeyframeMotionParam::loadMotions() return FALSE; } - addKeyframeMotion(strA, gAnimLibrary.stringToAnimState(strA), strB, floatA); + addKeyframeMotion(strA, gAnimLibrary.stringToAnimState(std::string(strA)), strB, floatA); if (isFirstMotion) { isFirstMotion = FALSE; diff --git a/indra/llcharacter/llmultigesture.cpp b/indra/llcharacter/llmultigesture.cpp index d8db060a0c..0de4612bae 100644 --- a/indra/llcharacter/llmultigesture.cpp +++ b/indra/llcharacter/llmultigesture.cpp @@ -124,8 +124,8 @@ BOOL LLMultiGesture::serialize(LLDataPacker& dp) const dp.packS32(GESTURE_VERSION, "version"); dp.packU8(mKey, "key"); dp.packU32(mMask, "mask"); - dp.packString(mTrigger.c_str(), "trigger"); - dp.packString(mReplaceText.c_str(), "replace"); + dp.packString(mTrigger, "trigger"); + dp.packString(mReplaceText, "replace"); S32 count = (S32)mSteps.size(); dp.packS32(count, "step_count"); @@ -269,7 +269,7 @@ S32 LLGestureStepAnimation::getMaxSerialSize() const BOOL LLGestureStepAnimation::serialize(LLDataPacker& dp) const { - dp.packString(mAnimName.c_str(), "anim_name"); + dp.packString(mAnimName, "anim_name"); dp.packUUID(mAnimAssetID, "asset_id"); dp.packU32(mFlags, "flags"); return TRUE; @@ -344,7 +344,7 @@ S32 LLGestureStepSound::getMaxSerialSize() const BOOL LLGestureStepSound::serialize(LLDataPacker& dp) const { - dp.packString(mSoundName.c_str(), "sound_name"); + dp.packString(mSoundName, "sound_name"); dp.packUUID(mSoundAssetID, "asset_id"); dp.packU32(mFlags, "flags"); return TRUE; @@ -401,7 +401,7 @@ S32 LLGestureStepChat::getMaxSerialSize() const BOOL LLGestureStepChat::serialize(LLDataPacker& dp) const { - dp.packString(mChatText.c_str(), "chat_text"); + dp.packString(mChatText, "chat_text"); dp.packU32(mFlags, "flags"); return TRUE; } diff --git a/indra/llcharacter/llstatemachine.cpp b/indra/llcharacter/llstatemachine.cpp index b3432b2b49..e38f7351d3 100644 --- a/indra/llcharacter/llstatemachine.cpp +++ b/indra/llcharacter/llstatemachine.cpp @@ -206,7 +206,7 @@ LLFSMState* LLStateDiagram::getState(U32 state_id) return NULL; } -BOOL LLStateDiagram::saveDotFile(const char* filename) +BOOL LLStateDiagram::saveDotFile(const std::string& filename) { apr_file_t* dot_file = ll_apr_file_open(filename, LL_APR_W); diff --git a/indra/llcharacter/llstatemachine.h b/indra/llcharacter/llstatemachine.h index 5ae1668a11..cbf1e12adb 100644 --- a/indra/llcharacter/llstatemachine.h +++ b/indra/llcharacter/llstatemachine.h @@ -115,7 +115,7 @@ protected: public: // save the graph in a DOT file for rendering and visualization - BOOL saveDotFile(const char* filename); + BOOL saveDotFile(const std::string& filename); }; class LLStateMachine diff --git a/indra/llcharacter/llvisualparam.cpp b/indra/llcharacter/llvisualparam.cpp index 065bf9fabd..c1a792edc7 100644 --- a/indra/llcharacter/llvisualparam.cpp +++ b/indra/llcharacter/llvisualparam.cpp @@ -89,7 +89,7 @@ BOOL LLVisualParamInfo::parseXml(LLXmlTreeNode *node) } // attribute: sex - LLString sex = "both"; + std::string sex = "both"; static LLStdStringHandle sex_string = LLXmlTree::addAttributeString("sex"); node->getFastAttributeString( sex_string, sex ); // optional if( sex == "both" ) @@ -127,7 +127,7 @@ BOOL LLVisualParamInfo::parseXml(LLXmlTreeNode *node) // JC - make sure the display name includes the capitalization in the XML file, // not the lowercased version. - LLString::toLower(mName); + LLStringUtil::toLower(mName); // attribute: label_min static LLStdStringHandle label_min_string = LLXmlTree::addAttributeString("label_min"); diff --git a/indra/llcharacter/llvisualparam.h b/indra/llcharacter/llvisualparam.h index 43911f4ed7..f2f1d23802 100644 --- a/indra/llcharacter/llvisualparam.h +++ b/indra/llcharacter/llvisualparam.h @@ -71,10 +71,10 @@ public: protected: S32 mID; // ID associated with VisualParam - LLString mName; // name (for internal purposes) - LLString mDisplayName; // name displayed to the user - LLString mMinName; // name associated with minimum value - LLString mMaxName; // name associated with maximum value + std::string mName; // name (for internal purposes) + std::string mDisplayName; // name displayed to the user + std::string mMinName; // name associated with minimum value + std::string mMaxName; // name associated with maximum value EVisualParamGroup mGroup; // morph group for separating UI controls F32 mMinWeight; // minimum weight that can be assigned to this morph target F32 mMaxWeight; // maximum weight that can be assigned to this morph target @@ -114,14 +114,14 @@ public: S32 getID() { return mID; } void setID(S32 id) { llassert(!mInfo); mID = id; } - const LLString& getName() const { return mInfo->mName; } - const LLString& getDisplayName() const { return mInfo->mDisplayName; } - const LLString& getMaxDisplayName() const { return mInfo->mMaxName; } - const LLString& getMinDisplayName() const { return mInfo->mMinName; } - - void setDisplayName(const LLString& s) { mInfo->mDisplayName = s; } - void setMaxDisplayName(const LLString& s) { mInfo->mMaxName = s; } - void setMinDisplayName(const LLString& s) { mInfo->mMinName = s; } + const std::string& getName() const { return mInfo->mName; } + const std::string& getDisplayName() const { return mInfo->mDisplayName; } + const std::string& getMaxDisplayName() const { return mInfo->mMaxName; } + const std::string& getMinDisplayName() const { return mInfo->mMinName; } + + void setDisplayName(const std::string& s) { mInfo->mDisplayName = s; } + void setMaxDisplayName(const std::string& s) { mInfo->mMaxName = s; } + void setMinDisplayName(const std::string& s) { mInfo->mMinName = s; } EVisualParamGroup getGroup() { return mInfo->mGroup; } F32 getMinWeight() { return mInfo->mMinWeight; } diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 5be3919898..e83473216a 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -129,7 +129,7 @@ void ll_apr_assert_status(apr_status_t status) } // File I/O -apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* sizep, apr_pool_t* pool) +apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, S32* sizep, apr_pool_t* pool) { apr_file_t* apr_file; apr_status_t s; @@ -160,15 +160,15 @@ apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* s return apr_file; } -apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* sizep) +apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, S32* sizep) { return ll_apr_file_open(filename, flags, sizep, NULL); } -apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, apr_pool_t* pool) +apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, apr_pool_t* pool) { return ll_apr_file_open(filename, flags, NULL, pool); } -apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags) +apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags) { return ll_apr_file_open(filename, flags, NULL, NULL); } @@ -188,7 +188,7 @@ S32 ll_apr_file_read(apr_file_t* apr_file, void *buf, S32 nbytes) } } -S32 ll_apr_file_read_ex(const LLString& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes) +S32 ll_apr_file_read_ex(const std::string& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes) { if (pool == NULL) pool = gAPRPoolp; apr_file_t* filep = ll_apr_file_open(filename, APR_READ|APR_BINARY, pool); @@ -230,7 +230,7 @@ S32 ll_apr_file_write(apr_file_t* apr_file, const void *buf, S32 nbytes) } } -S32 ll_apr_file_write_ex(const LLString& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes) +S32 ll_apr_file_write_ex(const std::string& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes) { if (pool == NULL) pool = gAPRPoolp; apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; @@ -287,7 +287,7 @@ S32 ll_apr_file_seek(apr_file_t* apr_file, apr_seek_where_t where, S32 offset) } } -bool ll_apr_file_remove(const LLString& filename, apr_pool_t* pool) +bool ll_apr_file_remove(const std::string& filename, apr_pool_t* pool) { apr_status_t s; if (pool == NULL) pool = gAPRPoolp; @@ -301,7 +301,7 @@ bool ll_apr_file_remove(const LLString& filename, apr_pool_t* pool) return true; } -bool ll_apr_file_rename(const LLString& filename, const LLString& newname, apr_pool_t* pool) +bool ll_apr_file_rename(const std::string& filename, const std::string& newname, apr_pool_t* pool) { apr_status_t s; if (pool == NULL) pool = gAPRPoolp; @@ -315,7 +315,7 @@ bool ll_apr_file_rename(const LLString& filename, const LLString& newname, apr_p return true; } -bool ll_apr_file_exists(const LLString& filename, apr_pool_t* pool) +bool ll_apr_file_exists(const std::string& filename, apr_pool_t* pool) { apr_file_t* apr_file; apr_status_t s; @@ -332,7 +332,7 @@ bool ll_apr_file_exists(const LLString& filename, apr_pool_t* pool) } } -S32 ll_apr_file_size(const LLString& filename, apr_pool_t* pool) +S32 ll_apr_file_size(const std::string& filename, apr_pool_t* pool) { apr_file_t* apr_file; apr_finfo_t info; @@ -358,7 +358,7 @@ S32 ll_apr_file_size(const LLString& filename, apr_pool_t* pool) } } -bool ll_apr_dir_make(const LLString& dirname, apr_pool_t* pool) +bool ll_apr_dir_make(const std::string& dirname, apr_pool_t* pool) { apr_status_t s; if (pool == NULL) pool = gAPRPoolp; @@ -372,7 +372,7 @@ bool ll_apr_dir_make(const LLString& dirname, apr_pool_t* pool) return true; } -bool ll_apr_dir_remove(const LLString& dirname, apr_pool_t* pool) +bool ll_apr_dir_remove(const std::string& dirname, apr_pool_t* pool) { apr_status_t s; if (pool == NULL) pool = gAPRPoolp; diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 3927d5f014..403d504932 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -130,24 +130,24 @@ typedef LLAtomic32<S32> LLAtomicS32; #define LL_APR_WB (APR_CREATE|APR_TRUNCATE|APR_WRITE|APR_BINARY) // "wb" #define LL_APR_RPB (APR_READ|APR_WRITE|APR_BINARY) // "r+b" #define LL_APR_WPB (APR_CREATE|APR_TRUNCATE|APR_READ|APR_WRITE|APR_BINARY) // "w+b" -apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* sizep, apr_pool_t* pool); -apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* sizep); -apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, apr_pool_t* pool); -apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags); +apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, S32* sizep, apr_pool_t* pool); +apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, S32* sizep); +apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, apr_pool_t* pool); +apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags); // Returns actual offset, -1 if seek fails S32 ll_apr_file_seek(apr_file_t* apr_file, apr_seek_where_t where, S32 offset); // Returns bytes read/written, 0 if read/write fails: S32 ll_apr_file_read(apr_file_t* apr_file, void* buf, S32 nbytes); -S32 ll_apr_file_read_ex(const LLString& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes); +S32 ll_apr_file_read_ex(const std::string& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes); S32 ll_apr_file_write(apr_file_t* apr_file, const void* buf, S32 nbytes); -S32 ll_apr_file_write_ex(const LLString& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes); +S32 ll_apr_file_write_ex(const std::string& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes); // returns false if failure: -bool ll_apr_file_remove(const LLString& filename, apr_pool_t* pool = NULL); -bool ll_apr_file_rename(const LLString& filename, const LLString& newname, apr_pool_t* pool = NULL); -bool ll_apr_file_exists(const LLString& filename, apr_pool_t* pool = NULL); -S32 ll_apr_file_size(const LLString& filename, apr_pool_t* pool = NULL); -bool ll_apr_dir_make(const LLString& dirname, apr_pool_t* pool = NULL); -bool ll_apr_dir_remove(const LLString& dirname, apr_pool_t* pool = NULL); +bool ll_apr_file_remove(const std::string& filename, apr_pool_t* pool = NULL); +bool ll_apr_file_rename(const std::string& filename, const std::string& newname, apr_pool_t* pool = NULL); +bool ll_apr_file_exists(const std::string& filename, apr_pool_t* pool = NULL); +S32 ll_apr_file_size(const std::string& filename, apr_pool_t* pool = NULL); +bool ll_apr_dir_make(const std::string& dirname, apr_pool_t* pool = NULL); +bool ll_apr_dir_remove(const std::string& dirname, apr_pool_t* pool = NULL); /** * @brief Function which approprately logs error or remains quiet on diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp index 06504b53fd..368c85acb0 100644 --- a/indra/llcommon/llassettype.cpp +++ b/indra/llcommon/llassettype.cpp @@ -75,7 +75,7 @@ asset_info_t asset_types[] = LLAssetType::EType LLAssetType::getType(const std::string& sin) { std::string s = sin; - LLString::toUpper(s); + LLStringUtil::toUpper(s); for (S32 idx = 0; ;idx++) { asset_info_t* info = asset_types + idx; @@ -181,9 +181,14 @@ const char* LLAssetType::lookup( LLAssetType::EType type ) // static LLAssetType::EType LLAssetType::lookup( const char* name ) { + return lookup(ll_safe_string(name)); +} + +LLAssetType::EType LLAssetType::lookup( const std::string& name ) +{ for( S32 i = 0; i < AT_COUNT; i++ ) { - if( 0 == strcmp(name, mAssetTypeNames[i]) ) + if( name == mAssetTypeNames[i] ) { // match return (EType)i; @@ -208,9 +213,14 @@ const char* LLAssetType::lookupHumanReadable(LLAssetType::EType type) // static LLAssetType::EType LLAssetType::lookupHumanReadable( const char* name ) { + return lookupHumanReadable(ll_safe_string(name)); +} + +LLAssetType::EType LLAssetType::lookupHumanReadable( const std::string& name ) +{ for( S32 i = 0; i < AT_COUNT; i++ ) { - if( 0 == strcmp(name, mAssetTypeHumanNames[i]) ) + if( name == mAssetTypeHumanNames[i] ) { // match return (EType)i; diff --git a/indra/llcommon/llassettype.h b/indra/llcommon/llassettype.h index f71e0b98cd..ad254703f0 100644 --- a/indra/llcommon/llassettype.h +++ b/indra/llcommon/llassettype.h @@ -145,11 +145,13 @@ public: }; // machine transation between type and strings - static EType lookup(const char* name); + static EType lookup(const char* name); // safe conversion to std::string, *TODO: deprecate + static EType lookup(const std::string& name); static const char* lookup(EType type); // translation from a type to a human readable form. - static EType lookupHumanReadable( const char* name ); + static EType lookupHumanReadable( const char* name ); // safe conversion to std::string, *TODO: deprecate + static EType lookupHumanReadable( const std::string& name ); static const char* lookupHumanReadable(EType type); static EDragAndDropType lookupDragAndDropType( EType ); diff --git a/indra/llcommon/llchat.h b/indra/llcommon/llchat.h index 0ae16380b4..b6f84b25b5 100644 --- a/indra/llcommon/llchat.h +++ b/indra/llcommon/llchat.h @@ -68,7 +68,7 @@ typedef enum e_chat_audible_level class LLChat { public: - LLChat(const LLString& text = LLString::null) + LLChat(const std::string& text = LLStringUtil::null) : mText(text), mFromName(), mFromID(), @@ -80,8 +80,8 @@ public: mPosAgent() { } - LLString mText; // UTF-8 line of text - LLString mFromName; // agent or object name + std::string mText; // UTF-8 line of text + std::string mFromName; // agent or object name LLUUID mFromID; // agent id or object id EChatSourceType mSourceType; EChatType mChatType; diff --git a/indra/llcommon/llcrc.cpp b/indra/llcommon/llcrc.cpp index 0836ccb66b..ea90b4f22f 100644 --- a/indra/llcommon/llcrc.cpp +++ b/indra/llcommon/llcrc.cpp @@ -163,9 +163,9 @@ void LLCRC::update(const U8* buffer, size_t buffer_size) } } -void LLCRC::update(const char* filename) +void LLCRC::update(const std::string& filename) { - if (!filename) + if (filename.empty()) { llerrs << "No filename specified" << llendl; return; diff --git a/indra/llcommon/llcrc.h b/indra/llcommon/llcrc.h index 287c1fbc41..8eab84799f 100644 --- a/indra/llcommon/llcrc.h +++ b/indra/llcommon/llcrc.h @@ -60,7 +60,7 @@ public: U32 getCRC() const; void update(U8 next_byte); void update(const U8* buffer, size_t buffer_size); - void update(const char *filename); + void update(const std::string& filename); #ifdef _DEBUG // This function runs tests to make sure the crc is diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 1d85bc0e70..b3d3122397 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -102,7 +102,7 @@ namespace { public: RecordToFile(const std::string& filename) { - mFile.open(filename.c_str(), llofstream::out | llofstream::app); + mFile.open(filename, llofstream::out | llofstream::app); if (!mFile) { llinfos << "Error setting log file to " << filename << llendl; @@ -196,7 +196,7 @@ namespace { virtual void recordMessage(LLError::ELevel level, const std::string& message) { - mBuffer.addLine(message.c_str()); + mBuffer.addLine(message); } private: @@ -305,7 +305,7 @@ namespace std::string file = dirBase + "logcontrol-dev.xml"; llstat stat_info; - if (LLFile::stat(file.c_str(), &stat_info)) { + if (LLFile::stat(file, &stat_info)) { // NB: stat returns non-zero if it can't read the file, for example // if it doesn't exist. LLFile has no better abstraction for // testing for file existence. @@ -321,7 +321,7 @@ namespace LLSD configuration; { - llifstream file(filename().c_str()); + llifstream file(filename()); if (file.is_open()) { LLSDSerialize::fromXML(configuration, file); diff --git a/indra/llcommon/llevent.cpp b/indra/llcommon/llevent.cpp index 292d0909a4..4f3962154e 100644 --- a/indra/llcommon/llevent.cpp +++ b/indra/llcommon/llevent.cpp @@ -219,7 +219,7 @@ std::vector<LLListenerEntry> LLSimpleDispatcher::getListeners() const bool LLSimpleDispatcher::fireEvent(LLPointer<LLEvent> event, LLSD filter) { std::vector<LLListenerEntry>::iterator itor; - LLString filter_string = filter.asString(); + std::string filter_string = filter.asString(); for (itor=mListeners.begin(); itor!=mListeners.end(); ++itor) { LLListenerEntry& entry = *itor; diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index 6b8f8e68c5..8f7a8ded63 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -44,7 +44,7 @@ using namespace std; // static -int LLFile::mkdir(const char* dirname, int perms) +int LLFile::mkdir(const std::string& dirname, int perms) { #if LL_WINDOWS // permissions are ignored on Windows @@ -52,12 +52,12 @@ int LLFile::mkdir(const char* dirname, int perms) llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname); return _wmkdir(utf16dirname.c_str()); #else - return ::mkdir(dirname, (mode_t)perms); + return ::mkdir(dirname.c_str(), (mode_t)perms); #endif } // static -int LLFile::rmdir(const char* dirname) +int LLFile::rmdir(const std::string& dirname) { #if LL_WINDOWS // permissions are ignored on Windows @@ -65,29 +65,29 @@ int LLFile::rmdir(const char* dirname) llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname); return _wrmdir(utf16dirname.c_str()); #else - return ::rmdir(dirname); + return ::rmdir(dirname.c_str()); #endif } // static -LLFILE* LLFile::fopen(const char* filename, const char* mode) /* Flawfinder: ignore */ +LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawfinder: ignore */ { #if LL_WINDOWS std::string utf8filename = filename; - std::string utf8mode = mode; + std::string utf8mode = std::string(mode); llutf16string utf16filename = utf8str_to_utf16str(utf8filename); llutf16string utf16mode = utf8str_to_utf16str(utf8mode); return _wfopen(utf16filename.c_str(),utf16mode.c_str()); #else - return ::fopen(filename,mode); /* Flawfinder: ignore */ + return ::fopen(filename.c_str(),mode); /* Flawfinder: ignore */ #endif } -LLFILE* LLFile::_fsopen(const char* filename, const char* mode, int sharingFlag) +LLFILE* LLFile::_fsopen(const std::string& filename, const char* mode, int sharingFlag) { #if LL_WINDOWS std::string utf8filename = filename; - std::string utf8mode = mode; + std::string utf8mode = std::string(mode); llutf16string utf16filename = utf8str_to_utf16str(utf8filename); llutf16string utf16mode = utf8str_to_utf16str(utf8mode); return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag); @@ -97,18 +97,18 @@ LLFILE* LLFile::_fsopen(const char* filename, const char* mode, int sharingFlag) #endif } -int LLFile::remove(const char* filename) +int LLFile::remove(const std::string& filename) { #if LL_WINDOWS std::string utf8filename = filename; llutf16string utf16filename = utf8str_to_utf16str(utf8filename); return _wremove(utf16filename.c_str()); #else - return ::remove(filename); + return ::remove(filename.c_str()); #endif } -int LLFile::rename(const char* filename, const char* newname) +int LLFile::rename(const std::string& filename, const std::string& newname) { #if LL_WINDOWS std::string utf8filename = filename; @@ -117,29 +117,29 @@ int LLFile::rename(const char* filename, const char* newname) llutf16string utf16newname = utf8str_to_utf16str(utf8newname); return _wrename(utf16filename.c_str(),utf16newname.c_str()); #else - return ::rename(filename,newname); + return ::rename(filename.c_str(),newname.c_str()); #endif } -int LLFile::stat(const char* filename, llstat* filestatus) +int LLFile::stat(const std::string& filename, llstat* filestatus) { #if LL_WINDOWS std::string utf8filename = filename; llutf16string utf16filename = utf8str_to_utf16str(utf8filename); return _wstat(utf16filename.c_str(),filestatus); #else - return ::stat(filename,filestatus); + return ::stat(filename.c_str(),filestatus); #endif } -bool LLFile::isdir(const char *filename) +bool LLFile::isdir(const std::string& filename) { llstat st; return stat(filename, &st) == 0 && S_ISDIR(st.st_mode); } -bool LLFile::isfile(const char *filename) +bool LLFile::isfile(const std::string& filename) { llstat st; @@ -181,7 +181,7 @@ const char *LLFile::tmpdir() #if USE_LLFILESTREAMS -LLFILE * LLFile::_Fiopen(const char *filename, std::ios::openmode mode,int) // protection currently unused +LLFILE * LLFile::_Fiopen(const std::string& filename, std::ios::openmode mode,int) // protection currently unused { // open a file static const char *mods[] = { // fopen mode strings corresponding to valid[i] @@ -250,7 +250,7 @@ void llifstream::close() } } -void llifstream::open(const char* _Filename, /* Flawfinder: ignore */ +void llifstream::open(const std::string& _Filename, /* Flawfinder: ignore */ ios_base::openmode _Mode, int _Prot) { // open a C stream with specified mode @@ -282,7 +282,7 @@ llifstream::~llifstream() delete _Filebuffer; } -llifstream::llifstream(const char *_Filename, +llifstream::llifstream(const std::string& _Filename, ios_base::openmode _Mode, int _Prot) : std::basic_istream< char , std::char_traits< char > >(NULL,true),_Filebuffer(NULL),_ShouldClose(false) @@ -301,7 +301,7 @@ bool llofstream::is_open() const return false; } -void llofstream::open(const char* _Filename, /* Flawfinder: ignore */ +void llofstream::open(const std::string& _Filename, /* Flawfinder: ignore */ ios_base::openmode _Mode, int _Prot) { // open a C stream with specified mode @@ -327,7 +327,7 @@ void llofstream::close() } } -llofstream::llofstream(const char *_Filename, +llofstream::llofstream(const std::string& _Filename, std::ios_base::openmode _Mode, int _Prot) : std::basic_ostream<char,std::char_traits < char > >(NULL,true),_Filebuffer(NULL),_ShouldClose(false) diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h index bd51ac2aa9..a196dad814 100644 --- a/indra/llcommon/llfile.h +++ b/indra/llcommon/llfile.h @@ -67,24 +67,27 @@ typedef struct stat llstat; # define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) #endif +#include "llstring.h" // safe char* -> std::string conversion + class LLFile { public: // All these functions take UTF8 path/filenames. - static LLFILE* fopen(const char* filename,const char* accessmode); /* Flawfinder: ignore */ - static LLFILE* _fsopen(const char* filename,const char* accessmode,int sharingFlag); + static LLFILE* fopen(const std::string& filename,const char* accessmode); /* Flawfinder: ignore */ + static LLFILE* _fsopen(const std::string& filename,const char* accessmode,int sharingFlag); // perms is a permissions mask like 0777 or 0700. In most cases it will // be overridden by the user's umask. It is ignored on Windows. - static int mkdir(const char* filename, int perms = 0700); - - static int rmdir(const char* filename); - static int remove(const char* filename); - static int rename(const char* filename,const char* newname); - static int stat(const char* filename,llstat* file_status); - static bool isdir(const char* filename); - static bool isfile(const char* filename); - static LLFILE * _Fiopen(const char *filename, std::ios::openmode mode,int); // protection currently unused + static int mkdir(const std::string& filename, int perms = 0700); + + static int rmdir(const std::string& filename); + static int remove(const std::string& filename); + static int rename(const std::string& filename,const std::string& newname); + static int stat(const std::string& filename,llstat* file_status); + static bool isdir(const std::string& filename); + static bool isfile(const std::string& filename); + static LLFILE * _Fiopen(const std::string& filename, std::ios::openmode mode,int); // protection currently unused + static const char * tmpdir(); }; @@ -104,7 +107,7 @@ public: { // construct unopened } - explicit llifstream(const char *_Filename, + explicit llifstream(const std::string& _Filename, ios_base::openmode _Mode = ios_base::in, int _Prot = (int)ios_base::_Openprot); @@ -121,7 +124,7 @@ public: return _Filebuffer; } bool is_open() const; - void open(const char* _Filename, /* Flawfinder: ignore */ + void open(const std::string& _Filename, /* Flawfinder: ignore */ ios_base::openmode _Mode = ios_base::in, int _Prot = (int)ios_base::_Openprot); void close(); @@ -144,7 +147,7 @@ public: { // construct unopened } - explicit llofstream(const char *_Filename, + explicit llofstream(const std::string& _Filename, std::ios_base::openmode _Mode = ios_base::out, int _Prot = (int)std::ios_base::_Openprot); @@ -165,7 +168,7 @@ public: bool is_open() const; - void open(const char *_Filename,ios_base::openmode _Mode = ios_base::out,int _Prot = (int)ios_base::_Openprot); /* Flawfinder: ignore */ + void open(const std::string& _Filename,ios_base::openmode _Mode = ios_base::out,int _Prot = (int)ios_base::_Openprot); /* Flawfinder: ignore */ void close(); @@ -178,8 +181,45 @@ private: #else //Use standard file streams on non windows platforms -#define llifstream std::ifstream -#define llofstream std::ofstream +//#define llifstream std::ifstream +//#define llofstream std::ofstream + +class llifstream : public std::ifstream +{ +public: + llifstream() : std::ifstream() + { + } + + explicit llifstream(const std::string& _Filename, std::_Ios_Openmode _Mode = in) + : std::ifstream(_Filename.c_str(), _Mode) + { + } + void open(const std::string& _Filename, std::_Ios_Openmode _Mode = in) /* Flawfinder: ignore */ + { + std::ifstream::open(_Filename.c_str(), _Mode); + } +}; + + +class llofstream : public std::ofstream +{ +public: + llofstream() : std::ofstream() + { + } + + explicit llofstream(const std::string& _Filename, std::_Ios_Openmode _Mode = out) + : std::ofstream(_Filename.c_str(), _Mode) + { + } + + void open(const std::string& _Filename, std::_Ios_Openmode _Mode = out) /* Flawfinder: ignore */ + { + std::ofstream::open(_Filename.c_str(), _Mode); + } + +}; #endif diff --git a/indra/llcommon/llfixedbuffer.cpp b/indra/llcommon/llfixedbuffer.cpp index 44bb953f80..fde4db98a1 100644 --- a/indra/llcommon/llfixedbuffer.cpp +++ b/indra/llcommon/llfixedbuffer.cpp @@ -54,7 +54,7 @@ void LLFixedBuffer::clear() } -void LLFixedBuffer::addLine(const LLString& utf8line) +void LLFixedBuffer::addLine(const std::string& utf8line) { LLWString wstring = utf8str_to_wstring(utf8line); LLFixedBuffer::addLine(wstring); diff --git a/indra/llcommon/llfixedbuffer.h b/indra/llcommon/llfixedbuffer.h index 148c0e60db..0a23fb30d1 100644 --- a/indra/llcommon/llfixedbuffer.h +++ b/indra/llcommon/llfixedbuffer.h @@ -52,7 +52,7 @@ public: std::deque<S32> mLineLengths; void clear(); // Clear the buffer, and reset it. - virtual void addLine(const LLString& utf8line); + virtual void addLine(const std::string& utf8line); virtual void addLine(const LLWString& line); // Get lines currently in the buffer, up to max_size chars, max_length lines diff --git a/indra/llcommon/llliveappconfig.cpp b/indra/llcommon/llliveappconfig.cpp index 76432770a3..418a34b662 100644 --- a/indra/llcommon/llliveappconfig.cpp +++ b/indra/llcommon/llliveappconfig.cpp @@ -51,7 +51,7 @@ void LLLiveAppConfig::loadFile() { llinfos << "LLLiveAppConfig::loadFile(): reading from " << filename() << llendl; - llifstream file(filename().c_str()); + llifstream file(filename()); LLSD config; if (file.is_open()) { diff --git a/indra/llcommon/lllivefile.cpp b/indra/llcommon/lllivefile.cpp index cb3ce0f8d2..8c625bce90 100644 --- a/indra/llcommon/lllivefile.cpp +++ b/indra/llcommon/lllivefile.cpp @@ -93,7 +93,7 @@ bool LLLiveFile::Impl::check() // Stat the file to see if it exists and when it was last modified. llstat stat_data; - int res = LLFile::stat(mFilename.c_str(), &stat_data); + int res = LLFile::stat(mFilename, &stat_data); if (res) { diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 29a3cf32a8..87c6e57fdd 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -2216,12 +2216,12 @@ bool CProcessor::CPUInfoToText(char *strBuffer, unsigned int uiMaxLen) return true; } -// bool CProcessor::WriteInfoTextFile(const char *strFilename) +// bool CProcessor::WriteInfoTextFile(const std::string& strFilename) // =========================================================== // Takes use of CProcessor::CPUInfoToText and saves the string to a // file /////////////////////////////////////////////////////////////////// -bool CProcessor::WriteInfoTextFile(const char *strFilename) +bool CProcessor::WriteInfoTextFile(const std::string& strFilename) { char buf[16384]; /* Flawfinder: ignore */ diff --git a/indra/llcommon/llprocessor.h b/indra/llcommon/llprocessor.h index 6b966c5339..30bc14d6ce 100644 --- a/indra/llcommon/llprocessor.h +++ b/indra/llcommon/llprocessor.h @@ -188,7 +188,7 @@ public: F64 GetCPUFrequency(unsigned int uiMeasureMSecs); const ProcessorInfo *GetCPUInfo(); bool CPUInfoToText(char *strBuffer, unsigned int uiMaxLen); - bool WriteInfoTextFile(const char *strFilename); + bool WriteInfoTextFile(const std::string& strFilename); }; diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 307d73608c..0382fb1360 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -394,7 +394,7 @@ std::ostream& operator<<(std::ostream& s, const LLSD& llsd); - as UTF8 encoded strings (making not like UUID<->String) - as Base64 or Base96 encoded (making like UUID<->String) - Conversions to std::string and LLUUID do not result in easy assignment - to std::string, LLString or LLUUID due to non-unique conversion paths + to std::string, std::string or LLUUID due to non-unique conversion paths */ #endif // LL_LLSD_NEW_H diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index 6bb75439a2..d496230dd8 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -1230,8 +1230,7 @@ void LLSDFormatter::realFormat(const std::string& format) void LLSDFormatter::formatReal(LLSD::Real real, std::ostream& ostr) const { - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buffer, MAX_STRING, mRealFormat.c_str(), real); /* Flawfinder: ignore */ + std::string buffer = llformat(mRealFormat.c_str(), real); ostr << buffer; } diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp index 592dfc9bc0..e23f765957 100644 --- a/indra/llcommon/llsdserialize_xml.cpp +++ b/indra/llcommon/llsdserialize_xml.cpp @@ -63,7 +63,7 @@ S32 LLSDXMLFormatter::format(const LLSD& data, std::ostream& ostr, U32 options) { std::streamsize old_precision = ostr.precision(25); - LLString post = ""; + std::string post; if (options & LLSDFormatter::OPTIONS_PRETTY) { post = "\n"; @@ -79,8 +79,8 @@ S32 LLSDXMLFormatter::format(const LLSD& data, std::ostream& ostr, U32 options) S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 options, U32 level) const { S32 format_count = 1; - LLString pre = ""; - LLString post = ""; + std::string pre; + std::string post; if (options & LLSDFormatter::OPTIONS_PRETTY) { diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index 6f26447695..137539cc04 100644 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -145,12 +145,11 @@ LLSD ll_binary_from_string(const LLSD& sd) { std::vector<U8> binary_value; - LLString string_value = sd.asString(); - const char* string_p = string_value.c_str(); - while (*string_p) + std::string string_value = sd.asString(); + for (std::string::iterator iter = string_value.begin(); + iter != string_value.end(); ++iter) { - binary_value.push_back(*string_p); - string_p++; + binary_value.push_back(*iter); } binary_value.push_back('\0'); diff --git a/indra/llcommon/llsecondlifeurls.cpp b/indra/llcommon/llsecondlifeurls.cpp index bf09453c16..207d704f2a 100644 --- a/indra/llcommon/llsecondlifeurls.cpp +++ b/indra/llcommon/llsecondlifeurls.cpp @@ -32,56 +32,56 @@ #include "linden_common.h" #include "llsecondlifeurls.h" -const char CREATE_ACCOUNT_URL[] = - "http://secondlife.com/registration/"; +const std::string CREATE_ACCOUNT_URL ( + "http://secondlife.com/registration/"); -const char MANAGE_ACCOUNT[] = - "http://secondlife.com/account/"; +const std::string MANAGE_ACCOUNT ( + "http://secondlife.com/account/"); -const char AUCTION_URL[] = - "http://secondlife.com/auctions/auction-detail.php?id="; +const std::string AUCTION_URL ( + "http://secondlife.com/auctions/auction-detail.php?id="); -const char EVENTS_URL[] = - "http://secondlife.com/events/"; +const std::string EVENTS_URL ( + "http://secondlife.com/events/"); -const char TIER_UP_URL[] = - "http://secondlife.com/app/landtier"; +const std::string TIER_UP_URL ( + "http://secondlife.com/app/landtier"); -const char LAND_URL[] = - "http://secondlife.com/app/landtier"; +const std::string LAND_URL ( + "http://secondlife.com/app/landtier"); -const char UPGRADE_TO_PREMIUM_URL[] = - "http://secondlife.com/app/upgrade/"; +const std::string UPGRADE_TO_PREMIUM_URL ( + "http://secondlife.com/app/upgrade/"); -const char DIRECTX_9_URL[] = - "http://secondlife.com/support/"; +const std::string DIRECTX_9_URL ( + "http://secondlife.com/support/"); -const char AMD_AGP_URL[] = - "http://secondlife.com/support/"; +const std::string AMD_AGP_URL ( + "http://secondlife.com/support/"); -const char VIA_URL[] = - "http://secondlife.com/support/"; +const std::string VIA_URL ( + "http://secondlife.com/support/"); -const char SUPPORT_URL[] = - "http://secondlife.com/support/"; +const std::string SUPPORT_URL ( + "http://secondlife.com/support/"); -const char INTEL_CHIPSET_URL[] = - "http://secondlife.com/support/"; +const std::string INTEL_CHIPSET_URL ( + "http://secondlife.com/support/"); -const char SIS_CHIPSET_URL[] = - "http://secondlife.com/support/"; +const std::string SIS_CHIPSET_URL ( + "http://secondlife.com/support/"); -const char BLOGS_URL[] = - "http://blog.secondlife.com/"; +const std::string BLOGS_URL ( + "http://blog.secondlife.com/"); -const char BUY_CURRENCY_URL[] = - "http://secondlife.com/app/currency/"; +const std::string BUY_CURRENCY_URL ( + "http://secondlife.com/app/currency/"); -const char LSL_DOC_URL[] = - "http://secondlife.com/app/lsldoc/"; +const std::string LSL_DOC_URL ( + "http://secondlife.com/app/lsldoc/"); -const char SL_KB_URL[] = - "http://secondlife.com/knowledgebase/"; +const std::string SL_KB_URL ( + "http://secondlife.com/knowledgebase/"); -const char RELEASE_NOTES[] = "releasenotes.txt"; +const std::string RELEASE_NOTES ( "releasenotes.txt"); diff --git a/indra/llcommon/llsecondlifeurls.h b/indra/llcommon/llsecondlifeurls.h index b8d8aa2402..0847c8378b 100644 --- a/indra/llcommon/llsecondlifeurls.h +++ b/indra/llcommon/llsecondlifeurls.h @@ -33,46 +33,46 @@ #define LL_LLSECONDLIFEURLS_H // Account registration web page -extern const char CREATE_ACCOUNT_URL[]; +extern const std::string CREATE_ACCOUNT_URL; // Manage Account -extern const char MANAGE_ACCOUNT[]; +extern const std::string MANAGE_ACCOUNT; -extern const char AUCTION_URL[]; +extern const std::string AUCTION_URL; -extern const char EVENTS_URL[]; +extern const std::string EVENTS_URL; // Tier up to a new land level. -extern const char TIER_UP_URL[]; +extern const std::string TIER_UP_URL; // Tier up to a new land level. -extern const char LAND_URL[]; +extern const std::string LAND_URL; // Upgrade from basic membership to premium membership -extern const char UPGRADE_TO_PREMIUM_URL[]; +extern const std::string UPGRADE_TO_PREMIUM_URL; // How to get DirectX 9 -extern const char DIRECTX_9_URL[]; +extern const std::string DIRECTX_9_URL; // Out of date VIA chipset -extern const char VIA_URL[]; +extern const std::string VIA_URL; // Support URL -extern const char SUPPORT_URL[]; +extern const std::string SUPPORT_URL; // Linden Blogs page -extern const char BLOGS_URL[]; +extern const std::string BLOGS_URL; // Currency page -extern const char BUY_CURRENCY_URL[]; +extern const std::string BUY_CURRENCY_URL; // LSL script wiki -extern const char LSL_DOC_URL[]; +extern const std::string LSL_DOC_URL; // SL KnowledgeBase page -extern const char SL_KB_URL[]; +extern const std::string SL_KB_URL; // Local Url Release Notes -extern const char RELEASE_NOTES[]; +extern const std::string RELEASE_NOTES; #endif diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 3a8756a31f..0d50919e26 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -1,6 +1,6 @@ /** * @file llstring.cpp - * @brief String utility functions and the LLString class. + * @brief String utility functions and the std::string class. * * $LicenseInfo:firstyear=2001&license=viewergpl$ * @@ -47,6 +47,12 @@ std::string ll_safe_string(const char* in) return std::string(); } +std::string ll_safe_string(const char* in, S32 maxlen) +{ + if(in) return std::string(in, maxlen); + return std::string(); +} + U8 hex_as_nybble(char hex) { if((hex >= '0') && (hex <= '9')) @@ -65,7 +71,7 @@ U8 hex_as_nybble(char hex) } -bool _read_file_into_string(std::string& str, const char* filename) +bool _read_file_into_string(std::string& str, const std::string& filename) { llifstream ifs(filename, llifstream::binary); if (!ifs.is_open()) @@ -174,20 +180,6 @@ S32 utf16chars_to_wchar(const U16* inchars, llwchar* outchar) return inchars - base; } -S32 utf16chars_to_utf8chars(const U16* inchars, char* outchars, S32* nchars8p) -{ - // Get 32 bit char32 - llwchar char32; - S32 nchars16 = utf16chars_to_wchar(inchars, &char32); - // Convert to utf8 - S32 nchars8 = wchar_to_utf8chars(char32, outchars); - if (nchars8p) - { - *nchars8p = nchars8; - } - return nchars16; -} - llutf16string wstring_to_utf16str(const LLWString &utf32str, S32 len) { llutf16string out; @@ -216,7 +208,7 @@ llutf16string wstring_to_utf16str(const LLWString &utf32str) return wstring_to_utf16str(utf32str, len); } -llutf16string utf8str_to_utf16str ( const LLString& utf8str ) +llutf16string utf8str_to_utf16str ( const std::string& utf8str ) { LLWString wstr = utf8str_to_wstring ( utf8str ); return wstring_to_utf16str ( wstr ); @@ -492,210 +484,10 @@ std::string utf16str_to_utf8str(const llutf16string& utf16str, S32 len) return wstring_to_utf8str(utf16str_to_wstring(utf16str, len), len); } - -//LLWString wstring_truncate(const LLWString &wstr, const S32 max_len) -//{ -// return wstr.substr(0, llmin((S32)wstr.length(), max_len)); -//} -// -// -//LLWString wstring_trim(const LLWString &wstr) -//{ -// LLWString outstr; -// outstr = wstring_trimhead(wstr); -// outstr = wstring_trimtail(outstr); -// return outstr; -//} -// -// -//LLWString wstring_trimhead(const LLWString &wstr) -//{ -// if(wstr.empty()) -// { -// return wstr; -// } -// -// S32 i = 0; -// while((i < (S32)wstr.length()) && iswspace(wstr[i])) -// { -// i++; -// } -// return wstr.substr(i, wstr.length() - i); -//} -// -// -//LLWString wstring_trimtail(const LLWString &wstr) -//{ -// if(wstr.empty()) -// { -// return wstr; -// } -// -// S32 len = (S32)wstr.length(); -// -// S32 i = len - 1; -// while (i >= 0 && iswspace(wstr[i])) -// { -// i--; -// } -// -// if (i >= 0) -// { -// return wstr.substr(0, i + 1); -// } -// return wstr; -//} -// -// -//LLWString wstring_copyinto(const LLWString &dest, const LLWString &src, const S32 insert_offset) -//{ -// llassert( insert_offset <= (S32)dest.length() ); -// -// LLWString out_str = dest.substr(0, insert_offset); -// out_str += src; -// LLWString tail = dest.substr(insert_offset); -// out_str += tail; -// -// return out_str; -//} - - -//LLWString wstring_detabify(const LLWString &wstr, const S32 num_spaces) -//{ -// LLWString out_str; -// // Replace tabs with spaces -// for (S32 i = 0; i < (S32)wstr.length(); i++) -// { -// if (wstr[i] == '\t') -// { -// for (S32 j = 0; j < num_spaces; j++) -// out_str += ' '; -// } -// else -// { -// out_str += wstr[i]; -// } -// } -// return out_str; -//} - - -//LLWString wstring_makeASCII(const LLWString &wstr) -//{ -// // Replace non-ASCII chars with replace_char -// LLWString out_str = wstr; -// for (S32 i = 0; i < (S32)out_str.length(); i++) -// { -// if (out_str[i] > 0x7f) -// { -// out_str[i] = LL_UNKNOWN_CHAR; -// } -// } -// return out_str; -//} - - -//LLWString wstring_substChar(const LLWString &wstr, const llwchar target_char, const llwchar replace_char) -//{ -// // Replace all occurences of target_char with replace_char -// LLWString out_str = wstr; -// for (S32 i = 0; i < (S32)out_str.length(); i++) -// { -// if (out_str[i] == target_char) -// { -// out_str[i] = replace_char; -// } -// } -// return out_str; -//} -// -// -//LLWString wstring_tolower(const LLWString &wstr) -//{ -// LLWString out_str = wstr; -// for (S32 i = 0; i < (S32)out_str.length(); i++) -// { -// out_str[i] = towlower(out_str[i]); -// } -// return out_str; -//} -// -// -//LLWString wstring_convert_to_lf(const LLWString &wstr) -//{ -// const llwchar CR = 13; -// // Remove carriage returns from string with CRLF -// LLWString out_str; -// -// for (S32 i = 0; i < (S32)wstr.length(); i++) -// { -// if (wstr[i] != CR) -// { -// out_str += wstr[i]; -// } -// } -// return out_str; -//} -// -// -//LLWString wstring_convert_to_crlf(const LLWString &wstr) -//{ -// const llwchar LF = 10; -// const llwchar CR = 13; -// // Remove carriage returns from string with CRLF -// LLWString out_str; -// -// for (S32 i = 0; i < (S32)wstr.length(); i++) -// { -// if (wstr[i] == LF) -// { -// out_str += CR; -// } -// out_str += wstr[i]; -// } -// return out_str; -//} - - -//S32 wstring_compare_insensitive(const LLWString &lhs, const LLWString &rhs) -//{ -// -// if (lhs == rhs) -// { -// return 0; -// } -// -// if (lhs.empty()) -// { -// return rhs.empty() ? 0 : 1; -// } -// -// if (rhs.empty()) -// { -// return -1; -// } -// -//#ifdef LL_LINUX -// // doesn't work because gcc 2.95 doesn't correctly implement c_str(). Sigh... -// llerrs << "wstring_compare_insensitive doesn't work on Linux!" << llendl; -// return 0; -//#else -// LLWString lhs_lower = lhs; -// LLWString::toLower(lhs_lower); -// std::string lhs_lower = wstring_to_utf8str(lhs_lower); -// LLWString rhs_lower = lhs; -// LLWString::toLower(rhs_lower); -// std::string rhs_lower = wstring_to_utf8str(rhs_lower); -// -// return strcmp(lhs_lower.c_str(), rhs_lower.c_str()); -//#endif -//} - - std::string utf8str_trim(const std::string& utf8str) { LLWString wstr = utf8str_to_wstring(utf8str); - LLWString::trim(wstr); + LLWStringUtil::trim(wstr); return wstring_to_utf8str(wstr); } @@ -703,7 +495,7 @@ std::string utf8str_trim(const std::string& utf8str) std::string utf8str_tolower(const std::string& utf8str) { LLWString out_str = utf8str_to_wstring(utf8str); - LLWString::toLower(out_str); + LLWStringUtil::toLower(out_str); return wstring_to_utf8str(out_str); } @@ -712,7 +504,7 @@ S32 utf8str_compare_insensitive(const std::string& lhs, const std::string& rhs) { LLWString wlhs = utf8str_to_wstring(lhs); LLWString wrhs = utf8str_to_wstring(rhs); - return LLWString::compareInsensitive(wlhs.c_str(), wrhs.c_str()); + return LLWStringUtil::compareInsensitive(wlhs, wrhs); } std::string utf8str_truncate(const std::string& utf8str, const S32 max_len) @@ -756,7 +548,7 @@ std::string utf8str_substChar( const llwchar replace_char) { LLWString wstr = utf8str_to_wstring(utf8str); - LLWString::replaceChar(wstr, target_char, replace_char); + LLWStringUtil::replaceChar(wstr, target_char, replace_char); //wstr = wstring_substChar(wstr, target_char, replace_char); return wstring_to_utf8str(wstr); } @@ -764,7 +556,7 @@ std::string utf8str_substChar( std::string utf8str_makeASCII(const std::string& utf8str) { LLWString wstr = utf8str_to_wstring(utf8str); - LLWString::_makeASCII(wstr); + LLWStringUtil::_makeASCII(wstr); return wstring_to_utf8str(wstr); } @@ -964,19 +756,19 @@ namespace LLStringFn #ifdef _DEBUG template<class T> -void LLStringBase<T>::testHarness() +void LLStringUtilBase<T>::testHarness() { - LLString s1; + std::string s1; llassert( s1.c_str() == NULL ); llassert( s1.size() == 0 ); llassert( s1.empty() ); - LLString s2( "hello"); + std::string s2( "hello"); llassert( !strcmp( s2.c_str(), "hello" ) ); llassert( s2.size() == 5 ); llassert( !s2.empty() ); - LLString s3( s2 ); + std::string s3( s2 ); llassert( "hello" == s2 ); llassert( s2 == "hello" ); @@ -985,12 +777,12 @@ void LLStringBase<T>::testHarness() llassert( "gello" != s2 ); llassert( s2 != "gello" ); - LLString s4 = s2; + std::string s4 = s2; llassert( !s4.empty() ); s4.empty(); llassert( s4.empty() ); - LLString s5(""); + std::string s5(""); llassert( s5.empty() ); llassert( isValidIndex(s5, 0) ); @@ -1004,8 +796,8 @@ void LLStringBase<T>::testHarness() llassert( s4 == "hello again!hello again!" ); - LLString s6 = s2 + " " + s2; - LLString s7 = s6; + std::string s6 = s2 + " " + s2; + std::string s7 = s6; llassert( s6 == s7 ); llassert( !( s6 != s7) ); llassert( !(s6 < s7) ); @@ -1028,10 +820,10 @@ void LLStringBase<T>::testHarness() s2.insert( 1, "awn, don't yel"); llassert( s2 == "yawn, don't yell"); - LLString s8 = s2.substr( 6, 5 ); + std::string s8 = s2.substr( 6, 5 ); llassert( s8 == "don't" ); - LLString s9 = " \t\ntest \t\t\n "; + std::string s9 = " \t\ntest \t\t\n "; trim(s9); llassert( s9 == "test" ); @@ -1046,17 +838,17 @@ void LLStringBase<T>::testHarness() llassert( s9 == "abc123&*(abc" ); - LLString s10( 10, 'x' ); + std::string s10( 10, 'x' ); llassert( s10 == "xxxxxxxxxx" ); - LLString s11( "monkey in the middle", 7, 2 ); + std::string s11( "monkey in the middle", 7, 2 ); llassert( s11 == "in" ); - LLString s12; //empty + std::string s12; //empty s12 += "foo"; llassert( s12 == "foo" ); - LLString s13; //empty + std::string s13; //empty s13 += 'f'; llassert( s13 == "f" ); } diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 18cfe4b64c..50681b7967 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -1,6 +1,6 @@ /** * @file llstring.h - * @brief String utility functions and LLString class. + * @brief String utility functions and std::string class. * * $LicenseInfo:firstyear=2001&license=viewergpl$ * @@ -155,50 +155,19 @@ public: static BOOL isDigit(llwchar a) { return iswdigit(a) != 0; } }; -//RN: I used a templated base class instead of a pure interface class to minimize code duplication -// but it might be worthwhile to just go with two implementations (LLString and LLWString) of -// an interface class, unless we can think of a good reason to have a std::basic_string polymorphic base - -// **************************************************************** -// NOTA BENE: do *NOT* dynamically allocate memory inside of LLStringBase as the {*()^#%*)#%W^*)#%*)STL implentation -// of basic_string doesn't provide a virtual destructor. If we need to allocate resources specific to LLString -// then we should either customize std::basic_string to linden::basic_string or change LLString to be a wrapper -// that contains an instance of std::basic_string. Similarly, overriding methods defined in std::basic_string will *not* -// be called in a polymorphic manner (passing an instance of basic_string to a particular function) -// **************************************************************** - template <class T> -class LLStringBase : public std::basic_string<T> +class LLStringUtilBase { public: typedef typename std::basic_string<T>::size_type size_type; - // naming convention follows those set for LLUUID -// static LLStringBase null; // deprecated for std::string compliance -// static LLStringBase zero_length; // deprecated for std::string compliance - - - // standard constructors - LLStringBase() : std::basic_string<T>() {} - LLStringBase(const LLStringBase& s): std::basic_string<T>(s) {} - LLStringBase(const std::basic_string<T>& s) : std::basic_string<T>(s) {} - LLStringBase(const std::basic_string<T>& s, size_type pos, size_type n = std::basic_string<T>::npos) - : std::basic_string<T>(s, pos, n) {} - LLStringBase(size_type count, const T& c) : std::basic_string<T>() { assign(count, c);} - // custom constructors - LLStringBase(const T* s); - LLStringBase(const T* s, size_type n); - LLStringBase(const T* s, size_type pos, size_type n ); - - bool operator==(const T* _Right) const { return _Right ? (std::basic_string<T>::compare(_Right) == 0) : this->empty(); } - public: ///////////////////////////////////////////////////////////////////////////////////////// // Static Utility functions that operate on std::strings - static LLStringBase null; + static std::basic_string<T> null; - typedef std::map<std::string, std::string> format_map_t; + typedef std::map<std::basic_string<T>, std::basic_string<T> > format_map_t; static S32 format(std::basic_string<T>& s, const format_map_t& fmt_map); static BOOL isValidIndex(const std::basic_string<T>& string, size_type i) @@ -230,8 +199,8 @@ public: /** * @brief Unsafe way to make ascii characters. You should probably * only call this when interacting with the host operating system. - * The 1 byte LLString does not work correctly. - * The 2 and 4 byte LLString probably work, so LLWString::_makeASCII + * The 1 byte std::string does not work correctly. + * The 2 and 4 byte std::string probably work, so LLWStringUtil::_makeASCII * should work. */ static void _makeASCII(std::basic_string<T>& string); @@ -253,11 +222,13 @@ public: // Like strcmp but also handles empty strings. Uses // current locale. static S32 compareStrings(const T* lhs, const T* rhs); + static S32 compareStrings(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs); // case insensitive version of above. Uses current locale on // Win32, and falls back to a non-locale aware comparison on // Linux. static S32 compareInsensitive(const T* lhs, const T* rhs); + static S32 compareInsensitive(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs); // Case sensitive comparison with good handling of numbers. Does not use current locale. // a.k.a. strdictcmp() @@ -284,21 +255,21 @@ public: }; -template<class T> LLStringBase<T> LLStringBase<T>::null; +template<class T> std::basic_string<T> LLStringUtilBase<T>::null; -typedef LLStringBase<char> LLString; -typedef LLStringBase<llwchar> LLWString; +typedef LLStringUtilBase<char> LLStringUtil; +typedef LLStringUtilBase<llwchar> LLWStringUtil; +typedef std::basic_string<llwchar> LLWString; //@ Use this where we want to disallow input in the form of "foo" // This is used to catch places where english text is embedded in the code // instead of in a translatable XUI file. -class LLStringExplicit : public LLString +class LLStringExplicit : public std::string { public: - explicit LLStringExplicit(const char* s) : LLString(s) {} - LLStringExplicit(const LLString& s) : LLString(s) {} - LLStringExplicit(const std::string& s) : LLString(s) {} - LLStringExplicit(const std::string& s, size_type pos, size_type n = std::string::npos) : LLString(s, pos, n) {} + explicit LLStringExplicit(const char* s) : std::string(s) {} + LLStringExplicit(const std::string& s) : std::string(s) {} + LLStringExplicit(const std::string& s, size_type pos, size_type n = std::string::npos) : std::string(s, pos, n) {} }; struct LLDictionaryLess @@ -306,7 +277,7 @@ struct LLDictionaryLess public: bool operator()(const std::string& a, const std::string& b) { - return (LLString::precedesDict(a, b) ? true : false); + return (LLStringUtil::precedesDict(a, b) ? true : false); } }; @@ -335,6 +306,7 @@ inline std::string chop_tail_copy( * pointer is NULL. */ std::string ll_safe_string(const char* in); +std::string ll_safe_string(const char* in, S32 maxlen); /** * @brief This translates a nybble stored as a hex value from 0-f back @@ -351,7 +323,7 @@ U8 hex_as_nybble(char hex); * @param filename The full name of the file to read. * @return Returns true on success. If false, str is unmodified. */ -bool _read_file_into_string(std::string& str, const char* filename); +bool _read_file_into_string(std::string& str, const std::string& filename); /** * Unicode support @@ -373,20 +345,17 @@ LLWString utf16str_to_wstring(const llutf16string &utf16str); llutf16string wstring_to_utf16str(const LLWString &utf32str, S32 len); llutf16string wstring_to_utf16str(const LLWString &utf32str); -llutf16string utf8str_to_utf16str ( const LLString& utf8str, S32 len); -llutf16string utf8str_to_utf16str ( const LLString& utf8str ); +llutf16string utf8str_to_utf16str ( const std::string& utf8str, S32 len); +llutf16string utf8str_to_utf16str ( const std::string& utf8str ); LLWString utf8str_to_wstring(const std::string &utf8str, S32 len); LLWString utf8str_to_wstring(const std::string &utf8str); // Same function, better name. JC inline LLWString utf8string_to_wstring(const std::string& utf8_string) { return utf8str_to_wstring(utf8_string); } -// Special hack for llfilepicker.cpp: -S32 utf16chars_to_utf8chars(const U16* inchars, char* outchars, S32* nchars8 = 0); -S32 utf16chars_to_wchar(const U16* inchars, llwchar* outchar); +// S32 wchar_to_utf8chars(llwchar inchar, char* outchars); -// std::string wstring_to_utf8str(const LLWString &utf32str, S32 len); std::string wstring_to_utf8str(const LLWString &utf32str); @@ -448,15 +417,6 @@ std::string mbcsstring_makeASCII(const std::string& str); std::string utf8str_removeCRLF(const std::string& utf8str); -template <class T> -std::ostream& operator<<(std::ostream &s, const LLStringBase<T> &str) -{ - s << ((std::basic_string<T>)str); - return s; -} - -std::ostream& operator<<(std::ostream &s, const LLWString &wstr); - #if LL_WINDOWS /* @name Windows string helpers */ @@ -492,7 +452,7 @@ std::string ll_convert_wide_to_string(const wchar_t* in); #endif // LL_WINDOWS /** - * Many of the 'strip' and 'replace' methods of LLStringBase need + * Many of the 'strip' and 'replace' methods of LLStringUtilBase need * specialization to work with the signed char type. * Sadly, it is not possible (AFAIK) to specialize a single method of * a template class. @@ -558,11 +518,12 @@ namespace LLStringFn // static template<class T> -S32 LLStringBase<T>::format(std::basic_string<T>& s, const format_map_t& fmt_map) +S32 LLStringUtilBase<T>::format(std::basic_string<T>& s, const format_map_t& fmt_map) { typedef typename std::basic_string<T>::size_type string_size_type_t; + typedef typename format_map_t::const_iterator format_map_const_iterator_t; S32 res = 0; - for (format_map_t::const_iterator iter = fmt_map.begin(); iter != fmt_map.end(); ++iter) + for (format_map_const_iterator_t iter = fmt_map.begin(); iter != fmt_map.end(); ++iter) { U32 fmtlen = iter->first.size(); string_size_type_t n = 0; @@ -584,7 +545,7 @@ S32 LLStringBase<T>::format(std::basic_string<T>& s, const format_map_t& fmt_map // static template<class T> -S32 LLStringBase<T>::compareStrings(const T* lhs, const T* rhs) +S32 LLStringUtilBase<T>::compareStrings(const T* lhs, const T* rhs) { S32 result; if( lhs == rhs ) @@ -608,9 +569,16 @@ S32 LLStringBase<T>::compareStrings(const T* lhs, const T* rhs) return result; } +//static +template<class T> +S32 LLStringUtilBase<T>::compareStrings(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs) +{ + return LLStringOps::collate(lhs.c_str(), rhs.c_str()); +} + // static template<class T> -S32 LLStringBase<T>::compareInsensitive(const T* lhs, const T* rhs ) +S32 LLStringUtilBase<T>::compareInsensitive(const T* lhs, const T* rhs ) { S32 result; if( lhs == rhs ) @@ -629,22 +597,32 @@ S32 LLStringBase<T>::compareInsensitive(const T* lhs, const T* rhs ) } else { - LLStringBase<T> lhs_string(lhs); - LLStringBase<T> rhs_string(rhs); - LLStringBase<T>::toUpper(lhs_string); - LLStringBase<T>::toUpper(rhs_string); + std::basic_string<T> lhs_string(lhs); + std::basic_string<T> rhs_string(rhs); + LLStringUtilBase<T>::toUpper(lhs_string); + LLStringUtilBase<T>::toUpper(rhs_string); result = LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str()); } return result; } +//static +template<class T> +S32 LLStringUtilBase<T>::compareInsensitive(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs) +{ + std::basic_string<T> lhs_string(lhs); + std::basic_string<T> rhs_string(rhs); + LLStringUtilBase<T>::toUpper(lhs_string); + LLStringUtilBase<T>::toUpper(rhs_string); + return LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str()); +} // Case sensitive comparison with good handling of numbers. Does not use current locale. // a.k.a. strdictcmp() //static template<class T> -S32 LLStringBase<T>::compareDict(const std::basic_string<T>& astr, const std::basic_string<T>& bstr) +S32 LLStringUtilBase<T>::compareDict(const std::basic_string<T>& astr, const std::basic_string<T>& bstr) { const T* a = astr.c_str(); const T* b = bstr.c_str(); @@ -683,8 +661,9 @@ S32 LLStringBase<T>::compareDict(const std::basic_string<T>& astr, const std::ba return ca-cb; } +// static template<class T> -S32 LLStringBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, const std::basic_string<T>& bstr) +S32 LLStringUtilBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, const std::basic_string<T>& bstr) { const T* a = astr.c_str(); const T* b = bstr.c_str(); @@ -719,11 +698,11 @@ S32 LLStringBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, co // Puts compareDict() in a form appropriate for LL container classes to use for sorting. // static template<class T> -BOOL LLStringBase<T>::precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b ) +BOOL LLStringUtilBase<T>::precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b ) { if( a.size() && b.size() ) { - return (LLStringBase<T>::compareDict(a.c_str(), b.c_str()) < 0); + return (LLStringUtilBase<T>::compareDict(a.c_str(), b.c_str()) < 0); } else { @@ -731,28 +710,9 @@ BOOL LLStringBase<T>::precedesDict( const std::basic_string<T>& a, const std::ba } } -// Constructors -template<class T> -LLStringBase<T>::LLStringBase(const T* s ) : std::basic_string<T>() -{ - if (s) assign(s); -} - -template<class T> -LLStringBase<T>::LLStringBase(const T* s, size_type n ) : std::basic_string<T>() -{ - if (s) assign(s, n); -} - -// Init from a substring -template<class T> -LLStringBase<T>::LLStringBase(const T* s, size_type pos, size_type n ) -: std::basic_string<T>( (s ? s : std::basic_string<T>() ), pos, n ) -{ } - //static template<class T> -void LLStringBase<T>::toUpper(std::basic_string<T>& string) +void LLStringUtilBase<T>::toUpper(std::basic_string<T>& string) { if( !string.empty() ) { @@ -766,7 +726,7 @@ void LLStringBase<T>::toUpper(std::basic_string<T>& string) //static template<class T> -void LLStringBase<T>::toLower(std::basic_string<T>& string) +void LLStringUtilBase<T>::toLower(std::basic_string<T>& string) { if( !string.empty() ) { @@ -780,7 +740,7 @@ void LLStringBase<T>::toLower(std::basic_string<T>& string) //static template<class T> -void LLStringBase<T>::trimHead(std::basic_string<T>& string) +void LLStringUtilBase<T>::trimHead(std::basic_string<T>& string) { if( !string.empty() ) { @@ -795,7 +755,7 @@ void LLStringBase<T>::trimHead(std::basic_string<T>& string) //static template<class T> -void LLStringBase<T>::trimTail(std::basic_string<T>& string) +void LLStringUtilBase<T>::trimTail(std::basic_string<T>& string) { if( string.size() ) { @@ -814,7 +774,7 @@ void LLStringBase<T>::trimTail(std::basic_string<T>& string) // Replace line feeds with carriage return-line feed pairs. //static template<class T> -void LLStringBase<T>::addCRLF(std::basic_string<T>& string) +void LLStringUtilBase<T>::addCRLF(std::basic_string<T>& string) { const T LF = 10; const T CR = 13; @@ -855,7 +815,7 @@ void LLStringBase<T>::addCRLF(std::basic_string<T>& string) // Remove all carriage returns //static template<class T> -void LLStringBase<T>::removeCRLF(std::basic_string<T>& string) +void LLStringUtilBase<T>::removeCRLF(std::basic_string<T>& string) { const T CR = 13; @@ -876,7 +836,7 @@ void LLStringBase<T>::removeCRLF(std::basic_string<T>& string) //static template<class T> -void LLStringBase<T>::replaceChar( std::basic_string<T>& string, T target, T replacement ) +void LLStringUtilBase<T>::replaceChar( std::basic_string<T>& string, T target, T replacement ) { size_type found_pos = 0; for (found_pos = string.find(target, found_pos); @@ -889,7 +849,7 @@ void LLStringBase<T>::replaceChar( std::basic_string<T>& string, T target, T rep //static template<class T> -void LLStringBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T replacement ) +void LLStringUtilBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T replacement ) { const char LF = 10; const S8 MIN = 32; @@ -909,12 +869,12 @@ void LLStringBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T r //static template<class T> -void LLStringBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_type spaces_per_tab ) +void LLStringUtilBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_type spaces_per_tab ) { const T TAB = '\t'; const T SPACE = ' '; - LLStringBase<T> out_str; + std::basic_string<T> out_str; // Replace tabs with spaces for (size_type i = 0; i < str.length(); i++) { @@ -933,7 +893,7 @@ void LLStringBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_typ //static template<class T> -BOOL LLStringBase<T>::containsNonprintable(const std::basic_string<T>& string) +BOOL LLStringUtilBase<T>::containsNonprintable(const std::basic_string<T>& string) { const char MIN = 32; BOOL rv = FALSE; @@ -950,7 +910,7 @@ BOOL LLStringBase<T>::containsNonprintable(const std::basic_string<T>& string) //static template<class T> -void LLStringBase<T>::stripNonprintable(std::basic_string<T>& string) +void LLStringUtilBase<T>::stripNonprintable(std::basic_string<T>& string) { const char MIN = 32; size_type j = 0; @@ -981,7 +941,7 @@ void LLStringBase<T>::stripNonprintable(std::basic_string<T>& string) } template<class T> -void LLStringBase<T>::_makeASCII(std::basic_string<T>& string) +void LLStringUtilBase<T>::_makeASCII(std::basic_string<T>& string) { // Replace non-ASCII chars with LL_UNKNOWN_CHAR for (size_type i = 0; i < string.length(); i++) @@ -995,7 +955,7 @@ void LLStringBase<T>::_makeASCII(std::basic_string<T>& string) // static template<class T> -void LLStringBase<T>::copy( T* dst, const T* src, size_type dst_size ) +void LLStringUtilBase<T>::copy( T* dst, const T* src, size_type dst_size ) { if( dst_size > 0 ) { @@ -1011,7 +971,7 @@ void LLStringBase<T>::copy( T* dst, const T* src, size_type dst_size ) // static template<class T> -void LLStringBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset) +void LLStringUtilBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset) { if ( offset == dst.length() ) { @@ -1032,7 +992,7 @@ void LLStringBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_strin // True if this is the head of s. //static template<class T> -BOOL LLStringBase<T>::isHead( const std::basic_string<T>& string, const T* s ) +BOOL LLStringUtilBase<T>::isHead( const std::basic_string<T>& string, const T* s ) { if( string.empty() ) { @@ -1046,14 +1006,14 @@ BOOL LLStringBase<T>::isHead( const std::basic_string<T>& string, const T* s ) } template<class T> -BOOL LLStringBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& value) +BOOL LLStringUtilBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& value) { if( string.empty() ) { return FALSE; } - LLStringBase<T> temp( string ); + std::basic_string<T> temp( string ); trim(temp); if( (temp == "1") || @@ -1083,7 +1043,7 @@ BOOL LLStringBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& va } template<class T> -BOOL LLStringBase<T>::convertToU8(const std::basic_string<T>& string, U8& value) +BOOL LLStringUtilBase<T>::convertToU8(const std::basic_string<T>& string, U8& value) { S32 value32 = 0; BOOL success = convertToS32(string, value32); @@ -1096,7 +1056,7 @@ BOOL LLStringBase<T>::convertToU8(const std::basic_string<T>& string, U8& value) } template<class T> -BOOL LLStringBase<T>::convertToS8(const std::basic_string<T>& string, S8& value) +BOOL LLStringUtilBase<T>::convertToS8(const std::basic_string<T>& string, S8& value) { S32 value32 = 0; BOOL success = convertToS32(string, value32); @@ -1109,7 +1069,7 @@ BOOL LLStringBase<T>::convertToS8(const std::basic_string<T>& string, S8& value) } template<class T> -BOOL LLStringBase<T>::convertToS16(const std::basic_string<T>& string, S16& value) +BOOL LLStringUtilBase<T>::convertToS16(const std::basic_string<T>& string, S16& value) { S32 value32 = 0; BOOL success = convertToS32(string, value32); @@ -1122,7 +1082,7 @@ BOOL LLStringBase<T>::convertToS16(const std::basic_string<T>& string, S16& valu } template<class T> -BOOL LLStringBase<T>::convertToU16(const std::basic_string<T>& string, U16& value) +BOOL LLStringUtilBase<T>::convertToU16(const std::basic_string<T>& string, U16& value) { S32 value32 = 0; BOOL success = convertToS32(string, value32); @@ -1135,14 +1095,14 @@ BOOL LLStringBase<T>::convertToU16(const std::basic_string<T>& string, U16& valu } template<class T> -BOOL LLStringBase<T>::convertToU32(const std::basic_string<T>& string, U32& value) +BOOL LLStringUtilBase<T>::convertToU32(const std::basic_string<T>& string, U32& value) { if( string.empty() ) { return FALSE; } - LLStringBase<T> temp( string ); + std::basic_string<T> temp( string ); trim(temp); U32 v; std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); @@ -1162,14 +1122,14 @@ BOOL LLStringBase<T>::convertToU32(const std::basic_string<T>& string, U32& valu } template<class T> -BOOL LLStringBase<T>::convertToS32(const std::basic_string<T>& string, S32& value) +BOOL LLStringUtilBase<T>::convertToS32(const std::basic_string<T>& string, S32& value) { if( string.empty() ) { return FALSE; } - LLStringBase<T> temp( string ); + std::basic_string<T> temp( string ); trim(temp); S32 v; std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); @@ -1189,7 +1149,7 @@ BOOL LLStringBase<T>::convertToS32(const std::basic_string<T>& string, S32& valu } template<class T> -BOOL LLStringBase<T>::convertToF32(const std::basic_string<T>& string, F32& value) +BOOL LLStringUtilBase<T>::convertToF32(const std::basic_string<T>& string, F32& value) { F64 value64 = 0.0; BOOL success = convertToF64(string, value64); @@ -1202,14 +1162,14 @@ BOOL LLStringBase<T>::convertToF32(const std::basic_string<T>& string, F32& valu } template<class T> -BOOL LLStringBase<T>::convertToF64(const std::basic_string<T>& string, F64& value) +BOOL LLStringUtilBase<T>::convertToF64(const std::basic_string<T>& string, F64& value) { if( string.empty() ) { return FALSE; } - LLStringBase<T> temp( string ); + std::basic_string<T> temp( string ); trim(temp); F64 v; std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); @@ -1229,7 +1189,7 @@ BOOL LLStringBase<T>::convertToF64(const std::basic_string<T>& string, F64& valu } template<class T> -void LLStringBase<T>::truncate(std::basic_string<T>& string, size_type count) +void LLStringUtilBase<T>::truncate(std::basic_string<T>& string, size_type count) { size_type cur_size = string.size(); string.resize(count < cur_size ? count : cur_size); diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 8700d9681e..d78a8591cb 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -143,28 +143,22 @@ LLOSInfo::LLOSInfo() : std::string csdversion = utf16str_to_utf8str(osvi.szCSDVersion); // Display version, service pack (if any), and build number. - char tmp[MAX_STRING]; /* Flawfinder: ignore */ + std::string tmpstr; if(osvi.dwMajorVersion <= 4) { - snprintf( /* Flawfinder: ignore */ - tmp, - sizeof(tmp), - "version %d.%d %s (Build %d)", - osvi.dwMajorVersion, - osvi.dwMinorVersion, - csdversion.c_str(), - (osvi.dwBuildNumber & 0xffff)); + tmpstr = llformat("version %d.%d %s (Build %d)", + osvi.dwMajorVersion, + osvi.dwMinorVersion, + csdversion.c_str(), + (osvi.dwBuildNumber & 0xffff)); } else { - snprintf( /* Flawfinder: ignore */ - tmp, - sizeof(tmp), - "%s (Build %d)", - csdversion.c_str(), - (osvi.dwBuildNumber & 0xffff)); + tmpstr = llformat("%s (Build %d)", + csdversion.c_str(), + (osvi.dwBuildNumber & 0xffff)); } - mOSString = mOSStringSimple + tmp; + mOSString = mOSStringSimple + tmpstr; } break; @@ -397,7 +391,7 @@ LLCPUInfo::LLCPUInfo() mCPUString = out.str(); #elif LL_LINUX - std::map< LLString, LLString > cpuinfo; + std::map< std::string, std::string > cpuinfo; LLFILE* cpuinfo_fp = LLFile::fopen(CPUINFO_FILE, "rb"); if(cpuinfo_fp) { @@ -420,21 +414,21 @@ LLCPUInfo::LLCPUInfo() if (nlspot == NULL) nlspot = line + strlen( line ); // Fallback to terminating NUL std::string linename( line, tabspot ); - LLString llinename(linename); - LLString::toLower(llinename); + std::string llinename(linename); + LLStringUtil::toLower(llinename); std::string lineval( spacespot + 1, nlspot ); cpuinfo[ llinename ] = lineval; } fclose(cpuinfo_fp); } # if LL_X86 - LLString flags = " " + cpuinfo["flags"] + " "; - LLString::toLower(flags); + std::string flags = " " + cpuinfo["flags"] + " "; + LLStringUtil::toLower(flags); mHasSSE = ( flags.find( " sse " ) != std::string::npos ); mHasSSE2 = ( flags.find( " sse2 " ) != std::string::npos ); F64 mhz; - if (LLString::convertToF64(cpuinfo["cpu mhz"], mhz) + if (LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhz) && 200.0 < mhz && mhz < 10000.0) { mCPUMhz = (S32)llrint(mhz); @@ -658,18 +652,17 @@ std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info) return s; } -BOOL gunzip_file(const char *srcfile, const char *dstfile) +BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile) { - char tmpfile[LL_MAX_PATH]; /* Flawfinder: ignore */ + std::string tmpfile; const S32 UNCOMPRESS_BUFFER_SIZE = 32768; BOOL retval = FALSE; gzFile src = NULL; U8 buffer[UNCOMPRESS_BUFFER_SIZE]; LLFILE *dst = NULL; S32 bytes = 0; - (void *) strcpy(tmpfile, dstfile); /* Flawfinder: ignore */ - (void *) strncat(tmpfile, ".t", sizeof(tmpfile) - strlen(tmpfile) -1); /* Flawfinder: ignore */ - src = gzopen(srcfile, "rb"); + tmpfile = dstfile + ".t"; + src = gzopen(srcfile.c_str(), "rb"); if (! src) goto err; dst = LLFile::fopen(tmpfile, "wb"); /* Flawfinder: ignore */ if (! dst) goto err; @@ -693,18 +686,17 @@ err: return retval; } -BOOL gzip_file(const char *srcfile, const char *dstfile) +BOOL gzip_file(const std::string& srcfile, const std::string& dstfile) { const S32 COMPRESS_BUFFER_SIZE = 32768; - char tmpfile[LL_MAX_PATH]; /* Flawfinder: ignore */ + std::string tmpfile; BOOL retval = FALSE; U8 buffer[COMPRESS_BUFFER_SIZE]; gzFile dst = NULL; LLFILE *src = NULL; S32 bytes = 0; - (void *) strcpy(tmpfile, dstfile); /* Flawfinder: ignore */ - (void *) strncat(tmpfile, ".t", sizeof(tmpfile) - strlen(tmpfile) -1); /* Flawfinder: ignore */ - dst = gzopen(tmpfile, "wb"); /* Flawfinder: ignore */ + tmpfile = dstfile + ".t"; + dst = gzopen(tmpfile.c_str(), "wb"); /* Flawfinder: ignore */ if (! dst) goto err; src = LLFile::fopen(srcfile, "rb"); /* Flawfinder: ignore */ if (! src) goto err; diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index 332d62c186..a56ba2bdda 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -127,9 +127,9 @@ std::ostream& operator<<(std::ostream& s, const LLCPUInfo& info); std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info); // gunzip srcfile into dstfile. Returns FALSE on error. -BOOL gunzip_file(const char *srcfile, const char *dstfile); +BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile); // gzip srcfile into dstfile. Returns FALSE on error. -BOOL gzip_file(const char *srcfile, const char *dstfile); +BOOL gzip_file(const std::string& srcfile, const std::string& dstfile); extern LLCPUInfo gSysCPU; diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 3d05699cd6..77d683adc0 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -483,7 +483,7 @@ struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time) } -void microsecondsToTimecodeString(U64 current_time, char *tcstring) +void microsecondsToTimecodeString(U64 current_time, std::string& tcstring) { U64 hours; U64 minutes; @@ -501,11 +501,11 @@ void microsecondsToTimecodeString(U64 current_time, char *tcstring) subframes = current_time / (U64)42; subframes %= 100; - sprintf(tcstring,"%3.3d:%2.2d:%2.2d:%2.2d.%2.2d",(int)hours,(int)minutes,(int)seconds,(int)frames,(int)subframes); /* Flawfinder: ignore */ + tcstring = llformat("%3.3d:%2.2d:%2.2d:%2.2d.%2.2d",(int)hours,(int)minutes,(int)seconds,(int)frames,(int)subframes); } -void secondsToTimecodeString(F32 current_time, char *tcstring) +void secondsToTimecodeString(F32 current_time, std::string& tcstring) { microsecondsToTimecodeString((U64)((F64)(SEC_TO_MICROSEC*current_time)), tcstring); } diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 41562f4a51..d3a83339f0 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -162,8 +162,8 @@ BOOL is_daylight_savings(); // struct tm* internal_time = utc_to_pacific_time(utc_time, gDaylight); struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time); -void microsecondsToTimecodeString(U64 current_time, char *tcstring); -void secondsToTimecodeString(F32 current_time, char *tcstring); +void microsecondsToTimecodeString(U64 current_time, std::string& tcstring); +void secondsToTimecodeString(F32 current_time, std::string& tcstring); // class for scheduling a function to be called at a given frequency (approximate, inprecise) class LLEventTimer diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index 3f86681315..51e27e0708 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -149,9 +149,9 @@ U32 janky_fast_random_seeded_bytes(U32 seed, U32 val) #endif // Common to all UUID implementations -void LLUUID::toString(char *out) const +void LLUUID::toString(std::string& out) const { - sprintf(out, + out = llformat( "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", (U8)(mData[0]), (U8)(mData[1]), @@ -171,6 +171,23 @@ void LLUUID::toString(char *out) const (U8)(mData[15])); } +// *TODO: deprecate +void LLUUID::toString(char *out) const +{ + std::string buffer; + toString(buffer); + strcpy(out,buffer.c_str()); /* Flawfinder: ignore */ +} + +void LLUUID::toCompressedString(std::string& out) const +{ + char bytes[UUID_BYTES+1]; + memcpy(bytes, mData, UUID_BYTES); /* Flawfinder: ignore */ + bytes[UUID_BYTES] = '\0'; + out = bytes; +} + +// *TODO: deprecate void LLUUID::toCompressedString(char *out) const { memcpy(out, mData, UUID_BYTES); /* Flawfinder: ignore */ @@ -184,38 +201,32 @@ std::string LLUUID::getString() const std::string LLUUID::asString() const { - char str[UUID_STR_SIZE]; /* Flawfinder: ignore */ + std::string str; toString(str); - return std::string(str); + return str; } -BOOL LLUUID::set(const std::string& in_string, BOOL emit) +BOOL LLUUID::set(const char* in_string, BOOL emit) { - return set(in_string.c_str(), emit); + return set(ll_safe_string(in_string)); } -BOOL LLUUID::set(const char *in_string, BOOL emit) +BOOL LLUUID::set(const std::string& in_string, BOOL emit) { BOOL broken_format = FALSE; - if (!in_string) - { - llerrs << "No string pointer in LLUUID::set!" << llendl; - setNull(); - return FALSE; - } // empty strings should make NULL uuid - if (!in_string[0]) + if (in_string.empty()) { setNull(); return TRUE; } - if (strlen(in_string) != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */ + if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */ { // I'm a moron. First implementation didn't have the right UUID format. // Shouldn't see any of these any more - if (strlen(in_string) == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */ + if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */ { if(emit) { @@ -251,17 +262,17 @@ BOOL LLUUID::set(const char *in_string, BOOL emit) mData[i] = 0; - if ((*(in_string + cur_pos) >= '0') && (*(in_string+cur_pos) <= '9')) + if ((in_string[cur_pos] >= '0') && (in_string[cur_pos] <= '9')) { - mData[i] += (U8)(*(in_string + cur_pos) - '0'); + mData[i] += (U8)(in_string[cur_pos] - '0'); } - else if ((*(in_string + cur_pos) >= 'a') && (*(in_string+cur_pos) <='f')) + else if ((in_string[cur_pos] >= 'a') && (in_string[cur_pos] <='f')) { - mData[i] += (U8)(10 + *(in_string + cur_pos) - 'a'); + mData[i] += (U8)(10 + in_string[cur_pos] - 'a'); } - else if ((*(in_string + cur_pos) >= 'A') && (*(in_string+cur_pos) <='F')) + else if ((in_string[cur_pos] >= 'A') && (in_string[cur_pos] <='F')) { - mData[i] += (U8)(10 + *(in_string + cur_pos) - 'A'); + mData[i] += (U8)(10 + in_string[cur_pos] - 'A'); } else { @@ -276,17 +287,17 @@ BOOL LLUUID::set(const char *in_string, BOOL emit) mData[i] = mData[i] << 4; cur_pos++; - if ((*(in_string + cur_pos) >= '0') && (*(in_string+cur_pos) <= '9')) + if ((in_string[cur_pos] >= '0') && (in_string[cur_pos] <= '9')) { - mData[i] += (U8)(*(in_string + cur_pos) - '0'); + mData[i] += (U8)(in_string[cur_pos] - '0'); } - else if ((*(in_string + cur_pos) >= 'a') && (*(in_string+cur_pos) <='f')) + else if ((in_string[cur_pos] >= 'a') && (in_string[cur_pos] <='f')) { - mData[i] += (U8)(10 + *(in_string + cur_pos) - 'a'); + mData[i] += (U8)(10 + in_string[cur_pos] - 'a'); } - else if ((*(in_string + cur_pos) >= 'A') && (*(in_string+cur_pos) <='F')) + else if ((in_string[cur_pos] >= 'A') && (in_string[cur_pos] <='F')) { - mData[i] += (U8)(10 + *(in_string + cur_pos) - 'A'); + mData[i] += (U8)(10 + in_string[cur_pos] - 'A'); } else { @@ -305,20 +316,11 @@ BOOL LLUUID::set(const char *in_string, BOOL emit) BOOL LLUUID::validate(const std::string& in_string) { - return validate(in_string.c_str()); -} - -BOOL LLUUID::validate(const char *in_string) -{ BOOL broken_format = FALSE; - if (!in_string) - { - return FALSE; - } - if (strlen(in_string) != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */ + if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */ { // I'm a moron. First implementation didn't have the right UUID format. - if (strlen(in_string) == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */ + if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */ { broken_format = TRUE; } @@ -329,8 +331,7 @@ BOOL LLUUID::validate(const char *in_string) } U8 cur_pos = 0; - U32 i; - for (i = 0; i < 16; i++) + for (U32 i = 0; i < 16; i++) { if ((i == 4) || (i == 6) || (i == 8) || (i == 10)) { @@ -342,13 +343,13 @@ BOOL LLUUID::validate(const char *in_string) } } - if ((*(in_string + cur_pos) >= '0') && (*(in_string+cur_pos) <= '9')) + if ((in_string[cur_pos] >= '0') && (in_string[cur_pos] <= '9')) { } - else if ((*(in_string + cur_pos) >= 'a') && (*(in_string+cur_pos) <='f')) + else if ((in_string[cur_pos] >= 'a') && (in_string[cur_pos] <='f')) { } - else if ((*(in_string + cur_pos) >= 'A') && (*(in_string+cur_pos) <='F')) + else if ((in_string[cur_pos] >= 'A') && (in_string[cur_pos] <='F')) { } else @@ -358,13 +359,13 @@ BOOL LLUUID::validate(const char *in_string) cur_pos++; - if ((*(in_string + cur_pos) >= '0') && (*(in_string+cur_pos) <= '9')) + if ((in_string[cur_pos] >= '0') && (in_string[cur_pos] <= '9')) { } - else if ((*(in_string + cur_pos) >= 'a') && (*(in_string+cur_pos) <='f')) + else if ((in_string[cur_pos] >= 'a') && (in_string[cur_pos] <='f')) { } - else if ((*(in_string + cur_pos) >= 'A') && (*(in_string+cur_pos) <='F')) + else if ((in_string[cur_pos] >= 'A') && (in_string[cur_pos] <='F')) { } else @@ -412,8 +413,7 @@ LLUUID LLUUID::combine(const LLUUID &other) const std::ostream& operator<<(std::ostream& s, const LLUUID &uuid) { - char uuid_str[UUID_STR_LENGTH]; - + std::string uuid_str; uuid.toString(uuid_str); s << uuid_str; return s; @@ -428,7 +428,7 @@ std::istream& operator>>(std::istream &s, LLUUID &uuid) s >> uuid_str[i]; } uuid_str[i] = '\0'; - uuid.set(uuid_str); + uuid.set(std::string(uuid_str)); return s; } @@ -891,15 +891,15 @@ U32 LLUUID::getRandomSeed() return(*(U32 *)seed); } -BOOL LLUUID::parseUUID(const char* buf, LLUUID* value) +BOOL LLUUID::parseUUID(const std::string& buf, LLUUID* value) { - if( buf == NULL || buf[0] == '\0' || value == NULL) + if( buf.empty() || value == NULL) { return FALSE; } - LLString temp( buf ); - LLString::trim(temp); + std::string temp( buf ); + LLStringUtil::trim(temp); if( LLUUID::validate( temp ) ) { value->set( temp ); diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h index 2f82ec9a93..b2fcce5161 100644 --- a/indra/llcommon/lluuid.h +++ b/indra/llcommon/lluuid.h @@ -106,7 +106,9 @@ public: friend std::istream& operator>>(std::istream& s, LLUUID &uuid); void toString(char *out) const; // Does not allocate memory, needs 36 characters (including \0) + void toString(std::string& out) const; void toCompressedString(char *out) const; // Does not allocate memory, needs 17 characters (including \0) + void toCompressedString(std::string& out) const; std::string asString() const; std::string getString() const; @@ -115,14 +117,13 @@ public: U32 getCRC32() const; static BOOL validate(const std::string& in_string); // Validate that the UUID string is legal. - static BOOL validate(const char *in_string); // Validate that the UUID string is legal. static const LLUUID null; static U32 getRandomSeed(); static S32 getNodeID(unsigned char * node_id); - static BOOL parseUUID(const char* buf, LLUUID* value); + static BOOL parseUUID(const std::string& buf, LLUUID* value); U8 mData[UUID_BYTES]; }; diff --git a/indra/llcommon/metapropertyt.h b/indra/llcommon/metapropertyt.h index 488a60c22f..158d0cebec 100644 --- a/indra/llcommon/metapropertyt.h +++ b/indra/llcommon/metapropertyt.h @@ -86,13 +86,6 @@ inline const LLReflective* LLMetaPropertyT<std::string>::get(const LLReflective* } template <> -inline const LLReflective* LLMetaPropertyT<LLString>::get(const LLReflective* object) const -{ - checkObjectClass(object); - return NULL; -} - -template <> inline const LLReflective* LLMetaPropertyT<LLUUID>::get(const LLReflective* object) const { checkObjectClass(object); @@ -112,12 +105,6 @@ inline LLSD LLMetaPropertyT<std::string>::getLLSD(const LLReflective* object) co } template <> -inline LLSD LLMetaPropertyT<LLString>::getLLSD(const LLReflective* object) const -{ - return *(getProperty(object)); -} - -template <> inline LLSD LLMetaPropertyT<LLUUID>::getLLSD(const LLReflective* object) const { return *(getProperty(object)); diff --git a/indra/llcommon/u64.cpp b/indra/llcommon/u64.cpp index f3422770ae..b23c74b79e 100644 --- a/indra/llcommon/u64.cpp +++ b/indra/llcommon/u64.cpp @@ -34,10 +34,10 @@ #include "u64.h" -U64 str_to_U64(const char *str) +U64 str_to_U64(const std::string& str) { U64 result = 0; - const char *aptr = strpbrk(str,"0123456789"); + const char *aptr = strpbrk(str.c_str(),"0123456789"); if (!aptr) { @@ -54,8 +54,9 @@ U64 str_to_U64(const char *str) } -char* U64_to_str(U64 value, char* result, S32 result_size) -{ +std::string U64_to_str(U64 value) +{ + std::string res; U32 part1,part2,part3; part3 = (U32)(value % (U64)10000000); @@ -70,31 +71,26 @@ char* U64_to_str(U64 value, char* result, S32 result_size) if (part1) { - snprintf( /* Flawfinder: ignore */ - result, - result_size, - "%u%07u%07u", - part1,part2,part3); + res = llformat("%u%07u%07u",part1,part2,part3); } else if (part2) { - snprintf( /* Flawfinder: ignore */ - result, - result_size, - "%u%07u", - part2,part3); + res = llformat("%u%07u",part2,part3); } else { - snprintf( /* Flawfinder: ignore */ - result, - result_size, - "%u", - part3); + res = llformat("%u",part3); } - return (result); + return res; } +char* U64_to_str(U64 value, char* result, S32 result_size) +{ + std::string res = U64_to_str(value); + LLStringUtil::copy(result, res.c_str(), result_size); + return result; +} + F64 U64_to_F64(const U64 value) { S64 top_bits = (S64)(value >> 1); diff --git a/indra/llcommon/u64.h b/indra/llcommon/u64.h index f4580513bc..3b833a4587 100644 --- a/indra/llcommon/u64.h +++ b/indra/llcommon/u64.h @@ -38,7 +38,14 @@ * @param str The string to parse. * @return Returns the first U64 value found in the string or 0 on failure. */ -U64 str_to_U64(const char* str); +U64 str_to_U64(const std::string& str); + +/** + * @brief Given a U64 value, return a printable representation. + * @param value The U64 to turn into a printable character array. + * @return Returns the result string. + */ +std::string U64_to_str(U64 value); /** * @brief Given a U64 value, return a printable representation. diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index 2640390b9c..32dea6c707 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -76,7 +76,7 @@ bool LLCrashLoggerText::mainLoop() return true; } -void LLCrashLoggerText::updateApplication(LLString message) +void LLCrashLoggerText::updateApplication(const std::string& message) { LLCrashLogger::updateApplication(message); std::cout << message << std::endl; @@ -120,10 +120,8 @@ void LLCrashLogger::gatherFiles() updateApplication("Gathering logs..."); // Figure out the filename of the debug log - std::string db_file_name = gDirUtilp->getExpandedFilename( - LL_PATH_LOGS, - "debug_info.log"); - llifstream debug_log_file(db_file_name.c_str()); + std::string db_file_name = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"debug_info.log"); + std::ifstream debug_log_file(db_file_name.c_str()); // Look for it in the debug_info.log file if (debug_log_file.is_open()) @@ -161,12 +159,12 @@ void LLCrashLogger::gatherFiles() updateApplication("Encoding files..."); - for(std::map<LLString, LLString>::iterator itr = mFileMap.begin(); itr != mFileMap.end(); ++itr) + for(std::map<std::string, std::string>::iterator itr = mFileMap.begin(); itr != mFileMap.end(); ++itr) { std::ifstream f((*itr).second.c_str()); if(!f.is_open()) { - std::cout << "Can't find file " << (*itr).second.c_str() << std::endl; + std::cout << "Can't find file " << (*itr).second << std::endl; continue; } std::stringstream s; @@ -212,10 +210,10 @@ bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior) return true; } -bool LLCrashLogger::runCrashLogPost(LLString host, LLSD data, LLString msg, int retries, int timeout) +bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout) { gBreak = false; - LLString status_message; + std::string status_message; for(int i = 0; i < retries; ++i) { status_message = llformat("%s, try %d...", msg.c_str(), i+1); @@ -251,14 +249,15 @@ bool LLCrashLogger::sendCrashLogs() bool sent = false; + //*TODO: Translate if(mCrashHost != "") { - sent = runCrashLogPost(mCrashHost, post_data, "Sending to server", 3, 5); + sent = runCrashLogPost(mCrashHost, post_data, std::string("Sending to server"), 3, 5); } if(!sent) { - sent = runCrashLogPost(mAltCrashHost, post_data, "Sending to alternate server", 3, 5); + sent = runCrashLogPost(mAltCrashHost, post_data, std::string("Sending to alternate server"), 3, 5); } mSentCrashLogs = sent; @@ -266,7 +265,7 @@ bool LLCrashLogger::sendCrashLogs() return true; } -void LLCrashLogger::updateApplication(LLString message) +void LLCrashLogger::updateApplication(const std::string& message) { gServicePump->pump(); gServicePump->callback(); @@ -319,7 +318,7 @@ bool LLCrashLogger::init() //If we've opened the crash logger, assume we can delete the marker file if it exists if( gDirUtilp ) { - LLString marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"SecondLife.exec_marker"); + std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"SecondLife.exec_marker"); ll_apr_file_remove( marker_file ); } diff --git a/indra/llcrashlogger/llcrashlogger.h b/indra/llcrashlogger/llcrashlogger.h index c4a583371e..b8856c8872 100755 --- a/indra/llcrashlogger/llcrashlogger.h +++ b/indra/llcrashlogger/llcrashlogger.h @@ -50,23 +50,23 @@ public: bool saveCrashBehaviorSetting(S32 crash_behavior); bool sendCrashLogs(); LLSD constructPostData(); - virtual void updateApplication(LLString message = ""); + virtual void updateApplication(const std::string& message = LLStringUtil::null); virtual bool init(); virtual bool mainLoop() = 0; virtual bool cleanup() { return true; } - void setUserText(LLString& text) { mCrashInfo["UserNotes"] = text; } + void setUserText(const std::string& text) { mCrashInfo["UserNotes"] = text; } S32 getCrashBehavior() { return mCrashBehavior; } - bool runCrashLogPost(LLString host, LLSD data, LLString msg, int retries, int timeout); + bool runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout); protected: S32 mCrashBehavior; BOOL mCrashInPreviousExec; - std::map<LLString, LLString> mFileMap; - LLString mGridName; + std::map<std::string, std::string> mFileMap; + std::string mGridName; LLControlGroup mCrashSettings; - LLString mProductName; + std::string mProductName; LLSD mCrashInfo; - LLString mCrashHost; - LLString mAltCrashHost; + std::string mCrashHost; + std::string mAltCrashHost; LLSD mDebugLog; bool mSentCrashLogs; }; @@ -78,7 +78,7 @@ public: ~LLCrashLoggerText(void) {} virtual bool mainLoop(); - virtual void updateApplication(LLString message = ""); + virtual void updateApplication(const std::string& message = LLStringUtil::null); }; diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 2948675396..66b84c9a08 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -97,15 +97,15 @@ void LLImageBase::sanityCheck() } } -LLString LLImageBase::sLastErrorMessage; +std::string LLImageBase::sLastErrorMessage; BOOL LLImageBase::sSizeOverride = FALSE; -BOOL LLImageBase::setLastError(const LLString& message, const LLString& filename) +BOOL LLImageBase::setLastError(const std::string& message, const std::string& filename) { sLastErrorMessage = message; - if (filename != "") + if (!filename.empty()) { - sLastErrorMessage += LLString(" FILE:"); + sLastErrorMessage += " FILE:"; sLastErrorMessage += filename; } llwarns << sLastErrorMessage << llendl; @@ -250,7 +250,7 @@ LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components) ++sRawImageCount; } -LLImageRaw::LLImageRaw(const LLString &filename, bool j2c_lowest_mip_only) +LLImageRaw::LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only) : LLImageBase() { createFromFile(filename, j2c_lowest_mip_only); @@ -1107,25 +1107,25 @@ file_extensions[] = }; #define NUM_FILE_EXTENSIONS sizeof(file_extensions)/sizeof(file_extensions[0]) -static LLString find_file(LLString &name, S8 *codec) +static std::string find_file(std::string &name, S8 *codec) { - LLString tname; + std::string tname; for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++) { - tname = name + "." + LLString(file_extensions[i].exten); - llifstream ifs(tname.c_str(), llifstream::binary); + tname = name + "." + std::string(file_extensions[i].exten); + llifstream ifs(tname, llifstream::binary); if (ifs.is_open()) { ifs.close(); if (codec) *codec = file_extensions[i].codec; - return LLString(file_extensions[i].exten); + return std::string(file_extensions[i].exten); } } - return LLString(""); + return std::string(""); } -EImageCodec LLImageBase::getCodecFromExtension(const LLString& exten) +EImageCodec LLImageBase::getCodecFromExtension(const std::string& exten) { for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++) { @@ -1135,19 +1135,19 @@ EImageCodec LLImageBase::getCodecFromExtension(const LLString& exten) return IMG_CODEC_INVALID; } -bool LLImageRaw::createFromFile(const LLString &filename, bool j2c_lowest_mip_only) +bool LLImageRaw::createFromFile(const std::string &filename, bool j2c_lowest_mip_only) { - LLString name = filename; + std::string name = filename; size_t dotidx = name.rfind('.'); S8 codec = IMG_CODEC_INVALID; - LLString exten; + std::string exten; deleteData(); // delete any existing data - if (dotidx != LLString::npos) + if (dotidx != std::string::npos) { exten = name.substr(dotidx+1); - LLString::toLower(exten); + LLStringUtil::toLower(exten); codec = getCodecFromExtension(exten); } else @@ -1160,7 +1160,7 @@ bool LLImageRaw::createFromFile(const LLString &filename, bool j2c_lowest_mip_on return false; // format not recognized } - llifstream ifs(name.c_str(), llifstream::binary); + llifstream ifs(name, llifstream::binary); if (!ifs.is_open()) { // SJB: changed from llinfos to lldebugs to reduce spam @@ -1302,11 +1302,11 @@ LLImageFormatted* LLImageFormatted::createFromType(S8 codec) } // static -LLImageFormatted* LLImageFormatted::createFromExtension(const LLString& instring) +LLImageFormatted* LLImageFormatted::createFromExtension(const std::string& instring) { - LLString exten; + std::string exten; size_t dotidx = instring.rfind('.'); - if (dotidx != LLString::npos) + if (dotidx != std::string::npos) { exten = instring.substr(dotidx+1); } @@ -1463,7 +1463,7 @@ void LLImageFormatted::appendData(U8 *data, S32 size) //---------------------------------------------------------------------------- -BOOL LLImageFormatted::load(const LLString &filename) +BOOL LLImageFormatted::load(const std::string &filename) { resetLastError(); @@ -1500,14 +1500,14 @@ BOOL LLImageFormatted::load(const LLString &filename) return res; } -BOOL LLImageFormatted::save(const LLString &filename) +BOOL LLImageFormatted::save(const std::string &filename) { resetLastError(); apr_file_t* apr_file = ll_apr_file_open(filename, LL_APR_WB); if (!apr_file) { - setLastError("Unable to open file for reading", filename); + setLastError("Unable to open file for writing", filename); return FALSE; } diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index ee29e5c4a4..98a86ad755 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -113,9 +113,9 @@ protected: void setDataAndSize(U8 *data, S32 size) { mData = data; mDataSize = size; }; public: - static const LLString& getLastError() {return sLastErrorMessage;}; - static void resetLastError() {sLastErrorMessage = LLString("No Error"); }; - static BOOL setLastError(const LLString& message, const LLString& filename = LLString()); // returns FALSE + static const std::string& getLastError() {return sLastErrorMessage;}; + static void resetLastError() {sLastErrorMessage = "No Error"; }; + static BOOL setLastError(const std::string& message, const std::string& filename = std::string()); // returns FALSE static void generateMip(const U8 *indata, U8* mipdata, int width, int height, S32 nchannels); @@ -125,7 +125,7 @@ public: static void setSizeOverride(BOOL enabled) { sSizeOverride = enabled; } - static EImageCodec getCodecFromExtension(const LLString& exten); + static EImageCodec getCodecFromExtension(const std::string& exten); private: U8 *mData; @@ -141,7 +141,7 @@ private: public: S16 mMemType; // debug - static LLString sLastErrorMessage; + static std::string sLastErrorMessage; static BOOL sSizeOverride; }; @@ -157,7 +157,7 @@ public: LLImageRaw(U16 width, U16 height, S8 components); LLImageRaw(U8 *data, U16 width, U16 height, S8 components); // Construct using createFromFile (used by tools) - LLImageRaw(const LLString& filename, bool j2c_lowest_mip_only = false); + LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only = false); /*virtual*/ void deleteData(); /*virtual*/ U8* allocateData(S32 size = -1); @@ -218,7 +218,7 @@ public: protected: // Create an image from a local file (generally used in tools) - bool createFromFile(const LLString& filename, bool j2c_lowest_mip_only = false); + bool createFromFile(const std::string& filename, bool j2c_lowest_mip_only = false); void copyLineScaled( U8* in, U8* out, S32 in_pixel_len, S32 out_pixel_len, S32 in_pixel_step, S32 out_pixel_step ); void compositeRowScaled4onto3( U8* in, U8* out, S32 in_pixel_len, S32 out_pixel_len ); @@ -236,7 +236,7 @@ class LLImageFormatted : public LLImageBase { public: static LLImageFormatted* createFromType(S8 codec); - static LLImageFormatted* createFromExtension(const LLString& instring); + static LLImageFormatted* createFromExtension(const std::string& instring); protected: /*virtual*/ ~LLImageFormatted(); @@ -265,8 +265,8 @@ public: // getRawDiscardLevel()by default returns mDiscardLevel, but may be overridden (LLImageJ2C) virtual S8 getRawDiscardLevel() { return mDiscardLevel; } - BOOL load(const LLString& filename); - BOOL save(const LLString& filename); + BOOL load(const std::string& filename); + BOOL save(const std::string& filename); virtual BOOL updateData() = 0; // pure virtual void setData(U8 *data, S32 size); diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 3a6fd2db18..73c5b111c3 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -374,7 +374,7 @@ void LLImageJ2C::setReversible(const BOOL reversible) } -BOOL LLImageJ2C::loadAndValidate(const LLString &filename) +BOOL LLImageJ2C::loadAndValidate(const std::string &filename) { resetLastError(); diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h index 6c720df586..8d01eceb54 100644 --- a/indra/llimage/llimagej2c.h +++ b/indra/llimage/llimagej2c.h @@ -58,7 +58,7 @@ public: BOOL encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time=0.0); BOOL validate(U8 *data, U32 file_size); - BOOL loadAndValidate(const LLString &filename); + BOOL loadAndValidate(const std::string &filename); // Encode accessors void setReversible(const BOOL reversible); // Use non-lossy? diff --git a/indra/llimage/llimagetga.cpp b/indra/llimage/llimagetga.cpp index a9fc02bf8d..c8689f6669 100644 --- a/indra/llimage/llimagetga.cpp +++ b/indra/llimage/llimagetga.cpp @@ -30,6 +30,7 @@ #include "linden_common.h" +#include "lldir.h" #include "llimagetga.h" #include "llerror.h" #include "llmath.h" @@ -90,7 +91,7 @@ LLImageTGA::LLImageTGA() { } -LLImageTGA::LLImageTGA(const LLString& file_name) +LLImageTGA::LLImageTGA(const std::string& file_name) : LLImageFormatted(IMG_CODEC_TGA), mColorMap( NULL ), mColorMapStart( 0 ), @@ -1136,7 +1137,7 @@ BOOL LLImageTGA::decodeAndProcess( LLImageRaw* raw_image, F32 domain, F32 weight } // Reads a .tga file and creates an LLImageTGA with its data. -bool LLImageTGA::loadFile( const LLString& path ) +bool LLImageTGA::loadFile( const std::string& path ) { S32 len = path.size(); if( len < 5 ) @@ -1144,14 +1145,13 @@ bool LLImageTGA::loadFile( const LLString& path ) return false; } - LLString extension = path.substr( len - 4, 4 ); - LLString::toLower(extension); - if( ".tga" != extension ) + std::string extension = gDirUtilp->getExtension(path); + if( "tga" != extension ) { return false; } - LLFILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */ + LLFILE* file = LLFile::fopen(path, "rb"); /* Flawfinder: ignore */ if( !file ) { llwarns << "Couldn't open file " << path << llendl; diff --git a/indra/llimage/llimagetga.h b/indra/llimage/llimagetga.h index 3bfe4e6e21..d1178ffb73 100644 --- a/indra/llimage/llimagetga.h +++ b/indra/llimage/llimagetga.h @@ -43,7 +43,7 @@ protected: public: LLImageTGA(); - LLImageTGA(const LLString& file_name); + LLImageTGA(const std::string& file_name); /*virtual*/ BOOL updateData(); /*virtual*/ BOOL decode(LLImageRaw* raw_image, F32 decode_time=0.0); @@ -70,7 +70,7 @@ private: void decodeColorMapPixel24(U8* dst, const U8* src); void decodeColorMapPixel32(U8* dst, const U8* src); - bool loadFile(const LLString& file_name); + bool loadFile(const std::string& file_name); private: // Class specific data diff --git a/indra/llimage/llpngwrapper.cpp b/indra/llimage/llpngwrapper.cpp index 7b0c1ea931..2cced39a6f 100644 --- a/indra/llimage/llpngwrapper.cpp +++ b/indra/llimage/llpngwrapper.cpp @@ -389,7 +389,7 @@ U32 LLPngWrapper::getFinalSize() } // Get last error message, if any -LLString LLPngWrapper::getErrorMessage() +const std::string& LLPngWrapper::getErrorMessage() { return mErrorMessage; } diff --git a/indra/llimage/llpngwrapper.h b/indra/llimage/llpngwrapper.h index fd21ae697f..6528fa4480 100644 --- a/indra/llimage/llpngwrapper.h +++ b/indra/llimage/llpngwrapper.h @@ -52,7 +52,7 @@ public: BOOL readPng(U8* src, LLImageRaw* rawImage, ImageInfo *infop = NULL); BOOL writePng(const LLImageRaw* rawImage, U8* dst); U32 getFinalSize(); - LLString getErrorMessage(); + const std::string& getErrorMessage(); protected: void normalizeImage(); @@ -98,7 +98,7 @@ private: F64 mGamma; - LLString mErrorMessage; + std::string mErrorMessage; }; #endif 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 diff --git a/indra/llmath/llline.cpp b/indra/llmath/llline.cpp index b62631072b..749e3bcdd0 100644 --- a/indra/llmath/llline.cpp +++ b/indra/llmath/llline.cpp @@ -7,6 +7,8 @@ * $License$ */ +#include "linden_common.h" + #include "llline.h" #include "llrand.h" diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index 9d31df12e2..fde210ef50 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -35,6 +35,8 @@ #include <cmath> #include <cstdlib> #include "lldefs.h" +#include "llstl.h" // *TODO: Remove when LLString is gone +#include "llstring.h" // *TODO: Remove when LLString is gone // work around for Windows & older gcc non-standard function names. #if LL_WINDOWS diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp index 7711d0881d..79b93e6a46 100644 --- a/indra/llmath/llquaternion.cpp +++ b/indra/llmath/llquaternion.cpp @@ -937,15 +937,15 @@ void LLQuaternion::unpackFromVector3( const LLVector3& vec ) } } -BOOL LLQuaternion::parseQuat(const char* buf, LLQuaternion* value) +BOOL LLQuaternion::parseQuat(const std::string& buf, LLQuaternion* value) { - if( buf == NULL || buf[0] == '\0' || value == NULL) + if( buf.empty() || value == NULL) { return FALSE; } LLQuaternion quat; - S32 count = sscanf( buf, "%f %f %f %f", quat.mQ + 0, quat.mQ + 1, quat.mQ + 2, quat.mQ + 3 ); + S32 count = sscanf( buf.c_str(), "%f %f %f %f", quat.mQ + 0, quat.mQ + 1, quat.mQ + 2, quat.mQ + 3 ); if( 4 == count ) { value->set( quat ); diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h index a088d70674..34a02f6e76 100644 --- a/indra/llmath/llquaternion.h +++ b/indra/llmath/llquaternion.h @@ -158,7 +158,7 @@ public: friend const char *OrderToString( const Order order ); friend Order StringToOrder( const char *str ); - static BOOL parseQuat(const char* buf, LLQuaternion* value); + static BOOL parseQuat(const std::string& buf, LLQuaternion* value); // For debugging, only //static U32 mMultCount; diff --git a/indra/llmath/llsphere.cpp b/indra/llmath/llsphere.cpp index 3428dc1487..be4df39443 100644 --- a/indra/llmath/llsphere.cpp +++ b/indra/llmath/llsphere.cpp @@ -7,6 +7,8 @@ * $License$ */ +#include "linden_common.h" + #include "llsphere.h" LLSphere::LLSphere() diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp index c4f10467a9..8a34d9d33b 100644 --- a/indra/llmath/llvolumemgr.cpp +++ b/indra/llmath/llvolumemgr.cpp @@ -376,7 +376,6 @@ F32 LLVolumeLODGroup::getVolumeScaleFromDetail(const S32 detail) F32 LLVolumeLODGroup::dump() { - char dump_str[255]; /* Flawfinder: ignore */ F32 usage = 0.f; for (S32 i = 0; i < NUM_LODS; i++) { @@ -387,7 +386,7 @@ F32 LLVolumeLODGroup::dump() } usage = usage / (F32)NUM_LODS; - snprintf(dump_str, sizeof(dump_str), "%.3f %d %d %d %d", usage, mAccessCount[0], mAccessCount[1], mAccessCount[2], mAccessCount[3]); /* Flawfinder: ignore */ + std::string dump_str = llformat("%.3f %d %d %d %d", usage, mAccessCount[0], mAccessCount[1], mAccessCount[2], mAccessCount[3]); llinfos << dump_str << llendl; return usage; diff --git a/indra/llmath/v3dmath.cpp b/indra/llmath/v3dmath.cpp index efe1274cbe..41f26c10d7 100644 --- a/indra/llmath/v3dmath.cpp +++ b/indra/llmath/v3dmath.cpp @@ -132,15 +132,15 @@ const LLVector3d& LLVector3d::rotVec(F64 angle, F64 x, F64 y, F64 z) } -BOOL LLVector3d::parseVector3d(const char* buf, LLVector3d* value) +BOOL LLVector3d::parseVector3d(const std::string& buf, LLVector3d* value) { - if( buf == NULL || buf[0] == '\0' || value == NULL) + if( buf.empty() || value == NULL) { return FALSE; } LLVector3d v; - S32 count = sscanf( buf, "%lf %lf %lf", v.mdV + 0, v.mdV + 1, v.mdV + 2 ); + S32 count = sscanf( buf.c_str(), "%lf %lf %lf", v.mdV + 0, v.mdV + 1, v.mdV + 2 ); if( 3 == count ) { value->setVec( v ); diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h index d5e5223571..36a28e25e6 100644 --- a/indra/llmath/v3dmath.h +++ b/indra/llmath/v3dmath.h @@ -132,7 +132,7 @@ class LLVector3d friend std::ostream& operator<<(std::ostream& s, const LLVector3d &a); // Stream a - static BOOL parseVector3d(const char* buf, LLVector3d* value); + static BOOL parseVector3d(const std::string& buf, LLVector3d* value); }; diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp index 6299bbd1b7..166761e550 100644 --- a/indra/llmath/v3math.cpp +++ b/indra/llmath/v3math.cpp @@ -326,15 +326,15 @@ const LLVector3& operator*=(LLVector3 &a, const LLQuaternion &rot) } // static -BOOL LLVector3::parseVector3(const char* buf, LLVector3* value) +BOOL LLVector3::parseVector3(const std::string& buf, LLVector3* value) { - if( buf == NULL || buf[0] == '\0' || value == NULL) + if( buf.empty() || value == NULL) { return FALSE; } LLVector3 v; - S32 count = sscanf( buf, "%f %f %f", v.mV + 0, v.mV + 1, v.mV + 2 ); + S32 count = sscanf( buf.c_str(), "%f %f %f", v.mV + 0, v.mV + 1, v.mV + 2 ); if( 3 == count ) { value->setVec( v ); diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h index d8f3bec193..051d5376b7 100644 --- a/indra/llmath/v3math.h +++ b/indra/llmath/v3math.h @@ -148,7 +148,7 @@ class LLVector3 friend std::ostream& operator<<(std::ostream& s, const LLVector3 &a); // Stream a - static BOOL parseVector3(const char* buf, LLVector3* value); + static BOOL parseVector3(const std::string& buf, LLVector3* value); }; typedef LLVector3 LLSimLocalVec; diff --git a/indra/llmath/v4color.cpp b/indra/llmath/v4color.cpp index 21166472e4..8ba329eaf2 100644 --- a/indra/llmath/v4color.cpp +++ b/indra/llmath/v4color.cpp @@ -286,16 +286,14 @@ void LLColor4::calcHSL(F32* hue, F32* saturation, F32* luminance) const } // static -BOOL LLColor4::parseColor(const char* buf, LLColor4* color) +BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color) { - if( buf == NULL || buf[0] == '\0' || color == NULL) + if( buf.empty() || color == NULL) { return FALSE; } - LLString full_string(buf); - - boost_tokenizer tokens(full_string, boost::char_separator<char>(", ")); + boost_tokenizer tokens(buf, boost::char_separator<char>(", ")); boost_tokenizer::iterator token_iter = tokens.begin(); if (token_iter == tokens.end()) { @@ -304,15 +302,15 @@ BOOL LLColor4::parseColor(const char* buf, LLColor4* color) // Grab the first token into a string, since we don't know // if this is a float or a color name. - LLString color_name( (*token_iter) ); + std::string color_name( (*token_iter) ); ++token_iter; if (token_iter != tokens.end()) { // There are more tokens to read. This must be a vector. LLColor4 v; - LLString::convertToF32( color_name, v.mV[VX] ); - LLString::convertToF32( *token_iter, v.mV[VY] ); + LLStringUtil::convertToF32( color_name, v.mV[VX] ); + LLStringUtil::convertToF32( *token_iter, v.mV[VY] ); v.mV[VZ] = 0.0f; v.mV[VW] = 1.0f; @@ -320,18 +318,18 @@ BOOL LLColor4::parseColor(const char* buf, LLColor4* color) if (token_iter == tokens.end()) { // This is a malformed vector. - llwarns << "LLColor4::parseColor() malformed color " << full_string << llendl; + llwarns << "LLColor4::parseColor() malformed color " << buf << llendl; } else { // There is a z-component. - LLString::convertToF32( *token_iter, v.mV[VZ] ); + LLStringUtil::convertToF32( *token_iter, v.mV[VZ] ); ++token_iter; if (token_iter != tokens.end()) { // There is an alpha component. - LLString::convertToF32( *token_iter, v.mV[VW] ); + LLStringUtil::convertToF32( *token_iter, v.mV[VW] ); } } @@ -615,19 +613,19 @@ BOOL LLColor4::parseColor(const char* buf, LLColor4* color) } // static -BOOL LLColor4::parseColor4(const char* buf, LLColor4* value) +BOOL LLColor4::parseColor4(const std::string& buf, LLColor4* value) { - if( buf == NULL || buf[0] == '\0' || value == NULL) + if( buf.empty() || value == NULL) { return FALSE; } LLColor4 v; - S32 count = sscanf( buf, "%f, %f, %f, %f", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3 ); + S32 count = sscanf( buf.c_str(), "%f, %f, %f, %f", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3 ); if (1 == count ) { // try this format - count = sscanf( buf, "%f %f %f %f", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3 ); + count = sscanf( buf.c_str(), "%f %f %f %f", v.mV + 0, v.mV + 1, v.mV + 2, v.mV + 3 ); } if( 4 == count ) { diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index bd990444b5..62c0b663b8 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -211,8 +211,8 @@ class LLColor4 static LLColor4 cyan5; static LLColor4 cyan6; - static BOOL parseColor(const char* buf, LLColor4* color); - static BOOL parseColor4(const char* buf, LLColor4* color); + static BOOL parseColor(const std::string& buf, LLColor4* color); + static BOOL parseColor4(const std::string& buf, LLColor4* color); inline void clamp(); }; diff --git a/indra/llmath/v4coloru.cpp b/indra/llmath/v4coloru.cpp index 6f6900b6c2..26f3804209 100644 --- a/indra/llmath/v4coloru.cpp +++ b/indra/llmath/v4coloru.cpp @@ -93,19 +93,19 @@ std::ostream& operator<<(std::ostream& s, const LLColor4U &a) } // static -BOOL LLColor4U::parseColor4U(const char* buf, LLColor4U* value) +BOOL LLColor4U::parseColor4U(const std::string& buf, LLColor4U* value) { - if( buf == NULL || buf[0] == '\0' || value == NULL) + if( buf.empty() || value == NULL) { return FALSE; } U32 v[4]; - S32 count = sscanf( buf, "%u, %u, %u, %u", v + 0, v + 1, v + 2, v + 3 ); + S32 count = sscanf( buf.c_str(), "%u, %u, %u, %u", v + 0, v + 1, v + 2, v + 3 ); if (1 == count ) { // try this format - count = sscanf( buf, "%u %u %u %u", v + 0, v + 1, v + 2, v + 3 ); + count = sscanf( buf.c_str(), "%u %u %u %u", v + 0, v + 1, v + 2, v + 3 ); } if( 4 != count ) { diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h index fc7845ad15..1d3f31e968 100644 --- a/indra/llmath/v4coloru.h +++ b/indra/llmath/v4coloru.h @@ -127,7 +127,7 @@ public: inline void setVecScaleClamp(const LLColor3 &color); inline void setVecScaleClamp(const LLColor4 &color); - static BOOL parseColor4U(const char* buf, LLColor4U* value); + static BOOL parseColor4U(const std::string& buf, LLColor4U* value); static LLColor4U white; static LLColor4U black; diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index 9d32afc2f0..af149d0f62 100644 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -59,7 +59,7 @@ LLAssetStorage *gAssetStorage = NULL; LLMetrics *LLAssetStorage::metric_recipient = NULL; -const LLUUID CATEGORIZE_LOST_AND_FOUND_ID("00000000-0000-0000-0000-000000000010"); +const LLUUID CATEGORIZE_LOST_AND_FOUND_ID(std::string("00000000-0000-0000-0000-000000000010")); const U64 TOXIC_ASSET_LIFETIME = (120 * 1000000); // microseconds @@ -137,20 +137,20 @@ void LLAssetInfo::setFromNameValue( const LLNameValue& nv ) str.assign( nv.mName ); pos1 = str.find('|'); buf.assign( str, 0, pos1++ ); - mType = LLAssetType::lookup( buf.c_str() ); + mType = LLAssetType::lookup( buf ); buf.assign( str, pos1, std::string::npos ); - mUuid.set( buf.c_str() ); + mUuid.set( buf ); // convert the value to useful information str.assign( nv.getAsset() ); pos1 = str.find('|'); buf.assign( str, 0, pos1++ ); - mCreatorID.set( buf.c_str() ); + mCreatorID.set( buf ); pos2 = str.find( '|', pos1 ); buf.assign( str, pos1, (pos2++) - pos1 ); - setName( buf.c_str() ); + setName( buf ); buf.assign( str, pos2, std::string::npos ); - setDescription( buf.c_str() ); + setDescription( buf ); llinfos << "uuid: " << mUuid << llendl; llinfos << "creator: " << mCreatorID << llendl; } @@ -1238,7 +1238,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, vo void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 status, LLExtStat ext_status) { LLLegacyAssetRequest *legacy = (LLLegacyAssetRequest *)user_data; - char filename[LL_MAX_PATH] = ""; /* Flawfinder: ignore */ + std::string filename; // Check if the asset is marked toxic, and don't load bad stuff BOOL toxic = gAssetStorage->isAssetToxic( uuid ); @@ -1248,10 +1248,10 @@ void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAss { LLVFile file(vfs, uuid, type); - char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string uuid_str; uuid.toString(uuid_str); - snprintf(filename,sizeof(filename),"%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */ + filename = llformat("%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); LLFILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ if (fp) @@ -1275,7 +1275,7 @@ void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAss } } - legacy->mDownCallback(filename, uuid, legacy->mUserData, status, ext_status); + legacy->mDownCallback(filename.c_str(), uuid, legacy->mUserData, status, ext_status); delete legacy; } @@ -1294,7 +1294,7 @@ void LLAssetStorage::storeAssetData( { llwarns << "storeAssetData: wrong version called" << llendl; // LLAssetStorage metric: Virtual base call - reportMetric( LLUUID::null, asset_type, NULL, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 1" ); + reportMetric( LLUUID::null, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 1" ); } // virtual @@ -1313,13 +1313,13 @@ void LLAssetStorage::storeAssetData( { llwarns << "storeAssetData: wrong version called" << llendl; // LLAssetStorage metric: Virtual base call - reportMetric( asset_id, asset_type, NULL, requesting_agent_id, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 2" ); + reportMetric( asset_id, asset_type, LLStringUtil::null, requesting_agent_id, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 2" ); } // virtual // this does nothing, viewer and sim both override this. void LLAssetStorage::storeAssetData( - const char* filename, + const std::string& filename, const LLUUID& asset_id, LLAssetType::EType asset_type, LLStoreAssetCallback callback, @@ -1331,13 +1331,13 @@ void LLAssetStorage::storeAssetData( { llwarns << "storeAssetData: wrong version called" << llendl; // LLAssetStorage metric: Virtual base call - reportMetric( asset_id, asset_type, NULL, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 3" ); + reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 3" ); } // virtual // this does nothing, viewer and sim both override this. void LLAssetStorage::storeAssetData( - const char* filename, + const std::string& filename, const LLTransactionID &transactoin_id, LLAssetType::EType asset_type, LLStoreAssetCallback callback, @@ -1349,7 +1349,7 @@ void LLAssetStorage::storeAssetData( { llwarns << "storeAssetData: wrong version called" << llendl; // LLAssetStorage metric: Virtual base call - reportMetric( LLUUID::null, asset_type, NULL, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 4" ); + reportMetric( LLUUID::null, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_BAD_FUNCTION, __FILE__, __LINE__, "Illegal call to base: LLAssetStorage::storeAssetData 4" ); } // static @@ -1396,9 +1396,9 @@ void LLAssetStorage::clearTempAssetData() { } // static -void LLAssetStorage::reportMetric( const LLUUID& asset_id, const LLAssetType::EType asset_type, const char *filename, +void LLAssetStorage::reportMetric( const LLUUID& asset_id, const LLAssetType::EType asset_type, const std::string& in_filename, const LLUUID& agent_id, S32 asset_size, EMetricResult result, - const char *file, const S32 line, const char *message ) + const char *file, const S32 line, const std::string& in_message ) { if( !metric_recipient ) { @@ -1406,18 +1406,13 @@ void LLAssetStorage::reportMetric( const LLUUID& asset_id, const LLAssetType::ET return; } - filename = filename ? filename : ""; - file = file ? file : ""; - - // Create revised message - message = "message :: file:line" - std::string new_message; //( message ); - new_message = message; // << " " << file << " " << line; - new_message += " :: "; - new_message += filename; - char line_string[16]; - sprintf( line_string, ":%d", line ); - new_message += line_string; - message = new_message.c_str(); + std::string filename(in_filename); + if (filename.empty()) + filename = ll_safe_string(file); + + // Create revised message - new_message = "in_message :: file:line" + std::stringstream new_message; + new_message << in_message << " :: " << filename << ":" << line; // Change always_report to true if debugging... do not check it in this way static bool always_report = false; @@ -1430,16 +1425,16 @@ void LLAssetStorage::reportMetric( const LLUUID& asset_id, const LLAssetType::ET LLSD stats; stats["asset_id"] = asset_id; stats["asset_type"] = asset_type; - stats["filename"] = filename? filename : ""; + stats["filename"] = filename; stats["agent_id"] = agent_id; stats["asset_size"] = (S32)asset_size; stats["result"] = (S32)result; - metric_recipient->recordEventDetails( metric_name, message, success, stats); + metric_recipient->recordEventDetails( metric_name, new_message.str(), success, stats); } else { - metric_recipient->recordEvent(metric_name, message, success); + metric_recipient->recordEvent(metric_name, new_message.str(), success); } } diff --git a/indra/llmessage/llassetstorage.h b/indra/llmessage/llassetstorage.h index b1007e83c6..1b83d17c8f 100644 --- a/indra/llmessage/llassetstorage.h +++ b/indra/llmessage/llassetstorage.h @@ -378,7 +378,7 @@ public: * AssetID version. */ virtual void storeAssetData( - const char* filename, + const std::string& filename, const LLUUID& asset_id, LLAssetType::EType type, LLStoreAssetCallback callback, @@ -392,7 +392,7 @@ public: * TransactionID version */ virtual void storeAssetData( - const char * filename, + const std::string& filename, const LLTransactionID &transaction_id, LLAssetType::EType type, LLStoreAssetCallback callback, @@ -451,9 +451,9 @@ protected: static class LLMetrics *metric_recipient; - static void reportMetric( const LLUUID& asset_id, const LLAssetType::EType asset_type, const char *filename, - const LLUUID& agent_id, S32 asset_size, EMetricResult result, - const char *file, const S32 line, const char *message ); + static void reportMetric( const LLUUID& asset_id, const LLAssetType::EType asset_type, const std::string& filename, + const LLUUID& agent_id, S32 asset_size, EMetricResult result, + const char* file, const S32 line, const std::string& message ); public: static void setMetricRecipient( LLMetrics *recip ) { diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 1ad5179455..2cc82f7c23 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -43,10 +43,9 @@ #include "message.h" // Constants -// probably need a setUIString() call in the interface -const char* const CN_WAITING = "(Loading...)"; // *TODO: translate -const char* const CN_NOBODY = "(nobody)"; // *TODO: translate -const char* const CN_NONE = "(none)"; // *TODO: translate +static const std::string CN_WAITING("(Loading...)"); // *TODO: translate +static const std::string CN_NOBODY("(nobody)"); // *TODO: translate +static const std::string CN_NONE("(none)"); // *TODO: translate // llsd serialization constants static const std::string AGENTS("agents"); @@ -78,16 +77,13 @@ public: public: bool mIsGroup; U32 mCreateTime; // unix time_t - char mFirstName[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ - char mLastName[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ - char mGroupName[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string mFirstName; + std::string mLastName; + std::string mGroupName; }; LLCacheNameEntry::LLCacheNameEntry() { - mFirstName[0] = '\0'; - mLastName[0] = '\0'; - mGroupName[0] = '\0'; } @@ -235,7 +231,7 @@ public: static void handleUUIDGroupNameRequest(LLMessageSystem* msg, void** userdata); static void handleUUIDGroupNameReply(LLMessageSystem* msg, void** userdata); - void notifyObservers(const LLUUID& id, const char* first, const char* last, BOOL group); + void notifyObservers(const LLUUID& id, const std::string& first, const std::string& last, BOOL group); }; @@ -390,8 +386,8 @@ void LLCacheName::importFile(LLFILE* fp) LLCacheNameEntry* entry = new LLCacheNameEntry(); entry->mIsGroup = false; entry->mCreateTime = create_time; - LLString::copy(entry->mFirstName, firstname, DB_FIRST_NAME_BUF_SIZE); - LLString::copy(entry->mLastName, lastname, DB_LAST_NAME_BUF_SIZE); + entry->mFirstName = firstname; + entry->mLastName = lastname; impl.mCache[id] = entry; count++; @@ -426,12 +422,8 @@ bool LLCacheName::importFile(std::istream& istr) LLCacheNameEntry* entry = new LLCacheNameEntry(); entry->mIsGroup = false; entry->mCreateTime = ctime; - std::string first = agent[FIRST].asString(); - first.copy(entry->mFirstName, DB_FIRST_NAME_BUF_SIZE, 0); - entry->mFirstName[llmin(first.size(),(std::string::size_type)DB_FIRST_NAME_BUF_SIZE-1)] = '\0'; - std::string last = agent[LAST].asString(); - last.copy(entry->mLastName, DB_LAST_NAME_BUF_SIZE, 0); - entry->mLastName[llmin(last.size(),(std::string::size_type)DB_LAST_NAME_BUF_SIZE-1)] = '\0'; + entry->mFirstName = agent[FIRST].asString(); + entry->mLastName = agent[LAST].asString(); impl.mCache[id] = entry; ++count; } @@ -451,9 +443,7 @@ bool LLCacheName::importFile(std::istream& istr) LLCacheNameEntry* entry = new LLCacheNameEntry(); entry->mIsGroup = true; entry->mCreateTime = ctime; - std::string name = group[NAME].asString(); - name.copy(entry->mGroupName, DB_GROUP_NAME_BUF_SIZE, 0); - entry->mGroupName[llmin(name.size(), (std::string::size_type)DB_GROUP_NAME_BUF_SIZE-1)] = '\0'; + entry->mGroupName = group[NAME].asString(); impl.mCache[id] = entry; ++count; } @@ -471,8 +461,8 @@ void LLCacheName::exportFile(std::ostream& ostr) // Only write entries for which we have valid data. LLCacheNameEntry* entry = iter->second; if(!entry - || (NULL != strchr(entry->mFirstName, '?')) - || (NULL != strchr(entry->mGroupName, '?'))) + || (std::string::npos != entry->mFirstName.find('?')) + || (std::string::npos != entry->mGroupName.find('?'))) { continue; } @@ -480,13 +470,13 @@ void LLCacheName::exportFile(std::ostream& ostr) // store it LLUUID id = iter->first; std::string id_str = id.asString(); - if(entry->mFirstName[0] && entry->mLastName[0]) + if(!entry->mFirstName.empty() && !entry->mLastName.empty()) { data[AGENTS][id_str][FIRST] = entry->mFirstName; data[AGENTS][id_str][LAST] = entry->mLastName; data[AGENTS][id_str][CTIME] = (S32)entry->mCreateTime; } - else if(entry->mIsGroup && entry->mGroupName[0]) + else if(entry->mIsGroup && !entry->mGroupName.empty()) { data[GROUPS][id_str][NAME] = entry->mGroupName; data[GROUPS][id_str][CTIME] = (S32)entry->mCreateTime; @@ -534,16 +524,6 @@ BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) return res; } -// *TODO: Deprecate -BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last) -{ - std::string first_name, last_name; - BOOL res = getName(id, first_name, last_name); - strcpy(first, first_name.c_str()); - strcpy(last, last_name.c_str()); - return res; -} - BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) { if(id.isNull()) @@ -553,7 +533,7 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) } LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache,id); - if (entry && !entry->mGroupName[0]) + if (entry && entry->mGroupName.empty()) { // COUNTER-HACK to combat James' HACK in exportFile()... // this group name was loaded from a name cache that did not @@ -578,16 +558,6 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) } } -// *TODO: Deprecate -BOOL LLCacheName::getGroupName(const LLUUID& id, char* group) -{ - std::string group_name; - BOOL res = getGroupName(id, group_name); - strcpy(group, group_name.c_str()); - return res; -} - - // TODO: Make the cache name callback take a SINGLE std::string, // not a separate first and last name. void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data) @@ -716,9 +686,9 @@ void LLCacheName::dumpStats() } //static -LLString LLCacheName::getDefaultName() +std::string LLCacheName::getDefaultName() { - return LLString(CN_WAITING); + return CN_WAITING; } void LLCacheName::Impl::processPendingAsks() @@ -813,7 +783,7 @@ void LLCacheName::Impl::sendRequest( } void LLCacheName::Impl::notifyObservers(const LLUUID& id, - const char* first, const char* last, BOOL is_group) + const std::string& first, const std::string& last, BOOL is_group) { for (Observers::const_iterator i = mObservers.begin(), end = mObservers.end(); @@ -917,19 +887,17 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) entry->mCreateTime = (U32)time(NULL); if (!isGroup) { - msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, DB_FIRST_NAME_BUF_SIZE, entry->mFirstName, i); - msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, DB_LAST_NAME_BUF_SIZE, entry->mLastName, i); + msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, entry->mFirstName, i); + msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, entry->mLastName, i); } else { - msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_GroupName, DB_GROUP_NAME_BUF_SIZE, entry->mGroupName, i); + msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_GroupName, entry->mGroupName, i); } if (!isGroup) { - notifyObservers(id, - entry->mFirstName, entry->mLastName, - FALSE); + notifyObservers(id, entry->mFirstName, entry->mLastName, FALSE); } else { diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 5dfde80622..879eb5fadb 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -37,7 +37,7 @@ class LLHost; class LLUUID; // agent_id/group_id, first_name, last_name, is_group, user_data -typedef void (*LLCacheNameCallback)(const LLUUID&, const char*, const char*, BOOL, void*); +typedef void (*LLCacheNameCallback)(const LLUUID&, const std::string&, const std::string&, BOOL, void*); // Here's the theory: // If you request a name that isn't in the cache, it returns "waiting" @@ -75,7 +75,6 @@ public: // last must be at least DB_LAST_NAME_BUF_SIZE characters. // If not available, copies the string "waiting". // Returns TRUE iff available. - BOOL getName(const LLUUID& id, char* first, char* last); BOOL getName(const LLUUID& id, std::string& first, std::string& last); BOOL getFullName(const LLUUID& id, std::string& fullname); @@ -83,7 +82,6 @@ public: // provided. The caller must allocate at least // DB_GROUP_NAME_BUF_SIZE characters. If not available, this // method copies the string "waiting". Returns TRUE iff available. - BOOL getGroupName(const LLUUID& id, char* group); BOOL getGroupName(const LLUUID& id, std::string& group); // Call the callback with the group or avatar name. @@ -107,7 +105,7 @@ public: void dump(); // Dumps the contents of the cache void dumpStats(); // Dumps the sizes of the cache and associated queues. - static LLString getDefaultName(); + static std::string getDefaultName(); private: diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp index 0db9f8e2f1..431fe802f6 100644 --- a/indra/llmessage/llcircuit.cpp +++ b/indra/llmessage/llcircuit.cpp @@ -184,7 +184,7 @@ LLCircuitData::~LLCircuitData() std::ostream_iterator<TPACKETID> append(str, " "); str << "MSG: -> " << mHost << "\tABORTING RELIABLE:\t"; std::copy(doomed.begin(), doomed.end(), append); - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } } @@ -204,7 +204,7 @@ void LLCircuitData::ackReliablePacket(TPACKETID packet_num) std::ostringstream str; str << "MSG: <- " << packetp->mHost << "\tRELIABLE ACKED:\t" << packetp->mPacketID; - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } if (packetp->mCallback) { @@ -238,7 +238,7 @@ void LLCircuitData::ackReliablePacket(TPACKETID packet_num) std::ostringstream str; str << "MSG: <- " << packetp->mHost << "\tRELIABLE ACKED:\t" << packetp->mPacketID; - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } if (packetp->mCallback) { @@ -342,7 +342,7 @@ S32 LLCircuitData::resendUnackedPackets(const F64 now) std::ostringstream str; str << "MSG: -> " << packetp->mHost << "\tRESENDING RELIABLE:\t" << packetp->mPacketID; - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } packetp->mBuffer[0] |= LL_RESENT_FLAG; // tag packet id as being a resend @@ -403,7 +403,7 @@ S32 LLCircuitData::resendUnackedPackets(const F64 now) std::ostringstream str; str << "MSG: -> " << packetp->mHost << "\tABORTING RELIABLE:\t" << packetp->mPacketID; - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } if (packetp->mCallback) @@ -710,7 +710,7 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) { std::ostringstream str; str << "MSG: <- " << mHost << "\tRECOVERING LOST:\t" << id; - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } // llinfos << "removing potential lost: " << id << llendl; mPotentialLostPackets.erase(id); @@ -729,7 +729,7 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) std::ostringstream str; str << "MSG: <- " << mHost << "\tPACKET GAP:\t" << index; - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } // llinfos << "adding potential lost: " << index << llendl; @@ -747,7 +747,7 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) std::ostringstream str; str << "MSG: <- " << mHost << "\tPACKET GAP:\t" << id << " expected " << index; - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } } @@ -969,7 +969,7 @@ BOOL LLCircuitData::updateWatchDogTimers(LLMessageSystem *msgsys) std::ostringstream str; str << "MSG: <- " << mHost << "\tLOST PACKET:\t" << (*it).first; - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } mPotentialLostPackets.erase(it++); } @@ -1114,7 +1114,7 @@ void LLCircuit::sendAcks() str << "MSG: -> " << cd->mHost << "\tPACKET ACKS:\t"; std::ostream_iterator<TPACKETID> append(str, " "); std::copy(cd->mAcks.begin(), cd->mAcks.end(), append); - llinfos << str.str().c_str() << llendl; + llinfos << str.str() << llendl; } // empty out the acks list diff --git a/indra/llmessage/lldatapacker.cpp b/indra/llmessage/lldatapacker.cpp index 2ebd1b7176..83fb0b85cd 100644 --- a/indra/llmessage/lldatapacker.cpp +++ b/indra/llmessage/lldatapacker.cpp @@ -170,16 +170,16 @@ BOOL LLDataPacker::unpackFixed(F32 &value, const char *name, // LLDataPackerBinaryBuffer implementation //--------------------------------------------------------------------------- -BOOL LLDataPackerBinaryBuffer::packString(const char *value, const char *name) +BOOL LLDataPackerBinaryBuffer::packString(const std::string& value, const char *name) { BOOL success = TRUE; - S32 length = (S32)strlen(value) + 1; /*Flawfinder: ignore*/ + S32 length = value.length()+1; success &= verifyLength(length, name); if (mWriteEnabled) { - htonmemcpy(mCurBufferp, value, MVT_VARIABLE, length); + htonmemcpy(mCurBufferp, value.c_str(), MVT_VARIABLE, length); } mCurBufferp += length; return success; @@ -577,18 +577,18 @@ void LLDataPackerBinaryBuffer::dumpBufferToLog() //--------------------------------------------------------------------------- // LLDataPackerAsciiBuffer implementation //--------------------------------------------------------------------------- -BOOL LLDataPackerAsciiBuffer::packString(const char *value, const char *name) +BOOL LLDataPackerAsciiBuffer::packString(const std::string& value, const char *name) { BOOL success = TRUE; writeIndentedName(name); int numCopied = 0; if (mWriteEnabled) { - numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", value); /* Flawfinder: ignore */ + numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", value.c_str()); /* Flawfinder: ignore */ } else { - numCopied = (S32)strlen(value) + 1; /*Flawfinder: ignore*/ + numCopied = value.length() + 1; /*Flawfinder: ignore*/ } // snprintf returns number of bytes that would have been written @@ -1242,9 +1242,9 @@ BOOL LLDataPackerAsciiBuffer::packUUID(const LLUUID &value, const char *name) int numCopied = 0; if (mWriteEnabled) { - char tmp_str[64]; /* Flawfinder: ignore */ + std::string tmp_str; value.toString(tmp_str); - numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", tmp_str); /* Flawfinder: ignore */ + numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", tmp_str.c_str()); /* Flawfinder: ignore */ } else { @@ -1376,13 +1376,13 @@ std::string convertF32ToString(F32 val) //--------------------------------------------------------------------------- // LLDataPackerAsciiFile implementation //--------------------------------------------------------------------------- -BOOL LLDataPackerAsciiFile::packString(const char *value, const char *name) +BOOL LLDataPackerAsciiFile::packString(const std::string& value, const char *name) { BOOL success = TRUE; writeIndentedName(name); if (mFP) { - fprintf(mFP,"%s\n", value); + fprintf(mFP,"%s\n", value.c_str()); } else if (mOutputStream) { @@ -1829,11 +1829,11 @@ BOOL LLDataPackerAsciiFile::packUUID(const LLUUID &value, const char *name) { BOOL success = TRUE; writeIndentedName(name); - char tmp_str[64]; /*Flawfinder: ignore */ + std::string tmp_str; value.toString(tmp_str); if (mFP) { - fprintf(mFP,"%s\n", tmp_str); + fprintf(mFP,"%s\n", tmp_str.c_str()); } else if (mOutputStream) { @@ -1877,7 +1877,7 @@ void LLDataPackerAsciiFile::writeIndentedName(const char *name) } else if (mOutputStream) { - *mOutputStream << indent_buf.c_str() << name << "\t"; + *mOutputStream << indent_buf << name << "\t"; } } diff --git a/indra/llmessage/lldatapacker.h b/indra/llmessage/lldatapacker.h index d6d1f5c1da..eac70e8c78 100644 --- a/indra/llmessage/lldatapacker.h +++ b/indra/llmessage/lldatapacker.h @@ -49,7 +49,7 @@ public: virtual BOOL hasNext() const = 0; - virtual BOOL packString(const char *value, const char *name) = 0; + virtual BOOL packString(const std::string& value, const char *name) = 0; virtual BOOL unpackString(std::string& value, const char *name) = 0; virtual BOOL packBinaryData(const U8 *value, S32 size, const char *name) = 0; @@ -127,7 +127,7 @@ public: { } - /*virtual*/ BOOL packString(const char *value, const char *name); + /*virtual*/ BOOL packString(const std::string& value, const char *name); /*virtual*/ BOOL unpackString(std::string& value, const char *name); /*virtual*/ BOOL packBinaryData(const U8 *value, S32 size, const char *name); @@ -229,7 +229,7 @@ public: mWriteEnabled = FALSE; } - /*virtual*/ BOOL packString(const char *value, const char *name); + /*virtual*/ BOOL packString(const std::string& value, const char *name); /*virtual*/ BOOL unpackString(std::string& value, const char *name); /*virtual*/ BOOL packBinaryData(const U8 *value, S32 size, const char *name); @@ -358,7 +358,7 @@ public: { } - /*virtual*/ BOOL packString(const char *value, const char *name); + /*virtual*/ BOOL packString(const std::string& value, const char *name); /*virtual*/ BOOL unpackString(std::string& value, const char *name); /*virtual*/ BOOL packBinaryData(const U8 *value, S32 size, const char *name); diff --git a/indra/llmessage/lldispatcher.cpp b/indra/llmessage/lldispatcher.cpp index d0e1e68b8a..64bfb04ea7 100644 --- a/indra/llmessage/lldispatcher.cpp +++ b/indra/llmessage/lldispatcher.cpp @@ -111,8 +111,7 @@ bool LLDispatcher::unpackMessage( LLDispatcher::sparam_t& parameters) { char buf[MAX_STRING]; /*Flawfinder: ignore*/ - msg->getStringFast(_PREHASH_MethodData, _PREHASH_Method, MAX_STRING, buf); - method.assign(buf); + msg->getStringFast(_PREHASH_MethodData, _PREHASH_Method, method); msg->getUUIDFast(_PREHASH_MethodData, _PREHASH_Invoice, invoice); S32 size; S32 count = msg->getNumberOfBlocksFast(_PREHASH_ParamList); diff --git a/indra/llmessage/llhost.cpp b/indra/llmessage/llhost.cpp index 4d10f06051..48666ffde7 100644 --- a/indra/llmessage/llhost.cpp +++ b/indra/llmessage/llhost.cpp @@ -66,34 +66,15 @@ LLHost::LLHost(const std::string& ip_and_port) } } -void LLHost::getString(char* buffer, S32 length) const +std::string LLHost::getString() const { - if (((U32) length) < MAXADDRSTR + 1 + 5) - { - llerrs << "LLHost::getString - string too short" << llendl; - return; - } - - snprintf(buffer, length, "%s:%u", u32_to_ip_string(mIP), mPort); /* Flawfinder: ignore */ -} - -void LLHost::getIPString(char* buffer, S32 length) const -{ - if ( ((U32) length) < MAXADDRSTR) - { - llerrs << "LLHost::getIPString - string too short" << llendl; - return; - } - - snprintf(buffer, length, "%s", u32_to_ip_string(mIP)); /* Flawfinder: ignore */ + return llformat("%s:%u", u32_to_ip_string(mIP), mPort); } std::string LLHost::getIPandPort() const { - char buffer[MAXADDRSTR + 1 + 5]; /*Flawfinder: ignore*/ - getString(buffer, sizeof(buffer)); - return buffer; + return getString(); } @@ -103,35 +84,6 @@ std::string LLHost::getIPString() const } -void LLHost::getHostName(char *buf, S32 len) const -{ - hostent *he; - - if (INVALID_HOST_IP_ADDRESS == mIP) - { - llwarns << "LLHost::getHostName() : Invalid IP address" << llendl; - buf[0] = '\0'; - return; - } - he = gethostbyaddr((char *)&mIP, sizeof(mIP), AF_INET); - if (!he) - { -#if LL_WINDOWS - llwarns << "LLHost::getHostName() : Couldn't find host name for address " << mIP << ", Error: " - << WSAGetLastError() << llendl; -#else - llwarns << "LLHost::getHostName() : Couldn't find host name for address " << mIP << ", Error: " - << h_errno << llendl; -#endif - buf[0] = '\0'; - } - else - { - strncpy(buf, he->h_name, len); /*Flawfinder: ignore*/ - buf[len-1] = '\0'; - } -} - std::string LLHost::getHostName() const { hostent* he; @@ -158,28 +110,20 @@ std::string LLHost::getHostName() const } } -BOOL LLHost::setHostByName(const char *string) +BOOL LLHost::setHostByName(const std::string& hostname) { hostent *he; - char local_name[MAX_STRING]; /*Flawfinder: ignore*/ - - if (strlen(string)+1 > MAX_STRING) /*Flawfinder: ignore*/ - { - llerrs << "LLHost::setHostByName() : Address string is too long: " - << string << llendl; - } + std::string local_name(hostname); - strncpy(local_name, string,MAX_STRING); /*Flawfinder: ignore*/ - local_name[MAX_STRING-1] = '\0'; #if LL_WINDOWS // We may need an equivalent for Linux, but not sure - djs - _strupr(local_name); + LLStringUtil::toUpper(local_name); #endif - he = gethostbyname(local_name); + he = gethostbyname(local_name.c_str()); if(!he) { - U32 ip_address = inet_addr(string); + U32 ip_address = inet_addr(hostname.c_str()); he = gethostbyaddr((char *)&ip_address, sizeof(ip_address), AF_INET); } diff --git a/indra/llmessage/llhost.h b/indra/llmessage/llhost.h index a865ad616c..516150540f 100644 --- a/indra/llmessage/llhost.h +++ b/indra/llmessage/llhost.h @@ -61,10 +61,10 @@ public: mIP = ipv4_addr; } - LLHost( const char *ipv4_addr, U32 port ) + LLHost( const std::string& ipv4_addr, U32 port ) : mPort( port ) { - mIP = ip_string_to_u32(ipv4_addr); + mIP = ip_string_to_u32(ipv4_addr.c_str()); } explicit LLHost(const U64 ip_port) @@ -82,11 +82,11 @@ public: // MANIPULATORS void set( U32 ip, U32 port ) { mIP = ip; mPort = port; } - void set( const char* ipstr, U32 port ) { mIP = ip_string_to_u32(ipstr); mPort = port; } - void setAddress( const char* ipstr ) { mIP = ip_string_to_u32(ipstr); } + void set( const std::string& ipstr, U32 port ) { mIP = ip_string_to_u32(ipstr.c_str()); mPort = port; } + void setAddress( const std::string& ipstr ) { mIP = ip_string_to_u32(ipstr.c_str()); } void setAddress( U32 ip ) { mIP = ip; } void setPort( U32 port ) { mPort = port; } - BOOL setHostByName(const char *hname); + BOOL setHostByName(const std::string& hname); LLHost& operator=(const LLHost &rhs); void invalidate() { mIP = INVALID_HOST_IP_ADDRESS; mPort = INVALID_PORT;}; @@ -96,10 +96,8 @@ public: U32 getPort() const { return mPort; } BOOL isOk() const { return (mIP != INVALID_HOST_IP_ADDRESS) && (mPort != INVALID_PORT); } size_t hash() const { return (mIP << 16) | (mPort & 0xffff); } - void getString(char* buffer, S32 length) const; // writes IP:port into buffer - void getIPString(char* buffer, S32 length) const; // writes IP into buffer + std::string getString() const; std::string getIPString() const; - void getHostName(char *buf, S32 len) const; std::string getHostName() const; std::string getIPandPort() const; diff --git a/indra/llmessage/llhttpassetstorage.cpp b/indra/llmessage/llhttpassetstorage.cpp index e5254bbc0f..6332c247a9 100644 --- a/indra/llmessage/llhttpassetstorage.cpp +++ b/indra/llmessage/llhttpassetstorage.cpp @@ -81,8 +81,8 @@ class LLHTTPAssetRequest : public LLAssetRequest { public: LLHTTPAssetRequest(LLHTTPAssetStorage *asp, const LLUUID &uuid, - LLAssetType::EType type, LLAssetStorage::ERequestType rt, - const char *url, CURLM *curl_multi); + LLAssetType::EType type, LLAssetStorage::ERequestType rt, + const std::string& url, CURLM *curl_multi); virtual ~LLHTTPAssetRequest(); void setupCurlHandle(); @@ -103,7 +103,7 @@ public: CURL *mCurlHandle; CURLM *mCurlMultiHandle; - char *mURLBuffer; + std::string mURLBuffer; struct curl_slist *mHTTPHeaders; LLVFile *mVFile; LLUUID mTmpUUID; @@ -122,7 +122,7 @@ LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, const LLUUID &uuid, LLAssetType::EType type, LLAssetStorage::ERequestType rt, - const char *url, + const std::string& url, CURLM *curl_multi) : LLAssetRequest(uuid, type), mZInitialized(false) @@ -137,11 +137,7 @@ LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, mZInputBuffer = NULL; mZInputExhausted = false; - mURLBuffer = new char[strlen(url) + 1]; /*Flawfinder: ignore*/ - if (mURLBuffer) - { - strcpy(mURLBuffer, url); /*Flawfinder: ignore*/ - } + mURLBuffer = url; } LLHTTPAssetRequest::~LLHTTPAssetRequest() @@ -156,7 +152,6 @@ LLHTTPAssetRequest::~LLHTTPAssetRequest() { curl_slist_free_all(mHTTPHeaders); } - delete[] mURLBuffer; delete mVFile; finishCompressedUpload(); } @@ -242,7 +237,7 @@ void LLHTTPAssetRequest::setupCurlHandle() mCurlHandle = curl_easy_init(); curl_easy_setopt(mCurlHandle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1); - curl_easy_setopt(mCurlHandle, CURLOPT_URL, mURLBuffer); + curl_easy_setopt(mCurlHandle, CURLOPT_URL, mURLBuffer.c_str()); curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, this); if (LLAssetStorage::RT_DOWNLOAD == mRequestType) { @@ -400,9 +395,9 @@ size_t LLHTTPAssetRequest::curlCompressedUploadCallback( LLHTTPAssetStorage::LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, LLVFS *vfs, const LLHost &upstream_host, - const char *web_host, - const char *local_web_host, - const char *host_name) + const std::string& web_host, + const std::string& local_web_host, + const std::string& host_name) : LLAssetStorage(msg, xfer, vfs, upstream_host) { _init(web_host, local_web_host, host_name); @@ -410,15 +405,15 @@ LLHTTPAssetStorage::LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer LLHTTPAssetStorage::LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, LLVFS *vfs, - const char *web_host, - const char *local_web_host, - const char *host_name) + const std::string& web_host, + const std::string& local_web_host, + const std::string& host_name) : LLAssetStorage(msg, xfer, vfs) { _init(web_host, local_web_host, host_name); } -void LLHTTPAssetStorage::_init(const char *web_host, const char *local_web_host, const char* host_name) +void LLHTTPAssetStorage::_init(const std::string& web_host, const std::string& local_web_host, const std::string& host_name) { mBaseURL = web_host; mLocalBaseURL = local_web_host; @@ -470,7 +465,7 @@ void LLHTTPAssetStorage::storeAssetData( { message = "Added to upload queue"; } - reportMetric( uuid, type, NULL, requesting_agent_id, size, MR_OKAY, __FILE__, __LINE__, message ); + reportMetric( uuid, type, LLStringUtil::null, requesting_agent_id, size, MR_OKAY, __FILE__, __LINE__, message ); // this will get picked up and transmitted in checkForTimeouts if(store_local) @@ -492,7 +487,7 @@ void LLHTTPAssetStorage::storeAssetData( if (callback) { // LLAssetStorage metric: Zero size VFS - reportMetric( uuid, type, NULL, requesting_agent_id, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" ); + reportMetric( uuid, type, LLStringUtil::null, requesting_agent_id, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" ); callback(uuid, user_data, LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_NONEXISTENT_FILE); } } @@ -500,7 +495,7 @@ void LLHTTPAssetStorage::storeAssetData( // virtual void LLHTTPAssetStorage::storeAssetData( - const char* filename, + const std::string& filename, const LLUUID& asset_id, LLAssetType::EType asset_type, LLStoreAssetCallback callback, @@ -597,7 +592,7 @@ LLSD LLHTTPAssetStorage::getPendingDetails(LLAssetStorage::ERequestType rt, LLSD& pending = sd["requests"][i]; // See if this pending request is running. const LLAssetRequest* req = findRequest(running, - LLAssetType::lookup(pending["type"].asString().c_str()), + LLAssetType::lookup(pending["type"].asString()), pending["asset_id"]); if (req) { @@ -768,11 +763,11 @@ void LLHTTPAssetStorage::checkForTimeouts() // Setup this curl download request // We need to generate a new request here // since the one in the list could go away - char tmp_url[MAX_STRING]; /*Flawfinder: ignore*/ - char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string tmp_url; + std::string uuid_str; req->getUUID().toString(uuid_str); std::string base_url = getBaseURL(req->getUUID(), req->getType()); - snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", base_url.c_str() , uuid_str, LLAssetType::lookup(req->getType())); /* Flawfinder: ignore */ + tmp_url = llformat("%s/%36s.%s", base_url.c_str() , uuid_str.c_str(), LLAssetType::lookup(req->getType())); LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), req->getType(), RT_DOWNLOAD, tmp_url, mCurlMultiHandle); @@ -805,12 +800,11 @@ void LLHTTPAssetStorage::checkForTimeouts() bool do_compress = req->getType() == LLAssetType::AT_OBJECT; - char tmp_url[MAX_STRING];/*Flawfinder: ignore*/ - char uuid_str[UUID_STR_LENGTH];/*Flawfinder: ignore*/ + std::string tmp_url; + std::string uuid_str; req->getUUID().toString(uuid_str); - snprintf(tmp_url, sizeof(tmp_url), /* Flawfinder: ignore */ - do_compress ? "%s/%s.%s.gz" : "%s/%s.%s", - mBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); + tmp_url = mBaseURL + "/" + uuid_str + "." + LLAssetType::lookup(req->getType()); + if (do_compress) tmp_url += ".gz"; LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), req->getType(), RT_UPLOAD, tmp_url, mCurlMultiHandle); @@ -876,12 +870,12 @@ void LLHTTPAssetStorage::checkForTimeouts() // setup this curl upload request LLVFile file(mVFS, req->getUUID(), req->getType()); - char tmp_url[MAX_STRING]; /*Flawfinder: ignore*/ - char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string tmp_url; + std::string uuid_str; req->getUUID().toString(uuid_str); // KLW - All temporary uploads are saved locally "http://localhost:12041/asset" - snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); /* Flawfinder: ignore */ + tmp_url = llformat("%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str.c_str(), LLAssetType::lookup(req->getType())); LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), req->getType(), RT_LOCALUPLOAD, tmp_url, mCurlMultiHandle); @@ -1160,7 +1154,7 @@ size_t LLHTTPAssetStorage::nullOutputCallback(void *data, size_t size, size_t nm // blocking asset fetch which bypasses the VFS // this is a very limited function for use by the simstate loader and other one-offs -S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const LLString &url, const char *filename, progress_callback callback, void *userdata) +S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const std::string &url, const std::string& filename, progress_callback callback, void *userdata) { // *NOTE: There is no guarantee that the uuid and the asset_type match // - not that it matters. - Doug @@ -1174,7 +1168,7 @@ S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asse } // make sure we use the normal curl setup, even though we don't really need a request object - LLHTTPAssetRequest req(this, uuid, asset_type, RT_DOWNLOAD, url.c_str(), mCurlMultiHandle); + LLHTTPAssetRequest req(this, uuid, asset_type, RT_DOWNLOAD, url, mCurlMultiHandle); req.mFP = fp; req.setupCurlHandle(); diff --git a/indra/llmessage/llhttpassetstorage.h b/indra/llmessage/llhttpassetstorage.h index e6ec39e27e..91876eb969 100644 --- a/indra/llmessage/llhttpassetstorage.h +++ b/indra/llmessage/llhttpassetstorage.h @@ -48,15 +48,15 @@ class LLHTTPAssetStorage : public LLAssetStorage public: LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, LLVFS *vfs, const LLHost &upstream_host, - const char *web_host, - const char *local_web_host, - const char *host_name); + const std::string& web_host, + const std::string& local_web_host, + const std::string& host_name); LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, LLVFS *vfs, - const char *web_host, - const char *local_web_host, - const char *host_name); + const std::string& web_host, + const std::string& local_web_host, + const std::string& host_name); virtual ~LLHTTPAssetStorage(); @@ -74,7 +74,7 @@ public: F64 timeout=LL_ASSET_STORAGE_TIMEOUT); virtual void storeAssetData( - const char* filename, + const std::string& filename, const LLUUID& asset_id, LLAssetType::EType atype, LLStoreAssetCallback callback, @@ -99,7 +99,7 @@ public: // Hack. One off curl download an URL to a file. Probably should be elsewhere. // Only used by lldynamicstate. The API is broken, and should be replaced with // a generic HTTP file fetch - Doug 9/25/06 - S32 getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const LLString &url, const char *filename, progress_callback callback, void *userdata); + S32 getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const std::string &url, const std::string& filename, progress_callback callback, void *userdata); LLAssetRequest* findNextRequest(request_list_t& pending, request_list_t& running); @@ -135,7 +135,7 @@ protected: void *user_data, BOOL duplicate, BOOL is_priority); private: - void _init(const char *web_host, const char *local_web_host, const char* host_name); + void _init(const std::string& web_host, const std::string& local_web_host, const std::string& host_name); // This will return the correct base URI for any http asset request std::string getBaseURL(const LLUUID& asset_id, LLAssetType::EType asset_type); diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index 52cb8fe1c3..2937edd853 100644 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -152,7 +152,7 @@ namespace { LLBufferStream ostream(channels, buffer.get()); - llifstream fstream(mFilename.c_str(), std::iostream::binary | std::iostream::out); + llifstream fstream(mFilename, std::iostream::binary | std::iostream::out); fstream.seekg(0, std::ios::end); U32 fileSize = fstream.tellg(); fstream.seekg(0, std::ios::beg); diff --git a/indra/llmessage/llhttpsender.cpp b/indra/llmessage/llhttpsender.cpp index 096bc73e0b..6e86947e6a 100644 --- a/indra/llmessage/llhttpsender.cpp +++ b/indra/llmessage/llhttpsender.cpp @@ -52,7 +52,7 @@ LLHTTPSender::~LLHTTPSender() } //virtual -void LLHTTPSender::send(const LLHost& host, const char* name, +void LLHTTPSender::send(const LLHost& host, const std::string& name, const LLSD& body, LLHTTPClient::ResponderPtr response) const { diff --git a/indra/llmessage/llhttpsender.h b/indra/llmessage/llhttpsender.h index 3a6cd681fa..e555b4485c 100644 --- a/indra/llmessage/llhttpsender.h +++ b/indra/llmessage/llhttpsender.h @@ -45,7 +45,7 @@ class LLHTTPSender /** @brief Send message to host with body, call response when done */ virtual void send(const LLHost& host, - const char* message, const LLSD& body, + const std::string& message, const LLSD& body, LLHTTPClient::ResponderPtr response) const; /** @brief Set sender for host, takes ownership of sender. */ diff --git a/indra/llmessage/llinstantmessage.cpp b/indra/llmessage/llinstantmessage.cpp index 04af44fe26..a7fac2dfc3 100644 --- a/indra/llmessage/llinstantmessage.cpp +++ b/indra/llmessage/llinstantmessage.cpp @@ -59,7 +59,7 @@ const S32 VOTE_UNANIMOUS = 2; const char EMPTY_BINARY_BUCKET[] = ""; const S32 EMPTY_BINARY_BUCKET_SIZE = 1; const U32 NO_TIMESTAMP = 0; -const char SYSTEM_FROM[] = "Second Life"; +const std::string SYSTEM_FROM("Second Life"); const S32 IM_TTL = 1; @@ -144,8 +144,8 @@ void LLIMInfo::packMessageBlock(LLMessageSystem* msg) const mFromGroup, LLUUID::null, mToID, - mName.c_str(), - mMessage.c_str(), + mName, + mMessage, mOffline, mIMType, mID, @@ -163,8 +163,8 @@ void pack_instant_message( BOOL from_group, const LLUUID& session_id, const LLUUID& to_id, - const char* name, - const char* message, + const std::string& name, + const std::string& message, U8 offline, EInstantMessage dialog, const LLUUID& id, @@ -202,8 +202,8 @@ void pack_instant_message_block( BOOL from_group, const LLUUID& session_id, const LLUUID& to_id, - const char* name, - const char* message, + const std::string& name, + const std::string& message, U8 offline, EInstantMessage dialog, const LLUUID& id, @@ -229,10 +229,10 @@ void pack_instant_message_block( msg->addU32Fast(_PREHASH_Timestamp, timestamp); msg->addStringFast(_PREHASH_FromAgentName, name); S32 bytes_left = MTUBYTES; - if(message) + if(!message.empty()) { char buffer[MTUBYTES]; - int num_written = snprintf(buffer, MTUBYTES, "%s", message); /* Flawfinder: ignore */ + int num_written = snprintf(buffer, MTUBYTES, "%s", message.c_str()); /* Flawfinder: ignore */ // snprintf returns number of bytes that would have been written // had the output not being truncated. In that case, it will // return either -1 or value >= passed in size value . So a check needs to be added @@ -281,13 +281,9 @@ void LLIMInfo::unpackMessageBlock(LLMessageSystem* msg) mIMType = (EInstantMessage) dialog; msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ID, mID); msg->getU32Fast(_PREHASH_MessageBlock, _PREHASH_Timestamp, mTimeStamp); - char name[DB_FULL_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ - msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, DB_FULL_NAME_BUF_SIZE, name); - mName.assign(name); + msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, mName); - char message[DB_IM_MSG_BUF_SIZE]; /*Flawfinder: ignore*/ - msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, DB_IM_MSG_BUF_SIZE, message); - mMessage.assign(message); + msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, mMessage); S32 binary_bucket_size = llmin( MTUBYTES, diff --git a/indra/llmessage/llinstantmessage.h b/indra/llmessage/llinstantmessage.h index 9645d4a763..251c1bc85c 100644 --- a/indra/llmessage/llinstantmessage.h +++ b/indra/llmessage/llinstantmessage.h @@ -222,7 +222,7 @@ extern const char EMPTY_BINARY_BUCKET[]; extern const S32 EMPTY_BINARY_BUCKET_SIZE; extern const U32 NO_TIMESTAMP; -extern const char SYSTEM_FROM[]; +extern const std::string SYSTEM_FROM; // Number of retry attempts on sending the im. extern const S32 IM_TTL; @@ -289,8 +289,8 @@ void pack_instant_message( BOOL from_group, const LLUUID& session_id, const LLUUID& to_id, - const char* name, - const char* message, + const std::string& name, + const std::string& message, U8 offline = IM_ONLINE, EInstantMessage dialog = IM_NOTHING_SPECIAL, const LLUUID& id = LLUUID::null, @@ -307,8 +307,8 @@ void pack_instant_message_block( BOOL from_group, const LLUUID& session_id, const LLUUID& to_id, - const char* name, - const char* message, + const std::string& name, + const std::string& message, U8 offline = IM_ONLINE, EInstantMessage dialog = IM_NOTHING_SPECIAL, const LLUUID& id = LLUUID::null, diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index 90f8ef7638..a2e0325ae7 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -707,7 +707,7 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl( read_next_line = true; std::string name(buf, pos_colon - buf); std::string value(pos_colon + 2); - LLString::toLower(name); + LLStringUtil::toLower(name); if("content-length" == name) { lldebugs << "Content-Length: " << value << llendl; @@ -715,7 +715,7 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl( } else { - LLString::trimTail(value); + LLStringUtil::trimTail(value); mHeaders[name] = value; } } diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index ff7c32aee8..ad309434ac 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -220,11 +220,11 @@ bool LLSocket::blockingConnect(const LLHost& host) { if(!mSocket) return false; apr_sockaddr_t* sa = NULL; - char ip_address[MAXADDRSTR]; /*Flawfinder: ignore*/ - host.getIPString(ip_address, MAXADDRSTR); + std::string ip_address; + ip_address = host.getIPString(); if(ll_apr_warn_status(apr_sockaddr_info_get( &sa, - ip_address, + ip_address.c_str(), APR_UNSPEC, host.getPort(), 0, diff --git a/indra/llmessage/llmail.cpp b/indra/llmessage/llmail.cpp index 1a076b7281..6a8931cf73 100644 --- a/indra/llmessage/llmail.cpp +++ b/indra/llmessage/llmail.cpp @@ -365,7 +365,7 @@ std::string LLMail::encryptIMEmailAddress(const LLUUID& from_agent_id, std::string address = LLBase32::encode(encrypted, encrypted_size); // Make it more pretty for humans. - LLString::toLower(address); + LLStringUtil::toLower(address); delete [] encrypted; diff --git a/indra/llmessage/llmessageconfig.cpp b/indra/llmessage/llmessageconfig.cpp index 259daada77..0159eb3562 100644 --- a/indra/llmessage/llmessageconfig.cpp +++ b/indra/llmessage/llmessageconfig.cpp @@ -97,7 +97,7 @@ void LLMessageConfigFile::loadFile() { LLSD data; { - llifstream file(filename().c_str()); + llifstream file(filename()); if (file.is_open()) { diff --git a/indra/llmessage/llmessagereader.h b/indra/llmessage/llmessagereader.h index 4687191494..3de94a1d8f 100644 --- a/indra/llmessage/llmessagereader.h +++ b/indra/llmessage/llmessagereader.h @@ -69,6 +69,7 @@ class LLMessageReader virtual void getIPAddr(const char *block, const char *var, U32 &ip, S32 blocknum = 0) = 0; virtual void getIPPort(const char *block, const char *var, U16 &port, S32 blocknum = 0) = 0; virtual void getString(const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0) = 0; + virtual void getString(const char *block, const char *var, std::string& outstr, S32 blocknum = 0) = 0; virtual S32 getNumberOfBlocks(const char *blockname) = 0; virtual S32 getSize(const char *blockname, const char *varname) = 0; diff --git a/indra/llmessage/llmessagethrottle.cpp b/indra/llmessage/llmessagethrottle.cpp index 912980d738..846d4067ad 100644 --- a/indra/llmessage/llmessagethrottle.cpp +++ b/indra/llmessage/llmessagethrottle.cpp @@ -110,7 +110,7 @@ void LLMessageThrottle::pruneEntries() } } -BOOL LLMessageThrottle::addViewerAlert(const LLUUID& to, const char* mesg) +BOOL LLMessageThrottle::addViewerAlert(const LLUUID& to, const std::string& mesg) { message_list_t* message_list = &(mMessageList[MTC_VIEWER_ALERT]); @@ -144,7 +144,7 @@ BOOL LLMessageThrottle::addViewerAlert(const LLUUID& to, const char* mesg) } } -BOOL LLMessageThrottle::addAgentAlert(const LLUUID& agent, const LLUUID& task, const char* mesg) +BOOL LLMessageThrottle::addAgentAlert(const LLUUID& agent, const LLUUID& task, const std::string& mesg) { message_list_t* message_list = &(mMessageList[MTC_AGENT_ALERT]); diff --git a/indra/llmessage/llmessagethrottle.h b/indra/llmessage/llmessagethrottle.h index a3267e7d9d..43c0809d94 100644 --- a/indra/llmessage/llmessagethrottle.h +++ b/indra/llmessage/llmessagethrottle.h @@ -64,8 +64,8 @@ public: LLMessageThrottle(); ~LLMessageThrottle(); - BOOL addViewerAlert (const LLUUID& to, const char* mesg); - BOOL addAgentAlert (const LLUUID& agent, const LLUUID& task, const char* mesg); + BOOL addViewerAlert (const LLUUID& to, const std::string& mesg); + BOOL addAgentAlert (const LLUUID& agent, const LLUUID& task, const std::string& mesg); void pruneEntries(); diff --git a/indra/llmessage/llmime.cpp b/indra/llmessage/llmime.cpp index 7d43f38e9a..de46a50bd9 100644 --- a/indra/llmessage/llmime.cpp +++ b/indra/llmessage/llmime.cpp @@ -439,9 +439,7 @@ bool LLMimeParser::Impl::parseHeaders( std::string value(colon); for(S32 ii = 0; ii < KNOWN_HEADER_COUNT; ++ii) { - if(0 == LLString::compareInsensitive( - name.c_str(), - KNOWN_HEADER[ii].c_str())) + if(0 == LLStringUtil::compareInsensitive(name, KNOWN_HEADER[ii])) { name = KNOWN_HEADER[ii]; break; @@ -525,7 +523,7 @@ void LLMimeParser::Impl::scanPastSeparator( { mContinue = false; } - if(0 == LLString::compareStrings(mBuffer, separator.c_str())) + if(0 == LLStringUtil::compareStrings(std::string(mBuffer), separator)) { found_separator = true; } diff --git a/indra/llmessage/llnamevalue.cpp b/indra/llmessage/llnamevalue.cpp index 3503458a3b..13dca3e51f 100644 --- a/indra/llmessage/llnamevalue.cpp +++ b/indra/llmessage/llnamevalue.cpp @@ -155,7 +155,7 @@ void LLNameValue::init(const char *name, const char *data, const char *type, con else if (!strcmp(mStringType, "U64")) { mType = NVT_U64; - mNameValueReference.u64 = new U64(str_to_U64(data)); + mNameValueReference.u64 = new U64(str_to_U64(ll_safe_string(data))); } else if (!strcmp(mStringType, "VEC3")) { diff --git a/indra/llmessage/llsdmessagereader.cpp b/indra/llmessage/llsdmessagereader.cpp index 4ca7895613..b7d0267423 100755 --- a/indra/llmessage/llsdmessagereader.cpp +++ b/indra/llmessage/llsdmessagereader.cpp @@ -243,6 +243,12 @@ void LLSDMessageReader::getString(const char *block, const char *var, buffer[data_size] = '\0'; } +//virtual +void LLSDMessageReader::getString(const char *block, const char *var, + std::string& outstr, S32 blocknum) +{ + outstr = getLLSD(mMessage, block, var, blocknum).asString(); +} //virtual S32 LLSDMessageReader::getNumberOfBlocks(const char *blockname) diff --git a/indra/llmessage/llsdmessagereader.h b/indra/llmessage/llsdmessagereader.h index 66ac1d14ad..bfb0b31218 100755 --- a/indra/llmessage/llsdmessagereader.h +++ b/indra/llmessage/llsdmessagereader.h @@ -87,6 +87,8 @@ public: S32 blocknum = 0); virtual void getString(const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0); + virtual void getString(const char *block, const char *var, std::string& outstr, + S32 blocknum = 0); virtual S32 getNumberOfBlocks(const char *blockname); virtual S32 getSize(const char *blockname, const char *varname); diff --git a/indra/llmessage/llservicebuilder.cpp b/indra/llmessage/llservicebuilder.cpp index 6442767ebd..c262515e74 100644 --- a/indra/llmessage/llservicebuilder.cpp +++ b/indra/llmessage/llservicebuilder.cpp @@ -39,7 +39,7 @@ void LLServiceBuilder::loadServiceDefinitionsFromFile( const std::string& service_filename) { - llifstream service_file(service_filename.c_str(), std::ios::binary); + llifstream service_file(service_filename, std::ios::binary); if(service_file.is_open()) { LLSD service_data; diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp index f9b703b52a..b1395b0b70 100644 --- a/indra/llmessage/lltemplatemessagereader.cpp +++ b/indra/llmessage/lltemplatemessagereader.cpp @@ -171,9 +171,6 @@ S32 LLTemplateMessageReader::getNumberOfBlocks(const char *blockname) if (iter == mCurrentRMessageData->mMemberBlocks.end()) { -// sprintf(errmsg, "Block %s not in message %s", bnamep, mCurrentRMessageData->mName); -// llerrs << errmsg << llendl; -// return -1; return 0; } @@ -433,6 +430,15 @@ inline void LLTemplateMessageReader::getString(const char *block, const char *va s[buffer_size - 1] = '\0'; } +inline void LLTemplateMessageReader::getString(const char *block, const char *var, std::string& outstr, S32 blocknum ) +{ + char s[MTUBYTES]; + s[0] = '\0'; + getData(block, var, s, 0, blocknum, MTUBYTES); + s[MTUBYTES - 1] = '\0'; + outstr = s; +} + //virtual S32 LLTemplateMessageReader::getMessageSize() const { diff --git a/indra/llmessage/lltemplatemessagereader.h b/indra/llmessage/lltemplatemessagereader.h index 42cd90ea94..ea3ec9a3d8 100644 --- a/indra/llmessage/lltemplatemessagereader.h +++ b/indra/llmessage/lltemplatemessagereader.h @@ -88,6 +88,8 @@ public: S32 blocknum = 0); virtual void getString(const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0); + virtual void getString(const char *block, const char *var, std::string& outstr, + S32 blocknum = 0); virtual S32 getNumberOfBlocks(const char *blockname); virtual S32 getSize(const char *blockname, const char *varname); diff --git a/indra/llmessage/lltransfersourcefile.cpp b/indra/llmessage/lltransfersourcefile.cpp index 268421627e..5088b33e0e 100644 --- a/indra/llmessage/lltransfersourcefile.cpp +++ b/indra/llmessage/lltransfersourcefile.cpp @@ -67,7 +67,7 @@ void LLTransferSourceFile::initTransfer() return; } // Look for the file. - mFP = LLFile::fopen(mParams.getFilename().c_str(), "rb"); /* Flawfinder: ignore */ + mFP = LLFile::fopen(mParams.getFilename(), "rb"); /* Flawfinder: ignore */ if (!mFP) { sendTransferStatus(LLTS_ERROR); @@ -134,9 +134,9 @@ void LLTransferSourceFile::completionCallback(const LLTSCode status) } // Delete the file iff the filename begins with "TEMP" - if (mParams.getDeleteOnCompletion() && memcmp(mParams.getFilename().c_str(), "TEMP", 4) == 0) + if (mParams.getDeleteOnCompletion() && mParams.getFilename().substr(0, 4) == "TEMP") { - LLFile::remove(mParams.getFilename().c_str()); + LLFile::remove(mParams.getFilename()); } } @@ -162,7 +162,7 @@ LLTransferSourceParamsFile::LLTransferSourceParamsFile() : void LLTransferSourceParamsFile::packParams(LLDataPacker &dp) const { - dp.packString(mFilename.c_str(), "Filename"); + dp.packString(mFilename, "Filename"); dp.packU8((U8)mDeleteOnCompletion, "Delete"); } diff --git a/indra/llmessage/lltransfersourcefile.h b/indra/llmessage/lltransfersourcefile.h index 84a6bd259f..0aa0eb8458 100644 --- a/indra/llmessage/lltransfersourcefile.h +++ b/indra/llmessage/lltransfersourcefile.h @@ -42,7 +42,7 @@ public: /*virtual*/ void packParams(LLDataPacker &dp) const; /*virtual*/ BOOL unpackParams(LLDataPacker &dp); - void setFilename(const LLString &filename) { mFilename = filename; } + void setFilename(const std::string &filename) { mFilename = filename; } std::string getFilename() const { return mFilename; } void setDeleteOnCompletion(BOOL enabled) { mDeleteOnCompletion = enabled; } diff --git a/indra/llmessage/lltransfertargetfile.cpp b/indra/llmessage/lltransfertargetfile.cpp index d05f80834a..64c001ed6e 100644 --- a/indra/llmessage/lltransfertargetfile.cpp +++ b/indra/llmessage/lltransfertargetfile.cpp @@ -80,7 +80,7 @@ LLTSCode LLTransferTargetFile::dataCallback(const S32 packet_id, U8 *in_datap, c if (!mFP) { - mFP = LLFile::fopen(mParams.mFilename.c_str(), "wb"); /* Flawfinder: ignore */ + mFP = LLFile::fopen(mParams.mFilename, "wb"); /* Flawfinder: ignore */ if (!mFP) { @@ -122,7 +122,7 @@ void LLTransferTargetFile::completionCallback(const LLTSCode status) if (mFP) { // Only need to remove file if we successfully opened it. - LLFile::remove(mParams.mFilename.c_str()); + LLFile::remove(mParams.mFilename); } default: break; diff --git a/indra/llmessage/lltransfertargetfile.h b/indra/llmessage/lltransfertargetfile.h index 6b837f4890..ba34ba1123 100644 --- a/indra/llmessage/lltransfertargetfile.h +++ b/indra/llmessage/lltransfertargetfile.h @@ -40,12 +40,12 @@ class LLTransferTargetParamsFile : public LLTransferTargetParams { public: LLTransferTargetParamsFile() : LLTransferTargetParams(LLTTT_FILE) {} - void setFilename(const LLString& filename) { mFilename = filename; } + void setFilename(const std::string& filename) { mFilename = filename; } void setCallback(LLTTFCompleteCallback cb, void *user_data) { mCompleteCallback = cb; mUserData = user_data; } friend class LLTransferTargetFile; protected: - LLString mFilename; + std::string mFilename; LLTTFCompleteCallback mCompleteCallback; void * mUserData; }; diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index e7be235221..5ac55bc83d 100644 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -542,7 +542,7 @@ LLIOPipe::EStatus LLContextURLExtractor::process_impl( // find the context url if(context.has(CONTEXT_DEST_URI_SD_LABEL)) { - mRequest->setURL(context[CONTEXT_DEST_URI_SD_LABEL]); + mRequest->setURL(context[CONTEXT_DEST_URI_SD_LABEL].asString()); return STATUS_DONE; } return STATUS_ERROR; diff --git a/indra/llmessage/llxfer.cpp b/indra/llmessage/llxfer.cpp index fefb6f9c63..5682b1c454 100644 --- a/indra/llmessage/llxfer.cpp +++ b/indra/llmessage/llxfer.cpp @@ -103,7 +103,7 @@ void LLXfer::free () S32 LLXfer::startSend (U64 xfer_id, const LLHost &remote_host) { - llwarns << "undifferentiated LLXfer::startSend for " << getName() << llendl; + llwarns << "undifferentiated LLXfer::startSend for " << getFileName() << llendl; return (-1); } @@ -119,7 +119,7 @@ void LLXfer::setXferSize (S32 xfer_size) S32 LLXfer::startDownload() { - llwarns << "undifferentiated LLXfer::startDownload for " << getName() + llwarns << "undifferentiated LLXfer::startDownload for " << getFileName() << llendl; return (-1); } @@ -293,13 +293,13 @@ S32 LLXfer::processEOF() if (LL_ERR_NOERR == mCallbackResult) { - llinfos << "xfer from " << mRemoteHost << " complete: " << getName() + llinfos << "xfer from " << mRemoteHost << " complete: " << getFileName() << llendl; } else { llinfos << "xfer from " << mRemoteHost << " failed, code " - << mCallbackResult << ": " << getName() << llendl; + << mCallbackResult << ": " << getFileName() << llendl; } if (mCallback) @@ -327,7 +327,7 @@ void LLXfer::abort (S32 result_code) { mCallbackResult = result_code; - llinfos << "Aborting xfer from " << mRemoteHost << " named " << getName() + llinfos << "Aborting xfer from " << mRemoteHost << " named " << getFileName() << " - error: " << result_code << llendl; gMessageSystem->newMessageFast(_PREHASH_AbortXfer); @@ -343,11 +343,9 @@ void LLXfer::abort (S32 result_code) /////////////////////////////////////////////////////////// -const char * LLXfer::getName() +std::string LLXfer::getFileName() { - static char tmp_str[256]; /* Flawfinder: ignore */ - - return (U64_to_str(mID, tmp_str, sizeof(tmp_str))); + return U64_to_str(mID); } /////////////////////////////////////////////////////////// @@ -367,7 +365,7 @@ S32 LLXfer::getMaxBufferSize () std::ostream& operator<< (std::ostream& os, LLXfer &hh) { - os << hh.getName() ; + os << hh.getFileName() ; return os; } diff --git a/indra/llmessage/llxfer.h b/indra/llmessage/llxfer.h index 017a521b81..57abc28960 100644 --- a/indra/llmessage/llxfer.h +++ b/indra/llmessage/llxfer.h @@ -106,7 +106,7 @@ class LLXfer virtual void setXferSize (S32 data_size); virtual S32 getMaxBufferSize(); - virtual const char *getName(); + virtual std::string getFileName(); virtual U32 getXferTypeTag(); diff --git a/indra/llmessage/llxfer_file.cpp b/indra/llmessage/llxfer_file.cpp index 6b71e7db8f..3643c4880d 100644 --- a/indra/llmessage/llxfer_file.cpp +++ b/indra/llmessage/llxfer_file.cpp @@ -47,17 +47,17 @@ const U32 LL_MAX_XFER_FILE_BUFFER = 65536; // local function to copy a file -S32 copy_file(const char* from, const char* to); +S32 copy_file(const std::string& from, const std::string& to); /////////////////////////////////////////////////////////// LLXfer_File::LLXfer_File (S32 chunk_size) : LLXfer(chunk_size) { - init(LLString::null, FALSE, chunk_size); + init(LLStringUtil::null, FALSE, chunk_size); } -LLXfer_File::LLXfer_File (const LLString& local_filename, BOOL delete_local_on_completion, S32 chunk_size) +LLXfer_File::LLXfer_File (const std::string& local_filename, BOOL delete_local_on_completion, S32 chunk_size) : LLXfer(chunk_size) { init(local_filename, delete_local_on_completion, chunk_size); @@ -72,24 +72,24 @@ LLXfer_File::~LLXfer_File () /////////////////////////////////////////////////////////// -void LLXfer_File::init (const LLString& local_filename, BOOL delete_local_on_completion, S32 chunk_size) +void LLXfer_File::init (const std::string& local_filename, BOOL delete_local_on_completion, S32 chunk_size) { mFp = NULL; - mLocalFilename[0] = 0; - mRemoteFilename[0] = 0; + mLocalFilename.clear(); + mRemoteFilename.clear(); mRemotePath = LL_PATH_NONE; - mTempFilename[0] = 0; + mTempFilename.clear(); mDeleteLocalOnCompletion = FALSE; mDeleteRemoteOnCompletion = FALSE; if (!local_filename.empty()) { - strncpy(mLocalFilename, local_filename.c_str(), LL_MAX_PATH-1); - mLocalFilename[LL_MAX_PATH-1] = '\0'; // stupid strncpy. + mLocalFilename = local_filename.substr(0,LL_MAX_PATH-1); // You can only automatically delete .tmp file as a safeguard against nasty messages. - mDeleteLocalOnCompletion = (delete_local_on_completion && (strstr(mLocalFilename,".tmp") == &mLocalFilename[strlen(mLocalFilename)-4])); /* Flawfinder : ignore */ + std::string exten = mLocalFilename.substr(mLocalFilename.length()-4, 4); + mDeleteLocalOnCompletion = (delete_local_on_completion && exten == ".tmp"); } } @@ -121,8 +121,8 @@ void LLXfer_File::free () /////////////////////////////////////////////////////////// S32 LLXfer_File::initializeRequest(U64 xfer_id, - const LLString& local_filename, - const LLString& remote_filename, + const std::string& local_filename, + const std::string& remote_filename, ELLPath remote_path, const LLHost& remote_host, BOOL delete_remote_on_completion, @@ -132,15 +132,13 @@ S32 LLXfer_File::initializeRequest(U64 xfer_id, S32 retval = 0; // presume success mID = xfer_id; - strncpy(mLocalFilename, local_filename.c_str(), LL_MAX_PATH-1); - mLocalFilename[LL_MAX_PATH-1] = '\0'; // stupid strncpy. - strncpy(mRemoteFilename,remote_filename.c_str(), LL_MAX_PATH-1); - mRemoteFilename[LL_MAX_PATH-1] = '\0'; // stupid strncpy. + mLocalFilename = local_filename; + mRemoteFilename = remote_filename; mRemotePath = remote_path; mRemoteHost = remote_host; mDeleteRemoteOnCompletion = delete_remote_on_completion; - snprintf(mTempFilename, sizeof(mTempFilename), "%s",gDirUtilp->getTempFilename().c_str()); /* Flawfinder: ignore */ + mTempFilename = gDirUtilp->getTempFilename(); mCallback = callback; mCallbackDataHandle = user_data; @@ -343,7 +341,7 @@ S32 LLXfer_File::processEOF() if(copy_file(mTempFilename, mLocalFilename) == 0) { llinfos << "Rename across mounts; copying+unlinking the file instead." << llendl; - unlink(mTempFilename); + unlink(mTempFilename.c_str()); } else { @@ -384,14 +382,14 @@ S32 LLXfer_File::processEOF() /////////////////////////////////////////////////////////// -BOOL LLXfer_File::matchesLocalFilename(const LLString& filename) +BOOL LLXfer_File::matchesLocalFilename(const std::string& filename) { return (filename == mLocalFilename); } /////////////////////////////////////////////////////////// -BOOL LLXfer_File::matchesRemoteFilename(const LLString& filename, ELLPath remote_path) +BOOL LLXfer_File::matchesRemoteFilename(const std::string& filename, ELLPath remote_path) { return ((filename == mRemoteFilename) && (remote_path == mRemotePath)); } @@ -399,9 +397,9 @@ BOOL LLXfer_File::matchesRemoteFilename(const LLString& filename, ELLPath remote /////////////////////////////////////////////////////////// -const char * LLXfer_File::getName() +std::string LLXfer_File::getFileName() { - return (mLocalFilename); + return mLocalFilename; } /////////////////////////////////////////////////////////// @@ -421,7 +419,7 @@ U32 LLXfer_File::getXferTypeTag() // function. It does not really spam enough information, but is useful // for this cpp file, because this should never be called in a // production environment. -S32 copy_file(const char* from, const char* to) +S32 copy_file(const std::string& from, const std::string& to) { S32 rv = 0; LLFILE* in = LLFile::fopen(from, "rb"); /*Flawfinder: ignore*/ diff --git a/indra/llmessage/llxfer_file.h b/indra/llmessage/llxfer_file.h index 5302302e54..04336c75fe 100644 --- a/indra/llmessage/llxfer_file.h +++ b/indra/llmessage/llxfer_file.h @@ -39,25 +39,25 @@ class LLXfer_File : public LLXfer { protected: LLFILE *mFp; - char mLocalFilename[LL_MAX_PATH]; /* Flawfinder : ignore */ - char mRemoteFilename[LL_MAX_PATH]; /* Flawfinder : ignore */ + std::string mLocalFilename; + std::string mRemoteFilename; ELLPath mRemotePath; - char mTempFilename[LL_MAX_PATH]; /* Flawfinder : ignore */ + std::string mTempFilename; BOOL mDeleteLocalOnCompletion; BOOL mDeleteRemoteOnCompletion; public: LLXfer_File (S32 chunk_size); - LLXfer_File (const LLString& local_filename, BOOL delete_local_on_completion, S32 chunk_size); + LLXfer_File (const std::string& local_filename, BOOL delete_local_on_completion, S32 chunk_size); virtual ~LLXfer_File(); - virtual void init(const LLString& local_filename, BOOL delete_local_on_completion, S32 chunk_size); + virtual void init(const std::string& local_filename, BOOL delete_local_on_completion, S32 chunk_size); virtual void free(); virtual S32 initializeRequest(U64 xfer_id, - const LLString& local_filename, - const LLString& remote_filename, + const std::string& local_filename, + const std::string& remote_filename, ELLPath remote_path, const LLHost& remote_host, BOOL delete_remote_on_completion, @@ -72,14 +72,14 @@ class LLXfer_File : public LLXfer virtual S32 suck(S32 start_position); virtual S32 flush(); - virtual BOOL matchesLocalFilename(const LLString& filename); - virtual BOOL matchesRemoteFilename(const LLString& filename, ELLPath remote_path); + virtual BOOL matchesLocalFilename(const std::string& filename); + virtual BOOL matchesRemoteFilename(const std::string& filename, ELLPath remote_path); virtual S32 getMaxBufferSize(); virtual U32 getXferTypeTag(); - virtual const char *getName(); + virtual std::string getFileName(); }; #endif diff --git a/indra/llmessage/llxfer_mem.cpp b/indra/llmessage/llxfer_mem.cpp index 4c3b1bbebb..dbaa3aebed 100644 --- a/indra/llmessage/llxfer_mem.cpp +++ b/indra/llmessage/llxfer_mem.cpp @@ -55,7 +55,7 @@ LLXfer_Mem::~LLXfer_Mem () void LLXfer_Mem::init () { - mRemoteFilename[0] = '\0'; + mRemoteFilename.clear(); mRemotePath = LL_PATH_NONE; mDeleteRemoteOnCompletion = FALSE; } @@ -120,7 +120,7 @@ S32 LLXfer_Mem::startSend (U64 xfer_id, const LLHost &remote_host) mID = xfer_id; mPacketNum = -1; -// cout << "Sending file: " << getName() << endl; +// cout << "Sending file: " << getFileName() << endl; mStatus = e_LL_XFER_PENDING; @@ -135,7 +135,7 @@ S32 LLXfer_Mem::processEOF() mStatus = e_LL_XFER_COMPLETE; - llinfos << "xfer complete: " << getName() << llendl; + llinfos << "xfer complete: " << getFileName() << llendl; if (mCallback) { @@ -165,8 +165,7 @@ S32 LLXfer_Mem::initializeRequest(U64 xfer_id, mCallbackDataHandle = user_data; mCallbackResult = LL_ERR_NOERR; - strncpy(mRemoteFilename, remote_filename.c_str(), LL_MAX_PATH-1); - mRemoteFilename[LL_MAX_PATH-1] = '\0'; // stupid strncpy. + mRemoteFilename = remote_filename; mRemotePath = remote_path; mDeleteRemoteOnCompletion = delete_remote_on_completion; diff --git a/indra/llmessage/llxfer_mem.h b/indra/llmessage/llxfer_mem.h index 858b8d1323..a6b95c0fcf 100644 --- a/indra/llmessage/llxfer_mem.h +++ b/indra/llmessage/llxfer_mem.h @@ -42,7 +42,7 @@ class LLXfer_Mem : public LLXfer private: protected: void (*mCallback)(void *, S32, void **, S32, LLExtStat); - char mRemoteFilename[LL_MAX_PATH]; /* Flawfinder : ignore */ + std::string mRemoteFilename; ELLPath mRemotePath; BOOL mDeleteRemoteOnCompletion; diff --git a/indra/llmessage/llxfer_vfile.cpp b/indra/llmessage/llxfer_vfile.cpp index b870e5369d..6dd683043b 100644 --- a/indra/llmessage/llxfer_vfile.cpp +++ b/indra/llmessage/llxfer_vfile.cpp @@ -74,10 +74,10 @@ void LLXfer_VFile::init (LLVFS *vfs, const LLUUID &local_id, LLAssetType::EType mVFile = NULL; - char id_string[UUID_STR_LENGTH]; /* Flawfinder : ignore */ + std::string id_string; mLocalID.toString(id_string); - snprintf(mName, sizeof(mName), "VFile %s:%s", id_string, LLAssetType::lookup(mType)); /* Flawfinder : ignore */ + mName = llformat("VFile %s:%s", id_string.c_str(), LLAssetType::lookup(mType)); } /////////////////////////////////////////////////////////// @@ -118,10 +118,10 @@ S32 LLXfer_VFile::initializeRequest(U64 xfer_id, mCallbackDataHandle = user_data; mCallbackResult = LL_ERR_NOERR; - char id_string[UUID_STR_LENGTH]; /* Flawfinder : ignore */ + std::string id_string; mLocalID.toString(id_string); - snprintf(mName, sizeof(mName), "VFile %s:%s", id_string, LLAssetType::lookup(mType)); /* Flawfinder : ignore */ + mName = llformat("VFile %s:%s", id_string.c_str(), LLAssetType::lookup(mType)); llinfos << "Requesting " << mName << llendl; @@ -328,7 +328,7 @@ BOOL LLXfer_VFile::matchesRemoteFile(const LLUUID &id, LLAssetType::EType type) ////////////////////////////////////////////////////////// -const char * LLXfer_VFile::getName() +std::string LLXfer_VFile::getFileName() { return mName; } diff --git a/indra/llmessage/llxfer_vfile.h b/indra/llmessage/llxfer_vfile.h index 5d57b08e3c..84457edf26 100644 --- a/indra/llmessage/llxfer_vfile.h +++ b/indra/llmessage/llxfer_vfile.h @@ -50,7 +50,7 @@ class LLXfer_VFile : public LLXfer LLVFS *mVFS; - char mName[MAX_STRING]; /* Flawfinder : ignore */ + std::string mName; public: LLXfer_VFile (); @@ -85,7 +85,7 @@ class LLXfer_VFile : public LLXfer virtual U32 getXferTypeTag(); - virtual const char *getName(); + virtual std::string getFileName(); }; #endif diff --git a/indra/llmessage/llxfermanager.cpp b/indra/llmessage/llxfermanager.cpp index fc75b3ae75..a94f982b8d 100644 --- a/indra/llmessage/llxfermanager.cpp +++ b/indra/llmessage/llxfermanager.cpp @@ -406,8 +406,8 @@ U64 LLXferManager::registerXfer(const void *datap, const S32 length) /////////////////////////////////////////////////////////// -void LLXferManager::requestFile(const char* local_filename, - const char* remote_filename, +void LLXferManager::requestFile(const std::string& local_filename, + const std::string& remote_filename, ELLPath remote_path, const LLHost& remote_host, BOOL delete_remote_on_completion, @@ -444,7 +444,7 @@ void LLXferManager::requestFile(const char* local_filename, // Note: according to AaronB, this is here to deal with locks on files that were // in transit during a crash, if(delete_remote_on_completion && - (strstr(remote_filename,".tmp") == &remote_filename[strlen(remote_filename)-4])) /* Flawfinder : ignore */ + (remote_filename.substr(remote_filename.length()-4) == ".tmp")) { LLFile::remove(local_filename); } @@ -464,7 +464,7 @@ void LLXferManager::requestFile(const char* local_filename, } } -void LLXferManager::requestFile(const char* remote_filename, +void LLXferManager::requestFile(const std::string& remote_filename, ELLPath remote_path, const LLHost& remote_host, BOOL delete_remote_on_completion, @@ -540,7 +540,7 @@ void LLXferManager::requestVFile(const LLUUID& local_id, /* void LLXferManager::requestXfer( - const char *local_filename, + const std::string& local_filename, BOOL delete_remote_on_completion, U64 xfer_id, const LLHost &remote_host, @@ -634,11 +634,11 @@ void LLXferManager::processReceiveData (LLMessageSystem *mesgsys, void ** /*user // confirm it if it was a resend of the last one, since the confirmation might have gotten dropped if (decodePacketNum(packetnum) == (xferp->mPacketNum - 1)) { - llinfos << "Reconfirming xfer " << xferp->mRemoteHost << ":" << xferp->getName() << " packet " << packetnum << llendl; sendConfirmPacket(mesgsys, id, decodePacketNum(packetnum), mesgsys->getSender()); + llinfos << "Reconfirming xfer " << xferp->mRemoteHost << ":" << xferp->getFileName() << " packet " << packetnum << llendl; sendConfirmPacket(mesgsys, id, decodePacketNum(packetnum), mesgsys->getSender()); } else { - llinfos << "Ignoring xfer " << xferp->mRemoteHost << ":" << xferp->getName() << " recv'd packet " << packetnum << "; expecting " << xferp->mPacketNum << llendl; + llinfos << "Ignoring xfer " << xferp->mRemoteHost << ":" << xferp->getFileName() << " recv'd packet " << packetnum << "; expecting " << xferp->mPacketNum << llendl; } return; } @@ -717,7 +717,7 @@ void LLXferManager::processFileRequest (LLMessageSystem *mesgsys, void ** /*user { U64 id; - char local_filename[MAX_STRING]; /* Flawfinder : ignore */ + std::string local_filename; ELLPath local_path = LL_PATH_NONE; S32 result = LL_ERR_NOERR; LLUUID uuid; @@ -732,7 +732,7 @@ void LLXferManager::processFileRequest (LLMessageSystem *mesgsys, void ** /*user llinfos << "xfer request id: " << U64_to_str(id, U64_BUF, sizeof(U64_BUF)) << " to " << mesgsys->getSender() << llendl; - mesgsys->getStringFast(_PREHASH_XferID, _PREHASH_Filename, MAX_STRING, local_filename); + mesgsys->getStringFast(_PREHASH_XferID, _PREHASH_Filename, local_filename); U8 local_path_u8; mesgsys->getU8("XferID", "FilePath", local_path_u8); @@ -780,7 +780,7 @@ void LLXferManager::processFileRequest (LLMessageSystem *mesgsys, void ** /*user llerrs << "Xfer allcoation error" << llendl; } } - else if (strlen(local_filename)) /* Flawfinder : ignore */ + else if (!local_filename.empty()) { std::string expanded_filename = gDirUtilp->getExpandedFilename( local_path, local_filename ); llinfos << "starting file transfer: " << expanded_filename << " to " << mesgsys->getSender() << llendl; @@ -923,7 +923,7 @@ void LLXferManager::retransmitUnackedPackets () { if (xferp->mRetries > LL_PACKET_RETRY_LIMIT) { - llinfos << "dropping xfer " << xferp->mRemoteHost << ":" << xferp->getName() << " packet retransmit limit exceeded, xfer dropped" << llendl; + llinfos << "dropping xfer " << xferp->mRemoteHost << ":" << xferp->getFileName() << " packet retransmit limit exceeded, xfer dropped" << llendl; xferp->abort(LL_ERR_TCP_TIMEOUT); delp = xferp; xferp = xferp->mNext; @@ -931,7 +931,7 @@ void LLXferManager::retransmitUnackedPackets () } else { - llinfos << "resending xfer " << xferp->mRemoteHost << ":" << xferp->getName() << " packet unconfirmed after: "<< et << " sec, packet " << xferp->mPacketNum << llendl; + llinfos << "resending xfer " << xferp->mRemoteHost << ":" << xferp->getFileName() << " packet unconfirmed after: "<< et << " sec, packet " << xferp->mPacketNum << llendl; xferp->resendLastPacket(); xferp = xferp->mNext; } @@ -946,7 +946,7 @@ void LLXferManager::retransmitUnackedPackets () } else if (xferp->mStatus == e_LL_XFER_ABORTED) { - llwarns << "Removing aborted xfer " << xferp->mRemoteHost << ":" << xferp->getName() << llendl; + llwarns << "Removing aborted xfer " << xferp->mRemoteHost << ":" << xferp->getFileName() << llendl; delp = xferp; xferp = xferp->mNext; removeXfer(delp,&mSendList); diff --git a/indra/llmessage/llxfermanager.h b/indra/llmessage/llxfermanager.h index c4af8fe937..dff8181584 100644 --- a/indra/llmessage/llxfermanager.h +++ b/indra/llmessage/llxfermanager.h @@ -143,8 +143,8 @@ class LLXferManager // file requesting routines // .. to file - virtual void requestFile(const char* local_filename, - const char* remote_filename, + virtual void requestFile(const std::string& local_filename, + const std::string& remote_filename, ELLPath remote_path, const LLHost& remote_host, BOOL delete_remote_on_completion, @@ -153,7 +153,7 @@ class LLXferManager BOOL use_big_packets = FALSE); // .. to memory - virtual void requestFile(const char* remote_filename, + virtual void requestFile(const std::string& remote_filename, ELLPath remote_path, const LLHost &remote_host, BOOL delete_remote_on_completion, diff --git a/indra/llmessage/mean_collision_data.h b/indra/llmessage/mean_collision_data.h index 1643c30594..7ee539720f 100644 --- a/indra/llmessage/mean_collision_data.h +++ b/indra/llmessage/mean_collision_data.h @@ -55,15 +55,13 @@ class LLMeanCollisionData public: LLMeanCollisionData(const LLUUID &victim, const LLUUID &perp, time_t time, EMeanCollisionType type, F32 mag) : mVictim(victim), mPerp(perp), mTime(time), mType(type), mMag(mag) - { mFirstName[0] = 0; mLastName[0] = 0; } + { + } LLMeanCollisionData(LLMeanCollisionData *mcd) - : mVictim(mcd->mVictim), mPerp(mcd->mPerp), mTime(mcd->mTime), mType(mcd->mType), mMag(mcd->mMag) - { - strncpy(mFirstName, mcd->mFirstName, sizeof(mFirstName) -1); /* Flawfinder: Ignore */ - mFirstName[sizeof(mFirstName) -1] = '\0'; - strncpy(mLastName, mcd->mLastName, sizeof(mLastName) -1); /* Flawfinder: Ignore */ - mLastName[sizeof(mLastName) -1] = '\0'; + : mVictim(mcd->mVictim), mPerp(mcd->mPerp), mTime(mcd->mTime), mType(mcd->mType), mMag(mcd->mMag), + mFirstName(mcd->mFirstName), mLastName(mcd->mLastName) + { } friend std::ostream& operator<<(std::ostream& s, const LLMeanCollisionData &a) @@ -96,8 +94,8 @@ public: time_t mTime; EMeanCollisionType mType; F32 mMag; - char mFirstName[DB_FIRST_NAME_BUF_SIZE]; /* Flawfinder: Ignore */ - char mLastName[DB_LAST_NAME_BUF_SIZE]; /* Flawfinder: Ignore */ + std::string mFirstName; + std::string mLastName; }; diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index c1731532ca..290682f7ce 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -286,7 +286,7 @@ void LLMessageSystem::init() } // Read file and build message templates -LLMessageSystem::LLMessageSystem(const char *filename, U32 port, +LLMessageSystem::LLMessageSystem(const std::string& filename, U32 port, S32 version_major, S32 version_minor, S32 version_patch, @@ -366,10 +366,9 @@ LLMessageSystem::LLMessageSystem(const char *filename, U32 port, // Read file and build message templates -void LLMessageSystem::loadTemplateFile(const char* filename, - bool failure_is_fatal) +void LLMessageSystem::loadTemplateFile(const std::string& filename, bool failure_is_fatal) { - if(!filename) + if(filename.empty()) { LL_ERRS("Messaging") << "No template filename specified" << llendl; mbError = TRUE; @@ -692,9 +691,9 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) { std::ostringstream str; str << "MSG: <- " << host; - char buffer[MAX_STRING]; /* Flawfinder: ignore*/ - snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", receive_size, (mIncomingCompressedSize ? mIncomingCompressedSize : receive_size), mCurrentRecvPacketID); /* Flawfinder: ignore */ - str << buffer << "(unknown)" + std::string tbuf; + tbuf = llformat( "\t%6d\t%6d\t%6d ", receive_size, (mIncomingCompressedSize ? mIncomingCompressedSize : receive_size), mCurrentRecvPacketID); + str << tbuf << "(unknown)" << (recv_reliable ? " reliable" : "") << " resent " << ((acks > 0) ? "acks" : "") @@ -822,10 +821,9 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) LLMsgBlkData *msg_block_data = mCurrentRMessageData->mMemberBlocks[bnamep]; - char errmsg[1024]; if (!msg_block_data) { - sprintf(errmsg, "Block %s #%d not in message %s", block_name, blocknum, mCurrentRMessageData->mName); + std::string errmsg = llformat("Block %s #%d not in message %s", block_name, blocknum, mCurrentRMessageData->mName); LL_ERRS("Messaging") << errmsg << llendl; } @@ -833,7 +831,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) if (!vardata.getName()) { - sprintf(errmsg, "Variable %s not in message %s block %s", vnamep, mCurrentRMessageData->mName, bnamep); + std::string errmsg = llformat("Variable %s not in message %s block %s", vnamep, mCurrentRMessageData->mName, bnamep); LL_ERRS("Messaging") << errmsg << llendl; } @@ -1384,8 +1382,8 @@ S32 LLMessageSystem::sendMessage(const LLHost &host) { std::ostringstream str; str << "MSG: -> " << host; - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mSendSize, buffer_length, cdp->getPacketOutID()); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat( "\t%6d\t%6d\t%6d ", mSendSize, buffer_length, cdp->getPacketOutID()); str << buffer << mMessageBuilder->getMessageName() << (mSendReliable ? " reliable " : ""); @@ -1413,8 +1411,8 @@ void LLMessageSystem::logMsgFromInvalidCircuit( const LLHost& host, BOOL recv_re { std::ostringstream str; str << "MSG: <- " << host; - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize: mMessageReader->getMessageSize()), mCurrentRecvPacketID); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat( "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize: mMessageReader->getMessageSize()), mCurrentRecvPacketID); str << buffer << nullToEmpty(mMessageReader->getMessageName()) << (recv_reliable ? " reliable" : "") @@ -1518,8 +1516,8 @@ void LLMessageSystem::logValidMsg(LLCircuitData *cdp, const LLHost& host, BOOL r { std::ostringstream str; str << "MSG: <- " << host; - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize : mMessageReader->getMessageSize()), mCurrentRecvPacketID); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat( "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize : mMessageReader->getMessageSize()), mCurrentRecvPacketID); str << buffer << nullToEmpty(mMessageReader->getMessageName()) << (recv_reliable ? " reliable" : "") @@ -2092,20 +2090,18 @@ void LLMessageSystem::processUseCircuitCode(LLMessageSystem* msg, // static void LLMessageSystem::processError(LLMessageSystem* msg, void**) { - char buffer[MTUBYTES]; S32 error_code = 0; msg->getS32("Data", "Code", error_code); std::string error_token; - msg->getString("Data", "Token", MTUBYTES, buffer); - error_token.assign(buffer); + msg->getString("Data", "Token", error_token); + LLUUID error_id; msg->getUUID("Data", "ID", error_id); std::string error_system; - msg->getString("Data", "System", MTUBYTES, buffer); - error_system.assign(buffer); + msg->getString("Data", "System", error_system); + std::string error_message; - msg->getString("Data", "Message", MTUBYTES, buffer); - error_message.assign(buffer); + msg->getString("Data", "Message", error_message); LL_WARNS("Messaging") << "Message error from " << msg->getSender() << " - " << error_code << " " << error_token << " " << error_id << " \"" @@ -2421,7 +2417,8 @@ void process_deny_trusted_circuit(LLMessageSystem *msg, void **) void dump_prehash_files() { U32 i; - LLFILE* fp = LLFile::fopen("../../indra/llmessage/message_prehash.h", "w"); /* Flawfinder: ignore */ + std::string filename("../../indra/llmessage/message_prehash.h"); + LLFILE* fp = LLFile::fopen(filename, "w"); /* Flawfinder: ignore */ if (fp) { fprintf( @@ -2451,7 +2448,8 @@ void dump_prehash_files() fprintf(fp, "\n\n#endif\n"); fclose(fp); } - fp = LLFile::fopen("../../indra/llmessage/message_prehash.cpp", "w"); /* Flawfinder: ignore */ + filename = std::string("../../indra/llmessage/message_prehash.cpp"); + fp = LLFile::fopen(filename, "w"); /* Flawfinder: ignore */ if (fp) { fprintf( @@ -2493,7 +2491,7 @@ bool start_messaging_system( bool failure_is_fatal) { gMessageSystem = new LLMessageSystem( - template_name.c_str(), + template_name, port, version_major, version_minor, @@ -2587,79 +2585,79 @@ void LLMessageSystem::stopLogging() void LLMessageSystem::summarizeLogs(std::ostream& str) { - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - char tmp_str[MAX_STRING]; /* Flawfinder: ignore */ + std::string buffer; + std::string tmp_str; F32 run_time = mMessageSystemTimer.getElapsedTimeF32(); str << "START MESSAGE LOG SUMMARY" << std::endl; - snprintf(buffer, MAX_STRING, "Run time: %12.3f seconds", run_time); /* Flawfinder: ignore */ + buffer = llformat( "Run time: %12.3f seconds", run_time); // Incoming str << buffer << std::endl << "Incoming:" << std::endl; - U64_to_str(mTotalBytesIn, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total bytes received: %20s (%5.2f kbits per second)", tmp_str, ((F32)mTotalBytesIn * 0.008f) / run_time); /* Flawfinder: ignore */ + tmp_str = U64_to_str(mTotalBytesIn); + buffer = llformat( "Total bytes received: %20s (%5.2f kbits per second)", tmp_str.c_str(), ((F32)mTotalBytesIn * 0.008f) / run_time); str << buffer << std::endl; - U64_to_str(mPacketsIn, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total packets received: %20s (%5.2f packets per second)", tmp_str, ((F32) mPacketsIn / run_time)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(mPacketsIn); + buffer = llformat( "Total packets received: %20s (%5.2f packets per second)", tmp_str.c_str(), ((F32) mPacketsIn / run_time)); str << buffer << std::endl; - snprintf(buffer, MAX_STRING, "Average packet size: %20.0f bytes", (F32)mTotalBytesIn / (F32)mPacketsIn); /* Flawfinder: ignore */ + buffer = llformat( "Average packet size: %20.0f bytes", (F32)mTotalBytesIn / (F32)mPacketsIn); str << buffer << std::endl; - U64_to_str(mReliablePacketsIn, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total reliable packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mReliablePacketsIn)/((F32) mPacketsIn + 1)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(mReliablePacketsIn); + buffer = llformat( "Total reliable packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mReliablePacketsIn)/((F32) mPacketsIn + 1)); str << buffer << std::endl; - U64_to_str(mCompressedPacketsIn, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total compressed packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mCompressedPacketsIn)/((F32) mPacketsIn + 1)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(mCompressedPacketsIn); + buffer = llformat( "Total compressed packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mCompressedPacketsIn)/((F32) mPacketsIn + 1)); str << buffer << std::endl; S64 savings = mUncompressedBytesIn - mCompressedBytesIn; - U64_to_str(savings, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total compression savings: %20s bytes", tmp_str); /* Flawfinder: ignore */ + tmp_str = U64_to_str(savings); + buffer = llformat( "Total compression savings: %20s bytes", tmp_str.c_str()); str << buffer << std::endl; - U64_to_str(savings/(mCompressedPacketsIn +1), tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str, ((F32) mUncompressedBytesIn)/((F32) mCompressedBytesIn+1)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(savings/(mCompressedPacketsIn +1)); + buffer = llformat( "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mUncompressedBytesIn)/((F32) mCompressedBytesIn+1)); str << buffer << std::endl; - U64_to_str(savings/(mPacketsIn+1), tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str, ((F32) mTotalBytesIn + (F32) savings)/((F32) mTotalBytesIn + 1.f)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(savings/(mPacketsIn+1)); + buffer = llformat( "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mTotalBytesIn + (F32) savings)/((F32) mTotalBytesIn + 1.f)); // Outgoing str << buffer << std::endl << std::endl << "Outgoing:" << std::endl; - U64_to_str(mTotalBytesOut, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total bytes sent: %20s (%5.2f kbits per second)", tmp_str, ((F32)mTotalBytesOut * 0.008f) / run_time ); /* Flawfinder: ignore */ + tmp_str = U64_to_str(mTotalBytesOut); + buffer = llformat( "Total bytes sent: %20s (%5.2f kbits per second)", tmp_str.c_str(), ((F32)mTotalBytesOut * 0.008f) / run_time ); str << buffer << std::endl; - U64_to_str(mPacketsOut, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total packets sent: %20s (%5.2f packets per second)", tmp_str, ((F32)mPacketsOut / run_time)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(mPacketsOut); + buffer = llformat( "Total packets sent: %20s (%5.2f packets per second)", tmp_str.c_str(), ((F32)mPacketsOut / run_time)); str << buffer << std::endl; - snprintf(buffer, MAX_STRING, "Average packet size: %20.0f bytes", (F32)mTotalBytesOut / (F32)mPacketsOut); /* Flawfinder: ignore */ + buffer = llformat( "Average packet size: %20.0f bytes", (F32)mTotalBytesOut / (F32)mPacketsOut); str << buffer << std::endl; - U64_to_str(mReliablePacketsOut, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total reliable packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mReliablePacketsOut)/((F32) mPacketsOut + 1)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(mReliablePacketsOut); + buffer = llformat( "Total reliable packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mReliablePacketsOut)/((F32) mPacketsOut + 1)); str << buffer << std::endl; - U64_to_str(mCompressedPacketsOut, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total compressed packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mCompressedPacketsOut)/((F32) mPacketsOut + 1)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(mCompressedPacketsOut); + buffer = llformat( "Total compressed packets: %20s (%5.2f%%)", tmp_str.c_str(), 100.f * ((F32) mCompressedPacketsOut)/((F32) mPacketsOut + 1)); str << buffer << std::endl; savings = mUncompressedBytesOut - mCompressedBytesOut; - U64_to_str(savings, tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Total compression savings: %20s bytes", tmp_str); /* Flawfinder: ignore */ + tmp_str = U64_to_str(savings); + buffer = llformat( "Total compression savings: %20s bytes", tmp_str.c_str()); str << buffer << std::endl; - U64_to_str(savings/(mCompressedPacketsOut +1), tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str, ((F32) mUncompressedBytesOut)/((F32) mCompressedBytesOut+1)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(savings/(mCompressedPacketsOut +1)); + buffer = llformat( "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mUncompressedBytesOut)/((F32) mCompressedBytesOut+1)); str << buffer << std::endl; - U64_to_str(savings/(mPacketsOut+1), tmp_str, sizeof(tmp_str)); - snprintf(buffer, MAX_STRING, "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str, ((F32) mTotalBytesOut + (F32) savings)/((F32) mTotalBytesOut + 1.f)); /* Flawfinder: ignore */ + tmp_str = U64_to_str(savings/(mPacketsOut+1)); + buffer = llformat( "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str.c_str(), ((F32) mTotalBytesOut + (F32) savings)/((F32) mTotalBytesOut + 1.f)); str << buffer << std::endl << std::endl; - snprintf(buffer, MAX_STRING, "SendPacket failures: %20d", mSendPacketFailureCount); /* Flawfinder: ignore */ + buffer = llformat( "SendPacket failures: %20d", mSendPacketFailureCount); str << buffer << std::endl; - snprintf(buffer, MAX_STRING, "Dropped packets: %20d", mDroppedPackets); /* Flawfinder: ignore */ + buffer = llformat( "Dropped packets: %20d", mDroppedPackets); str << buffer << std::endl; - snprintf(buffer, MAX_STRING, "Resent packets: %20d", mResentPackets); /* Flawfinder: ignore */ + buffer = llformat( "Resent packets: %20d", mResentPackets); str << buffer << std::endl; - snprintf(buffer, MAX_STRING, "Failed reliable resends: %20d", mFailedResendPackets); /* Flawfinder: ignore */ + buffer = llformat( "Failed reliable resends: %20d", mFailedResendPackets); str << buffer << std::endl; - snprintf(buffer, MAX_STRING, "Off-circuit rejected packets: %17d", mOffCircuitPackets); /* Flawfinder: ignore */ + buffer = llformat( "Off-circuit rejected packets: %17d", mOffCircuitPackets); str << buffer << std::endl; - snprintf(buffer, MAX_STRING, "On-circuit invalid packets: %17d", mInvalidOnCircuitPackets); /* Flawfinder: ignore */ + buffer = llformat( "On-circuit invalid packets: %17d", mInvalidOnCircuitPackets); str << buffer << std::endl << std::endl; str << "Decoding: " << std::endl; - snprintf(buffer, MAX_STRING, "%35s%10s%10s%10s%10s", "Message", "Count", "Time", "Max", "Avg"); /* Flawfinder: ignore */ + buffer = llformat( "%35s%10s%10s%10s%10s", "Message", "Count", "Time", "Max", "Avg"); str << buffer << std:: endl; F32 avg; for (message_template_name_map_t::const_iterator iter = mMessageTemplates.begin(), @@ -2670,7 +2668,7 @@ void LLMessageSystem::summarizeLogs(std::ostream& str) if(mt->mTotalDecoded > 0) { avg = mt->mTotalDecodeTime / (F32)mt->mTotalDecoded; - snprintf(buffer, MAX_STRING, "%35s%10u%10f%10f%10f", mt->mName, mt->mTotalDecoded, mt->mTotalDecodeTime, mt->mMaxDecodeTimePerMsg, avg); /* Flawfinder: ignore */ + buffer = llformat( "%35s%10u%10f%10f%10f", mt->mName, mt->mTotalDecoded, mt->mTotalDecodeTime, mt->mMaxDecodeTimePerMsg, avg); str << buffer << std::endl; } } @@ -3936,6 +3934,20 @@ void LLMessageSystem::getString(const char *block, const char *var, blocknum); } +void LLMessageSystem::getStringFast(const char *block, const char *var, + std::string& outstr, S32 blocknum) +{ + mMessageReader->getString(block, var, outstr, blocknum); +} + +void LLMessageSystem::getString(const char *block, const char *var, + std::string& outstr, S32 blocknum ) +{ + getStringFast(LLMessageStringTable::getInstance()->getString(block), + LLMessageStringTable::getInstance()->getString(var), outstr, + blocknum); +} + S32 LLMessageSystem::getNumberOfBlocksFast(const char *blockname) { return mMessageReader->getNumberOfBlocks(blockname); diff --git a/indra/llmessage/message.h b/indra/llmessage/message.h index 7462e1b1df..e2d2ed46e2 100644 --- a/indra/llmessage/message.h +++ b/indra/llmessage/message.h @@ -283,7 +283,7 @@ public: public: // Read file and build message templates - LLMessageSystem(const char *filename, U32 port, S32 version_major, + LLMessageSystem(const std::string& filename, U32 port, S32 version_major, S32 version_minor, S32 version_patch, bool failure_is_fatal = true); @@ -295,7 +295,7 @@ public: // Read file and build message templates filename must point to a // valid string which specifies the path of a valid linden // template. - void loadTemplateFile(const char* filename, bool failure_is_fatal); + void loadTemplateFile(const std::string& filename, bool failure_is_fatal); // methods for building, sending, receiving, and handling messages @@ -516,6 +516,8 @@ public: void getIPPort( const char *block, const char *var, U16 &port, S32 blocknum = 0); void getStringFast( const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0); void getString( const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0); + void getStringFast( const char *block, const char *var, std::string& outstr, S32 blocknum = 0); + void getString( const char *block, const char *var, std::string& outstr, S32 blocknum = 0); // Utility functions to generate a replay-resistant digest check diff --git a/indra/llprimitive/llmaterialtable.cpp b/indra/llprimitive/llmaterialtable.cpp index 61c9849144..b3addc720f 100644 --- a/indra/llprimitive/llmaterialtable.cpp +++ b/indra/llprimitive/llmaterialtable.cpp @@ -125,14 +125,15 @@ LLMaterialTable::~LLMaterialTable() void LLMaterialTable::initBasicTable() { - add(LL_MCODE_STONE,"Stone", LL_DEFAULT_STONE_UUID); - add(LL_MCODE_METAL,"Metal", LL_DEFAULT_METAL_UUID); - add(LL_MCODE_GLASS,"Glass", LL_DEFAULT_GLASS_UUID); - add(LL_MCODE_WOOD,"Wood", LL_DEFAULT_WOOD_UUID); - add(LL_MCODE_FLESH,"Flesh", LL_DEFAULT_FLESH_UUID); - add(LL_MCODE_PLASTIC,"Plastic", LL_DEFAULT_PLASTIC_UUID); - add(LL_MCODE_RUBBER,"Rubber", LL_DEFAULT_RUBBER_UUID); - add(LL_MCODE_LIGHT,"Light", LL_DEFAULT_LIGHT_UUID); + // *TODO: Translate + add(LL_MCODE_STONE,std::string("Stone"), LL_DEFAULT_STONE_UUID); + add(LL_MCODE_METAL,std::string("Metal"), LL_DEFAULT_METAL_UUID); + add(LL_MCODE_GLASS,std::string("Glass"), LL_DEFAULT_GLASS_UUID); + add(LL_MCODE_WOOD,std::string("Wood"), LL_DEFAULT_WOOD_UUID); + add(LL_MCODE_FLESH,std::string("Flesh"), LL_DEFAULT_FLESH_UUID); + add(LL_MCODE_PLASTIC,std::string("Plastic"), LL_DEFAULT_PLASTIC_UUID); + add(LL_MCODE_RUBBER,std::string("Rubber"), LL_DEFAULT_RUBBER_UUID); + add(LL_MCODE_LIGHT,std::string("Light"), LL_DEFAULT_LIGHT_UUID); // specify densities for these materials. . . // these were taken from http://www.mcelwee.net/html/densities_of_various_materials.html @@ -331,7 +332,7 @@ void LLMaterialTable::initBasicTable() } } -BOOL LLMaterialTable::add(U8 mcode, const char* name, const LLUUID &uuid) +BOOL LLMaterialTable::add(U8 mcode, const std::string& name, const LLUUID &uuid) { LLMaterialInfo *infop; @@ -466,13 +467,13 @@ BOOL LLMaterialTable::addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 return FALSE; } -LLUUID LLMaterialTable::getDefaultTextureID(char* name) +LLUUID LLMaterialTable::getDefaultTextureID(const std::string& name) { for (info_list_t::iterator iter = mMaterialInfoList.begin(); iter != mMaterialInfoList.end(); ++iter) { LLMaterialInfo *infop = *iter; - if (!strcmp(name, infop->mName)) + if (name == infop->mName) { return infop->mDefaultTextureID; } @@ -499,13 +500,13 @@ LLUUID LLMaterialTable::getDefaultTextureID(U8 mcode) } -U8 LLMaterialTable::getMCode(const char* name) +U8 LLMaterialTable::getMCode(const std::string& name) { for (info_list_t::iterator iter = mMaterialInfoList.begin(); iter != mMaterialInfoList.end(); ++iter) { LLMaterialInfo *infop = *iter; - if (!strcmp(name, infop->mName)) + if (name == infop->mName) { return infop->mMCode; } @@ -515,7 +516,7 @@ U8 LLMaterialTable::getMCode(const char* name) } -char* LLMaterialTable::getName(U8 mcode) +std::string LLMaterialTable::getName(U8 mcode) { mcode &= LL_MCODE_MASK; for (info_list_t::iterator iter = mMaterialInfoList.begin(); diff --git a/indra/llprimitive/llmaterialtable.h b/indra/llprimitive/llmaterialtable.h index 7dbe7de917..225d1976c0 100644 --- a/indra/llprimitive/llmaterialtable.h +++ b/indra/llprimitive/llmaterialtable.h @@ -67,7 +67,7 @@ class LLMaterialInfo { public: U8 mMCode; - char mName[LLMATERIAL_INFO_NAME_LENGTH]; /* Flawfinder: ignore */ + std::string mName; LLUUID mDefaultTextureID; LLUUID mShatterSoundID; F32 mDensity; // kg/m^3 @@ -79,24 +79,20 @@ public: F32 mDamageModifier; // modifier on KE based damage F32 mEPModifier; // modifier on mass based EP total - LLMaterialInfo(U8 mcode, const char* name, const LLUUID &uuid) + LLMaterialInfo(U8 mcode, const std::string& name, const LLUUID &uuid) { init(mcode,name,uuid); }; - void init(U8 mcode, const char* name, const LLUUID &uuid) + void init(U8 mcode, const std::string& name, const LLUUID &uuid) { - mName[0] = 0; mDensity = 1000.f; // default to 1000.0 (water) mHPModifier = 1.f; mDamageModifier = 1.f; mEPModifier = 1.f; mMCode = mcode; - if (name) - { - LLString::copy(mName,name,LLMATERIAL_INFO_NAME_LENGTH); - } + mName = name; mDefaultTextureID = uuid; }; @@ -150,7 +146,7 @@ public: void initBasicTable(); - BOOL add(U8 mcode, const char* name, const LLUUID &uuid); + BOOL add(U8 mcode, const std::string& name, const LLUUID &uuid); BOOL addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid); BOOL addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid); BOOL addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid); @@ -160,10 +156,10 @@ public: BOOL addRestitution(U8 mcode, const F32 &restitution); BOOL addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod); - LLUUID getDefaultTextureID(char* name); // LLUUID::null if not found + LLUUID getDefaultTextureID(const std::string& name); // LLUUID::null if not found LLUUID getDefaultTextureID(U8 mcode); // LLUUID::null if not found - U8 getMCode(const char* name); // 0 if not found - char* getName(U8 mcode); + U8 getMCode(const std::string& name); // 0 if not found + std::string getName(U8 mcode); F32 getDensity(U8 mcode); // kg/m^3, 0 if not found F32 getFriction(U8 mcode); // physics values diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index ff69cacf0f..90292d8f78 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -760,15 +760,14 @@ U8 LLPrimitive::pCodeToLegacy(const LLPCode pcode) // static // Don't crash or llerrs here! This function is used for debug strings. -const char * LLPrimitive::pCodeToString(const LLPCode pcode) +std::string LLPrimitive::pCodeToString(const LLPCode pcode) { - static char pcode_string[255]; /* Flawfinder: ignore */ + std::string pcode_string; U8 base_code = pcode & LL_PCODE_BASE_MASK; - pcode_string[0] = 0; if (!pcode) { - snprintf(pcode_string, sizeof(pcode_string), "null"); /* Flawfinder: ignore */ + pcode_string = "null"; } else if ((base_code) == LL_PCODE_LEGACY) { @@ -776,66 +775,66 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode) switch (pcode) { case LL_PCODE_LEGACY_GRASS: - snprintf(pcode_string, sizeof(pcode_string), "grass"); /* Flawfinder: ignore */ + pcode_string = "grass"; break; case LL_PCODE_LEGACY_PART_SYS: - snprintf(pcode_string, sizeof(pcode_string), "particle system"); /* Flawfinder: ignore */ + pcode_string = "particle system"; break; case LL_PCODE_LEGACY_AVATAR: - snprintf(pcode_string, sizeof(pcode_string), "avatar"); /* Flawfinder: ignore */ + pcode_string = "avatar"; break; case LL_PCODE_LEGACY_TEXT_BUBBLE: - snprintf(pcode_string, sizeof(pcode_string), "text bubble"); /* Flawfinder: ignore */ + pcode_string = "text bubble"; break; case LL_PCODE_LEGACY_TREE: - snprintf(pcode_string, sizeof(pcode_string), "tree"); /* Flawfinder: ignore */ + pcode_string = "tree"; break; case LL_PCODE_TREE_NEW: - snprintf(pcode_string, sizeof(pcode_string), "tree_new"); /* Flawfinder: ignore */ + pcode_string = "tree_new"; break; default: - snprintf(pcode_string, sizeof(pcode_string), "unknown legacy pcode %i",(U32)pcode); /* Flawfinder: ignore */ + pcode_string = llformat( "unknown legacy pcode %i",(U32)pcode); } } else { - char shape[32]; /* Flawfinder: ignore */ - char mask[32]; /* Flawfinder: ignore */ + std::string shape; + std::string mask; if (base_code == LL_PCODE_CUBE) { - snprintf(shape, sizeof(shape), "cube"); /* Flawfinder: ignore */ + shape = "cube"; } else if (base_code == LL_PCODE_CYLINDER) { - snprintf(shape, sizeof(shape), "cylinder"); /* Flawfinder: ignore */ + shape = "cylinder"; } else if (base_code == LL_PCODE_CONE) { - snprintf(shape, sizeof(shape), "cone"); /* Flawfinder: ignore */ + shape = "cone"; } else if (base_code == LL_PCODE_PRISM) { - snprintf(shape, sizeof(shape), "prism"); /* Flawfinder: ignore */ + shape = "prism"; } else if (base_code == LL_PCODE_PYRAMID) { - snprintf(shape, sizeof(shape), "pyramid"); /* Flawfinder: ignore */ + shape = "pyramid"; } else if (base_code == LL_PCODE_SPHERE) { - snprintf(shape, sizeof(shape), "sphere"); /* Flawfinder: ignore */ + shape = "sphere"; } else if (base_code == LL_PCODE_TETRAHEDRON) { - snprintf(shape, sizeof(shape), "tetrahedron"); /* Flawfinder: ignore */ + shape = "tetrahedron"; } else if (base_code == LL_PCODE_VOLUME) { - snprintf(shape, sizeof(shape), "volume"); /* Flawfinder: ignore */ + shape = "volume"; } else if (base_code == LL_PCODE_APP) { - snprintf(shape, sizeof(shape), "app"); /* Flawfinder: ignore */ + shape = "app"; } else { @@ -845,35 +844,27 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode) U8 mask_code = pcode & (~LL_PCODE_BASE_MASK); if (base_code == LL_PCODE_APP) { - snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */ + mask = llformat( "%x", mask_code); } else if (mask_code & LL_PCODE_HEMI_MASK) { - snprintf(mask, sizeof(mask), "hemi"); /* Flawfinder: ignore */ + mask = "hemi"; } else { - snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */ + mask = llformat( "%x", mask_code); } - // extra sanity against snprintf() being naturally crap - mask[sizeof(mask)-1] = '\0'; - shape[sizeof(shape)-1] = '\0'; - if (mask[0]) { - snprintf(pcode_string, sizeof(pcode_string), "%s-%s", shape, mask); /* Flawfinder: ignore */ + pcode_string = llformat( "%s-%s", shape.c_str(), mask.c_str()); } else { - snprintf(pcode_string, sizeof(pcode_string), "%s", shape); /* Flawfinder: ignore */ + pcode_string = llformat( "%s", shape.c_str()); } } - // Be really sure that pcode_string is nul-terminated after we've - // been using crappy snprintf() to build it. - pcode_string[sizeof(pcode_string)-1] = '\0'; - return pcode_string; } @@ -993,7 +984,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai S32 i; /* - LLString old_mask_string; + std::string old_mask_string; for (i = 0; i < 9; i++) { if (old_face_mask & (1 << i)) @@ -1005,7 +996,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai old_mask_string.append("0"); } } - LLString new_mask_string; + std::string new_mask_string; for (i = 0; i < 9; i++) { if (new_face_mask & (1 << i)) diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 2b738f8d29..e243ea623f 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -378,7 +378,7 @@ public: #endif LLPCode getPCode() const { return mPrimitiveCode; } - const char * getPCodeString() const { return pCodeToString(mPrimitiveCode); } + std::string getPCodeString() const { return pCodeToString(mPrimitiveCode); } const LLVector3& getAngularVelocity() const { return mAngularVelocity; } const LLVector3& getVelocity() const { return mVelocity; } const LLVector3& getAcceleration() const { return mAcceleration; } @@ -400,7 +400,7 @@ public: void removeFlags(U32 flags) { mMiscFlags &= ~flags; } U32 getFlags() const { return mMiscFlags; } - static const char *pCodeToString(const LLPCode pcode); + static std::string pCodeToString(const LLPCode pcode); static LLPCode legacyToPCode(const U8 legacy); static U8 pCodeToLegacy(const LLPCode pcode); static bool getTESTAxes(const U8 face, U32* s_axis, U32* t_axis); diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 1e0d9767ca..02e1663513 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -48,7 +48,7 @@ F32 LLFontGL::sHorizDPI = 96.f; F32 LLFontGL::sScaleX = 1.f; F32 LLFontGL::sScaleY = 1.f; BOOL LLFontGL::sDisplayFont = TRUE ; -LLString LLFontGL::sAppDir; +std::string LLFontGL::sAppDir; LLFontGL* LLFontGL::sMonospace = NULL; LLFontGL* LLFontGL::sSansSerifSmall = NULL; @@ -93,7 +93,7 @@ F32 llfont_round_y(F32 y) } // static -U8 LLFontGL::getStyleFromString(const LLString &style) +U8 LLFontGL::getStyleFromString(const std::string &style) { S32 ret = 0; if (style.find("NORMAL") != style.npos) @@ -166,9 +166,9 @@ void LLFontGL::reset() } // static -LLString LLFontGL::getFontPathSystem() +std::string LLFontGL::getFontPathSystem() { - LLString system_path; + std::string system_path; // Try to figure out where the system's font files are stored. char *system_root = NULL; @@ -199,9 +199,9 @@ LLString LLFontGL::getFontPathSystem() // static -LLString LLFontGL::getFontPathLocal() +std::string LLFontGL::getFontPathLocal() { - LLString local_path; + std::string local_path; // Backup files if we can't load from system fonts directory. // We could store this in an end-user writable directory to allow @@ -220,10 +220,10 @@ LLString LLFontGL::getFontPathLocal() } //static -bool LLFontGL::loadFaceFallback(LLFontList *fontlistp, const LLString& fontname, const F32 point_size) +bool LLFontGL::loadFaceFallback(LLFontList *fontlistp, const std::string& fontname, const F32 point_size) { - LLString local_path = getFontPathLocal(); - LLString sys_path = getFontPathSystem(); + std::string local_path = getFontPathLocal(); + std::string sys_path = getFontPathSystem(); // The fontname string may contain multiple font file names separated by semicolons. // Break it apart and try loading each one, in order. @@ -235,7 +235,7 @@ bool LLFontGL::loadFaceFallback(LLFontList *fontlistp, const LLString& fontname, for(token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) { LLFont *fontp = new LLFont(); - LLString font_path = local_path + *token_iter; + std::string font_path = local_path + *token_iter; if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, TRUE)) { font_path = sys_path + *token_iter; @@ -258,13 +258,13 @@ bool LLFontGL::loadFaceFallback(LLFontList *fontlistp, const LLString& fontname, } //static -bool LLFontGL::loadFace(LLFontGL *fontp, const LLString& fontname, const F32 point_size, LLFontList *fallback_fontp) +bool LLFontGL::loadFace(LLFontGL *fontp, const std::string& fontname, const F32 point_size, LLFontList *fallback_fontp) { - LLString local_path = getFontPathLocal(); - LLString font_path = local_path + fontname; + std::string local_path = getFontPathLocal(); + std::string font_path = local_path + fontname; if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, FALSE)) { - LLString sys_path = getFontPathSystem(); + std::string sys_path = getFontPathSystem(); font_path = sys_path + fontname; if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, FALSE)) { @@ -280,12 +280,12 @@ bool LLFontGL::loadFace(LLFontGL *fontp, const LLString& fontname, const F32 poi // static BOOL LLFontGL::initDefaultFonts(F32 screen_dpi, F32 x_scale, F32 y_scale, - const LLString& monospace_file, F32 monospace_size, - const LLString& sansserif_file, - const LLString& sanserif_fallback_file, F32 ss_fallback_scale, + const std::string& monospace_file, F32 monospace_size, + const std::string& sansserif_file, + const std::string& sanserif_fallback_file, F32 ss_fallback_scale, F32 small_size, F32 medium_size, F32 big_size, F32 huge_size, - const LLString& sansserif_bold_file, F32 bold_size, - const LLString& app_dir) + const std::string& sansserif_bold_file, F32 bold_size, + const std::string& app_dir) { BOOL failed = FALSE; sVertDPI = (F32)llfloor(screen_dpi * y_scale); @@ -554,7 +554,7 @@ BOOL LLFontGL::addChar(const llwchar wch) } -S32 LLFontGL::renderUTF8(const LLString &text, const S32 offset, +S32 LLFontGL::renderUTF8(const std::string &text, const S32 offset, const F32 x, const F32 y, const LLColor4 &color, const HAlign halign, const VAlign valign, @@ -726,7 +726,7 @@ S32 LLFontGL::render(const LLWString &wstr, if (getWidthF32(wstr.c_str(), 0, max_chars) * sScaleX > scaled_max_pixels) { // use four dots for ellipsis width to generate padding - const LLWString dots(utf8str_to_wstring(LLString("...."))); + const LLWString dots(utf8str_to_wstring(std::string("...."))); scaled_max_pixels = llmax(0, scaled_max_pixels - llround(getWidthF32(dots.c_str()))); draw_ellipses = TRUE; } @@ -879,7 +879,7 @@ S32 LLFontGL::render(const LLWString &wstr, //glLoadIdentity(); //gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f); //glScalef(sScaleX, sScaleY, 1.f); - renderUTF8("...", + renderUTF8(std::string("..."), 0, cur_x / sScaleX, (F32)y, color, @@ -902,7 +902,7 @@ LLImageGL *LLFontGL::getImageGL() const return mImageGLp; } -S32 LLFontGL::getWidth(const LLString& utf8text) const +S32 LLFontGL::getWidth(const std::string& utf8text) const { LLWString wtext = utf8str_to_wstring(utf8text); return getWidth(wtext.c_str(), 0, S32_MAX); @@ -913,7 +913,7 @@ S32 LLFontGL::getWidth(const llwchar* wchars) const return getWidth(wchars, 0, S32_MAX); } -S32 LLFontGL::getWidth(const LLString& utf8text, const S32 begin_offset, const S32 max_chars) const +S32 LLFontGL::getWidth(const std::string& utf8text, const S32 begin_offset, const S32 max_chars) const { LLWString wtext = utf8str_to_wstring(utf8text); return getWidth(wtext.c_str(), begin_offset, max_chars); @@ -925,7 +925,7 @@ S32 LLFontGL::getWidth(const llwchar* wchars, const S32 begin_offset, const S32 return llround(width); } -F32 LLFontGL::getWidthF32(const LLString& utf8text) const +F32 LLFontGL::getWidthF32(const std::string& utf8text) const { LLWString wtext = utf8str_to_wstring(utf8text); return getWidthF32(wtext.c_str(), 0, S32_MAX); @@ -936,7 +936,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars) const return getWidthF32(wchars, 0, S32_MAX); } -F32 LLFontGL::getWidthF32(const LLString& utf8text, const S32 begin_offset, const S32 max_chars ) const +F32 LLFontGL::getWidthF32(const std::string& utf8text, const S32 begin_offset, const S32 max_chars ) const { LLWString wtext = utf8str_to_wstring(utf8text); return getWidthF32(wtext.c_str(), begin_offset, max_chars); @@ -1312,7 +1312,7 @@ void LLFontGL::clearEmbeddedChars() mEmbeddedChars.clear(); } -void LLFontGL::addEmbeddedChar( llwchar wc, LLImageGL* image, const LLString& label ) +void LLFontGL::addEmbeddedChar( llwchar wc, LLImageGL* image, const std::string& label ) { LLWString wlabel = utf8str_to_wstring(label); addEmbeddedChar(wc, image, wlabel); @@ -1429,40 +1429,40 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con } // static -LLString LLFontGL::nameFromFont(const LLFontGL* fontp) +std::string LLFontGL::nameFromFont(const LLFontGL* fontp) { if (fontp == sSansSerifHuge) { - return LLString("SansSerifHuge"); + return std::string("SansSerifHuge"); } else if (fontp == sSansSerifSmall) { - return LLString("SansSerifSmall"); + return std::string("SansSerifSmall"); } else if (fontp == sSansSerif) { - return LLString("SansSerif"); + return std::string("SansSerif"); } else if (fontp == sSansSerifBig) { - return LLString("SansSerifBig"); + return std::string("SansSerifBig"); } else if (fontp == sSansSerifBold) { - return LLString("SansSerifBold"); + return std::string("SansSerifBold"); } else if (fontp == sMonospace) { - return LLString("Monospace"); + return std::string("Monospace"); } else { - return LLString(); + return std::string(); } } // static -LLFontGL* LLFontGL::fontFromName(const LLString& font_name) +LLFontGL* LLFontGL::fontFromName(const std::string& font_name) { LLFontGL* gl_font = NULL; if (font_name == "SansSerifHuge") @@ -1493,16 +1493,16 @@ LLFontGL* LLFontGL::fontFromName(const LLString& font_name) } // static -LLString LLFontGL::nameFromHAlign(LLFontGL::HAlign align) +std::string LLFontGL::nameFromHAlign(LLFontGL::HAlign align) { - if (align == LEFT) return LLString("left"); - else if (align == RIGHT) return LLString("right"); - else if (align == HCENTER) return LLString("center"); - else return LLString(); + if (align == LEFT) return std::string("left"); + else if (align == RIGHT) return std::string("right"); + else if (align == HCENTER) return std::string("center"); + else return std::string(); } // static -LLFontGL::HAlign LLFontGL::hAlignFromName(const LLString& name) +LLFontGL::HAlign LLFontGL::hAlignFromName(const std::string& name) { LLFontGL::HAlign gl_hfont_align = LLFontGL::LEFT; if (name == "left") @@ -1522,17 +1522,17 @@ LLFontGL::HAlign LLFontGL::hAlignFromName(const LLString& name) } // static -LLString LLFontGL::nameFromVAlign(LLFontGL::VAlign align) +std::string LLFontGL::nameFromVAlign(LLFontGL::VAlign align) { - if (align == TOP) return LLString("top"); - else if (align == VCENTER) return LLString("center"); - else if (align == BASELINE) return LLString("baseline"); - else if (align == BOTTOM) return LLString("bottom"); - else return LLString(); + if (align == TOP) return std::string("top"); + else if (align == VCENTER) return std::string("center"); + else if (align == BASELINE) return std::string("baseline"); + else if (align == BOTTOM) return std::string("bottom"); + else return std::string(); } // static -LLFontGL::VAlign LLFontGL::vAlignFromName(const LLString& name) +LLFontGL::VAlign LLFontGL::vAlignFromName(const std::string& name) { LLFontGL::VAlign gl_vfont_align = LLFontGL::BASELINE; if (name == "top") diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index e49a9fc296..e319ac95da 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -73,7 +73,7 @@ public: }; // Takes a string with potentially several flags, i.e. "NORMAL|BOLD|ITALIC" - static U8 getStyleFromString(const LLString &style); + static U8 getStyleFromString(const std::string &style); LLFontGL(); LLFontGL(const LLFontGL &source); @@ -85,24 +85,24 @@ public: LLFontGL &operator=(const LLFontGL &source); static BOOL initDefaultFonts(F32 screen_dpi, F32 x_scale, F32 y_scale, - const LLString& monospace_file, F32 monospace_size, - const LLString& sansserif_file, - const LLString& sansserif_fallback_file, F32 ss_fallback_scale, + const std::string& monospace_file, F32 monospace_size, + const std::string& sansserif_file, + const std::string& sansserif_fallback_file, F32 ss_fallback_scale, F32 small_size, F32 medium_size, F32 large_size, F32 huge_size, - const LLString& sansserif_bold_file, F32 bold_size, - const LLString& app_dir = LLString::null); + const std::string& sansserif_bold_file, F32 bold_size, + const std::string& app_dir = LLStringUtil::null); static void destroyDefaultFonts(); static void destroyGL(); - static bool loadFaceFallback(LLFontList *fontp, const LLString& fontname, const F32 point_size); - static bool loadFace(LLFontGL *fontp, const LLString& fontname, const F32 point_size, LLFontList *fallback_fontp); + static bool loadFaceFallback(LLFontList *fontp, const std::string& fontname, const F32 point_size); + static bool loadFace(LLFontGL *fontp, const std::string& fontname, const F32 point_size, LLFontList *fallback_fontp); /* virtual*/ BOOL loadFace(const std::string& filename, const F32 point_size, const F32 vert_dpi, const F32 horz_dpi, const S32 components, BOOL is_fallback); - S32 renderUTF8(const LLString &text, const S32 begin_offset, + S32 renderUTF8(const std::string &text, const S32 begin_offset, S32 x, S32 y, const LLColor4 &color) const { @@ -111,7 +111,7 @@ public: S32_MAX, S32_MAX, NULL, FALSE); } - S32 renderUTF8(const LLString &text, const S32 begin_offset, + S32 renderUTF8(const std::string &text, const S32 begin_offset, S32 x, S32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style = NORMAL) const @@ -122,7 +122,7 @@ public: } // renderUTF8 does a conversion, so is slower! - S32 renderUTF8(const LLString &text, + S32 renderUTF8(const std::string &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, @@ -162,14 +162,14 @@ public: /*virtual*/ F32 getAscenderHeight() const { return (F32)llround(mAscender / sScaleY); } /*virtual*/ F32 getDescenderHeight() const { return (F32)llround(mDescender / sScaleY); } - virtual S32 getWidth(const LLString& utf8text) const; + virtual S32 getWidth(const std::string& utf8text) const; virtual S32 getWidth(const llwchar* wchars) const; - virtual S32 getWidth(const LLString& utf8text, const S32 offset, const S32 max_chars ) const; + virtual S32 getWidth(const std::string& utf8text, const S32 offset, const S32 max_chars ) const; virtual S32 getWidth(const llwchar* wchars, const S32 offset, const S32 max_chars, BOOL use_embedded = FALSE) const; - virtual F32 getWidthF32(const LLString& utf8text) const; + virtual F32 getWidthF32(const std::string& utf8text) const; virtual F32 getWidthF32(const llwchar* wchars) const; - virtual F32 getWidthF32(const LLString& text, const S32 offset, const S32 max_chars ) const; + virtual F32 getWidthF32(const std::string& text, const S32 offset, const S32 max_chars ) const; virtual F32 getWidthF32(const llwchar* wchars, const S32 offset, const S32 max_chars, BOOL use_embedded = FALSE ) const; // The following are called often, frequently with large buffers, so do not use a string interface @@ -191,18 +191,18 @@ public: LLImageGL *getImageGL() const; - void addEmbeddedChar( llwchar wc, LLImageGL* image, const LLString& label); + void addEmbeddedChar( llwchar wc, LLImageGL* image, const std::string& label); void addEmbeddedChar( llwchar wc, LLImageGL* image, const LLWString& label); void removeEmbeddedChar( llwchar wc ); - static LLString nameFromFont(const LLFontGL* fontp); - static LLFontGL* fontFromName(const LLString& name); + static std::string nameFromFont(const LLFontGL* fontp); + static LLFontGL* fontFromName(const std::string& name); - static LLString nameFromHAlign(LLFontGL::HAlign align); - static LLFontGL::HAlign hAlignFromName(const LLString& name); + static std::string nameFromHAlign(LLFontGL::HAlign align); + static LLFontGL::HAlign hAlignFromName(const std::string& name); - static LLString nameFromVAlign(LLFontGL::VAlign align); - static LLFontGL::VAlign vAlignFromName(const LLString& name); + static std::string nameFromVAlign(LLFontGL::VAlign align); + static LLFontGL::VAlign vAlignFromName(const std::string& name); static void setFontDisplay(BOOL flag) { sDisplayFont = flag ; } @@ -225,7 +225,7 @@ public: static F32 sScaleX; static F32 sScaleY; static BOOL sDisplayFont ; - static LLString sAppDir; // For loading fonts + static std::string sAppDir; // For loading fonts static LLFontGL* sMonospace; // medium static LLFontList* sMonospaceFallback; @@ -249,8 +249,8 @@ public: protected: /*virtual*/ BOOL addChar(const llwchar wch); - static LLString getFontPathLocal(); - static LLString getFontPathSystem(); + static std::string getFontPathLocal(); + static std::string getFontPathSystem(); protected: LLPointer<LLImageRaw> mRawImageGLp; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index dd9f22361f..f020730d4a 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -842,7 +842,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S llwarns << "Trying to create a texture while GL is disabled!" << llendl; return FALSE; } - llassert(gGLManager.mInited || gNoRender); + llassert(gGLManager.mInited); stop_glerror(); if (discard_level < 0) diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 7d54aeb950..4f5f630fcd 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -59,7 +59,7 @@ S32 BTN_HEIGHT = 0; S32 BTN_GRID = 12; S32 BORDER_SIZE = 1; -LLButton::LLButton( const LLString& name, const LLRect& rect, const LLString& control_name, void (*click_callback)(void*), void *callback_data) +LLButton::LLButton( const std::string& name, const LLRect& rect, const std::string& control_name, void (*click_callback)(void*), void *callback_data) : LLUICtrl(name, rect, TRUE, NULL, NULL), mClickedCallback( click_callback ), mMouseDownCallback( NULL ), @@ -93,10 +93,10 @@ LLButton::LLButton( const LLString& name, const LLRect& rect, const LLString& co mUnselectedLabel = name; mSelectedLabel = name; - setImageUnselected("button_enabled_32x128.tga"); - setImageSelected("button_enabled_selected_32x128.tga"); - setImageDisabled("button_disabled_32x128.tga"); - setImageDisabledSelected("button_disabled_32x128.tga"); + setImageUnselected(std::string("button_enabled_32x128.tga")); + setImageSelected(std::string("button_enabled_selected_32x128.tga")); + setImageDisabled(std::string("button_disabled_32x128.tga")); + setImageDisabledSelected(std::string("button_disabled_32x128.tga")); mImageColor = LLUI::sColorsGroup->getColor( "ButtonImageColor" ); mDisabledImageColor = LLUI::sColorsGroup->getColor( "ButtonImageColor" ); @@ -105,15 +105,15 @@ LLButton::LLButton( const LLString& name, const LLRect& rect, const LLString& co } -LLButton::LLButton(const LLString& name, const LLRect& rect, - const LLString &unselected_image_name, - const LLString &selected_image_name, - const LLString& control_name, +LLButton::LLButton(const std::string& name, const LLRect& rect, + const std::string &unselected_image_name, + const std::string &selected_image_name, + const std::string& control_name, void (*click_callback)(void*), void *callback_data, const LLFontGL *font, - const LLString& unselected_label, - const LLString& selected_label ) + const std::string& unselected_label, + const std::string& selected_label ) : LLUICtrl(name, rect, TRUE, NULL, NULL), mClickedCallback( click_callback ), mMouseDownCallback( NULL ), @@ -162,8 +162,8 @@ LLButton::LLButton(const LLString& name, const LLRect& rect, } else { - setImageUnselected("button_enabled_32x128.tga"); - setImageDisabled("button_disabled_32x128.tga"); + setImageUnselected(std::string("button_enabled_32x128.tga")); + setImageDisabled(std::string("button_disabled_32x128.tga")); } if( selected_image_name != "" ) @@ -177,19 +177,19 @@ LLButton::LLButton(const LLString& name, const LLRect& rect, } else { - setImageSelected("button_enabled_selected_32x128.tga"); - setImageDisabledSelected("button_disabled_32x128.tga"); + setImageSelected(std::string("button_enabled_selected_32x128.tga")); + setImageDisabledSelected(std::string("button_disabled_32x128.tga")); } init(click_callback, callback_data, font, control_name); } -void LLButton::init(void (*click_callback)(void*), void *callback_data, const LLFontGL* font, const LLString& control_name) +void LLButton::init(void (*click_callback)(void*), void *callback_data, const LLFontGL* font, const std::string& control_name) { mGLFont = ( font ? font : LLFontGL::sSansSerif); // Hack to make sure there is space for at least one character - if (getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(" ")) + if (getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(std::string(" "))) { // Use old defaults mLeftHPad = LLBUTTON_ORIG_H_PAD; @@ -667,7 +667,7 @@ void LLButton::draw() // Draw label if( !label.empty() ) { - LLWString::trim(label); + LLWStringUtil::trim(label); S32 x; switch( mHAlign ) @@ -774,7 +774,7 @@ void LLButton::setLabel( const LLStringExplicit& label ) } //virtual -BOOL LLButton::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLButton::setLabelArg( const std::string& key, const LLStringExplicit& text ) { mUnselectedLabel.setArg(key, text); mSelectedLabel.setArg(key, text); @@ -806,7 +806,7 @@ void LLButton::setImageUnselected(LLPointer<LLUIImage> image) mImageUnselected = image; } -void LLButton::setImages( const LLString &image_name, const LLString &selected_name ) +void LLButton::setImages( const std::string &image_name, const std::string &selected_name ) { setImageUnselected(image_name); setImageSelected(selected_name); @@ -843,7 +843,7 @@ void LLButton::setImageDisabledSelected(LLPointer<LLUIImage> image) mDisabledImageColor.mV[VALPHA] *= 0.5f; } -void LLButton::setDisabledImages( const LLString &image_name, const LLString &selected_name, const LLColor4& c ) +void LLButton::setDisabledImages( const std::string &image_name, const std::string &selected_name, const LLColor4& c ) { setImageDisabled(image_name); setImageDisabledSelected(selected_name); @@ -855,7 +855,7 @@ void LLButton::setImageHoverSelected(LLPointer<LLUIImage> image) mImageHoverSelected = image; } -void LLButton::setDisabledImages( const LLString &image_name, const LLString &selected_name) +void LLButton::setDisabledImages( const std::string &image_name, const std::string &selected_name) { LLColor4 clr = mImageColor; clr.mV[VALPHA] *= .5f; @@ -867,13 +867,13 @@ void LLButton::setImageHoverUnselected(LLPointer<LLUIImage> image) mImageHoverUnselected = image; } -void LLButton::setHoverImages( const LLString& image_name, const LLString& selected_name ) +void LLButton::setHoverImages( const std::string& image_name, const std::string& selected_name ) { setImageHoverUnselected(image_name); setImageHoverSelected(selected_name); } -void LLButton::setImageOverlay(const LLString &image_name, LLFontGL::HAlign alignment, const LLColor4& color) +void LLButton::setImageOverlay(const std::string& image_name, LLFontGL::HAlign alignment, const LLColor4& color) { if (image_name.empty()) { @@ -912,54 +912,54 @@ S32 round_up(S32 grid, S32 value) } } -void LLButton::setImageUnselected(const LLString &image_name) +void LLButton::setImageUnselected(const std::string &image_name) { setImageUnselected(LLUI::getUIImage(image_name)); mImageUnselectedName = image_name; } -void LLButton::setImageSelected(const LLString &image_name) +void LLButton::setImageSelected(const std::string &image_name) { setImageSelected(LLUI::getUIImage(image_name)); mImageSelectedName = image_name; } -void LLButton::setImageHoverSelected(const LLString &image_name) +void LLButton::setImageHoverSelected(const std::string &image_name) { setImageHoverSelected(LLUI::getUIImage(image_name)); mImageHoverSelectedName = image_name; } -void LLButton::setImageHoverUnselected(const LLString &image_name) +void LLButton::setImageHoverUnselected(const std::string &image_name) { setImageHoverUnselected(LLUI::getUIImage(image_name)); mImageHoverUnselectedName = image_name; } -void LLButton::setImageDisabled(const LLString &image_name) +void LLButton::setImageDisabled(const std::string &image_name) { setImageDisabled(LLUI::getUIImage(image_name)); mImageDisabledName = image_name; } -void LLButton::setImageDisabledSelected(const LLString &image_name) +void LLButton::setImageDisabledSelected(const std::string &image_name) { setImageDisabledSelected(LLUI::getUIImage(image_name)); mImageDisabledSelectedName = image_name; } void LLButton::addImageAttributeToXML(LLXMLNodePtr node, - const LLString& image_name, + const std::string& image_name, const LLUUID& image_id, - const LLString& xml_tag_name) const + const std::string& xml_tag_name) const { if( !image_name.empty() ) { - node->createChild(xml_tag_name, TRUE)->setStringValue(image_name); + node->createChild(xml_tag_name.c_str(), TRUE)->setStringValue(image_name); } else if( image_id != LLUUID::null ) { - node->createChild(xml_tag_name + "_id", TRUE)->setUUIDValue(image_id); + node->createChild((xml_tag_name + "_id").c_str(), TRUE)->setUUIDValue(image_id); } } @@ -973,12 +973,12 @@ LLXMLNodePtr LLButton::getXML(bool save_children) const node->createChild("font", TRUE)->setStringValue(LLFontGL::nameFromFont(mGLFont)); node->createChild("halign", TRUE)->setStringValue(LLFontGL::nameFromHAlign(mHAlign)); - addImageAttributeToXML(node,mImageUnselectedName,mImageUnselectedID,"image_unselected"); - addImageAttributeToXML(node,mImageSelectedName,mImageSelectedID,"image_selected"); - addImageAttributeToXML(node,mImageHoverSelectedName,mImageHoverSelectedID,"image_hover_selected"); - addImageAttributeToXML(node,mImageHoverUnselectedName,mImageHoverUnselectedID,"image_hover_unselected"); - addImageAttributeToXML(node,mImageDisabledName,mImageDisabledID,"image_disabled"); - addImageAttributeToXML(node,mImageDisabledSelectedName,mImageDisabledSelectedID,"image_disabled_selected"); + addImageAttributeToXML(node,mImageUnselectedName,mImageUnselectedID,std::string("image_unselected")); + addImageAttributeToXML(node,mImageSelectedName,mImageSelectedID,std::string("image_selected")); + addImageAttributeToXML(node,mImageHoverSelectedName,mImageHoverSelectedID,std::string("image_hover_selected")); + addImageAttributeToXML(node,mImageHoverUnselectedName,mImageHoverUnselectedID,std::string("image_hover_unselected")); + addImageAttributeToXML(node,mImageDisabledName,mImageDisabledID,std::string("image_disabled")); + addImageAttributeToXML(node,mImageDisabledSelectedName,mImageDisabledSelectedID,std::string("image_disabled_selected")); node->createChild("scale_image", TRUE)->setBoolValue(mScaleImage); @@ -1001,40 +1001,40 @@ void clicked_help(void* data) // static LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("button"); + std::string name("button"); node->getAttributeString("name", name); - LLString label = name; + std::string label = name; node->getAttributeString("label", label); - LLString label_selected = label; + std::string label_selected = label; node->getAttributeString("label_selected", label_selected); LLFontGL* font = selectFont(node); - LLString image_unselected; + std::string image_unselected; if (node->hasAttribute("image_unselected")) node->getAttributeString("image_unselected",image_unselected); - LLString image_selected; + std::string image_selected; if (node->hasAttribute("image_selected")) node->getAttributeString("image_selected",image_selected); - LLString image_hover_selected; + std::string image_hover_selected; if (node->hasAttribute("image_hover_selected")) node->getAttributeString("image_hover_selected",image_hover_selected); - LLString image_hover_unselected; + std::string image_hover_unselected; if (node->hasAttribute("image_hover_unselected")) node->getAttributeString("image_hover_unselected",image_hover_unselected); - LLString image_disabled_selected; + std::string image_disabled_selected; if (node->hasAttribute("image_disabled_selected")) node->getAttributeString("image_disabled_selected",image_disabled_selected); - LLString image_disabled; + std::string image_disabled; if (node->hasAttribute("image_disabled")) node->getAttributeString("image_disabled",image_disabled); - LLString image_overlay; + std::string image_overlay; node->getAttributeString("image_overlay", image_overlay); LLFontGL::HAlign image_overlay_alignment = LLFontGL::HCENTER; - LLString image_overlay_alignment_string; + std::string image_overlay_alignment_string; if (node->hasAttribute("image_overlay_alignment")) { node->getAttributeString("image_overlay_alignment", image_overlay_alignment_string); @@ -1046,7 +1046,7 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa LLRect(), image_unselected, image_selected, - "", + LLStringUtil::null, NULL, parent, font, @@ -1060,15 +1060,15 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa node->getAttributeBOOL("toggle", is_toggle); button->setIsToggle(is_toggle); - if(image_hover_selected != LLString::null) button->setImageHoverSelected(image_hover_selected); + if(image_hover_selected != LLStringUtil::null) button->setImageHoverSelected(image_hover_selected); - if(image_hover_unselected != LLString::null) button->setImageHoverUnselected(image_hover_unselected); + if(image_hover_unselected != LLStringUtil::null) button->setImageHoverUnselected(image_hover_unselected); - if(image_disabled_selected != LLString::null) button->setImageDisabledSelected(image_disabled_selected ); + if(image_disabled_selected != LLStringUtil::null) button->setImageDisabledSelected(image_disabled_selected ); - if(image_disabled != LLString::null) button->setImageDisabled(image_disabled); + if(image_disabled != LLStringUtil::null) button->setImageDisabled(image_disabled); - if(image_overlay != LLString::null) button->setImageOverlay(image_overlay, image_overlay_alignment); + if(image_overlay != LLStringUtil::null) button->setImageOverlay(image_overlay, image_overlay_alignment); if (node->hasAttribute("halign")) { @@ -1094,7 +1094,7 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa if (node->hasAttribute("help_url")) { - LLString help_url; + std::string help_url; node->getAttributeString("help_url",help_url); button->setHelpURLCallback(help_url); } @@ -1104,7 +1104,7 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa return button; } -void LLButton::setHelpURLCallback(const LLString &help_url) +void LLButton::setHelpURLCallback(const std::string &help_url) { mHelpURL = help_url; setClickedCallback(clicked_help,this); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 6357e27bb7..9e24376938 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -72,25 +72,25 @@ class LLButton { public: // simple button with text label - LLButton(const LLString& name, const LLRect &rect, const LLString& control_name = LLString(), + LLButton(const std::string& name, const LLRect &rect, const std::string& control_name = std::string(), void (*on_click)(void*) = NULL, void *data = NULL); - LLButton(const LLString& name, const LLRect& rect, - const LLString &unselected_image, - const LLString &selected_image, - const LLString& control_name, + LLButton(const std::string& name, const LLRect& rect, + const std::string &unselected_image, + const std::string &selected_image, + const std::string& control_name, void (*click_callback)(void*), void *callback_data = NULL, const LLFontGL* mGLFont = NULL, - const LLString& unselected_label = LLString::null, - const LLString& selected_label = LLString::null ); + const std::string& unselected_label = LLStringUtil::null, + const std::string& selected_label = LLStringUtil::null ); virtual ~LLButton(); - void init(void (*click_callback)(void*), void *callback_data, const LLFontGL* font, const LLString& control_name); + void init(void (*click_callback)(void*), void *callback_data, const LLFontGL* font, const std::string& control_name); - void addImageAttributeToXML(LLXMLNodePtr node, const LLString& imageName, - const LLUUID& imageID,const LLString& xmlTagName) const; + void addImageAttributeToXML(LLXMLNodePtr node, const std::string& imageName, + const LLUUID& imageID,const std::string& xmlTagName) const; virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); @@ -130,24 +130,24 @@ public: void setLeftHPad( S32 pad ) { mLeftHPad = pad; } void setRightHPad( S32 pad ) { mRightHPad = pad; } - const LLString getLabelUnselected() const { return wstring_to_utf8str(mUnselectedLabel); } - const LLString getLabelSelected() const { return wstring_to_utf8str(mSelectedLabel); } + const std::string getLabelUnselected() const { return wstring_to_utf8str(mUnselectedLabel); } + const std::string getLabelSelected() const { return wstring_to_utf8str(mSelectedLabel); } - void setImageColor(const LLString& color_control); + void setImageColor(const std::string& color_control); void setImageColor(const LLColor4& c); virtual void setColor(const LLColor4& c); - void setImages(const LLString &image_name, const LLString &selected_name); - void setDisabledImages(const LLString &image_name, const LLString &selected_name); - void setDisabledImages(const LLString &image_name, const LLString &selected_name, const LLColor4& c); + void setImages(const std::string &image_name, const std::string &selected_name); + void setDisabledImages(const std::string &image_name, const std::string &selected_name); + void setDisabledImages(const std::string &image_name, const std::string &selected_name, const LLColor4& c); - void setHoverImages(const LLString &image_name, const LLString &selected_name); + void setHoverImages(const std::string &image_name, const std::string &selected_name); void setDisabledImageColor(const LLColor4& c) { mDisabledImageColor = c; } void setDisabledSelectedLabelColor( const LLColor4& c ) { mDisabledSelectedLabelColor = c; } - void setImageOverlay(const LLString &image_name, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white); + void setImageOverlay(const std::string& image_name, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white); LLPointer<LLUIImage> getImageOverlay() { return mImageOverlay; } @@ -155,7 +155,7 @@ public: virtual LLSD getValue() const; void setLabel( const LLStringExplicit& label); - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); void setLabelUnselected(const LLStringExplicit& label); void setLabelSelected(const LLStringExplicit& label); void setDisabledLabel(const LLStringExplicit& disabled_label); @@ -175,14 +175,14 @@ public: void setHoverGlowStrength(F32 strength) { mHoverGlowStrength = strength; } - void setImageUnselected(const LLString &image_name); - const LLString& getImageUnselectedName() const { return mImageUnselectedName; } - void setImageSelected(const LLString &image_name); - const LLString& getImageSelectedName() const { return mImageSelectedName; } - void setImageHoverSelected(const LLString &image_name); - void setImageHoverUnselected(const LLString &image_name); - void setImageDisabled(const LLString &image_name); - void setImageDisabledSelected(const LLString &image_name); + void setImageUnselected(const std::string &image_name); + const std::string& getImageUnselectedName() const { return mImageUnselectedName; } + void setImageSelected(const std::string &image_name); + const std::string& getImageSelectedName() const { return mImageSelectedName; } + void setImageHoverSelected(const std::string &image_name); + void setImageHoverUnselected(const std::string &image_name); + void setImageDisabled(const std::string &image_name); + void setImageDisabledSelected(const std::string &image_name); void setImageUnselected(LLPointer<LLUIImage> image); void setImageSelected(LLPointer<LLUIImage> image); @@ -194,8 +194,8 @@ public: void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; } BOOL getCommitOnReturn() const { return mCommitOnReturn; } - void setHelpURLCallback(const LLString &help_url); - const LLString& getHelpURL() const { return mHelpURL; } + void setHelpURLCallback(const std::string &help_url); + const std::string& getHelpURL() const { return mHelpURL; } protected: @@ -257,12 +257,12 @@ private: LLUUID mImageHoverUnselectedID; LLUUID mImageDisabledID; LLUUID mImageDisabledSelectedID; - LLString mImageUnselectedName; - LLString mImageSelectedName; - LLString mImageHoverSelectedName; - LLString mImageHoverUnselectedName; - LLString mImageDisabledName; - LLString mImageDisabledSelectedName; + std::string mImageUnselectedName; + std::string mImageSelectedName; + std::string mImageHoverSelectedName; + std::string mImageHoverUnselectedName; + std::string mImageDisabledName; + std::string mImageDisabledSelectedName; LLColor4 mHighlightColor; LLColor4 mUnselectedBgColor; @@ -291,7 +291,7 @@ private: BOOL mNeedsHighlight; BOOL mCommitOnReturn; - LLString mHelpURL; + std::string mHelpURL; LLPointer<LLUIImage> mImagep; diff --git a/indra/llui/llcallbackmap.h b/indra/llui/llcallbackmap.h index 496d7225f8..148993b1b1 100644 --- a/indra/llui/llcallbackmap.h +++ b/indra/llui/llcallbackmap.h @@ -41,7 +41,7 @@ public: // callback definition. typedef void* (*callback_t)(void* data); - typedef std::map<LLString, LLCallbackMap> map_t; + typedef std::map<std::string, LLCallbackMap> map_t; typedef map_t::iterator map_iter_t; typedef map_t::const_iterator map_const_iter_t; diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index 4d65047c36..0eab8f27a6 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -51,14 +51,14 @@ const U32 MAX_STRING_LENGTH = 10; static LLRegisterWidget<LLCheckBoxCtrl> r("check_box"); -LLCheckBoxCtrl::LLCheckBoxCtrl(const LLString& name, const LLRect& rect, - const LLString& label, +LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect, + const std::string& label, const LLFontGL* font, void (*commit_callback)(LLUICtrl* ctrl, void* userdata), void* callback_user_data, BOOL initial_value, BOOL use_radio_style, - const LLString& control_which) + const std::string& control_which) : LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data, FOLLOWS_LEFT | FOLLOWS_TOP), mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ), mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ), @@ -93,13 +93,13 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const LLString& name, const LLRect& rect, // *HACK Get rid of this with SL-55508... // this allows blank check boxes and radio boxes for now - LLString local_label = label; + std::string local_label = label; if(local_label.empty()) { local_label = " "; } - mLabel = new LLTextBox( "CheckboxCtrl Label", label_rect, local_label.c_str(), mFont ); + mLabel = new LLTextBox( std::string("CheckboxCtrl Label"), label_rect, local_label, mFont ); mLabel->setFollowsLeft(); mLabel->setFollowsBottom(); addChild(mLabel); @@ -112,18 +112,17 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const LLString& name, const LLRect& rect, LLCHECKBOXCTRL_VPAD, LLCHECKBOXCTRL_BTN_SIZE + LLCHECKBOXCTRL_SPACING + text_width + LLCHECKBOXCTRL_HPAD, llmax( text_height, LLCHECKBOXCTRL_BTN_SIZE ) + LLCHECKBOXCTRL_VPAD); - LLString active_true_id, active_false_id; - LLString inactive_true_id, inactive_false_id; + std::string active_true_id, active_false_id; + std::string inactive_true_id, inactive_false_id; if (mRadioStyle) { active_true_id = "UIImgRadioActiveSelectedUUID"; active_false_id = "UIImgRadioActiveUUID"; inactive_true_id = "UIImgRadioInactiveSelectedUUID"; inactive_false_id = "UIImgRadioInactiveUUID"; - mButton = new LLButton( - "Radio control button", btn_rect, - active_false_id, active_true_id, control_which, - &LLCheckBoxCtrl::onButtonPress, this, LLFontGL::sSansSerif ); + mButton = new LLButton(std::string("Radio control button"), btn_rect, + active_false_id, active_true_id, control_which, + &LLCheckBoxCtrl::onButtonPress, this, LLFontGL::sSansSerif ); mButton->setDisabledImages( inactive_false_id, inactive_true_id ); mButton->setHoverGlowStrength(0.35f); } @@ -133,10 +132,9 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const LLString& name, const LLRect& rect, active_true_id = "UIImgCheckboxActiveSelectedUUID"; inactive_true_id = "UIImgCheckboxInactiveSelectedUUID"; inactive_false_id = "UIImgCheckboxInactiveUUID"; - mButton = new LLButton( - "Checkbox control button", btn_rect, - active_false_id, active_true_id, control_which, - &LLCheckBoxCtrl::onButtonPress, this, LLFontGL::sSansSerif ); + mButton = new LLButton(std::string("Checkbox control button"), btn_rect, + active_false_id, active_true_id, control_which, + &LLCheckBoxCtrl::onButtonPress, this, LLFontGL::sSansSerif ); mButton->setDisabledImages( inactive_false_id, inactive_true_id ); mButton->setHoverGlowStrength(0.35f); } @@ -253,12 +251,12 @@ void LLCheckBoxCtrl::setLabel( const LLStringExplicit& label ) reshape(getRect().getWidth(), getRect().getHeight(), FALSE); } -LLString LLCheckBoxCtrl::getLabel() const +std::string LLCheckBoxCtrl::getLabel() const { return mLabel->getText(); } -BOOL LLCheckBoxCtrl::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLCheckBoxCtrl::setLabelArg( const std::string& key, const LLStringExplicit& text ) { BOOL res = mLabel->setTextArg(key, text); reshape(getRect().getWidth(), getRect().getHeight(), FALSE); @@ -266,13 +264,13 @@ BOOL LLCheckBoxCtrl::setLabelArg( const LLString& key, const LLStringExplicit& t } //virtual -LLString LLCheckBoxCtrl::getControlName() const +std::string LLCheckBoxCtrl::getControlName() const { return mButton->getControlName(); } // virtual -void LLCheckBoxCtrl::setControlName(const LLString& control_name, LLView* context) +void LLCheckBoxCtrl::setControlName(const std::string& control_name, LLView* context) { mButton->setControlName(control_name, context); } @@ -307,7 +305,7 @@ LLXMLNodePtr LLCheckBoxCtrl::getXML(bool save_children) const node->createChild("label", TRUE)->setStringValue(mLabel->getText()); - LLString control_name = mButton->getControlName(); + std::string control_name = mButton->getControlName(); node->createChild("initial_value", TRUE)->setBoolValue(mInitialValue); @@ -321,10 +319,10 @@ LLXMLNodePtr LLCheckBoxCtrl::getXML(bool save_children) const // static LLView* LLCheckBoxCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("checkbox"); + std::string name("checkbox"); node->getAttributeString("name", name); - LLString label(""); + std::string label(""); node->getAttributeString("label", label); LLFontGL* font = LLView::selectFont(node); diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h index 6e1ab322af..b78bf135f7 100644 --- a/indra/llui/llcheckboxctrl.h +++ b/indra/llui/llcheckboxctrl.h @@ -65,13 +65,13 @@ class LLCheckBoxCtrl : public LLUICtrl { public: - LLCheckBoxCtrl(const LLString& name, const LLRect& rect, const LLString& label, + LLCheckBoxCtrl(const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font = NULL, void (*commit_callback)(LLUICtrl*, void*) = NULL, void* callback_userdata = NULL, BOOL initial_value = FALSE, BOOL use_radio_style = FALSE, // if true, draw radio button style icons - const LLString& control_which = LLString::null); + const std::string& control_which = LLStringUtil::null); virtual ~LLCheckBoxCtrl(); // LLView interface @@ -93,7 +93,7 @@ public: virtual void setTentative(BOOL b) { mButton->setTentative(b); } virtual BOOL getTentative() const { return mButton->getTentative(); } - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); virtual void clear(); virtual void onCommit(); @@ -105,10 +105,10 @@ public: void setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; } void setLabel( const LLStringExplicit& label ); - LLString getLabel() const; + std::string getLabel() const; - virtual void setControlName(const LLString& control_name, LLView* context); - virtual LLString getControlName() const; + virtual void setControlName(const std::string& control_name, LLView* context); + virtual std::string getControlName() const; static void onButtonPress(void *userdata); diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 98a79fa650..8d8487f612 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -59,7 +59,7 @@ S32 MAX_COMBO_WIDTH = 500; static LLRegisterWidget<LLComboBox> r1("combo_box"); -LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString& label, +LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::string& label, void (*commit_callback)(LLUICtrl*,void*), void *callback_userdata ) @@ -78,12 +78,12 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString // Text label button mButton = new LLButton(label, LLRect(), - LLString::null, + LLStringUtil::null, NULL, this); - mButton->setImageUnselected("square_btn_32x128.tga"); - mButton->setImageSelected("square_btn_selected_32x128.tga"); - mButton->setImageDisabled("square_btn_32x128.tga"); - mButton->setImageDisabledSelected("square_btn_selected_32x128.tga"); + mButton->setImageUnselected(std::string("square_btn_32x128.tga")); + mButton->setImageSelected(std::string("square_btn_selected_32x128.tga")); + mButton->setImageDisabled(std::string("square_btn_32x128.tga")); + mButton->setImageDisabledSelected(std::string("square_btn_selected_32x128.tga")); mButton->setScaleImage(TRUE); mButton->setMouseDownCallback(onButtonDown); @@ -94,9 +94,8 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString addChild(mButton); // disallow multiple selection - mList = new LLScrollListCtrl( - "ComboBox", LLRect(), - &LLComboBox::onItemSelected, this, FALSE); + mList = new LLScrollListCtrl(std::string("ComboBox"), LLRect(), + &LLComboBox::onItemSelected, this, FALSE); mList->setVisible(FALSE); mList->setBgWriteableColor( LLColor4(1,1,1,1) ); mList->setCommitOnKeyboardMovement(FALSE); @@ -149,10 +148,10 @@ LLXMLNodePtr LLComboBox::getXML(bool save_children) const // static LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("combo_box"); + std::string name("combo_box"); node->getAttributeString("name", name); - LLString label(""); + std::string label(""); node->getAttributeString("label", label); LLRect rect; @@ -175,7 +174,7 @@ LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory * combo_box->initFromXML(node, parent); - const LLString& contents = node->getValue(); + const std::string& contents = node->getValue(); if (contents.find_first_not_of(" \n\t") != contents.npos) { @@ -188,9 +187,9 @@ LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory * { if (child->hasName("combo_item")) { - LLString label = child->getTextContents(); + std::string label = child->getTextContents(); - LLString value = label; + std::string value = label; child->getAttributeString("value", value); combo_box->add(label, LLSD(value) ); @@ -213,12 +212,12 @@ void LLComboBox::clear() { if (mTextEntry) { - mTextEntry->setText(LLString::null); + mTextEntry->setText(LLStringUtil::null); } - mButton->setLabelSelected(LLString::null); - mButton->setLabelUnselected(LLString::null); - mButton->setDisabledLabel(LLString::null); - mButton->setDisabledSelectedLabel(LLString::null); + mButton->setLabelSelected(LLStringUtil::null); + mButton->setLabelUnselected(LLStringUtil::null); + mButton->setDisabledLabel(LLStringUtil::null); + mButton->setDisabledSelectedLabel(LLStringUtil::null); mList->deselectAllItems(); } @@ -256,7 +255,7 @@ void LLComboBox::resetDirty() // add item "name" to menu -LLScrollListItem* LLComboBox::add(const LLString& name, EAddPosition pos, BOOL enabled) +LLScrollListItem* LLComboBox::add(const std::string& name, EAddPosition pos, BOOL enabled) { LLScrollListItem* item = mList->addSimpleElement(name, pos); item->setEnabled(enabled); @@ -265,7 +264,7 @@ LLScrollListItem* LLComboBox::add(const LLString& name, EAddPosition pos, BOOL e } // add item "name" with a unique id to menu -LLScrollListItem* LLComboBox::add(const LLString& name, const LLUUID& id, EAddPosition pos, BOOL enabled ) +LLScrollListItem* LLComboBox::add(const std::string& name, const LLUUID& id, EAddPosition pos, BOOL enabled ) { LLScrollListItem* item = mList->addSimpleElement(name, pos, id); item->setEnabled(enabled); @@ -274,7 +273,7 @@ LLScrollListItem* LLComboBox::add(const LLString& name, const LLUUID& id, EAddPo } // add item "name" with attached userdata -LLScrollListItem* LLComboBox::add(const LLString& name, void* userdata, EAddPosition pos, BOOL enabled ) +LLScrollListItem* LLComboBox::add(const std::string& name, void* userdata, EAddPosition pos, BOOL enabled ) { LLScrollListItem* item = mList->addSimpleElement(name, pos); item->setEnabled(enabled); @@ -284,7 +283,7 @@ LLScrollListItem* LLComboBox::add(const LLString& name, void* userdata, EAddPosi } // add item "name" with attached generic data -LLScrollListItem* LLComboBox::add(const LLString& name, LLSD value, EAddPosition pos, BOOL enabled ) +LLScrollListItem* LLComboBox::add(const std::string& name, LLSD value, EAddPosition pos, BOOL enabled ) { LLScrollListItem* item = mList->addSimpleElement(name, pos, value); item->setEnabled(enabled); @@ -299,7 +298,7 @@ LLScrollListItem* LLComboBox::addSeparator(EAddPosition pos) void LLComboBox::sortByName() { - mList->sortByColumn(0, TRUE); + mList->sortByColumnIndex(0, TRUE); } @@ -331,9 +330,9 @@ void LLComboBox::setValue(const LLSD& value) } } -const LLString LLComboBox::getSimple() const +const std::string LLComboBox::getSimple() const { - const LLString res = mList->getSelectedItemLabel(); + const std::string res = mList->getSelectedItemLabel(); if (res.empty() && mAllowTextEntry) { return mTextEntry->getText(); @@ -344,7 +343,7 @@ const LLString LLComboBox::getSimple() const } } -const LLString LLComboBox::getSelectedItemLabel(S32 column) const +const std::string LLComboBox::getSelectedItemLabel(S32 column) const { return mList->getSelectedItemLabel(column); } @@ -392,7 +391,7 @@ void LLComboBox::setLabel(const LLStringExplicit& name) } -BOOL LLComboBox::remove(const LLString& name) +BOOL LLComboBox::remove(const std::string& name) { BOOL found = mList->selectItemByLabel(name); @@ -495,10 +494,10 @@ void LLComboBox::updateLayout() LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); // clear label on button - LLString cur_label = mButton->getLabelSelected(); - mTextEntry = new LLLineEditor("combo_text_entry", + std::string cur_label = mButton->getLabelSelected(); + mTextEntry = new LLLineEditor(std::string("combo_text_entry"), text_entry_rect, - "", + LLStringUtil::null, LLFontGL::sSansSerifSmall, mMaxChars, onTextCommit, @@ -520,7 +519,7 @@ void LLComboBox::updateLayout() } // clear label on button - setLabel(LLString::null); + setLabel(LLStringUtil::null); mButton->setFollows(FOLLOWS_BOTTOM | FOLLOWS_TOP | FOLLOWS_RIGHT); } @@ -647,7 +646,7 @@ void LLComboBox::showList() void LLComboBox::hideList() { //*HACK: store the original value explicitly somewhere, not just in label - LLString orig_selection = mAllowTextEntry ? mTextEntry->getText() : mButton->getLabelSelected(); + std::string orig_selection = mAllowTextEntry ? mTextEntry->getText() : mButton->getLabelSelected(); // assert selection in list mList->selectItemByLabel(orig_selection, FALSE); @@ -712,7 +711,7 @@ void LLComboBox::onItemSelected(LLUICtrl* item, void *userdata) // Note: item is the LLScrollListCtrl LLComboBox *self = (LLComboBox *) userdata; - const LLString name = self->mList->getSelectedItemLabel(); + const std::string name = self->mList->getSelectedItemLabel(); S32 cur_id = self->getCurrentIndex(); if (cur_id != -1) @@ -733,9 +732,9 @@ void LLComboBox::onItemSelected(LLUICtrl* item, void *userdata) self->onCommit(); } -BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) +BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) { - LLString tool_tip; + std::string tool_tip; if(LLUICtrl::handleToolTip(x, y, msg, sticky_rect_screen)) { @@ -925,7 +924,7 @@ void LLComboBox::updateSelection() // user-entered portion of string, based on assumption that any selected // text was a result of auto-completion LLWString user_wstring = mTextEntry->hasSelection() ? left_wstring : mTextEntry->getWText(); - LLString full_string = mTextEntry->getText(); + std::string full_string = mTextEntry->getText(); // go ahead and arrange drop down list on first typed character, even // though we aren't showing it... some code relies on prearrange @@ -963,7 +962,7 @@ void LLComboBox::updateSelection() void LLComboBox::onTextCommit(LLUICtrl* caller, void* user_data) { LLComboBox* self = (LLComboBox*)user_data; - LLString text = self->mTextEntry->getText(); + std::string text = self->mTextEntry->getText(); self->setSimple(text); self->onCommit(); self->mTextEntry->selectAll(); @@ -1002,7 +1001,7 @@ void LLComboBox::clearColumns() mList->clearColumns(); } -void LLComboBox::setColumnLabel(const LLString& column, const LLString& label) +void LLComboBox::setColumnLabel(const std::string& column, const std::string& label) { mList->setColumnLabel(column, label); } @@ -1012,7 +1011,7 @@ LLScrollListItem* LLComboBox::addElement(const LLSD& value, EAddPosition pos, vo return mList->addElement(value, pos, userdata); } -LLScrollListItem* LLComboBox::addSimpleElement(const LLString& value, EAddPosition pos, const LLSD& id) +LLScrollListItem* LLComboBox::addSimpleElement(const std::string& value, EAddPosition pos, const LLSD& id) { return mList->addSimpleElement(value, pos, id); } @@ -1022,8 +1021,9 @@ void LLComboBox::clearRows() mList->clearRows(); } -void LLComboBox::sortByColumn(LLString name, BOOL ascending) +void LLComboBox::sortByColumn(const std::string& name, BOOL ascending) { + mList->sortByColumn(name, ascending); } //============================================================================ @@ -1100,19 +1100,19 @@ static LLRegisterWidget<LLFlyoutButton> r2("flyout_button"); const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24; LLFlyoutButton::LLFlyoutButton( - const LLString& name, + const std::string& name, const LLRect &rect, - const LLString& label, + const std::string& label, void (*commit_callback)(LLUICtrl*, void*) , void *callback_userdata) -: LLComboBox(name, rect, LLString::null, commit_callback, callback_userdata), +: LLComboBox(name, rect, LLStringUtil::null, commit_callback, callback_userdata), mToggleState(FALSE), mActionButton(NULL) { // Always use text box // Text label button mActionButton = new LLButton(label, - LLRect(), LLString::null, NULL, this); + LLRect(), LLStringUtil::null, NULL, this); mActionButton->setScaleImage(TRUE); mActionButton->setClickedCallback(onActionButtonClick); @@ -1145,10 +1145,10 @@ LLFlyoutButton::LLFlyoutButton( //static LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name = "flyout_button"; + std::string name = "flyout_button"; node->getAttributeString("name", name); - LLString label(""); + std::string label(""); node->getAttributeString("label", label); LLRect rect; @@ -1162,7 +1162,7 @@ LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto callback, NULL); - LLString list_position; + std::string list_position; node->getAttributeString("list_position", list_position); if (list_position == "below") { @@ -1181,9 +1181,9 @@ LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto { if (child->hasName("flyout_button_item")) { - LLString label = child->getTextContents(); + std::string label = child->getTextContents(); - LLString value = label; + std::string value = label; child->getAttributeString("value", value); flyout_button->add(label, LLSD(value) ); @@ -1225,7 +1225,7 @@ void LLFlyoutButton::draw() //FIXME: this should be an attribute of comboboxes, whether they have a distinct label or // the label reflects the last selected item, for now we have to manually remove the label - mButton->setLabel(LLString::null); + mButton->setLabel(LLStringUtil::null); LLComboBox::draw(); } diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index 09e8a0e0f4..ce923e277d 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -64,9 +64,9 @@ public: } EPreferredPosition; LLComboBox( - const LLString& name, + const std::string& name, const LLRect &rect, - const LLString& label, + const std::string& label, void (*commit_callback)(LLUICtrl*, void*) = NULL, void *callback_userdata = NULL ); @@ -83,7 +83,7 @@ public: virtual void setEnabled(BOOL enabled); - virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); + virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect); virtual BOOL handleKeyHere(KEY key, MASK mask); virtual BOOL handleUnicodeCharHere(llwchar uni_char); @@ -107,10 +107,10 @@ public: void setAllowTextEntry(BOOL allow, S32 max_chars = 50, BOOL make_tentative = TRUE); void setTextEntry(const LLStringExplicit& text); - LLScrollListItem* add(const LLString& name, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); // add item "name" to menu - LLScrollListItem* add(const LLString& name, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); - LLScrollListItem* add(const LLString& name, void* userdata, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); - LLScrollListItem* add(const LLString& name, LLSD value, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); + LLScrollListItem* add(const std::string& name, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); // add item "name" to menu + LLScrollListItem* add(const std::string& name, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); + LLScrollListItem* add(const std::string& name, void* userdata, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); + LLScrollListItem* add(const std::string& name, LLSD value, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); LLScrollListItem* addSeparator(EAddPosition pos = ADD_BOTTOM); BOOL remove( S32 index ); // remove item by index, return TRUE if found and removed void removeall() { clearRows(); } @@ -120,15 +120,15 @@ public: // Select current item by name using selectItemByLabel. Returns FALSE if not found. BOOL setSimple(const LLStringExplicit& name); // Get name of current item. Returns an empty string if not found. - const LLString getSimple() const; + const std::string getSimple() const; // Get contents of column x of selected row - const LLString getSelectedItemLabel(S32 column = 0) const; + const std::string getSelectedItemLabel(S32 column = 0) const; // Sets the label, which doesn't have to exist in the label. // This is probably a UI abuse. void setLabel(const LLStringExplicit& name); - BOOL remove(const LLString& name); // remove item "name", return TRUE if found and removed + BOOL remove(const std::string& name); // remove item "name", return TRUE if found and removed BOOL setCurrentByIndex( S32 index ); S32 getCurrentIndex() const; @@ -145,11 +145,11 @@ public: // Overwrites the default column (See LLScrollListCtrl for format) virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM); virtual void clearColumns(); - virtual void setColumnLabel(const LLString& column, const LLString& label); + virtual void setColumnLabel(const std::string& column, const std::string& label); virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL); - virtual LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD()); + virtual LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD()); virtual void clearRows(); - virtual void sortByColumn(LLString name, BOOL ascending); + virtual void sortByColumn(const std::string& name, BOOL ascending); // LLCtrlSelectionInterface functions virtual BOOL getCanSelect() const { return TRUE; } @@ -203,9 +203,9 @@ class LLFlyoutButton : public LLComboBox { public: LLFlyoutButton( - const LLString& name, + const std::string& name, const LLRect &rect, - const LLString& label, + const std::string& label, void (*commit_callback)(LLUICtrl*, void*) = NULL, void *callback_userdata = NULL); diff --git a/indra/llui/llctrlselectioninterface.cpp b/indra/llui/llctrlselectioninterface.cpp index 3dd401973b..589040f345 100644 --- a/indra/llui/llctrlselectioninterface.cpp +++ b/indra/llui/llctrlselectioninterface.cpp @@ -53,12 +53,12 @@ BOOL LLCtrlSelectionInterface::deselectByValue(LLSD value) LLCtrlListInterface::~LLCtrlListInterface() { } -LLScrollListItem* LLCtrlListInterface::addSimpleElement(const LLString& value) +LLScrollListItem* LLCtrlListInterface::addSimpleElement(const std::string& value) { return addSimpleElement(value, ADD_BOTTOM, LLSD()); } -LLScrollListItem* LLCtrlListInterface::addSimpleElement(const LLString& value, EAddPosition pos) +LLScrollListItem* LLCtrlListInterface::addSimpleElement(const std::string& value, EAddPosition pos) { return addSimpleElement(value, pos, LLSD()); } diff --git a/indra/llui/llctrlselectioninterface.h b/indra/llui/llctrlselectioninterface.h index eb89a0833d..2b386e98bb 100644 --- a/indra/llui/llctrlselectioninterface.h +++ b/indra/llui/llctrlselectioninterface.h @@ -84,16 +84,16 @@ public: virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM) = 0; virtual void clearColumns() = 0; - virtual void setColumnLabel(const LLString& column, const LLString& label) = 0; + virtual void setColumnLabel(const std::string& column, const std::string& label) = 0; // TomY TODO: Document this virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL) = 0; - LLScrollListItem* addSimpleElement(const LLString& value); // defaults to bottom - LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos); // defaults to no LLSD() id - virtual LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos, const LLSD& id) = 0; + LLScrollListItem* addSimpleElement(const std::string& value); // defaults to bottom + LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos); // defaults to no LLSD() id + virtual LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos, const LLSD& id) = 0; virtual void clearRows() = 0; - virtual void sortByColumn(LLString name, BOOL ascending) = 0; + virtual void sortByColumn(const std::string& name, BOOL ascending) = 0; }; class LLCtrlScrollInterface diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index 75e4ad5c08..9538a3f3ae 100644 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -55,7 +55,7 @@ const S32 RIGHT_PAD = BORDER_PAD + 32; // HACK: space for close btn and minimize S32 LLDragHandle::sSnapMargin = 5; -LLDragHandle::LLDragHandle( const LLString& name, const LLRect& rect, const LLString& title ) +LLDragHandle::LLDragHandle( const std::string& name, const LLRect& rect, const std::string& title ) : LLView( name, rect, TRUE ), mDragLastScreenX( 0 ), mDragLastScreenY( 0 ), @@ -94,27 +94,27 @@ void LLDragHandle::setTitleBox(LLTextBox* titlebox) } } -LLDragHandleTop::LLDragHandleTop(const LLString& name, const LLRect &rect, const LLString& title) +LLDragHandleTop::LLDragHandleTop(const std::string& name, const LLRect &rect, const std::string& title) : LLDragHandle(name, rect, title) { setFollowsAll(); setTitle( title ); } -LLDragHandleLeft::LLDragHandleLeft(const LLString& name, const LLRect &rect, const LLString& title) +LLDragHandleLeft::LLDragHandleLeft(const std::string& name, const LLRect &rect, const std::string& title) : LLDragHandle(name, rect, title) { setFollowsAll(); setTitle( title ); } -void LLDragHandleTop::setTitle(const LLString& title) +void LLDragHandleTop::setTitle(const std::string& title) { - LLString trimmed_title = title; - LLString::trim(trimmed_title); + std::string trimmed_title = title; + LLStringUtil::trim(trimmed_title); const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ); - LLTextBox* titlebox = new LLTextBox( "Drag Handle Title", getRect(), trimmed_title, font ); + LLTextBox* titlebox = new LLTextBox( std::string("Drag Handle Title"), getRect(), trimmed_title, font ); titlebox->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT); titlebox->setFontStyle(LLFontGL::DROP_SHADOW_SOFT); @@ -123,22 +123,22 @@ void LLDragHandleTop::setTitle(const LLString& title) } -const LLString& LLDragHandleTop::getTitle() const +const std::string& LLDragHandleTop::getTitle() const { - return getTitleBox() == NULL ? LLString::null : getTitleBox()->getText(); + return getTitleBox() == NULL ? LLStringUtil::null : getTitleBox()->getText(); } -void LLDragHandleLeft::setTitle(const LLString& ) +void LLDragHandleLeft::setTitle(const std::string& ) { setTitleBox(NULL); /* no title on left edge */ } -const LLString& LLDragHandleLeft::getTitle() const +const std::string& LLDragHandleLeft::getTitle() const { - return LLString::null; + return LLStringUtil::null; } diff --git a/indra/llui/lldraghandle.h b/indra/llui/lldraghandle.h index 3635409ec8..c44d2a3568 100644 --- a/indra/llui/lldraghandle.h +++ b/indra/llui/lldraghandle.h @@ -44,7 +44,7 @@ class LLTextBox; class LLDragHandle : public LLView { public: - LLDragHandle(const LLString& name, const LLRect& rect, const LLString& title ); + LLDragHandle(const std::string& name, const LLRect& rect, const std::string& title ); virtual ~LLDragHandle() { setTitleBox(NULL); } virtual void setValue(const LLSD& value); @@ -55,8 +55,8 @@ public: S32 getMaxTitleWidth() const { return mMaxTitleWidth; } void setTitleVisible(BOOL visible); - virtual void setTitle( const LLString& title ) = 0; - virtual const LLString& getTitle() const = 0; + virtual void setTitle( const std::string& title ) = 0; + virtual const std::string& getTitle() const = 0; virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); @@ -88,10 +88,10 @@ class LLDragHandleTop : public LLDragHandle { public: - LLDragHandleTop(const LLString& name, const LLRect& rect, const LLString& title ); + LLDragHandleTop(const std::string& name, const LLRect& rect, const std::string& title ); - virtual void setTitle( const LLString& title ); - virtual const LLString& getTitle() const; + virtual void setTitle( const std::string& title ); + virtual const std::string& getTitle() const; virtual void draw(); virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); @@ -105,10 +105,10 @@ class LLDragHandleLeft : public LLDragHandle { public: - LLDragHandleLeft(const LLString& name, const LLRect& rect, const LLString& title ); + LLDragHandleLeft(const std::string& name, const LLRect& rect, const std::string& title ); - virtual void setTitle( const LLString& title ); - virtual const LLString& getTitle() const; + virtual void setTitle( const std::string& title ); + virtual const std::string& getTitle() const; virtual void draw(); virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 7bb79d4973..18ffbdfbcd 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -56,14 +56,12 @@ #include "lltabcontainer.h" #include "v2math.h" -extern BOOL gNoRender; - const S32 MINIMIZED_WIDTH = 160; const S32 CLOSE_BOX_FROM_TOP = 1; // use this to control "jumping" behavior when Ctrl-Tabbing const S32 TABBED_FLOATER_OFFSET = 0; -LLString LLFloater::sButtonActiveImageNames[BUTTON_COUNT] = +std::string LLFloater::sButtonActiveImageNames[BUTTON_COUNT] = { "UIImgBtnCloseActiveUUID", //BUTTON_CLOSE "UIImgBtnRestoreActiveUUID", //BUTTON_RESTORE @@ -72,7 +70,7 @@ LLString LLFloater::sButtonActiveImageNames[BUTTON_COUNT] = "UIImgBtnCloseActiveUUID", //BUTTON_EDIT }; -LLString LLFloater::sButtonInactiveImageNames[BUTTON_COUNT] = +std::string LLFloater::sButtonInactiveImageNames[BUTTON_COUNT] = { "UIImgBtnCloseInactiveUUID", //BUTTON_CLOSE "UIImgBtnRestoreInactiveUUID", //BUTTON_RESTORE @@ -81,7 +79,7 @@ LLString LLFloater::sButtonInactiveImageNames[BUTTON_COUNT] = "UIImgBtnCloseInactiveUUID", //BUTTON_EDIT }; -LLString LLFloater::sButtonPressedImageNames[BUTTON_COUNT] = +std::string LLFloater::sButtonPressedImageNames[BUTTON_COUNT] = { "UIImgBtnClosePressedUUID", //BUTTON_CLOSE "UIImgBtnRestorePressedUUID", //BUTTON_RESTORE @@ -90,7 +88,7 @@ LLString LLFloater::sButtonPressedImageNames[BUTTON_COUNT] = "UIImgBtnClosePressedUUID", //BUTTON_EDIT }; -LLString LLFloater::sButtonNames[BUTTON_COUNT] = +std::string LLFloater::sButtonNames[BUTTON_COUNT] = { "llfloater_close_btn", //BUTTON_CLOSE "llfloater_restore_btn", //BUTTON_RESTORE @@ -99,7 +97,7 @@ LLString LLFloater::sButtonNames[BUTTON_COUNT] = "llfloater_edit_btn", //BUTTON_EDIT }; -LLString LLFloater::sButtonToolTips[BUTTON_COUNT] = +std::string LLFloater::sButtonToolTips[BUTTON_COUNT] = { #ifdef LL_DARWIN "Close (Cmd-W)", //BUTTON_CLOSE @@ -145,7 +143,7 @@ LLFloater::LLFloater() : mHandle.bind(this); } -LLFloater::LLFloater(const LLString& name) +LLFloater::LLFloater(const std::string& name) : LLPanel(name), mAutoFocus(TRUE) // automatically take focus when opened { for (S32 i = 0; i < BUTTON_COUNT; i++) @@ -153,12 +151,12 @@ LLFloater::LLFloater(const LLString& name) mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } - LLString title; // null string + std::string title; // null string initFloater(title, FALSE, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, FALSE, TRUE, TRUE); // defaults } -LLFloater::LLFloater(const LLString& name, const LLRect& rect, const LLString& title, +LLFloater::LLFloater(const std::string& name, const LLRect& rect, const std::string& title, BOOL resizable, S32 min_width, S32 min_height, @@ -176,7 +174,7 @@ LLFloater::LLFloater(const LLString& name, const LLRect& rect, const LLString& t initFloater( title, resizable, min_width, min_height, drag_on_left, minimizable, close_btn); } -LLFloater::LLFloater(const LLString& name, const LLString& rect_control, const LLString& title, +LLFloater::LLFloater(const std::string& name, const std::string& rect_control, const std::string& title, BOOL resizable, S32 min_width, S32 min_height, @@ -196,7 +194,7 @@ LLFloater::LLFloater(const LLString& name, const LLString& rect_control, const L // Note: Floaters constructed from XML call init() twice! -void LLFloater::initFloater(const LLString& title, +void LLFloater::initFloater(const std::string& title, BOOL resizable, S32 min_width, S32 min_height, BOOL drag_on_left, BOOL minimizable, BOOL close_btn) { @@ -291,12 +289,12 @@ void LLFloater::initFloater(const LLString& title, 0, 0, DRAG_HANDLE_WIDTH, getRect().getHeight() - LLPANEL_BORDER_WIDTH - close_box_size); - mDragHandle = new LLDragHandleLeft("drag", drag_handle_rect, title ); + mDragHandle = new LLDragHandleLeft(std::string("drag"), drag_handle_rect, title ); } else // drag on top { LLRect drag_handle_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 ); - mDragHandle = new LLDragHandleTop( "Drag Handle", drag_handle_rect, title ); + mDragHandle = new LLDragHandleTop( std::string("Drag Handle"), drag_handle_rect, title ); } addChild(mDragHandle); @@ -310,28 +308,28 @@ void LLFloater::initFloater(const LLString& title, // Resize bars (sides) const S32 RESIZE_BAR_THICKNESS = 3; mResizeBar[LLResizeBar::LEFT] = new LLResizeBar( - "resizebar_left", + std::string("resizebar_left"), this, LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0), min_width, S32_MAX, LLResizeBar::LEFT ); addChild( mResizeBar[0] ); mResizeBar[LLResizeBar::TOP] = new LLResizeBar( - "resizebar_top", + std::string("resizebar_top"), this, LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS), min_height, S32_MAX, LLResizeBar::TOP ); addChild( mResizeBar[1] ); mResizeBar[LLResizeBar::RIGHT] = new LLResizeBar( - "resizebar_right", + std::string("resizebar_right"), this, LLRect( getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0), min_width, S32_MAX, LLResizeBar::RIGHT ); addChild( mResizeBar[2] ); mResizeBar[LLResizeBar::BOTTOM] = new LLResizeBar( - "resizebar_bottom", + std::string("resizebar_bottom"), this, LLRect( 0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0), min_height, S32_MAX, LLResizeBar::BOTTOM ); @@ -340,28 +338,29 @@ void LLFloater::initFloater(const LLString& title, // Resize handles (corners) mResizeHandle[0] = new LLResizeHandle( - "Resize Handle", + std::string("Resize Handle"), LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0), min_width, min_height, LLResizeHandle::RIGHT_BOTTOM); addChild(mResizeHandle[0]); - mResizeHandle[1] = new LLResizeHandle( "resize", + mResizeHandle[1] = new LLResizeHandle( + std::string("resize"), LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT), min_width, min_height, LLResizeHandle::RIGHT_TOP ); addChild(mResizeHandle[1]); - mResizeHandle[2] = new LLResizeHandle( "resize", - LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 ), - min_width, - min_height, - LLResizeHandle::LEFT_BOTTOM ); + mResizeHandle[2] = new LLResizeHandle( std::string("resize"), + LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 ), + min_width, + min_height, + LLResizeHandle::LEFT_BOTTOM ); addChild(mResizeHandle[2]); - mResizeHandle[3] = new LLResizeHandle( "resize", + mResizeHandle[3] = new LLResizeHandle( std::string("resize"), LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT ), min_width, min_height, @@ -650,7 +649,7 @@ void LLFloater::applyRectControl() } } -void LLFloater::setTitle( const LLString& title ) +void LLFloater::setTitle( const std::string& title ) { if (gNoRender) { @@ -660,21 +659,21 @@ void LLFloater::setTitle( const LLString& title ) mDragHandle->setTitle( title ); } -const LLString& LLFloater::getTitle() const +const std::string& LLFloater::getTitle() const { - return mDragHandle ? mDragHandle->getTitle() : LLString::null; + return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null; } -void LLFloater::setShortTitle( const LLString& short_title ) +void LLFloater::setShortTitle( const std::string& short_title ) { mShortTitle = short_title; } -LLString LLFloater::getShortTitle() +std::string LLFloater::getShortTitle() { if (mShortTitle.empty()) { - return mDragHandle ? mDragHandle->getTitle() : LLString::null; + return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null; } else { @@ -841,7 +840,7 @@ void LLFloater::setMinimized(BOOL minimize) mResizeHandle[i]->setEnabled(FALSE); } } - + mMinimized = TRUE; // Reshape *after* setting mMinimized @@ -890,7 +889,7 @@ void LLFloater::setMinimized(BOOL minimize) mResizeHandle[i]->setEnabled(isResizable()); } } - + mMinimized = FALSE; // Reshape *after* setting mMinimized @@ -1484,28 +1483,28 @@ void LLFloater::setCanResize(BOOL can_resize) // Resize bars (sides) const S32 RESIZE_BAR_THICKNESS = 3; mResizeBar[0] = new LLResizeBar( - "resizebar_left", + std::string("resizebar_left"), this, LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0), mMinWidth, S32_MAX, LLResizeBar::LEFT ); addChild( mResizeBar[0] ); mResizeBar[1] = new LLResizeBar( - "resizebar_top", + std::string("resizebar_top"), this, LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS), mMinHeight, S32_MAX, LLResizeBar::TOP ); addChild( mResizeBar[1] ); mResizeBar[2] = new LLResizeBar( - "resizebar_right", + std::string("resizebar_right"), this, LLRect( getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0), mMinWidth, S32_MAX, LLResizeBar::RIGHT ); addChild( mResizeBar[2] ); mResizeBar[3] = new LLResizeBar( - "resizebar_bottom", + std::string("resizebar_bottom"), this, LLRect( 0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0), mMinHeight, S32_MAX, LLResizeBar::BOTTOM ); @@ -1514,28 +1513,28 @@ void LLFloater::setCanResize(BOOL can_resize) // Resize handles (corners) mResizeHandle[0] = new LLResizeHandle( - "Resize Handle", + std::string("Resize Handle"), LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0), mMinWidth, mMinHeight, LLResizeHandle::RIGHT_BOTTOM); addChild(mResizeHandle[0]); - mResizeHandle[1] = new LLResizeHandle( "resize", + mResizeHandle[1] = new LLResizeHandle( std::string("resize"), LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT), mMinWidth, mMinHeight, LLResizeHandle::RIGHT_TOP ); addChild(mResizeHandle[1]); - mResizeHandle[2] = new LLResizeHandle( "resize", - LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 ), - mMinWidth, - mMinHeight, - LLResizeHandle::LEFT_BOTTOM ); + mResizeHandle[2] = new LLResizeHandle( std::string("resize"), + LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 ), + mMinWidth, + mMinHeight, + LLResizeHandle::LEFT_BOTTOM ); addChild(mResizeHandle[2]); - mResizeHandle[3] = new LLResizeHandle( "resize", + mResizeHandle[3] = new LLResizeHandle( std::string("resize"), LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT ), mMinWidth, mMinHeight, @@ -1633,7 +1632,7 @@ void LLFloater::buildButtons() btn_rect, sButtonActiveImageNames[i], sButtonPressedImageNames[i], - "", + LLStringUtil::null, sButtonCallbacks[i], this, LLFontGL::sSansSerif); @@ -1657,7 +1656,7 @@ void LLFloater::buildButtons() ///////////////////////////////////////////////////// // LLFloaterView -LLFloaterView::LLFloaterView( const LLString& name, const LLRect& rect ) +LLFloaterView::LLFloaterView( const std::string& name, const LLRect& rect ) : LLUICtrl( name, rect, FALSE, NULL, NULL, FOLLOWS_ALL ), mFocusCycleMode(FALSE), mSnapOffsetBottom(0) @@ -2377,7 +2376,7 @@ LLMultiFloater::LLMultiFloater(LLTabContainer::TabPosition tab_pos) : } -LLMultiFloater::LLMultiFloater(const LLString &name) : +LLMultiFloater::LLMultiFloater(const std::string &name) : LLFloater(name), mTabContainer(NULL), mTabPos(LLTabContainer::TOP), @@ -2388,7 +2387,7 @@ LLMultiFloater::LLMultiFloater(const LLString &name) : } LLMultiFloater::LLMultiFloater( - const LLString& name, + const std::string& name, const LLRect& rect, LLTabContainer::TabPosition tab_pos, BOOL auto_resize) : @@ -2399,7 +2398,7 @@ LLMultiFloater::LLMultiFloater( mOrigMinWidth(0), mOrigMinHeight(0) { - mTabContainer = new LLTabContainer("Preview Tabs", + mTabContainer = new LLTabContainer(std::string("Preview Tabs"), LLRect(LLPANEL_BORDER_WIDTH, getRect().getHeight() - LLFLOATER_HEADER_SIZE, getRect().getWidth() - LLPANEL_BORDER_WIDTH, 0), mTabPos, FALSE, @@ -2414,8 +2413,8 @@ LLMultiFloater::LLMultiFloater( } LLMultiFloater::LLMultiFloater( - const LLString& name, - const LLString& rect_control, + const std::string& name, + const std::string& rect_control, LLTabContainer::TabPosition tab_pos, BOOL auto_resize) : LLFloater(name, rect_control, name), @@ -2425,7 +2424,7 @@ LLMultiFloater::LLMultiFloater( mOrigMinWidth(0), mOrigMinHeight(0) { - mTabContainer = new LLTabContainer("Preview Tabs", + mTabContainer = new LLTabContainer(std::string("Preview Tabs"), LLRect(LLPANEL_BORDER_WIDTH, getRect().getHeight() - LLFLOATER_HEADER_SIZE, getRect().getWidth() - LLPANEL_BORDER_WIDTH, 0), mTabPos, FALSE, @@ -2885,12 +2884,12 @@ LLXMLNodePtr LLFloater::getXML(bool save_children) const // static LLView* LLFloater::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("floater"); + std::string name("floater"); node->getAttributeString("name", name); LLFloater *floaterp = new LLFloater(name); - LLString filename; + std::string filename; node->getAttributeString("filename", filename); if (filename.empty()) @@ -2909,10 +2908,10 @@ LLView* LLFloater::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory, BOOL open) /* Flawfinder: ignore */ { - LLString name(getName()); - LLString title(getTitle()); - LLString short_title(getShortTitle()); - LLString rect_control(""); + std::string name(getName()); + std::string title(getTitle()); + std::string short_title(getShortTitle()); + std::string rect_control(""); BOOL resizable = isResizable(); S32 min_width = getMinWidth(); S32 min_height = getMinHeight(); diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 4e8b86d2de..cb21036ef4 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -86,8 +86,8 @@ public: }; LLFloater(); - LLFloater(const LLString& name); //simple constructor for data-driven initialization - LLFloater( const LLString& name, const LLRect& rect, const LLString& title, + LLFloater(const std::string& name); //simple constructor for data-driven initialization + LLFloater( const std::string& name, const LLRect& rect, const std::string& title, BOOL resizable = FALSE, S32 min_width = DEFAULT_MIN_WIDTH, S32 min_height = DEFAULT_MIN_HEIGHT, @@ -96,7 +96,7 @@ public: BOOL close_btn = TRUE, BOOL bordered = BORDER_NO); - LLFloater( const LLString& name, const LLString& rect_control, const LLString& title, + LLFloater( const std::string& name, const std::string& rect_control, const std::string& title, BOOL resizable = FALSE, S32 min_width = DEFAULT_MIN_WIDTH, S32 min_height = DEFAULT_MIN_HEIGHT, @@ -119,7 +119,7 @@ public: // Can be called multiple times to reset floater parameters. // Deletes all children of the floater. - virtual void initFloater(const LLString& title, BOOL resizable, + virtual void initFloater(const std::string& title, BOOL resizable, S32 min_width, S32 min_height, BOOL drag_on_left, BOOL minimizable, BOOL close_btn); @@ -142,10 +142,10 @@ public: LLMultiFloater* getHost() { return (LLMultiFloater*)mHostHandle.get(); } - void setTitle( const LLString& title ); - const LLString& getTitle() const; - void setShortTitle( const LLString& short_title ); - LLString getShortTitle(); + void setTitle( const std::string& title ); + const std::string& getTitle() const; + void setShortTitle( const std::string& short_title ); + std::string getShortTitle(); void setTitleVisible(bool visible); virtual void setMinimized(BOOL b); void moveResizeHandlesToFront(); @@ -246,7 +246,7 @@ private: BOOL mMinimized; BOOL mForeground; LLHandle<LLFloater> mDependeeHandle; - LLString mShortTitle; + std::string mShortTitle; BOOL mFirstLook; // TRUE if the _next_ time this floater is visible will be the first time in the session that it is visible. @@ -272,11 +272,11 @@ private: static LLMultiFloater* sHostp; static BOOL sEditModeEnabled; - static LLString sButtonActiveImageNames[BUTTON_COUNT]; - static LLString sButtonInactiveImageNames[BUTTON_COUNT]; - static LLString sButtonPressedImageNames[BUTTON_COUNT]; - static LLString sButtonNames[BUTTON_COUNT]; - static LLString sButtonToolTips[BUTTON_COUNT]; + static std::string sButtonActiveImageNames[BUTTON_COUNT]; + static std::string sButtonInactiveImageNames[BUTTON_COUNT]; + static std::string sButtonPressedImageNames[BUTTON_COUNT]; + static std::string sButtonNames[BUTTON_COUNT]; + static std::string sButtonToolTips[BUTTON_COUNT]; typedef void (*click_callback)(void *); static click_callback sButtonCallbacks[BUTTON_COUNT]; @@ -301,7 +301,7 @@ private: class LLFloaterView : public LLUICtrl { public: - LLFloaterView( const LLString& name, const LLRect& rect ); + LLFloaterView( const std::string& name, const LLRect& rect ); /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); void reshapeFloater(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical); @@ -361,9 +361,9 @@ class LLMultiFloater : public LLFloater public: LLMultiFloater(); LLMultiFloater(LLTabContainer::TabPosition tab_pos); - LLMultiFloater(const LLString& name); - LLMultiFloater(const LLString& name, const LLRect& rect, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE); - LLMultiFloater(const LLString& name, const LLString& rect_control, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE); + LLMultiFloater(const std::string& name); + LLMultiFloater(const std::string& name, const LLRect& rect, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE); + LLMultiFloater(const std::string& name, const std::string& rect_control, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE); virtual ~LLMultiFloater() {}; virtual BOOL postBuild(); diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index 621b01ad82..fce84eb2e8 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -120,7 +120,7 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke mFocusTimer.reset(); #ifdef _DEBUG - mKeyboardFocusName = new_focus ? new_focus->getName() : "none"; + mKeyboardFocusName = new_focus ? new_focus->getName() : std::string("none"); #endif // If we've got a default keyboard focus, and the caller is @@ -202,7 +202,7 @@ void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLView* focus ) { mKeyboardFocus = NULL; #ifdef _DEBUG - mKeyboardFocusName = "none"; + mKeyboardFocusName = std::string("none"); #endif } } @@ -243,7 +243,7 @@ void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor ) } #ifdef _DEBUG - mMouseCaptorName = new_captor ? new_captor->getName() : "none"; + mMouseCaptorName = new_captor ? new_captor->getName() : std::string("none"); #endif } } @@ -258,7 +258,7 @@ void LLFocusMgr::removeMouseCaptureWithoutCallback( const LLMouseHandler* captor { mMouseCaptor = NULL; #ifdef _DEBUG - mMouseCaptorName = "none"; + mMouseCaptorName = std::string("none"); #endif } } @@ -289,7 +289,7 @@ void LLFocusMgr::setTopCtrl( LLUICtrl* new_top ) mTopCtrl = new_top; #ifdef _DEBUG - mTopCtrlName = new_top ? new_top->getName() : "none"; + mTopCtrlName = new_top ? new_top->getName() : std::string("none"); #endif if (old_top) @@ -305,7 +305,7 @@ void LLFocusMgr::removeTopCtrlWithoutCallback( const LLUICtrl* top_view ) { mTopCtrl = NULL; #ifdef _DEBUG - mTopCtrlName = "none"; + mTopCtrlName = std::string("none"); #endif } } diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index 34651160f1..3cb45b73ca 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -114,9 +114,9 @@ private: focus_history_map_t mFocusHistory; #ifdef _DEBUG - LLString mMouseCaptorName; - LLString mKeyboardFocusName; - LLString mTopCtrlName; + std::string mMouseCaptorName; + std::string mKeyboardFocusName; + std::string mTopCtrlName; #endif }; diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp index df37532d60..2638bdc3e5 100644 --- a/indra/llui/lliconctrl.cpp +++ b/indra/llui/lliconctrl.cpp @@ -44,7 +44,7 @@ const F32 RESOLUTION_BUMP = 1.f; static LLRegisterWidget<LLIconCtrl> r("icon"); -LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLUUID &image_id) +LLIconCtrl::LLIconCtrl(const std::string& name, const LLRect &rect, const LLUUID &image_id) : LLUICtrl(name, rect, FALSE, // mouse opaque @@ -56,7 +56,7 @@ LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLUUID &i setTabStop(FALSE); } -LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLString &image_name) +LLIconCtrl::LLIconCtrl(const std::string& name, const LLRect &rect, const std::string &image_name) : LLUICtrl(name, rect, FALSE, // mouse opaque @@ -76,7 +76,7 @@ LLIconCtrl::~LLIconCtrl() } -void LLIconCtrl::setImage(const LLString& image_name) +void LLIconCtrl::setImage(const std::string& image_name) { //RN: support UUIDs masquerading as strings if (LLUUID::validate(image_name)) @@ -148,13 +148,13 @@ LLXMLNodePtr LLIconCtrl::getXML(bool save_children) const LLView* LLIconCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("icon"); + std::string name("icon"); node->getAttributeString("name", name); LLRect rect; createRect(node, rect, parent, LLRect()); - LLString image_name; + std::string image_name; if (node->hasAttribute("image_name")) { node->getAttributeString("image_name", image_name); diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index 33429c580e..f1b3a7e03f 100644 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -48,17 +48,17 @@ class LLIconCtrl : public LLUICtrl { public: - LLIconCtrl(const LLString& name, const LLRect &rect, const LLUUID &image_id); - LLIconCtrl(const LLString& name, const LLRect &rect, const LLString &image_name); + LLIconCtrl(const std::string& name, const LLRect &rect, const LLUUID &image_id); + LLIconCtrl(const std::string& name, const LLRect &rect, const std::string &image_name); virtual ~LLIconCtrl(); // llview overrides virtual void draw(); - void setImage(const LLString& image_name); + void setImage(const std::string& image_name); void setImage(const LLUUID& image_name); const LLUUID &getImage() const { return mImageID; } - LLString getImageName() const { return mImageName; } + std::string getImageName() const { return mImageName; } // Takes a UUID, wraps get/setImage virtual void setValue(const LLSD& value ); @@ -71,7 +71,7 @@ public: private: LLColor4 mColor; - LLString mImageName; + std::string mImageName; LLUUID mImageID; LLPointer<LLUIImage> mImagep; }; diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index a81e26f880..e6a87b496c 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -69,7 +69,7 @@ LLKeywords::~LLKeywords() std::for_each(mDelimiterTokenList.begin(), mDelimiterTokenList.end(), DeletePointer()); } -BOOL LLKeywords::loadFromFile( const LLString& filename ) +BOOL LLKeywords::loadFromFile( const std::string& filename ) { mLoaded = FALSE; @@ -80,7 +80,7 @@ BOOL LLKeywords::loadFromFile( const LLString& filename ) char buffer[BUFFER_SIZE]; /* Flawfinder: ignore */ llifstream file; - file.open(filename.c_str()); /* Flawfinder: ignore */ + file.open(filename); /* Flawfinder: ignore */ if( file.fail() ) { llinfos << "LLKeywords::loadFromFile() Unable to open file: " << filename << llendl; @@ -106,52 +106,51 @@ BOOL LLKeywords::loadFromFile( const LLString& filename ) } // start of line (SOL) - const char SOL_COMMENT[] = "#"; - const char SOL_WORD[] = "[word "; - const char SOL_LINE[] = "[line "; - const char SOL_ONE_SIDED_DELIMITER[] = "[one_sided_delimiter "; - const char SOL_TWO_SIDED_DELIMITER[] = "[two_sided_delimiter "; + std::string SOL_COMMENT("#"); + std::string SOL_WORD("[word "); + std::string SOL_LINE("[line "); + std::string SOL_ONE_SIDED_DELIMITER("[one_sided_delimiter "); + std::string SOL_TWO_SIDED_DELIMITER("[two_sided_delimiter "); LLColor3 cur_color( 1, 0, 0 ); LLKeywordToken::TOKEN_TYPE cur_type = LLKeywordToken::WORD; while (!file.eof()) { + buffer[0] = 0; file.getline( buffer, BUFFER_SIZE ); - if( !strncmp( buffer, SOL_COMMENT, strlen(SOL_COMMENT) ) ) /* Flawfinder: ignore */ + std::string line(buffer); + if( line.find(SOL_COMMENT) == 0 ) { continue; } - else - if( !strncmp( buffer, SOL_WORD, strlen(SOL_WORD) ) ) /* Flawfinder: ignore */ + else if( line.find(SOL_WORD) == 0 ) { - cur_color = readColor( buffer + strlen(SOL_WORD) ); /* Flawfinder: ignore */ + cur_color = readColor( line.substr(SOL_WORD.size()) ); cur_type = LLKeywordToken::WORD; continue; } - else - if( !strncmp( buffer, SOL_LINE, strlen(SOL_LINE) ) ) /* Flawfinder: ignore */ + else if( line.find(SOL_LINE) == 0 ) { - cur_color = readColor( buffer + strlen(SOL_LINE) ); /* Flawfinder: ignore */ + cur_color = readColor( line.substr(SOL_LINE.size()) ); cur_type = LLKeywordToken::LINE; continue; } - else - if( !strncmp( buffer, SOL_TWO_SIDED_DELIMITER, strlen(SOL_TWO_SIDED_DELIMITER) ) ) /* Flawfinder: ignore */ + else if( line.find(SOL_TWO_SIDED_DELIMITER) == 0 ) { - cur_color = readColor( buffer + strlen(SOL_TWO_SIDED_DELIMITER) ); /* Flawfinder: ignore */ + cur_color = readColor( line.substr(SOL_TWO_SIDED_DELIMITER.size()) ); cur_type = LLKeywordToken::TWO_SIDED_DELIMITER; continue; } - if( !strncmp( buffer, SOL_ONE_SIDED_DELIMITER, strlen(SOL_ONE_SIDED_DELIMITER) ) ) /* Flawfinder: ignore */ + else if( line.find(SOL_ONE_SIDED_DELIMITER) == 0 ) { - cur_color = readColor( buffer + strlen(SOL_ONE_SIDED_DELIMITER) ); /* Flawfinder: ignore */ + cur_color = readColor( line.substr(SOL_ONE_SIDED_DELIMITER.size()) ); cur_type = LLKeywordToken::ONE_SIDED_DELIMITER; continue; } - LLString token_buffer( buffer ); - LLString::trim(token_buffer); + std::string token_buffer( line ); + LLStringUtil::trim(token_buffer); typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep_word("", " \t"); @@ -161,26 +160,26 @@ BOOL LLKeywords::loadFromFile( const LLString& filename ) if( !token_buffer.empty() && token_word_iter != word_tokens.end() ) { // first word is keyword - LLString keyword = (*token_word_iter); - LLString::trim(keyword); + std::string keyword = (*token_word_iter); + LLStringUtil::trim(keyword); // following words are tooltip - LLString tool_tip; + std::string tool_tip; while (++token_word_iter != word_tokens.end()) { tool_tip += (*token_word_iter); } - LLString::trim(tool_tip); + LLStringUtil::trim(tool_tip); if( !tool_tip.empty() ) { // Replace : with \n for multi-line tool tips. - LLString::replaceChar( tool_tip, ':', '\n' ); + LLStringUtil::replaceChar( tool_tip, ':', '\n' ); addToken(cur_type, keyword, cur_color, tool_tip ); } else { - addToken(cur_type, keyword, cur_color, NULL ); + addToken(cur_type, keyword, cur_color, LLStringUtil::null ); } } } @@ -193,9 +192,9 @@ BOOL LLKeywords::loadFromFile( const LLString& filename ) // Add the token as described void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, - const LLString& key_in, + const std::string& key_in, const LLColor3& color, - const LLString& tool_tip_in ) + const std::string& tool_tip_in ) { LLWString key = utf8str_to_wstring(key_in); LLWString tool_tip = utf8str_to_wstring(tool_tip_in); @@ -219,7 +218,7 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, } } -LLColor3 LLKeywords::readColor( const LLString& s ) +LLColor3 LLKeywords::readColor( const std::string& s ) { F32 r, g, b; r = g = b = 0.0f; @@ -296,7 +295,6 @@ void LLKeywords::findSegments(std::vector<LLTextSegment *>* seg_list, const LLWS } S32 seg_end = cur - base; - //llinfos << "Seg: [" << (char*)LLString( base, seg_start, seg_end-seg_start) << "]" << llendl; LLTextSegment* text_segment = new LLTextSegment( cur_token->getColor(), seg_start, seg_end ); text_segment->setToken( cur_token ); insertSegment( seg_list, text_segment, text_len, defaultColor); @@ -406,7 +404,6 @@ void LLKeywords::findSegments(std::vector<LLTextSegment *>* seg_list, const LLWS } - //llinfos << "Seg: [" << (char*)LLString( base, seg_start, seg_end-seg_start ) << "]" << llendl; LLTextSegment* text_segment = new LLTextSegment( cur_delimiter->getColor(), seg_start, seg_end ); text_segment->setToken( cur_delimiter ); insertSegment( seg_list, text_segment, text_len, defaultColor); @@ -518,7 +515,7 @@ void LLKeywordToken::dump() mColor.mV[VX] << ", " << mColor.mV[VY] << ", " << mColor.mV[VZ] << "] [" << - mToken.c_str() << "]" << + wstring_to_utf8str(mToken) << "]" << llendl; } diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index fe36d7cbf6..ec01db76a8 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -80,16 +80,16 @@ public: LLKeywords(); ~LLKeywords(); - BOOL loadFromFile(const LLString& filename); + BOOL loadFromFile(const std::string& filename); BOOL isLoaded() const { return mLoaded; } void findSegments(std::vector<LLTextSegment *> *seg_list, const LLWString& text, const LLColor4 &defaultColor ); // Add the token as described void addToken(LLKeywordToken::TOKEN_TYPE type, - const LLString& key, + const std::string& key, const LLColor3& color, - const LLString& tool_tip = LLString::null); + const std::string& tool_tip = LLStringUtil::null); typedef std::map<LLWString, LLKeywordToken*> word_token_map_t; typedef word_token_map_t::const_iterator keyword_iterator_t; @@ -101,7 +101,7 @@ public: #endif private: - LLColor3 readColor(const LLString& s); + LLColor3 readColor(const std::string& s); void insertSegment(std::vector<LLTextSegment *> *seg_list, LLTextSegment* new_segment, S32 text_len, const LLColor4 &defaultColor); BOOL mLoaded; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 96039ce943..2655918169 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -87,8 +87,8 @@ static LLRegisterWidget<LLLineEditor> r1("line_editor"); // Member functions // -LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, - const LLString& default_text, const LLFontGL* font, +LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, + const std::string& default_text, const LLFontGL* font, S32 max_length_bytes, void (*commit_callback)(LLUICtrl* caller, void* user_data ), void (*keystroke_callback)(LLLineEditor* caller, void* user_data ), @@ -166,7 +166,7 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, // Scalable UI somehow made these rectangles off-by-one. // I don't know why. JC LLRect border_rect(0, getRect().getHeight()-1, getRect().getWidth()-1, 0); - mBorder = new LLViewBorder( "line ed border", border_rect, border_bevel, border_style, mBorderThickness ); + mBorder = new LLViewBorder( std::string("line ed border"), border_rect, border_bevel, border_style, mBorderThickness ); addChild( mBorder ); mBorder->setFollows(FOLLOWS_LEFT|FOLLOWS_RIGHT|FOLLOWS_TOP|FOLLOWS_BOTTOM); @@ -298,7 +298,7 @@ void LLLineEditor::setText(const LLStringExplicit &new_text) // also consider entire string selected when mSelectAllonFocusReceived is set on an empty, focused line editor all_selected = all_selected || (len == 0 && hasFocus() && mSelectAllonFocusReceived); - LLString truncated_utf8 = new_text; + std::string truncated_utf8 = new_text; if (truncated_utf8.size() > (U32)mMaxLengthBytes) { truncated_utf8 = utf8str_truncate(new_text, mMaxLengthBytes); @@ -959,9 +959,9 @@ void LLLineEditor::paste() // Clean up string (replace tabs and returns and remove characters that our fonts don't support.) LLWString clean_string(paste); - LLWString::replaceTabsWithSpaces(clean_string, 1); + LLWStringUtil::replaceTabsWithSpaces(clean_string, 1); //clean_string = wstring_detabify(paste, 1); - LLWString::replaceChar(clean_string, '\n', mReplaceNewlinesWithSpaces ? ' ' : 182); // 182 == paragraph character + LLWStringUtil::replaceChar(clean_string, '\n', mReplaceNewlinesWithSpaces ? ' ' : 182); // 182 == paragraph character // Insert the string @@ -1395,11 +1395,11 @@ void LLLineEditor::draw() { S32 text_len = mText.length(); - LLString saved_text; + std::string saved_text; if (mDrawAsterixes) { saved_text = mText.getString(); - LLString text; + std::string text; for (S32 i = 0; i < mText.length(); i++) { text += '*'; @@ -1594,7 +1594,7 @@ void LLLineEditor::draw() S32 cursor_right = cursor_left + UI_LINEEDITOR_CURSOR_THICKNESS; if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode() && !hasSelection()) { - const LLWString space(utf8str_to_wstring(LLString(" "))); + const LLWString space(utf8str_to_wstring(std::string(" "))); S32 wswidth = mGLFont->getWidth(space.c_str()); S32 width = mGLFont->getWidth(mText.getWString().c_str(), getCursor(), 1) + 1; cursor_right = cursor_left + llmax(wswidth, width); @@ -1771,7 +1771,7 @@ BOOL LLLineEditor::prevalidateFloat(const LLWString &str) BOOL success = TRUE; LLWString trimmed = str; - LLWString::trim(trimmed); + LLWStringUtil::trim(trimmed); S32 len = trimmed.length(); if( 0 < len ) { @@ -1803,7 +1803,7 @@ BOOL LLLineEditor::prevalidateFloat(const LLWString &str) BOOL LLLineEditor::isPartOfWord(llwchar c) { return (c == '_') || isalnum(c); } // static -BOOL LLLineEditor::postvalidateFloat(const LLString &str) +BOOL LLLineEditor::postvalidateFloat(const std::string &str) { LLLocale locale(LLLocale::USER_LOCALE); @@ -1812,7 +1812,7 @@ BOOL LLLineEditor::postvalidateFloat(const LLString &str) BOOL has_digit = FALSE; LLWString trimmed = utf8str_to_wstring(str); - LLWString::trim(trimmed); + LLWStringUtil::trim(trimmed); S32 len = trimmed.length(); if( 0 < len ) { @@ -1872,7 +1872,7 @@ BOOL LLLineEditor::prevalidateInt(const LLWString &str) BOOL success = TRUE; LLWString trimmed = str; - LLWString::trim(trimmed); + LLWStringUtil::trim(trimmed); S32 len = trimmed.length(); if( 0 < len ) { @@ -1903,7 +1903,7 @@ BOOL LLLineEditor::prevalidatePositiveS32(const LLWString &str) LLLocale locale(LLLocale::USER_LOCALE); LLWString trimmed = str; - LLWString::trim(trimmed); + LLWStringUtil::trim(trimmed); S32 len = trimmed.length(); BOOL success = TRUE; if(0 < len) @@ -1937,7 +1937,7 @@ BOOL LLLineEditor::prevalidateNonNegativeS32(const LLWString &str) LLLocale locale(LLLocale::USER_LOCALE); LLWString trimmed = str; - LLWString::trim(trimmed); + LLWStringUtil::trim(trimmed); S32 len = trimmed.length(); BOOL success = TRUE; if(0 < len) @@ -2092,7 +2092,7 @@ LLXMLNodePtr LLLineEditor::getXML(bool save_children) const if (mBorder) { - LLString bevel; + std::string bevel; switch(mBorder->getBevel()) { default: @@ -2103,7 +2103,7 @@ LLXMLNodePtr LLLineEditor::getXML(bool save_children) const } node->createChild("bevel_style", TRUE)->setStringValue(bevel); - LLString style; + std::string style; switch(mBorder->getStyle()) { default: @@ -2140,7 +2140,7 @@ LLXMLNodePtr LLLineEditor::getXML(bool save_children) const // static LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("line_editor"); + std::string name("line_editor"); node->getAttributeString("name", name); LLRect rect; @@ -2151,15 +2151,15 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory LLFontGL* font = LLView::selectFont(node); - LLString text = node->getTextContents().substr(0, max_text_length - 1); + std::string text = node->getTextContents().substr(0, max_text_length - 1); LLViewBorder::EBevel bevel_style = LLViewBorder::BEVEL_IN; LLViewBorder::getBevelFromAttribute(node, bevel_style); LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE; - LLString border_string; + std::string border_string; node->getAttributeString("border_style", border_string); - LLString::toLower(border_string); + LLStringUtil::toLower(border_string); if (border_string == "texture") { @@ -2185,7 +2185,7 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory border_style, border_thickness); - LLString label; + std::string label; if(node->getAttributeString("label", label)) { line_editor->setLabel(label); @@ -2215,10 +2215,10 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory line_editor->setSelectAllonFocusReceived(selectall); } - LLString prevalidate; + std::string prevalidate; if(node->getAttributeString("prevalidate", prevalidate)) { - LLString::toLower(prevalidate); + LLStringUtil::toLower(prevalidate); if ("ascii" == prevalidate) { @@ -2270,11 +2270,11 @@ void LLLineEditor::cleanupClass() } /* static */ -LLPointer<LLUIImage> LLLineEditor::parseImage(LLString name, LLXMLNodePtr from, LLPointer<LLUIImage> def) +LLPointer<LLUIImage> LLLineEditor::parseImage(std::string name, LLXMLNodePtr from, LLPointer<LLUIImage> def) { - LLString xml_name; - if (from->hasAttribute(name)) from->getAttributeString(name, xml_name); - if (xml_name == LLString::null) return def; + std::string xml_name; + if (from->hasAttribute(name.c_str())) from->getAttributeString(name.c_str(), xml_name); + if (xml_name == LLStringUtil::null) return def; LLPointer<LLUIImage> image = LLUI::getUIImage(xml_name); return image.isNull() ? def : image; } @@ -2282,7 +2282,7 @@ LLPointer<LLUIImage> LLLineEditor::parseImage(LLString name, LLXMLNodePtr from, void LLLineEditor::setColorParameters(LLXMLNodePtr node) { // overrides default image if supplied. - mImage = parseImage("image", node, mImage); + mImage = parseImage(std::string("image"), node, mImage); LLColor4 color; if (LLUICtrlFactory::getAttributeColor(node,"cursor_color", color)) @@ -2315,13 +2315,13 @@ void LLLineEditor::setColorParameters(LLXMLNodePtr node) } } -BOOL LLLineEditor::setTextArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLLineEditor::setTextArg( const std::string& key, const LLStringExplicit& text ) { mText.setArg(key, text); return TRUE; } -BOOL LLLineEditor::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLLineEditor::setLabelArg( const std::string& key, const LLStringExplicit& text ) { mLabel.setArg(key, text); return TRUE; @@ -2555,25 +2555,25 @@ void LLLineEditor::setReplaceNewlinesWithSpaces(BOOL replace) static LLRegisterWidget<LLSearchEditor> r2("search_editor"); -LLSearchEditor::LLSearchEditor(const LLString& name, +LLSearchEditor::LLSearchEditor(const std::string& name, const LLRect& rect, S32 max_length_bytes, - void (*search_callback)(const LLString& search_string, void* user_data), + void (*search_callback)(const std::string& search_string, void* user_data), void* userdata) : LLUICtrl(name, rect, TRUE, NULL, userdata), mSearchCallback(search_callback) { LLRect search_edit_rect(0, getRect().getHeight(), getRect().getWidth(), 0); - mSearchEdit = new LLLineEditor("search edit", - search_edit_rect, - LLString::null, - NULL, - max_length_bytes, - NULL, - onSearchEdit, - NULL, - this); + mSearchEdit = new LLLineEditor(std::string("search edit"), + search_edit_rect, + LLStringUtil::null, + NULL, + max_length_bytes, + NULL, + onSearchEdit, + NULL, + this); mSearchEdit->setFollowsAll(); mSearchEdit->setSelectAllonFocusReceived(TRUE); @@ -2582,15 +2582,15 @@ LLSearchEditor::LLSearchEditor(const LLString& name, S32 btn_width = rect.getHeight(); // button is square, and as tall as search editor LLRect clear_btn_rect(rect.getWidth() - btn_width, rect.getHeight(), rect.getWidth(), 0); - mClearSearchButton = new LLButton("clear search", + mClearSearchButton = new LLButton(std::string("clear search"), clear_btn_rect, - "icn_clear_lineeditor.tga", - "UIImgBtnCloseInactiveUUID", - LLString::null, + std::string("icn_clear_lineeditor.tga"), + std::string("UIImgBtnCloseInactiveUUID"), + LLStringUtil::null, onClearSearch, this, NULL, - LLString::null); + LLStringUtil::null); mClearSearchButton->setFollowsRight(); mClearSearchButton->setFollowsTop(); mClearSearchButton->setImageColor(LLUI::sColorsGroup->getColor("TextFgTentativeColor")); @@ -2614,13 +2614,13 @@ LLSD LLSearchEditor::getValue() const } //virtual -BOOL LLSearchEditor::setTextArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLSearchEditor::setTextArg( const std::string& key, const LLStringExplicit& text ) { return mSearchEdit->setTextArg(key, text); } //virtual -BOOL LLSearchEditor::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLSearchEditor::setLabelArg( const std::string& key, const LLStringExplicit& text ) { return mSearchEdit->setLabelArg(key, text); } @@ -2657,17 +2657,17 @@ void LLSearchEditor::onClearSearch(void* user_data) { LLSearchEditor* search_editor = (LLSearchEditor*)user_data; - search_editor->setText(LLString::null); + search_editor->setText(LLStringUtil::null); if (search_editor->mSearchCallback) { - search_editor->mSearchCallback(LLString::null, search_editor->mCallbackUserData); + search_editor->mSearchCallback(LLStringUtil::null, search_editor->mCallbackUserData); } } // static LLView* LLSearchEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("search_editor"); + std::string name("search_editor"); node->getAttributeString("name", name); LLRect rect; @@ -2676,14 +2676,14 @@ LLView* LLSearchEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto S32 max_text_length = 128; node->getAttributeS32("max_length", max_text_length); - LLString text = node->getValue().substr(0, max_text_length - 1); + std::string text = node->getValue().substr(0, max_text_length - 1); LLSearchEditor* search_editor = new LLSearchEditor(name, rect, max_text_length, NULL, NULL); - LLString label; + std::string label; if(node->getAttributeString("label", label)) { search_editor->mSearchEdit->setLabel(label); diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 8b41dd1d87..8bf7613c79 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -63,9 +63,9 @@ class LLLineEditor { public: - LLLineEditor(const LLString& name, + LLLineEditor(const std::string& name, const LLRect& rect, - const LLString& default_text = LLString::null, + const std::string& default_text = LLStringUtil::null, const LLFontGL* glfont = NULL, S32 max_length_bytes = 254, void (*commit_callback)(LLUICtrl* caller, void* user_data) = NULL, @@ -132,13 +132,13 @@ public: // assumes UTF8 text virtual void setValue(const LLSD& value ) { setText(value.asString()); } virtual LLSD getValue() const { return LLSD(getText()); } - virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text ); - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); + virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); void setLabel(const LLStringExplicit &new_label) { mLabel = new_label; } void setText(const LLStringExplicit &new_text); - const LLString& getText() const { return mText.getString(); } + const std::string& getText() const { return mText.getString(); } const LLWString& getWText() const { return mText.getWString(); } S32 getLength() const { return mText.length(); } @@ -205,7 +205,7 @@ public: static BOOL prevalidatePrintableNoSpace(const LLWString &str); static BOOL prevalidateASCII(const LLWString &str); - static BOOL postvalidateFloat(const LLString &str); + static BOOL postvalidateFloat(const std::string &str); // line history support: void setEnableLineHistory( BOOL enabled ) { mHaveHistory = enabled; } // switches line history on or off @@ -242,12 +242,12 @@ private: protected: LLUIString mText; // The string being edited. - LLString mPrevText; // Saved string for 'ESC' revert + std::string mPrevText; // Saved string for 'ESC' revert LLUIString mLabel; // text label that is visible when no user text provided // line history support: BOOL mHaveHistory; // flag for enabled line history - std::vector<LLString> mLineHistory; // line history storage + std::vector<std::string> mLineHistory; // line history storage U32 mCurrentHistoryLine; // currently browsed history line LLViewBorder* mBorder; @@ -307,7 +307,7 @@ protected: private: // Utility on top of LLUI::getUIImage, looks up a named image in a given XML node and returns it if possible // or returns a given default image if anything in the process fails. - static LLPointer<LLUIImage> parseImage(LLString name, LLXMLNodePtr from, LLPointer<LLUIImage> def); + static LLPointer<LLUIImage> parseImage(std::string name, LLXMLNodePtr from, LLPointer<LLUIImage> def); // Global instance used as default for member instance below. static LLPointer<LLUIImage> sImage; // Instances that by default point to the statics but can be overidden in XML. @@ -341,10 +341,10 @@ private: ed->mPrevText = mText; } - LLString getText() { return mText; } + std::string getText() { return mText; } private: - LLString mText; + std::string mText; S32 mCursorPos; S32 mScrollHPos; BOOL mIsSelecting; @@ -362,10 +362,10 @@ private: class LLSearchEditor : public LLUICtrl { public: - LLSearchEditor(const LLString& name, + LLSearchEditor(const std::string& name, const LLRect& rect, S32 max_length_bytes, - void (*search_callback)(const LLString& search_string, void* user_data), + void (*search_callback)(const std::string& search_string, void* user_data), void* userdata); virtual ~LLSearchEditor() {} @@ -376,13 +376,13 @@ public: void setText(const LLStringExplicit &new_text) { mSearchEdit->setText(new_text); } - void setSearchCallback(void (*search_callback)(const LLString& search_string, void* user_data), void* data) { mSearchCallback = search_callback; mCallbackUserData = data; } + void setSearchCallback(void (*search_callback)(const std::string& search_string, void* user_data), void* data) { mSearchCallback = search_callback; mCallbackUserData = data; } // LLUICtrl interface virtual void setValue(const LLSD& value ); virtual LLSD getValue() const; - virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text ); - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); + virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); virtual void clear(); private: @@ -391,7 +391,7 @@ private: LLLineEditor* mSearchEdit; class LLButton* mClearSearchButton; - void (*mSearchCallback)(const LLString& search_string, void* user_data); + void (*mSearchCallback)(const std::string& search_string, void* user_data); }; diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 62b86a6ad7..fba0984dce 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -74,10 +74,10 @@ S32 MENU_BAR_WIDTH = 0; /// Local function declarations, constants, enums, and typedefs ///============================================================================ -const LLString SEPARATOR_NAME("separator"); -const LLString TEAROFF_SEPARATOR_LABEL( "~~~~~~~~~~~" ); -const LLString SEPARATOR_LABEL( "-----------" ); -const LLString VERTICAL_SEPARATOR_LABEL( "|" ); +const std::string SEPARATOR_NAME("separator"); +const std::string TEAROFF_SEPARATOR_LABEL( "~~~~~~~~~~~" ); +const std::string SEPARATOR_LABEL( "-----------" ); +const std::string VERTICAL_SEPARATOR_LABEL( "|" ); const S32 LABEL_BOTTOM_PAD_PIXELS = 2; @@ -98,10 +98,10 @@ const U32 SEPARATOR_HEIGHT_PIXELS = 8; const S32 TEAROFF_SEPARATOR_HEIGHT_PIXELS = 10; const S32 MENU_ITEM_PADDING = 4; -const LLString BOOLEAN_TRUE_PREFIX( "X" ); -const LLString BRANCH_SUFFIX( ">" ); -const LLString ARROW_UP ("^^^^^^^"); -const LLString ARROW_DOWN("vvvvvvv"); +const std::string BOOLEAN_TRUE_PREFIX( "X" ); +const std::string BRANCH_SUFFIX( ">" ); +const std::string ARROW_UP ("^^^^^^^"); +const std::string ARROW_DOWN("vvvvvvv"); const F32 MAX_MOUSE_SLOPE_SUB_MENU = 0.9f; @@ -130,7 +130,7 @@ const F32 ACTIVATE_HIGHLIGHT_TIME = 0.3f; ///============================================================================ // Default constructor -LLMenuItemGL::LLMenuItemGL( const LLString& name, const LLString& label, KEY key, MASK mask ) : +LLMenuItemGL::LLMenuItemGL( const std::string& name, const std::string& label, KEY key, MASK mask ) : LLView( name, TRUE ), mJumpKey(KEY_NONE), mAcceleratorKey( key ), @@ -220,7 +220,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp) // *NOTE: get calling code to throw up warning or route // warning messages back to app-provided output - // LLString warning; + // std::string warning; // warning.append("Duplicate key binding <"); // appendAcceleratorString( warning ); // warning.append("> for menu items:\n "); @@ -250,7 +250,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp) // This function appends the character string representation of // the current accelerator key and mask to the provided string. -void LLMenuItemGL::appendAcceleratorString( LLString& st ) const +void LLMenuItemGL::appendAcceleratorString( std::string& st ) const { // break early if this is a silly thing to do. if( KEY_NONE == mAcceleratorKey ) @@ -286,7 +286,7 @@ void LLMenuItemGL::appendAcceleratorString( LLString& st ) const st.append( "Shift-" ); #endif - LLString keystr = LLKeyboard::stringFromKey( mAcceleratorKey ); + std::string keystr = LLKeyboard::stringFromKey( mAcceleratorKey ); if ((mAcceleratorMask & MASK_NORMALKEYS) && (keystr[0] == '-' || keystr[0] == '=')) { @@ -334,7 +334,7 @@ U32 LLMenuItemGL::getNominalWidth( void ) const if( KEY_NONE != mAcceleratorKey ) { width += ACCEL_PAD_PIXELS; - LLString temp; + std::string temp; appendAcceleratorString( temp ); width += mFont->getWidth( temp ); } @@ -346,7 +346,7 @@ U32 LLMenuItemGL::getNominalWidth( void ) const void LLMenuItemGL::buildDrawLabel( void ) { mDrawAccelLabel.clear(); - LLString st = mDrawAccelLabel.getString(); + std::string st = mDrawAccelLabel.getString(); appendAcceleratorString( st ); mDrawAccelLabel = st; } @@ -491,8 +491,8 @@ void LLMenuItemGL::draw( void ) // underline "jump" key only when keyboard navigation has been initiated if (getMenu()->jumpKeysActive() && LLMenuGL::getKeyboardMode()) { - LLString upper_case_label = mLabel.getString(); - LLString::toUpper(upper_case_label); + std::string upper_case_label = mLabel.getString(); + LLStringUtil::toUpper(upper_case_label); std::string::size_type offset = upper_case_label.find(mJumpKey); if (offset != std::string::npos) { @@ -506,7 +506,7 @@ void LLMenuItemGL::draw( void ) setHover(FALSE); } -BOOL LLMenuItemGL::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLMenuItemGL::setLabelArg( const std::string& key, const LLStringExplicit& text ) { mLabel.setArg(key, text); return TRUE; @@ -521,9 +521,9 @@ BOOL LLMenuItemGL::setLabelArg( const LLString& key, const LLStringExplicit& tex class LLMenuItemSeparatorGL : public LLMenuItemGL { public: - LLMenuItemSeparatorGL( const LLString &name = SEPARATOR_NAME ); + LLMenuItemSeparatorGL( const std::string &name = SEPARATOR_NAME ); - virtual LLString getType() const { return "separator"; } + virtual std::string getType() const { return "separator"; } // doIt() - do the primary funcationality of the menu item. virtual void doIt( void ) {} @@ -536,7 +536,7 @@ public: virtual U32 getNominalHeight( void ) const { return SEPARATOR_HEIGHT_PIXELS; } }; -LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const LLString &name ) : +LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const std::string &name ) : LLMenuItemGL( name, SEPARATOR_LABEL ) { } @@ -615,7 +615,7 @@ LLMenuItemVerticalSeparatorGL::LLMenuItemVerticalSeparatorGL( void ) // Class LLMenuItemTearOffGL //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LLMenuItemTearOffGL::LLMenuItemTearOffGL(LLHandle<LLFloater> parent_floater_handle) : - LLMenuItemGL("tear off", TEAROFF_SEPARATOR_LABEL), + LLMenuItemGL(std::string("tear off"), TEAROFF_SEPARATOR_LABEL), mParentHandle(parent_floater_handle) { } @@ -694,7 +694,7 @@ U32 LLMenuItemTearOffGL::getNominalHeight( void ) const class LLMenuItemBlankGL : public LLMenuItemGL { public: - LLMenuItemBlankGL( void ) : LLMenuItemGL( "", "" ) + LLMenuItemBlankGL( void ) : LLMenuItemGL( LLStringUtil::null, LLStringUtil::null ) { setEnabled(FALSE); } @@ -707,8 +707,8 @@ public: /// Class LLMenuItemCallGL ///============================================================================ -LLMenuItemCallGL::LLMenuItemCallGL( const LLString& name, - const LLString& label, +LLMenuItemCallGL::LLMenuItemCallGL( const std::string& name, + const std::string& label, menu_callback clicked_cb, enabled_callback enabled_cb, void* user_data, @@ -725,7 +725,7 @@ LLMenuItemCallGL::LLMenuItemCallGL( const LLString& name, if(!enabled) setEnabled(FALSE); } -LLMenuItemCallGL::LLMenuItemCallGL( const LLString& name, +LLMenuItemCallGL::LLMenuItemCallGL( const std::string& name, menu_callback clicked_cb, enabled_callback enabled_cb, void* user_data, @@ -742,8 +742,8 @@ LLMenuItemCallGL::LLMenuItemCallGL( const LLString& name, if(!enabled) setEnabled(FALSE); } -LLMenuItemCallGL::LLMenuItemCallGL(const LLString& name, - const LLString& label, +LLMenuItemCallGL::LLMenuItemCallGL(const std::string& name, + const std::string& label, menu_callback clicked_cb, enabled_callback enabled_cb, label_callback label_cb, @@ -761,7 +761,7 @@ LLMenuItemCallGL::LLMenuItemCallGL(const LLString& name, if(!enabled) setEnabled(FALSE); } -LLMenuItemCallGL::LLMenuItemCallGL(const LLString& name, +LLMenuItemCallGL::LLMenuItemCallGL(const std::string& name, menu_callback clicked_cb, enabled_callback enabled_cb, label_callback label_cb, @@ -779,7 +779,7 @@ LLMenuItemCallGL::LLMenuItemCallGL(const LLString& name, if(!enabled) setEnabled(FALSE); } -void LLMenuItemCallGL::setEnabledControl(LLString enabled_control, LLView *context) +void LLMenuItemCallGL::setEnabledControl(std::string enabled_control, LLView *context) { // Register new listener if (!enabled_control.empty()) @@ -796,7 +796,7 @@ void LLMenuItemCallGL::setEnabledControl(LLString enabled_control, LLView *conte } } -void LLMenuItemCallGL::setVisibleControl(LLString visible_control, LLView *context) +void LLMenuItemCallGL::setVisibleControl(std::string visible_control, LLView *context) { // Register new listener if (!visible_control.empty()) @@ -824,7 +824,7 @@ LLXMLNodePtr LLMenuItemCallGL::getXML(bool save_children) const std::vector<LLListenerEntry>::iterator itor; for (itor = listeners.begin(); itor != listeners.end(); ++itor) { - LLString listener_name = findEventListener((LLSimpleListener*)itor->listener); + std::string listener_name = findEventListener((LLSimpleListener*)itor->listener); if (!listener_name.empty()) { LLXMLNodePtr child_node = node->createChild("on_click", FALSE); @@ -862,7 +862,7 @@ void LLMenuItemCallGL::buildDrawLabel( void ) } if(mLabelCallback) { - LLString label; + std::string label; mLabelCallback(label, mUserData); mLabel = label; } @@ -894,8 +894,8 @@ BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) /// Class LLMenuItemCheckGL ///============================================================================ -LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, - const LLString& label, +LLMenuItemCheckGL::LLMenuItemCheckGL ( const std::string& name, + const std::string& label, menu_callback clicked_cb, enabled_callback enabled_cb, check_callback check_cb, @@ -907,7 +907,7 @@ LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, { } -LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, +LLMenuItemCheckGL::LLMenuItemCheckGL ( const std::string& name, menu_callback clicked_cb, enabled_callback enabled_cb, check_callback check_cb, @@ -919,11 +919,11 @@ LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, { } -LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, - const LLString& label, +LLMenuItemCheckGL::LLMenuItemCheckGL ( const std::string& name, + const std::string& label, menu_callback clicked_cb, enabled_callback enabled_cb, - LLString control_name, + std::string control_name, LLView *context, void* user_data, KEY key, MASK mask ) : @@ -947,7 +947,7 @@ void LLMenuItemCheckGL::setValue(const LLSD& value) } } -void LLMenuItemCheckGL::setCheckedControl(LLString checked_control, LLView *context) +void LLMenuItemCheckGL::setCheckedControl(std::string checked_control, LLView *context) { // Register new listener if (!checked_control.empty()) @@ -990,14 +990,14 @@ void LLMenuItemCheckGL::buildDrawLabel( void ) /// Class LLMenuItemToggleGL ///============================================================================ -LLMenuItemToggleGL::LLMenuItemToggleGL( const LLString& name, const LLString& label, BOOL* toggle, +LLMenuItemToggleGL::LLMenuItemToggleGL( const std::string& name, const std::string& label, BOOL* toggle, KEY key, MASK mask ) : LLMenuItemGL( name, label, key, mask ), mToggle( toggle ) { } -LLMenuItemToggleGL::LLMenuItemToggleGL( const LLString& name, BOOL* toggle, +LLMenuItemToggleGL::LLMenuItemToggleGL( const std::string& name, BOOL* toggle, KEY key, MASK mask ) : LLMenuItemGL( name, name, key, mask ), mToggle( toggle ) @@ -1017,7 +1017,7 @@ void LLMenuItemToggleGL::buildDrawLabel( void ) mDrawBoolLabel.clear(); } mDrawAccelLabel.clear(); - LLString st = mDrawAccelLabel; + std::string st = mDrawAccelLabel; appendAcceleratorString( st ); mDrawAccelLabel = st; } @@ -1033,7 +1033,7 @@ void LLMenuItemToggleGL::doIt( void ) } -LLMenuItemBranchGL::LLMenuItemBranchGL( const LLString& name, const LLString& label, LLMenuGL* branch, +LLMenuItemBranchGL::LLMenuItemBranchGL( const std::string& name, const std::string& label, LLMenuGL* branch, KEY key, MASK mask ) : LLMenuItemGL( name, label, key, mask ), mBranch( branch ) @@ -1043,7 +1043,7 @@ LLMenuItemBranchGL::LLMenuItemBranchGL( const LLString& name, const LLString& la } // virtual -LLView* LLMenuItemBranchGL::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const +LLView* LLMenuItemBranchGL::getChildView(const std::string& name, BOOL recurse, BOOL create_if_missing) const { // richard: this is redundant with parent, remove if (mBranch->getName() == name) @@ -1109,7 +1109,7 @@ BOOL LLMenuItemBranchGL::addToAcceleratorList(std::list<LLKeyBinding*> *listp) void LLMenuItemBranchGL::buildDrawLabel( void ) { mDrawAccelLabel.clear(); - LLString st = mDrawAccelLabel; + std::string st = mDrawAccelLabel; appendAcceleratorString( st ); mDrawAccelLabel = st; mDrawBranchLabel = BRANCH_SUFFIX; @@ -1325,10 +1325,10 @@ class LLMenuItemBranchDownGL : public LLMenuItemBranchGL protected: public: - LLMenuItemBranchDownGL( const LLString& name, const LLString& label, LLMenuGL* branch, + LLMenuItemBranchDownGL( const std::string& name, const std::string& label, LLMenuGL* branch, KEY key = KEY_NONE, MASK mask = MASK_NONE ); - virtual LLString getType() const { return "menu"; } + virtual std::string getType() const { return "menu"; } // returns the normal width of this control in pixels - this is // used for calculating the widest item, as well as for horizontal @@ -1356,8 +1356,8 @@ public: virtual BOOL handleAcceleratorKey(KEY key, MASK mask); }; -LLMenuItemBranchDownGL::LLMenuItemBranchDownGL( const LLString& name, - const LLString& label, +LLMenuItemBranchDownGL::LLMenuItemBranchDownGL( const std::string& name, + const std::string& label, LLMenuGL* branch, KEY key, MASK mask ) : LLMenuItemBranchGL( name, label, branch, key, mask ) @@ -1378,7 +1378,7 @@ U32 LLMenuItemBranchDownGL::getNominalWidth( void ) const void LLMenuItemBranchDownGL::buildDrawLabel( void ) { mDrawAccelLabel.clear(); - LLString st = mDrawAccelLabel; + std::string st = mDrawAccelLabel; appendAcceleratorString( st ); mDrawAccelLabel = st; } @@ -1591,8 +1591,8 @@ void LLMenuItemBranchDownGL::draw( void ) // underline navigation key only when keyboard navigation has been initiated if (getMenu()->jumpKeysActive() && LLMenuGL::getKeyboardMode()) { - LLString upper_case_label = mLabel.getString(); - LLString::toUpper(upper_case_label); + std::string upper_case_label = mLabel.getString(); + LLStringUtil::toUpper(upper_case_label); std::string::size_type offset = upper_case_label.find(getJumpKey()); if (offset != std::string::npos) { @@ -1615,7 +1615,7 @@ void LLMenuItemBranchDownGL::draw( void ) static LLRegisterWidget<LLMenuGL> r1("menu"); // Default constructor -LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater_handle ) +LLMenuGL::LLMenuGL( const std::string& name, const std::string& label, LLHandle<LLFloater> parent_floater_handle ) : LLUICtrl( name, LLRect(), FALSE, NULL, NULL ), mBackgroundColor( sDefaultBackgroundColor ), mBgVisible( TRUE ), @@ -1640,7 +1640,7 @@ LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloa setTabStop(FALSE); } -LLMenuGL::LLMenuGL( const LLString& label, LLHandle<LLFloater> parent_floater_handle ) +LLMenuGL::LLMenuGL( const std::string& label, LLHandle<LLFloater> parent_floater_handle ) : LLUICtrl( label, LLRect(), FALSE, NULL, NULL ), mBackgroundColor( sDefaultBackgroundColor ), mBgVisible( TRUE ), @@ -1749,10 +1749,10 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory { LLMenuItemGL *item = NULL; - LLString type; - LLString item_name; - LLString source_label; - LLString item_label; + std::string type; + std::string item_name; + std::string source_label; + std::string item_label; KEY jump_key = KEY_NONE; child->getAttributeString("type", type); @@ -1794,7 +1794,7 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory child->getAttributeBOOL("useMacCtrl", useMacCtrl); #endif // LL_DARWIN - LLString shortcut; + std::string shortcut; child->getAttributeString("shortcut", shortcut); if (shortcut.find("control") != shortcut.npos) { @@ -1815,7 +1815,7 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory mask |= MASK_SHIFT; } S32 pipe_pos = shortcut.rfind("|"); - LLString key_str = shortcut.substr(pipe_pos+1); + std::string key_str = shortcut.substr(pipe_pos+1); KEY key = KEY_NONE; LLKeyboard::keyFromString(key_str, &key); @@ -1825,7 +1825,7 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory if (child->hasName(LL_MENU_ITEM_CHECK_GL_TAG)) { - LLString control_name; + std::string control_name; child->getAttributeString("control_name", control_name); new_item = new LLMenuItemCheckGL(item_name, item_label, 0, 0, control_name, parent, 0, key, mask); @@ -1834,15 +1834,15 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory { if (call_child->hasName("on_check")) { - LLString callback_name; - LLString control_name = ""; + std::string callback_name; + std::string control_name; if (call_child->hasAttribute("function")) { call_child->getAttributeString("function", callback_name); control_name = callback_name; - LLString callback_data = item_name; + std::string callback_data = item_name; if (call_child->hasAttribute("userdata")) { call_child->getAttributeString("userdata", callback_data); @@ -1888,10 +1888,10 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory { if (call_child->hasName("on_click")) { - LLString callback_name; + std::string callback_name; call_child->getAttributeString("function", callback_name); - LLString callback_data = item_name; + std::string callback_data = item_name; if (call_child->hasAttribute("userdata")) { call_child->getAttributeString("userdata", callback_data); @@ -1905,15 +1905,15 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory } if (call_child->hasName("on_enable")) { - LLString callback_name; - LLString control_name = ""; + std::string callback_name; + std::string control_name; if (call_child->hasAttribute("function")) { call_child->getAttributeString("function", callback_name); control_name = callback_name; - LLString callback_data = ""; + std::string callback_data; if (call_child->hasAttribute("userdata")) { call_child->getAttributeString("userdata", callback_data); @@ -1945,15 +1945,15 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory } if (call_child->hasName("on_visible")) { - LLString callback_name; - LLString control_name = ""; + std::string callback_name; + std::string control_name; if (call_child->hasAttribute("function")) { call_child->getAttributeString("function", callback_name); control_name = callback_name; - LLString callback_data = ""; + std::string callback_data; if (call_child->hasAttribute("userdata")) { call_child->getAttributeString("userdata", callback_data); @@ -2045,14 +2045,14 @@ BOOL LLMenuGL::isOpen() // static LLView* LLMenuGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("menu"); + std::string name("menu"); node->getAttributeString("name", name); - LLString label = name; + std::string label = name; node->getAttributeString("label", label); // parse jump key out of label - LLString new_menu_label; + std::string new_menu_label; typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep("_"); @@ -2132,7 +2132,7 @@ void LLMenuGL::arrange( void ) U32 max_width = getTornOff() ? U32_MAX : menu_region_rect.getWidth(); U32 max_height = getTornOff() ? U32_MAX : menu_region_rect.getHeight(); // *FIX: create the item first and then ask for its dimensions? - S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::sSansSerif->getWidth( "More" ); + S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::sSansSerif->getWidth( std::string("More") ); S32 spillover_item_height = llround(LLFontGL::sSansSerif->getLineHeight()) + MENU_ITEM_PADDING; if (mHorizontalLayout) @@ -2249,13 +2249,13 @@ void LLMenuGL::createSpilloverBranch() delete mSpilloverMenu; // technically, you can't tear off spillover menus, but we're passing the handle // along just to be safe - mSpilloverMenu = new LLMenuGL("More", "More", mParentFloaterHandle); + mSpilloverMenu = new LLMenuGL(std::string("More"), std::string("More"), mParentFloaterHandle); mSpilloverMenu->updateParent(LLMenuGL::sMenuContainer); // Inherit colors mSpilloverMenu->setBackgroundColor( mBackgroundColor ); mSpilloverMenu->setCanTearOff(FALSE); - mSpilloverBranch = new LLMenuItemBranchGL("More", "More", mSpilloverMenu); + mSpilloverBranch = new LLMenuItemBranchGL(std::string("More"), std::string("More"), mSpilloverMenu); mSpilloverBranch->setFontStyle(LLFontGL::ITALIC); } } @@ -2295,8 +2295,8 @@ void LLMenuGL::createJumpKeys() { mJumpKeys.clear(); - std::set<LLString> unique_words; - std::set<LLString> shared_words; + std::set<std::string> unique_words; + std::set<std::string> shared_words; item_list_t::iterator item_it; typedef boost::tokenizer<boost::char_separator<char> > tokenizer; @@ -2304,8 +2304,8 @@ void LLMenuGL::createJumpKeys() for(item_it = mItems.begin(); item_it != mItems.end(); ++item_it) { - LLString uppercase_label = (*item_it)->getLabel(); - LLString::toUpper(uppercase_label); + std::string uppercase_label = (*item_it)->getLabel(); + LLStringUtil::toUpper(uppercase_label); tokenizer tokens(uppercase_label, sep); tokenizer::iterator token_iter; @@ -2350,8 +2350,8 @@ void LLMenuGL::createJumpKeys() { continue; } - LLString uppercase_label = (*item_it)->getLabel(); - LLString::toUpper(uppercase_label); + std::string uppercase_label = (*item_it)->getLabel(); + LLStringUtil::toUpper(uppercase_label); tokenizer tokens(uppercase_label, sep); tokenizer::iterator token_iter; @@ -2359,7 +2359,7 @@ void LLMenuGL::createJumpKeys() BOOL found_key = FALSE; for( token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) { - LLString uppercase_word = *token_iter; + std::string uppercase_word = *token_iter; // this word is not shared with other menu entries... if (shared_words.find(*token_iter) == shared_words.end()) @@ -2439,9 +2439,13 @@ BOOL LLMenuGL::append( LLMenuItemGL* item ) } // add a separator to this menu -BOOL LLMenuGL::appendSeparator( const LLString &separator_name ) +BOOL LLMenuGL::appendSeparator( const std::string &separator_name ) { - LLMenuItemGL* separator = new LLMenuItemSeparatorGL(separator_name); + LLMenuItemGL* separator; + if (separator_name.empty()) + separator = new LLMenuItemSeparatorGL(std::string("separator")); + else + separator = new LLMenuItemSeparatorGL(separator_name); return append( separator ); } @@ -2478,7 +2482,7 @@ void LLMenuGL::setEnabledSubMenus(BOOL enable) // setItemEnabled() - pass the label and the enable flag for a menu // item. TRUE will make sure it's enabled, FALSE will disable it. -void LLMenuGL::setItemEnabled( const LLString& name, BOOL enable ) +void LLMenuGL::setItemEnabled( const std::string& name, BOOL enable ) { item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) @@ -2492,7 +2496,7 @@ void LLMenuGL::setItemEnabled( const LLString& name, BOOL enable ) } } -void LLMenuGL::setItemVisible( const LLString& name, BOOL visible ) +void LLMenuGL::setItemVisible( const std::string& name, BOOL visible ) { item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) @@ -2871,7 +2875,7 @@ void LLMenuGL::setVisible(BOOL visible) } } -LLMenuGL* LLMenuGL::getChildMenuByName(const LLString& name, BOOL recurse) const +LLMenuGL* LLMenuGL::getChildMenuByName(const std::string& name, BOOL recurse) const { LLView* view = getChildView(name, recurse, FALSE); if (view) @@ -2963,7 +2967,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) class LLPieMenuBranch : public LLMenuItemGL { public: - LLPieMenuBranch(const LLString& name, const LLString& label, LLPieMenu* branch); + LLPieMenuBranch(const std::string& name, const std::string& label, LLPieMenu* branch); // called to rebuild the draw label virtual void buildDrawLabel( void ); @@ -2977,8 +2981,8 @@ protected: LLPieMenu* mBranch; }; -LLPieMenuBranch::LLPieMenuBranch(const LLString& name, - const LLString& label, +LLPieMenuBranch::LLPieMenuBranch(const std::string& name, + const std::string& label, LLPieMenu* branch) : LLMenuItemGL( name, label, KEY_NONE, MASK_NONE ), mBranch( branch ) @@ -3011,7 +3015,7 @@ void LLPieMenuBranch::buildDrawLabel( void ) } mDrawAccelLabel.clear(); - LLString st = mDrawAccelLabel; + std::string st = mDrawAccelLabel; appendAcceleratorString( st ); mDrawAccelLabel = st; @@ -3037,7 +3041,7 @@ void LLPieMenuBranch::doIt( void ) // class LLPieMenu // A circular menu of items, icons, etc. //----------------------------------------------------------------------------- -LLPieMenu::LLPieMenu(const LLString& name, const LLString& label) +LLPieMenu::LLPieMenu(const std::string& name, const std::string& label) : LLMenuGL(name, label), mFirstMouseDown(FALSE), mUseInfiniteRadius(FALSE), @@ -3052,7 +3056,7 @@ LLPieMenu::LLPieMenu(const LLString& name, const LLString& label) setCanTearOff(FALSE); } -LLPieMenu::LLPieMenu(const LLString& name) +LLPieMenu::LLPieMenu(const std::string& name) : LLMenuGL(name, name), mFirstMouseDown(FALSE), mUseInfiniteRadius(FALSE), @@ -3076,9 +3080,9 @@ void LLPieMenu::initXML(LLXMLNodePtr node, LLView *context, LLUICtrlFactory *fac if (child->hasName(LL_PIE_MENU_TAG)) { // SUBMENU - LLString name("menu"); + std::string name("menu"); child->getAttributeString("name", name); - LLString label(name); + std::string label(name); child->getAttributeString("label", label); LLPieMenu *submenu = new LLPieMenu(name, label); @@ -3456,7 +3460,7 @@ BOOL LLPieMenu::append(LLMenuItemGL *item) } // virtual -BOOL LLPieMenu::appendSeparator(const LLString &separator_name) +BOOL LLPieMenu::appendSeparator(const std::string &separator_name) { LLMenuItemGL* separator = new LLMenuItemBlankGL(); separator->setFont( LLFontGL::sSansSerifSmall ); @@ -3737,7 +3741,7 @@ void LLPieMenu::hide(BOOL item_selected) static LLRegisterWidget<LLMenuBarGL> r2("menu_bar"); // Default constructor -LLMenuBarGL::LLMenuBarGL( const LLString& name ) : LLMenuGL ( name, name ) +LLMenuBarGL::LLMenuBarGL( const std::string& name ) : LLMenuGL ( name, name ) { mHorizontalLayout = TRUE; setCanTearOff(FALSE); @@ -3782,7 +3786,7 @@ LLXMLNodePtr LLMenuBarGL::getXML(bool save_children) const LLView* LLMenuBarGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("menu"); + std::string name("menu"); node->getAttributeString("name", name); BOOL opaque = FALSE; @@ -4039,7 +4043,7 @@ S32 LLMenuBarGL::getRightmostMenuEdge() } // add a vertical separator to this menu -BOOL LLMenuBarGL::appendSeparator( const LLString &separator_name ) +BOOL LLMenuBarGL::appendSeparator( const std::string &separator_name ) { LLMenuItemGL* separator = new LLMenuItemVerticalSeparatorGL(); return append( separator ); @@ -4138,14 +4142,14 @@ BOOL LLMenuBarGL::handleHover( S32 x, S32 y, MASK mask ) /// Class LLMenuHolderGL ///============================================================================ LLMenuHolderGL::LLMenuHolderGL() -: LLPanel("Menu Holder") + : LLPanel(std::string("Menu Holder")) { setMouseOpaque(FALSE); sItemActivationTimer.stop(); mCanHide = TRUE; } -LLMenuHolderGL::LLMenuHolderGL(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows) +LLMenuHolderGL::LLMenuHolderGL(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows) : LLPanel(name, rect, FALSE) { setMouseOpaque(mouse_opaque); diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 16ab61c607..0125f954e5 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -67,7 +67,7 @@ typedef BOOL (*check_callback)(void*); // This callback is potentially used by LLMenuItemCallGL. If provided, // this function is called whenever it's time to determine the label's // contents. Put the contents of the label in the provided parameter. -typedef void (*label_callback)(LLString&,void*); +typedef void (*label_callback)(std::string&,void*); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemGL @@ -88,13 +88,13 @@ public: static void setHighlightFGColor( const LLColor4& color ) { sHighlightForeground = color; } static const LLColor4& getHighlightFGColor() { return sHighlightForeground; } - LLMenuItemGL( const LLString& name, const LLString& label, KEY key = KEY_NONE, MASK = MASK_NONE ); + LLMenuItemGL( const std::string& name, const std::string& label, KEY key = KEY_NONE, MASK = MASK_NONE ); virtual void setValue(const LLSD& value) { setLabel(value.asString()); } virtual LLXMLNodePtr getXML(bool save_children = true) const; - virtual LLString getType() const { return "item"; } + virtual std::string getType() const { return "item"; } virtual BOOL handleHover(S32 x, S32 y, MASK mask); @@ -122,8 +122,8 @@ public: // change the label void setLabel( const LLStringExplicit& label ) { mLabel = label; } - LLString getLabel( void ) const { return mLabel.getString(); } - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + std::string getLabel( void ) const { return mLabel.getString(); } + virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); // Get the parent menu for this item virtual class LLMenuGL* getMenu(); @@ -177,7 +177,7 @@ protected: // This function appends the character string representation of // the current accelerator key and mask to the provided string. - void appendAcceleratorString( LLString& st ) const; + void appendAcceleratorString( std::string& st ) const; KEY mAcceleratorKey; MASK mAcceleratorMask; @@ -226,15 +226,15 @@ class LLMenuItemCallGL : public LLMenuItemGL, public LLObservable { public: // normal constructor - LLMenuItemCallGL( const LLString& name, + LLMenuItemCallGL( const std::string& name, menu_callback clicked_cb, enabled_callback enabled_cb = NULL, void* user_data = NULL, KEY key = KEY_NONE, MASK mask = MASK_NONE, BOOL enabled = TRUE, on_disabled_callback on_disabled_cb = NULL); - LLMenuItemCallGL( const LLString& name, - const LLString& label, + LLMenuItemCallGL( const std::string& name, + const std::string& label, menu_callback clicked_cb, enabled_callback enabled_cb = NULL, void* user_data = NULL, @@ -243,8 +243,8 @@ public: on_disabled_callback on_disabled_cb = NULL); // constructor for when you want to trap the arrange method. - LLMenuItemCallGL( const LLString& name, - const LLString& label, + LLMenuItemCallGL( const std::string& name, + const std::string& label, menu_callback clicked_cb, enabled_callback enabled_cb, label_callback label_cb, @@ -252,7 +252,7 @@ public: KEY key = KEY_NONE, MASK mask = MASK_NONE, BOOL enabled = TRUE, on_disabled_callback on_disabled_c = NULL); - LLMenuItemCallGL( const LLString& name, + LLMenuItemCallGL( const std::string& name, menu_callback clicked_cb, enabled_callback enabled_cb, label_callback label_cb, @@ -262,11 +262,11 @@ public: on_disabled_callback on_disabled_c = NULL); virtual LLXMLNodePtr getXML(bool save_children = true) const; - virtual LLString getType() const { return "call"; } + virtual std::string getType() const { return "call"; } - void setEnabledControl(LLString enabled_control, LLView *context); - void setVisibleControl(LLString enabled_control, LLView *context); + void setEnabledControl(std::string enabled_control, LLView *context); + void setVisibleControl(std::string enabled_control, LLView *context); void setMenuCallback(menu_callback callback, void* data) { mCallback = callback; mUserData = data; }; menu_callback getMenuCallback() const { return mCallback; } @@ -310,34 +310,34 @@ class LLMenuItemCheckGL : public LLMenuItemCallGL { public: - LLMenuItemCheckGL( const LLString& name, - const LLString& label, + LLMenuItemCheckGL( const std::string& name, + const std::string& label, menu_callback callback, enabled_callback enabled_cb, check_callback check, void* user_data, KEY key = KEY_NONE, MASK mask = MASK_NONE ); - LLMenuItemCheckGL( const LLString& name, + LLMenuItemCheckGL( const std::string& name, menu_callback callback, enabled_callback enabled_cb, check_callback check, void* user_data, KEY key = KEY_NONE, MASK mask = MASK_NONE ); - LLMenuItemCheckGL( const LLString& name, - const LLString& label, + LLMenuItemCheckGL( const std::string& name, + const std::string& label, menu_callback callback, enabled_callback enabled_cb, - LLString control_name, + std::string control_name, LLView *context, void* user_data, KEY key = KEY_NONE, MASK mask = MASK_NONE ); virtual LLXMLNodePtr getXML(bool save_children = true) const; - void setCheckedControl(LLString checked_control, LLView *context); + void setCheckedControl(std::string checked_control, LLView *context); virtual void setValue(const LLSD& value); - virtual LLString getType() const { return "check"; } + virtual std::string getType() const { return "check"; } // called to rebuild the draw label virtual void buildDrawLabel( void ); @@ -358,15 +358,15 @@ private: class LLMenuItemToggleGL : public LLMenuItemGL { public: - LLMenuItemToggleGL( const LLString& name, const LLString& label, + LLMenuItemToggleGL( const std::string& name, const std::string& label, BOOL* toggle, KEY key = KEY_NONE, MASK mask = MASK_NONE ); - LLMenuItemToggleGL( const LLString& name, + LLMenuItemToggleGL( const std::string& name, BOOL* toggle, KEY key = KEY_NONE, MASK mask = MASK_NONE ); - virtual LLString getType() const { return "toggle"; } + virtual std::string getType() const { return "toggle"; } // called to rebuild the draw label virtual void buildDrawLabel( void ); @@ -401,8 +401,8 @@ class LLMenuGL // let branching menu items use my protected traversal methods friend class LLMenuItemBranchGL; public: - LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater = LLHandle<LLFloater>()); - LLMenuGL( const LLString& label, LLHandle<LLFloater> parent_floater = LLHandle<LLFloater>() ); + LLMenuGL( const std::string& name, const std::string& label, LLHandle<LLFloater> parent_floater = LLHandle<LLFloater>()); + LLMenuGL( const std::string& label, LLHandle<LLFloater> parent_floater = LLHandle<LLFloater>() ); virtual ~LLMenuGL( void ); virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); @@ -419,12 +419,12 @@ public: virtual BOOL handleAcceleratorKey(KEY key, MASK mask); - LLMenuGL* getChildMenuByName(const LLString& name, BOOL recurse) const; + LLMenuGL* getChildMenuByName(const std::string& name, BOOL recurse) const; BOOL clearHoverItem(); // return the name label - const LLString& getLabel( void ) const { return mLabel.getString(); } + const std::string& getLabel( void ) const { return mLabel.getString(); } void setLabel(const LLStringExplicit& label) { mLabel = label; } // background colors @@ -438,7 +438,7 @@ public: virtual BOOL append( LLMenuItemGL* item ); // add a separator to this menu - virtual BOOL appendSeparator( const LLString &separator_name = "separator" ); + virtual BOOL appendSeparator( const std::string &separator_name = LLStringUtil::null ); // add a menu - this will create a cascading menu virtual BOOL appendMenu( LLMenuGL* menu ); @@ -449,12 +449,12 @@ public: // setItemEnabled() - pass the name and the enable flag for a // menu item. TRUE will make sure it's enabled, FALSE will disable // it. - void setItemEnabled( const LLString& name, BOOL enable ); + void setItemEnabled( const std::string& name, BOOL enable ); // propagate message to submenus void setEnabledSubMenus(BOOL enable); - void setItemVisible( const LLString& name, BOOL visible); + void setItemVisible( const std::string& name, BOOL visible); // sets the left,bottom corner of menu, useful for popups void setLeftAndBottom(S32 left, S32 bottom); @@ -561,11 +561,11 @@ private: class LLMenuItemBranchGL : public LLMenuItemGL { public: - LLMenuItemBranchGL( const LLString& name, const LLString& label, LLMenuGL* branch, + LLMenuItemBranchGL( const std::string& name, const std::string& label, LLMenuGL* branch, KEY key = KEY_NONE, MASK mask = MASK_NONE ); virtual LLXMLNodePtr getXML(bool save_children = true) const; - virtual LLString getType() const { return "menu"; } + virtual std::string getType() const { return "menu"; } virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -606,7 +606,7 @@ public: virtual void openMenu(); - virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; + virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; private: LLMenuGL* mBranch; @@ -623,8 +623,8 @@ class LLPieMenu : public LLMenuGL { public: - LLPieMenu(const LLString& name, const LLString& label); - LLPieMenu(const LLString& name); + LLPieMenu(const std::string& name, const std::string& label); + LLPieMenu(const std::string& name); virtual ~LLPieMenu() {} void initXML(LLXMLNodePtr node, LLView *context, LLUICtrlFactory *factory); @@ -642,7 +642,7 @@ public: virtual void drawBackground(LLMenuItemGL* itemp, LLColor4& color); virtual BOOL append(LLMenuItemGL* item); - virtual BOOL appendSeparator( const LLString &separator_name = "separator" ); + virtual BOOL appendSeparator( const std::string &separator_name = LLStringUtil::null ); BOOL appendPieMenu(LLPieMenu *menu); @@ -682,7 +682,7 @@ private: class LLMenuBarGL : public LLMenuGL { public: - LLMenuBarGL( const LLString& name ); + LLMenuBarGL( const std::string& name ); virtual ~LLMenuBarGL(); virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); @@ -700,7 +700,7 @@ public: virtual BOOL jumpKeysActive(); // add a vertical separator to this menu - virtual BOOL appendSeparator( const LLString &separator_name = "separator" ); + virtual BOOL appendSeparator( const std::string &separator_name = LLStringUtil::null ); // add a menu - this will create a drop down menu. virtual BOOL appendMenu( LLMenuGL* menu ); @@ -729,7 +729,7 @@ class LLMenuHolderGL : public LLPanel { public: LLMenuHolderGL(); - LLMenuHolderGL(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows = FOLLOWS_NONE); + LLMenuHolderGL(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows = FOLLOWS_NONE); virtual ~LLMenuHolderGL() {} virtual BOOL hideMenus(); @@ -791,7 +791,7 @@ class LLMenuItemTearOffGL : public LLMenuItemGL public: LLMenuItemTearOffGL( LLHandle<LLFloater> parent_floater_handle = LLHandle<LLFloater>()); - virtual LLString getType() const { return "tearoff_menu"; } + virtual std::string getType() const { return "tearoff_menu"; } virtual void doIt(void); virtual void draw(void); diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp index 878c57b8b3..03dccdaf1f 100644 --- a/indra/llui/llmodaldialog.cpp +++ b/indra/llui/llmodaldialog.cpp @@ -43,8 +43,8 @@ // static std::list<LLModalDialog*> LLModalDialog::sModalStack; -LLModalDialog::LLModalDialog( const LLString& title, S32 width, S32 height, BOOL modal ) - : LLFloater( "modal container", +LLModalDialog::LLModalDialog( const std::string& title, S32 width, S32 height, BOOL modal ) + : LLFloater( std::string("modal container"), LLRect( 0, height, width, 0 ), title, FALSE, // resizable diff --git a/indra/llui/llmodaldialog.h b/indra/llui/llmodaldialog.h index 887239b18d..bb32950522 100644 --- a/indra/llui/llmodaldialog.h +++ b/indra/llui/llmodaldialog.h @@ -44,7 +44,7 @@ class LLModalDialog; class LLModalDialog : public LLFloater { public: - LLModalDialog( const LLString& title, S32 width, S32 height, BOOL modal = true ); + LLModalDialog( const std::string& title, S32 width, S32 height, BOOL modal = true ); /*virtual*/ ~LLModalDialog(); /*virtual*/ void open(); /* Flawfinder: ignore */ diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index c5c0e1c8b1..1663312c6f 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -54,7 +54,7 @@ const S32 EXTRA_TRIANGLE_HEIGHT = -2; S32 LLMultiSlider::mNameCounter = 0; LLMultiSlider::LLMultiSlider( - const LLString& name, + const std::string& name, const LLRect& rect, void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata), void* callback_userdata, @@ -66,7 +66,7 @@ LLMultiSlider::LLMultiSlider( BOOL allow_overlap, BOOL draw_track, BOOL use_triangle, - const LLString& control_name) + const std::string& control_name) : LLUICtrl( name, rect, TRUE, on_commit_callback, callback_userdata, FOLLOWS_LEFT | FOLLOWS_TOP), @@ -91,7 +91,7 @@ LLMultiSlider::LLMultiSlider( mMouseUpCallback( NULL ) { mValue.emptyMap(); - mCurSlider = LLString::null; + mCurSlider = LLStringUtil::null; // properly handle setting the starting thumb rect // do it this way to handle both the operating-on-settings @@ -100,7 +100,7 @@ LLMultiSlider::LLMultiSlider( setValue(getValue()); } -void LLMultiSlider::setSliderValue(const LLString& name, F32 value, BOOL from_event) +void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from_event) { // exit if not there if(!mValue.has(name)) { @@ -174,30 +174,30 @@ void LLMultiSlider::setValue(const LLSD& value) } } -F32 LLMultiSlider::getSliderValue(const LLString& name) const +F32 LLMultiSlider::getSliderValue(const std::string& name) const { return (F32)mValue[name].asReal(); } -void LLMultiSlider::setCurSlider(const LLString& name) +void LLMultiSlider::setCurSlider(const std::string& name) { if(mValue.has(name)) { mCurSlider = name; } } -const LLString& LLMultiSlider::addSlider() +const std::string& LLMultiSlider::addSlider() { return addSlider(mInitialValue); } -const LLString& LLMultiSlider::addSlider(F32 val) +const std::string& LLMultiSlider::addSlider(F32 val) { std::stringstream newName; F32 initVal = val; if(mValue.size() >= mMaxNumSliders) { - return LLString::null; + return LLStringUtil::null; } // create a new name @@ -206,7 +206,7 @@ const LLString& LLMultiSlider::addSlider(F32 val) bool foundOne = findUnusedValue(initVal); if(!foundOne) { - return LLString::null; + return LLStringUtil::null; } // add a new thumb rect @@ -269,7 +269,7 @@ bool LLMultiSlider::findUnusedValue(F32& initVal) } -void LLMultiSlider::deleteSlider(const LLString& name) +void LLMultiSlider::deleteSlider(const std::string& name) { // can't delete last slider if(mValue.size() <= 0) { @@ -282,7 +282,7 @@ void LLMultiSlider::deleteSlider(const LLString& name) // set to the last created if(mValue.size() > 0) { - std::map<LLString, LLRect>::iterator mIt = mThumbRects.end(); + std::map<std::string, LLRect>::iterator mIt = mThumbRects.end(); mIt--; mCurSlider = mIt->first; } @@ -365,7 +365,7 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask) else { // scroll through thumbs to see if we have a new one selected and select that one - std::map<LLString, LLRect>::iterator mIt = mThumbRects.begin(); + std::map<std::string, LLRect>::iterator mIt = mThumbRects.begin(); for(; mIt != mThumbRects.end(); mIt++) { // check if inside. If so, set current slider and continue @@ -425,8 +425,8 @@ void LLMultiSlider::draw() { LLColor4 curThumbColor; - std::map<LLString, LLRect>::iterator mIt; - std::map<LLString, LLRect>::iterator curSldrIt; + std::map<std::string, LLRect>::iterator mIt; + std::map<std::string, LLRect>::iterator curSldrIt; // Draw background and thumb. @@ -582,7 +582,7 @@ LLXMLNodePtr LLMultiSlider::getXML(bool save_children) const //static LLView* LLMultiSlider::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("multi_slider_bar"); + std::string name("multi_slider_bar"); node->getAttributeString("name", name); LLRect rect; diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index 1eb7764c3c..7e0e483e61 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -41,7 +41,7 @@ class LLMultiSlider : public LLUICtrl { public: LLMultiSlider( - const LLString& name, + const std::string& name, const LLRect& rect, void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata), void* callback_userdata, @@ -53,17 +53,17 @@ public: BOOL allow_overlap, BOOL draw_track, BOOL use_triangle, - const LLString& control_name = LLString::null ); + const std::string& control_name = LLStringUtil::null ); virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); - void setSliderValue(const LLString& name, F32 value, BOOL from_event = FALSE); - F32 getSliderValue(const LLString& name) const; + void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE); + F32 getSliderValue(const std::string& name) const; - const LLString& getCurSlider() const { return mCurSlider; } + const std::string& getCurSlider() const { return mCurSlider; } F32 getCurSliderValue() const { return getSliderValue(mCurSlider); } - void setCurSlider(const LLString& name); + void setCurSlider(const std::string& name); void setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mCurSlider, val, from_event); } virtual void setValue(const LLSD& value); @@ -83,9 +83,9 @@ public: void setMouseUpCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseUpCallback = cb; } bool findUnusedValue(F32& initVal); - const LLString& addSlider(); - const LLString& addSlider(F32 val); - void deleteSlider(const LLString& name); + const std::string& addSlider(); + const std::string& addSlider(F32 val); + void deleteSlider(const std::string& name); void deleteCurSlider() { deleteSlider(mCurSlider); } void clear(); @@ -101,7 +101,7 @@ protected: F32 mMinValue; F32 mMaxValue; F32 mIncrement; - LLString mCurSlider; + std::string mCurSlider; static S32 mNameCounter; S32 mMaxNumSliders; @@ -112,7 +112,7 @@ protected: S32 mMouseOffset; LLRect mDragStartThumbRect; - std::map<LLString, LLRect> mThumbRects; + std::map<std::string, LLRect> mThumbRects; LLColor4 mTrackColor; LLColor4 mThumbOutlineColor; LLColor4 mThumbCenterColor; diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp index e2b1e410fa..f6ad18f4b6 100644 --- a/indra/llui/llmultisliderctrl.cpp +++ b/indra/llui/llmultisliderctrl.cpp @@ -55,8 +55,8 @@ static LLRegisterWidget<LLMultiSliderCtrl> r("multi_slider"); const U32 MAX_STRING_LENGTH = 10; -LLMultiSliderCtrl::LLMultiSliderCtrl(const LLString& name, const LLRect& rect, - const LLString& label, +LLMultiSliderCtrl::LLMultiSliderCtrl(const std::string& name, const LLRect& rect, + const std::string& label, const LLFontGL* font, S32 label_width, S32 text_left, @@ -68,7 +68,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLString& name, const LLRect& rect, S32 max_sliders, BOOL allow_overlap, BOOL draw_track, BOOL use_triangle, - const LLString& control_which) + const std::string& control_which) : LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data ), mFont(font), mShowText( show_text ), @@ -96,7 +96,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLString& name, const LLRect& rect, label_width = font->getWidth(label); } LLRect label_rect( left, top, label_width, bottom ); - mLabelBox = new LLTextBox( "MultiSliderCtrl Label", label_rect, label.c_str(), font ); + mLabelBox = new LLTextBox( std::string("MultiSliderCtrl Label"), label_rect, label, font ); addChild(mLabelBox); } @@ -109,7 +109,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLString& name, const LLRect& rect, S32 slider_left = label_width ? label_width + MULTI_SLIDERCTRL_SPACING : 0; LLRect slider_rect( slider_left, top, slider_right, bottom ); mMultiSlider = new LLMultiSlider( - "multi_slider", + std::string("multi_slider"), slider_rect, LLMultiSliderCtrl::onSliderCommit, this, initial_value, min_value, max_value, increment, @@ -124,8 +124,8 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLString& name, const LLRect& rect, LLRect text_rect( text_left, top, getRect().getWidth(), bottom ); if( can_edit_text ) { - mEditor = new LLLineEditor( "MultiSliderCtrl Editor", text_rect, - "", font, + mEditor = new LLLineEditor( std::string("MultiSliderCtrl Editor"), text_rect, + LLStringUtil::null, font, MAX_STRING_LENGTH, &LLMultiSliderCtrl::onEditorCommit, NULL, NULL, this, &LLLineEditor::prevalidateFloat ); @@ -140,7 +140,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLString& name, const LLRect& rect, } else { - mTextBox = new LLTextBox( "MultiSliderCtrl Text", text_rect, "", font); + mTextBox = new LLTextBox( std::string("MultiSliderCtrl Text"), text_rect, LLStringUtil::null, font); mTextBox->setFollowsLeft(); mTextBox->setFollowsBottom(); addChild(mTextBox); @@ -172,20 +172,20 @@ void LLMultiSliderCtrl::setValue(const LLSD& value) updateText(); } -void LLMultiSliderCtrl::setSliderValue(const LLString& name, F32 v, BOOL from_event) +void LLMultiSliderCtrl::setSliderValue(const std::string& name, F32 v, BOOL from_event) { mMultiSlider->setSliderValue(name, v, from_event ); mCurValue = mMultiSlider->getCurSliderValue(); updateText(); } -void LLMultiSliderCtrl::setCurSlider(const LLString& name) +void LLMultiSliderCtrl::setCurSlider(const std::string& name) { mMultiSlider->setCurSlider(name); mCurValue = mMultiSlider->getCurSliderValue(); } -BOOL LLMultiSliderCtrl::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLMultiSliderCtrl::setLabelArg( const std::string& key, const LLStringExplicit& text ) { BOOL res = FALSE; if (mLabelBox) @@ -210,13 +210,13 @@ BOOL LLMultiSliderCtrl::setLabelArg( const LLString& key, const LLStringExplicit return res; } -const LLString& LLMultiSliderCtrl::addSlider() +const std::string& LLMultiSliderCtrl::addSlider() { - const LLString& name = mMultiSlider->addSlider(); + const std::string& name = mMultiSlider->addSlider(); // if it returns null, pass it on - if(name == LLString::null) { - return LLString::null; + if(name == LLStringUtil::null) { + return LLStringUtil::null; } // otherwise, update stuff @@ -225,13 +225,13 @@ const LLString& LLMultiSliderCtrl::addSlider() return name; } -const LLString& LLMultiSliderCtrl::addSlider(F32 val) +const std::string& LLMultiSliderCtrl::addSlider(F32 val) { - const LLString& name = mMultiSlider->addSlider(val); + const std::string& name = mMultiSlider->addSlider(val); // if it returns null, pass it on - if(name == LLString::null) { - return LLString::null; + if(name == LLStringUtil::null) { + return LLStringUtil::null; } // otherwise, update stuff @@ -240,7 +240,7 @@ const LLString& LLMultiSliderCtrl::addSlider(F32 val) return name; } -void LLMultiSliderCtrl::deleteSlider(const LLString& name) +void LLMultiSliderCtrl::deleteSlider(const std::string& name) { mMultiSlider->deleteSlider(name); mCurValue = mMultiSlider->getCurSliderValue(); @@ -253,11 +253,11 @@ void LLMultiSliderCtrl::clear() setCurSliderValue(0.0f); if( mEditor ) { - mEditor->setText(LLString("")); + mEditor->setText(std::string("")); } if( mTextBox ) { - mTextBox->setText(LLString("")); + mTextBox->setText(std::string("")); } // get rid of sliders @@ -279,8 +279,8 @@ void LLMultiSliderCtrl::updateText() // Don't display very small negative values as -0.000 F32 displayed_value = (F32)(floor(getCurSliderValue() * pow(10.0, (F64)mPrecision) + 0.5) / pow(10.0, (F64)mPrecision)); - LLString format = llformat("%%.%df", mPrecision); - LLString text = llformat(format.c_str(), displayed_value); + std::string format = llformat("%%.%df", mPrecision); + std::string text = llformat(format.c_str(), displayed_value); if( mEditor ) { mEditor->setText( text ); @@ -302,7 +302,7 @@ void LLMultiSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata ) F32 val = self->mCurValue; F32 saved_val = self->mCurValue; - LLString text = self->mEditor->getText(); + std::string text = self->mEditor->getText(); if( LLLineEditor::postvalidateFloat( text ) ) { LLLocale locale(LLLocale::USER_LOCALE); @@ -484,13 +484,13 @@ void LLMultiSliderCtrl::reportInvalidData() } //virtual -LLString LLMultiSliderCtrl::getControlName() const +std::string LLMultiSliderCtrl::getControlName() const { return mMultiSlider->getControlName(); } // virtual -void LLMultiSliderCtrl::setControlName(const LLString& control_name, LLView* context) +void LLMultiSliderCtrl::setControlName(const std::string& control_name, LLView* context) { mMultiSlider->setControlName(control_name, context); } @@ -529,10 +529,10 @@ LLXMLNodePtr LLMultiSliderCtrl::getXML(bool save_children) const LLView* LLMultiSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("multi_slider"); + std::string name("multi_slider"); node->getAttributeString("name", name); - LLString label; + std::string label; node->getAttributeString("label", label); LLRect rect; @@ -588,13 +588,13 @@ LLView* LLMultiSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFa { // calculate the size of the text box (log max_value is number of digits - 1 so plus 1) if ( max_value ) - text_left = font->getWidth("0") * ( static_cast < S32 > ( log10 ( max_value ) ) + precision + 1 ); + text_left = font->getWidth(std::string("0")) * ( static_cast < S32 > ( log10 ( max_value ) ) + precision + 1 ); if ( increment < 1.0f ) - text_left += font->getWidth("."); // (mostly) take account of decimal point in value + text_left += font->getWidth(std::string(".")); // (mostly) take account of decimal point in value if ( min_value < 0.0f || max_value < 0.0f ) - text_left += font->getWidth("-"); // (mostly) take account of minus sign + text_left += font->getWidth(std::string("-")); // (mostly) take account of minus sign // padding to make things look nicer text_left += 8; diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h index bbc3955f58..fc82a5501b 100644 --- a/indra/llui/llmultisliderctrl.h +++ b/indra/llui/llmultisliderctrl.h @@ -55,9 +55,9 @@ class LLSlider; class LLMultiSliderCtrl : public LLUICtrl { public: - LLMultiSliderCtrl(const LLString& name, + LLMultiSliderCtrl(const std::string& name, const LLRect& rect, - const LLString& label, + const std::string& label, const LLFontGL* font, S32 slider_left, S32 text_left, @@ -68,22 +68,22 @@ public: F32 initial_value, F32 min_value, F32 max_value, F32 increment, S32 max_sliders, BOOL allow_overlap, BOOL draw_track, BOOL use_triangle, - const LLString& control_which = LLString::null ); + const std::string& control_which = LLStringUtil::null ); virtual ~LLMultiSliderCtrl(); virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); - F32 getSliderValue(const LLString& name) const; - void setSliderValue(const LLString& name, F32 v, BOOL from_event = FALSE); + F32 getSliderValue(const std::string& name) const; + void setSliderValue(const std::string& name, F32 v, BOOL from_event = FALSE); virtual void setValue(const LLSD& value ); virtual LLSD getValue() const { return mMultiSlider->getValue(); } - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); - const LLString& getCurSlider() const { return mMultiSlider->getCurSlider(); } + const std::string& getCurSlider() const { return mMultiSlider->getCurSlider(); } F32 getCurSliderValue() const { return mCurValue; } - void setCurSlider(const LLString& name); + void setCurSlider(const std::string& name); void setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mMultiSlider->getCurSlider(), val, from_event); } virtual void setMinValue(LLSD min_value) { setMinValue((F32)min_value.asReal()); } @@ -99,15 +99,15 @@ public: void setIncrement(F32 increment) {mMultiSlider->setIncrement(increment);} /// for adding and deleting sliders - const LLString& addSlider(); - const LLString& addSlider(F32 val); - void deleteSlider(const LLString& name); + const std::string& addSlider(); + const std::string& addSlider(F32 val); + void deleteSlider(const std::string& name); void deleteCurSlider() { deleteSlider(mMultiSlider->getCurSlider()); } F32 getMinValue() { return mMultiSlider->getMinValue(); } F32 getMaxValue() { return mMultiSlider->getMaxValue(); } - void setLabel(const LLString& label) { if (mLabelBox) mLabelBox->setText(label); } + void setLabel(const std::string& label) { if (mLabelBox) mLabelBox->setText(label); } void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; } void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; } @@ -119,8 +119,8 @@ public: virtual void setTentative(BOOL b); // marks value as tentative virtual void onCommit(); // mark not tentative, then commit - virtual void setControlName(const LLString& control_name, LLView* context); - virtual LLString getControlName() const; + virtual void setControlName(const std::string& control_name, LLView* context); + virtual std::string getControlName() const; static void onSliderCommit(LLUICtrl* caller, void* userdata); static void onSliderMouseDown(LLUICtrl* caller,void* userdata); diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index fb14470612..700558094b 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -86,10 +86,10 @@ LLPanel::LLPanel() : mRectControl() { init(); - setName("panel"); + setName(std::string("panel")); } -LLPanel::LLPanel(const LLString& name) +LLPanel::LLPanel(const std::string& name) : LLUICtrl(name, LLRect(0, 0, 0, 0), TRUE, NULL, NULL), mRectControl() { @@ -97,7 +97,7 @@ LLPanel::LLPanel(const LLString& name) } -LLPanel::LLPanel(const LLString& name, const LLRect& rect, BOOL bordered) +LLPanel::LLPanel(const std::string& name, const LLRect& rect, BOOL bordered) : LLUICtrl(name, rect, TRUE, NULL, NULL), mRectControl() { @@ -109,7 +109,7 @@ LLPanel::LLPanel(const LLString& name, const LLRect& rect, BOOL bordered) } -LLPanel::LLPanel(const LLString& name, const LLString& rect_control, BOOL bordered) +LLPanel::LLPanel(const std::string& name, const std::string& rect_control, BOOL bordered) : LLUICtrl(name, LLUI::sConfigGroup->getRect(rect_control), TRUE, NULL, NULL), mRectControl( rect_control ) { @@ -141,7 +141,7 @@ void LLPanel::addBorder(LLViewBorder::EBevel border_bevel, LLViewBorder::EStyle border_style, S32 border_thickness) { removeBorder(); - mBorder = new LLViewBorder( "panel border", + mBorder = new LLViewBorder( std::string("panel border"), LLRect(0, getRect().getHeight(), getRect().getWidth(), 0), border_bevel, border_style, border_thickness ); mBorder->setSaveToXML(false); @@ -246,7 +246,7 @@ void LLPanel::setDefaultBtn(LLButton* btn) } } -void LLPanel::setDefaultBtn(const LLString& id) +void LLPanel::setDefaultBtn(const std::string& id) { LLButton *button = getChild<LLButton>(id); if (button) @@ -344,14 +344,14 @@ BOOL LLPanel::checkRequirements() { if (!mRequirementsError.empty()) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[COMPONENTS]"] = mRequirementsError; args["[FLOATER]"] = getName(); llwarns << getName() << " failed requirements check on: \n" << mRequirementsError << llendl; - alertXml("FailedRequirementsCheck", args); + alertXml(std::string("FailedRequirementsCheck"), args); mRequirementsError.clear(); return FALSE; } @@ -360,7 +360,7 @@ BOOL LLPanel::checkRequirements() } //static -void LLPanel::alertXml(LLString label, LLString::format_map_t args) +void LLPanel::alertXml(const std::string& label, LLStringUtil::format_map_t args) { sAlertQueue.push(LLAlertInfo(label,args)); } @@ -460,7 +460,7 @@ LLXMLNodePtr LLPanel::getXML(bool save_children) const LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory *factory) { - LLString name("panel"); + std::string name("panel"); node->getAttributeString("name", name); LLPanel* panelp = factory->createFactoryPanel(name); @@ -489,7 +489,7 @@ LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory *fac BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name = getName(); + std::string name = getName(); node->getAttributeString("name", name); setName(name); @@ -497,7 +497,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f initChildrenXML(node, factory); - LLString xml_filename; + std::string xml_filename; node->getAttributeString("filename", xml_filename); BOOL didPost; @@ -536,7 +536,7 @@ void LLPanel::initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory) // look for string declarations for programmatic text if (child->hasName("string")) { - LLString string_name; + std::string string_name; child->getAttributeString("name", string_name); if (!string_name.empty()) { @@ -564,9 +564,9 @@ void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parent) LLViewBorder::getBevelFromAttribute(node, bevel_style); LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE; - LLString border_string; + std::string border_string; node->getAttributeString("border_style", border_string); - LLString::toLower(border_string); + LLStringUtil::toLower(border_string); if (border_string == "texture") { @@ -601,12 +601,12 @@ void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parent) LLUICtrlFactory::getAttributeColor(node,"bg_alpha_color", color); setTransparentColor(color); - LLString label = getLabel(); + std::string label = getLabel(); node->getAttributeString("label", label); setLabel(label); } -LLString LLPanel::getString(const LLString& name, const LLString::format_map_t& args) const +std::string LLPanel::getString(const std::string& name, const LLStringUtil::format_map_t& args) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) @@ -616,7 +616,7 @@ LLString LLPanel::getString(const LLString& name, const LLString::format_map_t& formatted_string.setArgList(args); return formatted_string.getString(); } - LLString err_str("Failed to find string " + name + " in panel " + getName()); + std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate // *TODO: once the QAR-369 ui-cleanup work on settings is in we need to change the following line to be //if(LLUI::sConfigGroup->getBOOL("QAMode")) if(LLUI::sQAMode) @@ -627,10 +627,10 @@ LLString LLPanel::getString(const LLString& name, const LLString::format_map_t& { llwarns << err_str << llendl; } - return LLString::null; + return LLStringUtil::null; } -LLUIString LLPanel::getUIString(const LLString& name) const +LLUIString LLPanel::getUIString(const std::string& name) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) @@ -638,11 +638,11 @@ LLUIString LLPanel::getUIString(const LLString& name) const return found_it->second; } llerrs << "Failed to find string " << name << " in panel " << getName() << llendl; - return LLUIString(LLString::null); + return LLUIString(LLStringUtil::null); } -void LLPanel::childSetVisible(const LLString& id, bool visible) +void LLPanel::childSetVisible(const std::string& id, bool visible) { LLView* child = getChild<LLView>(id); if (child) @@ -651,7 +651,7 @@ void LLPanel::childSetVisible(const LLString& id, bool visible) } } -bool LLPanel::childIsVisible(const LLString& id) const +bool LLPanel::childIsVisible(const std::string& id) const { LLView* child = getChild<LLView>(id); if (child) @@ -661,7 +661,7 @@ bool LLPanel::childIsVisible(const LLString& id) const return false; } -void LLPanel::childSetEnabled(const LLString& id, bool enabled) +void LLPanel::childSetEnabled(const std::string& id, bool enabled) { LLView* child = getChild<LLView>(id); if (child) @@ -670,7 +670,7 @@ void LLPanel::childSetEnabled(const LLString& id, bool enabled) } } -void LLPanel::childSetTentative(const LLString& id, bool tentative) +void LLPanel::childSetTentative(const std::string& id, bool tentative) { LLView* child = getChild<LLView>(id); if (child) @@ -679,7 +679,7 @@ void LLPanel::childSetTentative(const LLString& id, bool tentative) } } -bool LLPanel::childIsEnabled(const LLString& id) const +bool LLPanel::childIsEnabled(const std::string& id) const { LLView* child = getChild<LLView>(id); if (child) @@ -690,7 +690,7 @@ bool LLPanel::childIsEnabled(const LLString& id) const } -void LLPanel::childSetToolTip(const LLString& id, const LLString& msg) +void LLPanel::childSetToolTip(const std::string& id, const std::string& msg) { LLView* child = getChild<LLView>(id); if (child) @@ -699,7 +699,7 @@ void LLPanel::childSetToolTip(const LLString& id, const LLString& msg) } } -void LLPanel::childSetRect(const LLString& id, const LLRect& rect) +void LLPanel::childSetRect(const std::string& id, const LLRect& rect) { LLView* child = getChild<LLView>(id); if (child) @@ -708,7 +708,7 @@ void LLPanel::childSetRect(const LLString& id, const LLRect& rect) } } -bool LLPanel::childGetRect(const LLString& id, LLRect& rect) const +bool LLPanel::childGetRect(const std::string& id, LLRect& rect) const { LLView* child = getChild<LLView>(id); if (child) @@ -719,7 +719,7 @@ bool LLPanel::childGetRect(const LLString& id, LLRect& rect) const return false; } -void LLPanel::childSetFocus(const LLString& id, BOOL focus) +void LLPanel::childSetFocus(const std::string& id, BOOL focus) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -728,7 +728,7 @@ void LLPanel::childSetFocus(const LLString& id, BOOL focus) } } -BOOL LLPanel::childHasFocus(const LLString& id) +BOOL LLPanel::childHasFocus(const std::string& id) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -743,7 +743,7 @@ BOOL LLPanel::childHasFocus(const LLString& id) } -void LLPanel::childSetFocusChangedCallback(const LLString& id, void (*cb)(LLFocusableElement*, void*), void* user_data) +void LLPanel::childSetFocusChangedCallback(const std::string& id, void (*cb)(LLFocusableElement*, void*), void* user_data) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -752,7 +752,7 @@ void LLPanel::childSetFocusChangedCallback(const LLString& id, void (*cb)(LLFocu } } -void LLPanel::childSetCommitCallback(const LLString& id, void (*cb)(LLUICtrl*, void*), void *userdata ) +void LLPanel::childSetCommitCallback(const std::string& id, void (*cb)(LLUICtrl*, void*), void *userdata ) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -762,7 +762,7 @@ void LLPanel::childSetCommitCallback(const LLString& id, void (*cb)(LLUICtrl*, v } } -void LLPanel::childSetDoubleClickCallback(const LLString& id, void (*cb)(void*), void *userdata ) +void LLPanel::childSetDoubleClickCallback(const std::string& id, void (*cb)(void*), void *userdata ) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -775,7 +775,7 @@ void LLPanel::childSetDoubleClickCallback(const LLString& id, void (*cb)(void*), } } -void LLPanel::childSetValidate(const LLString& id, BOOL (*cb)(LLUICtrl*, void*)) +void LLPanel::childSetValidate(const std::string& id, BOOL (*cb)(LLUICtrl*, void*)) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -784,7 +784,7 @@ void LLPanel::childSetValidate(const LLString& id, BOOL (*cb)(LLUICtrl*, void*)) } } -void LLPanel::childSetUserData(const LLString& id, void* userdata) +void LLPanel::childSetUserData(const std::string& id, void* userdata) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -793,7 +793,7 @@ void LLPanel::childSetUserData(const LLString& id, void* userdata) } } -void LLPanel::childSetColor(const LLString& id, const LLColor4& color) +void LLPanel::childSetColor(const std::string& id, const LLColor4& color) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -802,7 +802,7 @@ void LLPanel::childSetColor(const LLString& id, const LLColor4& color) } } -LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const LLString& id) const +LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& id) const { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -812,7 +812,7 @@ LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const LLString& id return NULL; } -LLCtrlListInterface* LLPanel::childGetListInterface(const LLString& id) const +LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -822,7 +822,7 @@ LLCtrlListInterface* LLPanel::childGetListInterface(const LLString& id) const return NULL; } -LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const LLString& id) const +LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) const { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -832,7 +832,7 @@ LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const LLString& id) cons return NULL; } -void LLPanel::childSetValue(const LLString& id, LLSD value) +void LLPanel::childSetValue(const std::string& id, LLSD value) { LLView* child = getChild<LLView>(id, true); if (child) @@ -841,7 +841,7 @@ void LLPanel::childSetValue(const LLString& id, LLSD value) } } -LLSD LLPanel::childGetValue(const LLString& id) const +LLSD LLPanel::childGetValue(const std::string& id) const { LLView* child = getChild<LLView>(id, true); if (child) @@ -852,7 +852,7 @@ LLSD LLPanel::childGetValue(const LLString& id) const return LLSD(); } -BOOL LLPanel::childSetTextArg(const LLString& id, const LLString& key, const LLStringExplicit& text) +BOOL LLPanel::childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -862,7 +862,7 @@ BOOL LLPanel::childSetTextArg(const LLString& id, const LLString& key, const LLS return FALSE; } -BOOL LLPanel::childSetLabelArg(const LLString& id, const LLString& key, const LLStringExplicit& text) +BOOL LLPanel::childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text) { LLView* child = getChild<LLView>(id); if (child) @@ -872,7 +872,7 @@ BOOL LLPanel::childSetLabelArg(const LLString& id, const LLString& key, const LL return FALSE; } -BOOL LLPanel::childSetToolTipArg(const LLString& id, const LLString& key, const LLStringExplicit& text) +BOOL LLPanel::childSetToolTipArg(const std::string& id, const std::string& key, const LLStringExplicit& text) { LLView* child = getChildView(id, true, FALSE); if (child) @@ -882,7 +882,7 @@ BOOL LLPanel::childSetToolTipArg(const LLString& id, const LLString& key, const return FALSE; } -void LLPanel::childSetMinValue(const LLString& id, LLSD min_value) +void LLPanel::childSetMinValue(const std::string& id, LLSD min_value) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -891,7 +891,7 @@ void LLPanel::childSetMinValue(const LLString& id, LLSD min_value) } } -void LLPanel::childSetMaxValue(const LLString& id, LLSD max_value) +void LLPanel::childSetMaxValue(const std::string& id, LLSD max_value) { LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) @@ -900,7 +900,7 @@ void LLPanel::childSetMaxValue(const LLString& id, LLSD max_value) } } -void LLPanel::childShowTab(const LLString& id, const LLString& tabname, bool visible) +void LLPanel::childShowTab(const std::string& id, const std::string& tabname, bool visible) { LLTabContainer* child = getChild<LLTabContainer>(id); if (child) @@ -909,7 +909,7 @@ void LLPanel::childShowTab(const LLString& id, const LLString& tabname, bool vis } } -LLPanel *LLPanel::childGetVisibleTab(const LLString& id) const +LLPanel *LLPanel::childGetVisibleTab(const std::string& id) const { LLTabContainer* child = getChild<LLTabContainer>(id); if (child) @@ -919,7 +919,7 @@ LLPanel *LLPanel::childGetVisibleTab(const LLString& id) const return NULL; } -void LLPanel::childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata) +void LLPanel::childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata) { LLTabContainer* child = getChild<LLTabContainer>(id); if (child) @@ -933,7 +933,7 @@ void LLPanel::childSetTabChangeCallback(const LLString& id, const LLString& tabn } } -void LLPanel::childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data) +void LLPanel::childSetKeystrokeCallback(const std::string& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data) { LLLineEditor* child = getChild<LLLineEditor>(id); if (child) @@ -946,7 +946,7 @@ void LLPanel::childSetKeystrokeCallback(const LLString& id, void (*keystroke_cal } } -void LLPanel::childSetPrevalidate(const LLString& id, BOOL (*func)(const LLWString &) ) +void LLPanel::childSetPrevalidate(const std::string& id, BOOL (*func)(const LLWString &) ) { LLLineEditor* child = getChild<LLLineEditor>(id); if (child) @@ -955,7 +955,7 @@ void LLPanel::childSetPrevalidate(const LLString& id, BOOL (*func)(const LLWStri } } -void LLPanel::childSetWrappedText(const LLString& id, const LLString& text, bool visible) +void LLPanel::childSetWrappedText(const std::string& id, const std::string& text, bool visible) { LLTextBox* child = getChild<LLTextBox>(id); if (child) @@ -965,7 +965,7 @@ void LLPanel::childSetWrappedText(const LLString& id, const LLString& text, bool } } -void LLPanel::childSetAction(const LLString& id, void(*function)(void*), void* value) +void LLPanel::childSetAction(const std::string& id, void(*function)(void*), void* value) { LLButton* button = getChild<LLButton>(id); if (button) @@ -974,7 +974,7 @@ void LLPanel::childSetAction(const LLString& id, void(*function)(void*), void* v } } -void LLPanel::childSetActionTextbox(const LLString& id, void(*function)(void*)) +void LLPanel::childSetActionTextbox(const std::string& id, void(*function)(void*)) { LLTextBox* textbox = getChild<LLTextBox>(id); if (textbox) @@ -983,7 +983,7 @@ void LLPanel::childSetActionTextbox(const LLString& id, void(*function)(void*)) } } -void LLPanel::childSetControlName(const LLString& id, const LLString& control_name) +void LLPanel::childSetControlName(const std::string& id, const std::string& control_name) { LLView* view = getChild<LLView>(id); if (view) @@ -993,7 +993,7 @@ void LLPanel::childSetControlName(const LLString& id, const LLString& control_na } //virtual -LLView* LLPanel::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const +LLView* LLPanel::getChildView(const std::string& name, BOOL recurse, BOOL create_if_missing) const { // just get child, don't try to create a dummy one LLView* view = LLUICtrl::getChildView(name, recurse, FALSE); @@ -1008,7 +1008,7 @@ LLView* LLPanel::getChildView(const LLString& name, BOOL recurse, BOOL create_if return view; } -void LLPanel::childNotFound(const LLString& id) const +void LLPanel::childNotFound(const std::string& id) const { if (mExpectedMembers.find(id) == mExpectedMembers.end()) { @@ -1022,7 +1022,7 @@ void LLPanel::childDisplayNotFound() { return; } - LLString msg; + std::string msg; expected_members_list_t::iterator itor; for (itor=mNewExpectedMembers.begin(); itor!=mNewExpectedMembers.end(); ++itor) { @@ -1031,7 +1031,7 @@ void LLPanel::childDisplayNotFound() mExpectedMembers.insert(*itor); } mNewExpectedMembers.clear(); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[CONTROLS]"] = msg; LLAlertDialog::showXml("FloaterNotFound", args); } @@ -1071,7 +1071,7 @@ struct LLLayoutStack::LLEmbeddedPanel { min_dim = mMinWidth; } - mResizeBar = new LLResizeBar("resizer", mPanel, LLRect(), min_dim, S32_MAX, side); + mResizeBar = new LLResizeBar(std::string("resizer"), mPanel, LLRect(), min_dim, S32_MAX, side); mResizeBar->setEnableSnapping(FALSE); // panels initialized as hidden should not start out partially visible if (!mPanel->getVisible()) @@ -1166,7 +1166,7 @@ LLXMLNodePtr LLLayoutStack::getXML(bool save_children) const //static LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString orientation_string("vertical"); + std::string orientation_string("vertical"); node->getAttributeString("orientation", orientation_string); eLayoutOrientation orientation = VERTICAL; @@ -1190,7 +1190,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor // don't allow negative spacing values layout_stackp->mPanelSpacing = llmax(layout_stackp->mPanelSpacing, 0); - LLString name("stack"); + std::string name("stack"); node->getAttributeString("name", name); layout_stackp->setName(name); @@ -1223,7 +1223,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor BOOL user_resize = FALSE; child->getAttributeBOOL("user_resize", user_resize); - LLPanel* panelp = new LLPanel("auto_panel"); + LLPanel* panelp = new LLPanel(std::string("auto_panel")); LLView* new_child = factory->createWidget(panelp, child); if (new_child) { diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 0485274055..1fe6a5679e 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -51,10 +51,10 @@ const BOOL BORDER_NO = FALSE; struct LLAlertInfo { - LLString mLabel; - LLString::format_map_t mArgs; + std::string mLabel; + LLStringUtil::format_map_t mArgs; - LLAlertInfo(LLString label, LLString::format_map_t args) : mLabel(label), mArgs(args) { } + LLAlertInfo(std::string label, LLStringUtil::format_map_t args) : mLabel(label), mArgs(args) { } LLAlertInfo(){} }; @@ -71,13 +71,13 @@ public: // minimal constructor for data-driven initialization LLPanel(); - LLPanel(const LLString& name); + LLPanel(const std::string& name); // Position and size not saved - LLPanel(const LLString& name, const LLRect& rect, BOOL bordered = TRUE); + LLPanel(const std::string& name, const LLRect& rect, BOOL bordered = TRUE); // Position and size are saved to rect_control - LLPanel(const LLString& name, const LLString& rect_control, BOOL bordered = TRUE); + LLPanel(const std::string& name, const std::string& rect_control, BOOL bordered = TRUE); /*virtual*/ ~LLPanel(); @@ -87,7 +87,7 @@ public: /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask ); /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; // Override to set not found list: - virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; + virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; // From LLFocusableElement /*virtual*/ void setFocus( BOOL b ); @@ -105,7 +105,7 @@ public: BOOL hasBorder() const { return mBorder != NULL; } void setBorderVisible( BOOL b ); - template <class T> void requires(LLString name) + template <class T> void requires(const std::string& name) { // check for widget with matching type and name if (LLView::getChild<T>(name) == NULL) @@ -115,7 +115,7 @@ public: } // requires LLView by default - void requires(LLString name) + void requires(const std::string& name) { requires<LLView>(name); } @@ -130,13 +130,13 @@ public: void setBackgroundOpaque(BOOL b) { mBgOpaque = b; } BOOL isBackgroundOpaque() const { return mBgOpaque; } void setDefaultBtn(LLButton* btn = NULL); - void setDefaultBtn(const LLString& id); + void setDefaultBtn(const std::string& id); void updateDefaultBtn(); void setLabel(const LLStringExplicit& label) { mLabel = label; } - LLString getLabel() const { return mLabel; } + std::string getLabel() const { return mLabel; } - void setRectControl(const LLString& rect_control) { mRectControl.assign(rect_control); } - const LLString& getRectControl() const { return mRectControl; } + void setRectControl(const std::string& rect_control) { mRectControl.assign(rect_control); } + const std::string& getRectControl() const { return mRectControl; } void storeRectControl(); void setCtrlsEnabled(BOOL b); @@ -151,83 +151,83 @@ public: void initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory); void setPanelParameters(LLXMLNodePtr node, LLView *parentp); - LLString getString(const LLString& name, const LLString::format_map_t& args = LLUIString::sNullArgs) const; - LLUIString getUIString(const LLString& name) const; + std::string getString(const std::string& name, const LLStringUtil::format_map_t& args = LLUIString::sNullArgs) const; + LLUIString getUIString(const std::string& name) const; // ** Wrappers for setting child properties by name ** -TomY // LLView - void childSetVisible(const LLString& name, bool visible); - void childShow(const LLString& name) { childSetVisible(name, true); } - void childHide(const LLString& name) { childSetVisible(name, false); } - bool childIsVisible(const LLString& id) const; - void childSetTentative(const LLString& name, bool tentative); + void childSetVisible(const std::string& name, bool visible); + void childShow(const std::string& name) { childSetVisible(name, true); } + void childHide(const std::string& name) { childSetVisible(name, false); } + bool childIsVisible(const std::string& id) const; + void childSetTentative(const std::string& name, bool tentative); - void childSetEnabled(const LLString& name, bool enabled); - void childEnable(const LLString& name) { childSetEnabled(name, true); } - void childDisable(const LLString& name) { childSetEnabled(name, false); }; - bool childIsEnabled(const LLString& id) const; + void childSetEnabled(const std::string& name, bool enabled); + void childEnable(const std::string& name) { childSetEnabled(name, true); } + void childDisable(const std::string& name) { childSetEnabled(name, false); }; + bool childIsEnabled(const std::string& id) const; - void childSetToolTip(const LLString& id, const LLString& msg); - void childSetRect(const LLString& id, const LLRect &rect); - bool childGetRect(const LLString& id, LLRect& rect) const; + void childSetToolTip(const std::string& id, const std::string& msg); + void childSetRect(const std::string& id, const LLRect &rect); + bool childGetRect(const std::string& id, LLRect& rect) const; // LLUICtrl - void childSetFocus(const LLString& id, BOOL focus = TRUE); - BOOL childHasFocus(const LLString& id); - void childSetFocusChangedCallback(const LLString& id, void (*cb)(LLFocusableElement*, void*), void* user_data = NULL); + void childSetFocus(const std::string& id, BOOL focus = TRUE); + BOOL childHasFocus(const std::string& id); + void childSetFocusChangedCallback(const std::string& id, void (*cb)(LLFocusableElement*, void*), void* user_data = NULL); - void childSetCommitCallback(const LLString& id, void (*cb)(LLUICtrl*, void*), void* userdata = NULL ); - void childSetDoubleClickCallback(const LLString& id, void (*cb)(void*), void* userdata = NULL ); - void childSetValidate(const LLString& id, BOOL (*cb)(LLUICtrl*, void*) ); - void childSetUserData(const LLString& id, void* userdata); + void childSetCommitCallback(const std::string& id, void (*cb)(LLUICtrl*, void*), void* userdata = NULL ); + void childSetDoubleClickCallback(const std::string& id, void (*cb)(void*), void* userdata = NULL ); + void childSetValidate(const std::string& id, BOOL (*cb)(LLUICtrl*, void*) ); + void childSetUserData(const std::string& id, void* userdata); - void childSetColor(const LLString& id, const LLColor4& color); + void childSetColor(const std::string& id, const LLColor4& color); - LLCtrlSelectionInterface* childGetSelectionInterface(const LLString& id) const; - LLCtrlListInterface* childGetListInterface(const LLString& id) const; - LLCtrlScrollInterface* childGetScrollInterface(const LLString& id) const; + LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; + LLCtrlListInterface* childGetListInterface(const std::string& id) const; + LLCtrlScrollInterface* childGetScrollInterface(const std::string& id) const; // This is the magic bullet for data-driven UI - void childSetValue(const LLString& id, LLSD value); - LLSD childGetValue(const LLString& id) const; + void childSetValue(const std::string& id, LLSD value); + LLSD childGetValue(const std::string& id) const; // For setting text / label replacement params, e.g. "Hello [NAME]" // Not implemented for all types, defaults to noop, returns FALSE if not applicaple - BOOL childSetTextArg(const LLString& id, const LLString& key, const LLStringExplicit& text); - BOOL childSetLabelArg(const LLString& id, const LLString& key, const LLStringExplicit& text); - BOOL childSetToolTipArg(const LLString& id, const LLString& key, const LLStringExplicit& text); + BOOL childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + BOOL childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + BOOL childSetToolTipArg(const std::string& id, const std::string& key, const LLStringExplicit& text); // LLSlider / LLMultiSlider / LLSpinCtrl - void childSetMinValue(const LLString& id, LLSD min_value); - void childSetMaxValue(const LLString& id, LLSD max_value); + void childSetMinValue(const std::string& id, LLSD min_value); + void childSetMaxValue(const std::string& id, LLSD max_value); // LLTabContainer - void childShowTab(const LLString& id, const LLString& tabname, bool visible = true); - LLPanel *childGetVisibleTab(const LLString& id) const; - void childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata); + void childShowTab(const std::string& id, const std::string& tabname, bool visible = true); + LLPanel *childGetVisibleTab(const std::string& id) const; + void childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata); // LLTextBox - void childSetWrappedText(const LLString& id, const LLString& text, bool visible = true); + void childSetWrappedText(const std::string& id, const std::string& text, bool visible = true); // LLTextBox/LLTextEditor/LLLineEditor - void childSetText(const LLString& id, const LLStringExplicit& text) { childSetValue(id, LLSD(text)); } - LLString childGetText(const LLString& id) const { return childGetValue(id).asString(); } + void childSetText(const std::string& id, const LLStringExplicit& text) { childSetValue(id, LLSD(text)); } + std::string childGetText(const std::string& id) const { return childGetValue(id).asString(); } // LLLineEditor - void childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data); - void childSetPrevalidate(const LLString& id, BOOL (*func)(const LLWString &) ); + void childSetKeystrokeCallback(const std::string& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data); + void childSetPrevalidate(const std::string& id, BOOL (*func)(const LLWString &) ); // LLButton - void childSetAction(const LLString& id, void(*function)(void*), void* value); - void childSetActionTextbox(const LLString& id, void(*function)(void*)); - void childSetControlName(const LLString& id, const LLString& control_name); + void childSetAction(const std::string& id, void(*function)(void*), void* value); + void childSetActionTextbox(const std::string& id, void(*function)(void*)); + void childSetControlName(const std::string& id, const std::string& control_name); // Error reporting - void childNotFound(const LLString& id) const; + void childNotFound(const std::string& id) const; void childDisplayNotFound(); - static void alertXml(LLString label, LLString::format_map_t args = LLString::format_map_t()); + static void alertXml(const std::string& label, LLStringUtil::format_map_t args = LLStringUtil::format_map_t()); static BOOL nextAlert(LLAlertInfo &alert); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); @@ -245,11 +245,11 @@ private: virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group); // Unified error reporting for the child* functions - typedef std::set<LLString> expected_members_list_t; + typedef std::set<std::string> expected_members_list_t; mutable expected_members_list_t mExpectedMembers; mutable expected_members_list_t mNewExpectedMembers; - LLString mRectControl; + std::string mRectControl; LLColor4 mBgColorAlpha; LLColor4 mBgColorOpaque; LLColor4 mDefaultBtnHighlight; @@ -257,14 +257,14 @@ private: BOOL mBgOpaque; LLViewBorder* mBorder; LLButton* mDefaultBtn; - LLString mLabel; + std::string mLabel; S32 mLastTabGroup; LLRootHandle<LLPanel> mPanelHandle; - typedef std::map<LLString, LLUIString> ui_string_map_t; + typedef std::map<std::string, LLUIString> ui_string_map_t; ui_string_map_t mUIStrings; - LLString mRequirementsError; + std::string mRequirementsError; typedef std::queue<LLAlertInfo> alert_queue_t; static alert_queue_t sAlertQueue; diff --git a/indra/llui/llradiogroup.cpp b/indra/llui/llradiogroup.cpp index 6d496b391f..b8f06e53ee 100644 --- a/indra/llui/llradiogroup.cpp +++ b/indra/llui/llradiogroup.cpp @@ -44,8 +44,8 @@ static LLRegisterWidget<LLRadioGroup> r("radio_group"); -LLRadioGroup::LLRadioGroup(const LLString& name, const LLRect& rect, - const LLString& control_name, +LLRadioGroup::LLRadioGroup(const std::string& name, const LLRect& rect, + const std::string& control_name, LLUICtrlCallback callback, void* userdata, BOOL border) @@ -56,7 +56,7 @@ LLRadioGroup::LLRadioGroup(const LLString& name, const LLRect& rect, init(border); } -LLRadioGroup::LLRadioGroup(const LLString& name, const LLRect& rect, +LLRadioGroup::LLRadioGroup(const std::string& name, const LLRect& rect, S32 initial_index, LLUICtrlCallback callback, void* userdata, @@ -71,7 +71,7 @@ void LLRadioGroup::init(BOOL border) { if (border) { - addChild( new LLViewBorder( "radio group border", + addChild( new LLViewBorder( std::string("radio group border"), LLRect(0, getRect().getHeight(), getRect().getWidth(), 0), LLViewBorder::BEVEL_NONE, LLViewBorder::STYLE_LINE, @@ -252,7 +252,7 @@ void LLRadioGroup::draw() // When adding a button, we need to ensure that the radio // group gets a message when the button is clicked. -LLRadioCtrl* LLRadioGroup::addRadioButton(const LLString& name, const LLString& label, const LLRect& rect, const LLFontGL* font ) +LLRadioCtrl* LLRadioGroup::addRadioButton(const std::string& name, const std::string& label, const LLRect& rect, const LLFontGL* font ) { // Highlight will get fixed in draw method above LLRadioCtrl* radio = new LLRadioCtrl(name, rect, label, font, @@ -298,7 +298,7 @@ void LLRadioGroup::onClickButton(LLUICtrl* ui_ctrl, void* userdata) void LLRadioGroup::setValue( const LLSD& value ) { - LLString value_name = value.asString(); + std::string value_name = value.asString(); int idx = 0; for (button_list_t::const_iterator iter = mRadioButtons.begin(); iter != mRadioButtons.end(); ++iter) @@ -357,7 +357,7 @@ LLXMLNodePtr LLRadioGroup::getXML(bool save_children) const LLXMLNodePtr child_node = radio->LLView::getXML(); child_node->setStringValue(radio->getLabel()); - child_node->setName("radio_item"); + child_node->setName(std::string("radio_item")); node->addChild(child_node); } @@ -368,7 +368,7 @@ LLXMLNodePtr LLRadioGroup::getXML(bool save_children) const // static LLView* LLRadioGroup::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("radio_group"); + std::string name("radio_group"); node->getAttributeString("name", name); U32 initial_value = 0; @@ -387,7 +387,7 @@ LLView* LLRadioGroup::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory NULL, draw_border); - const LLString& contents = node->getValue(); + const std::string& contents = node->getValue(); LLRect group_rect = radio_group->getRect(); @@ -406,10 +406,10 @@ LLView* LLRadioGroup::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory while(token_iter != tokens.end()) { - const char* line = token_iter->c_str(); + const std::string& line = *token_iter; LLRect rect(HPAD, cur_y, group_rect.getWidth() - (2 * HPAD), cur_y - 15); cur_y -= VPAD + 15; - radio_group->addRadioButton("radio", line, rect, font); + radio_group->addRadioButton(std::string("radio"), line, rect, font); ++token_iter; } llwarns << "Legacy radio group format used! Please convert to use <radio_item> tags!" << llendl; @@ -425,10 +425,10 @@ LLView* LLRadioGroup::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory LLRect item_rect; createRect(child, item_rect, radio_group, rect); - LLString radioname("radio"); + std::string radioname("radio"); child->getAttributeString("name", radioname); - LLString item_label = child->getTextContents(); - LLRadioCtrl* radio = radio_group->addRadioButton(radioname, item_label.c_str(), item_rect, font); + std::string item_label = child->getTextContents(); + LLRadioCtrl* radio = radio_group->addRadioButton(radioname, item_label, item_rect, font); radio->initFromXML(child, radio_group); } diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h index b9e2167446..fce467872a 100644 --- a/indra/llui/llradiogroup.h +++ b/indra/llui/llradiogroup.h @@ -43,7 +43,7 @@ class LLRadioCtrl : public LLCheckBoxCtrl { public: - LLRadioCtrl(const LLString& name, const LLRect& rect, const LLString& label, const LLFontGL* font = NULL, + LLRadioCtrl(const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font = NULL, void (*commit_callback)(LLUICtrl*, void*) = NULL, void* callback_userdata = NULL) : LLCheckBoxCtrl(name, rect, label, font, commit_callback, callback_userdata, FALSE, RADIO_STYLE) { @@ -67,15 +67,15 @@ public: // Build a radio group. The number (0...n-1) of the currently selected // element will be stored in the named control. After the control is // changed the callback will be called. - LLRadioGroup(const LLString& name, const LLRect& rect, - const LLString& control_name, + LLRadioGroup(const std::string& name, const LLRect& rect, + const std::string& control_name, LLUICtrlCallback callback = NULL, void* userdata = NULL, BOOL border = TRUE); // Another radio group constructor, but this one doesn't rely on // needing a control - LLRadioGroup(const LLString& name, const LLRect& rect, + LLRadioGroup(const std::string& name, const LLRect& rect, S32 initial_index, LLUICtrlCallback callback = NULL, void* userdata = NULL, @@ -106,7 +106,7 @@ public: // You must use this method to add buttons to a radio group. // Don't use addChild -- it won't set the callback function // correctly. - LLRadioCtrl* addRadioButton(const LLString& name, const LLString& label, const LLRect& rect, const LLFontGL* font); + LLRadioCtrl* addRadioButton(const std::string& name, const std::string& label, const LLRect& rect, const LLFontGL* font); LLRadioCtrl* getRadioButton(const S32& index) { return mRadioButtons[index]; } // Update the control as needed. Userdata must be a pointer to the button. static void onClickButton(LLUICtrl* radio, void* userdata); diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp index 82be9672b6..d69145d24e 100644 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -39,7 +39,7 @@ #include "llfocusmgr.h" #include "llwindow.h" -LLResizeBar::LLResizeBar( const LLString& name, LLView* resizing_view, const LLRect& rect, S32 min_size, S32 max_size, Side side ) +LLResizeBar::LLResizeBar( const std::string& name, LLView* resizing_view, const LLRect& rect, S32 min_size, S32 max_size, Side side ) : LLView( name, rect, TRUE ), mDragLastScreenX( 0 ), diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h index b760abf13d..bc7fdffc41 100644 --- a/indra/llui/llresizebar.h +++ b/indra/llui/llresizebar.h @@ -40,7 +40,7 @@ class LLResizeBar : public LLView public: enum Side { LEFT, TOP, RIGHT, BOTTOM }; - LLResizeBar(const LLString& name, LLView* resizing_view, const LLRect& rect, S32 min_size, S32 max_size, Side side ); + LLResizeBar(const std::string& name, LLView* resizing_view, const LLRect& rect, S32 min_size, S32 max_size, Side side ); // virtual void draw(); No appearance virtual BOOL handleHover(S32 x, S32 y, MASK mask); diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp index 4da2d4fca1..096aa91c81 100644 --- a/indra/llui/llresizehandle.cpp +++ b/indra/llui/llresizehandle.cpp @@ -43,7 +43,7 @@ const S32 RESIZE_BORDER_WIDTH = 3; -LLResizeHandle::LLResizeHandle( const LLString& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner ) +LLResizeHandle::LLResizeHandle( const std::string& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner ) : LLView( name, rect, TRUE ), mDragLastScreenX( 0 ), diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h index 15336948e2..8054806e40 100644 --- a/indra/llui/llresizehandle.h +++ b/indra/llui/llresizehandle.h @@ -44,7 +44,7 @@ public: enum ECorner { LEFT_TOP, LEFT_BOTTOM, RIGHT_TOP, RIGHT_BOTTOM }; - LLResizeHandle(const LLString& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner = RIGHT_BOTTOM ); + LLResizeHandle(const std::string& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner = RIGHT_BOTTOM ); virtual void draw(); virtual BOOL handleHover(S32 x, S32 y, MASK mask); diff --git a/indra/llui/llresmgr.cpp b/indra/llui/llresmgr.cpp index 6cfc6a924b..cb4d8c3373 100644 --- a/indra/llui/llresmgr.cpp +++ b/indra/llui/llresmgr.cpp @@ -292,7 +292,7 @@ std::string LLResMgr::getMonetaryString( S32 input ) const BOOL negative_before = negative && (conv->n_sign_posn != 2); BOOL negative_after = negative && (conv->n_sign_posn == 2); - LLString digits = llformat("%u", abs(input)); + std::string digits = llformat("%u", abs(input)); if( !grouping || !grouping[0] ) { if( negative_before ) @@ -378,10 +378,10 @@ std::string LLResMgr::getMonetaryString( S32 input ) const return output; } -void LLResMgr::getIntegerString( LLString& output, S32 input ) const +void LLResMgr::getIntegerString( std::string& output, S32 input ) const { S32 fraction = 0; - LLString fraction_string; + std::string fraction_string; S32 remaining_count = input; while(remaining_count > 0) { @@ -415,16 +415,16 @@ void LLResMgr::getIntegerString( LLString& output, S32 input ) const } } -const LLString LLFONT_ID_NAMES[] = +const std::string LLFONT_ID_NAMES[] = { - LLString("OCRA"), - LLString("SANSSERIF"), - LLString("SANSSERIF_SMALL"), - LLString("SANSSERIF_BIG"), - LLString("SMALL"), + std::string("OCRA"), + std::string("SANSSERIF"), + std::string("SANSSERIF_SMALL"), + std::string("SANSSERIF_BIG"), + std::string("SMALL"), }; -const LLFontGL* LLResMgr::getRes( LLString font_id ) const +const LLFontGL* LLResMgr::getRes( std::string font_id ) const { for (S32 i=0; i<LLFONT_COUNT; ++i) { @@ -437,21 +437,21 @@ const LLFontGL* LLResMgr::getRes( LLString font_id ) const } #if LL_WINDOWS -const LLString LLLocale::USER_LOCALE("English_United States.1252");// = LLString::null; -const LLString LLLocale::SYSTEM_LOCALE("English_United States.1252"); +const std::string LLLocale::USER_LOCALE("English_United States.1252");// = LLStringUtil::null; +const std::string LLLocale::SYSTEM_LOCALE("English_United States.1252"); #elif LL_DARWIN -const LLString LLLocale::USER_LOCALE("en_US.iso8859-1");// = LLString::null; -const LLString LLLocale::SYSTEM_LOCALE("en_US.iso8859-1"); +const std::string LLLocale::USER_LOCALE("en_US.iso8859-1");// = LLStringUtil::null; +const std::string LLLocale::SYSTEM_LOCALE("en_US.iso8859-1"); #elif LL_SOLARIS -const LLString LLLocale::USER_LOCALE("en_US.ISO8859-1"); -const LLString LLLocale::SYSTEM_LOCALE("C"); +const std::string LLLocale::USER_LOCALE("en_US.ISO8859-1"); +const std::string LLLocale::SYSTEM_LOCALE("C"); #else // LL_LINUX likes this -const LLString LLLocale::USER_LOCALE("en_US.utf8"); -const LLString LLLocale::SYSTEM_LOCALE("C"); +const std::string LLLocale::USER_LOCALE("en_US.utf8"); +const std::string LLLocale::SYSTEM_LOCALE("C"); #endif -LLLocale::LLLocale(const LLString& locale_string) +LLLocale::LLLocale(const std::string& locale_string) { mPrevLocaleString = setlocale( LC_ALL, NULL ); char* new_locale_string = setlocale( LC_ALL, locale_string.c_str()); diff --git a/indra/llui/llresmgr.h b/indra/llui/llresmgr.h index 2e39387ae1..ddddec71a5 100644 --- a/indra/llui/llresmgr.h +++ b/indra/llui/llresmgr.h @@ -71,11 +71,11 @@ public: char getMonetaryDecimalPoint() const; char getMonetaryThousandsSeparator() const; std::string getMonetaryString( S32 input ) const; - void getIntegerString( LLString& output, S32 input ) const; + void getIntegerString( std::string& output, S32 input ) const; // const char* getRes( LLSTR_ID string_id ) const { return mStrings[ string_id ]; } const LLFontGL* getRes( LLFONT_ID font_id ) const { return mFonts[ font_id ]; } - const LLFontGL* getRes( LLString font_id ) const; + const LLFontGL* getRes( std::string font_id ) const; private: LLLOCALE_ID mLocale; @@ -92,14 +92,14 @@ private: class LLLocale { public: - LLLocale(const LLString& locale_string); + LLLocale(const std::string& locale_string); virtual ~LLLocale(); - static const LLString USER_LOCALE; - static const LLString SYSTEM_LOCALE; + static const std::string USER_LOCALE; + static const std::string SYSTEM_LOCALE; private: - LLString mPrevLocaleString; + std::string mPrevLocaleString; }; #endif // LL_RESMGR_ diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index 5bc2c5cf85..07babd9f55 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -47,7 +47,7 @@ #include "llrender.h" LLScrollbar::LLScrollbar( - const LLString& name, LLRect rect, + const std::string& name, LLRect rect, LLScrollbar::ORIENTATION orientation, S32 doc_size, S32 doc_pos, S32 page_size, void (*change_callback)( S32 new_pos, LLScrollbar* self, void* userdata ), @@ -82,10 +82,10 @@ LLScrollbar::LLScrollbar( // Page up and page down buttons LLRect line_up_rect; - LLString line_up_img; - LLString line_up_selected_img; - LLString line_down_img; - LLString line_down_selected_img; + std::string line_up_img; + std::string line_up_selected_img; + std::string line_down_img; + std::string line_down_selected_img; LLRect line_down_rect; @@ -111,10 +111,9 @@ LLScrollbar::LLScrollbar( line_down_selected_img="UIImgBtnScrollRightInUUID"; } - LLButton* line_up_btn = new LLButton( - "Line Up", line_up_rect, - line_up_img, line_up_selected_img, "", - &LLScrollbar::onLineUpBtnPressed, this, LLFontGL::sSansSerif ); + LLButton* line_up_btn = new LLButton(std::string("Line Up"), line_up_rect, + line_up_img, line_up_selected_img, LLStringUtil::null, + &LLScrollbar::onLineUpBtnPressed, this, LLFontGL::sSansSerif ); if( LLScrollbar::VERTICAL == mOrientation ) { line_up_btn->setFollowsRight(); @@ -130,10 +129,9 @@ LLScrollbar::LLScrollbar( line_up_btn->setTabStop(FALSE); addChild(line_up_btn); - LLButton* line_down_btn = new LLButton( - "Line Down", line_down_rect, - line_down_img, line_down_selected_img, "", - &LLScrollbar::onLineDownBtnPressed, this, LLFontGL::sSansSerif ); + LLButton* line_down_btn = new LLButton(std::string("Line Down"), line_down_rect, + line_down_img, line_down_selected_img, LLStringUtil::null, + &LLScrollbar::onLineDownBtnPressed, this, LLFontGL::sSansSerif ); line_down_btn->setFollowsRight(); line_down_btn->setFollowsBottom(); line_down_btn->setHeldDownCallback( &LLScrollbar::onLineDownBtnPressed ); @@ -417,7 +415,7 @@ BOOL LLScrollbar::handleScrollWheel(S32 x, S32 y, S32 clicks) } BOOL LLScrollbar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, LLString &tooltip_msg) + EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string &tooltip_msg) { // enable this to get drag and drop to control scrollbars //if (!drop) diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h index 4d3b711b1a..d35dc10bd4 100644 --- a/indra/llui/llscrollbar.h +++ b/indra/llui/llscrollbar.h @@ -51,7 +51,7 @@ class LLScrollbar public: enum ORIENTATION { HORIZONTAL, VERTICAL }; - LLScrollbar(const LLString& name, LLRect rect, + LLScrollbar(const std::string& name, LLRect rect, ORIENTATION orientation, S32 doc_size, S32 doc_pos, S32 page_size, void(*change_callback)( S32 new_pos, LLScrollbar* self, void* userdata ), @@ -69,7 +69,7 @@ public: virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, LLString &tooltip_msg); + EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string &tooltip_msg); virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index 3cb4ecc172..8bb051f3f5 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -60,7 +60,7 @@ static const F32 AUTO_SCROLL_RATE_ACCEL = 120.f; static LLRegisterWidget<LLScrollableContainerView> r("scroll_container"); // Default constructor -LLScrollableContainerView::LLScrollableContainerView( const LLString& name, +LLScrollableContainerView::LLScrollableContainerView( const std::string& name, const LLRect& rect, LLView* scrolled_view, BOOL is_opaque, @@ -82,7 +82,7 @@ LLScrollableContainerView::LLScrollableContainerView( const LLString& name, } // LLUICtrl constructor -LLScrollableContainerView::LLScrollableContainerView( const LLString& name, const LLRect& rect, +LLScrollableContainerView::LLScrollableContainerView( const std::string& name, const LLRect& rect, LLUICtrl* scrolled_ctrl, BOOL is_opaque, const LLColor4& bg_color) : LLUICtrl( name, rect, FALSE, NULL, NULL ), @@ -104,7 +104,7 @@ LLScrollableContainerView::LLScrollableContainerView( const LLString& name, cons void LLScrollableContainerView::init() { LLRect border_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 ); - mBorder = new LLViewBorder( "scroll border", border_rect, LLViewBorder::BEVEL_IN ); + mBorder = new LLViewBorder( std::string("scroll border"), border_rect, LLViewBorder::BEVEL_IN ); addChild( mBorder ); mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 ); @@ -112,7 +112,7 @@ void LLScrollableContainerView::init() LLRect vertical_scroll_rect = mInnerRect; vertical_scroll_rect.mLeft = vertical_scroll_rect.mRight - SCROLLBAR_SIZE; - mScrollbar[VERTICAL] = new LLScrollbar( "scrollable vertical", + mScrollbar[VERTICAL] = new LLScrollbar( std::string("scrollable vertical"), vertical_scroll_rect, LLScrollbar::VERTICAL, mInnerRect.getHeight(), @@ -128,7 +128,7 @@ void LLScrollableContainerView::init() LLRect horizontal_scroll_rect = mInnerRect; horizontal_scroll_rect.mTop = horizontal_scroll_rect.mBottom + SCROLLBAR_SIZE; - mScrollbar[HORIZONTAL] = new LLScrollbar( "scrollable horizontal", + mScrollbar[HORIZONTAL] = new LLScrollbar( std::string("scrollable horizontal"), horizontal_scroll_rect, LLScrollbar::HORIZONTAL, mInnerRect.getWidth(), @@ -264,7 +264,7 @@ BOOL LLScrollableContainerView::handleDragAndDrop(S32 x, S32 y, MASK mask, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { // Scroll folder view if needed. Never accepts a drag or drop. *accept = ACCEPT_NO; @@ -336,7 +336,7 @@ BOOL LLScrollableContainerView::handleDragAndDrop(S32 x, S32 y, MASK mask, } -BOOL LLScrollableContainerView::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect) +BOOL LLScrollableContainerView::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect) { S32 local_x, local_y; for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) @@ -700,7 +700,7 @@ LLXMLNodePtr LLScrollableContainerView::getXML(bool save_children) const LLView* LLScrollableContainerView::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("scroll_container"); + std::string name("scroll_container"); node->getAttributeString("name", name); LLRect rect; @@ -738,7 +738,7 @@ LLView* LLScrollableContainerView::fromXML(LLXMLNodePtr node, LLView *parent, LL if (panelp == NULL) { - panelp = new LLPanel("dummy", LLRect::null, FALSE); + panelp = new LLPanel(std::string("dummy"), LLRect::null, FALSE); } ret->mScrolledView = panelp; diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h index 64be2169ad..f3da92cc88 100644 --- a/indra/llui/llscrollcontainer.h +++ b/indra/llui/llscrollcontainer.h @@ -59,10 +59,10 @@ public: // scrollbars have priority for mouse and keyboard events. enum SCROLL_ORIENTATION { VERTICAL, HORIZONTAL, SCROLLBAR_COUNT }; - LLScrollableContainerView( const LLString& name, const LLRect& rect, + LLScrollableContainerView( const std::string& name, const LLRect& rect, LLView* scrolled_view, BOOL is_opaque = FALSE, const LLColor4& bg_color = LLColor4(0,0,0,0) ); - LLScrollableContainerView( const LLString& name, const LLRect& rect, + LLScrollableContainerView( const std::string& name, const LLRect& rect, LLUICtrl* scrolled_ctrl, BOOL is_opaque = FALSE, const LLColor4& bg_color = LLColor4(0,0,0,0) ); virtual ~LLScrollableContainerView( void ); @@ -94,9 +94,9 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); - virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); + virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect); virtual void draw(); virtual LLXMLNodePtr getXML(bool save_children = true) const; diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp index 28755ed30f..c05dacf4d8 100644 --- a/indra/llui/llscrollingpanellist.cpp +++ b/indra/llui/llscrollingpanellist.cpp @@ -141,7 +141,7 @@ void LLScrollingPanelList::draw() // static LLView* LLScrollingPanelList::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("scrolling_panel_list"); + std::string name("scrolling_panel_list"); node->getAttributeString("name", name); LLRect rect; diff --git a/indra/llui/llscrollingpanellist.h b/indra/llui/llscrollingpanellist.h index dc0dcbd460..406c832383 100644 --- a/indra/llui/llscrollingpanellist.h +++ b/indra/llui/llscrollingpanellist.h @@ -41,7 +41,7 @@ class LLScrollingPanel : public LLPanel { public: - LLScrollingPanel(const LLString& name, const LLRect& rect) : LLPanel(name, rect) { } + LLScrollingPanel(const std::string& name, const LLRect& rect) : LLPanel(name, rect) { } virtual void updatePanel(BOOL allow_modify) = 0; }; @@ -52,7 +52,7 @@ public: class LLScrollingPanelList : public LLUICtrl { public: - LLScrollingPanelList(const LLString& name, const LLRect& rect) + LLScrollingPanelList(const std::string& name, const LLRect& rect) : LLUICtrl(name, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_BOTTOM ) {} virtual void setValue(const LLSD& value) {}; diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index b4a2ed874a..681c5ce5da 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -83,7 +83,7 @@ struct SortScrollListItem S32 order = sort_ascending ? 1 : -1; // ascending or descending sort for this column? if (cell1 && cell2) { - sort_result = order * LLString::compareDict(cell1->getValue().asString(), cell2->getValue().asString()); + sort_result = order * LLStringUtil::compareDict(cell1->getValue().asString(), cell2->getValue().asString()); if (sort_result != 0) { break; // we have a sort order! @@ -131,7 +131,7 @@ void LLScrollListIcon::setValue(const LLSD& value) } else { - LLString value_string = value.asString(); + std::string value_string = value.asString(); if (LLUUID::validate(value_string)) { setValue(LLUUID(value_string)); @@ -237,7 +237,7 @@ void LLScrollListSeparator::draw(const LLColor4& color, const LLColor4& highligh // U32 LLScrollListText::sCount = 0; -LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) +LLScrollListText::LLScrollListText( const std::string& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) : LLScrollListCell(width), mText( text ), mFont( font ), @@ -416,9 +416,9 @@ void LLScrollListItem::setColumn( S32 column, LLScrollListCell *cell ) } } -LLString LLScrollListItem::getContentsCSV() const +std::string LLScrollListItem::getContentsCSV() const { - LLString ret; + std::string ret; S32 count = getNumColumns(); for (S32 i=0; i<count; ++i) @@ -474,7 +474,7 @@ void LLScrollListItem::setEnabled(BOOL b) //--------------------------------------------------------------------------- // LLScrollListItemComment //--------------------------------------------------------------------------- -LLScrollListItemComment::LLScrollListItemComment(const LLString& comment_string, const LLColor4& color) +LLScrollListItemComment::LLScrollListItemComment(const std::string& comment_string, const LLColor4& color) : LLScrollListItem(FALSE), mColor(color) { @@ -539,7 +539,7 @@ void LLScrollListItemSeparator::draw(const LLRect& rect, const LLColor4& fg_colo // LLScrollListCtrl //--------------------------------------------------------------------------- -LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect, +LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, void (*commit_callback)(LLUICtrl* ctrl, void* userdata), void* callback_user_data, BOOL allow_multiple_selection, @@ -603,12 +603,12 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect, mItemListRect.mBottom, SCROLLBAR_SIZE, mItemListRect.getHeight()); - mScrollbar = new LLScrollbar( "Scrollbar", scroll_rect, - LLScrollbar::VERTICAL, - getItemCount(), - mScrollLines, - mPageLines, - &LLScrollListCtrl::onScrollChange, this ); + mScrollbar = new LLScrollbar( std::string("Scrollbar"), scroll_rect, + LLScrollbar::VERTICAL, + getItemCount(), + mScrollLines, + mPageLines, + &LLScrollListCtrl::onScrollChange, this ); mScrollbar->setFollowsRight(); mScrollbar->setFollowsTop(); mScrollbar->setFollowsBottom(); @@ -621,7 +621,7 @@ LLScrollListCtrl::LLScrollListCtrl(const LLString& name, const LLRect& rect, if (show_border) { LLRect border_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 ); - mBorder = new LLViewBorder( "dlg border", border_rect, LLViewBorder::BEVEL_IN, LLViewBorder::STYLE_LINE, 1 ); + mBorder = new LLViewBorder( std::string("dlg border"), border_rect, LLViewBorder::BEVEL_IN, LLViewBorder::STYLE_LINE, 1 ); addChild(mBorder); } @@ -756,7 +756,7 @@ std::vector<LLScrollListItem*> LLScrollListCtrl::getAllData() const // returns first matching item LLScrollListItem* LLScrollListCtrl::getItem(const LLSD& sd) const { - LLString string_val = sd.asString(); + std::string string_val = sd.asString(); item_list::const_iterator iter; for(iter = mItemList.begin(); iter != mItemList.end(); iter++) @@ -1398,7 +1398,7 @@ void LLScrollListCtrl::deselectAllItems(BOOL no_commit_on_change) /////////////////////////////////////////////////////////////////////////////////////////////////// // Use this to add comment text such as "Searching", which ignores column settings of list -LLScrollListItem* LLScrollListCtrl::addCommentText(const LLString& comment_text, EAddPosition pos) +LLScrollListItem* LLScrollListCtrl::addCommentText(const std::string& comment_text, EAddPosition pos) { LLScrollListItem* item = NULL; if (getItemCount() < mMaxItemCount) @@ -1419,7 +1419,7 @@ LLScrollListItem* LLScrollListCtrl::addSeparator(EAddPosition pos) // Selects first enabled item of the given name. // Returns false if item not found. -BOOL LLScrollListCtrl::selectItemByLabel(const LLString& label, BOOL case_sensitive) +BOOL LLScrollListCtrl::selectItemByLabel(const std::string& label, BOOL case_sensitive) { // ensure that no stale items are selected, even if we don't find a match deselectAllItems(TRUE); @@ -1429,10 +1429,10 @@ BOOL LLScrollListCtrl::selectItemByLabel(const LLString& label, BOOL case_sensit return FALSE; } - LLString target_text = label; + std::string target_text = label; if (!case_sensitive) { - LLString::toLower(target_text); + LLStringUtil::toLower(target_text); } BOOL found = FALSE; @@ -1443,10 +1443,10 @@ BOOL LLScrollListCtrl::selectItemByLabel(const LLString& label, BOOL case_sensit { LLScrollListItem* item = *iter; // Only select enabled items with matching names - LLString item_text = item->getColumn(0)->getValue().asString(); + std::string item_text = item->getColumn(0)->getValue().asString(); if (!case_sensitive) { - LLString::toLower(item_text); + LLStringUtil::toLower(item_text); } BOOL select = !found && item->getEnabled() && item_text == target_text; if (select) @@ -1466,7 +1466,7 @@ BOOL LLScrollListCtrl::selectItemByLabel(const LLString& label, BOOL case_sensit } -BOOL LLScrollListCtrl::selectItemByPrefix(const LLString& target, BOOL case_sensitive) +BOOL LLScrollListCtrl::selectItemByPrefix(const std::string& target, BOOL case_sensitive) { return selectItemByPrefix(utf8str_to_wstring(target), case_sensitive); } @@ -1503,7 +1503,7 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen if (!case_sensitive) { // do comparisons in lower case - LLWString::toLower(target_trimmed); + LLWStringUtil::toLower(target_trimmed); } for (item_list::iterator iter = mItemList.begin(); iter != mItemList.end(); iter++) @@ -1519,11 +1519,11 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen LLWString item_label = utf8str_to_wstring(cellp->getValue().asString()); if (!case_sensitive) { - LLWString::toLower(item_label); + LLWStringUtil::toLower(item_label); } // remove extraneous whitespace from searchable label LLWString trimmed_label = item_label; - LLWString::trim(trimmed_label); + LLWStringUtil::trim(trimmed_label); BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0; @@ -1547,7 +1547,7 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen return found; } -const LLString LLScrollListCtrl::getSelectedItemLabel(S32 column) const +const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const { LLScrollListItem* item; @@ -1557,14 +1557,14 @@ const LLString LLScrollListCtrl::getSelectedItemLabel(S32 column) const return item->getColumn(column)->getValue().asString(); } - return LLString::null; + return LLStringUtil::null; } /////////////////////////////////////////////////////////////////////////////////////////////////// // "StringUUID" interface: use this when you're creating a list that contains non-unique strings each of which // has an associated, unique UUID, and only one of which can be selected at a time. -LLScrollListItem* LLScrollListCtrl::addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos, BOOL enabled, S32 column_width) +LLScrollListItem* LLScrollListCtrl::addStringUUIDItem(const std::string& item_text, const LLUUID& id, EAddPosition pos, BOOL enabled, S32 column_width) { LLScrollListItem* item = NULL; if (getItemCount() < mMaxItemCount) @@ -1792,7 +1792,7 @@ BOOL LLScrollListCtrl::handleScrollWheel(S32 x, S32 y, S32 clicks) return handled; } -BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) +BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) { S32 column_index = getColumnIndexFromOffset(x); LLScrollListColumn* columnp = getColumn(column_index); @@ -2532,7 +2532,7 @@ void LLScrollListCtrl::onScrollChange( S32 new_pos, LLScrollbar* scrollbar, void } -void LLScrollListCtrl::sortByColumn(LLString name, BOOL ascending) +void LLScrollListCtrl::sortByColumn(const std::string& name, BOOL ascending) { if (name.empty()) { @@ -2540,15 +2540,15 @@ void LLScrollListCtrl::sortByColumn(LLString name, BOOL ascending) return; } - std::map<LLString, LLScrollListColumn>::iterator itor = mColumns.find(name); + std::map<std::string, LLScrollListColumn>::iterator itor = mColumns.find(name); if (itor != mColumns.end()) { - sortByColumn((*itor).second.mIndex, ascending); + sortByColumnIndex((*itor).second.mIndex, ascending); } } // First column is column 0 -void LLScrollListCtrl::sortByColumn(U32 column, BOOL ascending) +void LLScrollListCtrl::sortByColumnIndex(U32 column, BOOL ascending) { if (setSort(column, ascending)) { @@ -2575,7 +2575,7 @@ void LLScrollListCtrl::dirtyColumns() // just in case someone indexes into it immediately mColumnsIndexed.resize(mColumns.size()); - std::map<LLString, LLScrollListColumn>::iterator column_itor; + std::map<std::string, LLScrollListColumn>::iterator column_itor; for (column_itor = mColumns.begin(); column_itor != mColumns.end(); ++column_itor) { LLScrollListColumn *column = &column_itor->second; @@ -2664,7 +2664,7 @@ LLXMLNodePtr LLScrollListCtrl::getXML(bool save_children) const // Contents - std::map<LLString, LLScrollListColumn>::const_iterator itor; + std::map<std::string, LLScrollListColumn>::const_iterator itor; std::vector<const LLScrollListColumn*> sorted_list; sorted_list.resize(mColumns.size()); for (itor = mColumns.begin(); itor != mColumns.end(); ++itor) @@ -2756,7 +2756,7 @@ void LLScrollListCtrl::setScrollListParameters(LLXMLNodePtr node) // static LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("scroll_list"); + std::string name("scroll_list"); node->getAttributeString("name", name); LLRect rect; @@ -2806,7 +2806,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac if (sort_column >= 0) { - scroll_list->sortByColumn(sort_column, sort_ascending); + scroll_list->sortByColumnIndex(sort_column, sort_ascending); } LLSD columns; @@ -2817,19 +2817,19 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac { if (child->hasName("column")) { - LLString labelname(""); + std::string labelname(""); child->getAttributeString("label", labelname); - LLString columnname(labelname); + std::string columnname(labelname); child->getAttributeString("name", columnname); - LLString sortname(columnname); + std::string sortname(columnname); child->getAttributeString("sort", sortname); BOOL sort_ascending = TRUE; child->getAttributeBOOL("sort_ascending", sort_ascending); - LLString imagename; + std::string imagename; child->getAttributeString("image", imagename); BOOL columndynamicwidth = FALSE; @@ -2838,7 +2838,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac S32 columnwidth = -1; child->getAttributeS32("width", columnwidth); - LLString tooltip; + std::string tooltip; child->getAttributeString("tool_tip", tooltip); if(!columndynamicwidth) total_static += llmax(0, columnwidth); @@ -2883,15 +2883,15 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac { if (row_child->hasName("column")) { - LLString value = row_child->getTextContents(); + std::string value = row_child->getTextContents(); - LLString columnname(""); + std::string columnname(""); row_child->getAttributeString("name", columnname); - LLString font(""); + std::string font(""); row_child->getAttributeString("font", font); - LLString font_style(""); + std::string font_style(""); row_child->getAttributeString("font-style", font_style); row["columns"][column_idx]["column"] = columnname; @@ -2905,7 +2905,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac } } - LLString contents = node->getTextContents(); + std::string contents = node->getTextContents(); if (!contents.empty()) { typedef boost::tokenizer<boost::char_separator<char> > tokenizer; @@ -2915,7 +2915,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac while(token_iter != tokens.end()) { - const char* line = token_iter->c_str(); + const std::string& line = *token_iter; scroll_list->addSimpleElement(line); ++token_iter; } @@ -2929,7 +2929,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac // virtual void LLScrollListCtrl::copy() { - LLString buffer; + std::string buffer; std::vector<LLScrollListItem*> items = getAllSelected(); std::vector<LLScrollListItem*>::iterator itor; @@ -2999,7 +2999,7 @@ BOOL LLScrollListCtrl::canDeselect() const void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) { - LLString name = column["name"].asString(); + std::string name = column["name"].asString(); // if no column name provided, just use ordinal as name if (name.empty()) { @@ -3030,7 +3030,7 @@ void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) S32 top = mItemListRect.mTop; S32 left = mItemListRect.mLeft; { - std::map<LLString, LLScrollListColumn>::iterator itor; + std::map<std::string, LLScrollListColumn>::iterator itor; for (itor = mColumns.begin(); itor != mColumns.end(); ++itor) { if (itor->second.mIndex < new_column->mIndex && @@ -3040,7 +3040,7 @@ void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) } } } - LLString button_name = "btn_" + name; + std::string button_name = "btn_" + name; S32 right = left+new_column->mWidth; if (new_column->mIndex != (S32)mColumns.size()-1) { @@ -3101,7 +3101,7 @@ void LLScrollListCtrl::onClickColumn(void *userdata) ascending = !parent->mSortColumns.back().second; } - parent->sortByColumn(column_index, ascending); + parent->sortByColumnIndex(column_index, ascending); if (parent->mOnSortChangedCallback) { @@ -3124,7 +3124,7 @@ BOOL LLScrollListCtrl::needsSorting() void LLScrollListCtrl::clearColumns() { - std::map<LLString, LLScrollListColumn>::iterator itor; + std::map<std::string, LLScrollListColumn>::iterator itor; for (itor = mColumns.begin(); itor != mColumns.end(); ++itor) { LLColumnHeader *header = itor->second.mHeader; @@ -3138,9 +3138,9 @@ void LLScrollListCtrl::clearColumns() mSortColumns.clear(); } -void LLScrollListCtrl::setColumnLabel(const LLString& column, const LLString& label) +void LLScrollListCtrl::setColumnLabel(const std::string& column, const std::string& label) { - std::map<LLString, LLScrollListColumn>::iterator itor = mColumns.find(column); + std::map<std::string, LLScrollListColumn>::iterator itor = mColumns.find(column); if (itor != mColumns.end()) { itor->second.mLabel = label; @@ -3194,7 +3194,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p // skip unused columns in item passed in continue; } - LLString column = (*itor)["column"].asString(); + std::string column = (*itor)["column"].asString(); LLScrollListColumn* columnp = NULL; @@ -3206,7 +3206,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p column = new_name.str(); } - std::map<LLString, LLScrollListColumn>::iterator column_itor; + std::map<std::string, LLScrollListColumn>::iterator column_itor; column_itor = mColumns.find(column); if (column_itor != mColumns.end()) { @@ -3239,9 +3239,9 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p LLFontGL::HAlign font_alignment = columnp->mFontAlignment; LLSD value = (*itor)["value"]; - LLString fontname = (*itor)["font"].asString(); - LLString fontstyle = (*itor)["font-style"].asString(); - LLString type = (*itor)["type"].asString(); + std::string fontname = (*itor)["font"].asString(); + std::string fontstyle = (*itor)["font-style"].asString(); + std::string type = (*itor)["type"].asString(); BOOL has_color = (*itor).has("color"); LLColor4 color = ((*itor)["color"]); BOOL enabled = !(*itor).has("enabled") || (*itor)["enabled"].asBoolean() == true; @@ -3264,8 +3264,8 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p } else if (type == "checkbox") { - LLCheckBoxCtrl* ctrl = new LLCheckBoxCtrl("check", - LLRect(0, width, width, 0), " "); + LLCheckBoxCtrl* ctrl = new LLCheckBoxCtrl(std::string("check"), + LLRect(0, width, width, 0), std::string(" ")); ctrl->setEnabled(enabled); ctrl->setValue(value); LLScrollListCheck* cell = new LLScrollListCheck(ctrl,width); @@ -3308,7 +3308,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p if (new_item->getColumn(column_idx) == NULL) { LLScrollListColumn* column_ptr = &column_it->second; - new_item->setColumn(column_idx, new LLScrollListText("", LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ), column_ptr->mWidth, LLFontGL::NORMAL)); + new_item->setColumn(column_idx, new LLScrollListText(LLStringUtil::null, LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ), column_ptr->mWidth, LLFontGL::NORMAL)); } } @@ -3317,7 +3317,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p return new_item; } -LLScrollListItem* LLScrollListCtrl::addSimpleElement(const LLString& value, EAddPosition pos, const LLSD& id) +LLScrollListItem* LLScrollListCtrl::addSimpleElement(const std::string& value, EAddPosition pos, const LLSD& id) { LLSD entry_id = id; @@ -3434,7 +3434,7 @@ void LLScrollListCtrl::onFocusLost() LLUICtrl::onFocusLost(); } -LLColumnHeader::LLColumnHeader(const LLString& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL* fontp) : +LLColumnHeader::LLColumnHeader(const std::string& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL* fontp) : LLComboBox(label, rect, label, NULL, NULL), mColumn(column), mOrigLabel(label), @@ -3453,15 +3453,15 @@ LLColumnHeader::LLColumnHeader(const LLString& label, const LLRect &rect, LLScro mButton->setCallbackUserData(this); - mAscendingText = "[LOW]...[HIGH](Ascending)"; - mDescendingText = "[HIGH]...[LOW](Descending)"; + mAscendingText = std::string("[LOW]...[HIGH](Ascending)"); // *TODO: Translate + mDescendingText = std::string("[HIGH]...[LOW](Descending)"); // *TODO: Translate mList->reshape(llmax(mList->getRect().getWidth(), 110, getRect().getWidth()), mList->getRect().getHeight()); // resize handles on left and right const S32 RESIZE_BAR_THICKNESS = 3; mResizeBar = new LLResizeBar( - "resizebar", + std::string("resizebar"), this, LLRect( getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0), MIN_COLUMN_WIDTH, S32_MAX, LLResizeBar::RIGHT ); @@ -3514,7 +3514,7 @@ BOOL LLColumnHeader::handleDoubleClick(S32 x, S32 y, MASK mask) return TRUE; } -void LLColumnHeader::setImage(const LLString &image_name) +void LLColumnHeader::setImage(const std::string &image_name) { if (mButton) { @@ -3567,8 +3567,8 @@ void LLColumnHeader::showList() // move sort column over to this column and do initial sort mColumn->mParentCtrl->sortByColumn(mColumn->mSortingColumn, mColumn->mParentCtrl->getSortAscending()); - LLString low_item_text; - LLString high_item_text; + std::string low_item_text; + std::string high_item_text; LLScrollListItem* itemp = mColumn->mParentCtrl->getFirstData(); if (itemp) @@ -3604,11 +3604,11 @@ void LLColumnHeader::showList() } } - LLString::truncate(low_item_text, 3); - LLString::truncate(high_item_text, 3); + LLStringUtil::truncate(low_item_text, 3); + LLStringUtil::truncate(high_item_text, 3); - LLString ascending_string; - LLString descending_string; + std::string ascending_string; + std::string descending_string; if (low_item_text.empty() || high_item_text.empty()) { diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index 04a6a181eb..05ef69c9a4 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -65,7 +65,7 @@ public: virtual S32 getWidth() const {return mWidth;} virtual S32 getContentWidth() const { return 0; } virtual S32 getHeight() const = 0; - virtual const LLSD getValue() const { return LLString::null; } + virtual const LLSD getValue() const { return LLStringUtil::null; } virtual void setValue(const LLSD& value) { } virtual BOOL getVisible() const { return TRUE; } virtual void setWidth(S32 width) { mWidth = width; } @@ -100,7 +100,7 @@ public: class LLScrollListText : public LLScrollListCell { public: - LLScrollListText( const LLString& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); + LLScrollListText( const std::string& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); /*virtual*/ ~LLScrollListText(); virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const; @@ -145,7 +145,7 @@ public: virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const; virtual S32 getWidth() const; virtual S32 getHeight() const { return mIcon ? mIcon->getHeight() : 0; } - virtual const LLSD getValue() const { return mIcon.isNull() ? LLString::null : mIcon->getName(); } + virtual const LLSD getValue() const { return mIcon.isNull() ? LLStringUtil::null : mIcon->getName(); } virtual void setColor(const LLColor4&); virtual BOOL isText()const { return FALSE; } virtual void setValue(const LLSD& value); @@ -201,7 +201,7 @@ public: mFontAlignment(LLFontGL::LEFT) { } - LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) : + LLScrollListColumn(std::string name, std::string label, S32 width, F32 relwidth) : mName(name), mSortingColumn(name), mSortAscending(TRUE), @@ -267,10 +267,10 @@ public: // Public data is fine so long as this remains a simple struct-like data class. // If it ever gets any smarter than that, these should all become private // with protected or public accessor methods added as needed. -MG - LLString mName; - LLString mSortingColumn; + std::string mName; + std::string mSortingColumn; BOOL mSortAscending; - LLString mLabel; + std::string mLabel; S32 mWidth; F32 mRelWidth; BOOL mDynamicWidth; @@ -284,7 +284,7 @@ public: class LLColumnHeader : public LLComboBox { public: - LLColumnHeader(const LLString& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL *font = NULL); + LLColumnHeader(const std::string& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL *font = NULL); ~LLColumnHeader(); /*virtual*/ void draw(); @@ -294,12 +294,12 @@ public: /*virtual*/ LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding); /*virtual*/ void userSetShape(const LLRect& new_rect); - void setImage(const LLString &image_name); + void setImage(const std::string &image_name); LLScrollListColumn* getColumn() { return mColumn; } void setHasResizableElement(BOOL resizable); BOOL canResize(); void enableResizeBar(BOOL enable); - LLString getLabel() { return mOrigLabel; } + std::string getLabel() { return mOrigLabel; } static void onSelectSort(LLUICtrl* ctrl, void* user_data); static void onClick(void* user_data); @@ -309,7 +309,7 @@ public: private: LLScrollListColumn* mColumn; LLResizeBar* mResizeBar; - LLString mOrigLabel; + std::string mOrigLabel; LLUIString mAscendingText; LLUIString mDescendingText; BOOL mShowSortOptions; @@ -340,7 +340,7 @@ public: // If width = 0, just use the width of the text. Otherwise override with // specified width in pixels. - void addColumn( const LLString& text, const LLFontGL* font, S32 width = 0 , U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, BOOL visible = TRUE) + void addColumn( const std::string& text, const LLFontGL* font, S32 width = 0 , U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, BOOL visible = TRUE) { mColumns.push_back( new LLScrollListText(text, font, width, font_style, font_alignment, LLColor4::black, FALSE, visible) ); } void addColumn( LLUIImagePtr icon, S32 width = 0 ) @@ -357,7 +357,7 @@ public: LLScrollListCell *getColumn(const S32 i) const { if (0 <= i && i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; } - LLString getContentsCSV() const; + std::string getContentsCSV() const; virtual void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding); @@ -377,7 +377,7 @@ private: class LLScrollListItemComment : public LLScrollListItem { public: - LLScrollListItemComment(const LLString& comment_string, const LLColor4& color); + LLScrollListItemComment(const std::string& comment_string, const LLColor4& color); /*virtual*/ void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding); private: @@ -397,7 +397,7 @@ class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler, { public: LLScrollListCtrl( - const LLString& name, + const std::string& name, const LLRect& rect, void (*commit_callback)(LLUICtrl*, void*), void* callback_userdata, @@ -416,14 +416,14 @@ public: // Sets an array of column descriptors void setColumnHeadings(LLSD headings); - void sortByColumn(U32 column, BOOL ascending); + void sortByColumnIndex(U32 column, BOOL ascending); // LLCtrlListInterface functions virtual S32 getItemCount() const; // Adds a single column descriptor: ["name" : string, "label" : string, "width" : integer, "relwidth" : integer ] virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM); virtual void clearColumns(); - virtual void setColumnLabel(const LLString& column, const LLString& label); + virtual void setColumnLabel(const std::string& column, const std::string& label); virtual LLScrollListColumn* getColumn(S32 index); virtual S32 getNumColumns() const { return mColumnsIndexed.size(); } @@ -435,7 +435,7 @@ public: // Simple add element. Takes a single array of: // [ "value" => value, "font" => font, "font-style" => style ] virtual void clearRows(); // clears all elements - virtual void sortByColumn(LLString name, BOOL ascending); + virtual void sortByColumn(const std::string& name, BOOL ascending); // These functions take and return an array of arrays of elements, as above virtual void setValue(const LLSD& value ); @@ -490,24 +490,24 @@ public: S32 getItemIndex( LLScrollListItem* item ) const; S32 getItemIndex( const LLUUID& item_id ) const; - LLScrollListItem* addCommentText( const LLString& comment_text, EAddPosition pos = ADD_BOTTOM); + LLScrollListItem* addCommentText( const std::string& comment_text, EAddPosition pos = ADD_BOTTOM); LLScrollListItem* addSeparator(EAddPosition pos); // "Simple" interface: use this when you're creating a list that contains only unique strings, only // one of which can be selected at a time. - virtual LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD()); + virtual LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD()); - BOOL selectItemByLabel( const LLString& item, BOOL case_sensitive = TRUE ); // FALSE if item not found - BOOL selectItemByPrefix(const LLString& target, BOOL case_sensitive = TRUE); + BOOL selectItemByLabel( const std::string& item, BOOL case_sensitive = TRUE ); // FALSE if item not found + BOOL selectItemByPrefix(const std::string& target, BOOL case_sensitive = TRUE); BOOL selectItemByPrefix(const LLWString& target, BOOL case_sensitive = TRUE); - const LLString getSelectedItemLabel(S32 column = 0) const; + const std::string getSelectedItemLabel(S32 column = 0) const; LLSD getSelectedValue(); // DEPRECATED: Use LLSD versions of addCommentText() and getSelectedValue(). // "StringUUID" interface: use this when you're creating a list that contains non-unique strings each of which // has an associated, unique UUID, and only one of which can be selected at a time. - LLScrollListItem* addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0); + LLScrollListItem* addStringUUIDItem(const std::string& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0); LLUUID getStringUUIDSelectedItem() const; LLScrollListItem* getFirstSelected() const; @@ -565,7 +565,7 @@ public: /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char); /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); - /*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); + /*virtual*/ BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect); /*virtual*/ void setEnabled(BOOL enabled); /*virtual*/ void setFocus( BOOL b ); /*virtual*/ void onFocusReceived(); @@ -716,7 +716,7 @@ private: BOOL mSorted; - typedef std::map<LLString, LLScrollListColumn> column_map_t; + typedef std::map<std::string, LLScrollListColumn> column_map_t; column_map_t mColumns; BOOL mDirty; diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp index d53e957c9c..28058d0005 100644 --- a/indra/llui/llslider.cpp +++ b/indra/llui/llslider.cpp @@ -46,7 +46,7 @@ static LLRegisterWidget<LLSlider> r2("volume_slider"); LLSlider::LLSlider( - const LLString& name, + const std::string& name, const LLRect& rect, void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata), void* callback_userdata, @@ -55,7 +55,7 @@ LLSlider::LLSlider( F32 max_value, F32 increment, BOOL volume, - const LLString& control_name) + const std::string& control_name) : LLUICtrl( name, rect, TRUE, on_commit_callback, callback_userdata, FOLLOWS_LEFT | FOLLOWS_TOP), @@ -303,7 +303,7 @@ LLXMLNodePtr LLSlider::getXML(bool save_children) const //static LLView* LLSlider::fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory) { - LLString name("slider_bar"); + std::string name("slider_bar"); node->getAttributeString("name", name); LLRect rect; diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h index ba0fac1465..a0fa543e98 100644 --- a/indra/llui/llslider.h +++ b/indra/llui/llslider.h @@ -41,7 +41,7 @@ class LLSlider : public LLUICtrl { public: LLSlider( - const LLString& name, + const std::string& name, const LLRect& rect, void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata), void* callback_userdata, @@ -50,7 +50,7 @@ public: F32 max_value, F32 increment, BOOL volume, //TODO: create a "volume" slider sub-class or just use image art, no? -MG - const LLString& control_name = LLString::null ); + const std::string& control_name = LLStringUtil::null ); virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory); diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp index a2b0718c50..41ca6f6319 100644 --- a/indra/llui/llsliderctrl.cpp +++ b/indra/llui/llsliderctrl.cpp @@ -53,8 +53,8 @@ const U32 MAX_STRING_LENGTH = 10; static LLRegisterWidget<LLSliderCtrl> r("slider"); -LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, - const LLString& label, +LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect, + const std::string& label, const LLFontGL* font, S32 label_width, S32 text_left, @@ -64,7 +64,7 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, void (*commit_callback)(LLUICtrl*, void*), void* callback_user_data, F32 initial_value, F32 min_value, F32 max_value, F32 increment, - const LLString& control_which) + const std::string& control_which) : LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data ), mFont(font), mShowText( show_text ), @@ -93,7 +93,7 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, label_width = font->getWidth(label); } LLRect label_rect( left, top, label_width, bottom ); - mLabelBox = new LLTextBox( "SliderCtrl Label", label_rect, label.c_str(), font ); + mLabelBox = new LLTextBox( std::string("SliderCtrl Label"), label_rect, label, font ); addChild(mLabelBox); } @@ -105,12 +105,11 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, S32 slider_left = label_width ? label_width + SLIDERCTRL_SPACING : 0; LLRect slider_rect( slider_left, top, slider_right, bottom ); - mSlider = new LLSlider( - "slider", - slider_rect, - LLSliderCtrl::onSliderCommit, this, - initial_value, min_value, max_value, increment, volume, - control_which ); + mSlider = new LLSlider(std::string("slider"), + slider_rect, + LLSliderCtrl::onSliderCommit, this, + initial_value, min_value, max_value, increment, volume, + control_which ); addChild( mSlider ); if( show_text ) @@ -118,11 +117,11 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, LLRect text_rect( text_left, top, getRect().getWidth(), bottom ); if( can_edit_text ) { - mEditor = new LLLineEditor( "SliderCtrl Editor", text_rect, - "", font, - MAX_STRING_LENGTH, - &LLSliderCtrl::onEditorCommit, NULL, NULL, this, - &LLLineEditor::prevalidateFloat ); + mEditor = new LLLineEditor( std::string("SliderCtrl Editor"), text_rect, + LLStringUtil::null, font, + MAX_STRING_LENGTH, + &LLSliderCtrl::onEditorCommit, NULL, NULL, this, + &LLLineEditor::prevalidateFloat ); mEditor->setFollowsLeft(); mEditor->setFollowsBottom(); mEditor->setFocusReceivedCallback( &LLSliderCtrl::onEditorGainFocus, this ); @@ -134,7 +133,7 @@ LLSliderCtrl::LLSliderCtrl(const LLString& name, const LLRect& rect, } else { - mTextBox = new LLTextBox( "SliderCtrl Text", text_rect, "", font); + mTextBox = new LLTextBox( std::string("SliderCtrl Text"), text_rect, LLStringUtil::null, font); mTextBox->setFollowsLeft(); mTextBox->setFollowsBottom(); addChild(mTextBox); @@ -162,7 +161,7 @@ void LLSliderCtrl::setValue(F32 v, BOOL from_event) updateText(); } -BOOL LLSliderCtrl::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLSliderCtrl::setLabelArg( const std::string& key, const LLStringExplicit& text ) { BOOL res = FALSE; if (mLabelBox) @@ -192,11 +191,11 @@ void LLSliderCtrl::clear() setValue(0.0f); if( mEditor ) { - mEditor->setText( LLString::null ); + mEditor->setText( LLStringUtil::null ); } if( mTextBox ) { - mTextBox->setText( LLString::null ); + mTextBox->setText( LLStringUtil::null ); } } @@ -210,8 +209,8 @@ void LLSliderCtrl::updateText() // Don't display very small negative values as -0.000 F32 displayed_value = (F32)(floor(getValueF32() * pow(10.0, (F64)mPrecision) + 0.5) / pow(10.0, (F64)mPrecision)); - LLString format = llformat("%%.%df", mPrecision); - LLString text = llformat(format.c_str(), displayed_value); + std::string format = llformat("%%.%df", mPrecision); + std::string text = llformat(format.c_str(), displayed_value); if( mEditor ) { mEditor->setText( text ); @@ -233,7 +232,7 @@ void LLSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata ) F32 val = self->mValue; F32 saved_val = self->mValue; - LLString text = self->mEditor->getText(); + std::string text = self->mEditor->getText(); if( LLLineEditor::postvalidateFloat( text ) ) { LLLocale locale(LLLocale::USER_LOCALE); @@ -450,10 +449,10 @@ LLXMLNodePtr LLSliderCtrl::getXML(bool save_children) const LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("slider"); + std::string name("slider"); node->getAttributeString("name", name); - LLString label; + std::string label; node->getAttributeString("label", label); LLRect rect; @@ -499,13 +498,13 @@ LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory { // calculate the size of the text box (log max_value is number of digits - 1 so plus 1) if ( max_value ) - text_left = font->getWidth("0") * ( static_cast < S32 > ( log10 ( max_value ) ) + precision + 1 ); + text_left = font->getWidth(std::string("0")) * ( static_cast < S32 > ( log10 ( max_value ) ) + precision + 1 ); if ( increment < 1.0f ) - text_left += font->getWidth("."); // (mostly) take account of decimal point in value + text_left += font->getWidth(std::string(".")); // (mostly) take account of decimal point in value if ( min_value < 0.0f || max_value < 0.0f ) - text_left += font->getWidth("-"); // (mostly) take account of minus sign + text_left += font->getWidth(std::string("-")); // (mostly) take account of minus sign // padding to make things look nicer text_left += 8; diff --git a/indra/llui/llsliderctrl.h b/indra/llui/llsliderctrl.h index 992fbafe38..4e7fe36bb4 100644 --- a/indra/llui/llsliderctrl.h +++ b/indra/llui/llsliderctrl.h @@ -48,9 +48,9 @@ const S32 SLIDERCTRL_HEIGHT = 16; class LLSliderCtrl : public LLUICtrl { public: - LLSliderCtrl(const LLString& name, + LLSliderCtrl(const std::string& name, const LLRect& rect, - const LLString& label, + const std::string& label, const LLFontGL* font, S32 slider_left, S32 text_left, @@ -60,7 +60,7 @@ public: void (*commit_callback)(LLUICtrl*, void*), void* callback_userdata, F32 initial_value, F32 min_value, F32 max_value, F32 increment, - const LLString& control_which = LLString::null ); + const std::string& control_which = LLStringUtil::null ); virtual ~LLSliderCtrl() {} // Children all cleaned up by default view destructor. @@ -72,7 +72,7 @@ public: virtual void setValue(const LLSD& value) { setValue((F32)value.asReal(), TRUE); } virtual LLSD getValue() const { return LLSD(getValueF32()); } - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); virtual void setMinValue(LLSD min_value) { setMinValue((F32)min_value.asReal()); } virtual void setMaxValue(LLSD max_value) { setMaxValue((F32)max_value.asReal()); } @@ -101,13 +101,13 @@ public: virtual void setTentative(BOOL b); // marks value as tentative virtual void onCommit(); // mark not tentative, then commit - virtual void setControlName(const LLString& control_name, LLView* context) + virtual void setControlName(const std::string& control_name, LLView* context) { LLView::setControlName(control_name, context); mSlider->setControlName(control_name, context); } - virtual LLString getControlName() const { return mSlider->getControlName(); } + virtual std::string getControlName() const { return mSlider->getControlName(); } static void onSliderCommit(LLUICtrl* caller, void* userdata); static void onSliderMouseDown(LLUICtrl* caller,void* userdata); diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index c577b35e19..e7fc10912e 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -53,11 +53,11 @@ const U32 MAX_STRING_LENGTH = 32; static LLRegisterWidget<LLSpinCtrl> r2("spinner"); -LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString& label, const LLFontGL* font, +LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font, void (*commit_callback)(LLUICtrl*, void*), void* callback_user_data, F32 initial_value, F32 min_value, F32 max_value, F32 increment, - const LLString& control_name, + const std::string& control_name, S32 label_width) : LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data, FOLLOWS_LEFT | FOLLOWS_TOP ), @@ -82,7 +82,7 @@ LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString if( !label.empty() ) { LLRect label_rect( 0, centered_top, label_width, centered_bottom ); - mLabelBox = new LLTextBox( "SpinCtrl Label", label_rect, label.c_str(), font ); + mLabelBox = new LLTextBox( std::string("SpinCtrl Label"), label_rect, label, font ); addChild(mLabelBox); btn_left += label_rect.mRight + SPINCTRL_SPACING; @@ -92,14 +92,13 @@ LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString // Spin buttons LLRect up_rect( btn_left, top, btn_right, top - SPINCTRL_BTN_HEIGHT ); - LLString out_id = "UIImgBtnSpinUpOutUUID"; - LLString in_id = "UIImgBtnSpinUpInUUID"; - mUpBtn = new LLButton( - "SpinCtrl Up", up_rect, - out_id, - in_id, - "", - &LLSpinCtrl::onUpBtn, this, LLFontGL::sSansSerif ); + std::string out_id = "UIImgBtnSpinUpOutUUID"; + std::string in_id = "UIImgBtnSpinUpInUUID"; + mUpBtn = new LLButton(std::string("SpinCtrl Up"), up_rect, + out_id, + in_id, + LLStringUtil::null, + &LLSpinCtrl::onUpBtn, this, LLFontGL::sSansSerif ); mUpBtn->setFollowsLeft(); mUpBtn->setFollowsBottom(); mUpBtn->setHeldDownCallback( &LLSpinCtrl::onUpBtn ); @@ -109,12 +108,11 @@ LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString LLRect down_rect( btn_left, top - SPINCTRL_BTN_HEIGHT, btn_right, bottom ); out_id = "UIImgBtnSpinDownOutUUID"; in_id = "UIImgBtnSpinDownInUUID"; - mDownBtn = new LLButton( - "SpinCtrl Down", down_rect, - out_id, - in_id, - "", - &LLSpinCtrl::onDownBtn, this, LLFontGL::sSansSerif ); + mDownBtn = new LLButton(std::string("SpinCtrl Down"), down_rect, + out_id, + in_id, + LLStringUtil::null, + &LLSpinCtrl::onDownBtn, this, LLFontGL::sSansSerif ); mDownBtn->setFollowsLeft(); mDownBtn->setFollowsBottom(); mDownBtn->setHeldDownCallback( &LLSpinCtrl::onDownBtn ); @@ -122,10 +120,10 @@ LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString addChild(mDownBtn); LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom ); - mEditor = new LLLineEditor( "SpinCtrl Editor", editor_rect, "", font, - MAX_STRING_LENGTH, - &LLSpinCtrl::onEditorCommit, NULL, NULL, this, - &LLLineEditor::prevalidateFloat ); + mEditor = new LLLineEditor( std::string("SpinCtrl Editor"), editor_rect, LLStringUtil::null, font, + MAX_STRING_LENGTH, + &LLSpinCtrl::onEditorCommit, NULL, NULL, this, + &LLLineEditor::prevalidateFloat ); mEditor->setFollowsLeft(); mEditor->setFollowsBottom(); mEditor->setFocusReceivedCallback( &LLSpinCtrl::onEditorGainFocus, this ); @@ -282,8 +280,8 @@ void LLSpinCtrl::updateEditor() // displayed_value = 0.f; // } - LLString format = llformat("%%.%df", mPrecision); - LLString text = llformat(format.c_str(), displayed_value); + std::string format = llformat("%%.%df", mPrecision); + std::string text = llformat(format.c_str(), displayed_value); mEditor->setText( text ); } @@ -294,7 +292,7 @@ void LLSpinCtrl::onEditorCommit( LLUICtrl* caller, void *userdata ) LLSpinCtrl* self = (LLSpinCtrl*) userdata; llassert( caller == self->mEditor ); - LLString text = self->mEditor->getText(); + std::string text = self->mEditor->getText(); if( LLLineEditor::postvalidateFloat( text ) ) { LLLocale locale(LLLocale::USER_LOCALE); @@ -493,10 +491,10 @@ LLXMLNodePtr LLSpinCtrl::getXML(bool save_children) const LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("spinner"); + std::string name("spinner"); node->getAttributeString("name", name); - LLString label; + std::string label; node->getAttributeString("label", label); LLRect rect; @@ -539,7 +537,7 @@ LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory * min_value, max_value, increment, - "", + LLStringUtil::null, label_width); spinner->setPrecision(precision); diff --git a/indra/llui/llspinctrl.h b/indra/llui/llspinctrl.h index eb9c60d442..1ed9462f00 100644 --- a/indra/llui/llspinctrl.h +++ b/indra/llui/llspinctrl.h @@ -52,13 +52,13 @@ class LLSpinCtrl : public LLUICtrl { public: - LLSpinCtrl(const LLString& name, const LLRect& rect, - const LLString& label, + LLSpinCtrl(const std::string& name, const LLRect& rect, + const std::string& label, const LLFontGL* font, void (*commit_callback)(LLUICtrl*, void*), void* callback_userdata, F32 initial_value, F32 min_value, F32 max_value, F32 increment, - const LLString& control_name = LLString(), + const std::string& control_name = std::string(), S32 label_width = SPINCTRL_DEFAULT_LABEL_WIDTH ); virtual ~LLSpinCtrl() {} // Children all cleaned up by default view destructor. diff --git a/indra/llui/llstyle.cpp b/indra/llui/llstyle.cpp index 38608745c1..0bdc208a9e 100644 --- a/indra/llui/llstyle.cpp +++ b/indra/llui/llstyle.cpp @@ -39,7 +39,7 @@ LLStyle::LLStyle() { - init(TRUE, LLColor4(0,0,0,1),""); + init(TRUE, LLColor4(0,0,0,1),LLStringUtil::null); } LLStyle::LLStyle(const LLStyle &style) @@ -62,21 +62,21 @@ LLStyle::LLStyle(const LLStyle &style) } else { - init(TRUE, LLColor4(0,0,0,1),""); + init(TRUE, LLColor4(0,0,0,1),LLStringUtil::null); } } -LLStyle::LLStyle(BOOL is_visible, const LLColor4 &color, const LLString& font_name) +LLStyle::LLStyle(BOOL is_visible, const LLColor4 &color, const std::string& font_name) { init(is_visible, color, font_name); } -void LLStyle::init(BOOL is_visible, const LLColor4 &color, const LLString& font_name) +void LLStyle::init(BOOL is_visible, const LLColor4 &color, const std::string& font_name) { mVisible = is_visible; mColor = color; setFontName(font_name); - setLinkHREF(""); + setLinkHREF(LLStringUtil::null); mItalic = FALSE; mBold = FALSE; mUnderline = FALSE; @@ -110,12 +110,12 @@ LLStyle &LLStyle::operator=(const LLStyle &rhs) } -void LLStyle::setFontName(const LLString& fontname) +void LLStyle::setFontName(const std::string& fontname) { mFontName = fontname; - LLString fontname_lc = fontname; - LLString::toLower(fontname_lc); + std::string fontname_lc = fontname; + LLStringUtil::toLower(fontname_lc); mFontID = LLFONT_OCRA; // default @@ -138,7 +138,7 @@ void LLStyle::setFontName(const LLString& fontname) } -void LLStyle::setLinkHREF(const LLString& href) +void LLStyle::setLinkHREF(const std::string& href) { mLink = href; } diff --git a/indra/llui/llstyle.h b/indra/llui/llstyle.h index 6896ee288f..ecb2d3c541 100644 --- a/indra/llui/llstyle.h +++ b/indra/llui/llstyle.h @@ -42,11 +42,11 @@ class LLStyle : public LLRefCount public: LLStyle(); LLStyle(const LLStyle &style); - LLStyle(BOOL is_visible, const LLColor4 &color, const LLString& font_name); + LLStyle(BOOL is_visible, const LLColor4 &color, const std::string& font_name); LLStyle &operator=(const LLStyle &rhs); - virtual void init (BOOL is_visible, const LLColor4 &color, const LLString& font_name); + virtual void init (BOOL is_visible, const LLColor4 &color, const std::string& font_name); virtual const LLColor4& getColor() const { return mColor; } virtual void setColor(const LLColor4 &color) { mColor = color; } @@ -54,12 +54,12 @@ public: virtual BOOL isVisible() const; virtual void setVisible(BOOL is_visible); - virtual const LLString& getFontString() const { return mFontName; } - virtual void setFontName(const LLString& fontname); + virtual const std::string& getFontString() const { return mFontName; } + virtual void setFontName(const std::string& fontname); virtual LLFONT_ID getFontID() const { return mFontID; } - virtual const LLString& getLinkHREF() const { return mLink; } - virtual void setLinkHREF(const LLString& href); + virtual const std::string& getLinkHREF() const { return mLink; } + virtual void setLinkHREF(const std::string& href); virtual BOOL isLink() const; virtual LLUIImagePtr getImage() const; @@ -105,9 +105,9 @@ protected: private: BOOL mVisible; LLColor4 mColor; - LLString mFontName; + std::string mFontName; LLFONT_ID mFontID; - LLString mLink; + std::string mLink; LLUIImagePtr mImagep; BOOL mIsEmbeddedItem; }; diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index ccf6e90161..488e62c61e 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -65,7 +65,7 @@ const S32 TABCNTRV_PAD = 0; static LLRegisterWidget<LLTabContainer> r("tab_container"); -LLTabContainer::LLTabContainer(const LLString& name, const LLRect& rect, TabPosition pos, +LLTabContainer::LLTabContainer(const std::string& name, const LLRect& rect, TabPosition pos, BOOL bordered, BOOL is_vertical ) : LLPanel(name, rect, bordered), @@ -121,7 +121,7 @@ void LLTabContainer::reshape(S32 width, S32 height, BOOL called_from_parent) } //virtual -LLView* LLTabContainer::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const +LLView* LLTabContainer::getChildView(const std::string& name, BOOL recurse, BOOL create_if_missing) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) @@ -460,7 +460,7 @@ BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask ) } // virtual -BOOL LLTabContainer::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect ) +BOOL LLTabContainer::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect ) { BOOL handled = LLPanel::handleToolTip( x, y, msg, sticky_rect ); if (!handled && getTabCount() > 0) @@ -604,7 +604,7 @@ LLXMLNodePtr LLTabContainer::getXML(bool save_children) const } // virtual -BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType type, void* cargo_data, EAcceptance *accept, LLString &tooltip) +BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType type, void* cargo_data, EAcceptance *accept, std::string &tooltip) { BOOL has_scroll_arrows = (getMaxScrollPos() > 0); @@ -656,7 +656,7 @@ BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDrag } void LLTabContainer::addTabPanel(LLPanel* child, - const LLString& label, + const std::string& label, BOOL select, void (*on_tab_clicked)(void*, bool), void* userdata, @@ -673,8 +673,8 @@ void LLTabContainer::addTabPanel(LLPanel* child, // Store the original label for possible xml export. child->setLabel(label); - LLString trimmed_label = label; - LLString::trim(trimmed_label); + std::string trimmed_label = label; + LLStringUtil::trim(trimmed_label); S32 button_width = mMinTabWidth; if (!mIsVertical) @@ -723,8 +723,8 @@ void LLTabContainer::addTabPanel(LLPanel* child, // Tab button LLRect btn_rect; // Note: btn_rect.mLeft is just a dummy. Will be updated in draw(). - LLString tab_img; - LLString tab_selected_img; + std::string tab_img; + std::string tab_selected_img; S32 tab_fudge = 1; // To make new tab art look better, nudge buttons up 1 pel if (mIsVertical) @@ -755,21 +755,21 @@ void LLTabContainer::addTabPanel(LLPanel* child, btn_rect.translate(0, -LLBUTTON_V_PAD-2); textbox = new LLTextBox(trimmed_label, btn_rect, trimmed_label, font); - btn = new LLButton("", LLRect(0,0,0,0)); + btn = new LLButton(LLStringUtil::null, LLRect(0,0,0,0)); } else { if (mIsVertical) { - btn = new LLButton("vert tab button", + btn = new LLButton(std::string("vert tab button"), btn_rect, - "", - "", - "", + LLStringUtil::null, + LLStringUtil::null, + LLStringUtil::null, &LLTabContainer::onTabBtn, NULL, font, trimmed_label, trimmed_label); - btn->setImages("tab_left.tga", "tab_left_selected.tga"); + btn->setImages(std::string("tab_left.tga"), std::string("tab_left_selected.tga")); btn->setScaleImage(TRUE); btn->setHAlign(LLFontGL::LEFT); btn->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT); @@ -781,13 +781,13 @@ void LLTabContainer::addTabPanel(LLPanel* child, } else { - LLString tooltip = trimmed_label; + std::string tooltip = trimmed_label; tooltip += "\nAlt-Left arrow for previous tab"; tooltip += "\nAlt-Right arrow for next tab"; - btn = new LLButton(LLString(child->getName()) + " tab", + btn = new LLButton(std::string(child->getName()) + " tab", btn_rect, - "", "", "", + LLStringUtil::null, LLStringUtil::null, LLStringUtil::null, &LLTabContainer::onTabBtn, NULL, // set userdata below font, trimmed_label, trimmed_label ); @@ -844,7 +844,7 @@ void LLTabContainer::addTabPanel(LLPanel* child, updateMaxScrollPos(); } -void LLTabContainer::addPlaceholder(LLPanel* child, const LLString& label) +void LLTabContainer::addPlaceholder(LLPanel* child, const std::string& label) { addTabPanel(child, label, FALSE, NULL, NULL, 0, TRUE); } @@ -1011,7 +1011,7 @@ S32 LLTabContainer::getIndexForPanel(LLPanel* panel) return -1; } -S32 LLTabContainer::getPanelIndexByTitle(const LLString& title) +S32 LLTabContainer::getPanelIndexByTitle(const std::string& title) { for (S32 index = 0 ; index < (S32)mTabList.size(); index++) { @@ -1023,7 +1023,7 @@ S32 LLTabContainer::getPanelIndexByTitle(const LLString& title) return -1; } -LLPanel *LLTabContainer::getPanelByName(const LLString& name) +LLPanel *LLTabContainer::getPanelByName(const std::string& name) { for (S32 index = 0 ; index < (S32)mTabList.size(); index++) { @@ -1037,7 +1037,7 @@ LLPanel *LLTabContainer::getPanelByName(const LLString& name) } // Change the name of the button for the current tab. -void LLTabContainer::setCurrentTabName(const LLString& name) +void LLTabContainer::setCurrentTabName(const std::string& name) { // Might not have a tab selected if (mCurrentTabIdx < 0) return; @@ -1211,7 +1211,7 @@ BOOL LLTabContainer::selectTab(S32 which) return is_visible; } -BOOL LLTabContainer::selectTabByName(const LLString& name) +BOOL LLTabContainer::selectTabByName(const std::string& name) { LLPanel* panel = getPanelByName(name); if (!panel) @@ -1275,7 +1275,7 @@ void LLTabContainer::setTabImage(LLPanel* child, std::string image_name, const L } } -void LLTabContainer::setTitle(const LLString& title) +void LLTabContainer::setTitle(const std::string& title) { if (mTitleBox) { @@ -1283,14 +1283,14 @@ void LLTabContainer::setTitle(const LLString& title) } } -const LLString LLTabContainer::getPanelTitle(S32 index) +const std::string LLTabContainer::getPanelTitle(S32 index) { if (index >= 0 && index < (S32)mTabList.size()) { LLButton* tab_button = mTabList[index]->mButton; return tab_button->getLabelSelected(); } - return LLString::null; + return LLStringUtil::null; } void LLTabContainer::setTopBorderHeight(S32 height) @@ -1328,7 +1328,7 @@ void LLTabContainer::setRightTabBtnOffset(S32 offset) updateMaxScrollPos(); } -void LLTabContainer::setPanelTitle(S32 index, const LLString& title) +void LLTabContainer::setPanelTitle(S32 index, const std::string& title) { if (index >= 0 && index < getTabCount()) { @@ -1434,7 +1434,7 @@ void LLTabContainer::onPrevBtnHeld( void* userdata ) // static LLView* LLTabContainer::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("tab_container"); + std::string name("tab_container"); node->getAttributeString("name", name); // Figure out if we are creating a vertical or horizontal tab container. @@ -1442,9 +1442,9 @@ LLView* LLTabContainer::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto LLTabContainer::TabPosition tab_position = LLTabContainer::TOP; if (node->hasAttribute("tab_position")) { - LLString tab_position_string; + std::string tab_position_string; node->getAttributeString("tab_position", tab_position_string); - LLString::toLower(tab_position_string); + LLStringUtil::toLower(tab_position_string); if ("top" == tab_position_string) { @@ -1506,7 +1506,7 @@ LLView* LLTabContainer::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto if (control && control->isPanel()) { LLPanel* panelp = (LLPanel*)control; - LLString label; + std::string label; child->getAttributeString("label", label); if (label.empty()) { @@ -1514,7 +1514,7 @@ LLView* LLTabContainer::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto } BOOL placeholder = FALSE; child->getAttributeBOOL("placeholder", placeholder); - tab_container->addTabPanel(panelp, label.c_str(), false, + tab_container->addTabPanel(panelp, label, false, NULL, NULL, 0, placeholder); } } @@ -1538,8 +1538,8 @@ void LLTabContainer::initButtons() return; // Don't have a rect yet or already got called } - LLString out_id; - LLString in_id; + std::string out_id; + std::string in_id; if (mIsVertical) { @@ -1555,16 +1555,16 @@ void LLTabContainer::initButtons() out_id = "UIImgBtnScrollUpOutUUID"; in_id = "UIImgBtnScrollUpInUUID"; - mPrevArrowBtn = new LLButton("Up Arrow", up_arrow_btn_rect, - out_id, in_id, "", + mPrevArrowBtn = new LLButton(std::string("Up Arrow"), up_arrow_btn_rect, + out_id, in_id, LLStringUtil::null, &onPrevBtn, this, NULL ); mPrevArrowBtn->setFollowsTop(); mPrevArrowBtn->setFollowsLeft(); out_id = "UIImgBtnScrollDownOutUUID"; in_id = "UIImgBtnScrollDownInUUID"; - mNextArrowBtn = new LLButton("Down Arrow", down_arrow_btn_rect, - out_id, in_id, "", + mNextArrowBtn = new LLButton(std::string("Down Arrow"), down_arrow_btn_rect, + out_id, in_id, LLStringUtil::null, &onNextBtn, this, NULL ); mNextArrowBtn->setFollowsBottom(); mNextArrowBtn->setFollowsLeft(); @@ -1603,31 +1603,31 @@ void LLTabContainer::initButtons() out_id = "UIImgBtnJumpLeftOutUUID"; in_id = "UIImgBtnJumpLeftInUUID"; - mJumpPrevArrowBtn = new LLButton("Jump Left Arrow", jump_left_arrow_btn_rect, - out_id, in_id, "", + mJumpPrevArrowBtn = new LLButton(std::string("Jump Left Arrow"), jump_left_arrow_btn_rect, + out_id, in_id, LLStringUtil::null, &LLTabContainer::onJumpFirstBtn, this, LLFontGL::sSansSerif ); mJumpPrevArrowBtn->setFollowsLeft(); out_id = "UIImgBtnScrollLeftOutUUID"; in_id = "UIImgBtnScrollLeftInUUID"; - mPrevArrowBtn = new LLButton("Left Arrow", left_arrow_btn_rect, - out_id, in_id, "", + mPrevArrowBtn = new LLButton(std::string("Left Arrow"), left_arrow_btn_rect, + out_id, in_id, LLStringUtil::null, &LLTabContainer::onPrevBtn, this, LLFontGL::sSansSerif ); mPrevArrowBtn->setHeldDownCallback(onPrevBtnHeld); mPrevArrowBtn->setFollowsLeft(); out_id = "UIImgBtnJumpRightOutUUID"; in_id = "UIImgBtnJumpRightInUUID"; - mJumpNextArrowBtn = new LLButton("Jump Right Arrow", jump_right_arrow_btn_rect, - out_id, in_id, "", + mJumpNextArrowBtn = new LLButton(std::string("Jump Right Arrow"), jump_right_arrow_btn_rect, + out_id, in_id, LLStringUtil::null, &LLTabContainer::onJumpLastBtn, this, LLFontGL::sSansSerif); mJumpNextArrowBtn->setFollowsRight(); out_id = "UIImgBtnScrollRightOutUUID"; in_id = "UIImgBtnScrollRightInUUID"; - mNextArrowBtn = new LLButton("Right Arrow", right_arrow_btn_rect, - out_id, in_id, "", + mNextArrowBtn = new LLButton(std::string("Right Arrow"), right_arrow_btn_rect, + out_id, in_id, LLStringUtil::null, &LLTabContainer::onNextBtn, this, LLFontGL::sSansSerif); mNextArrowBtn->setFollowsRight(); diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index f4da5e5aed..eef5a70a3b 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -55,7 +55,7 @@ public: RIGHT_OF_CURRENT } eInsertionPoint; - LLTabContainer( const LLString& name, const LLRect& rect, TabPosition pos, + LLTabContainer( const std::string& name, const LLRect& rect, TabPosition pos, BOOL bordered, BOOL is_vertical); /*virtual*/ ~LLTabContainer(); @@ -68,23 +68,23 @@ public: /*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask ); /*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask ); /*virtual*/ BOOL handleMouseUp( S32 x, S32 y, MASK mask ); - /*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect ); + /*virtual*/ BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect ); /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType type, void* cargo_data, - EAcceptance* accept, LLString& tooltip); + EAcceptance* accept, std::string& tooltip); /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; - /*virtual*/ LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; + /*virtual*/ LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; void addTabPanel(LLPanel* child, - const LLString& label, + const std::string& label, BOOL select = FALSE, void (*on_tab_clicked)(void*, bool) = NULL, void* userdata = NULL, S32 indent = 0, BOOL placeholder = FALSE, eInsertionPoint insertion_point = END); - void addPlaceholder(LLPanel* child, const LLString& label); + void addPlaceholder(LLPanel* child, const std::string& label); void removeTabPanel( LLPanel* child ); void lockTabs(S32 num_tabs = 0); void unlockTabs(); @@ -96,9 +96,9 @@ public: S32 getTabCount(); LLPanel* getPanelByIndex(S32 index); S32 getIndexForPanel(LLPanel* panel); - S32 getPanelIndexByTitle(const LLString& title); - LLPanel* getPanelByName(const LLString& name); - void setCurrentTabName(const LLString& name); + S32 getPanelIndexByTitle(const std::string& title); + LLPanel* getPanelByName(const std::string& name); + void setCurrentTabName(const std::string& name); void selectFirstTab(); void selectLastTab(); @@ -106,13 +106,13 @@ public: void selectPrevTab(); BOOL selectTabPanel( LLPanel* child ); BOOL selectTab(S32 which); - BOOL selectTabByName(const LLString& title); + BOOL selectTabByName(const std::string& title); BOOL getTabPanelFlashing(LLPanel* child); void setTabPanelFlashing(LLPanel* child, BOOL state); void setTabImage(LLPanel* child, std::string img_name, const LLColor4& color = LLColor4::white); - void setTitle( const LLString& title ); - const LLString getPanelTitle(S32 index); + void setTitle( const std::string& title ); + const std::string getPanelTitle(S32 index); void setTopBorderHeight(S32 height); S32 getTopBorderHeight() const; @@ -121,7 +121,7 @@ public: void setTabUserData(LLPanel* tab, void* userdata); void setRightTabBtnOffset( S32 offset ); - void setPanelTitle(S32 index, const LLString& title); + void setPanelTitle(S32 index, const std::string& title); TabPosition getTabPosition() const { return mTabPosition; } void setMinTabWidth(S32 width) { mMinTabWidth = width; } diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 1c3c8329e6..ac2f2a64a3 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -36,7 +36,7 @@ static LLRegisterWidget<LLTextBox> r("text"); -LLTextBox::LLTextBox(const LLString& name, const LLRect& rect, const LLString& text, +LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::string& text, const LLFontGL* font, BOOL mouse_opaque) : LLUICtrl(name, rect, mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP ), mFontGL(font ? font : LLFontGL::sSansSerifSmall), @@ -63,7 +63,7 @@ LLTextBox::LLTextBox(const LLString& name, const LLRect& rect, const LLString& t setTabStop(FALSE); } -LLTextBox::LLTextBox(const LLString& name, const LLString& text, F32 max_width, +LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_width, const LLFontGL* font, BOOL mouse_opaque) : LLUICtrl(name, LLRect(0, 0, 1, 1), mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), mFontGL(font ? font : LLFontGL::sSansSerifSmall), @@ -91,7 +91,7 @@ LLTextBox::LLTextBox(const LLString& name, const LLString& text, F32 max_width, setTabStop(FALSE); } -LLTextBox::LLTextBox(const LLString& name_and_label, const LLRect& rect) : +LLTextBox::LLTextBox(const std::string& name_and_label, const LLRect& rect) : LLUICtrl(name_and_label, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), mFontGL(LLFontGL::sSansSerifSmall), mTextColor(LLUI::sColorsGroup->getColor("LabelTextColor")), @@ -113,7 +113,7 @@ LLTextBox::LLTextBox(const LLString& name_and_label, const LLRect& rect) : setTabStop(FALSE); } -LLTextBox::LLTextBox(const LLString& name_and_label) : +LLTextBox::LLTextBox(const std::string& name_and_label) : LLUICtrl(name_and_label, LLRect(0, 0, 1, 1), TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), mFontGL(LLFontGL::sSansSerifSmall), mTextColor(LLUI::sColorsGroup->getColor("LabelTextColor")), @@ -211,15 +211,15 @@ void LLTextBox::setLineLengths() { mLineLengthList.clear(); - LLString::size_type cur = 0; - LLString::size_type len = mText.getWString().size(); + std::string::size_type cur = 0; + std::string::size_type len = mText.getWString().size(); while (cur < len) { - LLString::size_type end = mText.getWString().find('\n', cur); - LLString::size_type runLen; + std::string::size_type end = mText.getWString().find('\n', cur); + std::string::size_type runLen; - if (end == LLString::npos) + if (end == std::string::npos) { runLen = len - cur; cur = len; @@ -276,7 +276,7 @@ void LLTextBox::setWrappedText(const LLStringExplicit& in_text, F32 max_width) } } - LLString final_text = wstring_to_utf8str(final_wtext); + std::string final_text = wstring_to_utf8str(final_wtext); setText(final_text); } @@ -316,7 +316,7 @@ S32 LLTextBox::getTextPixelHeight() } -BOOL LLTextBox::setTextArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLTextBox::setTextArg( const std::string& key, const LLStringExplicit& text ) { mText.setArg(key, text); setLineLengths(); @@ -451,11 +451,11 @@ LLXMLNodePtr LLTextBox::getXML(bool save_children) const // static LLView* LLTextBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("text_box"); + std::string name("text_box"); node->getAttributeString("name", name); LLFontGL* font = LLView::selectFont(node); - LLString text = node->getTextContents(); + std::string text = node->getTextContents(); LLTextBox* text_box = new LLTextBox(name, LLRect(), @@ -469,7 +469,7 @@ LLView* LLTextBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f text_box->initFromXML(node, parent); - LLString font_style; + std::string font_style; if (node->getAttributeString("font-style", font_style)) { text_box->mFontStyle = LLFontGL::getStyleFromString(font_style); diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index 91d47795a5..b1e8e0b7c6 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -45,16 +45,16 @@ public: // By default, follows top and left and is mouse-opaque. // If no text, text = name. // If no font, uses default system font. - LLTextBox(const LLString& name, const LLRect& rect, const LLString& text, + LLTextBox(const std::string& name, const LLRect& rect, const std::string& text, const LLFontGL* font = NULL, BOOL mouse_opaque = TRUE ); // Construct a textbox which handles word wrapping for us. - LLTextBox(const LLString& name, const LLString& text, F32 max_width = 200, + LLTextBox(const std::string& name, const std::string& text, F32 max_width = 200, const LLFontGL* font = NULL, BOOL mouse_opaque = TRUE ); // "Simple" constructors for text boxes that have the same name and label *TO BE DEPRECATED* - LLTextBox(const LLString& name_and_label, const LLRect& rect); - LLTextBox(const LLString& name_and_label); + LLTextBox(const std::string& name_and_label, const LLRect& rect); + LLTextBox(const std::string& name_and_label); virtual ~LLTextBox() {} @@ -95,13 +95,13 @@ public: void reshapeToFitText(); - const LLString& getText() const { return mText.getString(); } + const std::string& getText() const { return mText.getString(); } S32 getTextPixelWidth(); S32 getTextPixelHeight(); virtual void setValue(const LLSD& value ) { setText(value.asString()); } virtual LLSD getValue() const { return LLSD(getText()); } - virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); private: void setLineLengths(); diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 06df996088..a2063358bd 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -86,7 +86,7 @@ const S32 PREEDIT_STANDOUT_POSITION = 2; const S32 PREEDIT_STANDOUT_THICKNESS = 2; LLColor4 LLTextEditor::mLinkColor = LLColor4::blue; -void (* LLTextEditor::mURLcallback)(const char*) = NULL; +void (* LLTextEditor::mURLcallback)(const std::string&) = NULL; bool (* LLTextEditor::mSecondlifeURLcallback)(const std::string&) = NULL; bool (* LLTextEditor::mSecondlifeURLcallbackRightClick)(const std::string&) = NULL; @@ -104,7 +104,7 @@ public: virtual BOOL execute( LLTextEditor* editor, S32* delta ) { *delta = insert(editor, getPosition(), mWString ); - LLWString::truncate(mWString, *delta); + LLWStringUtil::truncate(mWString, *delta); //mWString = wstring_truncate(mWString, *delta); return (*delta != 0); } @@ -142,7 +142,7 @@ public: virtual BOOL execute( LLTextEditor* editor, S32* delta ) { *delta = insert(editor, getPosition(), mWString); - LLWString::truncate(mWString, *delta); + LLWStringUtil::truncate(mWString, *delta); //mWString = wstring_truncate(mWString, *delta); return (*delta != 0); } @@ -240,10 +240,10 @@ private: /////////////////////////////////////////////////////////////////// LLTextEditor::LLTextEditor( - const LLString& name, + const std::string& name, const LLRect& rect, S32 max_length, // In bytes - const LLString &default_text, + const std::string &default_text, const LLFontGL* font, BOOL allow_embedded_items) : @@ -308,7 +308,7 @@ LLTextEditor::LLTextEditor( SCROLLBAR_SIZE, getRect().getHeight() - 1); S32 lines_in_doc = getLineCount(); - mScrollbar = new LLScrollbar( "Scrollbar", scroll_rect, + mScrollbar = new LLScrollbar( std::string("Scrollbar"), scroll_rect, LLScrollbar::VERTICAL, lines_in_doc, 0, @@ -322,7 +322,7 @@ LLTextEditor::LLTextEditor( mScrollbar->setOnScrollEndCallback(mOnScrollEndCallback, mOnScrollEndData); addChild(mScrollbar); - mBorder = new LLViewBorder( "text ed border", LLRect(0, getRect().getHeight(), getRect().getWidth(), 0), LLViewBorder::BEVEL_IN, LLViewBorder::STYLE_LINE, UI_TEXTEDITOR_BORDER ); + mBorder = new LLViewBorder( std::string("text ed border"), LLRect(0, getRect().getHeight(), getRect().getWidth(), 0), LLViewBorder::BEVEL_IN, LLViewBorder::STYLE_LINE, UI_TEXTEDITOR_BORDER ); addChild( mBorder ); appendText(default_text, FALSE, FALSE); @@ -330,7 +330,7 @@ LLTextEditor::LLTextEditor( resetDirty(); // Update saved text state mParseHTML=FALSE; - mHTML=""; + mHTML.clear(); } @@ -493,7 +493,7 @@ BOOL LLTextEditor::truncate() void LLTextEditor::setText(const LLStringExplicit &utf8str) { - // LLString::removeCRLF(utf8str); + // LLStringUtil::removeCRLF(utf8str); mUTF8Text = utf8str_removeCRLF(utf8str); // mUTF8Text = utf8str; mWText = utf8str_to_wstring(mUTF8Text); @@ -535,7 +535,7 @@ void LLTextEditor::setValue(const LLSD& value) setText(value.asString()); } -const LLString& LLTextEditor::getText() const +const std::string& LLTextEditor::getText() const { if (!mTextIsUpToDate) { @@ -588,7 +588,7 @@ void LLTextEditor::setHideScrollbarForShortDocs(BOOL b) } } -void LLTextEditor::selectNext(const LLString& search_text_in, BOOL case_insensitive, BOOL wrap) +void LLTextEditor::selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap) { if (search_text_in.empty()) { @@ -599,8 +599,8 @@ void LLTextEditor::selectNext(const LLString& search_text_in, BOOL case_insensit LLWString search_text = utf8str_to_wstring(search_text_in); if (case_insensitive) { - LLWString::toLower(text); - LLWString::toLower(search_text); + LLWStringUtil::toLower(text); + LLWStringUtil::toLower(search_text); } if (mIsSelecting) @@ -638,7 +638,7 @@ void LLTextEditor::selectNext(const LLString& search_text_in, BOOL case_insensit mSelectionStart = llmin((S32)getLength(), (S32)(mCursorPos + search_text.size())); } -BOOL LLTextEditor::replaceText(const LLString& search_text_in, const LLString& replace_text, +BOOL LLTextEditor::replaceText(const std::string& search_text_in, const std::string& replace_text, BOOL case_insensitive, BOOL wrap) { BOOL replaced = FALSE; @@ -656,8 +656,8 @@ BOOL LLTextEditor::replaceText(const LLString& search_text_in, const LLString& r if (case_insensitive) { - LLWString::toLower(selected_text); - LLWString::toLower(search_text); + LLWStringUtil::toLower(selected_text); + LLWStringUtil::toLower(search_text); } if (selected_text == search_text) @@ -671,7 +671,7 @@ BOOL LLTextEditor::replaceText(const LLString& search_text_in, const LLString& r return replaced; } -void LLTextEditor::replaceTextAll(const LLString& search_text, const LLString& replace_text, BOOL case_insensitive) +void LLTextEditor::replaceTextAll(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive) { S32 cur_pos = mScrollbar->getDocPos(); @@ -1058,7 +1058,7 @@ void LLTextEditor::selectAll() } -BOOL LLTextEditor::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) +BOOL LLTextEditor::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) { for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) @@ -1389,7 +1389,7 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) BOOL LLTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { *accept = ACCEPT_NO; @@ -1876,7 +1876,7 @@ void LLTextEditor::paste() // Clean up string (replace tabs and remove characters that our fonts don't support). LLWString clean_string(paste); - LLWString::replaceTabsWithSpaces(clean_string, SPACES_PER_TAB); + LLWStringUtil::replaceTabsWithSpaces(clean_string, SPACES_PER_TAB); if( mAllowEmbeddedItems ) { const llwchar LF = 10; @@ -2567,7 +2567,7 @@ void LLTextEditor::drawSelectionBackground() { // extend selection slightly beyond end of line // to indicate selection of newline character (use "n" character to determine width) - const LLWString nstr(utf8str_to_wstring(LLString("n"))); + const LLWString nstr(utf8str_to_wstring(std::string("n"))); line_endings.push(mTextRect.mLeft + mGLFont->getWidth(line, 0, line_end - line_start, mAllowEmbeddedItems) + mGLFont->getWidth(nstr.c_str())); } @@ -2704,7 +2704,7 @@ void LLTextEditor::drawCursor() if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode() && !hasSelection()) { cursor_left += CURSOR_THICKNESS; - const LLWString space(utf8str_to_wstring(LLString(" "))); + const LLWString space(utf8str_to_wstring(std::string(" "))); F32 spacew = mGLFont->getWidthF32(space.c_str()); if (mCursorPos == line_end) { @@ -3080,7 +3080,7 @@ void LLTextEditor::onTabInto() // virtual void LLTextEditor::clear() { - setText(LLString::null); + setText(LLStringUtil::null); } // Start or stop the editor from accepting text-editing keystrokes @@ -3408,7 +3408,7 @@ void LLTextEditor::autoIndent() } // Inserts new text at the cursor position -void LLTextEditor::insertText(const LLString &new_text) +void LLTextEditor::insertText(const std::string &new_text) { BOOL enabled = getEnabled(); setEnabled( TRUE ); @@ -3428,11 +3428,11 @@ void LLTextEditor::insertText(const LLString &new_text) } -void LLTextEditor::appendColoredText(const LLString &new_text, +void LLTextEditor::appendColoredText(const std::string &new_text, bool allow_undo, bool prepend_newline, const LLColor4 &color, - const LLString& font_name) + const std::string& font_name) { LLStyleSP style(new LLStyle); style->setVisible(true); @@ -3441,7 +3441,7 @@ void LLTextEditor::appendColoredText(const LLString &new_text, appendStyledText(new_text, allow_undo, prepend_newline, &style); } -void LLTextEditor::appendStyledText(const LLString &new_text, +void LLTextEditor::appendStyledText(const std::string &new_text, bool allow_undo, bool prepend_newline, const LLStyleSP *stylep) @@ -3450,7 +3450,7 @@ void LLTextEditor::appendStyledText(const LLString &new_text, { S32 start=0,end=0; - LLString text = new_text; + std::string text = new_text; while ( findHTML(text, &start, &end) ) { LLStyleSP html(new LLStyle); @@ -3484,7 +3484,7 @@ void LLTextEditor::appendStyledText(const LLString &new_text, } // Appends new text to end of document -void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool prepend_newline, +void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool prepend_newline, const LLStyleSP *stylep) { // Save old state @@ -3504,7 +3504,7 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr if (getLength() != 0 && prepend_newline) { - LLString final_text = "\n"; + std::string final_text = "\n"; final_text += new_text; append(utf8str_to_wstring(final_text), TRUE); } @@ -3685,20 +3685,18 @@ void LLTextEditor::updateTextRect() getRect().getHeight() - 2 * UI_TEXTEDITOR_BORDER - UI_TEXTEDITOR_V_PAD_TOP ); } -void LLTextEditor::loadKeywords(const LLString& filename, - const LLDynamicArray<const char*>& funcs, - const LLDynamicArray<const char*>& tooltips, +void LLTextEditor::loadKeywords(const std::string& filename, + const std::vector<std::string>& funcs, + const std::vector<std::string>& tooltips, const LLColor3& color) { if(mKeywords.loadFromFile(filename)) { - S32 count = funcs.count(); - LLString name; + S32 count = llmin(funcs.size(), tooltips.size()); for(S32 i = 0; i < count; i++) { - name = funcs.get(i); - name = utf8str_trim(name); - mKeywords.addToken(LLKeywordToken::WORD, name.c_str(), color, tooltips.get(i) ); + std::string name = utf8str_trim(funcs[i]); + mKeywords.addToken(LLKeywordToken::WORD, name, color, tooltips[i] ); } mKeywords.findSegments( &mSegments, mWText, mDefaultColor ); @@ -3840,9 +3838,9 @@ BOOL LLTextEditor::handleMouseUpOverSegment(S32 x, S32 y, MASK mask) //Special handling for slurls if ( (mSecondlifeURLcallback!=NULL) && !(*mSecondlifeURLcallback)(mHTML) ) { - if (mURLcallback!=NULL) (*mURLcallback)(mHTML.c_str()); + if (mURLcallback!=NULL) (*mURLcallback)(mHTML); } - mHTML=""; + mHTML.clear(); } } @@ -3894,7 +3892,7 @@ void LLTextEditor::setOnScrollEndCallback(void (*callback)(void*), void* userdat /////////////////////////////////////////////////////////////////// // Hack for Notecards -BOOL LLTextEditor::importBuffer(const LLString& buffer ) +BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) { std::istringstream instream(buffer); @@ -3983,7 +3981,7 @@ BOOL LLTextEditor::importBuffer(const LLString& buffer ) return success; } -BOOL LLTextEditor::exportBuffer(LLString &buffer ) +BOOL LLTextEditor::exportBuffer(std::string &buffer ) { std::ostringstream outstream(buffer); @@ -4016,7 +4014,7 @@ LLTextSegment::LLTextSegment( const LLStyleSP& style, S32 start, S32 end ) : { } LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end, BOOL is_visible) : - mStyle(new LLStyle(is_visible,color,"")), + mStyle(new LLStyle(is_visible,color,LLStringUtil::null)), mStart( start), mEnd( end ), mToken(NULL), @@ -4024,7 +4022,7 @@ LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end, BOOL is { } LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end ) : - mStyle(new LLStyle(TRUE, color,"" )), + mStyle(new LLStyle(TRUE, color,LLStringUtil::null )), mStart( start), mEnd( end ), mToken(NULL), @@ -4032,7 +4030,7 @@ LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end ) : { } LLTextSegment::LLTextSegment( const LLColor3& color, S32 start, S32 end ) : - mStyle(new LLStyle(TRUE, color,"" )), + mStyle(new LLStyle(TRUE, color,LLStringUtil::null )), mStart( start), mEnd( end ), mToken(NULL), @@ -4040,7 +4038,7 @@ LLTextSegment::LLTextSegment( const LLColor3& color, S32 start, S32 end ) : { } -BOOL LLTextSegment::getToolTip(LLString& msg) const +BOOL LLTextSegment::getToolTip(std::string& msg) const { if (mToken && !mToken->getToolTip().empty()) { @@ -4095,7 +4093,7 @@ LLXMLNodePtr LLTextEditor::getXML(bool save_children) const // static LLView* LLTextEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("text_editor"); + std::string name("text_editor"); node->getAttributeString("name", name); LLRect rect; @@ -4109,7 +4107,7 @@ LLView* LLTextEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory LLFontGL* font = LLView::selectFont(node); - LLString text = node->getTextContents().substr(0, max_text_length - 1); + std::string text = node->getTextContents().substr(0, max_text_length - 1); LLTextEditor* text_editor = new LLTextEditor(name, rect, @@ -4161,10 +4159,10 @@ void LLTextEditor::setTextEditorParameters(LLXMLNodePtr node) } /////////////////////////////////////////////////////////////////// -S32 LLTextEditor::findHTMLToken(const LLString &line, S32 pos, BOOL reverse) const +S32 LLTextEditor::findHTMLToken(const std::string &line, S32 pos, BOOL reverse) const { - LLString openers=" \t('\"[{<>"; - LLString closers=" \t)'\"]}><;"; + std::string openers=" \t('\"[{<>"; + std::string closers=" \t)'\"]}><;"; S32 m2; S32 retval; @@ -4198,7 +4196,7 @@ S32 LLTextEditor::findHTMLToken(const LLString &line, S32 pos, BOOL reverse) con return retval; } -BOOL LLTextEditor::findHTML(const LLString &line, S32 *begin, S32 *end) const +BOOL LLTextEditor::findHTML(const std::string &line, S32 *begin, S32 *end) const { S32 m1,m2,m3; @@ -4215,7 +4213,7 @@ BOOL LLTextEditor::findHTML(const LLString &line, S32 *begin, S32 *end) const m2 = line.substr(*begin,(m1 - *begin)).find("http"); m3 = line.substr(*begin,(m1 - *begin)).find("secondlife"); - LLString badneighbors=".,<>?';\"][}{=-+_)(*&^%$#@!~`\t\r\n\\"; + std::string badneighbors=".,<>?';\"][}{=-+_)(*&^%$#@!~`\t\r\n\\"; if (m2 >= 0 || m3>=0) { @@ -4241,7 +4239,7 @@ BOOL LLTextEditor::findHTML(const LLString &line, S32 *begin, S32 *end) const if ( ( *end - m1 ) > 2 && m1 > *begin) { - LLString badneighbors=".,<>/?';\"][}{=-+_)(*&^%$#@!~`"; + std::string badneighbors=".,<>/?';\"][}{=-+_)(*&^%$#@!~`"; m2 = badneighbors.find(line.substr(m1+1,1)); m3 = badneighbors.find(line.substr(m1-1,1)); if (m3<0 && m2<0) @@ -4257,8 +4255,8 @@ BOOL LLTextEditor::findHTML(const LLString &line, S32 *begin, S32 *end) const { S32 strpos, strpos2; - LLString url = line.substr(*begin,*end - *begin); - LLString slurlID = "slurl.com/secondlife/"; + std::string url = line.substr(*begin,*end - *begin); + std::string slurlID = "slurl.com/secondlife/"; strpos = url.find(slurlID); if (strpos < 0) diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index af2dbcfd5f..e261d13872 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -62,10 +62,10 @@ public: static const llwchar LAST_EMBEDDED_CHAR = 0x10ffff; static const S32 MAX_EMBEDDED_ITEMS = LAST_EMBEDDED_CHAR - FIRST_EMBEDDED_CHAR + 1; - LLTextEditor(const LLString& name, + LLTextEditor(const std::string& name, const LLRect& rect, S32 max_length, - const LLString &default_text, + const std::string &default_text, const LLFontGL* glfont = NULL, BOOL allow_embedded_items = FALSE); @@ -85,10 +85,10 @@ public: virtual BOOL handleKeyHere(KEY key, MASK mask ); virtual BOOL handleUnicodeCharHere(llwchar uni_char); - virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); + virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, - EAcceptance *accept, LLString& tooltip_msg); + EAcceptance *accept, std::string& tooltip_msg); virtual void onMouseCaptureLost(); // view overrides @@ -123,9 +123,9 @@ public: virtual void deselect(); virtual BOOL canDeselect() const; - void selectNext(const LLString& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); - BOOL replaceText(const LLString& search_text, const LLString& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); - void replaceTextAll(const LLString& search_text, const LLString& replace_text, BOOL case_insensitive); + void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); + BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); + void replaceTextAll(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive); // Undo/redo stack void blockUndo(); @@ -136,17 +136,17 @@ public: BOOL allowsEmbeddedItems() const { return mAllowEmbeddedItems; } // inserts text at cursor - void insertText(const LLString &text); + void insertText(const std::string &text); // appends text at end - void appendText(const LLString &wtext, bool allow_undo, bool prepend_newline, + void appendText(const std::string &wtext, bool allow_undo, bool prepend_newline, const LLStyleSP *stylep = NULL); - void appendColoredText(const LLString &wtext, bool allow_undo, + void appendColoredText(const std::string &wtext, bool allow_undo, bool prepend_newline, const LLColor4 &color, - const LLString& font_name = LLString::null); + const std::string& font_name = LLStringUtil::null); // if styled text starts a line, you need to prepend a newline. - void appendStyledText(const LLString &new_text, bool allow_undo, + void appendStyledText(const std::string &new_text, bool allow_undo, bool prepend_newline, const LLStyleSP *stylep = NULL); @@ -162,10 +162,9 @@ public: void getCurrentLineAndColumn( S32* line, S32* col, BOOL include_wordwrap ); - // Keywords support - void loadKeywords(const LLString& filename, - const LLDynamicArray<const char*>& funcs, - const LLDynamicArray<const char*>& tooltips, + void loadKeywords(const std::string& filename, + const std::vector<std::string>& funcs, + const std::vector<std::string>& tooltips, const LLColor3& func_color); LLKeywords::keyword_iterator_t keywordsBegin() { return mKeywords.begin(); } LLKeywords::keyword_iterator_t keywordsEnd() { return mKeywords.end(); } @@ -195,8 +194,8 @@ public: void setCommitOnFocusLost(BOOL b) { mCommitOnFocusLost = b; } // Hack to handle Notecards - virtual BOOL importBuffer(const LLString& buffer ); - virtual BOOL exportBuffer(LLString& buffer ); + virtual BOOL importBuffer(const char* buffer, S32 length ); + virtual BOOL exportBuffer(std::string& buffer ); // If takes focus, will take keyboard focus on click. void setTakesFocus(BOOL b) { mTakesFocus = b; } @@ -210,7 +209,7 @@ public: // Callbacks static void setLinkColor(LLColor4 color) { mLinkColor = color; } - static void setURLCallbacks(void (*callback1) (const char* url), + static void setURLCallbacks(void (*callback1) (const std::string& url), bool (*callback2) (const std::string& url), bool (*callback3) (const std::string& url) ) { mURLcallback = callback1; mSecondlifeURLcallback = callback2; mSecondlifeURLcallbackRightClick = callback3;} @@ -221,7 +220,7 @@ public: void setValue(const LLSD& value); LLSD getValue() const; - const LLString& getText() const; + const std::string& getText() const; // Non-undoable void setText(const LLStringExplicit &utf8str); @@ -261,7 +260,7 @@ protected: void updateTextRect(); const LLRect& getTextRect() const { return mTextRect; } - void assignEmbedded(const LLString &s); + void assignEmbedded(const std::string &s); BOOL truncate(); // Returns true if truncation occurs static BOOL isPartOfWord(llwchar c) { return (c == '_') || isalnum(c); } @@ -313,8 +312,8 @@ protected: virtual void bindEmbeddedChars(LLFontGL* font) const {} virtual void unbindEmbeddedChars(LLFontGL* font) const {} - S32 findHTMLToken(const LLString &line, S32 pos, BOOL reverse) const; - BOOL findHTML(const LLString &line, S32 *begin, S32 *end) const; + S32 findHTMLToken(const std::string &line, S32 pos, BOOL reverse) const; + BOOL findHTML(const std::string &line, S32 *begin, S32 *end) const; // Abstract inner base class representing an undoable editor command. // Concrete sub-classes can be defined for operations such as insert, remove, etc. @@ -399,7 +398,7 @@ protected: S32 mLastSelectionY; BOOL mParseHTML; - LLString mHTML; + std::string mHTML; typedef std::vector<LLTextSegment *> segment_list_t; segment_list_t mSegments; @@ -436,7 +435,7 @@ private: // LLKeywords mKeywords; static LLColor4 mLinkColor; - static void (*mURLcallback) (const char* url); + static void (*mURLcallback) (const std::string& url); static bool (*mSecondlifeURLcallback) (const std::string& url); static bool (*mSecondlifeURLcallbackRightClick) (const std::string& url); @@ -447,7 +446,7 @@ private: class LLTextCmdRemove; LLWString mWText; - mutable LLString mUTF8Text; + mutable std::string mUTF8Text; mutable BOOL mTextIsUpToDate; S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes @@ -544,7 +543,7 @@ public: BOOL getIsDefault() const { return mIsDefault; } void setToken( LLKeywordToken* token ) { mToken = token; } LLKeywordToken* getToken() const { return mToken; } - BOOL getToolTip( LLString& msg ) const; + BOOL getToolTip( std::string& msg ) const; void dump() const; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 6ef485d82c..ac263250ff 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -63,8 +63,8 @@ const LLColor4 UI_VERTEX_COLOR(1.f, 1.f, 1.f, 1.f); BOOL gShowTextEditCursor = TRUE; // Language for UI construction -std::map<LLString, LLString> gTranslation; -std::list<LLString> gUntranslated; +std::map<std::string, std::string> gTranslation; +std::list<std::string> gUntranslated; LLControlGroup* LLUI::sConfigGroup = NULL; LLControlGroup* LLUI::sColorsGroup = NULL; @@ -80,8 +80,9 @@ BOOL LLUI::sQAMode = FALSE; // // Functions // -void make_ui_sound(const LLString& name) +void make_ui_sound(const char* namep) { + std::string name = ll_safe_string(namep); if (!LLUI::sConfigGroup->controlExists(name)) { llwarns << "tried to make ui sound for unknown sound name: " << name << llendl; @@ -1557,7 +1558,7 @@ void LLUI::initClass(LLControlGroup* config, LLImageProviderInterface* image_provider, LLUIAudioCallback audio_callback, const LLVector2* scale_factor, - const LLString& language) + const std::string& language) { sConfigGroup = config; sColorsGroup = colors; @@ -1647,10 +1648,10 @@ void LLUI::setCursorPositionLocal(const LLView* viewp, S32 x, S32 y) } //static -LLString LLUI::locateSkin(const LLString& filename) +std::string LLUI::locateSkin(const std::string& filename) { - LLString slash = gDirUtilp->getDirDelimiter(); - LLString found_file = filename; + std::string slash = gDirUtilp->getDirDelimiter(); + std::string found_file = filename; if (!gDirUtilp->fileExists(found_file)) { found_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename); // Should be CUSTOM_SKINS? @@ -1659,18 +1660,18 @@ LLString LLUI::locateSkin(const LLString& filename) { if (!gDirUtilp->fileExists(found_file)) { - LLString localization(sConfigGroup->getString("Language")); + std::string localization(sConfigGroup->getString("Language")); if(localization == "default") { localization = sConfigGroup->getString("SystemLanguage"); } - LLString local_skin = "xui" + slash + localization + slash + filename; + std::string local_skin = "xui" + slash + localization + slash + filename; found_file = gDirUtilp->getExpandedFilename(LL_PATH_SKINS, local_skin); } } if (!gDirUtilp->fileExists(found_file)) { - LLString local_skin = "xui" + slash + "en-us" + slash + filename; + std::string local_skin = "xui" + slash + "en-us" + slash + filename; found_file = gDirUtilp->getExpandedFilename(LL_PATH_SKINS, local_skin); } if (!gDirUtilp->fileExists(found_file)) @@ -1718,7 +1719,7 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen) } //static -LLUIImage* LLUI::getUIImage(const LLString& name) +LLUIImage* LLUI::getUIImage(const std::string& name) { if (!name.empty()) return sImageProvider->getUIImage(name); @@ -1806,7 +1807,7 @@ LLLocalClipRect::LLLocalClipRect(const LLRect &rect, BOOL enabled) // LLUIImage // -LLUIImage::LLUIImage(const LLString& name, LLPointer<LLImageGL> image) : +LLUIImage::LLUIImage(const std::string& name, LLPointer<LLImageGL> image) : mName(name), mImage(image), mScaleRegion(0.f, 1.f, 1.f, 0.f), diff --git a/indra/llui/llui.h b/indra/llui/llui.h index ab45e36175..d434dbd6d1 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -56,7 +56,7 @@ class LLUIImage; // UI colors extern const LLColor4 UI_VERTEX_COLOR; -void make_ui_sound(const LLString& name); +void make_ui_sound(const char* name); BOOL ui_point_in_rect(S32 x, S32 y, S32 left, S32 top, S32 right, S32 bottom); void gl_state_for_2d(S32 width, S32 height); @@ -144,7 +144,7 @@ inline void gl_rect_2d_offset_local( const LLRect& rect, S32 pixel_offset, BOOL // void init_tr(); // Returns a string from the string table in the correct language -// LLString tr(const LLString& english_chars); +// std::string tr(const std::string& english_chars); // Used to hide the flashing text cursor when window doesn't have focus. extern BOOL gShowTextEditCursor; @@ -164,7 +164,7 @@ public: LLImageProviderInterface* image_provider, LLUIAudioCallback audio_callback = NULL, const LLVector2 *scale_factor = NULL, - const LLString& language = LLString::null); + const std::string& language = LLStringUtil::null); static void cleanupClass(); static void pushMatrix(); @@ -173,12 +173,12 @@ public: static void translate(F32 x, F32 y, F32 z = 0.0f); //helper functions (should probably move free standing rendering helper functions here) - static LLString locateSkin(const LLString& filename); + static std::string locateSkin(const std::string& filename); static void setCursorPositionScreen(S32 x, S32 y); static void setCursorPositionLocal(const LLView* viewp, S32 x, S32 y); static void setScaleFactor(const LLVector2& scale_factor); static void setLineWidth(F32 width); - static LLUIImage* getUIImage(const LLString& name); + static LLUIImage* getUIImage(const std::string& name); static LLVector2 getWindowSize(); static void screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y); static void glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y); @@ -411,7 +411,7 @@ public: class LLUIImage : public LLRefCount { public: - LLUIImage(const LLString& name, LLPointer<LLImageGL> image); + LLUIImage(const std::string& name, LLPointer<LLImageGL> image); void setClipRegion(const LLRectf& region); void setScaleRegion(const LLRectf& region); @@ -431,7 +431,7 @@ public: void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); } void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, mImage->getWidth(0), mImage->getHeight(0), color, border_width); } - const LLString& getName() const { return mName; } + const std::string& getName() const { return mName; } S32 getWidth() const; S32 getHeight() const; @@ -441,7 +441,7 @@ public: S32 getTextureHeight() const; protected: - LLString mName; + std::string mName; LLRectf mScaleRegion; LLRectf mClipRegion; LLPointer<LLImageGL> mImage; @@ -592,7 +592,7 @@ public: LLImageProviderInterface() {}; virtual ~LLImageProviderInterface() {}; - virtual LLUIImagePtr getUIImage(const LLString& name) = 0; + virtual LLUIImagePtr getUIImage(const std::string& name) = 0; virtual LLUIImagePtr getUIImageByID(const LLUUID& id) = 0; virtual void cleanUp() = 0; }; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index aa44663fd0..c01845e524 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -98,7 +98,7 @@ LLUICtrl::LLUICtrl() : { } -LLUICtrl::LLUICtrl(const LLString& name, const LLRect& rect, BOOL mouse_opaque, +LLUICtrl::LLUICtrl(const std::string& name, const LLRect& rect, BOOL mouse_opaque, void (*on_commit_callback)(LLUICtrl*, void*), void* callback_userdata, U32 reshape) @@ -147,13 +147,13 @@ LLSD LLUICtrl::getValue() const } // virtual -BOOL LLUICtrl::setTextArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLUICtrl::setTextArg( const std::string& key, const LLStringExplicit& text ) { return FALSE; } // virtual -BOOL LLUICtrl::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLUICtrl::setLabelArg( const std::string& key, const LLStringExplicit& text ) { return FALSE; } @@ -495,7 +495,7 @@ LLUICtrl* LLUICtrl::findRootMostFocusRoot() const /* // Don't let the children handle the tool tip. Handle it here instead. -BOOL LLUICtrl::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) +BOOL LLUICtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) { BOOL handled = FALSE; if (getVisible() && pointInView( x, y ) ) diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 6863940ddd..52ea37ffdd 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -69,7 +69,7 @@ public: typedef BOOL (*LLUICtrlValidate)(LLUICtrl* ctrl, void* userdata); LLUICtrl(); - LLUICtrl( const LLString& name, const LLRect& rect, BOOL mouse_opaque, + LLUICtrl( const std::string& name, const LLRect& rect, BOOL mouse_opaque, LLUICtrlCallback callback, void* callback_userdata, U32 reshape=FOLLOWS_NONE); @@ -78,7 +78,7 @@ public: // LLView interface /*virtual*/ void initFromXML(LLXMLNodePtr node, LLView* parent); /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; - /*virtual*/ BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + /*virtual*/ BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); /*virtual*/ void onFocusReceived(); /*virtual*/ void onFocusLost(); /*virtual*/ BOOL isCtrl() const; @@ -97,7 +97,7 @@ public: virtual class LLCtrlScrollInterface* getScrollInterface(); virtual LLSD getValue() const; - virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); virtual void setIsChrome(BOOL is_chrome); virtual BOOL acceptsTextInput() const; // Defaults to false diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index c2dc9a1e90..15601850ae 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -76,18 +76,18 @@ const S32 VPAD = 4; const S32 FLOATER_H_MARGIN = 15; const S32 MIN_WIDGET_HEIGHT = 10; -std::vector<LLString> LLUICtrlFactory::mXUIPaths; +std::vector<std::string> LLUICtrlFactory::mXUIPaths; // UI Ctrl class for padding class LLUICtrlLocate : public LLUICtrl { public: - LLUICtrlLocate() : LLUICtrl("locate", LLRect(0,0,0,0), FALSE, NULL, NULL) { setTabStop(FALSE); } + LLUICtrlLocate() : LLUICtrl(std::string("locate"), LLRect(0,0,0,0), FALSE, NULL, NULL) { setTabStop(FALSE); } virtual void draw() { } static LLView *fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("pad"); + std::string name("pad"); node->getAttributeString("name", name); LLUICtrlLocate *new_ctrl = new LLUICtrlLocate(); @@ -117,7 +117,7 @@ LLUICtrlFactory::~LLUICtrlFactory() void LLUICtrlFactory::setupPaths() { - LLString filename = gDirUtilp->getExpandedFilename(LL_PATH_SKINS, "paths.xml"); + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_SKINS, "paths.xml"); LLXMLNodePtr root; BOOL success = LLXMLNode::parseFile(filename, root, NULL); @@ -126,12 +126,12 @@ void LLUICtrlFactory::setupPaths() if (success) { LLXMLNodePtr path; - LLString app_dir = gDirUtilp->getAppRODataDir(); + std::string app_dir = gDirUtilp->getAppRODataDir(); for (path = root->getFirstChild(); path.notNull(); path = path->getNextSibling()) { LLUIString path_val_ui(path->getValue()); - LLString language = "en-us"; + std::string language = "en-us"; if (LLUI::sConfigGroup) { language = LLUI::sConfigGroup->getString("Language"); @@ -141,7 +141,7 @@ void LLUICtrlFactory::setupPaths() } } path_val_ui.setArg("[Language]", language); - LLString fullpath = app_dir + path_val_ui.getString(); + std::string fullpath = app_dir + path_val_ui.getString(); if (std::find(mXUIPaths.begin(), mXUIPaths.end(), fullpath) == mXUIPaths.end()) { @@ -151,8 +151,8 @@ void LLUICtrlFactory::setupPaths() } else // parsing failed { - LLString slash = gDirUtilp->getDirDelimiter(); - LLString dir = gDirUtilp->getAppRODataDir() + slash + "skins" + slash + "xui" + slash + "en-us" + slash; + std::string slash = gDirUtilp->getDirDelimiter(); + std::string dir = gDirUtilp->getAppRODataDir() + slash + "skins" + slash + "xui" + slash + "en-us" + slash; llwarns << "XUI::config file unable to open." << llendl; mXUIPaths.push_back(dir); } @@ -163,7 +163,7 @@ void LLUICtrlFactory::setupPaths() //----------------------------------------------------------------------------- // getLayeredXMLNode() //----------------------------------------------------------------------------- -bool LLUICtrlFactory::getLayeredXMLNode(const LLString &filename, LLXMLNodePtr& root) +bool LLUICtrlFactory::getLayeredXMLNode(const std::string &filename, LLXMLNodePtr& root) { if (!LLXMLNode::parseFile(mXUIPaths.front() + filename, root, NULL)) { @@ -176,12 +176,12 @@ bool LLUICtrlFactory::getLayeredXMLNode(const LLString &filename, LLXMLNodePtr& LLXMLNodePtr updateRoot; - std::vector<LLString>::const_iterator itor; + std::vector<std::string>::const_iterator itor; for (itor = mXUIPaths.begin(), ++itor; itor != mXUIPaths.end(); ++itor) { - LLString nodeName; - LLString updateName; + std::string nodeName; + std::string updateName; LLXMLNode::parseFile((*itor) + filename, updateRoot, NULL); @@ -201,7 +201,7 @@ bool LLUICtrlFactory::getLayeredXMLNode(const LLString &filename, LLXMLNodePtr& //----------------------------------------------------------------------------- // buildFloater() //----------------------------------------------------------------------------- -void LLUICtrlFactory::buildFloater(LLFloater* floaterp, const LLString &filename, +void LLUICtrlFactory::buildFloater(LLFloater* floaterp, const std::string& filename, const LLCallbackMap::map_t* factory_map, BOOL open) /* Flawfinder: ignore */ { LLXMLNodePtr root; @@ -242,9 +242,9 @@ void LLUICtrlFactory::buildFloater(LLFloater* floaterp, const LLString &filename //----------------------------------------------------------------------------- // saveToXML() //----------------------------------------------------------------------------- -S32 LLUICtrlFactory::saveToXML(LLView* viewp, const LLString& filename) +S32 LLUICtrlFactory::saveToXML(LLView* viewp, const std::string& filename) { - llofstream out(filename.c_str()); + llofstream out(filename); if (!out.good()) { llwarns << "Unable to open " << filename << " for output." << llendl; @@ -264,7 +264,7 @@ S32 LLUICtrlFactory::saveToXML(LLView* viewp, const LLString& filename) //----------------------------------------------------------------------------- // buildPanel() //----------------------------------------------------------------------------- -BOOL LLUICtrlFactory::buildPanel(LLPanel* panelp, const LLString &filename, +BOOL LLUICtrlFactory::buildPanel(LLPanel* panelp, const std::string& filename, const LLCallbackMap::map_t* factory_map) { BOOL didPost = FALSE; @@ -308,7 +308,7 @@ BOOL LLUICtrlFactory::buildPanel(LLPanel* panelp, const LLString &filename, //----------------------------------------------------------------------------- // buildMenu() //----------------------------------------------------------------------------- -LLMenuGL *LLUICtrlFactory::buildMenu(const LLString &filename, LLView* parentp) +LLMenuGL *LLUICtrlFactory::buildMenu(const std::string &filename, LLView* parentp) { // TomY TODO: Break this function into buildMenu and buildMenuBar LLXMLNodePtr root; @@ -346,7 +346,7 @@ LLMenuGL *LLUICtrlFactory::buildMenu(const LLString &filename, LLView* parentp) //----------------------------------------------------------------------------- // buildMenu() //----------------------------------------------------------------------------- -LLPieMenu *LLUICtrlFactory::buildPieMenu(const LLString &filename, LLView* parentp) +LLPieMenu *LLUICtrlFactory::buildPieMenu(const std::string &filename, LLView* parentp) { LLXMLNodePtr root; @@ -362,7 +362,7 @@ LLPieMenu *LLUICtrlFactory::buildPieMenu(const LLString &filename, LLView* paren return NULL; } - LLString name("menu"); + std::string name("menu"); root->getAttributeString("name", name); LLPieMenu *menu = new LLPieMenu(name); @@ -387,7 +387,7 @@ void LLUICtrlFactory::rebuild() built_panel_it != mBuiltPanels.end(); ++built_panel_it) { - LLString filename = built_panel_it->second; + std::string filename = built_panel_it->second; LLPanel* panelp = built_panel_it->first.get(); if (!panelp) { @@ -415,7 +415,7 @@ void LLUICtrlFactory::rebuild() { continue; } - LLString filename = built_floater_it->second; + std::string filename = built_floater_it->second; llinfos << "Rebuilding UI floater " << floaterp->getName() << " from " << filename << llendl; @@ -435,8 +435,8 @@ void LLUICtrlFactory::rebuild() LLView *LLUICtrlFactory::createCtrlWidget(LLPanel *parent, LLXMLNodePtr node) { - LLString ctrl_type = node->getName()->mString; - LLString::toLower(ctrl_type); + std::string ctrl_type = node->getName()->mString; + LLStringUtil::toLower(ctrl_type); LLWidgetClassRegistry::factory_func_t func = LLWidgetClassRegistry::getInstance()->getCreatorFunc(ctrl_type); @@ -477,7 +477,7 @@ LLView* LLUICtrlFactory::createWidget(LLPanel *parent, LLXMLNodePtr node) //----------------------------------------------------------------------------- // createFactoryPanel() //----------------------------------------------------------------------------- -LLPanel* LLUICtrlFactory::createFactoryPanel(LLString name) +LLPanel* LLUICtrlFactory::createFactoryPanel(const std::string& name) { std::deque<const LLCallbackMap::map_t*>::iterator itor; for (itor = mFactoryStack.begin(); itor != mFactoryStack.end(); ++itor) @@ -499,10 +499,10 @@ LLPanel* LLUICtrlFactory::createFactoryPanel(LLString name) //----------------------------------------------------------------------------- //static -BOOL LLUICtrlFactory::getAttributeColor(LLXMLNodePtr node, const LLString& name, LLColor4& color) +BOOL LLUICtrlFactory::getAttributeColor(LLXMLNodePtr node, const std::string& name, LLColor4& color) { - LLString colorstring; - BOOL res = node->getAttributeString(name, colorstring); + std::string colorstring; + BOOL res = node->getAttributeString(name.c_str(), colorstring); if (res && LLUI::sColorsGroup) { if (LLUI::sColorsGroup->controlExists(colorstring)) @@ -516,11 +516,11 @@ BOOL LLUICtrlFactory::getAttributeColor(LLXMLNodePtr node, const LLString& name, } if (!res) { - res = LLColor4::parseColor(colorstring.c_str(), &color); + res = LLColor4::parseColor(colorstring, &color); } if (!res) { - res = node->getAttributeColor(name, color); + res = node->getAttributeColor(name.c_str(), color); } return res; } diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index cd4fa8cacf..8638986c9f 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -50,44 +50,45 @@ public: void setupPaths(); - void buildFloater(LLFloater* floaterp, const LLString &filename, + void buildFloater(LLFloater* floaterp, const std::string &filename, const LLCallbackMap::map_t* factory_map = NULL, BOOL open = TRUE); - BOOL buildPanel(LLPanel* panelp, const LLString &filename, + BOOL buildPanel(LLPanel* panelp, const std::string &filename, const LLCallbackMap::map_t* factory_map = NULL); void removePanel(LLPanel* panelp) { mBuiltPanels.erase(panelp->getHandle()); } void removeFloater(LLFloater* floaterp) { mBuiltFloaters.erase(floaterp->getHandle()); } - class LLMenuGL *buildMenu(const LLString &filename, LLView* parentp); - class LLPieMenu *buildPieMenu(const LLString &filename, LLView* parentp); + class LLMenuGL *buildMenu(const std::string &filename, LLView* parentp); + class LLPieMenu *buildPieMenu(const std::string &filename, LLView* parentp); // Does what you want for LLFloaters and LLPanels // Returns 0 on success - S32 saveToXML(LLView* viewp, const LLString& filename); + S32 saveToXML(LLView* viewp, const std::string& filename); // Rebuilds all currently built panels. void rebuild(); - static BOOL getAttributeColor(LLXMLNodePtr node, const LLString& name, LLColor4& color); + static BOOL getAttributeColor(LLXMLNodePtr node, const std::string& name, LLColor4& color); - LLPanel* createFactoryPanel(LLString name); + LLPanel* createFactoryPanel(const std::string& name); virtual LLView* createCtrlWidget(LLPanel *parent, LLXMLNodePtr node); virtual LLView* createWidget(LLPanel *parent, LLXMLNodePtr node); - static bool getLayeredXMLNode(const LLString &filename, LLXMLNodePtr& root); + static bool getLayeredXMLNode(const std::string &filename, LLXMLNodePtr& root); private: - typedef std::map<LLHandle<LLPanel>, LLString> built_panel_t; + typedef std::map<LLHandle<LLPanel>, std::string> built_panel_t; built_panel_t mBuiltPanels; - typedef std::map<LLHandle<LLFloater>, LLString> built_floater_t; + typedef std::map<LLHandle<LLFloater>, std::string> built_floater_t; built_floater_t mBuiltFloaters; std::deque<const LLCallbackMap::map_t*> mFactoryStack; - static std::vector<LLString> mXUIPaths; + + static std::vector<std::string> mXUIPaths; LLPanel* mDummyPanel; }; diff --git a/indra/llui/lluistring.cpp b/indra/llui/lluistring.cpp index d6496b1a41..0dde20934c 100644 --- a/indra/llui/lluistring.cpp +++ b/indra/llui/lluistring.cpp @@ -32,29 +32,29 @@ #include "linden_common.h" #include "lluistring.h" -const LLString::format_map_t LLUIString::sNullArgs; +const LLStringUtil::format_map_t LLUIString::sNullArgs; -LLUIString::LLUIString(const LLString& instring, const LLString::format_map_t& args) +LLUIString::LLUIString(const std::string& instring, const LLStringUtil::format_map_t& args) : mOrig(instring), mArgs(args) { format(); } -void LLUIString::assign(const LLString& s) +void LLUIString::assign(const std::string& s) { mOrig = s; format(); } -void LLUIString::setArgList(const LLString::format_map_t& args) +void LLUIString::setArgList(const LLStringUtil::format_map_t& args) { mArgs = args; format(); } -void LLUIString::setArg(const LLString& key, const LLString& replacement) +void LLUIString::setArg(const std::string& key, const std::string& replacement) { mArgs[key] = replacement; format(); @@ -64,7 +64,7 @@ void LLUIString::truncate(S32 maxchars) { if (mWResult.size() > (size_t)maxchars) { - LLWString::truncate(mWResult, maxchars); + LLWStringUtil::truncate(mWResult, maxchars); mResult = wstring_to_utf8str(mWResult); } } @@ -98,6 +98,6 @@ void LLUIString::clear() void LLUIString::format() { mResult = mOrig; - LLString::format(mResult, mArgs); + LLStringUtil::format(mResult, mArgs); mWResult = utf8str_to_wstring(mResult); } diff --git a/indra/llui/lluistring.h b/indra/llui/lluistring.h index dd787baafe..773bc09763 100644 --- a/indra/llui/lluistring.h +++ b/indra/llui/lluistring.h @@ -1,7 +1,7 @@ /** * @file lluistring.h * @author: Steve Bennetts - * @brief A fancy wrapper for LLString supporting argument substitutions. + * @brief A fancy wrapper for std::string supporting argument substitutions. * * $LicenseInfo:firstyear=2006&license=viewergpl$ * @@ -47,15 +47,15 @@ // LLUIString mMessage("Welcome [USERNAME] to [SECONDLIFE]!"); // mMessage.setArg("[USERNAME]", "Steve"); // mMessage.setArg("[SECONDLIFE]", "Second Life"); -// llinfos << mMessage.getString().c_str() << llendl; // outputs "Welcome Steve to Second Life" +// llinfos << mMessage.getString() << llendl; // outputs "Welcome Steve to Second Life" // mMessage.setArg("[USERNAME]", "Joe"); -// llinfos << mMessage.getString().c_str() << llendl; // outputs "Welcome Joe to Second Life" +// llinfos << mMessage.getString() << llendl; // outputs "Welcome Joe to Second Life" // mMessage = "Recepción a la [SECONDLIFE] [USERNAME]" // mMessage.setArg("[SECONDLIFE]", "Segunda Vida"); -// llinfos << mMessage.getString().c_str() << llendl; // outputs "Recepción a la Segunda Vida Joe" +// llinfos << mMessage.getString() << llendl; // outputs "Recepción a la Segunda Vida Joe" // Implementation Notes: -// Attempting to have operator[](const LLString& s) return mArgs[s] fails because we have +// Attempting to have operator[](const std::string& s) return mArgs[s] fails because we have // to call format() after the assignment happens. class LLUIString @@ -64,17 +64,17 @@ public: // These methods all perform appropriate argument substitution // and modify mOrig where appropriate LLUIString() {} - LLUIString(const LLString& instring, const LLString::format_map_t& args); - LLUIString(const LLString& instring) { assign(instring); } + LLUIString(const std::string& instring, const LLStringUtil::format_map_t& args); + LLUIString(const std::string& instring) { assign(instring); } - void assign(const LLString& instring); - LLUIString& operator=(const LLString& s) { assign(s); return *this; } + void assign(const std::string& instring); + LLUIString& operator=(const std::string& s) { assign(s); return *this; } - void setArgList(const LLString::format_map_t& args); - void setArg(const LLString& key, const LLString& replacement); + void setArgList(const LLStringUtil::format_map_t& args); + void setArg(const std::string& key, const std::string& replacement); - const LLString& getString() const { return mResult; } - operator LLString() const { return mResult; } + const std::string& getString() const { return mResult; } + operator std::string() const { return mResult; } const LLWString& getWString() const { return mWResult; } operator LLWString() const { return mWResult; } @@ -92,15 +92,15 @@ public: void insert(S32 charidx, const LLWString& wchars); void replace(S32 charidx, llwchar wc); - static const LLString::format_map_t sNullArgs; + static const LLStringUtil::format_map_t sNullArgs; private: void format(); - LLString mOrig; - LLString mResult; + std::string mOrig; + std::string mResult; LLWString mWResult; // for displaying - LLString::format_map_t mArgs; + LLStringUtil::format_map_t mArgs; }; #endif // LL_LLUISTRING_H diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index a239968e5d..c20bfe6ac0 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -62,7 +62,7 @@ BOOL LLView::sDebugRects = FALSE; BOOL LLView::sDebugKeys = FALSE; S32 LLView::sDepth = 0; BOOL LLView::sDebugMouseHandling = FALSE; -LLString LLView::sMouseHandlerMessage; +std::string LLView::sMouseHandlerMessage; S32 LLView::sSelectID = GL_NAME_UI_RESERVED; BOOL LLView::sEditingUI = FALSE; BOOL LLView::sForceReshape = FALSE; @@ -90,7 +90,7 @@ LLView::LLView() : { } -LLView::LLView(const LLString& name, BOOL mouse_opaque) : +LLView::LLView(const std::string& name, BOOL mouse_opaque) : mParentView(NULL), mName(name), mReshapeFlags(FOLLOWS_NONE), @@ -109,7 +109,7 @@ LLView::LLView(const LLString& name, BOOL mouse_opaque) : LLView::LLView( - const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 reshape) : + const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 reshape) : mParentView(NULL), mName(name), mRect(rect), @@ -194,7 +194,7 @@ BOOL LLView::setToolTipArg(const LLStringExplicit& key, const LLStringExplicit& return TRUE; } -void LLView::setToolTipArgs( const LLString::format_map_t& args ) +void LLView::setToolTipArgs( const LLStringUtil::format_map_t& args ) { mToolTipMsg.setArgList(args); } @@ -221,9 +221,9 @@ BOOL LLView::getUseBoundingRect() } // virtual -const LLString& LLView::getName() const +const std::string& LLView::getName() const { - static const LLString unnamed("(no name)"); + static const std::string unnamed("(no name)"); return mName.empty() ? unnamed : mName; } @@ -460,7 +460,7 @@ void LLView::setEnabled(BOOL enabled) } //virtual -BOOL LLView::setLabelArg( const LLString& key, const LLStringExplicit& text ) +BOOL LLView::setLabelArg( const std::string& key, const LLStringExplicit& text ) { return FALSE; } @@ -666,11 +666,11 @@ BOOL LLView::handleHover(S32 x, S32 y, MASK mask) return handled; } -LLString LLView::getShowNamesToolTip() +std::string LLView::getShowNamesToolTip() { LLView* view = getParent(); - LLString name; - LLString tool_tip = mName; + std::string name; + std::string tool_tip = mName; while (view) { @@ -678,7 +678,7 @@ LLString LLView::getShowNamesToolTip() if (name == "root") break; - if (view->getToolTip().find(".xml") != LLString::npos) + if (view->getToolTip().find(".xml") != std::string::npos) { tool_tip = view->getToolTip() + "/" + tool_tip; break; @@ -695,11 +695,11 @@ LLString LLView::getShowNamesToolTip() } -BOOL LLView::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) +BOOL LLView::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) { BOOL handled = FALSE; - LLString tool_tip; + std::string tool_tip; for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) { @@ -719,8 +719,8 @@ BOOL LLView::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_scre tool_tip = mToolTipMsg.getString(); if ( LLUI::sShowXUINames && - (tool_tip.find(".xml", 0) == LLString::npos) && - (mName.find("Drag", 0) == LLString::npos)) + (tool_tip.find(".xml", 0) == std::string::npos) && + (mName.find("Drag", 0) == std::string::npos)) { tool_tip = getShowNamesToolTip(); } @@ -824,7 +824,7 @@ BOOL LLView::handleUnicodeCharHere(llwchar uni_char ) BOOL LLView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { // CRO this is an experiment to allow drag and drop into object inventory based on the DragAndDrop tool's permissions rather than the parent BOOL handled = childrenHandleDragAndDrop( x, y, mask, drop, @@ -847,7 +847,7 @@ LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { LLView* handled_view = FALSE; // CRO this is an experiment to allow drag and drop into object inventory based on the DragAndDrop tool's permissions rather than the parent @@ -987,7 +987,7 @@ LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks) { if (sDebugMouseHandling) { - sMouseHandlerMessage = LLString("->") + viewp->mName.c_str() + sMouseHandlerMessage; + sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; } handled_view = viewp; @@ -1015,7 +1015,7 @@ LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask) { if (sDebugMouseHandling) { - sMouseHandlerMessage = LLString("->") + viewp->mName.c_str() + sMouseHandlerMessage; + sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; } handled_view = viewp; @@ -1093,7 +1093,7 @@ LLView* LLView::childrenHandleMouseDown(S32 x, S32 y, MASK mask) { if (sDebugMouseHandling) { - sMouseHandlerMessage = LLString("->") + viewp->mName.c_str() + sMouseHandlerMessage; + sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; } handled_view = viewp; break; @@ -1120,7 +1120,7 @@ LLView* LLView::childrenHandleRightMouseDown(S32 x, S32 y, MASK mask) { if (sDebugMouseHandling) { - sMouseHandlerMessage = LLString("->") + viewp->mName.c_str() + sMouseHandlerMessage; + sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; } handled_view = viewp; break; @@ -1148,7 +1148,7 @@ LLView* LLView::childrenHandleDoubleClick(S32 x, S32 y, MASK mask) { if (sDebugMouseHandling) { - sMouseHandlerMessage = LLString("->") + viewp->mName.c_str() + sMouseHandlerMessage; + sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; } handled_view = viewp; break; @@ -1178,7 +1178,7 @@ LLView* LLView::childrenHandleMouseUp(S32 x, S32 y, MASK mask) { if (sDebugMouseHandling) { - sMouseHandlerMessage = LLString("->") + viewp->mName.c_str() + sMouseHandlerMessage; + sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; } handled_view = viewp; break; @@ -1205,7 +1205,7 @@ LLView* LLView::childrenHandleRightMouseUp(S32 x, S32 y, MASK mask) { if (sDebugMouseHandling) { - sMouseHandlerMessage = LLString("->") + viewp->mName.c_str() + sMouseHandlerMessage; + sMouseHandlerMessage = std::string("->") + viewp->mName + sMouseHandlerMessage; } handled_view = viewp; break; @@ -1326,7 +1326,7 @@ void LLView::drawDebugRect() gGL.color4fv( border_color.mV ); x = debug_rect.getWidth()/2; y = debug_rect.getHeight()/2; - LLString debug_text = llformat("%s (%d x %d)", getName().c_str(), + std::string debug_text = llformat("%s (%d x %d)", getName().c_str(), debug_rect.getWidth(), debug_rect.getHeight()); LLFontGL::sSansSerifSmall->renderUTF8(debug_text, 0, (F32)x, (F32)y, border_color, LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, @@ -1537,7 +1537,7 @@ BOOL LLView::hasAncestor(const LLView* parentp) const //----------------------------------------------------------------------------- -BOOL LLView::childHasKeyboardFocus( const LLString& childname ) const +BOOL LLView::childHasKeyboardFocus( const std::string& childname ) const { LLView *child = getChildView(childname, TRUE, FALSE); if (child) @@ -1552,7 +1552,7 @@ BOOL LLView::childHasKeyboardFocus( const LLString& childname ) const //----------------------------------------------------------------------------- -BOOL LLView::hasChild(const LLString& childname, BOOL recurse) const +BOOL LLView::hasChild(const std::string& childname, BOOL recurse) const { return getChildView(childname, recurse, FALSE) != NULL; } @@ -1560,7 +1560,7 @@ BOOL LLView::hasChild(const LLString& childname, BOOL recurse) const //----------------------------------------------------------------------------- // getChildView() //----------------------------------------------------------------------------- -LLView* LLView::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const +LLView* LLView::getChildView(const std::string& name, BOOL recurse, BOOL create_if_missing) const { //richard: should we allow empty names? //if(name.empty()) @@ -1923,33 +1923,18 @@ LLView* LLView::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fact // static void LLView::addColorXML(LLXMLNodePtr node, const LLColor4& color, - const LLString& xml_name, const LLString& control_name) + const char* xml_name, const char* control_name) { - if (color != LLUI::sColorsGroup->getColor(control_name)) + if (color != LLUI::sColorsGroup->getColor(ll_safe_string(control_name))) { node->createChild(xml_name, TRUE)->setFloatValue(4, color.mV); } } -// static -void LLView::saveColorToXML(std::ostream& out, const LLColor4& color, - const LLString& xml_name, const LLString& control_name, - const LLString& indent) -{ - if (color != LLUI::sColorsGroup->getColor(control_name)) - { - out << indent << xml_name << "=\"" - << color.mV[VRED] << ", " - << color.mV[VGREEN] << ", " - << color.mV[VBLUE] << ", " - << color.mV[VALPHA] << "\"\n"; - } -} - //static -LLString LLView::escapeXML(const LLString& xml, LLString& indent) +std::string LLView::escapeXML(const std::string& xml, std::string& indent) { - LLString ret = indent + "\"" + LLXMLNode::escapeXML(xml); + std::string ret = indent + "\"" + LLXMLNode::escapeXML(xml); //replace every newline with a close quote, new line, indent, open quote size_t index = ret.size()-1; @@ -2404,12 +2389,12 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna // Listener dispatch functions //----------------------------------------------------------------------------- -void LLView::registerEventListener(LLString name, LLSimpleListener* function) +void LLView::registerEventListener(std::string name, LLSimpleListener* function) { - mDispatchList.insert(std::pair<LLString, LLSimpleListener*>(name, function)); + mDispatchList.insert(std::pair<std::string, LLSimpleListener*>(name, function)); } -void LLView::deregisterEventListener(LLString name) +void LLView::deregisterEventListener(std::string name) { dispatch_list_t::iterator itor = mDispatchList.find(name); if (itor != mDispatchList.end()) @@ -2418,7 +2403,7 @@ void LLView::deregisterEventListener(LLString name) } } -LLString LLView::findEventListener(LLSimpleListener *listener) const +std::string LLView::findEventListener(LLSimpleListener *listener) const { dispatch_list_t::const_iterator itor; for (itor = mDispatchList.begin(); itor != mDispatchList.end(); ++itor) @@ -2432,10 +2417,10 @@ LLString LLView::findEventListener(LLSimpleListener *listener) const { return mParentView->findEventListener(listener); } - return LLString::null; + return LLStringUtil::null; } -LLSimpleListener* LLView::getListenerByName(const LLString& callback_name) +LLSimpleListener* LLView::getListenerByName(const std::string& callback_name) { LLSimpleListener* callback = NULL; dispatch_list_t::iterator itor = mDispatchList.find(callback_name); @@ -2450,7 +2435,7 @@ LLSimpleListener* LLView::getListenerByName(const LLString& callback_name) return callback; } -LLControlVariable *LLView::findControl(LLString name) +LLControlVariable *LLView::findControl(const std::string& name) { control_map_t::iterator itor = mFloaterControls.find(name); if (itor != mFloaterControls.end()) @@ -2494,7 +2479,7 @@ U32 LLView::createRect(LLXMLNodePtr node, LLRect &rect, LLView* parent_view, con } } - LLString rect_control; + std::string rect_control; node->getAttributeString("rect_control", rect_control); if (! rect_control.empty()) { @@ -2655,14 +2640,14 @@ void LLView::initFromXML(LLXMLNodePtr node, LLView* parent) if (node->hasAttribute("control_name")) { - LLString control_name; + std::string control_name; node->getAttributeString("control_name", control_name); setControlName(control_name, NULL); } if (node->hasAttribute("tool_tip")) { - LLString tool_tip_msg(""); + std::string tool_tip_msg; node->getAttributeString("tool_tip", tool_tip_msg); setToolTip(tool_tip_msg); } @@ -2695,7 +2680,7 @@ void LLView::parseFollowsFlags(LLXMLNodePtr node) { setFollowsNone(); - LLString follows; + std::string follows; node->getAttributeString("follows", follows); typedef boost::tokenizer<boost::char_separator<char> > tokenizer; @@ -2739,10 +2724,10 @@ LLFontGL* LLView::selectFont(LLXMLNodePtr node) if (node->hasAttribute("font")) { - LLString font_name; + std::string font_name; node->getAttributeString("font", font_name); - gl_font = LLFontGL::fontFromName(font_name.c_str()); + gl_font = LLFontGL::fontFromName(font_name); } return gl_font; } @@ -2754,7 +2739,7 @@ LLFontGL::HAlign LLView::selectFontHAlign(LLXMLNodePtr node) if (node->hasAttribute("halign")) { - LLString horizontal_align_name; + std::string horizontal_align_name; node->getAttributeString("halign", horizontal_align_name); gl_hfont_align = LLFontGL::hAlignFromName(horizontal_align_name); } @@ -2768,7 +2753,7 @@ LLFontGL::VAlign LLView::selectFontVAlign(LLXMLNodePtr node) if (node->hasAttribute("valign")) { - LLString vert_align_name; + std::string vert_align_name; node->getAttributeString("valign", vert_align_name); gl_vfont_align = LLFontGL::vAlignFromName(vert_align_name); } @@ -2782,7 +2767,7 @@ LLFontGL::StyleFlags LLView::selectFontStyle(LLXMLNodePtr node) if (node->hasAttribute("style")) { - LLString style_flags_name; + std::string style_flags_name; node->getAttributeString("style", style_flags_name); if (style_flags_name == "normal") @@ -2808,7 +2793,7 @@ LLFontGL::StyleFlags LLView::selectFontStyle(LLXMLNodePtr node) bool LLView::setControlValue(const LLSD& value) { - LLString ctrlname = getControlName(); + std::string ctrlname = getControlName(); if (!ctrlname.empty()) { LLUI::sConfigGroup->setValue(ctrlname, value); @@ -2818,7 +2803,7 @@ bool LLView::setControlValue(const LLSD& value) } //virtual -void LLView::setControlName(const LLString& control_name, LLView *context) +void LLView::setControlName(const std::string& control_name, LLView *context) { if (context == NULL) { @@ -2870,12 +2855,12 @@ bool LLView::controlListener(const LLSD& newvalue, LLHandle<LLView> handle, std: return false; } -void LLView::addBoolControl(LLString name, bool initial_value) +void LLView::addBoolControl(const std::string& name, bool initial_value) { - mFloaterControls[name] = new LLControlVariable(name, TYPE_BOOLEAN, initial_value, "Internal floater control"); + mFloaterControls[name] = new LLControlVariable(name, TYPE_BOOLEAN, initial_value, std::string("Internal floater control")); } -LLControlVariable *LLView::getControl(LLString name) +LLControlVariable *LLView::getControl(const std::string& name) { control_map_t::iterator itor = mFloaterControls.find(name); if (itor != mFloaterControls.end()) @@ -2910,20 +2895,20 @@ LLWidgetClassRegistry::LLWidgetClassRegistry() { } -void LLWidgetClassRegistry::registerCtrl(const LLString& tag, LLWidgetClassRegistry::factory_func_t function) +void LLWidgetClassRegistry::registerCtrl(const std::string& tag, LLWidgetClassRegistry::factory_func_t function) { - LLString lower_case_tag = tag; - LLString::toLower(lower_case_tag); + std::string lower_case_tag = tag; + LLStringUtil::toLower(lower_case_tag); mCreatorFunctions[lower_case_tag] = function; } -BOOL LLWidgetClassRegistry::isTagRegistered(const LLString &tag) +BOOL LLWidgetClassRegistry::isTagRegistered(const std::string &tag) { return mCreatorFunctions.find(tag) != mCreatorFunctions.end(); } -LLWidgetClassRegistry::factory_func_t LLWidgetClassRegistry::getCreatorFunc(const LLString& ctrl_type) +LLWidgetClassRegistry::factory_func_t LLWidgetClassRegistry::getCreatorFunc(const std::string& ctrl_type) { factory_map_t::const_iterator found_it = mCreatorFunctions.find(ctrl_type); if (found_it == mCreatorFunctions.end()) diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 94811adaa5..2e1d0e3868 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -89,7 +89,7 @@ virtual void setVisible(BOOL visible); LLFloater, LLAlertDialog, LLMenuItemGL, LLModalDialog virtual void setEnabled(BOOL enabled) { mEnabled = enabled; } LLCheckBoxCtrl, LLComboBox, LLLineEditor, LLMenuGL, LLRadioGroup, etc -virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ) { return FALSE; } +virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ) { return FALSE; } LLUICtrl, LLButton, LLCheckBoxCtrl, LLLineEditor, LLMenuGL, LLSliderCtrl virtual void onVisibilityChange ( BOOL curVisibilityIn ); LLMenuGL @@ -114,7 +114,7 @@ virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); * virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent); * -virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,EDragAndDropType cargo_type,void* cargo_data,EAcceptance* accept,LLString& tooltip_msg); +virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,EDragAndDropType cargo_type,void* cargo_data,EAcceptance* accept,std::string& tooltip_msg); * virtual void draw(); * @@ -128,11 +128,11 @@ virtual void onFocusLost() {} LLUICtrl, LLScrollListCtrl, LLMenuGL, LLLineEditor, LLComboBox virtual void onFocusReceived() {} LLUICtrl, LLTextEditor, LLScrollListVtrl, LLMenuGL, LLLineEditor -virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; +virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; LLTabContainer, LLPanel, LLMenuGL -virtual void setControlName(const LLString& control, LLView *context); +virtual void setControlName(const std::string& control, LLView *context); LLSliderCtrl, LLCheckBoxCtrl -virtual LLString getControlName() const { return mControlName; } +virtual std::string getControlName() const { return mControlName; } LLSliderCtrl, LLCheckBoxCtrl virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); LLMenuItem @@ -154,11 +154,11 @@ class LLWidgetClassRegistry : public LLSingleton<LLWidgetClassRegistry> friend class LLSingleton<LLWidgetClassRegistry>; public: typedef LLView* (*factory_func_t)(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); - typedef std::map<LLString, factory_func_t> factory_map_t; + typedef std::map<std::string, factory_func_t> factory_map_t; - void registerCtrl(const LLString& xml_tag, factory_func_t function); - BOOL isTagRegistered(const LLString& xml_tag); - factory_func_t getCreatorFunc(const LLString& xml_tag); + void registerCtrl(const std::string& xml_tag, factory_func_t function); + BOOL isTagRegistered(const std::string& xml_tag); + factory_func_t getCreatorFunc(const std::string& xml_tag); // get (first) xml tag for a given class template <class T> std::string getTag() @@ -179,7 +179,7 @@ private: LLWidgetClassRegistry(); virtual ~LLWidgetClassRegistry() {}; - typedef std::set<LLString> ctrl_name_set_t; + typedef std::set<std::string> ctrl_name_set_t; ctrl_name_set_t mUICtrlNames; // map of xml tags to widget creator functions @@ -252,8 +252,8 @@ public: typedef child_tab_order_t::const_reverse_iterator child_tab_order_const_reverse_iter_t; LLView(); - LLView(const LLString& name, BOOL mouse_opaque); - LLView(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows=FOLLOWS_NONE); + LLView(const std::string& name, BOOL mouse_opaque); + LLView(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows=FOLLOWS_NONE); virtual ~LLView(); @@ -274,7 +274,7 @@ public: BOOL getMouseOpaque() const { return mMouseOpaque; } void setToolTip( const LLStringExplicit& msg ); BOOL setToolTipArg( const LLStringExplicit& key, const LLStringExplicit& text ); - void setToolTipArgs( const LLString::format_map_t& args ); + void setToolTipArgs( const LLStringUtil::format_map_t& args ); virtual void setRect(const LLRect &rect); void setFollows(U32 flags) { mReshapeFlags = flags; } @@ -288,11 +288,11 @@ public: void setFollowsAll() { mReshapeFlags |= FOLLOWS_ALL; } void setSoundFlags(U8 flags) { mSoundFlags = flags; } - void setName(LLString name) { mName = name; } + void setName(std::string name) { mName = name; } void setUseBoundingRect( BOOL use_bounding_rect ); BOOL getUseBoundingRect(); - const LLString& getToolTip() const { return mToolTipMsg.getString(); } + const std::string& getToolTip() const { return mToolTipMsg.getString(); } void sendChildToFront(LLView* child); void sendChildToBack(LLView* child); @@ -340,7 +340,7 @@ public: BOOL getEnabled() const { return mEnabled; } U8 getSoundFlags() const { return mSoundFlags; } - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); + virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); virtual void onVisibilityChange ( BOOL curVisibilityIn ); @@ -374,8 +374,8 @@ public: S32 getChildCount() const { return (S32)mChildList.size(); } template<class _Pr3> void sortChildren(_Pr3 _Pred) { mChildList.sort(_Pred); } BOOL hasAncestor(const LLView* parentp) const; - BOOL hasChild(const LLString& childname, BOOL recurse = FALSE) const; - BOOL childHasKeyboardFocus( const LLString& childname ) const; + BOOL hasChild(const std::string& childname, BOOL recurse = FALSE) const; + BOOL childHasKeyboardFocus( const std::string& childname ) const; // @@ -403,9 +403,9 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); - LLString getShowNamesToolTip(); + std::string getShowNamesToolTip(); virtual void draw(); @@ -439,19 +439,19 @@ public: void localRectToScreen( const LLRect& local, LLRect* screen ) const; // Listener dispatching functions (Dispatcher deletes pointers to listeners on deregistration or destruction) - LLSimpleListener* getListenerByName(const LLString &callback_name); - void registerEventListener(LLString name, LLSimpleListener* function); - void deregisterEventListener(LLString name); - LLString findEventListener(LLSimpleListener *listener) const; - void addListenerToControl(LLEventDispatcher *observer, const LLString& name, LLSD filter, LLSD userdata); + LLSimpleListener* getListenerByName(const std::string& callback_name); + void registerEventListener(std::string name, LLSimpleListener* function); + void deregisterEventListener(std::string name); + std::string findEventListener(LLSimpleListener *listener) const; + void addListenerToControl(LLEventDispatcher *observer, const std::string& name, LLSD filter, LLSD userdata); - void addBoolControl(LLString name, bool initial_value); - LLControlVariable *getControl(LLString name); - LLControlVariable *findControl(LLString name); + void addBoolControl(const std::string& name, bool initial_value); + LLControlVariable *getControl(const std::string& name); + LLControlVariable *findControl(const std::string& name); bool setControlValue(const LLSD& value); - virtual void setControlName(const LLString& control, LLView *context); - virtual LLString getControlName() const { return mControlName; } + virtual void setControlName(const std::string& control, LLView *context); + virtual std::string getControlName() const { return mControlName; } // virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); virtual void setValue(const LLSD& value); virtual LLSD getValue() const; @@ -467,15 +467,15 @@ public: /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); // Display mToolTipMsg if no child handles it. - /*virtual*/ const LLString& getName() const; + /*virtual*/ BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect); // Display mToolTipMsg if no child handles it. + /*virtual*/ const std::string& getName() const; /*virtual*/ void onMouseCaptureLost(); /*virtual*/ BOOL hasMouseCapture(); /*virtual*/ BOOL isView(); // Hack to support LLFocusMgr /*virtual*/ void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const; /*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const; - template <class T> T* getChild(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const + template <class T> T* getChild(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const { LLView* child = getChildView(name, recurse, FALSE); T* result = dynamic_cast<T*>(child); @@ -495,22 +495,22 @@ public: return result; } - virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; + virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; - template <class T> T* createDummyWidget(const LLString& name) const + template <class T> T* createDummyWidget(const std::string& name) const { T* widget = getDummyWidget<T>(name); if (!widget) { // get xml tag name corresponding to requested widget type (e.g. "button") - LLString xml_tag = LLWidgetClassRegistry::getInstance()->getTag<T>(); + std::string xml_tag = LLWidgetClassRegistry::getInstance()->getTag<T>(); if (xml_tag.empty()) { llwarns << "No xml tag registered for this class " << llendl; return NULL; } // create dummy xml node (<button name="foo"/>) - LLXMLNodePtr new_node_ptr = new LLXMLNode(xml_tag, FALSE); + LLXMLNodePtr new_node_ptr = new LLXMLNode(xml_tag.c_str(), FALSE); new_node_ptr->createChild("name", TRUE)->setStringValue(name); widget = dynamic_cast<T*>(createWidget(new_node_ptr)); @@ -530,7 +530,7 @@ public: return widget; } - template <class T> T* getDummyWidget(const LLString& name) const + template <class T> T* getDummyWidget(const std::string& name) const { dummy_widget_map_t::const_iterator found_it = mDummyWidgets.find(name); if (found_it == mDummyWidgets.end()) @@ -554,17 +554,14 @@ public: // Only saves color if different from default setting. static void addColorXML(LLXMLNodePtr node, const LLColor4& color, - const LLString& xml_name, const LLString& control_name); - static void saveColorToXML(std::ostream& out, const LLColor4& color, - const LLString& xml_name, const LLString& control_name, - const LLString& indent); // DEPRECATED + const char* xml_name, const char* control_name); // Escapes " (quot) ' (apos) & (amp) < (lt) > (gt) - //static LLString escapeXML(const LLString& xml); + //static std::string escapeXML(const std::string& xml); static LLWString escapeXML(const LLWString& xml); //same as above, but wraps multiple lines in quotes and prepends //indent as leading white space on each line - static LLString escapeXML(const LLString& xml, LLString& indent); + static std::string escapeXML(const std::string& xml, std::string& indent); // focuses the item in the list after the currently-focused item, wrapping if necessary static BOOL focusNext(LLView::child_list_t & result); @@ -594,7 +591,7 @@ protected: EDragAndDropType type, void* data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); LLView* childrenHandleHover(S32 x, S32 y, MASK mask); LLView* childrenHandleMouseUp(S32 x, S32 y, MASK mask); @@ -606,14 +603,14 @@ protected: static bool controlListener(const LLSD& newvalue, LLHandle<LLView> handle, std::string type); - typedef std::map<LLString, LLControlVariable*> control_map_t; + typedef std::map<std::string, LLControlVariable*> control_map_t; control_map_t mFloaterControls; private: LLView* mParentView; child_list_t mChildList; - LLString mName; + std::string mName; // location in pixels, relative to surrounding structure, bottom,left=0,0 LLRect mRect; LLRect mBoundingRect; @@ -643,12 +640,12 @@ private: static LLWindow* sWindow; // All root views must know about their window. - typedef std::map<LLString, LLPointer<LLSimpleListener> > dispatch_list_t; + typedef std::map<std::string, LLPointer<LLSimpleListener> > dispatch_list_t; dispatch_list_t mDispatchList; - LLString mControlName; + std::string mControlName; - typedef std::map<LLString, LLView*> dummy_widget_map_t; + typedef std::map<std::string, LLView*> dummy_widget_map_t; dummy_widget_map_t mDummyWidgets; boost::signals::connection mControlConnection; @@ -658,7 +655,7 @@ public: static BOOL sDebugKeys; static S32 sDepth; static BOOL sDebugMouseHandling; - static LLString sMouseHandlerMessage; + static std::string sMouseHandlerMessage; static S32 sSelectID; static BOOL sEditingUI; static LLView* sEditingUIView; diff --git a/indra/llui/llviewborder.cpp b/indra/llui/llviewborder.cpp index 2148957ce3..a4cec9a53f 100644 --- a/indra/llui/llviewborder.cpp +++ b/indra/llui/llviewborder.cpp @@ -35,7 +35,7 @@ static LLRegisterWidget<LLViewBorder> r("view_border"); -LLViewBorder::LLViewBorder( const LLString& name, const LLRect& rect, EBevel bevel, EStyle style, S32 width ) +LLViewBorder::LLViewBorder( const std::string& name, const LLRect& rect, EBevel bevel, EStyle style, S32 width ) : LLView( name, rect, FALSE ), mBevel( bevel ), @@ -277,9 +277,9 @@ BOOL LLViewBorder::getBevelFromAttribute(LLXMLNodePtr node, LLViewBorder::EBevel { if (node->hasAttribute("bevel_style")) { - LLString bevel_string; + std::string bevel_string; node->getAttributeString("bevel_style", bevel_string); - LLString::toLower(bevel_string); + LLStringUtil::toLower(bevel_string); if (bevel_string == "none") { @@ -306,7 +306,7 @@ BOOL LLViewBorder::getBevelFromAttribute(LLXMLNodePtr node, LLViewBorder::EBevel // static LLView* LLViewBorder::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("view_border"); + std::string name("view_border"); node->getAttributeString("name", name); LLViewBorder::EBevel bevel_style = LLViewBorder::BEVEL_IN; diff --git a/indra/llui/llviewborder.h b/indra/llui/llviewborder.h index 3353103e96..d1bea62cb7 100644 --- a/indra/llui/llviewborder.h +++ b/indra/llui/llviewborder.h @@ -41,7 +41,7 @@ public: enum EBevel { BEVEL_IN, BEVEL_OUT, BEVEL_BRIGHT, BEVEL_NONE }; enum EStyle { STYLE_LINE, STYLE_TEXTURE }; - LLViewBorder( const LLString& name, const LLRect& rect, EBevel bevel = BEVEL_OUT, EStyle style = STYLE_LINE, S32 width = 1 ); + LLViewBorder( const std::string& name, const LLRect& rect, EBevel bevel = BEVEL_OUT, EStyle style = STYLE_LINE, S32 width = 1 ); virtual void setValue(const LLSD& val) { setRect(LLRect(val)); } diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index 3604d3f86f..766c1c85b4 100644 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -100,7 +100,7 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) S32 retry_count = 0; while (retry_count < 5) { - if (0 != LLFile::remove(fullpath.c_str())) + if (0 != LLFile::remove(fullpath)) { result = errno; llwarns << "Problem removing " << fullpath << " - errorcode: " @@ -381,10 +381,44 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd return expanded_filename; } +std::string LLDir::getBaseFileName(const std::string& filepath, bool strip_exten) const +{ + std::size_t offset = filepath.find_last_of(getDirDelimiter()); + offset = (offset == std::string::npos) ? 0 : offset+1; + std::string res = filepath.substr(offset, std::string::npos); + if (strip_exten) + { + offset = res.find_last_of('.'); + if (offset != std::string::npos && + offset != 0) // if basename STARTS with '.', don't strip + { + res = res.substr(0, offset); + } + } + return res; +} + +std::string LLDir::getDirName(const std::string& filepath) const +{ + std::size_t offset = filepath.find_last_of(getDirDelimiter()); + S32 len = (offset == std::string::npos) ? 0 : offset; + std::string dirname = filepath.substr(0, len); + return dirname; +} + +std::string LLDir::getExtension(const std::string& filepath) const +{ + std::string basename = getBaseFileName(filepath, false); + std::size_t offset = basename.find_last_of('.'); + std::string exten = (offset == std::string::npos || offset == 0) ? "" : basename.substr(offset+1); + LLStringUtil::toLower(exten); + return exten; +} + std::string LLDir::getTempFilename() const { LLUUID random_uuid; - char uuid_str[64]; /* Flawfinder: ignore */ + std::string uuid_str; random_uuid.generate(); random_uuid.toString(uuid_str); @@ -404,15 +438,15 @@ void LLDir::setLindenUserDir(const std::string &first, const std::string &last) { // some platforms have case-sensitive filesystems, so be // utterly consistent with our firstname/lastname case. - LLString firstlower(first); - LLString::toLower(firstlower); - LLString lastlower(last); - LLString::toLower(lastlower); + std::string firstlower(first); + LLStringUtil::toLower(firstlower); + std::string lastlower(last); + LLStringUtil::toLower(lastlower); mLindenUserDir = getOSUserAppDir(); mLindenUserDir += mDirDelimiter; - mLindenUserDir += firstlower.c_str(); + mLindenUserDir += firstlower; mLindenUserDir += "_"; - mLindenUserDir += lastlower.c_str(); + mLindenUserDir += lastlower; } else { @@ -441,15 +475,15 @@ void LLDir::setPerAccountChatLogsDir(const std::string &first, const std::string { // some platforms have case-sensitive filesystems, so be // utterly consistent with our firstname/lastname case. - LLString firstlower(first); - LLString::toLower(firstlower); - LLString lastlower(last); - LLString::toLower(lastlower); + std::string firstlower(first); + LLStringUtil::toLower(firstlower); + std::string lastlower(last); + LLStringUtil::toLower(lastlower); mPerAccountChatLogsDir = getChatLogsDir(); mPerAccountChatLogsDir += mDirDelimiter; - mPerAccountChatLogsDir += firstlower.c_str(); + mPerAccountChatLogsDir += firstlower; mPerAccountChatLogsDir += "_"; - mPerAccountChatLogsDir += lastlower.c_str(); + mPerAccountChatLogsDir += lastlower; } else { @@ -476,13 +510,13 @@ bool LLDir::setCacheDir(const std::string &path) } else { - LLFile::mkdir(path.c_str()); + LLFile::mkdir(path); std::string tempname = path + mDirDelimiter + "temp"; - LLFILE* file = LLFile::fopen(tempname.c_str(),"wt"); + LLFILE* file = LLFile::fopen(tempname,"wt"); if (file) { fclose(file); - LLFile::remove(tempname.c_str()); + LLFile::remove(tempname); mCacheDir = path; return true; } @@ -515,15 +549,15 @@ void dir_exists_or_crash(const std::string &dir_name) #if LL_WINDOWS // *FIX: lame - it doesn't do the same thing on windows. not so // important since we don't deploy simulator to windows boxes. - LLFile::mkdir(dir_name.c_str(), 0700); + LLFile::mkdir(dir_name, 0700); #else struct stat dir_stat; - if(0 != LLFile::stat(dir_name.c_str(), &dir_stat)) + if(0 != LLFile::stat(dir_name, &dir_stat)) { S32 stat_rv = errno; if(ENOENT == stat_rv) { - if(0 != LLFile::mkdir(dir_name.c_str(), 0700)) // octal + if(0 != LLFile::mkdir(dir_name, 0700)) // octal { llerrs << "Unable to create directory: " << dir_name << llendl; } diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index 4426935e5c..6e7166c81d 100644 --- a/indra/llvfs/lldir.h +++ b/indra/llvfs/lldir.h @@ -93,6 +93,11 @@ class LLDir std::string getExpandedFilename(ELLPath location, const std::string &filename) const; std::string getExpandedFilename(ELLPath location, const std::string &subdir, const std::string &filename) const; + // Base and Directory name extraction + std::string getBaseFileName(const std::string& filepath, bool strip_exten = false) const; + std::string getDirName(const std::string& filepath) const; + std::string getExtension(const std::string& filepath) const; // Excludes '.', e.g getExtension("foo.wav") == "wav" + // random filename in common temporary directory std::string getTempFilename() const; diff --git a/indra/llvfs/lldir_linux.cpp b/indra/llvfs/lldir_linux.cpp index 222c97156e..7fa30b0ff1 100644 --- a/indra/llvfs/lldir_linux.cpp +++ b/indra/llvfs/lldir_linux.cpp @@ -142,8 +142,8 @@ void LLDir_Linux::initAppDirs(const std::string &app_name) { mAppName = app_name; - LLString upper_app_name(app_name); - LLString::toUpper(upper_app_name); + std::string upper_app_name(app_name); + LLStringUtil::toUpper(upper_app_name); char* app_home_env = getenv((upper_app_name + "_USER_DIR").c_str()); /* Flawfinder: ignore */ if (app_home_env) @@ -157,14 +157,14 @@ void LLDir_Linux::initAppDirs(const std::string &app_name) mOSUserAppDir = mOSUserDir; mOSUserAppDir += "/"; mOSUserAppDir += "."; - LLString lower_app_name(app_name); - LLString::toLower(lower_app_name); + std::string lower_app_name(app_name); + LLStringUtil::toLower(lower_app_name); mOSUserAppDir += lower_app_name; } // create any directories we expect to write to. - int res = LLFile::mkdir(mOSUserAppDir.c_str()); + int res = LLFile::mkdir(mOSUserAppDir); if (res == -1) { if (errno != EEXIST) @@ -175,7 +175,7 @@ void LLDir_Linux::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_LOGS,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_LOGS,"")); if (res == -1) { if (errno != EEXIST) @@ -184,7 +184,7 @@ void LLDir_Linux::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS,"")); if (res == -1) { if (errno != EEXIST) @@ -193,7 +193,7 @@ void LLDir_Linux::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_CACHE,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_CACHE,"")); if (res == -1) { if (errno != EEXIST) @@ -202,7 +202,7 @@ void LLDir_Linux::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"")); if (res == -1) { if (errno != EEXIST) diff --git a/indra/llvfs/lldir_solaris.cpp b/indra/llvfs/lldir_solaris.cpp index b13d3d05ea..2e6f616a3a 100644 --- a/indra/llvfs/lldir_solaris.cpp +++ b/indra/llvfs/lldir_solaris.cpp @@ -152,8 +152,8 @@ void LLDir_Solaris::initAppDirs(const std::string &app_name) { mAppName = app_name; - LLString upper_app_name(app_name); - LLString::toUpper(upper_app_name); + std::string upper_app_name(app_name); + LLStringUtil::toUpper(upper_app_name); char* app_home_env = getenv((upper_app_name + "_USER_DIR").c_str()); /* Flawfinder: ignore */ if (app_home_env) @@ -167,14 +167,14 @@ void LLDir_Solaris::initAppDirs(const std::string &app_name) mOSUserAppDir = mOSUserDir; mOSUserAppDir += "/"; mOSUserAppDir += "."; - LLString lower_app_name(app_name); - LLString::toLower(lower_app_name); + std::string lower_app_name(app_name); + LLStringUtil::toLower(lower_app_name); mOSUserAppDir += lower_app_name; } // create any directories we expect to write to. - int res = LLFile::mkdir(mOSUserAppDir.c_str()); + int res = LLFile::mkdir(mOSUserAppDir); if (res == -1) { if (errno != EEXIST) @@ -185,7 +185,7 @@ void LLDir_Solaris::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_LOGS,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_LOGS,"")); if (res == -1) { if (errno != EEXIST) @@ -194,7 +194,7 @@ void LLDir_Solaris::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS,"")); if (res == -1) { if (errno != EEXIST) @@ -203,7 +203,7 @@ void LLDir_Solaris::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_CACHE,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_CACHE,"")); if (res == -1) { if (errno != EEXIST) @@ -212,7 +212,7 @@ void LLDir_Solaris::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"")); if (res == -1) { if (errno != EEXIST) diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index 17723b36d1..0632813b15 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -141,7 +141,7 @@ void LLDir_Win32::initAppDirs(const std::string &app_name) mOSUserAppDir += "\\"; mOSUserAppDir += app_name; - int res = LLFile::mkdir(mOSUserAppDir.c_str()); + int res = LLFile::mkdir(mOSUserAppDir); if (res == -1) { if (errno != EEXIST) @@ -153,7 +153,7 @@ void LLDir_Win32::initAppDirs(const std::string &app_name) } //dumpCurrentDirectories(); - res = LLFile::mkdir(getExpandedFilename(LL_PATH_LOGS,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_LOGS,"")); if (res == -1) { if (errno != EEXIST) @@ -162,7 +162,7 @@ void LLDir_Win32::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS,"")); if (res == -1) { if (errno != EEXIST) @@ -171,7 +171,7 @@ void LLDir_Win32::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_CACHE,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_CACHE,"")); if (res == -1) { if (errno != EEXIST) @@ -180,7 +180,7 @@ void LLDir_Win32::initAppDirs(const std::string &app_name) } } - res = LLFile::mkdir(getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"").c_str()); + res = LLFile::mkdir(getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"")); if (res == -1) { if (errno != EEXIST) @@ -349,7 +349,7 @@ BOOL LLDir_Win32::fileExists(const std::string &filename) llstat stat_data; // Check the age of the file // Now, we see if the files we've gathered are recent... - int res = LLFile::stat(filename.c_str(), &stat_data); + int res = LLFile::stat(filename, &stat_data); if (!res) { return TRUE; diff --git a/indra/llvfs/lllfsthread.cpp b/indra/llvfs/lllfsthread.cpp index 76e25e2272..daede0bfc0 100644 --- a/indra/llvfs/lllfsthread.cpp +++ b/indra/llvfs/lllfsthread.cpp @@ -81,7 +81,7 @@ LLLFSThread::~LLLFSThread() //---------------------------------------------------------------------------- -LLLFSThread::handle_t LLLFSThread::read(const LLString& filename, /* Flawfinder: ignore */ +LLLFSThread::handle_t LLLFSThread::read(const std::string& filename, /* Flawfinder: ignore */ U8* buffer, S32 offset, S32 numbytes, Responder* responder, U32 priority) { @@ -104,7 +104,7 @@ LLLFSThread::handle_t LLLFSThread::read(const LLString& filename, /* Flawfinder: return handle; } -LLLFSThread::handle_t LLLFSThread::write(const LLString& filename, +LLLFSThread::handle_t LLLFSThread::write(const std::string& filename, U8* buffer, S32 offset, S32 numbytes, Responder* responder, U32 priority) { @@ -130,7 +130,7 @@ LLLFSThread::handle_t LLLFSThread::write(const LLString& filename, LLLFSThread::Request::Request(LLLFSThread* thread, handle_t handle, U32 priority, - operation_t op, const LLString& filename, + operation_t op, const std::string& filename, U8* buffer, S32 offset, S32 numbytes, Responder* responder) : QueuedRequest(handle, priority, FLAG_AUTO_COMPLETE), diff --git a/indra/llvfs/lllfsthread.h b/indra/llvfs/lllfsthread.h index 2a23f550e7..7592ee1839 100644 --- a/indra/llvfs/lllfsthread.h +++ b/indra/llvfs/lllfsthread.h @@ -75,7 +75,7 @@ public: public: Request(LLLFSThread* thread, handle_t handle, U32 priority, - operation_t op, const LLString& filename, + operation_t op, const std::string& filename, U8* buffer, S32 offset, S32 numbytes, Responder* responder); @@ -95,7 +95,7 @@ public: { return mBuffer; } - const LLString& getFilename() + const std::string& getFilename() { return mFileName; } @@ -108,7 +108,7 @@ public: LLLFSThread* mThread; operation_t mOperation; - LLString mFileName; + std::string mFileName; U8* mBuffer; // dest for reads, source for writes, new UUID for rename S32 mOffset; // offset into file, -1 = append (WRITE only) @@ -124,10 +124,10 @@ public: ~LLLFSThread(); // Return a Request handle - handle_t read(const LLString& filename, /* Flawfinder: ignore */ + handle_t read(const std::string& filename, /* Flawfinder: ignore */ U8* buffer, S32 offset, S32 numbytes, Responder* responder, U32 pri=0); - handle_t write(const LLString& filename, + handle_t write(const std::string& filename, U8* buffer, S32 offset, S32 numbytes, Responder* responder, U32 pri=0); diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp index cb04dee834..07c6124544 100644 --- a/indra/llvfs/llvfs.cpp +++ b/indra/llvfs/llvfs.cpp @@ -232,7 +232,7 @@ struct LLVFSFileBlock_less const S32 LLVFSFileBlock::SERIAL_SIZE = 34; -LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash) +LLVFS::LLVFS(const std::string& index_filename, const std::string& data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash) : mRemoveAfterCrash(remove_after_crash) { mDataMutex = new LLMutex(0); @@ -244,15 +244,8 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r } mValid = VFSVALID_OK; mReadOnly = read_only; - mIndexFilename = new char[strlen(index_filename) + 1]; /* Flawfinder: ignore */ - mDataFilename = new char[strlen(data_filename) + 1]; /* Flawfinder: ignore */ - if (mIndexFilename == NULL || mDataFilename == NULL) - { - LL_ERRS("VFS") << "Memory Allocation Failure" << LL_ENDL; - return; - } - strcpy(mIndexFilename, index_filename); /* Flawfinder: ignore */ - strcpy(mDataFilename, data_filename); /* Flawfinder: ignore */ + mIndexFilename = index_filename; + mDataFilename = data_filename; const char *file_mode = mReadOnly ? "rb" : "r+b"; @@ -276,23 +269,13 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r { LL_WARNS("VFS") << "Can't open VFS data file " << mDataFilename << " attempting to use alternate" << LL_ENDL; - char *temp_index = new char[strlen(mIndexFilename) + 10]; /* Flawfinder: ignore */ - if (!temp_index) - { - LL_ERRS("VFS") << "Out of the memory in LLVFS::LLVFS()" << LL_ENDL; - return; - } - char *temp_data = new char[strlen(mDataFilename) + 10]; /* Flawfinder: ignore */ - if (!temp_data) - { - LL_ERRS("VFS") << "Out of the memory in LLVFS::LLVFS()" << LL_ENDL; - return; - } + std::string temp_index; + std::string temp_data; for (U32 count = 0; count < 256; count++) { - sprintf(temp_index, "%s.%u", mIndexFilename, count); /* Flawfinder: ignore */ - sprintf(temp_data, "%s.%u", mDataFilename, count); /* Flawfinder: ignore */ + temp_index = mIndexFilename + llformat(".%u",count); + temp_data = mDataFilename + llformat(".%u", count); // try just opening, then creating, each alternate if ((mDataFP = openAndLock(temp_data, "r+b", FALSE))) @@ -312,14 +295,9 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r { LL_WARNS("VFS") << "Couldn't open vfs data file after trying many alternates" << LL_ENDL; mValid = VFSVALID_BAD_CANNOT_CREATE; - delete[] temp_index; - delete[] temp_data; return; } - delete[] mIndexFilename; - delete[] mDataFilename; - mIndexFilename = temp_index; mDataFilename = temp_data; } @@ -335,13 +313,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r if (!mReadOnly && mRemoveAfterCrash) { llstat marker_info; - char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1]; /* Flawfinder: ignore */ - if (!marker ) - { - LL_ERRS("VFS") << "Out of memory in LLVFS::LLVFS()" << LL_ENDL; - return; - } - sprintf(marker, "%s.open", mDataFilename); /* Flawfinder: ignore */ + std::string marker = mDataFilename + ".open"; if (!LLFile::stat(marker, &marker_info)) { // marker exists, kill the lock and the VFS files @@ -366,8 +338,6 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r presizeDataFile(presize); } } - delete [] marker; - marker = NULL; } // determine the real file size @@ -590,21 +560,13 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r // Open marker file to look for bad shutdowns if (!mReadOnly && mRemoveAfterCrash) { - char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1]; - if (!marker) - { - LL_ERRS("VFS") << "Out of memory in LLVFS::LLVFS()" << LL_ENDL; - return; - } - sprintf(marker, "%s.open", mDataFilename); /* Flawfinder: ignore */ + std::string marker = mDataFilename + ".open"; LLFILE* marker_fp = LLFile::fopen(marker, "w"); /* Flawfinder: ignore */ if (marker_fp) { fclose(marker_fp); marker_fp = NULL; } - delete [] marker; - marker = NULL; } LL_WARNS("VFS") << "Using index file " << mIndexFilename << LL_ENDL; @@ -640,23 +602,10 @@ LLVFS::~LLVFS() // Remove marker file if (!mReadOnly && mRemoveAfterCrash) { - char* marker_file = new char[strlen(mDataFilename) + strlen(".open") + 1]; - if (marker_file == NULL) - { - LL_ERRS("VFS") << "Memory Allocation Failure" << LL_ENDL; - return; - } - sprintf(marker_file, "%s.open", mDataFilename); /* Flawfinder: ignore */ - LLFile::remove(marker_file); - delete [] marker_file; - marker_file = NULL; + std::string marker = mDataFilename + ".open"; + LLFile::remove(marker); } - delete[] mIndexFilename; - mIndexFilename = NULL; - delete[] mDataFilename; - mDataFilename = NULL; - delete mDataMutex; } @@ -2042,9 +1991,9 @@ void LLVFS::dumpStatistics() } // Debug Only! -LLString get_extension(LLAssetType::EType type) +std::string get_extension(LLAssetType::EType type) { - LLString extension; + std::string extension; switch(type) { case LLAssetType::AT_TEXTURE: @@ -2085,7 +2034,7 @@ void LLVFS::listFiles() if (length != BLOCK_LENGTH_INVALID && size > 0) { LLUUID id = file_spec.mFileID; - LLString extension = get_extension(file_spec.mFileType); + std::string extension = get_extension(file_spec.mFileType); llinfos << " File: " << id << " Type: " << LLAssetType::getDesc(file_spec.mFileType) << " Size: " << size @@ -2117,8 +2066,8 @@ void LLVFS::dumpFiles() getData(id, type, buffer, 0, size); lockData(); - LLString extension = get_extension(type); - LLString filename = id.asString() + extension; + std::string extension = get_extension(type); + std::string filename = id.asString() + extension; llinfos << " Writing " << filename << llendl; apr_file_t* file = ll_apr_file_open(filename, LL_APR_WB); ll_apr_file_write(file, buffer, size); @@ -2135,7 +2084,7 @@ void LLVFS::dumpFiles() //============================================================================ // static -LLFILE *LLVFS::openAndLock(const char *filename, const char *mode, BOOL read_lock) +LLFILE *LLVFS::openAndLock(const std::string& filename, const char* mode, BOOL read_lock) { #if LL_WINDOWS @@ -2153,7 +2102,7 @@ LLFILE *LLVFS::openAndLock(const char *filename, const char *mode, BOOL read_loc fl.l_start = 0; fl.l_len = 1; #else // !LL_SOLARIS - if (strstr(mode, "w")) + if (strchr(mode, 'w') != NULL) { fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */ if (fp) diff --git a/indra/llvfs/llvfs.h b/indra/llvfs/llvfs.h index 8ed0afe12f..071305d3e6 100644 --- a/indra/llvfs/llvfs.h +++ b/indra/llvfs/llvfs.h @@ -78,7 +78,7 @@ class LLVFS { public: // Pass 0 to not presize - LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash); + LLVFS(const std::string& index_filename, const std::string& data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash); ~LLVFS(); BOOL isValid() const { return (VFSVALID_OK == mValid); } @@ -131,8 +131,8 @@ protected: void sync(LLVFSFileBlock *block, BOOL remove = FALSE); void presizeDataFile(const U32 size); - static LLFILE *openAndLock(const char *filename, const char *mode, BOOL read_lock); - static void unlockAndClose(LLFILE *fp); + static LLFILE *openAndLock(const std::string& filename, const char* mode, BOOL read_lock); + static void unlockAndClose(FILE *fp); // Can initiate LRU-based file removal to make space. // The immune file block will not be removed. @@ -158,8 +158,8 @@ protected: std::deque<S32> mIndexHoles; - char *mIndexFilename; - char *mDataFilename; + std::string mIndexFilename; + std::string mDataFilename; BOOL mReadOnly; EVFSValid mValid; diff --git a/indra/llvfs/llvfsthread.h b/indra/llvfs/llvfsthread.h index 6028199055..4e20e98d1d 100644 --- a/indra/llvfs/llvfsthread.h +++ b/indra/llvfs/llvfsthread.h @@ -87,9 +87,9 @@ public: } std::string getFilename() { - char tbuf[40]; /* Flawfinder: ignore */ - mFileID.toString(tbuf); - return std::string(tbuf); + std::string tstring; + mFileID.toString(tstring); + return tstring; } /*virtual*/ bool processRequest(); diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp index e3cbf6d9d2..053da0279c 100644 --- a/indra/llwindow/lldxhardware.cpp +++ b/indra/llwindow/lldxhardware.cpp @@ -150,7 +150,7 @@ S32 LLVersion::getField(const S32 field_num) } } -LLString LLDXDriverFile::dump() +std::string LLDXDriverFile::dump() { if (gWriteDebug) { @@ -237,7 +237,7 @@ void LLDXHardware::cleanup() } /* -LLString LLDXHardware::dumpDevices() +std::string LLDXHardware::dumpDevices() { if (gWriteDebug) { diff --git a/indra/llwindow/lldxhardware.h b/indra/llwindow/lldxhardware.h index e174b322b0..4f3254a8d7 100644 --- a/indra/llwindow/lldxhardware.h +++ b/indra/llwindow/lldxhardware.h @@ -53,7 +53,7 @@ protected: class LLDXDriverFile { public: - LLString dump(); + std::string dump(); public: std::string mFilepath; @@ -103,7 +103,7 @@ public: // ANY of them to match and return. // LLDXDevice *findDevice(const std::string &vendor, const std::string &devices); - // LLString dumpDevices(); + // std::string dumpDevices(); public: typedef std::map<std::string, LLDXDevice *> device_map_t; // device_map_t mDevices; diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index 9ed3c9b12d..5e6a412b06 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -43,8 +43,8 @@ LLKeyboard *gKeyboard = NULL; //static -std::map<KEY,LLString> LLKeyboard::sKeysToNames; -std::map<LLString,KEY> LLKeyboard::sNamesToKeys; +std::map<KEY,std::string> LLKeyboard::sKeysToNames; +std::map<std::string,KEY> LLKeyboard::sNamesToKeys; // // Class Implementation @@ -144,11 +144,11 @@ LLKeyboard::~LLKeyboard() // nothing } -void LLKeyboard::addKeyName(KEY key, const LLString& name) +void LLKeyboard::addKeyName(KEY key, const std::string& name) { sKeysToNames[key] = name; - LLString nameuc = name; - LLString::toUpper(nameuc); + std::string nameuc = name; + LLStringUtil::toUpper(nameuc); sNamesToKeys[nameuc] = key; } @@ -294,9 +294,9 @@ S32 LLKeyboard::getKeyElapsedFrameCount(KEY key) } // static -BOOL LLKeyboard::keyFromString(const LLString& str, KEY *key) +BOOL LLKeyboard::keyFromString(const std::string& str, KEY *key) { - LLString instring(str); + std::string instring(str); size_t length = instring.size(); if (length < 1) @@ -318,7 +318,7 @@ BOOL LLKeyboard::keyFromString(const LLString& str, KEY *key) } } - LLString::toUpper(instring); + LLStringUtil::toUpper(instring); KEY res = get_if_there(sNamesToKeys, instring, (KEY)0); if (res != 0) { @@ -331,15 +331,15 @@ BOOL LLKeyboard::keyFromString(const LLString& str, KEY *key) // static -LLString LLKeyboard::stringFromKey(KEY key) +std::string LLKeyboard::stringFromKey(KEY key) { - LLString res = get_if_there(sKeysToNames, key, LLString::null); + std::string res = get_if_there(sKeysToNames, key, std::string()); if (res.empty()) { char buffer[2]; /* Flawfinder: ignore */ buffer[0] = key; buffer[1] = '\0'; - res = LLString(buffer); + res = std::string(buffer); } return res; } @@ -347,9 +347,9 @@ LLString LLKeyboard::stringFromKey(KEY key) //static -BOOL LLKeyboard::maskFromString(const LLString& str, MASK *mask) +BOOL LLKeyboard::maskFromString(const std::string& str, MASK *mask) { - LLString instring(str); + std::string instring(str); if (instring == "NONE") { *mask = MASK_NONE; diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 55af6fed6f..05303c85c2 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -107,9 +107,9 @@ public: EKeyboardInsertMode getInsertMode() { return mInsertMode; } void toggleInsertMode(); - static BOOL maskFromString(const LLString& str, MASK *mask); // False on failure - static BOOL keyFromString(const LLString& str, KEY *key); // False on failure - static LLString stringFromKey(KEY key); + static BOOL maskFromString(const std::string& str, MASK *mask); // False on failure + static BOOL keyFromString(const std::string& str, KEY *key); // False on failure + static std::string stringFromKey(KEY key); e_numpad_distinct getNumpadDistinct() { return mNumpadDistinct; } void setNumpadDistinct(e_numpad_distinct val) { mNumpadDistinct = val; } @@ -119,7 +119,7 @@ public: S32 getKeyElapsedFrameCount( KEY key ); // Returns time in frames since key was pressed. protected: - void addKeyName(KEY key, const LLString& name); + void addKeyName(KEY key, const std::string& name); protected: std::map<U16, KEY> mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs @@ -139,8 +139,8 @@ protected: EKeyboardInsertMode mInsertMode; - static std::map<KEY,LLString> sKeysToNames; - static std::map<LLString,KEY> sNamesToKeys; + static std::map<KEY,std::string> sKeysToNames; + static std::map<std::string,KEY> sNamesToKeys; }; extern LLKeyboard *gKeyboard; diff --git a/indra/llwindow/llmousehandler.h b/indra/llwindow/llmousehandler.h index e3ef37e4e7..6fbdbe3c3e 100644 --- a/indra/llwindow/llmousehandler.h +++ b/indra/llwindow/llmousehandler.h @@ -51,8 +51,8 @@ public: virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask) = 0; - virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) = 0; - virtual const LLString& getName() const = 0; + virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) = 0; + virtual const std::string& getName() const = 0; virtual void onMouseCaptureLost() = 0; diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index d954bdf86b..5f46b36c68 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -58,13 +58,13 @@ BOOL gDebugClicks = FALSE; BOOL gDebugWindowProc = FALSE; const S32 gURLProtocolWhitelistCount = 3; -const char* gURLProtocolWhitelist[] = { "file", "http", "https" }; +const std::string gURLProtocolWhitelist[] = { "file:", "http:", "https:" }; // CP: added a handler list - this is what's used to open the protocol and is based on registry entry // only meaningful difference currently is that file: protocols are opened using http: // since no protocol handler exists in registry for file: // Important - these lists should match - protocol to handler -const char* gURLProtocolWhitelistHandler[] = { "http", "http", "https" }; +const std::string gURLProtocolWhitelistHandler[] = { "http", "http", "https" }; BOOL LLWindowCallbacks::handleTranslatedKeyDown(const KEY key, const MASK mask, BOOL repeated) { @@ -203,7 +203,7 @@ BOOL LLWindowCallbacks::handleDeviceChange(LLWindow *window) return FALSE; } -S32 OSMessageBox(const char* text, const char* caption, U32 type) +S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) { // Properly hide the splash screen when displaying the message box BOOL was_visible = FALSE; @@ -389,7 +389,7 @@ void LLSplashScreen::show() } //static -void LLSplashScreen::update(const char* str) +void LLSplashScreen::update(const std::string& str) { LLSplashScreen::show(); if (gSplashScreenp) @@ -417,8 +417,8 @@ void LLSplashScreen::hide() static std::set<LLWindow*> sWindowList; LLWindow* LLWindowManager::createWindow( - const char *title, - const char *name, + const std::string& title, + const std::string& name, LLCoordScreen upper_left, LLCoordScreen size, U32 flags, @@ -434,7 +434,7 @@ LLWindow* LLWindowManager::createWindow( } LLWindow* LLWindowManager::createWindow( - const char *title, const char *name, S32 x, S32 y, S32 width, S32 height, U32 flags, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 9fc91d3643..84ea9755fd 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -32,8 +32,6 @@ #ifndef LL_LLWINDOW_H #define LL_LLWINDOW_H -#include <sys/stat.h> - #include "llrect.h" #include "llcoord.h" #include "llstring.h" @@ -197,10 +195,6 @@ public: virtual void bringToFront() = 0; virtual void focusClient() { }; // this may not have meaning or be required on other platforms, therefore, it's not abstract - virtual S32 stat( const char* file_name, struct stat* stat_info ) = 0; - virtual BOOL sendEmail(const char* address,const char* subject,const char* body_text, const char* attachment=NULL, const char* attachment_displayed_name=NULL ) = 0; - - // handy coordinate space conversion routines // NB: screen to window and vice verse won't work on width/height coordinate pairs, // as the conversion must take into account left AND right border widths, etc. @@ -233,6 +227,7 @@ public: virtual void setLanguageTextInput( const LLCoordGL & pos ) {}; virtual void updateLanguageTextInputArea() {} virtual void interruptLanguageTextInput() {} + virtual void spawnWebBrowser(const std::string& escaped_url) {}; static std::string getFontListSans(); @@ -293,13 +288,13 @@ public: static LLSplashScreen * create(); static void show(); static void hide(); - static void update(const char* string); + static void update(const std::string& string); static bool isVisible(); protected: // These are overridden by the platform implementation virtual void showImpl() = 0; - virtual void updateImpl(const char* string) = 0; + virtual void updateImpl(const std::string& string) = 0; virtual void hideImpl() = 0; static BOOL sVisible; @@ -307,7 +302,7 @@ protected: }; // Platform-neutral for accessing the platform specific message box -S32 OSMessageBox(const char* text, const char* caption, U32 type); +S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type); const U32 OSMB_OK = 0; const U32 OSMB_OKCANCEL = 1; const U32 OSMB_YESNO = 2; @@ -325,8 +320,8 @@ class LLWindowManager { public: static LLWindow* createWindow( - const char *title, - const char *name, + const std::string& title, + const std::string& name, LLCoordScreen upper_left = LLCoordScreen(10, 10), LLCoordScreen size = LLCoordScreen(320, 240), U32 flags = 0, @@ -336,7 +331,7 @@ public: BOOL use_gl = TRUE, BOOL ignore_pixel_depth = FALSE); static LLWindow *createWindow( - const char* title, const char* name, S32 x, S32 y, S32 width, S32 height, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags = 0, BOOL fullscreen = FALSE, BOOL clearBg = FALSE, @@ -355,11 +350,8 @@ extern BOOL gDebugWindowProc; // Protocols, like "http" and "https" we support in URLs extern const S32 gURLProtocolWhitelistCount; -extern const char* gURLProtocolWhitelist[]; -extern const char* gURLProtocolWhitelistHandler[]; - -// Loads a URL with the user's default browser -void spawn_web_browser(const char* escaped_url); +extern const std::string gURLProtocolWhitelist[]; +extern const std::string gURLProtocolWhitelistHandler[]; void simpleEscapeString ( std::string& stringIn ); diff --git a/indra/llwindow/llwindowheadless.cpp b/indra/llwindow/llwindowheadless.cpp index 77bee891b7..87cf3e0b86 100644 --- a/indra/llwindow/llwindowheadless.cpp +++ b/indra/llwindow/llwindowheadless.cpp @@ -37,7 +37,7 @@ // // LLWindowHeadless // -LLWindowHeadless::LLWindowHeadless(const char *title, const char *name, S32 x, S32 y, S32 width, S32 height, +LLWindowHeadless::LLWindowHeadless(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth) : LLWindow(fullscreen, flags) diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h index 1970a03931..ef1be057c0 100644 --- a/indra/llwindow/llwindowheadless.h +++ b/indra/llwindow/llwindowheadless.h @@ -77,12 +77,6 @@ public: /*virtual*/ void delayInputProcessing() {}; /*virtual*/ void swapBuffers(); - /*virtual*/ LLString getTempFileName() {return LLString(""); }; - /*virtual*/ void deleteFile( const char* file_name ) {}; - /*virtual*/ S32 stat( const char* file_name, struct stat* stat_info ) {return 0; }; - /*virtual*/ BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL) { return FALSE; }; - - // handy coordinate space conversion routines /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to) { return FALSE; }; /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to) { return FALSE; }; @@ -99,7 +93,7 @@ public: /*virtual*/ void *getPlatformWindow() { return 0; }; /*virtual*/ void bringToFront() {}; - LLWindowHeadless(const char *title, const char *name, S32 x, S32 y, S32 width, S32 height, + LLWindowHeadless(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth); virtual ~LLWindowHeadless(); @@ -114,7 +108,7 @@ public: virtual ~LLSplashScreenHeadless() {}; /*virtual*/ void showImpl() {}; - /*virtual*/ void updateImpl(const char* mesg) {}; + /*virtual*/ void updateImpl(const std::string& mesg) {}; /*virtual*/ void hideImpl() {}; }; diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 22b594d745..65f0a2b7e2 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -64,35 +64,11 @@ BOOL LLWindowMacOSX::sUseMultGL = FALSE; // Cross-platform bits: -void show_window_creation_error(const char* title) -{ - llwarns << title << llendl; - /* - OSMessageBox( - "Second Life is unable to run because it can't set up your display.\n" - "We need to be able to make a 32-bit color window at 1024x768, with\n" - "an 8 bit alpha channel.\n" - "\n" - "First, be sure your monitor is set to True Color (32-bit) in\n" - "Start -> Control Panels -> Display -> Settings.\n" - "\n" - "Otherwise, this may be due to video card driver issues.\n" - "Please make sure you have the latest video card drivers installed.\n" - "ATI drivers are available at http://www.ati.com/\n" - "nVidia drivers are available at http://www.nvidia.com/\n" - "\n" - "If you continue to receive this message, contact customer service.", - title, - OSMB_OK); - */ -} - BOOL check_for_card(const char* RENDERER, const char* bad_card) { if (!strnicmp(RENDERER, bad_card, strlen(bad_card))) { - char buffer[1024];/* Flawfinder: ignore */ - snprintf(buffer, sizeof(buffer), + std::string buffer = llformat( "Your video card appears to be a %s, which Second Life does not support.\n" "\n" "Second Life requires a video card with 32 Mb of memory or more, as well as\n" @@ -106,7 +82,7 @@ BOOL check_for_card(const char* RENDERER, const char* bad_card) "You can try to run Second Life, but it will probably crash or run\n" "very slowly. Try anyway?", bad_card); - S32 button = OSMessageBox(buffer, "Unsupported video card", OSMB_YESNO); + S32 button = OSMessageBox(buffer.c_str(), "Unsupported video card", OSMB_YESNO); if (OSBTN_YES == button) { return FALSE; @@ -120,8 +96,6 @@ BOOL check_for_card(const char* RENDERER, const char* bad_card) return FALSE; } - - // Switch to determine whether we capture all displays, or just the main one. // We may want to base this on the setting of _DEBUG... @@ -238,7 +212,7 @@ static LLWindowMacOSX *gWindowImplementation = NULL; -LLWindowMacOSX::LLWindowMacOSX(const char *title, const char *name, S32 x, S32 y, S32 width, +LLWindowMacOSX::LLWindowMacOSX(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, @@ -285,8 +259,8 @@ LLWindowMacOSX::LLWindowMacOSX(const char *title, const char *name, S32 x, S32 y mOriginalAspectRatio = (double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); // Stash the window title - strcpy((char*)mWindowTitle + 1, title); /* Flawfinder: ignore */ - mWindowTitle[0] = strlen(title); /* Flawfinder: ignore */ + strcpy((char*)mWindowTitle + 1, title.c_str()); /* Flawfinder: ignore */ + mWindowTitle[0] = title.length(); mEventHandlerUPP = NewEventHandlerUPP(staticEventHandler); mGlobalHandlerRef = NULL; @@ -463,8 +437,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits mFullscreenBits = -1; mFullscreenRefresh = -1; - char error[256]; /* Flawfinder: ignore */ - snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); + std::string error= llformat("Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); OSMessageBox(error, "Error", OSMB_OK); } } @@ -822,9 +795,6 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits } } - //make sure multisample starts off disabled - glDisable(GL_MULTISAMPLE_ARB); - // Don't need to get the current gamma, since there's a call that restores it to the system defaults. return TRUE; } @@ -1606,11 +1576,6 @@ void LLWindowMacOSX::afterDialog() } -S32 LLWindowMacOSX::stat(const char* file_name, struct stat* stat_info) -{ - return ::stat( file_name, stat_info ); -} - void LLWindowMacOSX::flashIcon(F32 seconds) { // Don't do this if we're already started, since this would try to install the NMRec twice. @@ -1740,15 +1705,6 @@ BOOL LLWindowMacOSX::copyTextToClipboard(const LLWString &s) } -BOOL LLWindowMacOSX::sendEmail(const char* address, const char* subject, const char* body_text, - const char* attachment, const char* attachment_displayed_name ) -{ - // MBW -- XXX -- Um... yeah. I'll get to this later. - - return false; -} - - // protected BOOL LLWindowMacOSX::resetDisplayResolution() { @@ -1945,7 +1901,7 @@ BOOL LLWindowMacOSX::convertCoords(LLCoordGL from, LLCoordScreen *to) -void LLWindowMacOSX::setupFailure(const char* text, const char* caption, U32 type) +void LLWindowMacOSX::setupFailure(const std::string& text, const std::string& caption, U32 type) { destroyContext(); @@ -3016,20 +2972,13 @@ void LLSplashScreenMacOSX::showImpl() #endif } -void LLSplashScreenMacOSX::updateImpl(const char* mesg) +void LLSplashScreenMacOSX::updateImpl(const std::string& mesg) { if(mWindow != NULL) { CFStringRef string = NULL; - if(mesg != NULL) - { - string = CFStringCreateWithCString(NULL, mesg, kCFStringEncodingUTF8); - } - else - { - string = CFStringCreateWithCString(NULL, "", kCFStringEncodingUTF8); - } + string = CFStringCreateWithCString(NULL, mesg.c_str(), kCFStringEncodingUTF8); if(string != NULL) { @@ -3064,7 +3013,7 @@ void LLSplashScreenMacOSX::hideImpl() -S32 OSMessageBoxMacOSX(const char* text, const char* caption, U32 type) +S32 OSMessageBoxMacOSX(const std::string& text, const std::string& caption, U32 type) { S32 result = OSBTN_CANCEL; SInt16 retval_mac = 1; @@ -3075,23 +3024,8 @@ S32 OSMessageBoxMacOSX(const char* text, const char* caption, U32 type) AlertType alertType = kAlertCautionAlert; OSStatus err; - if(text != NULL) - { - explanationString = CFStringCreateWithCString(NULL, text, kCFStringEncodingUTF8); - } - else - { - explanationString = CFStringCreateWithCString(NULL, "", kCFStringEncodingUTF8); - } - - if(caption != NULL) - { - errorString = CFStringCreateWithCString(NULL, caption, kCFStringEncodingUTF8); - } - else - { - errorString = CFStringCreateWithCString(NULL, "", kCFStringEncodingUTF8); - } + explanationString = CFStringCreateWithCString(NULL, text.c_str(), kCFStringEncodingUTF8); + errorString = CFStringCreateWithCString(NULL, caption.c_str(), kCFStringEncodingUTF8); params.version = kStdCFStringAlertVersionOne; params.movable = false; @@ -3175,15 +3109,13 @@ S32 OSMessageBoxMacOSX(const char* text, const char* caption, U32 type) // Open a URL with the user's default web browser. // Must begin with protocol identifier. -void spawn_web_browser(const char* escaped_url) +void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url) { bool found = false; S32 i; for (i = 0; i < gURLProtocolWhitelistCount; i++) { - S32 len = strlen(gURLProtocolWhitelist[i]); /* Flawfinder: ignore */ - if (!strncmp(escaped_url, gURLProtocolWhitelist[i], len) - && escaped_url[len] == ':') + if (escaped_url.find(gURLProtocolWhitelist[i]) != std::string::npos) { found = true; break; @@ -3192,7 +3124,7 @@ void spawn_web_browser(const char* escaped_url) if (!found) { - llwarns << "spawn_web_browser() called for url with protocol not on whitelist: " << escaped_url << llendl; + llwarns << "spawn_web_browser called for url with protocol not on whitelist: " << escaped_url << llendl; return; } @@ -3201,7 +3133,7 @@ void spawn_web_browser(const char* escaped_url) llinfos << "Opening URL " << escaped_url << llendl; - CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url, kCFStringEncodingUTF8); + CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8); if (stringRef) { // This will succeed if the string is a full URL, including the http:// diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 171ec9864a..10955b1288 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -86,12 +86,6 @@ public: /*virtual*/ void delayInputProcessing() {}; /*virtual*/ void swapBuffers(); - /*virtual*/ LLString getTempFileName(); - /*virtual*/ void deleteFile( const char* file_name ); - /*virtual*/ S32 stat( const char* file_name, struct stat* stat_info ); - /*virtual*/ BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL); - - // handy coordinate space conversion routines /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to); /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to); @@ -115,12 +109,13 @@ public: /*virtual*/ void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b); /*virtual*/ void interruptLanguageTextInput(); + /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); static std::string getFontListSans(); protected: LLWindowMacOSX( - const char *title, const char *name, int x, int y, int width, int height, U32 flags, + const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples); @@ -154,7 +149,7 @@ protected: // create or re-create the GL context/window. Called from the constructor and switchContext(). BOOL createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync); void destroyContext(); - void setupFailure(const char* text, const char* caption, U32 type); + void setupFailure(const std::string& text, const std::string& caption, U32 type); static pascal OSStatus staticEventHandler (EventHandlerCallRef myHandler, EventRef event, void* userData); OSStatus eventHandler (EventHandlerCallRef myHandler, EventRef event); void adjustCursorDecouple(bool warpingMouse = false); @@ -216,14 +211,14 @@ public: virtual ~LLSplashScreenMacOSX(); /*virtual*/ void showImpl(); - /*virtual*/ void updateImpl(const char* mesg); + /*virtual*/ void updateImpl(const std::string& mesg); /*virtual*/ void hideImpl(); private: WindowRef mWindow; }; -S32 OSMessageBoxMacOSX(const char* text, const char* caption, U32 type); +S32 OSMessageBoxMacOSX(const std::string& text, const std::string& caption, U32 type); void load_url_external(const char* url); diff --git a/indra/llwindow/llwindowmesaheadless.cpp b/indra/llwindow/llwindowmesaheadless.cpp index b24d3b91f8..a6fbf720de 100644 --- a/indra/llwindow/llwindowmesaheadless.cpp +++ b/indra/llwindow/llwindowmesaheadless.cpp @@ -43,7 +43,7 @@ U16 *gMesaBuffer = NULL; // // LLWindowMesaHeadless // -LLWindowMesaHeadless::LLWindowMesaHeadless(const char *title, const char *name, S32 x, S32 y, S32 width, S32 height, +LLWindowMesaHeadless::LLWindowMesaHeadless(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth) : LLWindow(fullscreen, flags) diff --git a/indra/llwindow/llwindowmesaheadless.h b/indra/llwindow/llwindowmesaheadless.h index 4ecc971abb..d81dd31631 100644 --- a/indra/llwindow/llwindowmesaheadless.h +++ b/indra/llwindow/llwindowmesaheadless.h @@ -81,12 +81,6 @@ public: /*virtual*/ void delayInputProcessing() {}; /*virtual*/ void swapBuffers(); - /*virtual*/ LLString getTempFileName() {return LLString(""); }; - /*virtual*/ void deleteFile( const char* file_name ) {}; - /*virtual*/ S32 stat( const char* file_name, struct stat* stat_info ) {return 0; }; - /*virtual*/ BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL) { return FALSE; }; - - // handy coordinate space conversion routines /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to) { return FALSE; }; /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to) { return FALSE; }; @@ -103,7 +97,7 @@ public: /*virtual*/ void *getPlatformWindow() { return 0; }; /*virtual*/ void bringToFront() {}; - LLWindowMesaHeadless(const char *title, const char *name, S32 x, S32 y, S32 width, S32 height, + LLWindowMesaHeadless(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth); ~LLWindowMesaHeadless(); @@ -120,7 +114,7 @@ public: virtual ~LLSplashScreenMesaHeadless() {}; /*virtual*/ void showImpl() {}; - /*virtual*/ void updateImpl(const char* mesg) {}; + /*virtual*/ void updateImpl(const std::string& mesg) {}; /*virtual*/ void hideImpl() {}; }; diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 50925dcebf..23030b559d 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -181,43 +181,7 @@ Display* get_SDL_Display(void) #endif // LL_X11 -BOOL check_for_card(const char* RENDERER, const char* bad_card) -{ - if (!strncasecmp(RENDERER, bad_card, strlen(bad_card))) - { - char buffer[1024]; /* Flawfinder: ignore */ - snprintf(buffer, sizeof(buffer), - "Your video card appears to be a %s, which Second Life does not support.\n" - "\n" - "Second Life requires a video card with 32 Mb of memory or more, as well as\n" - "multitexture support. We explicitly support nVidia GeForce 2 or better, \n" - "and ATI Radeon 8500 or better.\n" - "\n" - "If you own a supported card and continue to receive this message, try \n" - "updating to the latest video card drivers. Otherwise look in the\n" - "secondlife.com support section or e-mail technical support\n" - "\n" - "You can try to run Second Life, but it will probably crash or run\n" - "very slowly. Try anyway?", - bad_card); - S32 button = OSMessageBox(buffer, "Unsupported video card", OSMB_YESNO); - if (OSBTN_YES == button) - { - return FALSE; - } - else - { - return TRUE; - } - } - - return FALSE; -} - - - - -LLWindowSDL::LLWindowSDL(const char *title, S32 x, S32 y, S32 width, +LLWindowSDL::LLWindowSDL(const std::string& title, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, @@ -258,18 +222,11 @@ LLWindowSDL::LLWindowSDL(const char *title, S32 x, S32 y, S32 width, // Get the original aspect ratio of the main device. mOriginalAspectRatio = 1024.0 / 768.0; // !!! *FIX: ? //(double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); - if (!title) - title = "SDL Window"; // *FIX: (???) - - // Stash the window title - mWindowTitle = new char[strlen(title) + 1]; /* Flawfinder: ignore */ - if(mWindowTitle == NULL) - { - llwarns << "Memory allocation failure" << llendl; - return; - } + if (title.empty()) + mWindowTitle = "SDL Window"; // *FIX: (???) + else + mWindowTitle = title; - strcpy(mWindowTitle, title); /* Flawfinder: ignore */ // Create the GL context and set it up for windowed or fullscreen, as appropriate. if(createContext(x, y, width, height, 32, fullscreen, disable_vsync)) { @@ -483,7 +440,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B } SDL_EnableUNICODE(1); - SDL_WM_SetCaption(mWindowTitle, mWindowTitle); + SDL_WM_SetCaption(mWindowTitle.c_str(), mWindowTitle.c_str()); // Set the application icon. SDL_Surface *bmpsurface; @@ -633,8 +590,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B mFullscreenBits = -1; mFullscreenRefresh = -1; - char error[256]; /* Flawfinder: ignore */ - snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); + std::string error = llformat("Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); OSMessageBox(error, "Error", OSMB_OK); } } @@ -824,8 +780,6 @@ LLWindowSDL::~LLWindowSDL() delete []mSupportedResolutions; } - delete[] mWindowTitle; - gWindowImplementation = NULL; } @@ -1206,11 +1160,6 @@ void LLWindowSDL::afterDialog() } -S32 LLWindowSDL::stat(const char* file_name, struct stat* stat_info) -{ - return ::stat( file_name, stat_info ); -} - #if LL_X11 // set/reset the XWMHints flag for 'urgency' that usually makes the icon flash void LLWindowSDL::x11_set_urgent(BOOL urgent) @@ -1775,15 +1724,6 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &s) } #endif // LL_X11 -BOOL LLWindowSDL::sendEmail(const char* address, const char* subject, const char* body_text, - const char* attachment, const char* attachment_displayed_name ) -{ - // MBW -- XXX -- Um... yeah. I'll get to this later. - - return FALSE; -} - - LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_resolutions) { if (!mSupportedResolutions) @@ -1888,7 +1828,7 @@ BOOL LLWindowSDL::convertCoords(LLCoordGL from, LLCoordScreen *to) -void LLWindowSDL::setupFailure(const char* text, const char* caption, U32 type) +void LLWindowSDL::setupFailure(const std::string& text, const std::string& caption, U32 type) { destroyContext(); @@ -2518,7 +2458,7 @@ void LLSplashScreenSDL::showImpl() { } -void LLSplashScreenSDL::updateImpl(const char* mesg) +void LLSplashScreenSDL::updateImpl(const std::string& mesg) { } @@ -2539,7 +2479,7 @@ static void response_callback (GtkDialog *dialog, gtk_main_quit(); } -S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type) +S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 type) { S32 rtn = OSBTN_CANCEL; @@ -2576,9 +2516,7 @@ S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type) buttons = GTK_BUTTONS_YES_NO; break; } - win = gtk_message_dialog_new(NULL, - flags, messagetype, buttons, - text); + win = gtk_message_dialog_new(NULL,flags, messagetype, buttons, text.c_str()); # if LL_X11 // Make GTK tell the window manager to associate this @@ -2600,8 +2538,8 @@ S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type) gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG); - if (caption) - gtk_window_set_title(GTK_WINDOW(win), caption); + if (!caption.empty()) + gtk_window_set_title(GTK_WINDOW(win), caption.c_str()); gint response = GTK_RESPONSE_NONE; g_signal_connect (win, @@ -2725,7 +2663,7 @@ BOOL LLWindowSDL::dialog_color_picker ( F32 *r, F32 *g, F32 *b) return rtn; } #else -S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type) +S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 type) { llinfos << "MSGBOX: " << caption << ": " << text << llendl; return 0; @@ -2737,30 +2675,13 @@ BOOL LLWindowSDL::dialog_color_picker ( F32 *r, F32 *g, F32 *b) } #endif // LL_GTK -// Open a URL with the user's default web browser. -// Must begin with protocol identifier. -void spawn_web_browser(const char* escaped_url) -{ - llinfos << "spawn_web_browser: " << escaped_url << llendl; - #if LL_LINUX || LL_SOLARIS -# if LL_X11 - if (gWindowImplementation && gWindowImplementation->mSDL_Display) - { - maybe_lock_display(); - // Just in case - before forking. - XSync(gWindowImplementation->mSDL_Display, False); - maybe_unlock_display(); - } -# endif // LL_X11 - - std::string cmd; - cmd = gDirUtilp->getAppRODataDir(); - cmd += gDirUtilp->getDirDelimiter(); - cmd += "launch_url.sh"; - char* const argv[] = {(char*)cmd.c_str(), (char*)escaped_url, NULL}; - - fflush(NULL); // flush all buffers before the child inherits them +// extracted from spawnWebBrowser for clarity and to eliminate +// compiler confusion regarding close(int fd) vs. LLWindow::close() +void exec_cmd(const std::string& cmd, const std::string& arg) +{ + char* const argv[] = {(char*)cmd.c_str(), (char*)arg.c_str(), NULL}; + fflush(NULL); pid_t pid = fork(); if (pid == 0) { // child @@ -2784,6 +2705,32 @@ void spawn_web_browser(const char* escaped_url) llwarns << "fork failure." << llendl; } } +} +#endif + +// Open a URL with the user's default web browser. +// Must begin with protocol identifier. +void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url) +{ + llinfos << "spawn_web_browser: " << escaped_url << llendl; + +#if LL_LINUX || LL_SOLARIS +# if LL_X11 + if (mSDL_Display) + { + maybe_lock_display(); + // Just in case - before forking. + XSync(mSDL_Display, False); + maybe_unlock_display(); + } +# endif // LL_X11 + + std::string cmd, arg; + cmd = gDirUtilp->getAppRODataDir().c_str(); + cmd += gDirUtilp->getDirDelimiter().c_str(); + cmd += "launch_url.sh"; + arg = escaped_url; + exec_cmd(cmd, arg); #endif // LL_LINUX || LL_SOLARIS llinfos << "spawn_web_browser returning." << llendl; diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index f878ded891..6ac2a789ac 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -92,11 +92,6 @@ public: /*virtual*/ void gatherInput(); /*virtual*/ void swapBuffers(); - /*virtual*/ LLString getTempFileName(); - /*virtual*/ void deleteFile( const char* file_name ); - /*virtual*/ S32 stat( const char* file_name, struct stat* stat_info ); - /*virtual*/ BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL); - /*virtual*/ void delayInputProcessing() { }; // handy coordinate space conversion routines @@ -120,6 +115,8 @@ public: /*virtual*/ void *getPlatformWindow(); /*virtual*/ void bringToFront(); + /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); + static std::string getFontListSans(); // Not great that these are public, but they have to be accessible @@ -134,7 +131,7 @@ public: protected: LLWindowSDL( - const char *title, int x, int y, int width, int height, U32 flags, + const std::string& title, int x, int y, int width, int height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples); ~LLWindowSDL(); @@ -164,7 +161,7 @@ protected: // create or re-create the GL context/window. Called from the constructor and switchContext(). BOOL createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync); void destroyContext(); - void setupFailure(const char* text, const char* caption, U32 type); + void setupFailure(const std::string& text, const std::string& caption, U32 type); void adjustCursorDecouple(bool warpingMouse = false); void fixWindowSize(void); U32 SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain); @@ -176,7 +173,7 @@ protected: U32 mGrabbyKeyFlags; int mReallyCapturedCount; SDL_Surface * mWindow; - char * mWindowTitle; + std::string mWindowTitle; double mOriginalAspectRatio; BOOL mCursorDecoupled; S32 mCursorLastEventDeltaX; @@ -220,11 +217,11 @@ public: virtual ~LLSplashScreenSDL(); /*virtual*/ void showImpl(); - /*virtual*/ void updateImpl(const char* mesg); + /*virtual*/ void updateImpl(const std::string& mesg); /*virtual*/ void hideImpl(); }; -S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type); +S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 type); void load_url_external(const char* url); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index e715080916..ccff4f3161 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -80,7 +80,7 @@ LLW32MsgCallback gAsyncMsgCallback = NULL; // LLWindowWin32 // -void show_window_creation_error(const char* title) +void show_window_creation_error(const std::string& title) { LL_WARNS("Window") << title << LL_ENDL; } @@ -357,7 +357,7 @@ LLWinImm::~LLWinImm() } -LLWindowWin32::LLWindowWin32(const char *title, const char *name, S32 x, S32 y, S32 width, +LLWindowWin32::LLWindowWin32(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, @@ -384,7 +384,7 @@ LLWindowWin32::LLWindowWin32(const char *title, const char *name, S32 x, S32 y, RECT window_rect; // Set the window title - if (!title) + if (title.empty()) { mWindowTitle = new WCHAR[50]; wsprintf(mWindowTitle, L"OpenGL Window"); @@ -392,12 +392,12 @@ LLWindowWin32::LLWindowWin32(const char *title, const char *name, S32 x, S32 y, else { mWindowTitle = new WCHAR[256]; // Assume title length < 255 chars. - mbstowcs(mWindowTitle, title, 255); + mbstowcs(mWindowTitle, title.c_str(), 255); mWindowTitle[255] = 0; } // Set the window class name - if (!name) + if (name.empty()) { mWindowClassName = new WCHAR[50]; wsprintf(mWindowClassName, L"OpenGL Window"); @@ -405,7 +405,7 @@ LLWindowWin32::LLWindowWin32(const char *title, const char *name, S32 x, S32 y, else { mWindowClassName = new WCHAR[256]; // Assume title length < 255 chars. - mbstowcs(mWindowClassName, name, 255); + mbstowcs(mWindowClassName, name.c_str(), 255); mWindowClassName[255] = 0; } @@ -569,8 +569,7 @@ LLWindowWin32::LLWindowWin32(const char *title, const char *name, S32 x, S32 y, mFullscreenBits = -1; mFullscreenRefresh = -1; - char error[256]; /* Flawfinder: ignore */ - snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); /* Flawfinder: ignore */ + std::string error = llformat("Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); OSMessageBox(error, "Error", OSMB_OK); } } @@ -2375,7 +2374,7 @@ BOOL LLWindowWin32::pasteTextFromClipboard(LLWString &dst) if (utf16str) { dst = utf16str_to_wstring(utf16str); - LLWString::removeCRLF(dst); + LLWStringUtil::removeCRLF(dst); GlobalUnlock(h_data); success = TRUE; } @@ -2398,7 +2397,7 @@ BOOL LLWindowWin32::copyTextToClipboard(const LLWString& wstr) // Provide a copy of the data in Unicode format. LLWString sanitized_string(wstr); - LLWString::addCRLF(sanitized_string); + LLWStringUtil::addCRLF(sanitized_string); llutf16string out_utf16 = wstring_to_utf16str(sanitized_string); const size_t size_utf16 = (out_utf16.length() + 1) * sizeof(WCHAR); @@ -2485,86 +2484,6 @@ BOOL LLWindowWin32::getClientRectInScreenSpace( RECT* rectp ) return success; } - -BOOL LLWindowWin32::sendEmail(const char* address, const char* subject, const char* body_text, - const char* attachment, const char* attachment_displayed_name ) -{ - // Based on "A SendMail() DLL" by Greg Turner, Windows Developer Magazine, Nov. 1997. - // See article for use of GetProcAddress - // No restrictions on use. - - enum SendResult - { - LL_EMAIL_SUCCESS, - LL_EMAIL_MAPI_NOT_INSTALLED, // No MAPI Server (eg Microsoft Exchange) installed - LL_EMAIL_MAPILOAD_FAILED, // Load of MAPI32.DLL failed - LL_EMAIL_SEND_FAILED // The message send itself failed - }; - - SendResult result = LL_EMAIL_SUCCESS; - - U32 mapi_installed = GetProfileInt(L"Mail", L"MAPI", 0); - if( !mapi_installed) - { - result = LL_EMAIL_MAPI_NOT_INSTALLED; - } - else - { - HINSTANCE hMAPIInst = LoadLibrary(L"MAPI32.DLL"); /* Flawfinder: ignore */ - if(!hMAPIInst) - { - result = LL_EMAIL_MAPILOAD_FAILED; - } - else - { - LPMAPISENDMAIL pMAPISendMail = (LPMAPISENDMAIL) GetProcAddress(hMAPIInst, "MAPISendMail"); - - // Send the message - MapiRecipDesc recipients[1]; - recipients[0].ulReserved = 0; - recipients[0].ulRecipClass = MAPI_TO; - recipients[0].lpszName = (char*)address; - recipients[0].lpszAddress = (char*)address; - recipients[0].ulEIDSize = 0; - recipients[0].lpEntryID = 0; - - MapiFileDesc files[1]; - files[0].ulReserved = 0; - files[0].flFlags = 0; // non-OLE file - files[0].nPosition = -1; // Leave file location in email unspecified. - files[0].lpszPathName = (char*)attachment; // Must be fully qualified name, including drive letter. - files[0].lpszFileName = (char*)attachment_displayed_name; // If NULL, uses attachment as displayed name. - files[0].lpFileType = NULL; // Recipient will have to figure out what kind of file this is. - - MapiMessage msg; - memset(&msg, 0, sizeof(msg)); - msg.lpszSubject = (char*)subject; // may be NULL - msg.lpszNoteText = (char*)body_text; - msg.nRecipCount = address ? 1 : 0; - msg.lpRecips = address ? recipients : NULL; - msg.nFileCount = attachment ? 1 : 0; - msg.lpFiles = attachment ? files : NULL; - - U32 success = pMAPISendMail(0, (U32) mWindowHandle, &msg, MAPI_DIALOG|MAPI_LOGON_UI|MAPI_NEW_SESSION, 0); - if(success != SUCCESS_SUCCESS) - { - result = LL_EMAIL_SEND_FAILED; - } - - FreeLibrary(hMAPIInst); - } - } - - return result == LL_EMAIL_SUCCESS; -} - - -S32 LLWindowWin32::stat(const char* file_name, struct stat* stat_info) -{ - llassert( sizeof(struct stat) == sizeof(struct _stat) ); // They are defined identically in sys/stat.h, but I'm paranoid. - return LLFile::stat( file_name, (struct _stat*) stat_info ); -} - void LLWindowWin32::flashIcon(F32 seconds) { FLASHWINFO flash_info; @@ -2802,12 +2721,12 @@ void LLSplashScreenWin32::showImpl() } -void LLSplashScreenWin32::updateImpl(const char *mesg) +void LLSplashScreenWin32::updateImpl(const std::string& mesg) { if (!mWindow) return; WCHAR w_mesg[1024]; - mbstowcs(w_mesg, mesg, 1024); + mbstowcs(w_mesg, mesg.c_str(), 1024); SendDlgItemMessage(mWindow, 666, // HACK: text id @@ -2839,7 +2758,7 @@ LRESULT CALLBACK LLSplashScreenWin32::windowProc(HWND h_wnd, UINT u_msg, // Helper Funcs // -S32 OSMessageBoxWin32(const char* text, const char* caption, U32 type) +S32 OSMessageBoxWin32(const std::string& text, const std::string& caption, U32 type) { UINT uType; @@ -2860,7 +2779,7 @@ S32 OSMessageBoxWin32(const char* text, const char* caption, U32 type) } // HACK! Doesn't properly handle wide strings! - int retval_win = MessageBoxA(NULL, text, caption, uType); + int retval_win = MessageBoxA(NULL, text.c_str(), caption.c_str(), uType); S32 retval; switch(retval_win) @@ -2886,15 +2805,13 @@ S32 OSMessageBoxWin32(const char* text, const char* caption, U32 type) } -void spawn_web_browser(const char* escaped_url ) +void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url ) { bool found = false; S32 i; for (i = 0; i < gURLProtocolWhitelistCount; i++) { - S32 len = strlen(gURLProtocolWhitelist[i]); /* Flawfinder: ignore */ - if (!strncmp(escaped_url, gURLProtocolWhitelist[i], len) - && escaped_url[len] == ':') + if (escaped_url.find(gURLProtocolWhitelist[i]) == 0) { found = true; break; @@ -2930,10 +2847,9 @@ void spawn_web_browser(const char* escaped_url ) // Figure out the user's default web browser // HKEY_CLASSES_ROOT\http\shell\open\command /* - char reg_path_str[256]; // Flawfinder: ignore - snprintf(reg_path_str, sizeof(reg_path_str), "%s\\shell\\open\\command", gURLProtocolWhitelistHandler[i]); // Flawfinder: ignore + std::string reg_path_str = gURLProtocolWhitelistHandler[i] + "\\shell\\open\\command"; WCHAR reg_path_wstr[256]; - mbstowcs(reg_path_wstr, reg_path_str, sizeof(reg_path_wstr)/sizeof(reg_path_wstr[0])); + mbstowcs(reg_path_wstr, reg_path_str.c_str(), sizeof(reg_path_wstr)/sizeof(reg_path_wstr[0])); HKEY key; WCHAR browser_open_wstr[1024]; diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 039774f138..ec9da55826 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -86,12 +86,6 @@ public: /*virtual*/ void delayInputProcessing(); /*virtual*/ void swapBuffers(); - /*virtual*/ LLString getTempFileName(); - /*virtual*/ void deleteFile( const char* file_name ); - /*virtual*/ S32 stat( const char* file_name, struct stat* stat_info ); - /*virtual*/ BOOL sendEmail(const char* address,const char* subject,const char* body_text,const char* attachment=NULL, const char* attachment_displayed_name=NULL); - - // handy coordinate space conversion routines /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to); /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to); @@ -115,12 +109,13 @@ public: /*virtual*/ void setLanguageTextInput( const LLCoordGL & pos ); /*virtual*/ void updateLanguageTextInputArea(); /*virtual*/ void interruptLanguageTextInput(); + /*virtual*/ void spawnWebBrowser(const std::string& escaped_url); static std::string getFontListSans(); protected: LLWindowWin32( - const char *title, const char *name, int x, int y, int width, int height, U32 flags, + const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags, BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples); ~LLWindowWin32(); @@ -220,7 +215,7 @@ public: virtual ~LLSplashScreenWin32(); /*virtual*/ void showImpl(); - /*virtual*/ void updateImpl(const char* mesg); + /*virtual*/ void updateImpl(const std::string& mesg); /*virtual*/ void hideImpl(); #if LL_WINDOWS @@ -239,6 +234,6 @@ extern LPWSTR gIconResource; static void handleMessage( const MSG& msg ); -S32 OSMessageBoxWin32(const char* text, const char* caption, U32 type); +S32 OSMessageBoxWin32(const std::string& text, const std::string& caption, U32 type); #endif //LL_LLWINDOWWIN32_H diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index cb0c4f001a..c5d86f161a 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -99,8 +99,8 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) return result; } -LLControlVariable::LLControlVariable(const LLString& name, eControlType type, - LLSD initial, const LLString& comment, +LLControlVariable::LLControlVariable(const std::string& name, eControlType type, + LLSD initial, const std::string& comment, BOOL persist) : mName(name), mComment(comment), @@ -129,7 +129,7 @@ void LLControlVariable::setValue(const LLSD& value, bool saved_value) if(TYPE_BOOLEAN == type() && value.isString()) { BOOL temp; - if(LLString::convertToBOOL(value.asString(), temp)) + if(LLStringUtil::convertToBOOL(value.asString(), temp)) { storable_value = temp; } @@ -206,7 +206,7 @@ LLSD LLControlVariable::getSaveValue() const return mValues[0]; } -LLControlVariable* LLControlGroup::getControl(const LLString& name) +LLControlVariable* LLControlGroup::getControl(const std::string& name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter == mNameTable.end() ? NULL : iter->second; @@ -242,7 +242,7 @@ void LLControlGroup::cleanup() mNameTable.clear(); } -eControlType LLControlGroup::typeStringToEnum(const LLString& typestr) +eControlType LLControlGroup::typeStringToEnum(const std::string& typestr) { for(int i = 0; i < (int)TYPE_COUNT; ++i) { @@ -251,12 +251,12 @@ eControlType LLControlGroup::typeStringToEnum(const LLString& typestr) return (eControlType)-1; } -LLString LLControlGroup::typeEnumToString(eControlType typeenum) +std::string LLControlGroup::typeEnumToString(eControlType typeenum) { return mTypeString[typeenum]; } -BOOL LLControlGroup::declareControl(const LLString& name, eControlType type, const LLSD initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist) { if(mNameTable.find(name) != mNameTable.end()) { @@ -270,67 +270,67 @@ BOOL LLControlGroup::declareControl(const LLString& name, eControlType type, con return TRUE; } -BOOL LLControlGroup::declareU32(const LLString& name, const U32 initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareU32(const std::string& name, const U32 initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_U32, (LLSD::Integer) initial_val, comment, persist); } -BOOL LLControlGroup::declareS32(const LLString& name, const S32 initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareS32(const std::string& name, const S32 initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_S32, initial_val, comment, persist); } -BOOL LLControlGroup::declareF32(const LLString& name, const F32 initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareF32(const std::string& name, const F32 initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_F32, initial_val, comment, persist); } -BOOL LLControlGroup::declareBOOL(const LLString& name, const BOOL initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareBOOL(const std::string& name, const BOOL initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_BOOLEAN, initial_val, comment, persist); } -BOOL LLControlGroup::declareString(const LLString& name, const LLString& initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_STRING, initial_val, comment, persist); } -BOOL LLControlGroup::declareVec3(const LLString& name, const LLVector3 &initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareVec3(const std::string& name, const LLVector3 &initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_VEC3, initial_val.getValue(), comment, persist); } -BOOL LLControlGroup::declareVec3d(const LLString& name, const LLVector3d &initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_VEC3D, initial_val.getValue(), comment, persist); } -BOOL LLControlGroup::declareRect(const LLString& name, const LLRect &initial_val, const LLString& comment, BOOL persist) +BOOL LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, BOOL persist) { return declareControl(name, TYPE_RECT, initial_val.getValue(), comment, persist); } -BOOL LLControlGroup::declareColor4U(const LLString& name, const LLColor4U &initial_val, const LLString& comment, BOOL persist ) +BOOL LLControlGroup::declareColor4U(const std::string& name, const LLColor4U &initial_val, const std::string& comment, BOOL persist ) { return declareControl(name, TYPE_COL4U, initial_val.getValue(), comment, persist); } -BOOL LLControlGroup::declareColor4(const LLString& name, const LLColor4 &initial_val, const LLString& comment, BOOL persist ) +BOOL LLControlGroup::declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist ) { return declareControl(name, TYPE_COL4, initial_val.getValue(), comment, persist); } -BOOL LLControlGroup::declareColor3(const LLString& name, const LLColor3 &initial_val, const LLString& comment, BOOL persist ) +BOOL LLControlGroup::declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, BOOL persist ) { return declareControl(name, TYPE_COL3, initial_val.getValue(), comment, persist); } -BOOL LLControlGroup::declareLLSD(const LLString& name, const LLSD &initial_val, const LLString& comment, BOOL persist ) +BOOL LLControlGroup::declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, BOOL persist ) { return declareControl(name, TYPE_LLSD, initial_val, comment, persist); } -BOOL LLControlGroup::getBOOL(const LLString& name) +BOOL LLControlGroup::getBOOL(const std::string& name) { LLControlVariable* control = getControl(name); @@ -343,7 +343,7 @@ BOOL LLControlGroup::getBOOL(const LLString& name) } } -S32 LLControlGroup::getS32(const LLString& name) +S32 LLControlGroup::getS32(const std::string& name) { LLControlVariable* control = getControl(name); @@ -356,7 +356,7 @@ S32 LLControlGroup::getS32(const LLString& name) } } -U32 LLControlGroup::getU32(const LLString& name) +U32 LLControlGroup::getU32(const std::string& name) { LLControlVariable* control = getControl(name); @@ -369,7 +369,7 @@ U32 LLControlGroup::getU32(const LLString& name) } } -F32 LLControlGroup::getF32(const LLString& name) +F32 LLControlGroup::getF32(const std::string& name) { LLControlVariable* control = getControl(name); @@ -382,16 +382,16 @@ F32 LLControlGroup::getF32(const LLString& name) } } -LLString LLControlGroup::findString(const LLString& name) +std::string LLControlGroup::findString(const std::string& name) { LLControlVariable* control = getControl(name); if (control && control->isType(TYPE_STRING)) return control->get().asString(); - return LLString::null; + return LLStringUtil::null; } -LLString LLControlGroup::getString(const LLString& name) +std::string LLControlGroup::getString(const std::string& name) { LLControlVariable* control = getControl(name); @@ -400,24 +400,24 @@ LLString LLControlGroup::getString(const LLString& name) else { CONTROL_ERRS << "Invalid string control " << name << llendl; - return LLString::null; + return LLStringUtil::null; } } -LLWString LLControlGroup::getWString(const LLString& name) +LLWString LLControlGroup::getWString(const std::string& name) { return utf8str_to_wstring(getString(name)); } -LLString LLControlGroup::getText(const LLString& name) +std::string LLControlGroup::getText(const std::string& name) { - LLString utf8_string = getString(name); - LLString::replaceChar(utf8_string, '^', '\n'); - LLString::replaceChar(utf8_string, '%', ' '); + std::string utf8_string = getString(name); + LLStringUtil::replaceChar(utf8_string, '^', '\n'); + LLStringUtil::replaceChar(utf8_string, '%', ' '); return (utf8_string); } -LLVector3 LLControlGroup::getVector3(const LLString& name) +LLVector3 LLControlGroup::getVector3(const std::string& name) { LLControlVariable* control = getControl(name); @@ -430,7 +430,7 @@ LLVector3 LLControlGroup::getVector3(const LLString& name) } } -LLVector3d LLControlGroup::getVector3d(const LLString& name) +LLVector3d LLControlGroup::getVector3d(const std::string& name) { LLControlVariable* control = getControl(name); @@ -443,7 +443,7 @@ LLVector3d LLControlGroup::getVector3d(const LLString& name) } } -LLRect LLControlGroup::getRect(const LLString& name) +LLRect LLControlGroup::getRect(const std::string& name) { LLControlVariable* control = getControl(name); @@ -457,7 +457,7 @@ LLRect LLControlGroup::getRect(const LLString& name) } -LLColor4 LLControlGroup::getColor(const LLString& name) +LLColor4 LLControlGroup::getColor(const std::string& name) { ctrl_name_table_t::const_iterator i = mNameTable.find(name); @@ -489,7 +489,7 @@ LLColor4 LLControlGroup::getColor(const LLString& name) } } -LLColor4U LLControlGroup::getColor4U(const LLString& name) +LLColor4U LLControlGroup::getColor4U(const std::string& name) { LLControlVariable* control = getControl(name); @@ -502,7 +502,7 @@ LLColor4U LLControlGroup::getColor4U(const LLString& name) } } -LLColor4 LLControlGroup::getColor4(const LLString& name) +LLColor4 LLControlGroup::getColor4(const std::string& name) { LLControlVariable* control = getControl(name); @@ -515,7 +515,7 @@ LLColor4 LLControlGroup::getColor4(const LLString& name) } } -LLColor3 LLControlGroup::getColor3(const LLString& name) +LLColor3 LLControlGroup::getColor3(const std::string& name) { LLControlVariable* control = getControl(name); @@ -528,7 +528,7 @@ LLColor3 LLControlGroup::getColor3(const LLString& name) } } -LLSD LLControlGroup::getLLSD(const LLString& name) +LLSD LLControlGroup::getLLSD(const std::string& name) { LLControlVariable* control = getControl(name); @@ -538,7 +538,7 @@ LLSD LLControlGroup::getLLSD(const LLString& name) return LLSD(); } -BOOL LLControlGroup::controlExists(const LLString& name) +BOOL LLControlGroup::controlExists(const std::string& name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter != mNameTable.end(); @@ -548,7 +548,7 @@ BOOL LLControlGroup::controlExists(const LLString& name) // Set functions //------------------------------------------------------------------- -void LLControlGroup::setBOOL(const LLString& name, BOOL val) +void LLControlGroup::setBOOL(const std::string& name, BOOL val) { LLControlVariable* control = getControl(name); @@ -563,7 +563,7 @@ void LLControlGroup::setBOOL(const LLString& name, BOOL val) } -void LLControlGroup::setS32(const LLString& name, S32 val) +void LLControlGroup::setS32(const std::string& name, S32 val) { LLControlVariable* control = getControl(name); @@ -578,7 +578,7 @@ void LLControlGroup::setS32(const LLString& name, S32 val) } -void LLControlGroup::setF32(const LLString& name, F32 val) +void LLControlGroup::setF32(const std::string& name, F32 val) { LLControlVariable* control = getControl(name); @@ -593,7 +593,7 @@ void LLControlGroup::setF32(const LLString& name, F32 val) } -void LLControlGroup::setU32(const LLString& name, U32 val) +void LLControlGroup::setU32(const std::string& name, U32 val) { LLControlVariable* control = getControl(name); @@ -608,7 +608,7 @@ void LLControlGroup::setU32(const LLString& name, U32 val) } -void LLControlGroup::setString(const LLString& name, const LLString &val) +void LLControlGroup::setString(const std::string& name, const std::string &val) { LLControlVariable* control = getControl(name); @@ -623,7 +623,7 @@ void LLControlGroup::setString(const LLString& name, const LLString &val) } -void LLControlGroup::setVector3(const LLString& name, const LLVector3 &val) +void LLControlGroup::setVector3(const std::string& name, const LLVector3 &val) { LLControlVariable* control = getControl(name); @@ -637,7 +637,7 @@ void LLControlGroup::setVector3(const LLString& name, const LLVector3 &val) } } -void LLControlGroup::setVector3d(const LLString& name, const LLVector3d &val) +void LLControlGroup::setVector3d(const std::string& name, const LLVector3d &val) { LLControlVariable* control = getControl(name); @@ -651,7 +651,7 @@ void LLControlGroup::setVector3d(const LLString& name, const LLVector3d &val) } } -void LLControlGroup::setRect(const LLString& name, const LLRect &val) +void LLControlGroup::setRect(const std::string& name, const LLRect &val) { LLControlVariable* control = getControl(name); @@ -665,7 +665,7 @@ void LLControlGroup::setRect(const LLString& name, const LLRect &val) } } -void LLControlGroup::setColor4U(const LLString& name, const LLColor4U &val) +void LLControlGroup::setColor4U(const std::string& name, const LLColor4U &val) { LLControlVariable* control = getControl(name); @@ -679,7 +679,7 @@ void LLControlGroup::setColor4U(const LLString& name, const LLColor4U &val) } } -void LLControlGroup::setColor4(const LLString& name, const LLColor4 &val) +void LLControlGroup::setColor4(const std::string& name, const LLColor4 &val) { LLControlVariable* control = getControl(name); @@ -693,7 +693,7 @@ void LLControlGroup::setColor4(const LLString& name, const LLColor4 &val) } } -void LLControlGroup::setLLSD(const LLString& name, const LLSD& val) +void LLControlGroup::setLLSD(const std::string& name, const LLSD& val) { LLControlVariable* control = getControl(name); @@ -707,7 +707,7 @@ void LLControlGroup::setLLSD(const LLString& name, const LLSD& val) } } -void LLControlGroup::setValue(const LLString& name, const LLSD& val) +void LLControlGroup::setValue(const std::string& name, const LLSD& val) { if (name.empty()) { @@ -731,9 +731,9 @@ void LLControlGroup::setValue(const LLString& name, const LLSD& val) //--------------------------------------------------------------- // Returns number of controls loaded, so 0 if failure -U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_declaration, eControlType declare_as) +U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require_declaration, eControlType declare_as) { - LLString name; + std::string name; LLXmlTree xml_controls; @@ -792,14 +792,14 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de switch(declare_as) { case TYPE_COL4: - declareColor4(name, LLColor4::white, "", NO_PERSIST); + declareColor4(name, LLColor4::white, LLStringUtil::null, NO_PERSIST); break; case TYPE_COL4U: - declareColor4U(name, LLColor4U::white, "", NO_PERSIST); + declareColor4U(name, LLColor4U::white, LLStringUtil::null, NO_PERSIST); break; case TYPE_STRING: default: - declareString(name, LLString::null, "", NO_PERSIST); + declareString(name, LLStringUtil::null, LLStringUtil::null, NO_PERSIST); break; } } @@ -851,12 +851,8 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de break; case TYPE_STRING: { - LLString string; + std::string string; child_nodep->getAttributeString("value", string); - if (string == LLString::null) - { - string = ""; - } control->set(string); validitems++; } @@ -883,7 +879,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de case TYPE_RECT: { //RN: hack to support reading rectangles from a string - LLString rect_string; + std::string rect_string; child_nodep->getAttributeString("value", rect_string); std::istringstream istream(rect_string); @@ -937,7 +933,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de return validitems; } -U32 LLControlGroup::saveToFile(const LLString& filename, BOOL nondefault_only) +U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only) { LLSD settings; int num_saved = 0; @@ -967,7 +963,7 @@ U32 LLControlGroup::saveToFile(const LLString& filename, BOOL nondefault_only) } } llofstream file; - file.open(filename.c_str()); + file.open(filename); if (file.is_open()) { LLSDSerialize::toPrettyXML(settings, file); @@ -983,13 +979,13 @@ U32 LLControlGroup::saveToFile(const LLString& filename, BOOL nondefault_only) return num_saved; } -U32 LLControlGroup::loadFromFile(const LLString& filename) +U32 LLControlGroup::loadFromFile(const std::string& filename) { - LLString name; + std::string name; LLSD settings; LLSD control_map; llifstream infile; - infile.open(filename.c_str()); + infile.open(filename); if(!infile.is_open()) { llwarns << "Cannot find file " << filename << " to load." << llendl; @@ -1067,10 +1063,10 @@ void LLControlGroup::applyToAll(ApplyFunctor* func) //============================================================================ // First-use -static LLString get_warn_name(const LLString& name) +static std::string get_warn_name(const std::string& name) { - LLString warnname = "Warn" + name; - for (LLString::iterator iter = warnname.begin(); iter != warnname.end(); ++iter) + std::string warnname = "Warn" + name; + for (std::string::iterator iter = warnname.begin(); iter != warnname.end(); ++iter) { char c = *iter; if (!isalnum(c)) @@ -1081,32 +1077,32 @@ static LLString get_warn_name(const LLString& name) return warnname; } -void LLControlGroup::addWarning(const LLString& name) +void LLControlGroup::addWarning(const std::string& name) { - LLString warnname = get_warn_name(name); + std::string warnname = get_warn_name(name); if(mNameTable.find(warnname) == mNameTable.end()) { - LLString comment = LLString("Enables ") + name + LLString(" warning dialog"); + std::string comment = std::string("Enables ") + name + std::string(" warning dialog"); declareBOOL(warnname, TRUE, comment); mWarnings.insert(warnname); } } -BOOL LLControlGroup::getWarning(const LLString& name) +BOOL LLControlGroup::getWarning(const std::string& name) { - LLString warnname = get_warn_name(name); + std::string warnname = get_warn_name(name); return getBOOL(warnname); } -void LLControlGroup::setWarning(const LLString& name, BOOL val) +void LLControlGroup::setWarning(const std::string& name, BOOL val) { - LLString warnname = get_warn_name(name); + std::string warnname = get_warn_name(name); setBOOL(warnname, val); } void LLControlGroup::resetWarnings() { - for (std::set<LLString>::iterator iter = mWarnings.begin(); + for (std::set<std::string>::iterator iter = mWarnings.begin(); iter != mWarnings.end(); ++iter) { setBOOL(*iter, TRUE); diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index fdbbe11b91..289e85b8a4 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -89,8 +89,8 @@ class LLControlVariable typedef boost::signal<void(const LLSD&)> signal_t; private: - LLString mName; - LLString mComment; + std::string mName; + std::string mComment; eControlType mType; BOOL mPersist; std::vector<LLSD> mValues; @@ -98,14 +98,14 @@ private: signal_t mSignal; public: - LLControlVariable(const LLString& name, eControlType type, - LLSD initial, const LLString& comment, + LLControlVariable(const std::string& name, eControlType type, + LLSD initial, const std::string& comment, BOOL persist = TRUE); virtual ~LLControlVariable(); - const LLString& getName() const { return mName; } - const LLString& getComment() const { return mComment; } + const std::string& getName() const { return mName; } + const std::string& getComment() const { return mComment; } eControlType type() { return mType; } BOOL isType(eControlType tp) { return tp == mType; } @@ -134,95 +134,95 @@ public: class LLControlGroup { protected: - typedef std::map<LLString, LLControlVariable* > ctrl_name_table_t; + typedef std::map<std::string, LLControlVariable* > ctrl_name_table_t; ctrl_name_table_t mNameTable; - std::set<LLString> mWarnings; - LLString mTypeString[TYPE_COUNT]; + std::set<std::string> mWarnings; + std::string mTypeString[TYPE_COUNT]; - eControlType typeStringToEnum(const LLString& typestr); - LLString typeEnumToString(eControlType typeenum); + eControlType typeStringToEnum(const std::string& typestr); + std::string typeEnumToString(eControlType typeenum); public: LLControlGroup(); ~LLControlGroup(); void cleanup(); - LLControlVariable* getControl(const LLString& name); + LLControlVariable* getControl(const std::string& name); struct ApplyFunctor { virtual ~ApplyFunctor() {}; - virtual void apply(const LLString& name, LLControlVariable* control) = 0; + virtual void apply(const std::string& name, LLControlVariable* control) = 0; }; void applyToAll(ApplyFunctor* func); - BOOL declareControl(const LLString& name, eControlType type, const LLSD initial_val, const LLString& comment, BOOL persist); - BOOL declareU32(const LLString& name, U32 initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareS32(const LLString& name, S32 initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareF32(const LLString& name, F32 initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareBOOL(const LLString& name, BOOL initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareString(const LLString& name, const LLString &initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareVec3(const LLString& name, const LLVector3 &initial_val,const LLString& comment, BOOL persist = TRUE); - BOOL declareVec3d(const LLString& name, const LLVector3d &initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareRect(const LLString& name, const LLRect &initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareColor4U(const LLString& name, const LLColor4U &initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareColor4(const LLString& name, const LLColor4 &initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareColor3(const LLString& name, const LLColor3 &initial_val, const LLString& comment, BOOL persist = TRUE); - BOOL declareLLSD(const LLString& name, const LLSD &initial_val, const LLString& comment, BOOL persist = TRUE); + BOOL declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist); + BOOL declareU32(const std::string& name, U32 initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareS32(const std::string& name, S32 initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareF32(const std::string& name, F32 initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareString(const std::string& name, const std::string &initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, BOOL persist = TRUE); + BOOL declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareColor4U(const std::string& name, const LLColor4U &initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, BOOL persist = TRUE); + BOOL declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, BOOL persist = TRUE); - LLString findString(const LLString& name); + std::string findString(const std::string& name); - LLString getString(const LLString& name); - LLWString getWString(const LLString& name); - LLString getText(const LLString& name); - LLVector3 getVector3(const LLString& name); - LLVector3d getVector3d(const LLString& name); - LLRect getRect(const LLString& name); - BOOL getBOOL(const LLString& name); - S32 getS32(const LLString& name); - F32 getF32(const LLString& name); - U32 getU32(const LLString& name); - LLSD getLLSD(const LLString& name); + std::string getString(const std::string& name); + LLWString getWString(const std::string& name); + std::string getText(const std::string& name); + LLVector3 getVector3(const std::string& name); + LLVector3d getVector3d(const std::string& name); + LLRect getRect(const std::string& name); + BOOL getBOOL(const std::string& name); + S32 getS32(const std::string& name); + F32 getF32(const std::string& name); + U32 getU32(const std::string& name); + LLSD getLLSD(const std::string& name); // Note: If an LLColor4U control exists, it will cast it to the correct // LLColor4 for you. - LLColor4 getColor(const LLString& name); - LLColor4U getColor4U(const LLString& name); - LLColor4 getColor4(const LLString& name); - LLColor3 getColor3(const LLString& name); - - void setBOOL(const LLString& name, BOOL val); - void setS32(const LLString& name, S32 val); - void setF32(const LLString& name, F32 val); - void setU32(const LLString& name, U32 val); - void setString(const LLString& name, const LLString& val); - void setVector3(const LLString& name, const LLVector3 &val); - void setVector3d(const LLString& name, const LLVector3d &val); - void setRect(const LLString& name, const LLRect &val); - void setColor4U(const LLString& name, const LLColor4U &val); - void setColor4(const LLString& name, const LLColor4 &val); - void setColor3(const LLString& name, const LLColor3 &val); - void setLLSD(const LLString& name, const LLSD& val); - void setValue(const LLString& name, const LLSD& val); + LLColor4 getColor(const std::string& name); + LLColor4U getColor4U(const std::string& name); + LLColor4 getColor4(const std::string& name); + LLColor3 getColor3(const std::string& name); + + void setBOOL(const std::string& name, BOOL val); + void setS32(const std::string& name, S32 val); + void setF32(const std::string& name, F32 val); + void setU32(const std::string& name, U32 val); + void setString(const std::string& name, const std::string& val); + void setVector3(const std::string& name, const LLVector3 &val); + void setVector3d(const std::string& name, const LLVector3d &val); + void setRect(const std::string& name, const LLRect &val); + void setColor4U(const std::string& name, const LLColor4U &val); + void setColor4(const std::string& name, const LLColor4 &val); + void setColor3(const std::string& name, const LLColor3 &val); + void setLLSD(const std::string& name, const LLSD& val); + void setValue(const std::string& name, const LLSD& val); - BOOL controlExists(const LLString& name); + BOOL controlExists(const std::string& name); // Returns number of controls loaded, 0 if failed // If require_declaration is false, will auto-declare controls it finds // as the given type. - U32 loadFromFileLegacy(const LLString& filename, BOOL require_declaration = TRUE, eControlType declare_as = TYPE_STRING); - U32 saveToFile(const LLString& filename, BOOL nondefault_only); - U32 loadFromFile(const LLString& filename); + U32 loadFromFileLegacy(const std::string& filename, BOOL require_declaration = TRUE, eControlType declare_as = TYPE_STRING); + U32 saveToFile(const std::string& filename, BOOL nondefault_only); + U32 loadFromFile(const std::string& filename); void resetToDefaults(); // Ignorable Warnings // Add a config variable to be reset on resetWarnings() - void addWarning(const LLString& name); - BOOL getWarning(const LLString& name); - void setWarning(const LLString& name, BOOL val); + void addWarning(const std::string& name); + BOOL getWarning(const std::string& name); + void setWarning(const std::string& name, BOOL val); // Resets all ignorables void resetWarnings(); diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp index bd465c30f0..750c1fc1ef 100644 --- a/indra/llxml/llxmlnode.cpp +++ b/indra/llxml/llxmlnode.cpp @@ -71,7 +71,7 @@ LLXMLNode::LLXMLNode() : { } -LLXMLNode::LLXMLNode(const LLString& name, BOOL is_attribute) : +LLXMLNode::LLXMLNode(const char* name, BOOL is_attribute) : mID(""), mParser(NULL), mIsAttribute(is_attribute), @@ -215,7 +215,7 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child) new_child->mParent = this; if (new_child->mIsAttribute) { - mAttributes.insert(std::pair<LLStringTableEntry*, LLXMLNodePtr>(new_child->mName, new_child)); + mAttributes.insert(std::make_pair(new_child->mName, new_child)); } else { @@ -225,7 +225,7 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child) mChildren->head = new_child; mChildren->tail = new_child; } - mChildren->map.insert(std::pair<LLStringTableEntry*, LLXMLNodePtr>(new_child->mName, new_child)); + mChildren->map.insert(std::make_pair(new_child->mName, new_child)); if (mChildren->tail != new_child) { @@ -239,7 +239,7 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child) } // virtual -LLXMLNodePtr LLXMLNode::createChild(const LLString& name, BOOL is_attribute) +LLXMLNodePtr LLXMLNode::createChild(const char* name, BOOL is_attribute) { return createChild(gStringTable.addStringEntry(name), is_attribute); } @@ -248,7 +248,7 @@ LLXMLNodePtr LLXMLNode::createChild(const LLString& name, BOOL is_attribute) LLXMLNodePtr LLXMLNode::createChild(LLStringTableEntry* name, BOOL is_attribute) { LLXMLNode* ret = new LLXMLNode(name, is_attribute); - ret->mID = ""; + ret->mID.clear(); addChild(ret); return ret; } @@ -312,7 +312,7 @@ void XMLCALL StartXMLNode(void *userData, // Create a new node LLXMLNode *new_node_ptr = new LLXMLNode(name, FALSE); LLXMLNodePtr new_node = new_node_ptr; - new_node->mID = ""; + new_node->mID.clear(); LLXMLNodePtr ptr_new_node = new_node; // Set the parent-child relationship with the current active node @@ -334,8 +334,8 @@ void XMLCALL StartXMLNode(void *userData, U32 pos = 0; while (atts[pos] != NULL) { - LLString attr_name = atts[pos]; - LLString attr_value = atts[pos+1]; + std::string attr_name = atts[pos]; + std::string attr_value = atts[pos+1]; // Special cases if ('i' == attr_name[0] && "id" == attr_name) @@ -413,9 +413,9 @@ void XMLCALL StartXMLNode(void *userData, // only one attribute child per description LLXMLNodePtr attr_node; - if (!new_node->getAttribute(attr_name, attr_node, FALSE)) + if (!new_node->getAttribute(attr_name.c_str(), attr_node, FALSE)) { - attr_node = new LLXMLNode(attr_name, TRUE); + attr_node = new LLXMLNode(attr_name.c_str(), TRUE); } attr_node->setValue(attr_value); new_node->addChild(attr_node); @@ -439,7 +439,7 @@ void XMLCALL EndXMLNode(void *userData, // SJB: total hack: if (LLXMLNode::sStripWhitespaceValues) { - LLString value = node->getValue(); + std::string value = node->getValue(); BOOL is_empty = TRUE; for (std::string::size_type s = 0; s < value.length(); s++) { @@ -463,13 +463,13 @@ void XMLCALL XMLData(void *userData, int len) { LLXMLNode* current_node = (LLXMLNode *)userData; - LLString value = current_node->getValue(); + std::string value = current_node->getValue(); if (LLXMLNode::sStripEscapedStrings) { if (s[0] == '\"' && s[len-1] == '\"') { // Special-case: Escaped string. - LLString unescaped_string; + std::string unescaped_string; for (S32 pos=1; pos<len-1; ++pos) { if (s[pos] == '\\' && s[pos+1] == '\\') @@ -540,8 +540,8 @@ bool LLXMLNode::updateNode( { for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { - LLString nodeName; - LLString updateName; + std::string nodeName; + std::string updateName; updateChild->getAttributeString("name", updateName); child->getAttributeString("name", nodeName); @@ -569,13 +569,11 @@ bool LLXMLNode::updateNode( // static -bool LLXMLNode::parseFile( - LLString filename, - LLXMLNodePtr& node, - LLXMLNode* defaults_tree) +bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXMLNode* defaults_tree) { // Read file - LLFILE* fp = LLFile::fopen(filename.c_str(), "rb"); /* Flawfinder: ignore */ + LL_DEBUGS("XMLNode") << "parsing XML file: " << filename << LL_ENDL; + LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */ if (fp == NULL) { node = new LLXMLNode(); @@ -749,7 +747,7 @@ void LLXMLNode::writeHeaderToFile(LLFILE *fOut) fprintf(fOut, "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n"); } -void LLXMLNode::writeToFile(LLFILE *fOut, LLString indent) +void LLXMLNode::writeToFile(LLFILE *fOut, const std::string& indent) { if (isFullyDefault()) { @@ -759,14 +757,14 @@ void LLXMLNode::writeToFile(LLFILE *fOut, LLString indent) std::ostringstream ostream; writeToOstream(ostream, indent); - LLString outstring = ostream.str(); + std::string outstring = ostream.str(); if (fwrite(outstring.c_str(), 1, outstring.length(), fOut) != outstring.length()) { llwarns << "Short write" << llendl; } } -void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& indent) +void LLXMLNode::writeToOstream(std::ostream& output_stream, const std::string& indent) { if (isFullyDefault()) { @@ -780,12 +778,12 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde BOOL has_default_length = mDefault.isNull()?FALSE:(mLength == mDefault->mLength); // stream the name - output_stream << indent.c_str() << "<" << mName->mString; + output_stream << indent << "<" << mName->mString; // ID if (mID != "") { - output_stream << " id=\"" << mID.c_str() << "\""; + output_stream << " id=\"" << mID << "\""; } // Type @@ -865,7 +863,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde LLXMLNodePtr child = (*attr_itr).second; if (child->mDefault.isNull() || child->mDefault->mValue != child->mValue) { - LLString attr = child->mName->mString; + std::string attr = child->mName->mString; if (attr == "id" || attr == "type" || attr == "encoding" || @@ -876,7 +874,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde continue; // skip built-in attributes } - LLString attr_str = llformat(" %s=\"%s\"", + std::string attr_str = llformat(" %s=\"%s\"", attr.c_str(), escapeXML(child->mValue).c_str()); if (col_pos + (S32)attr_str.length() > MAX_COLUMN_WIDTH) @@ -901,7 +899,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde if (mChildren) { // stream non-attributes - LLString next_indent = indent + "\t"; + std::string next_indent = indent + "\t"; for (LLXMLNode* child = getFirstChild(); child; child = child->getNextSibling()) { child->writeToOstream(output_stream, next_indent); @@ -909,19 +907,19 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde } if (!mValue.empty()) { - LLString contents = getTextContents(); - output_stream << indent.c_str() << "\t" << escapeXML(contents) << "\n"; + std::string contents = getTextContents(); + output_stream << indent << "\t" << escapeXML(contents) << "\n"; } - output_stream << indent.c_str() << "</" << mName->mString << ">\n"; + output_stream << indent << "</" << mName->mString << ">\n"; } } -void LLXMLNode::findName(const LLString& name, LLXMLNodeList &results) +void LLXMLNode::findName(const std::string& name, LLXMLNodeList &results) { LLStringTableEntry* name_entry = gStringTable.checkStringEntry(name); if (name_entry == mName) { - results.insert(std::pair<LLString, LLXMLNode*>(this->mName->mString, this)); + results.insert(std::make_pair(this->mName->mString, this)); return; } if (mChildren) @@ -940,7 +938,7 @@ void LLXMLNode::findName(LLStringTableEntry* name, LLXMLNodeList &results) { if (name == mName) { - results.insert(std::pair<LLString, LLXMLNode*>(this->mName->mString, this)); + results.insert(std::make_pair(this->mName->mString, this)); return; } if (mChildren) @@ -955,11 +953,11 @@ void LLXMLNode::findName(LLStringTableEntry* name, LLXMLNodeList &results) } } -void LLXMLNode::findID(const LLString& id, LLXMLNodeList &results) +void LLXMLNode::findID(const std::string& id, LLXMLNodeList &results) { if (id == mID) { - results.insert(std::pair<LLString, LLXMLNode*>(this->mName->mString, this)); + results.insert(std::make_pair(this->mName->mString, this)); return; } if (mChildren) @@ -1018,7 +1016,7 @@ void LLXMLNode::scrubToTree(LLXMLNode *tree) } } -bool LLXMLNode::getChild(const LLString& name, LLXMLNodePtr& node, BOOL use_default_if_missing) +bool LLXMLNode::getChild(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing) { return getChild(gStringTable.checkStringEntry(name), node, use_default_if_missing); } @@ -1042,7 +1040,7 @@ bool LLXMLNode::getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOO return false; } -void LLXMLNode::getChildren(const LLString& name, LLXMLNodeList &children, BOOL use_default_if_missing) const +void LLXMLNode::getChildren(const char* name, LLXMLNodeList &children, BOOL use_default_if_missing) const { getChildren(gStringTable.checkStringEntry(name), children, use_default_if_missing); } @@ -1062,7 +1060,7 @@ void LLXMLNode::getChildren(const LLStringTableEntry* name, LLXMLNodeList &child { break; } - children.insert(std::pair<LLString, LLXMLNodePtr>(child->mName->mString, child)); + children.insert(std::make_pair(child->mName->mString, child)); child_itr++; } } @@ -1073,7 +1071,7 @@ void LLXMLNode::getChildren(const LLStringTableEntry* name, LLXMLNodeList &child } } -bool LLXMLNode::getAttribute(const LLString& name, LLXMLNodePtr& node, BOOL use_default_if_missing) +bool LLXMLNode::getAttribute(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing) { return getAttribute(gStringTable.checkStringEntry(name), node, use_default_if_missing); } @@ -1094,7 +1092,7 @@ bool LLXMLNode::getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node, return false; } -bool LLXMLNode::setAttributeString(const LLString& attr, const LLString& value) +bool LLXMLNode::setAttributeString(const char* attr, const std::string& value) { LLStringTableEntry* name = gStringTable.checkStringEntry(attr); LLXMLAttribList::const_iterator child_itr = mAttributes.find(name); @@ -1107,25 +1105,25 @@ bool LLXMLNode::setAttributeString(const LLString& attr, const LLString& value) return false; } -BOOL LLXMLNode::hasAttribute(const LLString& name ) +BOOL LLXMLNode::hasAttribute(const char* name ) { LLXMLNodePtr node; return getAttribute(name, node); } -BOOL LLXMLNode::getAttributeBOOL(const LLString& name, BOOL& value ) +BOOL LLXMLNode::getAttributeBOOL(const char* name, BOOL& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getBoolValue(1, &value)); } -BOOL LLXMLNode::getAttributeU8(const LLString& name, U8& value ) +BOOL LLXMLNode::getAttributeU8(const char* name, U8& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getByteValue(1, &value)); } -BOOL LLXMLNode::getAttributeS8(const LLString& name, S8& value ) +BOOL LLXMLNode::getAttributeS8(const char* name, S8& value ) { LLXMLNodePtr node; S32 val; @@ -1137,7 +1135,7 @@ BOOL LLXMLNode::getAttributeS8(const LLString& name, S8& value ) return true; } -BOOL LLXMLNode::getAttributeU16(const LLString& name, U16& value ) +BOOL LLXMLNode::getAttributeU16(const char* name, U16& value ) { LLXMLNodePtr node; U32 val; @@ -1149,7 +1147,7 @@ BOOL LLXMLNode::getAttributeU16(const LLString& name, U16& value ) return true; } -BOOL LLXMLNode::getAttributeS16(const LLString& name, S16& value ) +BOOL LLXMLNode::getAttributeS16(const char* name, S16& value ) { LLXMLNodePtr node; S32 val; @@ -1161,73 +1159,73 @@ BOOL LLXMLNode::getAttributeS16(const LLString& name, S16& value ) return true; } -BOOL LLXMLNode::getAttributeU32(const LLString& name, U32& value ) +BOOL LLXMLNode::getAttributeU32(const char* name, U32& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getUnsignedValue(1, &value)); } -BOOL LLXMLNode::getAttributeS32(const LLString& name, S32& value ) +BOOL LLXMLNode::getAttributeS32(const char* name, S32& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getIntValue(1, &value)); } -BOOL LLXMLNode::getAttributeF32(const LLString& name, F32& value ) +BOOL LLXMLNode::getAttributeF32(const char* name, F32& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getFloatValue(1, &value)); } -BOOL LLXMLNode::getAttributeF64(const LLString& name, F64& value ) +BOOL LLXMLNode::getAttributeF64(const char* name, F64& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getDoubleValue(1, &value)); } -BOOL LLXMLNode::getAttributeColor(const LLString& name, LLColor4& value ) +BOOL LLXMLNode::getAttributeColor(const char* name, LLColor4& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getFloatValue(4, value.mV)); } -BOOL LLXMLNode::getAttributeColor4(const LLString& name, LLColor4& value ) +BOOL LLXMLNode::getAttributeColor4(const char* name, LLColor4& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getFloatValue(4, value.mV)); } -BOOL LLXMLNode::getAttributeColor4U(const LLString& name, LLColor4U& value ) +BOOL LLXMLNode::getAttributeColor4U(const char* name, LLColor4U& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getByteValue(4, value.mV)); } -BOOL LLXMLNode::getAttributeVector3(const LLString& name, LLVector3& value ) +BOOL LLXMLNode::getAttributeVector3(const char* name, LLVector3& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getFloatValue(3, value.mV)); } -BOOL LLXMLNode::getAttributeVector3d(const LLString& name, LLVector3d& value ) +BOOL LLXMLNode::getAttributeVector3d(const char* name, LLVector3d& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getDoubleValue(3, value.mdV)); } -BOOL LLXMLNode::getAttributeQuat(const LLString& name, LLQuaternion& value ) +BOOL LLXMLNode::getAttributeQuat(const char* name, LLQuaternion& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getFloatValue(4, value.mQ)); } -BOOL LLXMLNode::getAttributeUUID(const LLString& name, LLUUID& value ) +BOOL LLXMLNode::getAttributeUUID(const char* name, LLUUID& value ) { LLXMLNodePtr node; return (getAttribute(name, node) && node->getUUIDValue(1, &value)); } -BOOL LLXMLNode::getAttributeString(const LLString& name, LLString& value ) +BOOL LLXMLNode::getAttributeString(const char* name, std::string& value ) { LLXMLNodePtr node; if (!getAttribute(name, node)) @@ -1539,14 +1537,14 @@ U32 LLXMLNode::getBoolValue(U32 expected_length, BOOL *array) return 0; } - LLString *str_array = new LLString[expected_length]; + std::string *str_array = new std::string[expected_length]; U32 length = getStringValue(expected_length, str_array); U32 ret_length = 0; for (U32 i=0; i<length; ++i) { - LLString::toLower(str_array[i]); + LLStringUtil::toLower(str_array[i]); if (str_array[i] == "false") { array[ret_length++] = FALSE; @@ -1875,7 +1873,7 @@ U32 LLXMLNode::getDoubleValue(U32 expected_length, F64 *array, Encoding encoding return i; } -U32 LLXMLNode::getStringValue(U32 expected_length, LLString *array) +U32 LLXMLNode::getStringValue(U32 expected_length, std::string *array) { llassert(array); @@ -1950,7 +1948,7 @@ U32 LLXMLNode::getUUIDValue(U32 expected_length, LLUUID *array) memcpy(uuid_string, value_string, (UUID_STR_LENGTH-1)); /* Flawfinder: ignore */ uuid_string[(UUID_STR_LENGTH-1)] = 0; - if (!LLUUID::parseUUID(uuid_string, &uuid_value)) + if (!LLUUID::parseUUID(std::string(uuid_string), &uuid_value)) { break; } @@ -1978,7 +1976,7 @@ U32 LLXMLNode::getNodeRefValue(U32 expected_length, LLXMLNode **array) return 0; } - LLString *string_array = new LLString[expected_length]; + std::string *string_array = new std::string[expected_length]; U32 num_strings = getStringValue(expected_length, string_array); @@ -2018,7 +2016,7 @@ void LLXMLNode::setBoolValue(U32 length, const BOOL *array) { if (length == 0) return; - LLString new_value; + std::string new_value; for (U32 pos=0; pos<length; ++pos) { if (pos > 0) @@ -2041,7 +2039,7 @@ void LLXMLNode::setByteValue(U32 length, const U8* const array, Encoding encodin { if (length == 0) return; - LLString new_value; + std::string new_value; if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) { for (U32 pos=0; pos<length; ++pos) @@ -2084,7 +2082,7 @@ void LLXMLNode::setIntValue(U32 length, const S32 *array, Encoding encoding) { if (length == 0) return; - LLString new_value; + std::string new_value; if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) { for (U32 pos=0; pos<length; ++pos) @@ -2131,7 +2129,7 @@ void LLXMLNode::setUnsignedValue(U32 length, const U32* array, Encoding encoding { if (length == 0) return; - LLString new_value; + std::string new_value; if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) { for (U32 pos=0; pos<length; ++pos) @@ -2180,7 +2178,7 @@ void LLXMLNode::setLongValue(U32 length, const U64* array, Encoding encoding) { if (length == 0) return; - LLString new_value; + std::string new_value; if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) { for (U32 pos=0; pos<length; ++pos) @@ -2229,21 +2227,21 @@ void LLXMLNode::setFloatValue(U32 length, const F32 *array, Encoding encoding, U { if (length == 0) return; - LLString new_value; + std::string new_value; if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) { - char format_string[10]; /* Flawfinder: ignore */ + std::string format_string; if (precision > 0) { if (precision > 25) { precision = 25; } - snprintf(format_string, sizeof(format_string), "%%.%dg", precision); /* Flawfinder: ignore */ + format_string = llformat( "%%.%dg", precision); } else { - snprintf(format_string, sizeof(format_string), "%%g"); /* Flawfinder: ignore */ + format_string = llformat( "%%g"); } for (U32 pos=0; pos<length; ++pos) @@ -2251,11 +2249,11 @@ void LLXMLNode::setFloatValue(U32 length, const F32 *array, Encoding encoding, U if (pos > 0) { new_value.append(" "); - new_value.append(llformat(format_string, array[pos])); + new_value.append(llformat(format_string.c_str(), array[pos])); } else { - new_value.assign(llformat(format_string, array[pos])); + new_value.assign(llformat(format_string.c_str(), array[pos])); } } mValue = new_value; @@ -2280,32 +2278,32 @@ void LLXMLNode::setDoubleValue(U32 length, const F64 *array, Encoding encoding, { if (length == 0) return; - LLString new_value; + std::string new_value; if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) { - char format_string[10]; /* Flawfinder: ignore */ + std::string format_string; if (precision > 0) { if (precision > 25) { precision = 25; } - snprintf(format_string, sizeof(format_string), "%%.%dg", precision); /* Flawfinder: ignore */ + format_string = llformat( "%%.%dg", precision); } else { - snprintf(format_string, sizeof(format_string), "%%g"); /* Flawfinder: ignore */ + format_string = llformat( "%%g"); } for (U32 pos=0; pos<length; ++pos) { if (pos > 0) { new_value.append(" "); - new_value.append(llformat(format_string, array[pos])); + new_value.append(llformat(format_string.c_str(), array[pos])); } else { - new_value.assign(llformat(format_string, array[pos])); + new_value.assign(llformat(format_string.c_str(), array[pos])); } } mValue = new_value; @@ -2328,10 +2326,10 @@ void LLXMLNode::setDoubleValue(U32 length, const F64 *array, Encoding encoding, } // static -LLString LLXMLNode::escapeXML(const LLString& xml) +std::string LLXMLNode::escapeXML(const std::string& xml) { - LLString out; - for (LLString::size_type i = 0; i < xml.size(); ++i) + std::string out; + for (std::string::size_type i = 0; i < xml.size(); ++i) { char c = xml[i]; switch(c) @@ -2347,11 +2345,11 @@ LLString LLXMLNode::escapeXML(const LLString& xml) return out; } -void LLXMLNode::setStringValue(U32 length, const LLString *array) +void LLXMLNode::setStringValue(U32 length, const std::string *array) { if (length == 0) return; - LLString new_value; + std::string new_value; for (U32 pos=0; pos<length; ++pos) { new_value.append(escapeXML(array[pos])); @@ -2368,7 +2366,7 @@ void LLXMLNode::setUUIDValue(U32 length, const LLUUID *array) { if (length == 0) return; - LLString new_value; + std::string new_value; for (U32 pos=0; pos<length; ++pos) { new_value.append(array[pos].asString()); @@ -2385,7 +2383,7 @@ void LLXMLNode::setNodeRefValue(U32 length, const LLXMLNode **array) { if (length == 0) return; - LLString new_value; + std::string new_value; for (U32 pos=0; pos<length; ++pos) { if (array[pos]->mID != "") @@ -2405,7 +2403,7 @@ void LLXMLNode::setNodeRefValue(U32 length, const LLXMLNode **array) mType = TYPE_NODEREF; } -void LLXMLNode::setValue(const LLString& value) +void LLXMLNode::setValue(const std::string& value) { if (TYPE_CONTAINER == mType) { @@ -2442,7 +2440,7 @@ void LLXMLNode::findDefault(LLXMLNode *defaults_list) mDefault = NULL; } -BOOL LLXMLNode::deleteChildren(const LLString& name) +BOOL LLXMLNode::deleteChildren(const std::string& name) { U32 removed_count = 0; LLXMLNodeList node_list; @@ -2494,7 +2492,7 @@ void LLXMLNode::setAttributes(LLXMLNode::ValueType type, U32 precision, LLXMLNod mLength = length; } -void LLXMLNode::setName(const LLString& name) +void LLXMLNode::setName(const std::string& name) { setName(gStringTable.addStringEntry(name)); } @@ -2515,10 +2513,11 @@ void LLXMLNode::setName(LLStringTableEntry* name) } } -void LLXMLNode::appendValue(const LLString& value) -{ - mValue.append(value); -} +// Unused +// void LLXMLNode::appendValue(const std::string& value) +// { +// mValue.append(value); +// } U32 LLXMLNode::getChildCount() const { @@ -2568,14 +2567,13 @@ LLXMLNode *get_rand_node(LLXMLNode *node) void LLXMLNode::createUnitTest(S32 max_num_children) { // Random ID - char rand_id[20]; /* Flawfinder: ignore */ + std::string rand_id; U32 rand_id_len = get_rand(10)+5; - U32 pos = 0; - for (; pos<rand_id_len; ++pos) + for (U32 pos = 0; pos<rand_id_len; ++pos) { - rand_id[pos] = get_rand(26)+'a'; + char c = 'a' + get_rand(26); + rand_id.append(1, c); } - rand_id[pos] = 0; mID = rand_id; if (max_num_children < 2) @@ -2597,26 +2595,24 @@ void LLXMLNode::createUnitTest(S32 max_num_children) for (U32 child_num=0; child_num<num_children; ++child_num) { // Random Name - char child_name[20]; /* Flawfinder: ignore */ + std::string child_name; U32 child_name_len = get_rand(10)+5; - pos = 0; - for (; pos<child_name_len; ++pos) + for (U32 pos = 0; pos<child_name_len; ++pos) { - child_name[pos] = get_rand(26)+'a'; + char c = 'a' + get_rand(26); + child_name.append(1, c); } - child_name[pos] = 0; - LLXMLNode *new_child = createChild(child_name, FALSE); + LLXMLNode *new_child = createChild(child_name.c_str(), FALSE); // Random ID - char child_id[20]; /* Flawfinder: ignore */ + std::string child_id; U32 child_id_len = get_rand(10)+5; - pos = 0; - for (; pos<child_id_len; ++pos) + for (U32 pos=0; pos<child_id_len; ++pos) { - child_id[pos] = get_rand(26)+'a'; + char c = 'a' + get_rand(26); + child_id.append(1, c); } - child_id[pos] = 0; new_child->mID = child_id; // Random Length @@ -2750,7 +2746,7 @@ void LLXMLNode::createUnitTest(S32 max_num_children) createChild("float_checksum", TRUE)->setUnsignedValue(1, &float_checksum, LLXMLNode::ENCODING_HEX); } -BOOL LLXMLNode::performUnitTest(LLString &error_buffer) +BOOL LLXMLNode::performUnitTest(std::string &error_buffer) { if (!mChildren) { @@ -3024,10 +3020,10 @@ LLXMLNodePtr LLXMLNode::getNextSibling() return ret; } -LLString LLXMLNode::getTextContents() const +std::string LLXMLNode::getTextContents() const { std::string msg; - LLString contents = mValue; + std::string contents = mValue; std::string::size_type n = contents.find_first_not_of(" \t\n"); if (n != std::string::npos && contents[n] == '\"') { @@ -3071,10 +3067,10 @@ LLString LLXMLNode::getTextContents() const else { // Case 2: node has embedded text (beginning and trailing whitespace trimmed) - LLString::size_type start = mValue.find_first_not_of(" \t\n"); + std::string::size_type start = mValue.find_first_not_of(" \t\n"); if (start != mValue.npos) { - LLString::size_type end = mValue.find_last_not_of(" \t\n"); + std::string::size_type end = mValue.find_last_not_of(" \t\n"); if (end != mValue.npos) { msg = mValue.substr(start, end+1-start); diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h index 58cef95ce0..5ca726effe 100644 --- a/indra/llxml/llxmlnode.h +++ b/indra/llxml/llxmlnode.h @@ -75,7 +75,7 @@ struct CompareAttributes class LLXMLNode; typedef LLPointer<LLXMLNode> LLXMLNodePtr; -typedef std::multimap<LLString, LLXMLNodePtr > LLXMLNodeList; +typedef std::multimap<std::string, LLXMLNodePtr > LLXMLNodeList; typedef std::multimap<const LLStringTableEntry *, LLXMLNodePtr > LLXMLChildList; typedef std::map<const LLStringTableEntry *, LLXMLNodePtr, CompareAttributes> LLXMLAttribList; @@ -122,7 +122,7 @@ protected: public: LLXMLNode(); - LLXMLNode(const LLString& name, BOOL is_attribute); + LLXMLNode(const char* name, BOOL is_attribute); LLXMLNode(LLStringTableEntry* name, BOOL is_attribute); BOOL isNull(); @@ -133,7 +133,7 @@ public: // Serialization static bool parseFile( - LLString filename, + const std::string& filename, LLXMLNodePtr& node, LLXMLNode* defaults_tree); static bool parseBuffer( @@ -149,16 +149,16 @@ public: LLXMLNodePtr& node, LLXMLNodePtr& update_node); static void writeHeaderToFile(LLFILE *fOut); - void writeToFile(LLFILE *fOut, LLString indent = LLString()); - void writeToOstream(std::ostream& output_stream, const LLString& indent = LLString()); + void writeToFile(LLFILE *fOut, const std::string& indent = std::string()); + void writeToOstream(std::ostream& output_stream, const std::string& indent = std::string()); // Utility - void findName(const LLString& name, LLXMLNodeList &results); + void findName(const std::string& name, LLXMLNodeList &results); void findName(LLStringTableEntry* name, LLXMLNodeList &results); - void findID(const LLString& id, LLXMLNodeList &results); + void findID(const std::string& id, LLXMLNodeList &results); - virtual LLXMLNodePtr createChild(const LLString& name, BOOL is_attribute); + virtual LLXMLNodePtr createChild(const char* name, BOOL is_attribute); virtual LLXMLNodePtr createChild(LLStringTableEntry* name, BOOL is_attribute); @@ -170,49 +170,49 @@ public: U32 getLongValue(U32 expected_length, U64 *array, Encoding encoding = ENCODING_DEFAULT); U32 getFloatValue(U32 expected_length, F32 *array, Encoding encoding = ENCODING_DEFAULT); U32 getDoubleValue(U32 expected_length, F64 *array, Encoding encoding = ENCODING_DEFAULT); - U32 getStringValue(U32 expected_length, LLString *array); + U32 getStringValue(U32 expected_length, std::string *array); U32 getUUIDValue(U32 expected_length, LLUUID *array); U32 getNodeRefValue(U32 expected_length, LLXMLNode **array); - BOOL hasAttribute(const LLString& name ); - - BOOL getAttributeBOOL(const LLString& name, BOOL& value ); - BOOL getAttributeU8(const LLString& name, U8& value ); - BOOL getAttributeS8(const LLString& name, S8& value ); - BOOL getAttributeU16(const LLString& name, U16& value ); - BOOL getAttributeS16(const LLString& name, S16& value ); - BOOL getAttributeU32(const LLString& name, U32& value ); - BOOL getAttributeS32(const LLString& name, S32& value ); - BOOL getAttributeF32(const LLString& name, F32& value ); - BOOL getAttributeF64(const LLString& name, F64& value ); - BOOL getAttributeColor(const LLString& name, LLColor4& value ); - BOOL getAttributeColor4(const LLString& name, LLColor4& value ); - BOOL getAttributeColor4U(const LLString& name, LLColor4U& value ); - BOOL getAttributeVector3(const LLString& name, LLVector3& value ); - BOOL getAttributeVector3d(const LLString& name, LLVector3d& value ); - BOOL getAttributeQuat(const LLString& name, LLQuaternion& value ); - BOOL getAttributeUUID(const LLString& name, LLUUID& value ); - BOOL getAttributeString(const LLString& name, LLString& value ); + BOOL hasAttribute(const char* name ); + + BOOL getAttributeBOOL(const char* name, BOOL& value ); + BOOL getAttributeU8(const char* name, U8& value ); + BOOL getAttributeS8(const char* name, S8& value ); + BOOL getAttributeU16(const char* name, U16& value ); + BOOL getAttributeS16(const char* name, S16& value ); + BOOL getAttributeU32(const char* name, U32& value ); + BOOL getAttributeS32(const char* name, S32& value ); + BOOL getAttributeF32(const char* name, F32& value ); + BOOL getAttributeF64(const char* name, F64& value ); + BOOL getAttributeColor(const char* name, LLColor4& value ); + BOOL getAttributeColor4(const char* name, LLColor4& value ); + BOOL getAttributeColor4U(const char* name, LLColor4U& value ); + BOOL getAttributeVector3(const char* name, LLVector3& value ); + BOOL getAttributeVector3d(const char* name, LLVector3d& value ); + BOOL getAttributeQuat(const char* name, LLQuaternion& value ); + BOOL getAttributeUUID(const char* name, LLUUID& value ); + BOOL getAttributeString(const char* name, std::string& value ); const ValueType& getType() const { return mType; } U32 getLength() const { return mLength; } U32 getPrecision() const { return mPrecision; } - const LLString& getValue() const { return mValue; } - LLString getTextContents() const; + const std::string& getValue() const { return mValue; } + std::string getTextContents() const; const LLStringTableEntry* getName() const { return mName; } BOOL hasName(const char* name) const { return mName == gStringTable.checkStringEntry(name); } - BOOL hasName(LLString name) const { return mName == gStringTable.checkStringEntry(name.c_str()); } - const LLString& getID() const { return mID; } + BOOL hasName(const std::string& name) const { return mName == gStringTable.checkStringEntry(name.c_str()); } + const std::string& getID() const { return mID; } U32 getChildCount() const; // getChild returns a Null LLXMLNode (not a NULL pointer) if there is no such child. // This child has no value so any getTYPEValue() calls on it will return 0. - bool getChild(const LLString& name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); + bool getChild(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); bool getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); - void getChildren(const LLString& name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const; + void getChildren(const char* name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const; void getChildren(const LLStringTableEntry* name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const; - bool getAttribute(const LLString& name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); + bool getAttribute(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); bool getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); // The following skip over attributes @@ -223,7 +223,7 @@ public: // Setters - bool setAttributeString(const LLString& attr, const LLString& value); + bool setAttributeString(const char* attr, const std::string& value); void setBoolValue(const BOOL value) { setBoolValue(1, &value); } void setByteValue(const U8 value, Encoding encoding = ENCODING_DEFAULT) { setByteValue(1, &value, encoding); } @@ -232,7 +232,7 @@ public: void setLongValue(const U64 value, Encoding encoding = ENCODING_DEFAULT) { setLongValue(1, &value, encoding); } void setFloatValue(const F32 value, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0) { setFloatValue(1, &value, encoding); } void setDoubleValue(const F64 value, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0) { setDoubleValue(1, &value, encoding); } - void setStringValue(const LLString value) { setStringValue(1, &value); } + void setStringValue(const std::string& value) { setStringValue(1, &value); } void setUUIDValue(const LLUUID value) { setUUIDValue(1, &value); } void setNodeRefValue(const LLXMLNode *value) { setNodeRefValue(1, &value); } @@ -243,16 +243,16 @@ public: void setLongValue(U32 length, const U64 *array, Encoding encoding = ENCODING_DEFAULT); void setFloatValue(U32 length, const F32 *array, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0); void setDoubleValue(U32 length, const F64 *array, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0); - void setStringValue(U32 length, const LLString *array); + void setStringValue(U32 length, const std::string *array); void setUUIDValue(U32 length, const LLUUID *array); void setNodeRefValue(U32 length, const LLXMLNode **array); - void setValue(const LLString& value); - void setName(const LLString& name); + void setValue(const std::string& value); + void setName(const std::string& name); void setName(LLStringTableEntry* name); // Escapes " (quot) ' (apos) & (amp) < (lt) > (gt) // TomY TODO: Make this private - static LLString escapeXML(const LLString& xml); + static std::string escapeXML(const std::string& xml); // Set the default node corresponding to this default node void setDefault(LLXMLNode *default_node); @@ -265,20 +265,20 @@ public: // Delete any child nodes that aren't among the tree's children, recursive void scrubToTree(LLXMLNode *tree); - BOOL deleteChildren(const LLString& name); + BOOL deleteChildren(const std::string& name); BOOL deleteChildren(LLStringTableEntry* name); void setAttributes(ValueType type, U32 precision, Encoding encoding, U32 length); - void appendValue(const LLString& value); +// void appendValue(const std::string& value); // Unused // Unit Testing void createUnitTest(S32 max_num_children); - BOOL performUnitTest(LLString &error_buffer); + BOOL performUnitTest(std::string &error_buffer); protected: BOOL removeChild(LLXMLNode* child); public: - LLString mID; // The ID attribute of this node + std::string mID; // The ID attribute of this node XML_Parser *mParser; // Temporary pointer while loading @@ -301,7 +301,7 @@ public: protected: LLStringTableEntry *mName; // The name of this node - LLString mValue; // The value of this node (use getters/setters only) + std::string mValue; // The value of this node (use getters/setters only) LLXMLNodePtr mDefault; // Mirror node in the default tree diff --git a/indra/llxml/llxmlparser.cpp b/indra/llxml/llxmlparser.cpp index 5591551bb7..6a3953edd9 100644 --- a/indra/llxml/llxmlparser.cpp +++ b/indra/llxml/llxmlparser.cpp @@ -45,7 +45,7 @@ LLXmlParser::LLXmlParser() mParser( NULL ), mDepth( 0 ) { - strcpy( mAuxErrorString, "no error" ); /* Flawfinder: ignore */ + mAuxErrorString = "no error"; // Override the document's declared encoding. mParser = XML_ParserCreate(NULL); @@ -77,10 +77,10 @@ BOOL LLXmlParser::parseFile(const std::string &path) BOOL success = TRUE; - LLFILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */ + LLFILE* file = LLFile::fopen(path, "rb"); /* Flawfinder: ignore */ if( !file ) { - snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Couldn't open file %s", path.c_str()); /* Flawfinder: ignore */ + mAuxErrorString = llformat( "Couldn't open file %s", path.c_str()); success = FALSE; } else @@ -94,7 +94,7 @@ BOOL LLXmlParser::parseFile(const std::string &path) void* buffer = XML_GetBuffer(mParser, buffer_size); if( !buffer ) { - snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Unable to allocate XML buffer while reading file %s", path.c_str() ); /* Flawfinder: ignore */ + mAuxErrorString = llformat( "Unable to allocate XML buffer while reading file %s", path.c_str() ); success = FALSE; goto exit_label; } @@ -102,14 +102,14 @@ BOOL LLXmlParser::parseFile(const std::string &path) bytes_read = (S32)fread(buffer, 1, buffer_size, file); if( bytes_read <= 0 ) { - snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Error while reading file %s", path.c_str() ); /* Flawfinder: ignore */ + mAuxErrorString = llformat( "Error while reading file %s", path.c_str() ); success = FALSE; goto exit_label; } if( !XML_ParseBuffer(mParser, bytes_read, TRUE ) ) { - snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Error while parsing file %s", path.c_str() ); /* Flawfinder: ignore */ + mAuxErrorString = llformat( "Error while parsing file %s", path.c_str() ); success = FALSE; } @@ -146,7 +146,7 @@ const char* LLXmlParser::getErrorString() const char* error_string = XML_ErrorString(XML_GetErrorCode( mParser )); if( !error_string ) { - error_string = mAuxErrorString; + error_string = mAuxErrorString.c_str(); } return error_string; } diff --git a/indra/llxml/llxmlparser.h b/indra/llxml/llxmlparser.h index 747cf3d0ca..1ccda7b7c6 100644 --- a/indra/llxml/llxmlparser.h +++ b/indra/llxml/llxmlparser.h @@ -132,7 +132,7 @@ public: protected: XML_Parser mParser; int mDepth; - char mAuxErrorString[1024]; /*Flawfinder: ignore*/ + std::string mAuxErrorString; }; #endif // LL_LLXMLPARSER_H diff --git a/indra/llxml/llxmltree.cpp b/indra/llxml/llxmltree.cpp index a036b876a9..20a9cbdede 100644 --- a/indra/llxml/llxmltree.cpp +++ b/indra/llxml/llxmltree.cpp @@ -90,11 +90,11 @@ void LLXmlTree::dump() } } -void LLXmlTree::dumpNode( LLXmlTreeNode* node, const LLString& prefix ) +void LLXmlTree::dumpNode( LLXmlTreeNode* node, const std::string& prefix ) { node->dump( prefix ); - LLString new_prefix = prefix + " "; + std::string new_prefix = prefix + " "; for( LLXmlTreeNode* child = node->getFirstChild(); child; child = node->getNextChild() ) { dumpNode( child, new_prefix ); @@ -121,7 +121,7 @@ LLXmlTreeNode::~LLXmlTreeNode() delete *child_iter; } -void LLXmlTreeNode::dump( const LLString& prefix ) +void LLXmlTreeNode::dump( const std::string& prefix ) { llinfos << prefix << mName ; if( !mContents.empty() ) @@ -132,7 +132,7 @@ void LLXmlTreeNode::dump( const LLString& prefix ) for (iter=mAttributes.begin(); iter != mAttributes.end(); iter++) { LLStdStringHandle key = iter->first; - const LLString* value = iter->second; + const std::string* value = iter->second; llcont << prefix << " " << key << "=" << (value->empty() ? "NULL" : *value); } llcont << llendl; @@ -148,7 +148,7 @@ BOOL LLXmlTreeNode::hasAttribute(const std::string& name) void LLXmlTreeNode::addAttribute(const std::string& name, const std::string& value) { LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name ); - const LLString *newstr = new LLString(value); + const std::string *newstr = new std::string(value); mAttributes[canonical_name] = newstr; // insert + copy } @@ -204,103 +204,103 @@ void LLXmlTreeNode::addChild(LLXmlTreeNode* child) BOOL LLXmlTreeNode::getFastAttributeBOOL(LLStdStringHandle canonical_name, BOOL& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToBOOL( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToBOOL( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeU8(LLStdStringHandle canonical_name, U8& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToU8( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToU8( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeS8(LLStdStringHandle canonical_name, S8& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToS8( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToS8( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeS16(LLStdStringHandle canonical_name, S16& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToS16( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToS16( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeU16(LLStdStringHandle canonical_name, U16& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToU16( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToU16( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeU32(LLStdStringHandle canonical_name, U32& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToU32( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToU32( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeS32(LLStdStringHandle canonical_name, S32& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToS32( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToS32( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeF32(LLStdStringHandle canonical_name, F32& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToF32( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToF32( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeF64(LLStdStringHandle canonical_name, F64& value) { - const LLString *s = getAttribute( canonical_name ); - return s && LLString::convertToF64( *s, value ); + const std::string *s = getAttribute( canonical_name ); + return s && LLStringUtil::convertToF64( *s, value ); } BOOL LLXmlTreeNode::getFastAttributeColor(LLStdStringHandle canonical_name, LLColor4& value) { - const LLString *s = getAttribute( canonical_name ); - return s ? LLColor4::parseColor(s->c_str(), &value) : FALSE; + const std::string *s = getAttribute( canonical_name ); + return s ? LLColor4::parseColor(*s, &value) : FALSE; } BOOL LLXmlTreeNode::getFastAttributeColor4(LLStdStringHandle canonical_name, LLColor4& value) { - const LLString *s = getAttribute( canonical_name ); - return s ? LLColor4::parseColor4(s->c_str(), &value) : FALSE; + const std::string *s = getAttribute( canonical_name ); + return s ? LLColor4::parseColor4(*s, &value) : FALSE; } BOOL LLXmlTreeNode::getFastAttributeColor4U(LLStdStringHandle canonical_name, LLColor4U& value) { - const LLString *s = getAttribute( canonical_name ); - return s ? LLColor4U::parseColor4U(s->c_str(), &value ) : FALSE; + const std::string *s = getAttribute( canonical_name ); + return s ? LLColor4U::parseColor4U(*s, &value ) : FALSE; } BOOL LLXmlTreeNode::getFastAttributeVector3(LLStdStringHandle canonical_name, LLVector3& value) { - const LLString *s = getAttribute( canonical_name ); - return s ? LLVector3::parseVector3(s->c_str(), &value ) : FALSE; + const std::string *s = getAttribute( canonical_name ); + return s ? LLVector3::parseVector3(*s, &value ) : FALSE; } BOOL LLXmlTreeNode::getFastAttributeVector3d(LLStdStringHandle canonical_name, LLVector3d& value) { - const LLString *s = getAttribute( canonical_name ); - return s ? LLVector3d::parseVector3d(s->c_str(), &value ) : FALSE; + const std::string *s = getAttribute( canonical_name ); + return s ? LLVector3d::parseVector3d(*s, &value ) : FALSE; } BOOL LLXmlTreeNode::getFastAttributeQuat(LLStdStringHandle canonical_name, LLQuaternion& value) { - const LLString *s = getAttribute( canonical_name ); - return s ? LLQuaternion::parseQuat(s->c_str(), &value ) : FALSE; + const std::string *s = getAttribute( canonical_name ); + return s ? LLQuaternion::parseQuat(*s, &value ) : FALSE; } BOOL LLXmlTreeNode::getFastAttributeUUID(LLStdStringHandle canonical_name, LLUUID& value) { - const LLString *s = getAttribute( canonical_name ); - return s ? LLUUID::parseUUID(s->c_str(), &value ) : FALSE; + const std::string *s = getAttribute( canonical_name ); + return s ? LLUUID::parseUUID(*s, &value ) : FALSE; } -BOOL LLXmlTreeNode::getFastAttributeString(LLStdStringHandle canonical_name, LLString& value) +BOOL LLXmlTreeNode::getFastAttributeString(LLStdStringHandle canonical_name, std::string& value) { - const LLString *s = getAttribute( canonical_name ); + const std::string *s = getAttribute( canonical_name ); if( !s ) { return FALSE; @@ -409,7 +409,7 @@ BOOL LLXmlTreeNode::getAttributeUUID(const std::string& name, LLUUID& value) return getFastAttributeUUID(canonical_name, value); } -BOOL LLXmlTreeNode::getAttributeString(const std::string& name, LLString& value) +BOOL LLXmlTreeNode::getAttributeString(const std::string& name, std::string& value) { LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name ); return getFastAttributeString(canonical_name, value); @@ -437,7 +437,7 @@ The quick brown fox */ -LLString LLXmlTreeNode::getTextContents() +std::string LLXmlTreeNode::getTextContents() { std::string msg; LLXmlTreeNode* p = getChildByName("p"); @@ -541,7 +541,7 @@ BOOL LLXmlTreeParser::parseFile(const std::string &path, LLXmlTreeNode** root, B const std::string& LLXmlTreeParser::tabs() { - static LLString s; + static std::string s; s = ""; S32 num_tabs = getDepth() - 1; for( S32 i = 0; i < num_tabs; i++) @@ -602,8 +602,8 @@ void LLXmlTreeParser::endElement(const char* name) if( !mCurrent->mContents.empty() ) { - LLString::trim(mCurrent->mContents); - LLString::removeCRLF(mCurrent->mContents); + LLStringUtil::trim(mCurrent->mContents); + LLStringUtil::removeCRLF(mCurrent->mContents); } mCurrent = mCurrent->getParent(); @@ -611,7 +611,8 @@ void LLXmlTreeParser::endElement(const char* name) void LLXmlTreeParser::characterData(const char *s, int len) { - LLString str(s, len); + std::string str; + if (s) str = std::string(s, len); if( mDump ) { llinfos << tabs() << "CharacterData " << str << llendl; @@ -659,7 +660,8 @@ void LLXmlTreeParser::defaultData(const char *s, int len) { if( mDump ) { - LLString str(s, len); + std::string str; + if (s) str = std::string(s, len); llinfos << tabs() << "defaultData " << str << llendl; } } diff --git a/indra/llxml/llxmltree.h b/indra/llxml/llxmltree.h index d4926656be..e54d5c6960 100644 --- a/indra/llxml/llxmltree.h +++ b/indra/llxml/llxmltree.h @@ -65,7 +65,7 @@ public: LLXmlTreeNode* getRoot() { return mRoot; } void dump(); - void dumpNode( LLXmlTreeNode* node, const LLString &prefix ); + void dumpNode( LLXmlTreeNode* node, const std::string& prefix ); static LLStdStringHandle addAttributeString( const std::string& name) { @@ -126,7 +126,7 @@ public: BOOL getFastAttributeVector3d( LLStdStringHandle cannonical_name, LLVector3d& value ); BOOL getFastAttributeQuat( LLStdStringHandle cannonical_name, LLQuaternion& value ); BOOL getFastAttributeUUID( LLStdStringHandle cannonical_name, LLUUID& value ); - BOOL getFastAttributeString( LLStdStringHandle cannonical_name, LLString& value ); + BOOL getFastAttributeString( LLStdStringHandle cannonical_name, std::string& value ); // Normal versions find 'name' in LLXmlTree::sAttributeKeys then call fast versions virtual BOOL getAttributeBOOL( const std::string& name, BOOL& value ); @@ -145,13 +145,13 @@ public: virtual BOOL getAttributeVector3d( const std::string& name, LLVector3d& value ); virtual BOOL getAttributeQuat( const std::string& name, LLQuaternion& value ); virtual BOOL getAttributeUUID( const std::string& name, LLUUID& value ); - virtual BOOL getAttributeString( const std::string& name, LLString& value ); + virtual BOOL getAttributeString( const std::string& name, std::string& value ); - const LLString& getContents() + const std::string& getContents() { return mContents; } - LLString getTextContents(); + std::string getTextContents(); LLXmlTreeNode* getParent() { return mParent; } LLXmlTreeNode* getFirstChild(); @@ -161,7 +161,7 @@ public: LLXmlTreeNode* getNextNamedChild(); // returns next child with name, NULL if none protected: - const LLString* getAttribute( LLStdStringHandle name) + const std::string* getAttribute( LLStdStringHandle name) { attribute_map_t::iterator iter = mAttributes.find(name); return (iter == mAttributes.end()) ? 0 : iter->second; @@ -172,15 +172,15 @@ private: void appendContents( const std::string& str ); void addChild( LLXmlTreeNode* child ); - void dump( const LLString& prefix ); + void dump( const std::string& prefix ); protected: - typedef std::map<LLStdStringHandle, const LLString*> attribute_map_t; + typedef std::map<LLStdStringHandle, const std::string*> attribute_map_t; attribute_map_t mAttributes; private: - LLString mName; - LLString mContents; + std::string mName; + std::string mContents; typedef std::list<class LLXmlTreeNode *> child_list_t; child_list_t mChildList; diff --git a/indra/lscript/lscript_byteconvert.h b/indra/lscript/lscript_byteconvert.h index e8b727b737..89f3cc4a21 100644 --- a/indra/lscript/lscript_byteconvert.h +++ b/indra/lscript/lscript_byteconvert.h @@ -1110,7 +1110,7 @@ inline void safe_heap_bytestream_count_char(U8 *stream, S32 &offset) ; } -inline void safe_instruction_char2bytestream(U8 *stream, S32 &offset, char *buffer) +inline void safe_instruction_char2bytestream(U8 *stream, S32 &offset, const char* buffer) { while ( (safe_instruction_check_address(stream, offset, 1)) &&(*(stream + offset++) = *buffer++)) diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l index eec3cb7bbf..5f649d1f8d 100644 --- a/indra/lscript/lscript_compile/indra.l +++ b/indra/lscript/lscript_compile/indra.l @@ -691,10 +691,10 @@ BOOL lscript_compile(const char* src_filename, const char* dst_filename, init_temp_jumps(); gAllocationManager = new LLScriptAllocationManager(); - yyin = LLFile::fopen(src_filename, "r"); + yyin = LLFile::fopen(std::string(src_filename), "r"); if (yyin) { - yyout = LLFile::fopen(err_filename, "w"); + yyout = LLFile::fopen(std::string(err_filename), "w"); // Reset the lexer's internal buffering. diff --git a/indra/lscript/lscript_compile/lscript_tree.cpp b/indra/lscript/lscript_compile/lscript_tree.cpp index efbbe374ed..3a93f7b896 100644 --- a/indra/lscript/lscript_compile/lscript_tree.cpp +++ b/indra/lscript/lscript_compile/lscript_tree.cpp @@ -9704,8 +9704,7 @@ LLScriptScript::LLScriptScript(LLScritpGlobalStorage *globals, mStates(states), mGlobalScope(NULL), mGlobals(NULL), mGlobalFunctions(NULL), mGodLike(FALSE) { const char DEFAULT_BYTECODE_FILENAME[] = "lscript.lso"; - strncpy(mBytecodeDest, DEFAULT_BYTECODE_FILENAME, sizeof(mBytecodeDest) -1); /*Flawfinder: ignore*/ - mBytecodeDest[MAX_STRING-1] = '\0'; + mBytecodeDest = DEFAULT_BYTECODE_FILENAME; LLScriptGlobalVariable *tvar; LLScriptGlobalFunctions *tfunc; LLScritpGlobalStorage *temp; @@ -9751,8 +9750,7 @@ LLScriptScript::LLScriptScript(LLScritpGlobalStorage *globals, void LLScriptScript::setBytecodeDest(const char* dst_filename) { - strncpy(mBytecodeDest, dst_filename, MAX_STRING); /*Flawfinder: ignore*/ - mBytecodeDest[MAX_STRING-1] = '\0'; + mBytecodeDest = ll_safe_string(dst_filename); } void print_cil_globals(LLFILE* fp, LLScriptGlobalVariable* global) diff --git a/indra/lscript/lscript_compile/lscript_tree.h b/indra/lscript/lscript_compile/lscript_tree.h index f80d7fdf24..4c25c097d8 100644 --- a/indra/lscript/lscript_compile/lscript_tree.h +++ b/indra/lscript/lscript_compile/lscript_tree.h @@ -2269,7 +2269,7 @@ public: BOOL mGodLike; private: - char mBytecodeDest[MAX_STRING]; /*Flawfinder: ignore*/ + std::string mBytecodeDest; }; class LLScriptAllocationManager diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp index 70202f7d4d..aa73025b7f 100644 --- a/indra/lscript/lscript_execute/lscript_execute.cpp +++ b/indra/lscript/lscript_execute/lscript_execute.cpp @@ -3684,10 +3684,10 @@ BOOL run_print(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) } -void lscript_run(char *filename, BOOL b_debug) +void lscript_run(const std::string& filename, BOOL b_debug) { LLTimer timer; - if (filename == NULL) + if (filename.empty()) { llerrs << "filename is NULL" << llendl; // Just reporting error is likely not enough. Need @@ -3709,7 +3709,8 @@ void lscript_run(char *filename, BOOL b_debug) file = LLFile::fopen(filename, "r"); if (file) { - LLFILE* fp = LLFile::fopen("lscript.parse", "w"); /*Flawfinder: ignore*/ + std::string parsefile("lscript.parse"); + LLFILE* fp = LLFile::fopen(parsefile, "w"); /*Flawfinder: ignore*/ LLScriptLSOParse *parse = new LLScriptLSOParse(file); parse->printData(fp); delete parse; diff --git a/indra/lscript/lscript_library.h b/indra/lscript/lscript_library.h index 48a566de3e..74356256ae 100644 --- a/indra/lscript/lscript_library.h +++ b/indra/lscript/lscript_library.h @@ -387,8 +387,10 @@ public: LLScriptLibData(const LLUUID &id) : mType(LST_KEY), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL) { - mKey = new char[UUID_STR_LENGTH]; - id.toString(mKey); + std::string idstr; + id.toString(idstr); + mKey = new char[idstr.length()+1]; + LLStringUtil::copy(mKey,idstr.c_str(),idstr.length()+1); } LLScriptLibData(const char *string) : mType(LST_STRING), mInteger(0), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL) diff --git a/indra/lscript/lscript_rt_interface.h b/indra/lscript/lscript_rt_interface.h index 791c447d33..3e05212c67 100644 --- a/indra/lscript/lscript_rt_interface.h +++ b/indra/lscript/lscript_rt_interface.h @@ -35,7 +35,7 @@ BOOL lscript_compile(char *filename, BOOL is_god_like = FALSE); BOOL lscript_compile(const char* src_filename, const char* dst_filename, const char* err_filename, BOOL is_god_like = FALSE); -void lscript_run(char *filename, BOOL b_debug); +void lscript_run(const std::string& filename, BOOL b_debug); #endif diff --git a/indra/mac_crash_logger/llcrashloggermac.cpp b/indra/mac_crash_logger/llcrashloggermac.cpp index 767327f95f..8d7e2ae0f7 100644 --- a/indra/mac_crash_logger/llcrashloggermac.cpp +++ b/indra/mac_crash_logger/llcrashloggermac.cpp @@ -57,7 +57,7 @@ LLFILE *gDebugFile = NULL; WindowRef gWindow = NULL; EventHandlerRef gEventHandler = NULL; -LLString gUserNotes = ""; +std::string gUserNotes = ""; bool gSendReport = false; bool gRememberChoice = false; IBNibRef nib = NULL; @@ -217,16 +217,16 @@ void LLCrashLoggerMac::gatherPlatformSpecificFiles() if(FSRefMakePath(&folder, (UInt8*)&path, sizeof(path)) == noErr) { struct stat dw_stat; - LLString mBuf; + std::string mBuf; bool isLeopard = false; // Try the 10.3 path first... - LLString dw_file_name = LLString(path) + LLString("/CrashReporter/Second Life.crash.log"); + std::string dw_file_name = std::string(path) + std::string("/CrashReporter/Second Life.crash.log"); int res = stat(dw_file_name.c_str(), &dw_stat); if (res) { // Try the 10.2 one next... - dw_file_name = LLString(path) + LLString("/Second Life.crash.log"); + dw_file_name = std::string(path) + std::string("/Second Life.crash.log"); res = stat(dw_file_name.c_str(), &dw_stat); } @@ -235,8 +235,8 @@ void LLCrashLoggerMac::gatherPlatformSpecificFiles() //10.5: Like 10.3+, except it puts the crash time in the file instead of dividing it up //using asterisks. Get a directory listing, search for files starting with second life, //use the last one found. - LLString old_file_name, current_file_name, pathname, mask; - pathname = LLString(path) + LLString("/CrashReporter/"); + std::string old_file_name, current_file_name, pathname, mask; + pathname = std::string(path) + std::string("/CrashReporter/"); mask = "Second Life*"; while(gDirUtilp->getNextFileInDir(pathname, mask, current_file_name, false)) { @@ -331,7 +331,7 @@ bool LLCrashLoggerMac::mainLoop() return true; } -void LLCrashLoggerMac::updateApplication(LLString message) +void LLCrashLoggerMac::updateApplication(const std::string& message) { LLCrashLogger::updateApplication(); } diff --git a/indra/mac_crash_logger/llcrashloggermac.h b/indra/mac_crash_logger/llcrashloggermac.h index cf4e766bda..72675906fb 100644 --- a/indra/mac_crash_logger/llcrashloggermac.h +++ b/indra/mac_crash_logger/llcrashloggermac.h @@ -43,7 +43,7 @@ public: ~LLCrashLoggerMac(void); virtual bool init(); virtual bool mainLoop(); - virtual void updateApplication(LLString message = ""); + virtual void updateApplication(const std::string& message = LLStringUtil::null); virtual bool cleanup(); virtual void gatherPlatformSpecificFiles(); }; diff --git a/indra/mac_updater/mac_updater.cpp b/indra/mac_updater/mac_updater.cpp index 2437071068..800521e572 100644 --- a/indra/mac_updater/mac_updater.cpp +++ b/indra/mac_updater/mac_updater.cpp @@ -986,7 +986,7 @@ void *updatethreadproc(void*) // NOTE: we could add -private at the end of this command line to keep the image from showing up in the Finder, // but if our cleanup fails, this makes it much harder for the user to unmount the image. - LLString mountOutput; + std::string mountOutput; FILE* mounter = popen("hdiutil attach SecondLife.dmg -mountpoint mnt", "r"); /* Flawfinder: ignore */ if(mounter == NULL) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 29d05cbdbc..a1515abf9d 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -199,7 +199,6 @@ set(viewer_SOURCE_FILES llglslshader.cpp llgroupmgr.cpp llgroupnotify.cpp - llhippo.cpp llhoverview.cpp llhudeffectbeam.cpp llhudeffect.cpp @@ -590,7 +589,6 @@ set(viewer_HEADER_FILES llglslshader.h llgroupmgr.h llgroupnotify.h - llhippo.h llhoverview.h llhudeffect.h llhudeffectbeam.h diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index a46db09e3e..9d2ea7a1b7 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -236,8 +236,8 @@ BOOL LLAgent::sDebugDisplayTarget = FALSE; const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f; -std::map<LLString, LLString> LLAgent::sTeleportErrorMessages; -std::map<LLString, LLString> LLAgent::sTeleportProgressMessages; +std::map<std::string, std::string> LLAgent::sTeleportErrorMessages; +std::map<std::string, std::string> LLAgent::sTeleportProgressMessages; class LLAgentFriendObserver : public LLFriendObserver { @@ -819,13 +819,10 @@ void LLAgent::setRegion(LLViewerRegion *regionp) llassert(regionp); if (mRegionp != regionp) { - // JC - Avoid this, causes out-of-bounds array write deep within - // Windows. - // char host_name[MAX_STRING]; - // regionp->getHost().getHostName(host_name, MAX_STRING); + // std::string host_name; + // host_name = regionp->getHost().getHostName(); - char ip[MAX_STRING]; /*Flawfinder: ignore*/ - regionp->getHost().getString(ip, MAX_STRING); + std::string ip = regionp->getHost().getString(); llinfos << "Moving agent into region: " << regionp->getName() << " located at " << ip << llendl; if (mRegionp) @@ -2092,7 +2089,7 @@ void LLAgent::setAFK() if (gAFKMenu) { //*TODO:Translate - gAFKMenu->setLabel(LLString("Set Not Away")); + gAFKMenu->setLabel(std::string("Set Not Away")); } } } @@ -2116,7 +2113,7 @@ void LLAgent::clearAFK() if (gAFKMenu) { //*TODO:Translate - gAFKMenu->setLabel(LLString("Set Away")); + gAFKMenu->setLabel(std::string("Set Away")); } } } @@ -2139,7 +2136,7 @@ void LLAgent::setBusy() if (gBusyMenu) { //*TODO:Translate - gBusyMenu->setLabel(LLString("Set Not Busy")); + gBusyMenu->setLabel(std::string("Set Not Busy")); } LLFloaterMute::getInstance()->updateButtons(); } @@ -2154,7 +2151,7 @@ void LLAgent::clearBusy() if (gBusyMenu) { //*TODO:Translate - gBusyMenu->setLabel(LLString("Set Busy")); + gBusyMenu->setLabel(std::string("Set Busy")); } LLFloaterMute::getInstance()->updateButtons(); } @@ -5113,9 +5110,8 @@ BOOL LLAgent::allowOperation(PermissionBit op, } -void LLAgent::getName(LLString& name) +void LLAgent::getName(std::string& name) { - // Note: assumes that name points to a buffer of at least DB_FULL_NAME_BUF_SIZE bytes. name.clear(); if (mAvatarObject) @@ -5198,8 +5194,8 @@ void LLAgent::processAgentDropGroup(LLMessageSystem *msg, void **) { gAgent.mGroupID.setNull(); gAgent.mGroupPowers = 0; - gAgent.mGroupName[0] = '\0'; - gAgent.mGroupTitle[0] = '\0'; + gAgent.mGroupName.clear(); + gAgent.mGroupTitle.clear(); } // refresh all group information @@ -5277,8 +5273,8 @@ class LLAgentDropGroupViewerNode : public LLHTTPNode { gAgent.mGroupID.setNull(); gAgent.mGroupPowers = 0; - gAgent.mGroupName[0] = '\0'; - gAgent.mGroupTitle[0] = '\0'; + gAgent.mGroupName.clear(); + gAgent.mGroupTitle.clear(); } // refresh all group information @@ -5330,7 +5326,6 @@ void LLAgent::processAgentGroupDataUpdate(LLMessageSystem *msg, void **) LLGroupData group; S32 index = -1; bool need_floater_update = false; - char group_name[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ for(S32 i = 0; i < count; ++i) { msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_GroupID, group.mID, i); @@ -5338,8 +5333,7 @@ void LLAgent::processAgentGroupDataUpdate(LLMessageSystem *msg, void **) msg->getU64(_PREHASH_GroupData, "GroupPowers", group.mPowers, i); msg->getBOOL(_PREHASH_GroupData, "AcceptNotices", group.mAcceptNotices, i); msg->getS32(_PREHASH_GroupData, "Contribution", group.mContribution, i); - msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, DB_GROUP_NAME_BUF_SIZE, group_name, i); - group.mName.assign(group_name); + msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, group.mName, i); if(group.mID.notNull()) { @@ -5437,7 +5431,7 @@ void LLAgent::processAgentDataUpdate(LLMessageSystem *msg, void **) return; } - msg->getStringFast(_PREHASH_AgentData, _PREHASH_GroupTitle, DB_GROUP_TITLE_BUF_SIZE, gAgent.mGroupTitle); + msg->getStringFast(_PREHASH_AgentData, _PREHASH_GroupTitle, gAgent.mGroupTitle); LLUUID active_id; msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_ActiveGroupID, active_id); @@ -5446,13 +5440,13 @@ void LLAgent::processAgentDataUpdate(LLMessageSystem *msg, void **) { gAgent.mGroupID = active_id; msg->getU64(_PREHASH_AgentData, "GroupPowers", gAgent.mGroupPowers); - msg->getString(_PREHASH_AgentData, _PREHASH_GroupName, DB_GROUP_NAME_BUF_SIZE, gAgent.mGroupName); + msg->getString(_PREHASH_AgentData, _PREHASH_GroupName, gAgent.mGroupName); } else { gAgent.mGroupID.setNull(); gAgent.mGroupPowers = 0; - gAgent.mGroupName[0] = '\0'; + gAgent.mGroupName.clear(); } update_group_floaters(active_id); @@ -6217,7 +6211,7 @@ void LLAgent::saveWearableAs( return; } std::string trunc_name(new_name); - LLString::truncate(trunc_name, DB_INV_ITEM_NAME_STR_LEN); + LLStringUtil::truncate(trunc_name, DB_INV_ITEM_NAME_STR_LEN); LLWearable* new_wearable = gWearableList.createCopyFromAvatar( old_wearable, trunc_name); @@ -6251,7 +6245,7 @@ void LLAgent::saveWearableAs( LLWearable* old_wearable = getWearable( type ); if( old_wearable ) { - LLString old_name = old_wearable->getName(); + std::string old_name = old_wearable->getName(); old_wearable->setName( new_name ); LLWearable* new_wearable = gWearableList.createCopyFromAvatar( old_wearable ); old_wearable->setName( old_name ); @@ -6330,7 +6324,7 @@ void LLAgent::setWearableName( const LLUUID& item_id, const std::string& new_nam LLWearable* old_wearable = mWearableEntry[i].mWearable; llassert( old_wearable ); - LLString old_name = old_wearable->getName(); + std::string old_name = old_wearable->getName(); old_wearable->setName( new_name ); LLWearable* new_wearable = gWearableList.createCopy( old_wearable ); LLInventoryItem* item = gInventory.getItem(item_id); @@ -6527,7 +6521,7 @@ void LLAgent::processAgentInitialWearablesUpdate( LLMessageSystem* mesgsys, void { gWearableList.getAsset( asset_id_array[i], - LLString::null, + LLStringUtil::null, LLWearable::typeToAssetType( (EWearableType) i ), LLAgent::onInitialWearableAssetArrived, (void*)(intptr_t)i ); } @@ -6769,7 +6763,7 @@ void LLAgent::makeNewOutfit( new_name = new_folder_name; new_name.append(" "); new_name.append(old_wearable->getTypeLabel()); - LLString::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN); + LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN); new_wearable->setName(new_name); } @@ -7470,7 +7464,7 @@ void LLAgent::observeFriends() } } -void LLAgent::parseTeleportMessages(const LLString& xml_filename) +void LLAgent::parseTeleportMessages(const std::string& xml_filename) { LLXMLNodePtr root; BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); @@ -7488,8 +7482,8 @@ void LLAgent::parseTeleportMessages(const LLString& xml_filename) { if ( !message_set->hasName("message_set") ) continue; - std::map<LLString, LLString> *teleport_msg_map = NULL; - LLString message_set_name; + std::map<std::string, std::string> *teleport_msg_map = NULL; + std::string message_set_name; if ( message_set->getAttributeString("name", message_set_name) ) { @@ -7507,7 +7501,7 @@ void LLAgent::parseTeleportMessages(const LLString& xml_filename) if ( !teleport_msg_map ) continue; - LLString message_name; + std::string message_name; for (LLXMLNode* message_node = message_set->getFirstChild(); message_node != NULL; message_node = message_node->getNextSibling()) diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 281b2d0c88..45006fef8d 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -331,7 +331,7 @@ public: // of the agent in the absolute frame // BOOL getLookingAtAvatar() const; - void getName(LLString& name); + void getName(std::string& name); const LLColor4 &getEffectColor(); void setEffectColor(const LLColor4 &color); @@ -563,8 +563,8 @@ public: ETeleportState getTeleportState() const { return mTeleportState; } void setTeleportState( ETeleportState state ); - const LLString& getTeleportMessage() const { return mTeleportMessage; } - void setTeleportMessage(const LLString& message) + const std::string& getTeleportMessage() const { return mTeleportMessage; } + void setTeleportMessage(const std::string& message) { mTeleportMessage = message; } @@ -694,8 +694,8 @@ public: U64 mGroupPowers; BOOL mHideGroupTitle; - char mGroupTitle[DB_GROUP_TITLE_BUF_SIZE]; /*Flawfinder: ignore*/ // honorific, like "Sir" - char mGroupName[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string mGroupTitle; // honorific, like "Sir" + std::string mGroupName; LLUUID mGroupID; //LLUUID mGroupInsigniaID; LLUUID mInventoryRootID; @@ -719,12 +719,12 @@ public: BOOL mForceMouselook; - static void parseTeleportMessages(const LLString& xml_filename); + static void parseTeleportMessages(const std::string& xml_filename); //we should really define ERROR and PROGRESS enums here //but I don't really feel like doing that, so I am just going //to expose the mappings....yup - static std::map<LLString, LLString> sTeleportErrorMessages; - static std::map<LLString, LLString> sTeleportProgressMessages; + static std::map<std::string, std::string> sTeleportErrorMessages; + static std::map<std::string, std::string> sTeleportProgressMessages; LLFrameTimer mDoubleTapRunTimer; EDoubleTapRunMode mDoubleTapRunMode; @@ -736,7 +736,7 @@ private: // Access or "maturity" level U8 mAccess; // SIM_ACCESS_MATURE or SIM_ACCESS_PG ETeleportState mTeleportState; - LLString mTeleportMessage; + std::string mTeleportMessage; S32 mControlsTakenCount[TOTAL_CONTROLS]; S32 mControlsTakenPassedOnCount[TOTAL_CONTROLS]; diff --git a/indra/newview/llagentpilot.cpp b/indra/newview/llagentpilot.cpp index 136afb78aa..679cd1688e 100644 --- a/indra/newview/llagentpilot.cpp +++ b/indra/newview/llagentpilot.cpp @@ -60,10 +60,13 @@ LLAgentPilot::~LLAgentPilot() { } -void LLAgentPilot::load(const char *filename) +void LLAgentPilot::load(const std::string& filename) { - if(!filename) return; - + if(filename.empty()) + { + return; + } + llifstream file(filename); if (!file) @@ -81,8 +84,7 @@ void LLAgentPilot::load(const char *filename) file >> num_actions; - S32 i; - for (i = 0; i < num_actions; i++) + for (S32 i = 0; i < num_actions; i++) { S32 action_type; Action new_action; @@ -95,10 +97,10 @@ void LLAgentPilot::load(const char *filename) file.close(); } -void LLAgentPilot::save(const char *filename) +void LLAgentPilot::save(const std::string& filename) { llofstream file; - file.open(filename); /*Flawfinder: ignore*/ + file.open(filename); if (!file) { @@ -128,7 +130,7 @@ void LLAgentPilot::startRecord() void LLAgentPilot::stopRecord() { gAgentPilot.addAction(STRAIGHT); - gAgentPilot.save(gSavedSettings.getString("StatsPilotFile").c_str()); + gAgentPilot.save(gSavedSettings.getString("StatsPilotFile")); mRecording = FALSE; } diff --git a/indra/newview/llagentpilot.h b/indra/newview/llagentpilot.h index 3a3140a6e4..55c5351c75 100644 --- a/indra/newview/llagentpilot.h +++ b/indra/newview/llagentpilot.h @@ -51,8 +51,8 @@ public: LLAgentPilot(); virtual ~LLAgentPilot(); - void load(const char *filename); - void save(const char *filename); + void load(const std::string& filename); + void save(const std::string& filename); void startRecord(); void stopRecord(); diff --git a/indra/newview/llanimstatelabels.cpp b/indra/newview/llanimstatelabels.cpp index 380bf7c39c..7877bd7d2f 100644 --- a/indra/newview/llanimstatelabels.cpp +++ b/indra/newview/llanimstatelabels.cpp @@ -33,7 +33,7 @@ #include "llanimstatelabels.h" #include "lltrans.h" -std::string LLAnimStateLabels::getStateLabel( const char *animName ) +std::string LLAnimStateLabels::getStateLabel( const char* animName ) { - return LLTrans::getString("anim_" + LLString(animName) ); + return LLTrans::getString(std::string("anim_") + std::string(animName) ); } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 8140f00167..0c7a5e23ae 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -216,7 +216,7 @@ const F32 DEFAULT_AFK_TIMEOUT = 5.f * 60.f; // time with no input before user fl F32 gSimLastTime; // Used in LLAppViewer::init and send_stats() F32 gSimFrames; -LLString gDisabledMessage; // Set in LLAppViewer::initConfiguration used in idle_startup +std::string gDisabledMessage; // Set in LLAppViewer::initConfiguration used in idle_startup BOOL gHideLinks = FALSE; // Set in LLAppViewer::initConfiguration, used externally @@ -271,7 +271,7 @@ LLVFS* gStaticVFS = NULL; LLMemoryInfo gSysMemory; U64 gMemoryAllocated = 0; // updated in display_stats() in llviewerdisplay.cpp -LLString gLastVersionChannel; +std::string gLastVersionChannel; LLVector3 gWindVec(3.0, 3.0, 0.0); LLVector3 gRelativeWindVec(0.0, 0.0, 0.0); @@ -289,22 +289,22 @@ BOOL gLogoutInProgress = FALSE; //////////////////////////////////////////////////////////// // Internal globals... that should be removed. -static LLString gArgs; +static std::string gArgs; -const char* MARKER_FILE_NAME = "SecondLife.exec_marker"; -const char* ERROR_MARKER_FILE_NAME = "SecondLife.error_marker"; -const char* LLERROR_MARKER_FILE_NAME = "SecondLife.llerror_marker"; -const char* LOGOUT_MARKER_FILE_NAME = "SecondLife.logout_marker"; +const std::string MARKER_FILE_NAME("SecondLife.exec_marker"); +const std::string ERROR_MARKER_FILE_NAME("SecondLife.error_marker"); +const std::string LLERROR_MARKER_FILE_NAME("SecondLife.llerror_marker"); +const std::string LOGOUT_MARKER_FILE_NAME("SecondLife.logout_marker"); static BOOL gDoDisconnect = FALSE; -static LLString gLaunchFileOnQuit; +static std::string gLaunchFileOnQuit; //---------------------------------------------------------------------------- // File scope definitons const char *VFS_DATA_FILE_BASE = "data.db2.x."; const char *VFS_INDEX_FILE_BASE = "index.db2.x."; -static LLString gSecondLife; -static LLString gWindowTitle; +static std::string gSecondLife; +static std::string gWindowTitle; #ifdef LL_WINDOWS static char sWindowClass[] = "Second Life"; #endif @@ -527,7 +527,7 @@ void LLAppViewer::initGridChoice() server = llclamp(server, 0, (S32)GRID_INFO_COUNT - 1); if(server == GRID_INFO_OTHER) { - LLString custom_server = gSavedSettings.getString("CustomServer"); + std::string custom_server = gSavedSettings.getString("CustomServer"); LLViewerLogin::getInstance()->setGridChoice(custom_server); } else if(server != 0) @@ -659,7 +659,7 @@ bool LLAppViewer::init() // Get the single value from the crash settings file, if it exists std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); - gCrashSettings.loadFromFile(crash_settings_filename.c_str()); + gCrashSettings.loadFromFile(crash_settings_filename); ///////////////////////////////////////////////// // OS-specific login dialogs @@ -697,14 +697,14 @@ bool LLAppViewer::init() } // Load art UUID information, don't require these strings to be declared in code. - LLString colors_base_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colors_base.xml"); + std::string colors_base_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colors_base.xml"); LL_DEBUGS("InitInfo") << "Loading base colors from " << colors_base_filename << LL_ENDL; - gColors.loadFromFileLegacy(colors_base_filename.c_str(), FALSE, TYPE_COL4U); + gColors.loadFromFileLegacy(colors_base_filename, FALSE, TYPE_COL4U); // Load overrides from user colors file - LLString user_colors_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colors.xml"); + std::string user_colors_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colors.xml"); LL_DEBUGS("InitInfo") << "Loading user colors from " << user_colors_filename << LL_ENDL; - if (gColors.loadFromFileLegacy(user_colors_filename.c_str(), FALSE, TYPE_COL4U) == 0) + if (gColors.loadFromFileLegacy(user_colors_filename, FALSE, TYPE_COL4U) == 0) { LL_DEBUGS("InitInfo") << "Cannot load user colors from " << user_colors_filename << LL_ENDL; } @@ -731,7 +731,7 @@ bool LLAppViewer::init() LLViewerJointMesh::updateVectorize(); // load MIME type -> media impl mappings - LLMIMETypes::parseMIMETypes( "mime_types.xml" ); + LLMIMETypes::parseMIMETypes( std::string("mime_types.xml") ); // Copy settings to globals. *TODO: Remove or move to appropriage class initializers @@ -778,8 +778,8 @@ bool LLAppViewer::init() "If it continues to persist, you may need to completely uninstall " << gSecondLife << " and reinstall it."; OSMessageBox( - msg.str().c_str(), - NULL, + msg.str(), + LLStringUtil::null, OSMB_OK); return 1; } @@ -803,12 +803,12 @@ bool LLAppViewer::init() bind_keyboard_functions(); // Load Default bindings - if (!gViewerKeyboard.loadBindings(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keys.ini").c_str())) + if (!gViewerKeyboard.loadBindings(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keys.ini"))) { LL_ERRS("InitInfo") << "Unable to open keys.ini" << LL_ENDL; } // Load Custom bindings (override defaults) - gViewerKeyboard.loadBindings(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"custom_keys.ini").c_str()); + gViewerKeyboard.loadBindings(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"custom_keys.ini")); // If we don't have the right GL requirements, exit. if (!gGLManager.mHasRequirements && !gNoRender) @@ -816,16 +816,16 @@ bool LLAppViewer::init() // can't use an alert here since we're existing and // all hell breaks lose. OSMessageBox( - LLAlertDialog::getTemplateMessage("UnsupportedGLRequirements").c_str(), - NULL, + LLAlertDialog::getTemplateMessage("UnsupportedGLRequirements"), + LLStringUtil::null, OSMB_OK); return 0; } bool unsupported = false; - LLString::format_map_t args; - LLString minSpecs; + LLStringUtil::format_map_t args; + std::string minSpecs; // get cpu data from xml std::stringstream minCPUString(LLAlertDialog::getTemplateMessage("UnsupportedCPUAmount")); @@ -1300,7 +1300,7 @@ bool LLAppViewer::cleanup() std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); // save all settings, even if equals defaults - gCrashSettings.saveToFile(crash_settings_filename.c_str(), FALSE); + gCrashSettings.saveToFile(crash_settings_filename, FALSE); gSavedSettings.cleanup(); gColors.cleanup(); @@ -1315,9 +1315,8 @@ bool LLAppViewer::cleanup() if (mPurgeOnExit) { llinfos << "Purging all cache files on exit" << llendflush; - char mask[LL_MAX_PATH]; /* Flawfinder: ignore */ - snprintf(mask, LL_MAX_PATH, "%s*.*", gDirUtilp->getDirDelimiter().c_str()); /* Flawfinder: ignore */ - gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"").c_str(),mask); + std::string mask = gDirUtilp->getDirDelimiter() + "*.*"; + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""),mask); } removeMarkerFile(); // Any crashes from here on we'll just have to ignore @@ -1438,7 +1437,7 @@ bool LLAppViewer::initThreads() void errorCallback(const std::string &error_string) { #ifndef LL_RELEASE_FOR_DOWNLOAD - OSMessageBox(error_string.c_str(), "Fatal Error", OSMB_OK); + OSMessageBox(error_string, "Fatal Error", OSMB_OK); #endif //Set the ErrorActivated global so we know to create a marker file @@ -1459,12 +1458,12 @@ bool LLAppViewer::initLogging() // Remove the last ".old" log file. std::string old_log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLife.old"); - LLFile::remove(old_log_file.c_str()); + LLFile::remove(old_log_file); // Rename current log file to ".old" std::string log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLife.log"); - LLFile::rename(log_file.c_str(), old_log_file.c_str()); + LLFile::rename(log_file, old_log_file); // Set the log file to SecondLife.log @@ -1478,10 +1477,10 @@ void LLAppViewer::loadSettingsFromDirectory(ELLPath path_index) { for(LLSD::map_iterator itr = mSettingsFileList.beginMap(); itr != mSettingsFileList.endMap(); ++itr) { - LLString settings_name = (*itr).first; - LLString settings_file = mSettingsFileList[settings_name].asString(); + std::string settings_name = (*itr).first; + std::string settings_file = mSettingsFileList[settings_name].asString(); - LLString full_settings_path = gDirUtilp->getExpandedFilename(path_index, settings_file); + std::string full_settings_path = gDirUtilp->getExpandedFilename(path_index, settings_file); if(settings_name == sGlobalSettingsName && path_index == LL_PATH_USER_SETTINGS) @@ -1820,7 +1819,7 @@ bool LLAppViewer::initConfiguration() } const LLControlVariable* skinfolder = gSavedSettings.getControl("SkinFolder"); - if(skinfolder && LLString::null != skinfolder->getValue().asString()) + if(skinfolder && LLStringUtil::null != skinfolder->getValue().asString()) { gDirUtilp->setSkinFolder(skinfolder->getValue().asString()); } @@ -1871,8 +1870,8 @@ bool LLAppViewer::initConfiguration() std::ostringstream msg; msg << gSecondLife << " requires a processor with AltiVec (G4 or later)."; OSMessageBox( - msg.str().c_str(), - NULL, + msg.str(), + LLStringUtil::null, OSMB_OK); removeMarkerFile(); return false; @@ -1886,14 +1885,14 @@ bool LLAppViewer::initConfiguration() std::ostringstream splash_msg; splash_msg << "Loading " << gSecondLife << "..."; LLSplashScreen::show(); - LLSplashScreen::update(splash_msg.str().c_str()); + LLSplashScreen::update(splash_msg.str()); //LLVolumeMgr::initClass(); LLVolumeMgr* volume_manager = new LLVolumeMgr(); volume_manager->useMutex(); // LLApp and LLMutex magic must be manually enabled LLPrimitive::setVolumeManager(volume_manager); - // Note: this is where we used to initialize LLFeatureManager::getInstance()->. + // Note: this is where we used to initialize gFeatureManagerp. gStartTime = totalTime(); @@ -1903,11 +1902,11 @@ bool LLAppViewer::initConfiguration() #if LL_RELEASE_FOR_DOWNLOAD gWindowTitle = gSecondLife; #elif LL_DEBUG - gWindowTitle = gSecondLife + LLString(" [DEBUG] ") + gArgs; + gWindowTitle = gSecondLife + std::string(" [DEBUG] ") + gArgs; #else - gWindowTitle = gSecondLife + LLString(" ") + gArgs; + gWindowTitle = gSecondLife + std::string(" ") + gArgs; #endif - LLString::truncate(gWindowTitle, 255); + LLStringUtil::truncate(gWindowTitle, 255); //RN: if we received a URL, hand it off to the existing instance // don't call anotherInstanceRunning() when doing URL handoff, as @@ -1948,8 +1947,8 @@ bool LLAppViewer::initConfiguration() "Check your task bar for a minimized copy of the program.\n" "If this message persists, restart your computer.", OSMessageBox( - msg.str().c_str(), - NULL, + msg.str(), + LLStringUtil::null, OSMB_OK); return false; } @@ -1970,9 +1969,9 @@ bool LLAppViewer::initConfiguration() std::string alert; alert = gSecondLife; alert += " Alert"; - S32 choice = OSMessageBox(msg.str().c_str(), - alert.c_str(), - OSMB_YESNO); + S32 choice = OSMessageBox(msg.str(), + alert, + OSMB_YESNO); if (OSBTN_YES == choice) { llinfos << "Sending crash report." << llendl; @@ -2051,10 +2050,10 @@ bool LLAppViewer::initConfiguration() } // need to do this here - need to have initialized global settings first - LLString nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" ); + std::string nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" ); if ( nextLoginLocation.length() ) { - LLURLSimString::setString( nextLoginLocation.c_str() ); + LLURLSimString::setString( nextLoginLocation ); }; gLastRunVersion = gSavedSettings.getString("LastRunVersion"); @@ -2072,14 +2071,9 @@ bool LLAppViewer::initWindow() // Hide the splash screen LLSplashScreen::hide(); - // HACK: Need a non-const char * for stupid window name (propagated deep down) - char window_title_str[256]; /* Flawfinder: ignore */ - strncpy(window_title_str, gWindowTitle.c_str(), sizeof(window_title_str) - 1); /* Flawfinder: ignore */ - window_title_str[sizeof(window_title_str) - 1] = '\0'; - // always start windowed BOOL ignorePixelDepth = gSavedSettings.getBOOL("IgnorePixelDepth"); - gViewerWindow = new LLViewerWindow(window_title_str, "Second Life", + gViewerWindow = new LLViewerWindow(gWindowTitle, "Second Life", gSavedSettings.getS32("WindowX"), gSavedSettings.getS32("WindowY"), gSavedSettings.getS32("WindowWidth"), gSavedSettings.getS32("WindowHeight"), FALSE, ignorePixelDepth); @@ -2143,7 +2137,7 @@ void LLAppViewer::closeDebug() { std::string debug_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"debug_info.log"); llinfos << "Opening debug file " << debug_filename << llendl; - std::ofstream out_file(debug_filename.c_str()); + llofstream out_file(debug_filename); LLSDSerialize::toPrettyXML(gDebugInfo, out_file); out_file.close(); } @@ -2202,11 +2196,10 @@ void LLAppViewer::cleanupSavedSettings() } } -void LLAppViewer::removeCacheFiles(const char* file_mask) +void LLAppViewer::removeCacheFiles(const std::string& file_mask) { - char mask[LL_MAX_PATH]; /* Flawfinder: ignore */ - snprintf(mask, LL_MAX_PATH, "%s%s", gDirUtilp->getDirDelimiter().c_str(), file_mask); /* Flawfinder: ignore */ - gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "").c_str(), mask); + std::string mask = gDirUtilp->getDirDelimiter() + file_mask; + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), mask); } void LLAppViewer::writeSystemInfo() @@ -2306,8 +2299,8 @@ void LLAppViewer::handleViewerCrash() gDebugInfo["SettingsFilename"] = gSavedSettings.getString("ClientSettingsFile"); gDebugInfo["CAFilename"] = gDirUtilp->getCAFile(); - gDebugInfo["ViewerExePath"] = gDirUtilp->getExecutablePathAndName().c_str(); - gDebugInfo["CurrentPath"] = gDirUtilp->getCurPath().c_str(); + gDebugInfo["ViewerExePath"] = gDirUtilp->getExecutablePathAndName(); + gDebugInfo["CurrentPath"] = gDirUtilp->getCurPath(); if(gLogoutInProgress) { gDebugInfo["LastExecEvent"] = LAST_EXEC_LOGOUT_CRASH; @@ -2334,7 +2327,7 @@ void LLAppViewer::handleViewerCrash() //we're already in a crash situation if (gDirUtilp) { - LLString crash_file_name; + std::string crash_file_name; if(gLLErrorActivated) crash_file_name = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,LLERROR_MARKER_FILE_NAME); else crash_file_name = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,ERROR_MARKER_FILE_NAME); llinfos << "Creating crash marker file " << crash_file_name << llendl; @@ -2354,7 +2347,7 @@ void LLAppViewer::handleViewerCrash() { std::string filename; filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "stats.log"); - llofstream file(filename.c_str(), llofstream::binary); + llofstream file(filename, llofstream::binary); if(file.good()) { llinfos << "Handle viewer crash generating stats log." << llendl; @@ -2443,9 +2436,9 @@ void LLAppViewer::initMarkerFile() // These checks should also remove these files for the last 2 cases if they currently exist //LLError/Error checks. Only one of these should ever happen at a time. - LLString logout_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, LOGOUT_MARKER_FILE_NAME); - LLString llerror_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, LLERROR_MARKER_FILE_NAME); - LLString error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); + std::string logout_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, LOGOUT_MARKER_FILE_NAME); + std::string llerror_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, LLERROR_MARKER_FILE_NAME); + std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); apr_file_t* fMarker = ll_apr_file_open(logout_marker_file, LL_APR_RB); if(fMarker != NULL) @@ -2580,11 +2573,11 @@ static void finish_early_exit(S32 option, void* userdata) LLAppViewer::instance()->forceQuit(); } -void LLAppViewer::earlyExit(const LLString& msg) +void LLAppViewer::earlyExit(const std::string& msg) { llwarns << "app_early_exit: " << msg << llendl; gDoDisconnect = TRUE; -// LLStringBase<char>::format_map_t args; +// LLStringUtil::format_map_t args; // args["[MESSAGE]"] = mesg; // gViewerWindow->alertXml("AppEarlyExit", args, finish_early_exit); LLAlertDialog::showCritical(msg, finish_early_exit, NULL); @@ -2626,8 +2619,8 @@ bool LLAppViewer::initCache() } // Setup and verify the cache location - LLString cache_location = gSavedSettings.getString("CacheLocation"); - LLString new_cache_location = gSavedSettings.getString("NewCacheLocation"); + std::string cache_location = gSavedSettings.getString("CacheLocation"); + std::string new_cache_location = gSavedSettings.getString("NewCacheLocation"); if (new_cache_location != cache_location) { gDirUtilp->setCacheDir(gSavedSettings.getString("CacheLocation")); @@ -2681,12 +2674,12 @@ bool LLAppViewer::initCache() srand(time(NULL)); // Flawfinder: ignore U32 old_salt = gSavedSettings.getU32("VFSSalt"); U32 new_salt; - char old_vfs_data_file[LL_MAX_PATH]; // Flawfinder: ignore - char old_vfs_index_file[LL_MAX_PATH]; // Flawfinder: ignore - char new_vfs_data_file[LL_MAX_PATH]; // Flawfinder: ignore - char new_vfs_index_file[LL_MAX_PATH]; // Flawfinder: ignore - char static_vfs_index_file[LL_MAX_PATH]; // Flawfinder: ignore - char static_vfs_data_file[LL_MAX_PATH]; // Flawfinder: ignore + std::string old_vfs_data_file; + std::string old_vfs_index_file; + std::string new_vfs_data_file; + std::string new_vfs_index_file; + std::string static_vfs_index_file; + std::string static_vfs_data_file; if (gSavedSettings.getBOOL("AllowMultipleViewers")) { @@ -2701,9 +2694,7 @@ bool LLAppViewer::initCache() } while( new_salt == old_salt ); } - snprintf(old_vfs_data_file, LL_MAX_PATH, "%s%u", // Flawfinder: ignore - gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_DATA_FILE_BASE).c_str(), - old_salt); + old_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_DATA_FILE_BASE) + llformat("%u",old_salt); // make sure this file exists llstat s; @@ -2722,29 +2713,18 @@ bool LLAppViewer::initCache() std::string found_file; if (gDirUtilp->getNextFileInDir(dir, mask, found_file, false)) { - snprintf(old_vfs_data_file, LL_MAX_PATH, "%s%s%s", dir.c_str(), gDirUtilp->getDirDelimiter().c_str(), found_file.c_str()); // Flawfinder: ignore + old_vfs_data_file = dir + gDirUtilp->getDirDelimiter() + found_file; - S32 start_pos; - S32 length = strlen(found_file.c_str()); /* Flawfinder: ignore*/ - for (start_pos = length - 1; start_pos >= 0; start_pos--) - { - if (found_file[start_pos] == '.') - { - start_pos++; - break; - } - } + S32 start_pos = found_file.find_last_of('.'); if (start_pos > 0) { - sscanf(found_file.c_str() + start_pos, "%d", &old_salt); + sscanf(found_file.substr(start_pos+1).c_str(), "%d", &old_salt); } LL_DEBUGS("AppCache") << "Default vfs data file not present, found: " << old_vfs_data_file << " Old salt: " << old_salt << llendl; } } - snprintf(old_vfs_index_file, LL_MAX_PATH, "%s%u", // Flawfinder: ignore - gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_INDEX_FILE_BASE).c_str(), - old_salt); + old_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_INDEX_FILE_BASE) + llformat("%u",old_salt); stat_result = LLFile::stat(old_vfs_index_file, &s); if (stat_result) @@ -2773,18 +2753,11 @@ bool LLAppViewer::initCache() gDirUtilp->deleteFilesInDir(dir, mask); } - snprintf(new_vfs_data_file, LL_MAX_PATH, "%s%u", // Flawfinder: ignore - gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_DATA_FILE_BASE).c_str(), - new_salt); - - snprintf(new_vfs_index_file, LL_MAX_PATH, "%s%u", gDirUtilp->getExpandedFilename(LL_PATH_CACHE, VFS_INDEX_FILE_BASE).c_str(), // Flawfinder: ignore - new_salt); - + new_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_DATA_FILE_BASE) + llformat("%u",new_salt); + new_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, VFS_INDEX_FILE_BASE) + llformat("%u",new_salt); - strncpy(static_vfs_data_file, gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"static_data.db2").c_str(), LL_MAX_PATH -1); // Flawfinder: ignore - static_vfs_data_file[LL_MAX_PATH -1] = '\0'; - strncpy(static_vfs_index_file, gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"static_index.db2").c_str(), LL_MAX_PATH -1); // Flawfinder: ignore - static_vfs_index_file[LL_MAX_PATH -1] = '\0'; + static_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"static_data.db2"); + static_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"static_index.db2"); if (resize_vfs) { @@ -2835,15 +2808,15 @@ void LLAppViewer::purgeCache() LL_INFOS("AppCache") << "Purging Cache and Texture Cache..." << llendl; LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE); std::string mask = gDirUtilp->getDirDelimiter() + "*.*"; - gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"").c_str(),mask); + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""),mask); } -const LLString& LLAppViewer::getSecondLifeTitle() const +const std::string& LLAppViewer::getSecondLifeTitle() const { return gSecondLife; } -const LLString& LLAppViewer::getWindowTitle() const +const std::string& LLAppViewer::getWindowTitle() const { return gWindowTitle; } @@ -2864,7 +2837,7 @@ void finish_forced_disconnect(S32 /* option */, void* /* userdata */) } -void LLAppViewer::forceDisconnect(const LLString& mesg) +void LLAppViewer::forceDisconnect(const std::string& mesg) { if (gDoDisconnect) { @@ -2874,13 +2847,13 @@ void LLAppViewer::forceDisconnect(const LLString& mesg) } // Translate the message if possible - LLString big_reason = LLAgent::sTeleportErrorMessages[mesg]; + std::string big_reason = LLAgent::sTeleportErrorMessages[mesg]; if ( big_reason.size() == 0 ) { big_reason = mesg; } - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; gDoDisconnect = TRUE; if (LLStartUp::getStartupState() < STATE_STARTED) @@ -2941,7 +2914,7 @@ void LLAppViewer::saveFinalSnapshot() gSavedSettings.setBOOL("ShowParcelOwners", FALSE); idle(); - LLString snap_filename = gDirUtilp->getLindenUserDir(); + std::string snap_filename = gDirUtilp->getLindenUserDir(); snap_filename += gDirUtilp->getDirDelimiter(); snap_filename += SCREEN_LAST_FILENAME; // use full pixel dimensions of viewer window (not post-scale dimensions) @@ -2956,7 +2929,7 @@ void LLAppViewer::loadNameCache() std::string name_cache; name_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "name.cache"); - llifstream cache_file(name_cache.c_str()); + llifstream cache_file(name_cache); if(cache_file.is_open()) { if(gCacheName->importFile(cache_file)) return; @@ -2964,7 +2937,7 @@ void LLAppViewer::loadNameCache() // Try to load from the legacy format. This should go away after a // while. Phoenix 2008-01-30 - LLFILE* name_cache_fp = LLFile::fopen(name_cache.c_str(), "r"); // Flawfinder: ignore + LLFILE* name_cache_fp = LLFile::fopen(name_cache, "r"); // Flawfinder: ignore if (name_cache_fp) { gCacheName->importFile(name_cache_fp); @@ -2978,7 +2951,7 @@ void LLAppViewer::saveNameCache() std::string name_cache; name_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "name.cache"); - llofstream cache_file(name_cache.c_str()); + llofstream cache_file(name_cache); if(cache_file.is_open()) { gCacheName->exportFile(cache_file); @@ -3421,9 +3394,7 @@ void LLAppViewer::idleShutdown() S32 finished_uploads = total_uploads - pending_uploads; F32 percent = 100.f * finished_uploads / total_uploads; gViewerWindow->setProgressPercent(percent); - char buffer[MAX_STRING]; // Flawfinder: ignore - snprintf(buffer, MAX_STRING, "Saving final data..."); // Flawfinder: ignore - gViewerWindow->setProgressString(buffer); + gViewerWindow->setProgressString("Saving final data..."); return; } diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 8ef22deb27..228f6e4baf 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -63,7 +63,7 @@ public: void forceQuit(); // Puts the viewer into 'shutting down without error' mode. void requestQuit(); // Request a quit. A kinder, gentler quit. void userQuit(); // The users asks to quit. Confirm, then requestQuit() - void earlyExit(const LLString& msg); // Display an error dialog and forcibly quit. + void earlyExit(const std::string& msg); // Display an error dialog and forcibly quit. void forceExit(S32 arg); // exit() immediately (after some cleanup). void abortQuit(); // Called to abort a quit request. @@ -91,10 +91,10 @@ public: bool getPurgeCache() const { return mPurgeCache; } - const LLString& getSecondLifeTitle() const; // The Second Life title. - const LLString& getWindowTitle() const; // The window display name. + const std::string& getSecondLifeTitle() const; // The Second Life title. + const std::string& getWindowTitle() const; // The window display name. - void forceDisconnect(const LLString& msg); // Force disconnection, with a message to the user. + void forceDisconnect(const std::string& msg); // Force disconnection, with a message to the user. void badNetworkHandler(); // Cause a crash state due to bad network packet. bool hasSavedFinalSnapshot() { return mSavedFinalSnapshot; } @@ -157,7 +157,7 @@ private: void purgeCache(); // Clear the local cache. void cleanupSavedSettings(); // Sets some config data to current or default values during cleanup. - void removeCacheFiles(const char *filemask); // Deletes cached files the match the given wildcard. + void removeCacheFiles(const std::string& filemask); // Deletes cached files the match the given wildcard. void writeSystemInfo(); // Write system info to "debug_info.log" @@ -177,10 +177,10 @@ private: bool mSecondInstance; // Is this a second instance of the app? - LLString mMarkerFileName; + std::string mMarkerFileName; apr_file_t* mMarkerFile; // A file created to indicate the app is running. - LLString mLogoutMarkerFileName; + std::string mLogoutMarkerFileName; apr_file_t* mLogoutMarkerFile; // A file created to indicate the app is running. @@ -217,7 +217,7 @@ const S32 AGENT_UPDATES_PER_SECOND = 10; // "// llstartup" indicates that llstartup is the only client for this global. extern BOOL gHandleKeysAsync; // gSavedSettings used by llviewerdisplay.cpp & llviewermenu.cpp -extern LLString gDisabledMessage; // llstartup +extern std::string gDisabledMessage; // llstartup extern BOOL gHideLinks; // used by llpanellogin, lllfloaterbuycurrency, llstartup extern LLSD gDebugInfo; @@ -287,7 +287,7 @@ extern LLVFS *gStaticVFS; extern LLMemoryInfo gSysMemory; extern U64 gMemoryAllocated; -extern LLString gLastVersionChannel; +extern std::string gLastVersionChannel; extern LLVector3 gWindVec; extern LLVector3 gRelativeWindVec; diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp index 0a2cb43c80..980ccd81fd 100644 --- a/indra/newview/llappviewerlinux.cpp +++ b/indra/newview/llappviewerlinux.cpp @@ -131,7 +131,7 @@ static inline BOOL do_basic_glibc_backtrace() std::string strace_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log"); llinfos << "Opening stack trace file " << strace_filename << llendl; - LLFILE* StraceFile = LLFile::fopen(strace_filename.c_str(), "w"); + LLFILE* StraceFile = LLFile::fopen(strace_filename, "w"); if (!StraceFile) { llinfos << "Opening stack trace file " << strace_filename << " failed. Using stderr." << llendl; @@ -162,7 +162,7 @@ static inline BOOL do_basic_glibc_backtrace() std::string strace_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log"); llinfos << "Opening stack trace file " << strace_filename << llendl; - LLFILE* StraceFile = LLFile::fopen(strace_filename.c_str(), "w"); // Flawfinder: ignore + LLFILE* StraceFile = LLFile::fopen(strace_filename, "w"); // Flawfinder: ignore if (!StraceFile) { llinfos << "Opening stack trace file " << strace_filename << " failed. Using stderr." << llendl; @@ -200,7 +200,7 @@ static inline BOOL do_elfio_glibc_backtrace() std::string strace_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log"); llinfos << "Opening stack trace file " << strace_filename << llendl; - LLFILE* StraceFile = LLFile::fopen(strace_filename.c_str(), "w"); // Flawfinder: ignore + LLFILE* StraceFile = LLFile::fopen(strace_filename, "w"); // Flawfinder: ignore if (!StraceFile) { llinfos << "Opening stack trace file " << strace_filename << " failed. Using stderr." << llendl; @@ -429,7 +429,7 @@ bool LLAppViewerLinux::initLogging() // Remove the last stack trace, if any std::string old_stack_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log"); - LLFile::remove(old_stack_file.c_str()); + LLFile::remove(old_stack_file); return LLAppViewer::initLogging(); } diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index c1e6888478..a6d93e5652 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -178,7 +178,7 @@ bool LLAppViewerMacOSX::initParseCommandLine(LLCommandLineParser& clp) char path[MAX_PATH]; if(CFURLGetFileSystemRepresentation(url, false, (UInt8 *)path, sizeof(path))) { - LLString lang; + std::string lang; if(_read_file_into_string(lang, path)) /* Flawfinder: ignore*/ { LLControlVariable* c = gSavedSettings.getControl("SystemLanguage"); @@ -201,7 +201,7 @@ void LLAppViewerMacOSX::handleSyncCrashTrace() void LLAppViewerMacOSX::handleCrashReporting() { // Macintosh - LLString command_str; + std::string command_str; command_str += "open crashreporter.app"; clear_signals(); @@ -331,7 +331,7 @@ OSStatus DisplayReleaseNotes(void) id.signature = 'text'; id.id = 0; - LLString releaseNotesText; + std::string releaseNotesText; _read_file_into_string(releaseNotesText, "releasenotes.txt"); // Flawfinder: ignore diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index e2663f05bd..b88bcb758b 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -298,7 +298,7 @@ void LLAppViewerWin32::initConsole() void write_debug_dx(const char* str) { - LLString value = gDebugInfo["DXInfo"].asString(); + std::string value = gDebugInfo["DXInfo"].asString(); value += str; gDebugInfo["DXInfo"] = value; } @@ -347,7 +347,7 @@ bool LLAppViewerWin32::initHardwareTest() "\n" "Do you wish to continue?\n"; S32 button = OSMessageBox( - msg.str().c_str(), + msg.str(), "Warning", OSMB_YESNO); if (OSBTN_NO== button) @@ -367,7 +367,7 @@ bool LLAppViewerWin32::initHardwareTest() std::ostringstream splash_msg; splash_msg << "Loading " << LLAppViewer::instance()->getSecondLifeTitle() << "..."; - LLSplashScreen::update(splash_msg.str().c_str()); + LLSplashScreen::update(splash_msg.str()); } if (!LLWinDebug::checkExceptionHandler()) diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index 3d2ae03d63..3d91384f48 100644 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -86,7 +86,7 @@ LLAssetUploadResponder::~LLAssetUploadResponder() if (!mFileName.empty()) { // Delete temp file - LLFile::remove(mFileName.c_str()); + LLFile::remove(mFileName); } } @@ -95,7 +95,7 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason) { llinfos << "LLAssetUploadResponder::error " << statusNum << " reason: " << reason << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; switch(statusNum) { case 400: @@ -164,7 +164,7 @@ void LLAssetUploadResponder::uploadFailure(const LLSD& content) } else { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); args["[REASON]"] = content["message"].asString(); gViewerWindow->alertXml("CannotUploadReason", args); @@ -192,8 +192,8 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) { lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; - LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString().c_str()); - LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString().c_str()); + LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); + LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); // Update L$ and ownership credit information // since it probably changed on the server @@ -209,7 +209,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); gAgent.sendReliableMessage(); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d",LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); LLNotifyBox::showXml("UploadPayment", args); } @@ -276,27 +276,16 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) // *FIX: This is a pretty big hack. What this does is check the // file picker if there are any more pending uploads. If so, // upload that file. - const char* next_file = LLFilePicker::instance().getNextFile(); - if(next_file) + std::string next_file = LLFilePicker::instance().getNextFile(); + if(!next_file.empty()) { - const char* name = LLFilePicker::instance().getDirname(); + std::string name = gDirUtilp->getBaseFileName(next_file, true); - LLString asset_name = name; - LLString::replaceNonstandardASCII( asset_name, '?' ); - LLString::replaceChar(asset_name, '|', '?'); - LLString::stripNonprintable(asset_name); - LLString::trim(asset_name); - - char* asset_name_str = (char*)asset_name.c_str(); - char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists - if( !end_p ) - { - end_p = asset_name_str + strlen( asset_name_str ); /*Flawfinder: ignore*/ - } - - S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) ); - - asset_name = asset_name.substr( 0, len ); + std::string asset_name = name; + LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); + LLStringUtil::replaceChar(asset_name, '|', '?'); + LLStringUtil::stripNonprintable(asset_name); + LLStringUtil::trim(asset_name); upload_new_resource(next_file, asset_name, asset_name, 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 11d4f4c651..1fdefbac49 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -78,7 +78,7 @@ public: public: LLUUID mAvatarID; - LLString mName; + std::string mName; LLVector3d mGlobalPositionEstimate; bool mHaveInfo; bool mHaveCoarseInfo; @@ -240,7 +240,7 @@ void LLAvatarTracker::getDegreesAndDist(F32& rot, rot = F32(RAD_TO_DEG * atan2(to_vec.mdV[VY], to_vec.mdV[VX])); } -const LLString& LLAvatarTracker::getName() +const std::string& LLAvatarTracker::getName() { if(mTrackingData) { @@ -248,7 +248,7 @@ const LLString& LLAvatarTracker::getName() } else { - return LLString::null; + return LLStringUtil::null; } } @@ -592,7 +592,7 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg) if((mBuddyInfo[agent_id]->getRightsGrantedFrom() ^ new_rights) & LLRelationship::GRANT_MODIFY_OBJECTS) { std::string first, last; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; if(gCacheName->getName(agent_id, first, last)) { args["[FIRST_NAME]"] = first; @@ -638,7 +638,7 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) tracking_id = mTrackingData->mAvatarID; } BOOL notify = FALSE; - LLString::format_map_t args; + LLStringUtil::format_map_t args; for(S32 i = 0; i < count; ++i) { msg->getUUIDFast(_PREHASH_AgentBlock, _PREHASH_AgentID, agent_id, i); diff --git a/indra/newview/llcallingcard.h b/indra/newview/llcallingcard.h index c00fe5295d..763ef00b8a 100644 --- a/indra/newview/llcallingcard.h +++ b/indra/newview/llcallingcard.h @@ -101,7 +101,7 @@ public: LLVector3d getGlobalPos(); // Get the name passed in, returns null string if uninitialized. - const LLString& getName(); + const std::string& getName(); // Get the avatar being tracked, returns LLUUID::null if uninitialized const LLUUID& getAvatarID(); diff --git a/indra/newview/llcaphttpsender.cpp b/indra/newview/llcaphttpsender.cpp index f34711a5c6..3065da4c7b 100644 --- a/indra/newview/llcaphttpsender.cpp +++ b/indra/newview/llcaphttpsender.cpp @@ -40,7 +40,7 @@ LLCapHTTPSender::LLCapHTTPSender(const std::string& cap) : } //virtual -void LLCapHTTPSender::send(const LLHost& host, const char* message, +void LLCapHTTPSender::send(const LLHost& host, const std::string& message, const LLSD& body, LLHTTPClient::ResponderPtr response) const { diff --git a/indra/newview/llcaphttpsender.h b/indra/newview/llcaphttpsender.h index 222aa773cc..2296281241 100644 --- a/indra/newview/llcaphttpsender.h +++ b/indra/newview/llcaphttpsender.h @@ -43,7 +43,7 @@ public: /** @brief Send message via UntrustedMessage capability with body, call response when done */ virtual void send(const LLHost& host, - const char* message, const LLSD& body, + const std::string& message, const LLSD& body, LLHTTPClient::ResponderPtr response) const; private: diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp index e2ab30f1cb..fac934a3bb 100644 --- a/indra/newview/llchatbar.cpp +++ b/indra/newview/llchatbar.cpp @@ -96,7 +96,7 @@ private: // LLChatBar::LLChatBar() -: LLPanel("", LLRect(), BORDER_NO), +: LLPanel(LLStringUtil::null, LLRect(), BORDER_NO), mInputEditor(NULL), mGestureLabelTimer(), mLastSpecialChatChannel(0), @@ -220,9 +220,9 @@ void LLChatBar::refreshGestures() if (mGestureCombo && gestures) { //store current selection so we can maintain it - LLString cur_gesture = mGestureCombo->getValue().asString(); + std::string cur_gesture = mGestureCombo->getValue().asString(); gestures->selectFirstItem(); - LLString label = mGestureCombo->getValue().asString();; + std::string label = mGestureCombo->getValue().asString();; // clear gestures->clearRows(); @@ -241,14 +241,14 @@ void LLChatBar::refreshGestures() } } - // ad unique gestures + // add unique gestures std::map <std::string, BOOL>::iterator it2; for (it2 = unique.begin(); it2 != unique.end(); ++it2) { gestures->addSimpleElement((*it2).first); } - gestures->sortByColumn(0, TRUE); + gestures->sortByColumn(LLStringUtil::null, TRUE); // Insert label after sorting gestures->addSimpleElement(label, ADD_TOP); @@ -299,9 +299,9 @@ BOOL LLChatBar::inputEditorHasFocus() return mInputEditor && mInputEditor->hasFocus(); } -LLString LLChatBar::getCurrentChat() +std::string LLChatBar::getCurrentChat() { - return mInputEditor ? mInputEditor->getText() : LLString::null; + return mInputEditor ? mInputEditor->getText() : LLStringUtil::null; } void LLChatBar::setGestureCombo(LLComboBox* combo) @@ -344,12 +344,12 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel) S32 pos = 0; // Copy the channel number into a string - llwchar channel_string[64]; + LLWString channel_string; llwchar c; do { c = mesg[pos+1]; - channel_string[pos] = c; + channel_string.push_back(c); pos++; } while(c && pos < 64 && LLStringOps::isDigit(c)); @@ -362,7 +362,6 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel) c = mesg[pos+1]; pos++; } - mLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10); *channel = mLastSpecialChatChannel; @@ -381,8 +380,8 @@ void LLChatBar::sendChat( EChatType type ) { LLWString text; if (mInputEditor) text = mInputEditor->getWText(); - LLWString::trim(text); - LLWString::replaceChar(text,182,'\n'); // Convert paragraph symbols back into newlines. + LLWStringUtil::trim(text); + LLWStringUtil::replaceChar(text,182,'\n'); // Convert paragraph symbols back into newlines. if (!text.empty()) { @@ -413,7 +412,7 @@ void LLChatBar::sendChat( EChatType type ) sendChatFromViewer(utf8_revised_text, type, TRUE); } } - childSetValue("Chat Editor", LLString::null); + childSetValue("Chat Editor", LLStringUtil::null); gAgent.stopTyping(); @@ -478,7 +477,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) // Can't trim the end, because that will cause autocompletion // to eat trailing spaces that might be part of a gesture. - LLWString::trimHead(raw_text); + LLWStringUtil::trimHead(raw_text); S32 length = raw_text.length(); @@ -499,7 +498,7 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) { // the selection will already be deleted, but we need to trim // off the character before - LLString new_text = raw_text.substr(0, length-1); + std::string new_text = raw_text.substr(0, length-1); self->mInputEditor->setText( new_text ); self->mInputEditor->setCursorToEnd(); length = length - 1; diff --git a/indra/newview/llchatbar.h b/indra/newview/llchatbar.h index c5cb741453..912cadbf7d 100644 --- a/indra/newview/llchatbar.h +++ b/indra/newview/llchatbar.h @@ -65,7 +65,7 @@ public: void setIgnoreArrowKeys(BOOL b); BOOL inputEditorHasFocus(); - LLString getCurrentChat(); + std::string getCurrentChat(); // since chat bar logic is reused for chat history // gesture combo box might not be a direct child diff --git a/indra/newview/llcolorswatch.cpp b/indra/newview/llcolorswatch.cpp index e4256b40f5..b8166a98f6 100644 --- a/indra/newview/llcolorswatch.cpp +++ b/indra/newview/llcolorswatch.cpp @@ -73,7 +73,7 @@ LLColorSwatchCtrl::LLColorSwatchCtrl(const std::string& name, const LLRect& rect // Scalable UI made this off-by-one, I don't know why. JC LLRect border_rect(0, getRect().getHeight()-1, getRect().getWidth()-1, 0); border_rect.mBottom += BTN_HEIGHT_SMALL; - mBorder = new LLViewBorder("border", border_rect, LLViewBorder::BEVEL_IN); + mBorder = new LLViewBorder(std::string("border"), border_rect, LLViewBorder::BEVEL_IN); addChild(mBorder); mAlphaGradientImage = LLUI::getUIImage("color_swatch_alpha.tga"); @@ -100,7 +100,7 @@ LLColorSwatchCtrl::LLColorSwatchCtrl(const std::string& name, const LLRect& rect // Scalable UI made this off-by-one, I don't know why. JC LLRect border_rect(0, getRect().getHeight()-1, getRect().getWidth()-1, 0); border_rect.mBottom += BTN_HEIGHT_SMALL; - mBorder = new LLViewBorder("border", border_rect, LLViewBorder::BEVEL_IN); + mBorder = new LLViewBorder(std::string("border"), border_rect, LLViewBorder::BEVEL_IN); addChild(mBorder); mAlphaGradientImage = LLUI::getUIImage("color_swatch_alpha.tga"); @@ -351,10 +351,10 @@ LLXMLNodePtr LLColorSwatchCtrl::getXML(bool save_children) const LLView* LLColorSwatchCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("colorswatch"); + std::string name("colorswatch"); node->getAttributeString("name", name); - LLString label; + std::string label; node->getAttributeString("label", label); LLColor4 color(1.f, 1.f, 1.f, 1.f); diff --git a/indra/newview/llcommandlineparser.cpp b/indra/newview/llcommandlineparser.cpp index f06a8abfe0..f9c8100cf5 100644 --- a/indra/newview/llcommandlineparser.cpp +++ b/indra/newview/llcommandlineparser.cpp @@ -218,20 +218,20 @@ protected: //---------------------------------------------------------------------------- // LLCommandLineParser defintions //---------------------------------------------------------------------------- -void LLCommandLineParser::addOptionDesc(const LLString& option_name, +void LLCommandLineParser::addOptionDesc(const std::string& option_name, boost::function1<void, const token_vector_t&> notify_callback, unsigned int token_count, - const LLString& description, - const LLString& short_name, + const std::string& description, + const std::string& short_name, bool composing, bool positional, bool last_option) { // Compose the name for boost::po. // It takes the format "long_name, short name" - const LLString comma(","); - LLString boost_option_name = option_name; - if(short_name != LLString::null) + const std::string comma(","); + std::string boost_option_name = option_name; + if(short_name != LLStringUtil::null) { boost_option_name += comma; boost_option_name += short_name; @@ -413,7 +413,7 @@ const LLCommandLineParser::token_vector_t& LLCommandLineParser::getOption(const // LLControlGroupCLP defintions //---------------------------------------------------------------------------- void setControlValueCB(const LLCommandLineParser::token_vector_t& value, - const LLString& opt_name, + const std::string& opt_name, LLControlGroup* ctrlGroup) { if(value.size() > 1) @@ -442,7 +442,7 @@ void setControlValueCB(const LLCommandLineParser::token_vector_t& value, { // There's a token. check the string for true/false/1/0 etc. BOOL result = false; - BOOL gotSet = LLString::convertToBOOL(value[0], result); + BOOL gotSet = LLStringUtil::convertToBOOL(value[0], result); if(gotSet) { ctrl->setValue(LLSD(result), false); @@ -489,14 +489,14 @@ void setControlValueCB(const LLCommandLineParser::token_vector_t& value, } } -void LLControlGroupCLP::configure(const LLString& config_filename, LLControlGroup* controlGroup) +void LLControlGroupCLP::configure(const std::string& config_filename, LLControlGroup* controlGroup) { // This method reads the llsd based config file, and uses it to set // members of a control group. LLSD clpConfigLLSD; llifstream input_stream; - input_stream.open(config_filename.c_str(), std::ios::in | std::ios::binary); + input_stream.open(config_filename, std::ios::in | std::ios::binary); if(input_stream.is_open()) { @@ -508,13 +508,13 @@ void LLControlGroupCLP::configure(const LLString& config_filename, LLControlGrou LLSD::String long_name = option_itr->first; LLSD option_params = option_itr->second; - LLString desc("n/a"); + std::string desc("n/a"); if(option_params.has("desc")) { desc = option_params["desc"].asString(); } - LLString short_name = LLString::null; + std::string short_name = LLStringUtil::null; if(option_params.has("short")) { short_name = option_params["short"].asString(); @@ -547,7 +547,7 @@ void LLControlGroupCLP::configure(const LLString& config_filename, LLControlGrou boost::function1<void, const token_vector_t&> callback; if(option_params.has("map-to") && (NULL != controlGroup)) { - LLString controlName = option_params["map-to"].asString(); + std::string controlName = option_params["map-to"].asString(); callback = boost::bind(setControlValueCB, _1, controlName, controlGroup); } diff --git a/indra/newview/llcommandlineparser.h b/indra/newview/llcommandlineparser.h index 6fe418a631..229da81bd1 100644 --- a/indra/newview/llcommandlineparser.h +++ b/indra/newview/llcommandlineparser.h @@ -62,11 +62,11 @@ public: * @param description The text description of the option usage. */ void addOptionDesc( - const LLString& option_name, + const std::string& option_name, boost::function1<void, const token_vector_t&> notify_callback = 0, unsigned int num_tokens = 0, - const LLString& description = LLString::null, - const LLString& short_name = LLString::null, + const std::string& description = LLStringUtil::null, + const std::string& short_name = LLStringUtil::null, bool composing = false, bool positional = false, bool last_option = false); @@ -159,7 +159,7 @@ public: * * *FIX:Mani Specify config file format. */ - void configure(const LLString& config_filename, + void configure(const std::string& config_filename, LLControlGroup* controlGroup); }; diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index 8e5e8c8ea3..3ab340f66a 100644 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -63,14 +63,14 @@ ///---------------------------------------------------------------------------- // *TODO:Translate -const char* COMPILE_QUEUE_TITLE = "Recompilation Progress"; -const char* COMPILE_START_STRING = "recompile"; -const char* RESET_QUEUE_TITLE = "Reset Progress"; -const char* RESET_START_STRING = "reset"; -const char* RUN_QUEUE_TITLE = "Set Running Progress"; -const char* RUN_START_STRING = "set running"; -const char* NOT_RUN_QUEUE_TITLE = "Set Not Running Progress"; -const char* NOT_RUN_START_STRING = "set not running"; +const std::string COMPILE_QUEUE_TITLE("Recompilation Progress"); +const std::string COMPILE_START_STRING("recompile"); +const std::string RESET_QUEUE_TITLE("Reset Progress"); +const std::string RESET_START_STRING("reset"); +const std::string RUN_QUEUE_TITLE("Set Running Progress"); +const std::string RUN_START_STRING("set running"); +const std::string NOT_RUN_QUEUE_TITLE("Set Not Running Progress"); +const std::string NOT_RUN_START_STRING("set not running"); struct LLCompileQueueData { @@ -83,8 +83,8 @@ struct LLCompileQueueData struct LLScriptQueueData { LLUUID mQueueID; - LLString mScriptName; - LLScriptQueueData(const LLUUID& q_id, const char* name) : + std::string mScriptName; + LLScriptQueueData(const LLUUID& q_id, const std::string& name) : mQueueID(q_id), mScriptName(name) {} }; @@ -98,9 +98,9 @@ LLMap<LLUUID, LLFloaterScriptQueue*> LLFloaterScriptQueue::sInstances; // Default constructor LLFloaterScriptQueue::LLFloaterScriptQueue(const std::string& name, - const LLRect& rect, - const char* title, - const char* start_string) : + const LLRect& rect, + const std::string& title, + const std::string& start_string) : LLFloater(name, rect, title, RESIZE_YES, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES) @@ -198,8 +198,8 @@ void LLFloaterScriptQueue::addObject(const LLUUID& id) BOOL LLFloaterScriptQueue::start() { //llinfos << "LLFloaterCompileQueue::start()" << llendl; - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(buffer, sizeof(buffer), "Starting %s of %d items.", mStartString, mObjectIDs.count()); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat("Starting %s of %d items.", mStartString.c_str(), mObjectIDs.count()); // *TODO: Translate LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); list->addCommentText(buffer); @@ -238,8 +238,7 @@ BOOL LLFloaterScriptQueue::nextObject() LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); mDone = TRUE; - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(buffer, sizeof(buffer), "Done."); /* Flawfinder: ignore */ + std::string buffer = "Done."; // *TODO: Translate list->addCommentText(buffer); childSetEnabled("close",TRUE); } @@ -286,8 +285,7 @@ LLFloaterCompileQueue* LLFloaterCompileQueue::create() gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("CompileOutputRect"); rect.translate(left - rect.mLeft, top - rect.mTop); - LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue", - rect); + LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue", rect); new_queue->open(); /*Flawfinder: ignore*/ return new_queue; } @@ -344,7 +342,7 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object, for(iter = asset_item_map.begin(); iter != asset_item_map.end(); iter++) { LLInventoryItem *itemp = iter->second; - LLScriptQueueData* datap = new LLScriptQueueData(getID(), itemp->getName().c_str()); + LLScriptQueueData* datap = new LLScriptQueueData(getID(), itemp->getName()); //llinfos << "ITEM NAME 2: " << names.get(i) << llendl; gAssetStorage->getInvItemAsset(viewer_object->getRegion()->getHost(), @@ -373,18 +371,17 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, if(!data) return; LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*> (LLFloaterScriptQueue::findInstance(data->mQueueID)); - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - buffer[0] = '\0'; + std::string buffer; if(queue && (0 == status)) { //llinfos << "ITEM NAME 3: " << data->mScriptName << llendl; // Dump this into a file on the local disk so we can compile it. - char filename[LL_MAX_PATH] = ""; /*Flawfinder: ignore*/ + std::string filename; LLVFile file(vfs, asset_id, type); - char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string uuid_str; asset_id.toString(uuid_str); - snprintf(filename, sizeof(filename), "%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */ + filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + llformat(".%s",LLAssetType::lookup(type)); LLFILE *fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/ if (fp) @@ -403,8 +400,9 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, fclose(fp); } + // *TODO: translate // It's now in the file, now compile it. - snprintf(buffer, sizeof(buffer), "Downloaded, now compiling '%s'.", data->mScriptName.c_str()); /* Flawfinder: ignore */ + buffer = std::string("Downloaded, now compiling: ") + data->mScriptName; // *TODO: Translate queue->compile(filename, asset_id); // Delete it after we're done compiling? @@ -416,22 +414,19 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) { - LLChat chat("Script not found on server."); + LLChat chat(std::string("Script not found on server.")); // *TODO: Translate LLFloaterChat::addChat(chat); - snprintf(buffer, sizeof(buffer), "Problem downloading %s.", /* Flawfinder: ignore */ - data->mScriptName.c_str()); + buffer = std::string("Problem downloading: ") + data->mScriptName; // *TODO: Translate } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - LLChat chat("Insufficient permissions to download a script."); + LLChat chat(std::string("Insufficient permissions to download a script.")); // *TODO: Translate LLFloaterChat::addChat(chat); - snprintf(buffer, sizeof(buffer), "Insufficient permissions for '%s'.", /* Flawfinder: ignore */ - data->mScriptName.c_str()); + buffer = std::string("Insufficient permissions for: ") + data->mScriptName; // *TODO: Translate } else { - snprintf(buffer, sizeof(buffer), "Unknown failure to download %s.", /* Flawfinder: ignore */ - data->mScriptName.c_str()); + buffer = std::string("Unknown failure to download ") + data->mScriptName; // *TODO: Translate } llwarns << "Problem downloading script asset." << llendl; @@ -452,7 +447,7 @@ void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* use if (status) { llwarns << "Unable to save text for script." << llendl; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("CompileQueueSaveText", args); } @@ -474,7 +469,7 @@ void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* else { llwarns << "Unable to save bytecode for script." << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("CompileQueueSaveBytecode", args); } @@ -483,7 +478,7 @@ void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* } // compile the file given and save it out. -void LLFloaterCompileQueue::compile(const char* filename, +void LLFloaterCompileQueue::compile(const std::string& filename, const LLUUID& asset_id) { LLUUID new_asset_id; @@ -491,17 +486,17 @@ void LLFloaterCompileQueue::compile(const char* filename, tid.generate(); new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - char uuid_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string uuid_string; new_asset_id.toString(uuid_string); - char dst_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ - snprintf(dst_filename, sizeof(dst_filename), "%s.lso", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */ - char err_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ - snprintf(err_filename, sizeof(err_filename), "%s.out", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */ + std::string dst_filename; + dst_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".lso"; + std::string err_filename; + err_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".out"; gAssetStorage->storeAssetData(filename, tid, LLAssetType::AT_LSL_TEXT, &onSaveTextComplete, NULL, FALSE); - if(!lscript_compile(filename, dst_filename, err_filename, gAgent.isGodlike())) + if(!lscript_compile(filename.c_str(), dst_filename.c_str(), err_filename.c_str(), gAgent.isGodlike())) { llwarns << "compile failed" << llendl; removeItemByAssetID(asset_id); @@ -586,8 +581,7 @@ LLFloaterResetQueue* LLFloaterResetQueue::create() gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("CompileOutputRect"); rect.translate(left - rect.mLeft, top - rect.mTop); - LLFloaterResetQueue* new_queue = new LLFloaterResetQueue("queue", - rect); + LLFloaterResetQueue* new_queue = new LLFloaterResetQueue("queue", rect); new_queue->open(); /*Flawfinder: ignore*/ return new_queue; } @@ -619,8 +613,8 @@ void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj, { LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(buffer, sizeof(buffer), "Resetting '%s'.", item->getName().c_str()); /* Flawfinder: ignore */ + std::string buffer; + buffer = std::string("Resetting: ") + item->getName(); // *TODO: Translate list->addCommentText(buffer); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ScriptReset); @@ -649,8 +643,7 @@ LLFloaterRunQueue* LLFloaterRunQueue::create() gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("CompileOutputRect"); rect.translate(left - rect.mLeft, top - rect.mTop); - LLFloaterRunQueue* new_queue = new LLFloaterRunQueue("queue", - rect); + LLFloaterRunQueue* new_queue = new LLFloaterRunQueue("queue", rect); new_queue->open(); /*Flawfinder: ignore*/ return new_queue; } @@ -682,8 +675,8 @@ void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj, { LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(buffer, sizeof(buffer), "Running '%s'.", item->getName().c_str()); /* Flawfinder: ignore */ + std::string buffer; + buffer = std::string("Running: ") + item->getName(); // *TODO: Translate list->addCommentText(buffer); LLMessageSystem* msg = gMessageSystem; @@ -714,8 +707,7 @@ LLFloaterNotRunQueue* LLFloaterNotRunQueue::create() gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect = gSavedSettings.getRect("CompileOutputRect"); rect.translate(left - rect.mLeft, top - rect.mTop); - LLFloaterNotRunQueue* new_queue = new LLFloaterNotRunQueue("queue", - rect); + LLFloaterNotRunQueue* new_queue = new LLFloaterNotRunQueue("queue", rect); new_queue->open(); /*Flawfinder: ignore*/ return new_queue; } @@ -747,8 +739,8 @@ void LLFloaterNotRunQueue::handleInventory(LLViewerObject* viewer_obj, { LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it)); LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(buffer, sizeof(buffer), "Not running '%s'.", item->getName().c_str()); /* Flawfinder: ignore */ + std::string buffer; + buffer = std::string("Not running: ") +item->getName(); // *TODO: Translate list->addCommentText(buffer); LLMessageSystem* msg = gMessageSystem; diff --git a/indra/newview/llcompilequeue.h b/indra/newview/llcompilequeue.h index ca5589f902..be7bbd5ceb 100644 --- a/indra/newview/llcompilequeue.h +++ b/indra/newview/llcompilequeue.h @@ -66,7 +66,7 @@ public: protected: LLFloaterScriptQueue(const std::string& name, const LLRect& rect, - const char* title, const char* start_string); + const std::string& title, const std::string& start_string); virtual ~LLFloaterScriptQueue(); // This is the callback method for the viewer object currently @@ -109,7 +109,7 @@ protected: LLUUID mID; static LLMap<LLUUID, LLFloaterScriptQueue*> sInstances; - const char* mStartString; + std::string mStartString; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -144,7 +144,7 @@ protected: S32 status, LLExtStat ext_status); // compile the file given and save it out. - void compile(const char* filename, const LLUUID& asset_id); + void compile(const std::string& filename, const LLUUID& asset_id); // remove any object in mScriptScripts with the matching uuid. void removeItemByAssetID(const LLUUID& asset_id); diff --git a/indra/newview/llconfirmationmanager.cpp b/indra/newview/llconfirmationmanager.cpp index 1c62b70b4c..167afb8062 100644 --- a/indra/newview/llconfirmationmanager.cpp +++ b/indra/newview/llconfirmationmanager.cpp @@ -59,7 +59,7 @@ static void onConfirmAlert(S32 option, void* data) } static void onConfirmAlertPassword( - S32 option, const LLString& text, void* data) + S32 option, const std::string& text, void* data) { LLConfirmationManager::ListenerBase* listener = (LLConfirmationManager::ListenerBase*)data; @@ -77,7 +77,7 @@ void LLConfirmationManager::confirm(Type type, const std::string& action, ListenerBase* listener) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[ACTION]"] = action; switch (type) @@ -91,7 +91,7 @@ void LLConfirmationManager::confirm(Type type, gViewerWindow->alertXmlEditText("ConfirmPurchasePassword", args, NULL, NULL, onConfirmAlertPassword, listener, - LLString::format_map_t(), + LLStringUtil::format_map_t(), TRUE); break; case TYPE_NONE: diff --git a/indra/newview/llcurrencyuimanager.cpp b/indra/newview/llcurrencyuimanager.cpp index c32bf7c268..ab7990b170 100644 --- a/indra/newview/llcurrencyuimanager.cpp +++ b/indra/newview/llcurrencyuimanager.cpp @@ -381,7 +381,7 @@ void LLCurrencyUIManager::Impl::updateUI() { if (!mZeroMessage.empty() && mUserCurrencyBuy == 0) { - lindenAmount->setText(LLString::null); + lindenAmount->setText(LLStringUtil::null); } else { @@ -467,7 +467,7 @@ bool LLCurrencyUIManager::process() return changed; } -void LLCurrencyUIManager::buy(const LLString& buy_msg) +void LLCurrencyUIManager::buy(const std::string& buy_msg) { if (!canBuy()) { diff --git a/indra/newview/llcurrencyuimanager.h b/indra/newview/llcurrencyuimanager.h index bb135d0189..5f5845af9b 100644 --- a/indra/newview/llcurrencyuimanager.h +++ b/indra/newview/llcurrencyuimanager.h @@ -71,7 +71,7 @@ public: // call periodically, for example, from draw() // returns true if the UI needs to be updated - void buy(const LLString& buy_msg); + void buy(const std::string& buy_msg); // call to initiate the purchase bool inProcess(); // is a transaction in process diff --git a/indra/newview/lldebugmessagebox.cpp b/indra/newview/lldebugmessagebox.cpp index 371426d56e..9fa2c76bbf 100644 --- a/indra/newview/lldebugmessagebox.cpp +++ b/indra/newview/lldebugmessagebox.cpp @@ -46,34 +46,34 @@ /// Class LLDebugVarMessageBox ///---------------------------------------------------------------------------- -std::map<LLString, LLDebugVarMessageBox*> LLDebugVarMessageBox::sInstances; +std::map<std::string, LLDebugVarMessageBox*> LLDebugVarMessageBox::sInstances; LLDebugVarMessageBox::LLDebugVarMessageBox(const std::string& title, EDebugVarType var_type, void *var) : - LLFloater("msg box", LLRect(10,160,400,10), title), + LLFloater(std::string("msg box"), LLRect(10,160,400,10), title), mVarType(var_type), mVarData(var), mAnimate(FALSE) { switch(var_type) { case VAR_TYPE_F32: - mSlider1 = new LLSliderCtrl("slider 1", LLRect(20,130,190,110), title, NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, *((F32*)var), -100.f, 100.f, 0.1f, NULL); + mSlider1 = new LLSliderCtrl(std::string("slider 1"), LLRect(20,130,190,110), title, NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, *((F32*)var), -100.f, 100.f, 0.1f, LLStringUtil::null); mSlider1->setPrecision(3); addChild(mSlider1); mSlider2 = NULL; mSlider3 = NULL; break; case VAR_TYPE_S32: - mSlider1 = new LLSliderCtrl("slider 1", LLRect(20,100,190,80), title, NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, (F32)*((S32*)var), -255.f, 255.f, 1.f, NULL); + mSlider1 = new LLSliderCtrl(std::string("slider 1"), LLRect(20,100,190,80), title, NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, (F32)*((S32*)var), -255.f, 255.f, 1.f, LLStringUtil::null); mSlider1->setPrecision(0); addChild(mSlider1); mSlider2 = NULL; mSlider3 = NULL; break; case VAR_TYPE_VEC3: - mSlider1 = new LLSliderCtrl("slider 1", LLRect(20,130,190,110), "x: ", NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, ((LLVector3*)var)->mV[VX], -100.f, 100.f, 0.1f, NULL); + mSlider1 = new LLSliderCtrl(std::string("slider 1"), LLRect(20,130,190,110), std::string("x: "), NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, ((LLVector3*)var)->mV[VX], -100.f, 100.f, 0.1f, LLStringUtil::null); mSlider1->setPrecision(3); - mSlider2 = new LLSliderCtrl("slider 2", LLRect(20,100,190,80), "y: ", NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, ((LLVector3*)var)->mV[VY], -100.f, 100.f, 0.1f, NULL); + mSlider2 = new LLSliderCtrl(std::string("slider 2"), LLRect(20,100,190,80), std::string("y: "), NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, ((LLVector3*)var)->mV[VY], -100.f, 100.f, 0.1f, LLStringUtil::null); mSlider2->setPrecision(3); - mSlider3 = new LLSliderCtrl("slider 3", LLRect(20,70,190,50), "z: ", NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, ((LLVector3*)var)->mV[VZ], -100.f, 100.f, 0.1f, NULL); + mSlider3 = new LLSliderCtrl(std::string("slider 3"), LLRect(20,70,190,50), std::string("z: "), NULL, 70, 130, TRUE, TRUE, FALSE, NULL, NULL, ((LLVector3*)var)->mV[VZ], -100.f, 100.f, 0.1f, LLStringUtil::null); mSlider3->setPrecision(3); addChild(mSlider1); addChild(mSlider2); @@ -84,10 +84,10 @@ LLDebugVarMessageBox::LLDebugVarMessageBox(const std::string& title, EDebugVarTy break; } - mAnimateButton = new LLButton("Animate", LLRect(20, 45, 180, 25), "", onAnimateClicked, this); + mAnimateButton = new LLButton(std::string("Animate"), LLRect(20, 45, 180, 25), LLStringUtil::null, onAnimateClicked, this); addChild(mAnimateButton); - mText = new LLTextBox("value", LLRect(20,20,190,0)); + mText = new LLTextBox(std::string("value"), LLRect(20,20,190,0)); addChild(mText); //disable hitting enter closes dialog @@ -160,7 +160,7 @@ void LLDebugVarMessageBox::show(const std::string& title, LLVector3 *var, LLVect LLDebugVarMessageBox* LLDebugVarMessageBox::show(const std::string& title, EDebugVarType var_type, void *var) { - LLString title_string(title); + std::string title_string(title); LLDebugVarMessageBox *box = sInstances[title_string]; if (!box) @@ -217,7 +217,7 @@ void LLDebugVarMessageBox::onClose(bool app_quitting) void LLDebugVarMessageBox::draw() { - LLString text; + std::string text; switch(mVarType) { case VAR_TYPE_F32: diff --git a/indra/newview/lldebugmessagebox.h b/indra/newview/lldebugmessagebox.h index d90d7b1a5f..5e89c6614d 100644 --- a/indra/newview/lldebugmessagebox.h +++ b/indra/newview/lldebugmessagebox.h @@ -86,10 +86,10 @@ protected: LLSliderCtrl* mSlider3; LLButton* mAnimateButton; LLTextBox* mText; - LLString mTitle; + std::string mTitle; BOOL mAnimate; - static std::map<LLString, LLDebugVarMessageBox*> sInstances; + static std::map<std::string, LLDebugVarMessageBox*> sInstances; }; #endif // LL_LLMESSAGEBOX_H diff --git a/indra/newview/lldelayedgestureerror.cpp b/indra/newview/lldelayedgestureerror.cpp index aaa49b831d..832b1b9130 100644 --- a/indra/newview/lldelayedgestureerror.cpp +++ b/indra/newview/lldelayedgestureerror.cpp @@ -98,7 +98,7 @@ void LLDelayedGestureError::onIdle(void *userdata) //static bool LLDelayedGestureError::doDialog(const LLErrorEntry &ent, bool uuid_ok) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; LLInventoryItem *item = gInventory.getItem( ent.mItemID ); if ( item ) @@ -109,7 +109,7 @@ bool LLDelayedGestureError::doDialog(const LLErrorEntry &ent, bool uuid_ok) { if ( uuid_ok || ent.mTimer.getElapsedTimeF32() > MAX_NAME_WAIT_TIME ) { - args["[NAME]"] = LLString( ent.mItemID.asString() ); + args["[NAME]"] = std::string( ent.mItemID.asString() ); } else { diff --git a/indra/newview/lldelayedgestureerror.h b/indra/newview/lldelayedgestureerror.h index 8430a9b848..090940b7c2 100644 --- a/indra/newview/lldelayedgestureerror.h +++ b/indra/newview/lldelayedgestureerror.h @@ -61,10 +61,10 @@ private: struct LLErrorEntry { - LLErrorEntry(const LLString& notify, const LLUUID &item) : mTimer(), mNotifyName(notify), mItemID(item) {} + LLErrorEntry(const std::string& notify, const LLUUID &item) : mTimer(), mNotifyName(notify), mItemID(item) {} LLTimer mTimer; - LLString mNotifyName; + std::string mNotifyName; LLUUID mItemID; }; diff --git a/indra/newview/lldirpicker.cpp b/indra/newview/lldirpicker.cpp index 367293929d..bf4a9bb8d4 100644 --- a/indra/newview/lldirpicker.cpp +++ b/indra/newview/lldirpicker.cpp @@ -67,7 +67,7 @@ LLDirPicker::~LLDirPicker() // nothing } -BOOL LLDirPicker::getDir(LLString* filename) +BOOL LLDirPicker::getDir(std::string* filename) { if( mLocked ) { @@ -114,7 +114,7 @@ BOOL LLDirPicker::getDir(LLString* filename) return success; } -LLString LLDirPicker::getDirName() +std::string LLDirPicker::getDirName() { return mDir; } @@ -225,7 +225,7 @@ OSStatus LLDirPicker::doNavChooseDialog() return error; } -BOOL LLDirPicker::getDir(LLString* filename) +BOOL LLDirPicker::getDir(std::string* filename) { if( mLocked ) return FALSE; BOOL success = FALSE; @@ -252,7 +252,7 @@ BOOL LLDirPicker::getDir(LLString* filename) return success; } -LLString LLDirPicker::getDirName() +std::string LLDirPicker::getDirName() { return mDir; } @@ -260,7 +260,7 @@ LLString LLDirPicker::getDirName() void LLDirPicker::reset() { mLocked = FALSE; - mDir = NULL; + mDir.clear(); } #elif LL_LINUX @@ -283,7 +283,7 @@ void LLDirPicker::reset() mFilePicker->reset(); } -BOOL LLDirPicker::getDir(LLString* filename) +BOOL LLDirPicker::getDir(std::string* filename) { reset(); if (mFilePicker) @@ -296,19 +296,17 @@ BOOL LLDirPicker::getDir(LLString* filename) gtk_window_set_title(GTK_WINDOW(picker), "Choose Directory"); gtk_widget_show_all(GTK_WIDGET(picker)); gtk_main(); - return (NULL != mFilePicker->getFirstFile()); + return (!mFilePicker->getFirstFile().empty()); } } return FALSE; } -LLString LLDirPicker::getDirName() +std::string LLDirPicker::getDirName() { if (mFilePicker) { - const char* name = mFilePicker->getFirstFile(); - if (name) - return name; + return mFilePicker->getFirstFile(); } return ""; } @@ -329,12 +327,12 @@ void LLDirPicker::reset() { } -BOOL LLDirPicker::getDir(LLString* filename) +BOOL LLDirPicker::getDir(std::string* filename) { return FALSE; } -LLString LLDirPicker::getDirName() +std::string LLDirPicker::getDirName() { return ""; } diff --git a/indra/newview/lldirpicker.h b/indra/newview/lldirpicker.h index 0bfb3620c9..d133a947e1 100644 --- a/indra/newview/lldirpicker.h +++ b/indra/newview/lldirpicker.h @@ -64,8 +64,8 @@ public: // calling this before main() is undefined static LLDirPicker& instance( void ) { return sInstance; } - BOOL getDir(LLString* filename); - LLString getDirName(); + BOOL getDir(std::string* filename); + std::string getDirName(); // clear any lists of buffers or whatever, and make sure the dir // picker isn't locked. @@ -94,9 +94,8 @@ private: LLFilePicker *mFilePicker; #endif - char mDirs[DIRNAME_BUFFER_SIZE]; /*Flawfinder: ignore*/ - LLString* mFileName; - LLString mDir; + std::string* mFileName; + std::string mDir; BOOL mLocked; static LLDirPicker sInstance; diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 1dfaf6569e..1784fccf1f 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -100,7 +100,7 @@ void LLStandardBumpmap::restoreGL() gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness"); // BE_DARKNESS std::string file_name = gDirUtilp->getExpandedFilename( LL_PATH_APP_SETTINGS, "std_bump.ini" ); - LLFILE* file = LLFile::fopen( file_name.c_str(), "rt" ); /*Flawfinder: ignore*/ + LLFILE* file = LLFile::fopen( file_name, "rt" ); /*Flawfinder: ignore*/ if( !file ) { llwarns << "Could not open std_bump <" << file_name << ">" << llendl; diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index ae722b2fd3..d0c9b258f3 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -96,9 +96,9 @@ class LLStandardBumpmap { public: LLStandardBumpmap() : mLabel() {} - LLStandardBumpmap( const char* label ) : mLabel(label) {} + LLStandardBumpmap( const std::string& label ) : mLabel(label) {} - LLString mLabel; + std::string mLabel; LLPointer<LLViewerImage> mImage; static U32 sStandardBumpmapCount; // Number of valid values in gStandardBumpmapList[] diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 09a87f2402..ea3999f93f 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -55,7 +55,7 @@ LLPointer<LLImageRaw> LLDrawPoolWLSky::sCloudNoiseRawImage = NULL; LLDrawPoolWLSky::LLDrawPoolWLSky(void) : LLDrawPool(POOL_WL_SKY) { - const LLString cloudNoiseFilename(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", "clouds2.tga")); + const std::string cloudNoiseFilename(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", "clouds2.tga")); llinfos << "loading WindLight cloud noise from " << cloudNoiseFilename << llendl; LLPointer<LLImageFormatted> cloudNoiseFile(LLImageFormatted::createFromExtension(cloudNoiseFilename)); diff --git a/indra/newview/llemote.h b/indra/newview/llemote.h index 785c9df753..5f1e091fa1 100644 --- a/indra/newview/llemote.h +++ b/indra/newview/llemote.h @@ -113,8 +113,6 @@ public: virtual BOOL canDeprecate() { return FALSE; } - static BOOL getIndexFromName( const char* name, U32* index ); - protected: LLCharacter* mCharacter; diff --git a/indra/newview/lleventinfo.cpp b/indra/newview/lleventinfo.cpp index 91401a048b..a3cb925a46 100644 --- a/indra/newview/lleventinfo.cpp +++ b/indra/newview/lleventinfo.cpp @@ -38,54 +38,17 @@ LLEventInfo::cat_map LLEventInfo::sCategories; -LLEventInfo::LLEventInfo(F32 global_x, F32 global_y, - const char* name, - U32 id, - time_t unix_time, - U32 event_flags) -: mName( name ), - mID( id ), - mPosGlobal( global_x, global_y, 40.0 ), - mUnixTime( unix_time ), - mEventFlags(event_flags), - mSelected( FALSE ) -{ - struct tm* timep; - // Convert to Pacific, based on server's opinion of whether - // it's daylight savings time there. - timep = utc_to_pacific_time(unix_time, gPacificDaylightTime); - - S32 display_hour = timep->tm_hour % 12; - if (display_hour == 0) display_hour = 12; - - mTimeStr = llformat("% 2d/% 2d % 2d:%02d %s", - timep->tm_mon+1, - timep->tm_year-100, - display_hour, - timep->tm_min, - (timep->tm_hour < 12 ? "AM" : "PM") ); -} - - void LLEventInfo::unpack(LLMessageSystem *msg) { - const U32 MAX_DESC_LENGTH = 1024; - U32 event_id; msg->getU32("EventData", "EventID", event_id); mID = event_id; - char buffer[MAX_DESC_LENGTH]; /*Flawfinder: ignore*/ - msg->getString("EventData", "Name", MAX_DESC_LENGTH, buffer); - mName = buffer; + msg->getString("EventData", "Name", mName); - msg->getString("EventData", "Category", MAX_DESC_LENGTH, buffer); - mCategoryStr = buffer; + msg->getString("EventData", "Category", mCategoryStr); - msg->getString("EventData", "Date", MAX_DESC_LENGTH, buffer); - // *FIX: evil hack to let users know that we don't localize - // time information. Hack! This is WRONG. - mTimeStr = buffer; + msg->getString("EventData", "Date", mTimeStr); U32 duration; msg->getU32("EventData","Duration",duration); @@ -95,10 +58,10 @@ void LLEventInfo::unpack(LLMessageSystem *msg) msg->getU32("EventData", "DateUTC", date); mUnixTime = date; - msg->getString("EventData", "Desc", MAX_DESC_LENGTH, buffer); - mDesc = buffer; + msg->getString("EventData", "Desc", mDesc); - msg->getString("EventData", "Creator", MAX_DESC_LENGTH, buffer); + std::string buffer; + msg->getString("EventData", "Creator", buffer); mRunByID = LLUUID(buffer); U32 foo; @@ -112,9 +75,7 @@ void LLEventInfo::unpack(LLMessageSystem *msg) mCover = cover; } - char sim_name[256]; /*Flawfinder: ignore*/ - msg->getString("EventData", "SimName", 256, sim_name); - mSimName.assign(sim_name); + msg->getString("EventData", "SimName", mSimName); msg->getVector3d("EventData", "GlobalPos", mPosGlobal); diff --git a/indra/newview/lleventinfo.h b/indra/newview/lleventinfo.h index 4d0687f81c..8a33a191e1 100644 --- a/indra/newview/lleventinfo.h +++ b/indra/newview/lleventinfo.h @@ -44,7 +44,6 @@ class LLEventInfo { public: LLEventInfo() {} - LLEventInfo(F32 global_x, F32 global_y, const char* name, U32 id, time_t unix_time, U32 event_flags); void unpack(LLMessageSystem *msg); @@ -58,7 +57,7 @@ public: U32 mDuration; std::string mTimeStr; LLUUID mRunByID; - LLString mSimName; + std::string mSimName; LLVector3d mPosGlobal; time_t mUnixTime; // seconds from 1970 BOOL mHasCover; diff --git a/indra/newview/lleventnotifier.cpp b/indra/newview/lleventnotifier.cpp index 3d2bbcd1f5..343a572a6a 100644 --- a/indra/newview/lleventnotifier.cpp +++ b/indra/newview/lleventnotifier.cpp @@ -77,7 +77,7 @@ void LLEventNotifier::update() if (np->getEventDate() < (alert_time)) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = np->getEventName(); args["[DATE]"] = np->getEventDateStr(); LLNotifyBox::showXml("EventNotification", args, diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index ad89d8220f..e224ee57c0 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -208,7 +208,7 @@ static const int FTV_DISPLAY_NUM = (sizeof(ft_display_table)/sizeof(ft_display_ S32 ft_display_idx[FTV_DISPLAY_NUM]; // line of table entry for display purposes (for collapse) LLFastTimerView::LLFastTimerView(const std::string& name, const LLRect& rect) - : LLFloater(name, rect, "Fast Timers") + : LLFloater(name, rect, std::string("Fast Timers")) { setVisible(FALSE); mDisplayMode = 0; @@ -499,7 +499,7 @@ void LLFastTimerView::draw() LLFontGL::sMonospace->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); y -= (texth + 2); - LLFontGL::sMonospace->renderUTF8("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]", + LLFontGL::sMonospace->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"), 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); y -= (texth + 2); } @@ -632,7 +632,7 @@ void LLFastTimerView::draw() } y -= (texth + 2); - textw = dx + LLFontGL::sMonospace->getWidth(ft_display_table[i].desc) + 40; + textw = dx + LLFontGL::sMonospace->getWidth(std::string(ft_display_table[i].desc)) + 40; if (textw > legendwidth) legendwidth = textw; } @@ -946,11 +946,13 @@ void LLFastTimerView::draw() F32 ms = (F32)((F64)max_ticks * iclock_freq); //display y-axis range - LLString tdesc = mDisplayCalls ? - llformat("%d calls", max_ticks) : - mDisplayHz ? - llformat("%d Hz", max_ticks) : - llformat("%4.2f ms", ms); + std::string tdesc; + if (mDisplayCalls) + tdesc = llformat("%d calls", (int)max_ticks); + else if (mDisplayHz) + tdesc = llformat("%d Hz", (int)max_ticks); + else + tdesc = llformat("%4.2f ms", ms); x = graph_rect.mRight - LLFontGL::sMonospace->getWidth(tdesc)-5; y = graph_rect.mTop - ((S32)LLFontGL::sMonospace->getLineHeight()); @@ -1063,7 +1065,7 @@ void LLFastTimerView::draw() x = (graph_rect.mRight + graph_rect.mLeft)/2; y = graph_rect.mBottom + 8; - LLFontGL::sMonospace->renderUTF8(ft_display_table[mHoverIndex].desc, 0, x, y, LLColor4::white, + LLFontGL::sMonospace->renderUTF8(std::string(ft_display_table[mHoverIndex].desc), 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM); } } @@ -1072,7 +1074,7 @@ void LLFastTimerView::draw() // Output stats for clicked bar to log if (mPrintStats >= 0) { - LLString legend_stat; + std::string legend_stat; S32 stat_num; S32 first = 1; for (stat_num = 0; stat_num < FTV_DISPLAY_NUM; stat_num++) @@ -1086,7 +1088,7 @@ void LLFastTimerView::draw() } llinfos << legend_stat << llendl; - LLString timer_stat; + std::string timer_stat; first = 1; for (stat_num = 0; stat_num < FTV_DISPLAY_NUM; stat_num++) { diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index c24b4c13d9..73d8036122 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -75,23 +75,21 @@ const char FEATURE_TABLE_FILENAME[] = "featuretable.txt"; const char GPU_TABLE_FILENAME[] = "gpu_table.txt"; -LLFeatureInfo::LLFeatureInfo(const char *name, const BOOL available, const F32 level) : mValid(TRUE) +LLFeatureInfo::LLFeatureInfo(const std::string& name, const BOOL available, const F32 level) + : mValid(TRUE), mName(name), mAvailable(available), mRecommendedLevel(level) { - mName = name; - mAvailable = available; - mRecommendedLevel = level; } -LLFeatureList::LLFeatureList(const char *name) +LLFeatureList::LLFeatureList(const std::string& name) + : mName(name) { - mName = name; } LLFeatureList::~LLFeatureList() { } -void LLFeatureList::addFeature(const char *name, const BOOL available, const F32 level) +void LLFeatureList::addFeature(const std::string& name, const BOOL available, const F32 level) { if (mFeatures.count(name)) { @@ -102,7 +100,7 @@ void LLFeatureList::addFeature(const char *name, const BOOL available, const F32 mFeatures[name] = fi; } -BOOL LLFeatureList::isFeatureAvailable(const char *name) +BOOL LLFeatureList::isFeatureAvailable(const std::string& name) { if (mFeatures.count(name)) { @@ -116,7 +114,7 @@ BOOL LLFeatureList::isFeatureAvailable(const char *name) return TRUE; } -F32 LLFeatureList::getRecommendedValue(const char *name) +F32 LLFeatureList::getRecommendedValue(const std::string& name) { if (mFeatures.count(name) && isFeatureAvailable(name)) { @@ -188,7 +186,7 @@ void LLFeatureList::dump() LL_DEBUGS("RenderInit") << LL_ENDL; } -LLFeatureList *LLFeatureManager::findMask(const char *name) +LLFeatureList *LLFeatureManager::findMask(const std::string& name) { if (mMaskList.count(name)) { @@ -198,7 +196,7 @@ LLFeatureList *LLFeatureManager::findMask(const char *name) return NULL; } -BOOL LLFeatureManager::maskFeatures(const char *name) +BOOL LLFeatureManager::maskFeatures(const std::string& name) { LLFeatureList *maskp = findMask(name); if (!maskp) @@ -227,12 +225,11 @@ BOOL LLFeatureManager::loadFeatureTables() data_path += FEATURE_TABLE_FILENAME; lldebugs << "Looking for feature table in " << data_path << llendl; - char name[MAX_STRING+1]; /*Flawfinder: ignore*/ - llifstream file; + std::string name; U32 version; - file.open(data_path.c_str()); /*Flawfinder: ignore*/ + file.open(data_path); /*Flawfinder: ignore*/ if (!file) { @@ -243,7 +240,7 @@ BOOL LLFeatureManager::loadFeatureTables() // Check file version file >> name; file >> version; - if (strcmp(name, "version")) + if (name != "version") { LL_WARNS("RenderInit") << data_path << " does not appear to be a valid feature table!" << LL_ENDL; return FALSE; @@ -255,27 +252,24 @@ BOOL LLFeatureManager::loadFeatureTables() while (!file.eof() && file.good()) { char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - name[0] = 0; file >> name; - if (strlen(name) >= 2 && /*Flawfinder: ignore*/ - name[0] == '/' && - name[1] == '/') + if (name.substr(0,2) == "//") { // This is a comment. file.getline(buffer, MAX_STRING); continue; } - if (strlen(name) == 0) /*Flawfinder: ignore*/ + if (name.empty()) { // This is a blank line file.getline(buffer, MAX_STRING); continue; } - if (!strcmp(name, "list")) + if (name == "list") { if (flp) { @@ -323,7 +317,7 @@ void LLFeatureManager::loadGPUClass() llifstream file; - file.open(data_path.c_str()); /*Flawfinder: ignore*/ + file.open(data_path); /*Flawfinder: ignore*/ if (!file) { @@ -491,19 +485,19 @@ void LLFeatureManager::applyFeatures(bool skipFeatures) // handle all the different types if(ctrl->isType(TYPE_BOOLEAN)) { - gSavedSettings.setBOOL(mIt->first, (BOOL)getRecommendedValue(mIt->first.c_str())); + gSavedSettings.setBOOL(mIt->first, (BOOL)getRecommendedValue(mIt->first)); } else if (ctrl->isType(TYPE_S32)) { - gSavedSettings.setS32(mIt->first, (S32)getRecommendedValue(mIt->first.c_str())); + gSavedSettings.setS32(mIt->first, (S32)getRecommendedValue(mIt->first)); } else if (ctrl->isType(TYPE_U32)) { - gSavedSettings.setU32(mIt->first, (U32)getRecommendedValue(mIt->first.c_str())); + gSavedSettings.setU32(mIt->first, (U32)getRecommendedValue(mIt->first)); } else if (ctrl->isType(TYPE_F32)) { - gSavedSettings.setF32(mIt->first, (F32)getRecommendedValue(mIt->first.c_str())); + gSavedSettings.setF32(mIt->first, (F32)getRecommendedValue(mIt->first)); } else { @@ -618,7 +612,7 @@ void LLFeatureManager::applyBaseMasks() } //llinfos << "Masking features from gpu table match: " << gpustr << llendl; - maskFeatures(gpustr.c_str()); + maskFeatures(gpustr); // now mask cpu type ones if (gSysMemory.getPhysicalMemoryClamped() <= 256*1024*1024) diff --git a/indra/newview/llfeaturemanager.h b/indra/newview/llfeaturemanager.h index ffa8420697..e5bf73eb30 100644 --- a/indra/newview/llfeaturemanager.h +++ b/indra/newview/llfeaturemanager.h @@ -50,13 +50,13 @@ class LLFeatureInfo { public: LLFeatureInfo() : mValid(FALSE), mAvailable(FALSE), mRecommendedLevel(-1) {} - LLFeatureInfo(const char *name, const BOOL available, const F32 level); + LLFeatureInfo(const std::string& name, const BOOL available, const F32 level); BOOL isValid() const { return mValid; }; public: BOOL mValid; - LLString mName; + std::string mName; BOOL mAvailable; F32 mRecommendedLevel; }; @@ -65,22 +65,22 @@ public: class LLFeatureList { public: - typedef std::map<LLString, LLFeatureInfo> feature_map_t; + typedef std::map<std::string, LLFeatureInfo> feature_map_t; - LLFeatureList(const char *name = "default"); + LLFeatureList(const std::string& name); virtual ~LLFeatureList(); - BOOL isFeatureAvailable(const char *name); - F32 getRecommendedValue(const char *name); + BOOL isFeatureAvailable(const std::string& name); + F32 getRecommendedValue(const std::string& name); - void setFeatureAvailable(const char *name, const BOOL available); - void setRecommendedLevel(const char *name, const F32 level); + void setFeatureAvailable(const std::string& name, const BOOL available); + void setRecommendedLevel(const std::string& name, const F32 level); BOOL loadFeatureList(LLFILE *fp); BOOL maskList(LLFeatureList &mask); - void addFeature(const char *name, const BOOL available, const F32 level); + void addFeature(const std::string& name, const BOOL available, const F32 level); feature_map_t& getFeatures() { @@ -89,7 +89,7 @@ public: void dump(); protected: - LLString mName; + std::string mName; feature_map_t mFeatures; }; @@ -97,13 +97,16 @@ protected: class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManager> { public: - LLFeatureManager() : mInited(FALSE), mTableVersion(0), mSafe(FALSE), mGPUClass(GPU_CLASS_UNKNOWN) {} + LLFeatureManager() : + LLFeatureList("default"), mInited(FALSE), mTableVersion(0), mSafe(FALSE), mGPUClass(GPU_CLASS_UNKNOWN) + { + } ~LLFeatureManager() {cleanupFeatureTables();} // initialize this by loading feature table and gpu table void init(); - void maskCurrentList(const char *name); // Mask the current feature list with the named list + void maskCurrentList(const std::string& name); // Mask the current feature list with the named list BOOL loadFeatureTables(); @@ -117,8 +120,8 @@ public: void setSafe(const BOOL safe) { mSafe = safe; } BOOL isSafe() const { return mSafe; } - LLFeatureList *findMask(const char *name); - BOOL maskFeatures(const char *name); + LLFeatureList *findMask(const std::string& name); + BOOL maskFeatures(const std::string& name); // set the graphics to low, medium, high, or ultra. // skipFeatures forces skipping of mostly hardware settings @@ -138,8 +141,8 @@ protected: void initBaseMask(); - std::map<LLString, LLFeatureList *> mMaskList; - std::set<LLString> mSkippedFeatures; + std::map<std::string, LLFeatureList *> mMaskList; + std::set<std::string> mSkippedFeatures; BOOL mInited; S32 mTableVersion; BOOL mSafe; // Reinitialize everything to the "safe" mask diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index 4c387a3b6d..344917150f 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -63,12 +63,14 @@ LLFilePicker LLFilePicker::sInstance; // // Implementation // -#if LL_WINDOWS +LLFilePicker::LLFilePicker() + : mCurrentFile(0), + mLocked(FALSE) -LLFilePicker::LLFilePicker() { reset(); +#if LL_WINDOWS mOFN.lStructSize = sizeof(OPENFILENAMEW); mOFN.hwndOwner = NULL; // Set later mOFN.hInstance = NULL; @@ -87,6 +89,16 @@ LLFilePicker::LLFilePicker() mOFN.lCustData = 0L; mOFN.lpfnHook = NULL; mOFN.lpTemplateName = NULL; +#endif + +#if LL_DARWIN + memset(&mNavOptions, 0, sizeof(mNavOptions)); + OSStatus error = NavGetDefaultDialogCreationOptions(&mNavOptions); + if (error == noErr) + { + mNavOptions.modality = kWindowModalityAppModal; + } +#endif } LLFilePicker::~LLFilePicker() @@ -94,6 +106,48 @@ LLFilePicker::~LLFilePicker() // nothing } + +const std::string LLFilePicker::getFirstFile() +{ + mCurrentFile = 0; + return getNextFile(); +} + +const std::string LLFilePicker::getNextFile() +{ + if (mCurrentFile >= (S32)mFiles.size()) + { + mLocked = FALSE; + return std::string(); + } + else + { + return mFiles[mCurrentFile++]; + } +} + +const std::string LLFilePicker::getCurFile() +{ + if (mCurrentFile >= (S32)mFiles.size()) + { + mLocked = FALSE; + return std::string(); + } + else + { + return mFiles[mCurrentFile]; + } +} + +void LLFilePicker::reset() +{ + mLocked = FALSE; + mFiles.clear(); + mCurrentFile = 0; +} + +#if LL_WINDOWS + BOOL LLFilePicker::setupFilter(ELoadFilter filter) { BOOL res = TRUE; @@ -150,7 +204,6 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter) return FALSE; } BOOL success = FALSE; - mMultiFile = FALSE; // don't provide default file selection mFilesW[0] = '\0'; @@ -165,13 +218,15 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter) // Modal, so pause agent send_agent_pause(); + + reset(); + // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! success = GetOpenFileName(&mOFN); if (success) { - LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW)); - memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/ - mCurrentFile = mFiles; + std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); + mFiles.push_back(filename); } send_agent_resume(); @@ -187,7 +242,6 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) return FALSE; } BOOL success = FALSE; - mMultiFile = FALSE; // don't provide default file selection mFilesW[0] = '\0'; @@ -200,6 +254,8 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) OFN_EXPLORER | OFN_ALLOWMULTISELECT; setupFilter(filter); + + reset(); // Modal, so pause agent send_agent_pause(); @@ -212,31 +268,26 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) // lengths. if( wcslen(mOFN.lpstrFile) > mOFN.nFileOffset ) /*Flawfinder: ignore*/ { - mMultiFile = FALSE; - mCurrentFile = mFiles; - LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW)); - memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/ - - mCurrentFile = &mFiles[mOFN.nFileOffset]; + std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); + mFiles.push_back(filename); } else { - mMultiFile = TRUE; - mCurrentFile = 0; mLocked = TRUE; WCHAR* tptrw = mFilesW; - char* tptr = mFiles; - memset( mFiles, 0, FILENAME_BUFFER_SIZE ); + std::string dirname; while(1) { if (*tptrw == 0 && *(tptrw+1) == 0) // double '\0' break; - if (*tptrw == 0 && !mCurrentFile) - mCurrentFile = tptr+1; - S32 tlen16,tlen8; - tlen16 = utf16chars_to_utf8chars(tptrw, tptr, &tlen8); - tptrw += tlen16; - tptr += tlen8; + if (*tptrw == 0) + tptrw++; // shouldn't happen? + std::string filename = utf16str_to_utf8str(llutf16string(tptrw)); + if (dirname.empty()) + dirname = filename + "\\"; + else + mFiles.push_back(dirname + filename); + tptrw += filename.size(); } } } @@ -247,17 +298,16 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) return success; } -BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) +BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) { if( mLocked ) { return FALSE; } BOOL success = FALSE; - mMultiFile = FALSE; mOFN.lpstrFile = mFilesW; - if (filename) + if (!filename.empty()) { llutf16string tstring = utf8str_to_utf16str(filename); wcsncpy(mFilesW, tstring.c_str(), FILENAME_BUFFER_SIZE); } /*Flawfinder: ignore*/ @@ -278,7 +328,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) L"\0"; break; case FFSAVE_WAV: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.wav", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -288,7 +338,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) L"\0"; break; case FFSAVE_TGA: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.tga", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -298,7 +348,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) L"\0"; break; case FFSAVE_BMP: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.bmp", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -308,7 +358,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) L"\0"; break; case FFSAVE_AVI: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.avi", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -318,7 +368,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) L"\0"; break; case FFSAVE_ANIM: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.xaf", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -329,7 +379,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) break; #ifdef _CORY_TESTING case FFSAVE_GEOMETRY: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.slg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -340,7 +390,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) break; #endif case FFSAVE_XML: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.xml", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -351,7 +401,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) L"\0"; break; case FFSAVE_COLLADA: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.collada", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -361,7 +411,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) L"\0"; break; case FFSAVE_RAW: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.raw", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } @@ -370,7 +420,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) L"\0"; break; case FFSAVE_J2C: - if (!filename) + if (filename.empty()) { wcsncpy( mFilesW,L"untitled.j2c", FILENAME_BUFFER_SIZE); } @@ -387,6 +437,8 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) mOFN.nMaxFile = SINGLE_FILENAME_BUFFER_SIZE; mOFN.Flags = OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; + reset(); + // Modal, so pause agent send_agent_pause(); { @@ -394,9 +446,8 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) success = GetSaveFileName(&mOFN); if (success) { - LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW)); - memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/ - mCurrentFile = mFiles; + std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); + mFiles.push_back(filename); } gKeyboard->resetKeys(); } @@ -407,84 +458,8 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) return success; } -const char* LLFilePicker::getFirstFile() -{ - if(mMultiFile) - { - buildFilename(); - return mFilename; - } - return mFiles; -} - -const char* LLFilePicker::getNextFile() -{ - if(mMultiFile) - { - mCurrentFile += strlen(mCurrentFile) + 1; /*Flawfinder: ignore*/ - if( '\0' != mCurrentFile[0] ) - { - buildFilename(); - return mFilename; - } - else - { - mLocked = FALSE; - } - } - return NULL; -} - -const char* LLFilePicker::getDirname() -{ - if( '\0' != mCurrentFile[0] ) - { - return mCurrentFile; - } - return NULL; -} - -void LLFilePicker::reset() -{ - mLocked = FALSE; - memset( mFiles, 0, FILENAME_BUFFER_SIZE ); - memset( mFilename, 0, LL_MAX_PATH ); - mCurrentFile = mFiles; -} - -void LLFilePicker::buildFilename( void ) -{ - strncpy( mFilename, mFiles, LL_MAX_PATH ); - mFilename[LL_MAX_PATH-1] = '\0'; // stupid strncpy - S32 len = strlen( mFilename ); - - strncat(mFilename,gDirUtilp->getDirDelimiter().c_str(), sizeof(mFilename)-len+1); /*Flawfinder: ignore*/ - len += strlen(gDirUtilp->getDirDelimiter().c_str()); /*Flawfinder: ignore*/ - -// mFilename[len++] = '\\'; - LLString::copy( mFilename + len, mCurrentFile, LL_MAX_PATH - len ); -} - #elif LL_DARWIN -LLFilePicker::LLFilePicker() -{ - reset(); - - memset(&mNavOptions, 0, sizeof(mNavOptions)); - OSStatus error = NavGetDefaultDialogCreationOptions(&mNavOptions); - if (error == noErr) - { - mNavOptions.modality = kWindowModalityAppModal; - } - mFileIndex = 0; -} - -LLFilePicker::~LLFilePicker() -{ - // nothing -} - Boolean LLFilePicker::navOpenFilterProc(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode) { Boolean result = true; @@ -589,8 +564,6 @@ OSStatus LLFilePicker::doNavChooseDialog(ELoadFilter filter) NavReplyRecord navReply; memset(&navReply, 0, sizeof(navReply)); - mFiles[0] = '\0'; - mFileVector.clear(); // NOTE: we are passing the address of a local variable here. // This is fine, because the object this call creates will exist for less than the lifetime of this function. @@ -632,22 +605,20 @@ OSStatus LLFilePicker::doNavChooseDialog(ELoadFilter filter) error = FSRefMakePath(&fsRef, (UInt8*) path, sizeof(path)); if (error == noErr) - mFileVector.push_back(LLString(path)); + mFiles.push_back(std::string(path)); } } return error; } -OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const char* filename) +OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const std::string& filename) { OSStatus error = noErr; NavDialogRef navRef = NULL; NavReplyRecord navReply; memset(&navReply, 0, sizeof(navReply)); - mFiles[0] = '\0'; - mFileVector.clear(); // Setup the type, creator, and extension OSType type, creator; @@ -719,8 +690,8 @@ OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const char* filename) bool hasExtension = true; // Create a CFString of the initial file name - if (filename) - nameString = CFStringCreateWithCString(NULL, filename, kCFStringEncodingUTF8); + if (!filename.empty()) + nameString = CFStringCreateWithCString(NULL, filename.c_str(), kCFStringEncodingUTF8); else nameString = CFSTR("Untitled"); @@ -786,7 +757,7 @@ OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const char* filename) { if (CFStringGetCString(navReply.saveFileName, newFileName, sizeof(newFileName), kCFStringEncodingUTF8)) { - mFileVector.push_back(LLString(path) + LLString("/") + LLString(newFileName)); + mFiles.push_back(std::string(path) + "/" + std::string(newFileName)); } else { @@ -806,13 +777,15 @@ OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const char* filename) BOOL LLFilePicker::getOpenFile(ELoadFilter filter) { - if( mLocked ) return FALSE; - mMultiFile = FALSE; + if( mLocked ) + return FALSE; + BOOL success = FALSE; OSStatus error = noErr; - mFileVector.clear(); + reset(); + mNavOptions.optionFlags &= ~kNavAllowMultipleFiles; // Modal, so pause agent send_agent_pause(); @@ -822,7 +795,7 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter) send_agent_resume(); if (error == noErr) { - if (mFileVector.size()) + if (mFiles.size()) success = true; } @@ -833,13 +806,15 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter) BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) { - if( mLocked ) return FALSE; - mMultiFile = TRUE; + if( mLocked ) + return FALSE; + BOOL success = FALSE; OSStatus error = noErr; + + reset(); - mFileVector.clear(); mNavOptions.optionFlags |= kNavAllowMultipleFiles; // Modal, so pause agent send_agent_pause(); @@ -849,9 +824,9 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) send_agent_resume(); if (error == noErr) { - if (mFileVector.size()) + if (mFiles.size()) success = true; - if (mFileVector.size() > 1) + if (mFiles.size() > 1) mLocked = TRUE; } @@ -860,38 +835,15 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) return success; } -void LLFilePicker::getFilePath(SInt32 index) -{ - mFiles[0] = 0; - if (mFileVector.size()) - { - strncpy(mFiles, mFileVector[index].c_str(), sizeof(mFiles)); - mFiles[sizeof(mFiles)-1] = '\0'; // stupid strncpy - } -} - -void LLFilePicker::getFileName(SInt32 index) +BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) { - mFilename[0] = 0; - if (mFileVector.size()) - { - char *start = strrchr(mFileVector[index].c_str(), '/'); - if (start && ((start + 1 - mFileVector[index].c_str()) < (mFileVector[index].size()))) - { - strncpy(mFilename, start + 1, sizeof(mFilename)); - mFilename[sizeof(mFilename)-1] = '\0';// stupid strncpy - } - } -} - -BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) -{ - if( mLocked ) return FALSE; + if( mLocked ) + return FALSE; BOOL success = FALSE; OSStatus error = noErr; - mFileVector.clear(); - mMultiFile = FALSE; + reset(); + mNavOptions.optionFlags &= ~kNavAllowMultipleFiles; // Modal, so pause agent @@ -902,7 +854,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) send_agent_resume(); if (error == noErr) { - if (mFileVector.size()) + if (mFiles.size()) success = true; } @@ -911,98 +863,38 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename) return success; } -const char* LLFilePicker::getFirstFile() -{ - mFileIndex = 0; - getFilePath(mFileIndex); - return mFiles; -} - -const char* LLFilePicker::getNextFile() -{ - if(mMultiFile) - { - mFileIndex++; - if (mFileIndex < mFileVector.size()) - { - getFilePath(mFileIndex); - return mFiles; - } - else - { - mLocked = FALSE; - } - } - return NULL; -} - -const char* LLFilePicker::getDirname() -{ - if (mFileIndex < mFileVector.size()) - { - getFileName(mFileIndex); - return mFilename; - } - return NULL; -} - -void LLFilePicker::reset() -{ - mLocked = FALSE; - memset( mFiles, 0, FILENAME_BUFFER_SIZE ); - memset( mFilename, 0, LL_MAX_PATH ); - mCurrentFile = mFiles; - - mFileIndex = 0; - mFileVector.clear(); -} - #elif LL_LINUX # if LL_GTK -// This caches the previously-accessed path for a given context of the file -// chooser, for user convenience. -std::map <std::string, std::string> LLFilePicker::sContextToPathMap; -LLFilePicker::LLFilePicker() +// static +void LLFilePicker::add_to_selectedfiles(gpointer data, gpointer user_data) { - reset(); -} - -LLFilePicker::~LLFilePicker() -{ -} - - -static void add_to_sfs(gpointer data, gpointer user_data) -{ - StoreFilenamesStruct *sfs = (StoreFilenamesStruct*) user_data; + LLFilePicker* picker = (LLFilePicker*) user_data; gchar* filename_utf8 = g_filename_to_utf8((gchar*)data, - -1, NULL, - NULL, - NULL); - sfs->fileVector.push_back(LLString(filename_utf8)); + -1, NULL, NULL, NULL); + picker->mFiles.push_back(std::string(filename_utf8)); + lldebugs << "ADDED FILE " << filename_utf8 << llendl; g_free(filename_utf8); } - -void chooser_responder(GtkWidget *widget, - gint response, - gpointer user_data) { - StoreFilenamesStruct *sfs = (StoreFilenamesStruct*) user_data; +// static +void LLFilePicker::chooser_responder(GtkWidget *widget, gint response, gpointer user_data) +{ + LLFilePicker* picker = (LLFilePicker*)user_data; lldebugs << "GTK DIALOG RESPONSE " << response << llendl; if (response == GTK_RESPONSE_ACCEPT) { GSList *file_list = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(widget)); - g_slist_foreach(file_list, (GFunc)add_to_sfs, sfs); + g_slist_foreach(file_list, (GFunc)add_to_selectedfiles, user_data); g_slist_foreach(file_list, (GFunc)g_free, NULL); g_slist_free (file_list); } // set the default path for this usage context. - LLFilePicker::sContextToPathMap[sfs->contextName] = + picker->mContextToPathMap[picker->mCurContextName] = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(widget)); gtk_widget_destroy(widget); @@ -1010,8 +902,7 @@ void chooser_responder(GtkWidget *widget, } -GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, - std::string context) +GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, std::string context) { if (ll_try_gtk_init() && ! gViewerWindow->getWindow()->getFullscreen()) @@ -1037,14 +928,13 @@ GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, GTK_STOCK_OPEN), GTK_RESPONSE_ACCEPT, (gchar *)NULL); - mStoreFilenames.win = win; - mStoreFilenames.contextName = context; + mCurContextName = context; // get the default path for this usage context if it's been // seen before. std::map<std::string,std::string>::iterator - this_path = sContextToPathMap.find(context); - if (this_path != sContextToPathMap.end()) + this_path = mContextToPathMap.find(context); + if (this_path != mContextToPathMap.end()) { gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(win), @@ -1071,8 +961,8 @@ GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, g_signal_connect (GTK_FILE_CHOOSER(win), "response", - G_CALLBACK(chooser_responder), - &mStoreFilenames); + G_CALLBACK(LLFilePicker::chooser_responder), + this); gtk_window_set_modal(GTK_WINDOW(win), TRUE); @@ -1147,13 +1037,14 @@ static std::string add_imageload_filter_to_gtkchooser(GtkWindow *picker) } -BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const char* filename ) +BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename ) { BOOL rtn = FALSE; gViewerWindow->mWindow->beforeDialog(); reset(); + GtkWindow* picker = buildFilePicker(true, false, "savefile"); if (picker) @@ -1210,7 +1101,7 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const char* filename ) gtk_window_set_title(GTK_WINDOW(picker), caption.c_str()); - if (!filename) + if (filename.empty()) { suggest_name += suggest_ext; @@ -1221,13 +1112,13 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const char* filename ) else { gtk_file_chooser_set_current_name - (GTK_FILE_CHOOSER(picker), filename); + (GTK_FILE_CHOOSER(picker), filename.c_str()); } gtk_widget_show_all(GTK_WIDGET(picker)); gtk_main(); - rtn = (mStoreFilenames.fileVector.size() == 1); + rtn = (mFiles.size() == 1); } gViewerWindow->mWindow->afterDialog(); @@ -1242,6 +1133,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter ) gViewerWindow->mWindow->beforeDialog(); reset(); + GtkWindow* picker = buildFilePicker(false, false, "openfile"); if (picker) @@ -1270,7 +1162,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter ) gtk_widget_show_all(GTK_WIDGET(picker)); gtk_main(); - rtn = (mStoreFilenames.fileVector.size() == 1); + rtn = (mFiles.size() == 1); } gViewerWindow->mWindow->afterDialog(); @@ -1285,6 +1177,7 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) gViewerWindow->mWindow->beforeDialog(); reset(); + GtkWindow* picker = buildFilePicker(false, false, "openfile"); if (picker) @@ -1296,7 +1189,7 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) gtk_widget_show_all(GTK_WIDGET(picker)); gtk_main(); - rtn = !mStoreFilenames.fileVector.empty(); + rtn = !mFiles.empty(); } gViewerWindow->mWindow->afterDialog(); @@ -1304,178 +1197,69 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) return rtn; } -const char* LLFilePicker::getFirstFile() -{ - mNextFileIndex = 0; - return getNextFile(); -} - -const char* LLFilePicker::getNextFile() -{ - if (mStoreFilenames.fileVector.size() > mNextFileIndex) - return mStoreFilenames.fileVector[mNextFileIndex++].c_str(); - else - return NULL; -} - -const char* LLFilePicker::getDirname() -{ - // getDirname is badly named... it really means getBasename. - S32 index = mNextFileIndex - 1; // want index before the 'next' cursor - if (index >= 0 && index < (S32)mStoreFilenames.fileVector.size()) - { - // we do this using C strings so we don't have to - // convert a LLString/std::string character offset into a - // byte-offset for the return (which is a C string anyway). - const char* dirsep = gDirUtilp->getDirDelimiter().c_str(); - const char* fullpath = mStoreFilenames.fileVector[index].c_str(); - const char* finalpart = NULL; - const char* thispart = fullpath; - // (Hmm, is the strstr of dirsep UTF-8-correct? Yes, reckon.) - // Walk through the string looking for the final dirsep, i.e. / - do - { - thispart = strstr(thispart, dirsep); - if (NULL != thispart) - finalpart = thispart = &thispart[1]; - } - while (NULL != thispart); - return finalpart; - } - else - return NULL; -} - -void LLFilePicker::reset() -{ - mNextFileIndex = 0; - mStoreFilenames.win = NULL; - mStoreFilenames.fileVector.clear(); -} - # else // LL_GTK // Hacky stubs designed to facilitate fake getSaveFile and getOpenFile with // static results, when we don't have a real filepicker. -static LLString hackyfilename; - -LLFilePicker::LLFilePicker() +BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename ) { reset(); -} - -LLFilePicker::~LLFilePicker() -{ -} - -BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const char* filename ) -{ + llinfos << "getSaveFile suggested filename is [" << filename << "]" << llendl; - if (filename && filename[0]) + if (!filename.empty()) { - hackyfilename.assign(gDirUtilp->getLindenUserDir()); - hackyfilename += gDirUtilp->getDirDelimiter(); - hackyfilename += filename; + mFiles.push_back(gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + filename); return TRUE; } - hackyfilename.clear(); return FALSE; } BOOL LLFilePicker::getOpenFile( ELoadFilter filter ) { + reset(); + // HACK: Static filenames for 'open' until we implement filepicker - hackyfilename.assign(gDirUtilp->getLindenUserDir()); - hackyfilename += gDirUtilp->getDirDelimiter(); - hackyfilename += "upload"; + std::string filename = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + "upload"; switch (filter) { - case FFLOAD_WAV: hackyfilename += ".wav"; break; - case FFLOAD_IMAGE: hackyfilename += ".tga"; break; - case FFLOAD_ANIM: hackyfilename += ".bvh"; break; + case FFLOAD_WAV: filename += ".wav"; break; + case FFLOAD_IMAGE: filename += ".tga"; break; + case FFLOAD_ANIM: filename += ".bvh"; break; default: break; } - llinfos << "getOpenFile: Will try to open file: " << hackyfilename - << llendl; + mFiles.push_back(filename); + llinfos << "getOpenFile: Will try to open file: " << hackyfilename << llendl; return TRUE; } BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) { - hackyfilename.clear(); + reset(); return FALSE; } -const char* LLFilePicker::getFirstFile() -{ - if (!hackyfilename.empty()) - { - return hackyfilename.c_str(); - } - return NULL; -} - -const char* LLFilePicker::getNextFile() -{ - hackyfilename.clear(); - return NULL; -} - -const char* LLFilePicker::getDirname() -{ - return NULL; -} - -void LLFilePicker::reset() -{ -} #endif // LL_GTK #else // not implemented -LLFilePicker::LLFilePicker() -{ - reset(); -} - -LLFilePicker::~LLFilePicker() -{ -} - -BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const char* filename ) +BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename ) { + reset(); return FALSE; } BOOL LLFilePicker::getOpenFile( ELoadFilter filter ) { + reset(); return FALSE; } BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) { + reset(); return FALSE; } -const char* LLFilePicker::getFirstFile() -{ - return NULL; -} - -const char* LLFilePicker::getNextFile() -{ - return NULL; -} - -const char* LLFilePicker::getDirname() -{ - return NULL; -} - -void LLFilePicker::reset() -{ -} - #endif diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h index d4b0ebe321..012524a541 100644 --- a/indra/newview/llfilepicker.h +++ b/indra/newview/llfilepicker.h @@ -68,15 +68,6 @@ #include "SDL/SDL_syswm.h" #endif -#if LL_GTK -// we use an aggregate structure so we can pass its pointer through a C callback -typedef struct { - GtkWidget *win; - std::vector<LLString> fileVector; - std::string contextName; -} StoreFilenamesStruct; -#endif // LL_GTK - class LLFilePicker { #ifdef LL_GTK @@ -119,25 +110,26 @@ public: }; // open the dialog. This is a modal operation - BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const char* filename = NULL ); + BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const std::string& filename = LLStringUtil::null ); BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL ); BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL ); // Get the filename(s) found. getFirstFile() sets the pointer to // the start of the structure and allows the start of iteration. - const char* getFirstFile(); + const std::string getFirstFile(); // getNextFile() increments the internal representation and // returns the next file specified by the user. Returns NULL when // no more files are left. Further calls to getNextFile() are // undefined. - const char* getNextFile(); + const std::string getNextFile(); - // This utility function extracts the directory name but doesn't - // do any incrementing. This is currently only supported when - // you're opening multiple files. - const char* getDirname(); + // This utility function extracts the current file name without + // doing any incrementing. + const std::string getCurFile(); + // See llvfs/lldir.h : getBaseFileName and getDirName to extract base or directory names + // clear any lists of buffers or whatever, and make sure the file // picker isn't locked. void reset(); @@ -150,11 +142,8 @@ private: FILENAME_BUFFER_SIZE = 65000 }; - void buildFilename( void ); - #if LL_WINDOWS OPENFILENAMEW mOFN; // for open and save dialogs - char *mOpenFilter; WCHAR mFilesW[FILENAME_BUFFER_SIZE]; BOOL setupFilter(ELoadFilter filter); @@ -162,26 +151,26 @@ private: #if LL_DARWIN NavDialogCreationOptions mNavOptions; - std::vector<LLString> mFileVector; + std::vector<std::string> mFileVector; UInt32 mFileIndex; OSStatus doNavChooseDialog(ELoadFilter filter); - OSStatus doNavSaveDialog(ESaveFilter filter, const char* filename); + OSStatus doNavSaveDialog(ESaveFilter filter, const std::string& filename); void getFilePath(SInt32 index); void getFileName(SInt32 index); static Boolean navOpenFilterProc(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode); #endif #if LL_GTK - StoreFilenamesStruct mStoreFilenames; - U32 mNextFileIndex; + static void add_to_selectedfiles(gpointer data, gpointer user_data); + static void chooser_responder(GtkWidget *widget, gint response, gpointer user_data); // we remember the last path that was accessed for a particular usage - static std::map <std::string, std::string> sContextToPathMap; + std::map <std::string, std::string> mContextToPathMap; + std::string mCurContextName; #endif - char mFiles[FILENAME_BUFFER_SIZE]; /*Flawfinder: ignore*/ - char mFilename[LL_MAX_PATH]; /*Flawfinder: ignore*/ - char* mCurrentFile; + std::vector<std::string> mFiles; + S32 mCurrentFile; BOOL mLocked; BOOL mMultiFile; diff --git a/indra/newview/llfirstuse.cpp b/indra/newview/llfirstuse.cpp index 3cd1158ec0..6c956a1ed0 100644 --- a/indra/newview/llfirstuse.cpp +++ b/indra/newview/llfirstuse.cpp @@ -44,10 +44,10 @@ #include "llappviewer.h" // static -std::set<LLString> LLFirstUse::sConfigVariables; +std::set<std::string> LLFirstUse::sConfigVariables; // static -void LLFirstUse::addConfigVariable(const LLString& var) +void LLFirstUse::addConfigVariable(const std::string& var) { //Don't add the warning, now that we're storing the default in the settings_default.xml file //gSavedSettings.addWarning(var); @@ -58,7 +58,7 @@ void LLFirstUse::addConfigVariable(const LLString& var) void LLFirstUse::disableFirstUse() { // Set all first-use warnings to disabled - for (std::set<LLString>::iterator iter = sConfigVariables.begin(); + for (std::set<std::string>::iterator iter = sConfigVariables.begin(); iter != sConfigVariables.end(); ++iter) { gSavedSettings.setWarning(*iter, FALSE); @@ -69,7 +69,7 @@ void LLFirstUse::disableFirstUse() void LLFirstUse::resetFirstUse() { // Set all first-use warnings to disabled - for (std::set<LLString>::iterator iter = sConfigVariables.begin(); + for (std::set<std::string>::iterator iter = sConfigVariables.begin(); iter != sConfigVariables.end(); ++iter) { gSavedSettings.setWarning(*iter, TRUE); @@ -84,7 +84,7 @@ void LLFirstUse::useBalanceIncrease(S32 delta) { gSavedSettings.setWarning("FirstBalanceIncrease", FALSE); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d",delta); LLNotifyBox::showXml("FirstBalanceIncrease", args); } @@ -98,7 +98,7 @@ void LLFirstUse::useBalanceDecrease(S32 delta) { gSavedSettings.setWarning("FirstBalanceDecrease", FALSE); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d",-delta); LLNotifyBox::showXml("FirstBalanceDecrease", args); } @@ -220,7 +220,7 @@ void LLFirstUse::useSandbox() { gSavedSettings.setWarning("FirstSandbox", FALSE); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[HOURS]"] = llformat("%d",SANDBOX_CLEAN_FREQ); args["[TIME]"] = llformat("%d",SANDBOX_FIRST_CLEAN_HOUR); LLNotifyBox::showXml("FirstSandbox", args); diff --git a/indra/newview/llfirstuse.h b/indra/newview/llfirstuse.h index 92c3da6f44..7747c0f177 100644 --- a/indra/newview/llfirstuse.h +++ b/indra/newview/llfirstuse.h @@ -79,7 +79,7 @@ class LLFirstUse { public: // Add a config variable to be reset on resetFirstUse() - static void addConfigVariable(const LLString& var); + static void addConfigVariable(const std::string& var); // Sets all controls back to show the dialogs. static void disableFirstUse(); @@ -107,7 +107,7 @@ public: static void useMedia(); protected: - static std::set<LLString> sConfigVariables; + static std::set<std::string> sConfigVariables; }; #endif diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index 62fe68f67a..9746b06500 100644 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -68,19 +68,19 @@ LLFloaterAbout* LLFloaterAbout::sInstance = NULL; // Default constructor LLFloaterAbout::LLFloaterAbout() -: LLFloater("floater_about", "FloaterAboutRect", "") +: LLFloater(std::string("floater_about"), std::string("FloaterAboutRect"), LLStringUtil::null) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_about.xml"); // Support for changing product name. - LLString title("About "); + std::string title("About "); title += LLAppViewer::instance()->getSecondLifeTitle(); setTitle(title); - LLString support; + std::string support; // Version string - LLString version = LLAppViewer::instance()->getSecondLifeTitle() + std::string version = LLAppViewer::instance()->getSecondLifeTitle() + llformat(" %d.%d.%d (%d) %s %s (%s)", LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VIEWER_BUILD, __DATE__, __TIME__, @@ -98,15 +98,15 @@ LLFloaterAbout::LLFloaterAbout() llformat("%.1f, %.1f, %.1f ", pos.mdV[VX], pos.mdV[VY], pos.mdV[VZ])); support.append(pos_text); - LLString region_text = llformat("in %s located at ", - gAgent.getRegion()->getName().c_str()); + std::string region_text = llformat("in %s located at ", + gAgent.getRegion()->getName().c_str()); support.append(region_text); - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - gAgent.getRegion()->getHost().getHostName(buffer, MAX_STRING); + std::string buffer; + buffer = gAgent.getRegion()->getHost().getHostName(); support.append(buffer); support.append(" ("); - gAgent.getRegion()->getHost().getString(buffer, MAX_STRING); + buffer = gAgent.getRegion()->getHost().getString(); support.append(buffer); support.append(")\n"); support.append(gLastVersionChannel); @@ -125,11 +125,11 @@ LLFloaterAbout::LLFloaterAbout() U32 memory = gSysMemory.getPhysicalMemoryKB() / 1024; // Moved hack adjustment to Windows memory size into llsys.cpp - LLString mem_text = llformat("Memory: %u MB\n", memory ); + std::string mem_text = llformat("Memory: %u MB\n", memory ); support.append(mem_text); support.append("OS Version: "); - support.append( LLAppViewer::instance()->getOSInfo().getOSString().c_str() ); + support.append( LLAppViewer::instance()->getOSInfo().getOSString() ); support.append("\n"); support.append("Graphics Card Vendor: "); @@ -151,7 +151,7 @@ LLFloaterAbout::LLFloaterAbout() if (media_source) { support.append("LLMozLib Version: "); - support.append((const char*) media_source->getVersion().c_str()); + support.append(media_source->getVersion()); support.append("\n"); mgr->destroySource(media_source); } @@ -159,7 +159,7 @@ LLFloaterAbout::LLFloaterAbout() if (gPacketsIn > 0) { - LLString packet_loss = llformat("Packets Lost: %.0f/%.0f (%.1f%%)", + std::string packet_loss = llformat("Packets Lost: %.0f/%.0f (%.1f%%)", LLViewerStats::getInstance()->mPacketsLostStat.getCurrent(), F32(gPacketsIn), 100.f*LLViewerStats::getInstance()->mPacketsLostStat.getCurrent() / F32(gPacketsIn) ); diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp index 1e0ebb7248..6d4ff5a1a7 100644 --- a/indra/newview/llfloateranimpreview.cpp +++ b/indra/newview/llfloateranimpreview.cpp @@ -79,7 +79,7 @@ const F32 MAX_CAMERA_ZOOM = 10.f; //----------------------------------------------------------------------------- // LLFloaterAnimPreview() //----------------------------------------------------------------------------- -LLFloaterAnimPreview::LLFloaterAnimPreview(const char* filename) : +LLFloaterAnimPreview::LLFloaterAnimPreview(const std::string& filename) : LLFloaterNameDesc(filename) { mLastSliderValue = 0.f; @@ -174,28 +174,28 @@ BOOL LLFloaterAnimPreview::postBuild() mPlayButton = getChild<LLButton>( "play_btn"); if (!mPlayButton) { - mPlayButton = new LLButton("play_btn", LLRect(0,0,0,0)); + mPlayButton = new LLButton(std::string("play_btn"), LLRect(0,0,0,0)); } mPlayButton->setClickedCallback(onBtnPlay); mPlayButton->setCallbackUserData(this); - mPlayButton->setImages("button_anim_play.tga", - "button_anim_play_selected.tga"); - mPlayButton->setDisabledImages("",""); + mPlayButton->setImages(std::string("button_anim_play.tga"), + std::string("button_anim_play_selected.tga")); + mPlayButton->setDisabledImages(LLStringUtil::null,LLStringUtil::null); mPlayButton->setScaleImage(TRUE); mStopButton = getChild<LLButton>( "stop_btn"); if (!mStopButton) { - mStopButton = new LLButton("stop_btn", LLRect(0,0,0,0)); + mStopButton = new LLButton(std::string("stop_btn"), LLRect(0,0,0,0)); } mStopButton->setClickedCallback(onBtnStop); mStopButton->setCallbackUserData(this); - mStopButton->setImages("button_anim_stop.tga", - "button_anim_stop_selected.tga"); - mStopButton->setDisabledImages("",""); + mStopButton->setImages(std::string("button_anim_stop.tga"), + std::string("button_anim_stop_selected.tga")); + mStopButton->setDisabledImages(LLStringUtil::null,LLStringUtil::null); mStopButton->setScaleImage(TRUE); @@ -224,7 +224,8 @@ BOOL LLFloaterAnimPreview::postBuild() //childSetCommitCallback("ease_out_time", onCommitEaseOut, this); //childSetValidate("ease_out_time", validateEaseOut); - if (!stricmp(strrchr(mFilename.c_str(), '.'), ".bvh")) + std::string exten = gDirUtilp->getExtension(mFilename); + if (exten == "bvh") { // loading a bvh file @@ -312,10 +313,10 @@ BOOL LLFloaterAnimPreview::postBuild() childSetValue("ease_in_time", LLSD(motionp->getEaseInDuration())); childSetValue("ease_out_time", LLSD(motionp->getEaseOutDuration())); setEnabled(TRUE); - char seconds_string[128]; /*Flawfinder: ignore*/ - snprintf(seconds_string, sizeof(seconds_string), " - %.2f seconds", motionp->getDuration()); /* Flawfinder: ignore */ + std::string seconds_string; + seconds_string = llformat(" - %.2f seconds", motionp->getDuration()); - setTitle(mFilename + LLString(seconds_string)); + setTitle(mFilename + std::string(seconds_string)); } else { @@ -939,8 +940,8 @@ void LLFloaterAnimPreview::refresh() if (avatarp->areAnimationsPaused()) { - mPlayButton->setImages("button_anim_play.tga", - "button_anim_play_selected.tga"); + mPlayButton->setImages(std::string("button_anim_play.tga"), + std::string("button_anim_play_selected.tga")); } else @@ -953,16 +954,16 @@ void LLFloaterAnimPreview::refresh() childSetValue("playback_slider", fraction_complete); mLastSliderValue = fraction_complete; } - mPlayButton->setImages("button_anim_pause.tga", - "button_anim_pause_selected.tga"); + mPlayButton->setImages(std::string("button_anim_pause.tga"), + std::string("button_anim_pause_selected.tga")); } } else { mPauseRequest = avatarp->requestPause(); - mPlayButton->setImages("button_anim_play.tga", - "button_anim_play_selected.tga"); + mPlayButton->setImages(std::string("button_anim_play.tga"), + std::string("button_anim_play_selected.tga")); mStopButton->setEnabled(FALSE); } diff --git a/indra/newview/llfloateranimpreview.h b/indra/newview/llfloateranimpreview.h index cbfba0c43e..693e3f8fbf 100644 --- a/indra/newview/llfloateranimpreview.h +++ b/indra/newview/llfloateranimpreview.h @@ -70,7 +70,7 @@ protected: class LLFloaterAnimPreview : public LLFloaterNameDesc { public: - LLFloaterAnimPreview(const char* filename); + LLFloaterAnimPreview(const std::string& filename); virtual ~LLFloaterAnimPreview(); BOOL postBuild(); @@ -126,7 +126,7 @@ protected: BOOL mEnabled; LLAnimPauseRequest mPauseRequest; - std::map<LLString, LLUUID> mIDList; + std::map<std::string, LLUUID> mIDList; static S32 sUploadAmount; }; diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp index 41bc0db6a6..480ef708d6 100644 --- a/indra/newview/llfloaterauction.cpp +++ b/indra/newview/llfloaterauction.cpp @@ -72,7 +72,7 @@ LLFloaterAuction* LLFloaterAuction::sInstance = NULL; // Default constructor LLFloaterAuction::LLFloaterAuction() : - LLFloater("floater_auction"), + LLFloater(std::string("floater_auction")), mParcelID(-1) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_auction.xml"); @@ -128,7 +128,7 @@ void LLFloaterAuction::initialize() } else { - childSetText("parcel_text", LLString::null); + childSetText("parcel_text", LLStringUtil::null); } mParcelID = -1; childSetEnabled("snapshot_btn", false); @@ -224,14 +224,14 @@ void LLFloaterAuction::onClickOK(void* data) LLSD parcel_name = self->childGetValue("parcel_text"); // create the asset - LLString* name = new LLString(parcel_name.asString()); + std::string* name = new std::string(parcel_name.asString()); gAssetStorage->storeAssetData(self->mTransactionID, LLAssetType::AT_IMAGE_TGA, &auction_tga_upload_done, (void*)name, FALSE); self->getWindow()->incBusyCount(); - LLString* j2c_name = new LLString(parcel_name.asString()); + std::string* j2c_name = new std::string(parcel_name.asString()); gAssetStorage->storeAssetData(self->mTransactionID, LLAssetType::AT_TEXTURE, &auction_j2c_upload_done, (void*)j2c_name, @@ -268,7 +268,7 @@ void LLFloaterAuction::onClickOK(void* data) void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed) { - LLString* name = (LLString*)(user_data); + std::string* name = (std::string*)(user_data); llinfos << "Upload of asset '" << *name << "' " << asset_id << " returned " << status << llendl; delete name; @@ -281,7 +281,7 @@ void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status } else { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("UploadAuctionSnapshotFail", args); } @@ -289,7 +289,7 @@ void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status void auction_j2c_upload_done(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed) { - LLString* name = (LLString*)(user_data); + std::string* name = (std::string*)(user_data); llinfos << "Upload of asset '" << *name << "' " << asset_id << " returned " << status << llendl; delete name; @@ -302,7 +302,7 @@ void auction_j2c_upload_done(const LLUUID& asset_id, void* user_data, S32 status } else { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("UploadAuctionSnapshotFail", args); } diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 0c1175b26c..c45b2916e7 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -47,7 +47,7 @@ const S32 MIN_WIDTH = 200; const S32 MIN_HEIGHT = 340; const LLRect FLOATER_RECT(0, 380, 240, 0); -const char FLOATER_TITLE[] = "Choose Resident"; +const std::string FLOATER_TITLE = "Choose Resident"; // static LLFloaterAvatarPicker* LLFloaterAvatarPicker::sInstance = NULL; @@ -83,7 +83,7 @@ LLFloaterAvatarPicker* LLFloaterAvatarPicker::show(callback_t callback, // Default constructor LLFloaterAvatarPicker::LLFloaterAvatarPicker() : - LLFloater("avatarpicker", FLOATER_RECT, FLOATER_TITLE, TRUE, MIN_WIDTH, MIN_HEIGHT), + LLFloater(std::string("avatarpicker"), FLOATER_RECT, FLOATER_TITLE, TRUE, MIN_WIDTH, MIN_HEIGHT), mResultsReturned(FALSE), mCallback(NULL), mCallbackUserdata(NULL) @@ -112,7 +112,7 @@ BOOL LLFloaterAvatarPicker::postBuild() if (mListNames) { - mListNames->addCommentText("No results"); + mListNames->addCommentText(std::string("No results")); // *TODO: Translate } mInventoryPanel = getChild<LLInventoryPanel>("Inventory Panel"); @@ -260,7 +260,7 @@ void LLFloaterAvatarPicker::doSelectionChange(const std::deque<LLFolderViewItem* void LLFloaterAvatarPicker::find() { - const LLString& text = childGetValue("Edit").asString(); + const std::string& text = childGetValue("Edit").asString(); mQueryID.generate(); @@ -279,7 +279,7 @@ void LLFloaterAvatarPicker::find() if (mListNames) { mListNames->deleteAllItems(); - mListNames->addCommentText("Searching..."); + mListNames->addCommentText(std::string("Searching...")); // *TODO: Translate } childSetEnabled("Select", FALSE); @@ -305,8 +305,8 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* LLUUID agent_id; LLUUID query_id; LLUUID avatar_id; - char first_name[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ - char last_name[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string first_name; + std::string last_name; msg->getUUID("AgentData", "AgentID", agent_id); msg->getUUID("AgentData", "QueryID", query_id); @@ -341,20 +341,20 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* for (S32 i = 0; i < num_new_rows; i++) { msg->getUUIDFast( _PREHASH_Data,_PREHASH_AvatarID, avatar_id, i); - msg->getStringFast(_PREHASH_Data,_PREHASH_FirstName, DB_FIRST_NAME_BUF_SIZE, first_name, i); - msg->getStringFast(_PREHASH_Data,_PREHASH_LastName, DB_LAST_NAME_BUF_SIZE, last_name, i); + msg->getStringFast(_PREHASH_Data,_PREHASH_FirstName, first_name, i); + msg->getStringFast(_PREHASH_Data,_PREHASH_LastName, last_name, i); - LLString avatar_name; + std::string avatar_name; if (avatar_id.isNull()) { - LLString::format_map_t map; + LLStringUtil::format_map_t map; map["[TEXT]"] = self->childGetText("Edit"); avatar_name = self->getString("NotFound", map); self->mListNames->setEnabled(FALSE); } else { - avatar_name = LLString(first_name) + " " + last_name; + avatar_name = first_name + " " + last_name; self->mListNames->setEnabled(TRUE); found_one = TRUE; } diff --git a/indra/newview/llfloateravatartextures.cpp b/indra/newview/llfloateravatartextures.cpp index 3870448652..008266c6f7 100644 --- a/indra/newview/llfloateravatartextures.cpp +++ b/indra/newview/llfloateravatartextures.cpp @@ -40,7 +40,7 @@ #include "llvoavatar.h" LLFloaterAvatarTextures::LLFloaterAvatarTextures(const LLUUID& id) : - LLFloater("avatar_texture_debug"), + LLFloater(std::string("avatar_texture_debug")), mID(id) { } @@ -110,7 +110,7 @@ static void update_texture_ctrl(LLVOAvatar* avatarp, if (id == IMG_DEFAULT_AVATAR) { ctrl->setImageAssetID(LLUUID::null); - ctrl->setToolTip(LLString("IMG_DEFAULT_AVATAR")); + ctrl->setToolTip(std::string("IMG_DEFAULT_AVATAR")); } else { diff --git a/indra/newview/llfloateravatartextures.h b/indra/newview/llfloateravatartextures.h index 85208ce648..a49f9d5150 100644 --- a/indra/newview/llfloateravatartextures.h +++ b/indra/newview/llfloateravatartextures.h @@ -56,7 +56,7 @@ private: private: LLUUID mID; - LLString mTitle; + std::string mTitle; LLTextureCtrl* mBakedHead; LLTextureCtrl* mBakedEyes; LLTextureCtrl* mBakedUpper; diff --git a/indra/newview/llfloaterbuildoptions.cpp b/indra/newview/llfloaterbuildoptions.cpp index 35add8d5b5..0d2611556f 100644 --- a/indra/newview/llfloaterbuildoptions.cpp +++ b/indra/newview/llfloaterbuildoptions.cpp @@ -58,7 +58,7 @@ LLFloaterBuildOptions *LLFloaterBuildOptions::sInstance = NULL; // Methods // LLFloaterBuildOptions::LLFloaterBuildOptions( ) -: LLFloater("build options floater") +: LLFloater(std::string("build options floater")) { sInstance = this; } diff --git a/indra/newview/llfloaterbump.cpp b/indra/newview/llfloaterbump.cpp index ce2d56612c..98540f3c5e 100644 --- a/indra/newview/llfloaterbump.cpp +++ b/indra/newview/llfloaterbump.cpp @@ -84,7 +84,7 @@ void LLFloaterBump::show(void *contents) if (gMeanCollisionList.empty()) { - LLString none_detected = sInstance->getString("none_detected"); + std::string none_detected = sInstance->getString("none_detected"); LLSD row; row["columns"][0]["value"] = none_detected; row["columns"][0]["font"] = "SansSerifBold"; @@ -110,8 +110,7 @@ void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd) new LLFloaterBump(); } - if (!mcd->mFirstName[0] - || list->getItemCount() >= 20) + if (mcd->mFirstName.empty() || list->getItemCount() >= 20) { return; } @@ -123,9 +122,9 @@ void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd) // it's daylight savings time there. timep = utc_to_pacific_time(mcd->mTime, gPacificDaylightTime); - LLString time = llformat("[%d:%02d]", timep->tm_hour, timep->tm_min); + std::string time = llformat("[%d:%02d]", timep->tm_hour, timep->tm_min); - LLString action; + std::string action; switch(mcd->mType) { case MEAN_BUMP: diff --git a/indra/newview/llfloaterbuy.cpp b/indra/newview/llfloaterbuy.cpp index 34bdaffd76..e64f218457 100644 --- a/indra/newview/llfloaterbuy.cpp +++ b/indra/newview/llfloaterbuy.cpp @@ -52,7 +52,7 @@ LLFloaterBuy* LLFloaterBuy::sInstance = NULL; LLFloaterBuy::LLFloaterBuy() -: LLFloater("floater_buy_object", "FloaterBuyRect", "") +: LLFloater(std::string("floater_buy_object"), std::string("FloaterBuyRect"), LLStringUtil::null) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_buy_object.xml"); @@ -132,7 +132,7 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info) sInstance->setTitle(title); LLUUID owner_id; - LLString owner_name; + std::string owner_name; BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { @@ -151,7 +151,7 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info) LLSD row; // Compute icon for this item - LLString icon_name = get_item_icon_name(LLAssetType::AT_OBJECT, + std::string icon_name = get_item_icon_name(LLAssetType::AT_OBJECT, LLInventoryType::IT_OBJECT, 0x0, FALSE); @@ -162,7 +162,7 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info) // Append the permissions that you will acquire (not the current // permissions). U32 next_owner_mask = node->mPermissions->getMaskNextOwner(); - LLString text = node->mName; + std::string text = node->mName; if (!(next_owner_mask & PERM_COPY)) { text.append(sInstance->getString("no_copy_text")); @@ -256,7 +256,7 @@ void LLFloaterBuy::inventoryChanged(LLViewerObject* obj, item_is_multi = TRUE; } - LLString icon_name = get_item_icon_name(inv_item->getType(), + std::string icon_name = get_item_icon_name(inv_item->getType(), inv_item->getInventoryType(), inv_item->getFlags(), item_is_multi); @@ -267,7 +267,7 @@ void LLFloaterBuy::inventoryChanged(LLViewerObject* obj, // Append the permissions that you will acquire (not the current // permissions). U32 next_owner_mask = inv_item->getPermissions().getMaskNextOwner(); - LLString text = obj->getName(); + std::string text = obj->getName(); if (!(next_owner_mask & PERM_COPY)) { text.append(" (no copy)"); diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp index 34be223286..d74707f6b1 100644 --- a/indra/newview/llfloaterbuycontents.cpp +++ b/indra/newview/llfloaterbuycontents.cpp @@ -56,7 +56,7 @@ LLFloaterBuyContents* LLFloaterBuyContents::sInstance = NULL; LLFloaterBuyContents::LLFloaterBuyContents() -: LLFloater("floater_buy_contents", "FloaterBuyContentsRect", "") +: LLFloater(std::string("floater_buy_contents"), std::string("FloaterBuyContentsRect"), LLStringUtil::null) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_buy_contents.xml"); @@ -109,7 +109,7 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info) sInstance->center(); LLUUID owner_id; - LLString owner_name; + std::string owner_name; BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { @@ -223,7 +223,7 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj, item_is_multi = TRUE; } - LLString icon_name = get_item_icon_name(inv_item->getType(), + std::string icon_name = get_item_icon_name(inv_item->getType(), inv_item->getInventoryType(), inv_item->getFlags(), item_is_multi); @@ -234,7 +234,7 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj, // Append the permissions that you will acquire (not the current // permissions). U32 next_owner_mask = inv_item->getPermissions().getMaskNextOwner(); - LLString text = (*it)->getName(); + std::string text = (*it)->getName(); if (!(next_owner_mask & PERM_COPY)) { diff --git a/indra/newview/llfloaterbuycurrency.cpp b/indra/newview/llfloaterbuycurrency.cpp index 1ab42efef3..34df1e06ae 100644 --- a/indra/newview/llfloaterbuycurrency.cpp +++ b/indra/newview/llfloaterbuycurrency.cpp @@ -113,7 +113,7 @@ LLFloaterBuyCurrencyUI* LLFloaterBuyCurrencyUI::soleInstance(bool createIfNeeded #pragma warning(disable : 4355) #endif LLFloaterBuyCurrencyUI::LLFloaterBuyCurrencyUI() -: LLFloater("Buy Currency"), +: LLFloater(std::string("Buy Currency")), mChildren(*this), mManager(*this) { @@ -219,7 +219,7 @@ void LLFloaterBuyCurrencyUI::updateUI() // error section if (hasError) { - mChildren.setBadge("step_error", LLViewChildren::BADGE_ERROR); + mChildren.setBadge(std::string("step_error"), LLViewChildren::BADGE_ERROR); LLTextBox* message = getChild<LLTextBox>("error_message"); if (message) @@ -249,7 +249,7 @@ void LLFloaterBuyCurrencyUI::updateUI() if (!hasError) { - mChildren.setBadge("step_1", LLViewChildren::BADGE_NOTE); + mChildren.setBadge(std::string("step_1"), LLViewChildren::BADGE_NOTE); if (mManager.buying()) { @@ -373,8 +373,8 @@ void LLFloaterBuyCurrency::buyCurrency(const std::string& name, S32 price) { if (gHideLinks) { - LLStringBase<char>::format_map_t args; - args["[NAME]"] = name.c_str(); + LLStringUtil::format_map_t args; + args["[NAME]"] = name; args["[PRICE]"] = llformat("%d", price); gViewerWindow->alertXml("NotEnoughCurrency", args); return; diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 936aad6606..b08dea248f 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -198,7 +198,7 @@ private: }; static void cacheNameUpdateRefreshesBuyLand(const LLUUID&, - const char*, const char*, BOOL, void* data) + const std::string&, const std::string&, BOOL, void* data) { LLFloaterBuyLandUI* ui = LLFloaterBuyLandUI::soleInstance(false); if (ui) @@ -321,7 +321,7 @@ LLFloaterBuyLandUI* LLFloaterBuyLandUI::soleInstance(bool createIfNeeded) #pragma warning(disable : 4355) #endif LLFloaterBuyLandUI::LLFloaterBuyLandUI() -: LLFloater("Buy Land"), +: LLFloater(std::string("Buy Land")), mParcel(0), mBought(false), mParcelValid(false), mSiteValid(false), @@ -455,7 +455,7 @@ void LLFloaterBuyLandUI::updateParcelInfo() bool haveEnoughCash = mParcelPrice <= mAgentCashBalance; S32 cashBuy = haveEnoughCash ? 0 : (mParcelPrice - mAgentCashBalance); mCurrency.setAmount(cashBuy, true); - mCurrency.setZeroMessage(haveEnoughCash ? getString("none_needed") : ""); + mCurrency.setZeroMessage(haveEnoughCash ? getString("none_needed") : LLStringUtil::null); // checks that we can buy the land @@ -810,7 +810,7 @@ void LLFloaterBuyLandUI::updateNames() if (!parcelp) { - mParcelSellerName = ""; + mParcelSellerName = LLStringUtil::null; return; } @@ -1014,7 +1014,7 @@ void LLFloaterBuyLandUI::refreshUI() { childSetText("info_parcel", mParcelLocation); - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mParcelActualArea); string_args["[AMOUNT2]"] = llformat("%d", mParcelSupportedObjects); @@ -1033,8 +1033,8 @@ void LLFloaterBuyLandUI::refreshUI() else { childSetText("info_parcel", getString("no_parcel_selected")); - childSetText("info_size", LLString::null); - childSetText("info_price", LLString::null); + childSetText("info_size", LLStringUtil::null); + childSetText("info_price", LLStringUtil::null); } childSetText("info_action", @@ -1056,7 +1056,7 @@ void LLFloaterBuyLandUI::refreshUI() // error section if (showingError) { - mChildren.setBadge("step_error", + mChildren.setBadge(std::string("step_error"), mCannotBuyIsError ? LLViewChildren::BADGE_ERROR : LLViewChildren::BADGE_WARN); @@ -1084,7 +1084,7 @@ void LLFloaterBuyLandUI::refreshUI() // section one: account if (!showingError) { - mChildren.setBadge("step_1", + mChildren.setBadge(std::string("step_1"), mSiteMembershipUpgrade ? LLViewChildren::BADGE_NOTE : LLViewChildren::BADGE_OK); @@ -1127,7 +1127,7 @@ void LLFloaterBuyLandUI::refreshUI() // section two: land use fees if (!showingError) { - mChildren.setBadge("step_2", + mChildren.setBadge(std::string("step_2"), mSiteLandUseUpgrade ? LLViewChildren::BADGE_NOTE : LLViewChildren::BADGE_OK); @@ -1137,15 +1137,15 @@ void LLFloaterBuyLandUI::refreshUI() if (mIsForGroup) { - LLString::format_map_t string_args; - string_args["[GROUP]"] = LLString(gAgent.mGroupName); + LLStringUtil::format_map_t string_args; + string_args["[GROUP]"] = std::string(gAgent.mGroupName); message += getString("insufficient_land_credits", string_args); } else { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[BUYER]"] = llformat("%d", mAgentCommittedTier); message += getString("land_holdings", string_args); } @@ -1156,7 +1156,7 @@ void LLFloaterBuyLandUI::refreshUI() } else if (mParcelBillableArea == mParcelActualArea) { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mParcelActualArea); message += getString("parcel_meters", string_args); } @@ -1165,13 +1165,13 @@ void LLFloaterBuyLandUI::refreshUI() if (mParcelBillableArea > mParcelActualArea) { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mParcelBillableArea); message += getString("premium_land", string_args); } else { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mParcelBillableArea); message += getString("discounted_land", string_args); } @@ -1201,7 +1201,7 @@ void LLFloaterBuyLandUI::refreshUI() if (!showingError) { - mChildren.setBadge("step_3", + mChildren.setBadge(std::string("step_3"), !willHaveEnough ? LLViewChildren::BADGE_WARN : mCurrency.getAmount() > 0 @@ -1220,14 +1220,14 @@ void LLFloaterBuyLandUI::refreshUI() if (haveEnough) { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mAgentCashBalance); childSetText("currency_reason", getString("have_enough_lindens", string_args)); } else { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mAgentCashBalance); string_args["[AMOUNT2]"] = llformat("%d", mParcelPrice - mAgentCashBalance); @@ -1238,7 +1238,7 @@ void LLFloaterBuyLandUI::refreshUI() if (willHaveEnough) { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", finalBalance); childSetText("currency_balance", getString("balance_left", string_args)); @@ -1246,7 +1246,7 @@ void LLFloaterBuyLandUI::refreshUI() } else { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mParcelPrice - mAgentCashBalance); childSetText("currency_balance", getString("balance_needed", string_args)); @@ -1311,14 +1311,14 @@ void LLFloaterBuyLandUI::startBuyPreConfirm() } if (mCurrency.getAmount() > 0) { - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mCurrency.getAmount()); string_args["[AMOUNT2]"] = llformat("%#.2f", mCurrency.getEstimate() / 100.0); action += getString("buy_for_US", string_args); } - LLString::format_map_t string_args; + LLStringUtil::format_map_t string_args; string_args["[AMOUNT]"] = llformat("%d", mParcelPrice); string_args["[SELLER]"] = mParcelSellerName; action += getString("pay_to_for_land", string_args); diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index 75e1d694a4..47803d8304 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -61,10 +61,10 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val) S32 left = 16; const S32 ROTATE_WIDTH = 64; - mRotate = new LLJoystickCameraRotate("cam rotate stick", + mRotate = new LLJoystickCameraRotate(std::string("cam rotate stick"), LLRect( left, top, left + ROTATE_WIDTH, bottom ), - "cam_rotate_out.tga", - "cam_rotate_in.tga" ); + std::string("cam_rotate_out.tga"), + std::string("cam_rotate_in.tga") ); mRotate->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT); mRotate->setHeldDownDelay(CAMERA_BUTTON_DELAY); mRotate->setToolTip( getString("rotate_tooltip") ); @@ -75,11 +75,11 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val) const S32 ZOOM_WIDTH = 16; mZoom = new LLJoystickCameraZoom( - "zoom", + std::string("zoom"), LLRect( left, top, left + ZOOM_WIDTH, bottom ), - "cam_zoom_out.tga", - "cam_zoom_plus_in.tga", - "cam_zoom_minus_in.tga"); + std::string("cam_zoom_out.tga"), + std::string("cam_zoom_plus_in.tga"), + std::string("cam_zoom_minus_in.tga")); mZoom->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT); mZoom->setHeldDownDelay(CAMERA_BUTTON_DELAY); mZoom->setToolTip( getString("zoom_tooltip") ); @@ -89,10 +89,10 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val) left += ZOOM_WIDTH; const S32 TRACK_WIDTH = 64; - mTrack = new LLJoystickCameraTrack("cam track stick", + mTrack = new LLJoystickCameraTrack(std::string("cam track stick"), LLRect( left, top, left + TRACK_WIDTH, bottom ), - "cam_tracking_out.tga", - "cam_tracking_in.tga"); + std::string("cam_tracking_out.tga"), + std::string("cam_tracking_in.tga")); mTrack->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT); mTrack->setHeldDownDelay(CAMERA_BUTTON_DELAY); mTrack->setToolTip( getString("move_tooltip") ); diff --git a/indra/newview/llfloaterchat.cpp b/indra/newview/llfloaterchat.cpp index fd428990f8..745e7766f2 100644 --- a/indra/newview/llfloaterchat.cpp +++ b/indra/newview/llfloaterchat.cpp @@ -75,8 +75,8 @@ #include "llstylemap.h" // Used for LCD display -extern void AddNewIMToLCD(const LLString &newLine); -extern void AddNewChatToLCD(const LLString &newLine); +extern void AddNewIMToLCD(const std::string &newLine); +extern void AddNewChatToLCD(const std::string &newLine); // // Constants // @@ -94,7 +94,7 @@ LLColor4 get_text_color(const LLChat& chat); // Member Functions // LLFloaterChat::LLFloaterChat(const LLSD& seed) -: LLFloater("chat floater", "FloaterChatRect", "", +: LLFloater(std::string("chat floater"), std::string("FloaterChatRect"), LLStringUtil::null, RESIZE_YES, 440, 100, DRAG_ON_TOP, MINIMIZE_NO, CLOSE_YES), mPanel(NULL) { @@ -191,7 +191,7 @@ void LLFloaterChat::updateConsoleVisibility() void add_timestamped_line(LLViewerTextEditor* edit, const LLChat &chat, const LLColor4& color) { - LLString line = chat.mText; + std::string line = chat.mText; bool prepend_newline = true; if (gSavedSettings.getBOOL("ChatShowTimestamps")) { @@ -215,13 +215,13 @@ void add_timestamped_line(LLViewerTextEditor* edit, const LLChat &chat, const LL void log_chat_text(const LLChat& chat) { - LLString histstr; + std::string histstr; if (gSavedPerAccountSettings.getBOOL("LogChatTimestamp")) histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + chat.mText; else histstr = chat.mText; - LLLogChat::saveHistory("chat",histstr); + LLLogChat::saveHistory(std::string("chat"),histstr); } // static void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) @@ -304,7 +304,7 @@ void LLFloaterChat::onClickMute(void *data) LLComboBox* chatter_combo = self->getChild<LLComboBox>("chatter combobox"); - const LLString& name = chatter_combo->getSimple(); + const std::string& name = chatter_combo->getSimple(); LLUUID id = chatter_combo->getCurrentID(); if (name.empty()) return; @@ -459,11 +459,11 @@ LLColor4 get_text_color(const LLChat& chat) //static void LLFloaterChat::loadHistory() { - LLLogChat::loadHistory("chat", &chatFromLogFile, (void *)LLFloaterChat::getInstance(LLSD())); + LLLogChat::loadHistory(std::string("chat"), &chatFromLogFile, (void *)LLFloaterChat::getInstance(LLSD())); } //static -void LLFloaterChat::chatFromLogFile(LLLogChat::ELogLineType type , LLString line, void* userdata) +void LLFloaterChat::chatFromLogFile(LLLogChat::ELogLineType type , std::string line, void* userdata) { switch (type) { diff --git a/indra/newview/llfloaterchat.h b/indra/newview/llfloaterchat.h index 118e6bbe6d..d118f2f099 100644 --- a/indra/newview/llfloaterchat.h +++ b/indra/newview/llfloaterchat.h @@ -77,7 +77,7 @@ public: static void onClickMute(void *data); static void onClickToggleShowMute(LLUICtrl* caller, void *data); static void onClickToggleActiveSpeakers(void* userdata); - static void chatFromLogFile(LLLogChat::ELogLineType type,LLString line, void* userdata); + static void chatFromLogFile(LLLogChat::ELogLineType type,std::string line, void* userdata); static void loadHistory(); static void* createSpeakersPanel(void* data); static void* createChatPanel(void* data); diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index ec659b5146..d02fd072e2 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -78,7 +78,7 @@ const F32 CONTEXT_FADE_TIME = 0.08f; // default ctor LLFloaterColorPicker:: LLFloaterColorPicker (LLColorSwatchCtrl* swatch, BOOL show_apply_immediate ) - : LLFloater ("Color Picker Floater"), + : LLFloater (std::string("Color Picker Floater")), mComponents ( 3 ), mMouseDownInLumRegion ( FALSE ), mMouseDownInHueRegion ( FALSE ), @@ -232,7 +232,7 @@ postBuild() mPipetteBtn = getChild<LLButton>("color_pipette" ); - mPipetteBtn->setImages("eye_button_inactive.tga", "eye_button_active.tga"); + mPipetteBtn->setImages(std::string("eye_button_inactive.tga"), std::string("eye_button_active.tga")); mPipetteBtn->setClickedCallback( onClickPipette ); mPipetteBtn->setCallbackUserData ( this ); @@ -794,7 +794,7 @@ LLFloaterColorPicker:: onTextEntryChanged ( LLUICtrl* ctrl ) { // value in RGB boxes changed - LLString name = ctrl->getName(); + std::string name = ctrl->getName(); if ( ( name == "rspin" ) || ( name == "gspin" ) || ( name == "bspin" ) ) { // get current RGB diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp index ca1131face..1a8c35b837 100644 --- a/indra/newview/llfloaterdaycycle.cpp +++ b/indra/newview/llfloaterdaycycle.cpp @@ -59,10 +59,10 @@ LLFloaterDayCycle* LLFloaterDayCycle::sDayCycle = NULL; -std::map<LLString, LLWLSkyKey> LLFloaterDayCycle::sSliderToKey; +std::map<std::string, LLWLSkyKey> LLFloaterDayCycle::sSliderToKey; const F32 LLFloaterDayCycle::sHoursPerDay = 24.0f; -LLFloaterDayCycle::LLFloaterDayCycle() : LLFloater("Day Cycle Floater") +LLFloaterDayCycle::LLFloaterDayCycle() : LLFloater(std::string("Day Cycle Floater")) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_day_cycle_options.xml"); @@ -75,7 +75,7 @@ LLFloaterDayCycle::LLFloaterDayCycle() : LLFloater("Day Cycle Floater") LLWLParamManager::instance()->mParamList.begin(); for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) { - keyCombo->add(LLString(mIt->first)); + keyCombo->add(std::string(mIt->first)); } // set defaults on combo boxes @@ -97,11 +97,10 @@ LLFloaterDayCycle::~LLFloaterDayCycle() void LLFloaterDayCycle::onClickHelp(void* data) { - LLFloaterDayCycle* self = LLFloaterDayCycle::instance(); + const std::string* xml_alert = (std::string*)data; - const char* xml_alert = (const char*) data; - LLAlertDialog* dialogp = gViewerWindow->alertXml(xml_alert); + LLAlertDialog* dialogp = gViewerWindow->alertXml(*xml_alert); if (dialogp) { LLFloater* root_floater = gFloaterView->getParentFloater(self); @@ -110,11 +109,12 @@ void LLFloaterDayCycle::onClickHelp(void* data) root_floater->addDependentFloater(dialogp); } } + delete xml_alert; } -void LLFloaterDayCycle::initHelpBtn(const char* name, const char* xml_alert) +void LLFloaterDayCycle::initHelpBtn(const std::string& name, const std::string& xml_alert) { - childSetAction(name, onClickHelp, (void*)xml_alert); + childSetAction(name, onClickHelp, new std::string(xml_alert)); } void LLFloaterDayCycle::initCallbacks(void) @@ -193,7 +193,7 @@ void LLFloaterDayCycle::syncSliderTrack() LLWLParamManager::instance()->mDay.mTimeMap.begin(); for(; mIt != LLWLParamManager::instance()->mDay.mTimeMap.end(); mIt++) { - addSliderKey(mIt->first * sHoursPerDay, mIt->second.c_str()); + addSliderKey(mIt->first * sHoursPerDay, mIt->second); } } @@ -218,7 +218,7 @@ void LLFloaterDayCycle::syncTrack() LLWLParamManager::instance()->mDay.clearKeys(); // add the keys one by one - std::map<LLString, LLWLSkyKey>::iterator mIt = sSliderToKey.begin(); + std::map<std::string, LLWLSkyKey>::iterator mIt = sSliderToKey.begin(); for(; mIt != sSliderToKey.end(); mIt++) { LLWLParamManager::instance()->mDay.addKey(mIt->second.time / sHoursPerDay, @@ -379,7 +379,7 @@ void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl, void* userData) } // make sure we have a slider - const LLString& curSldr = sldr->getCurSlider(); + const std::string& curSldr = sldr->getCurSlider(); if(curSldr == "") { return; } @@ -387,7 +387,7 @@ void LLFloaterDayCycle::onKeyTimeMoved(LLUICtrl* ctrl, void* userData) F32 time = sldr->getCurSliderValue(); // check to see if a key exists - LLString presetName = sSliderToKey[curSldr].presetName; + std::string presetName = sSliderToKey[curSldr].presetName; sSliderToKey[curSldr].time = time; // if it exists, turn on check box @@ -428,12 +428,12 @@ void LLFloaterDayCycle::onKeyTimeChanged(LLUICtrl* ctrl, void* userData) F32 min = minSpin->get(); F32 val = hour + min / 60.0f; - const LLString& curSldr = sldr->getCurSlider(); + const std::string& curSldr = sldr->getCurSlider(); sldr->setCurSliderValue(val, TRUE); F32 time = sldr->getCurSliderValue() / sHoursPerDay; // now set the key's time in the sliderToKey map - LLString presetName = sSliderToKey[curSldr].presetName; + std::string presetName = sSliderToKey[curSldr].presetName; sSliderToKey[curSldr].time = time; syncTrack(); @@ -453,8 +453,8 @@ void LLFloaterDayCycle::onKeyPresetChanged(LLUICtrl* ctrl, void* userData) } // change the map - LLString newPreset(comboBox->getSelectedValue().asString()); - const LLString& curSldr = sldr->getCurSlider(); + std::string newPreset(comboBox->getSelectedValue().asString()); + const std::string& curSldr = sldr->getCurSlider(); // if null, don't use if(curSldr == "") { @@ -506,7 +506,7 @@ void LLFloaterDayCycle::onAddKey(void* userData) llassert_always(sSliderToKey.size() == kSldr->getValue().size()); // get the values - LLString newPreset(comboBox->getSelectedValue().asString()); + std::string newPreset(comboBox->getSelectedValue().asString()); // add the slider key addSliderKey(tSldr->getCurSliderValue(), newPreset); @@ -514,13 +514,13 @@ void LLFloaterDayCycle::onAddKey(void* userData) syncTrack(); } -void LLFloaterDayCycle::addSliderKey(F32 time, const LLString & presetName) +void LLFloaterDayCycle::addSliderKey(F32 time, const std::string & presetName) { LLMultiSliderCtrl* kSldr = sDayCycle->getChild<LLMultiSliderCtrl>( "WLDayCycleKeys"); // make a slider - const LLString& sldrName = kSldr->addSlider(time); + const std::string& sldrName = kSldr->addSlider(time); if(sldrName == "") { return; } @@ -530,21 +530,21 @@ void LLFloaterDayCycle::addSliderKey(F32 time, const LLString & presetName) newKey.presetName = presetName; newKey.time = kSldr->getCurSliderValue(); - llassert_always(sldrName != LLString::null); + llassert_always(sldrName != LLStringUtil::null); // add to map - sSliderToKey.insert(std::pair<LLString, LLWLSkyKey>(sldrName, newKey)); + sSliderToKey.insert(std::pair<std::string, LLWLSkyKey>(sldrName, newKey)); llassert_always(sSliderToKey.size() == kSldr->getValue().size()); } -void LLFloaterDayCycle::deletePreset(LLString& presetName) +void LLFloaterDayCycle::deletePreset(std::string& presetName) { LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); /// delete any reference - std::map<LLString, LLWLSkyKey>::iterator curr_preset, next_preset; + std::map<std::string, LLWLSkyKey>::iterator curr_preset, next_preset; for(curr_preset = sSliderToKey.begin(); curr_preset != sSliderToKey.end(); curr_preset = next_preset) { next_preset = curr_preset; @@ -568,8 +568,8 @@ void LLFloaterDayCycle::onDeleteKey(void* userData) LLMultiSliderCtrl* sldr = sDayCycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); // delete from map - const LLString& sldrName = sldr->getCurSlider(); - std::map<LLString, LLWLSkyKey>::iterator mIt = sSliderToKey.find(sldrName); + const std::string& sldrName = sldr->getCurSlider(); + std::map<std::string, LLWLSkyKey>::iterator mIt = sSliderToKey.find(sldrName); sSliderToKey.erase(mIt); sldr->deleteCurSlider(); @@ -578,7 +578,7 @@ void LLFloaterDayCycle::onDeleteKey(void* userData) return; } - const LLString& name = sldr->getCurSlider(); + const std::string& name = sldr->getCurSlider(); comboBox->selectByValue(sSliderToKey[name].presetName); F32 time = sSliderToKey[name].time; diff --git a/indra/newview/llfloaterdaycycle.h b/indra/newview/llfloaterdaycycle.h index 91a649b97c..2e66c1c609 100644 --- a/indra/newview/llfloaterdaycycle.h +++ b/indra/newview/llfloaterdaycycle.h @@ -45,7 +45,7 @@ struct WLFloatControl; struct LLWLSkyKey { public: - LLString presetName; + std::string presetName; F32 time; }; @@ -60,7 +60,7 @@ public: /// help button stuff static void onClickHelp(void* data); - void initHelpBtn(const char* name, const char* xml_alert); + void initHelpBtn(const std::string& name, const std::string& xml_alert); /// initialize all void initCallbacks(void); @@ -93,7 +93,7 @@ public: static void onAddKey(void* userData); /// delete any and all reference to a preset - void deletePreset(LLString& presetName); + void deletePreset(std::string& presetName); /// delete a key frame static void onDeleteKey(void* userData); @@ -129,7 +129,7 @@ public: static void syncTrack(); /// add a slider to the track - static void addSliderKey(F32 time, const LLString& presetName); + static void addSliderKey(F32 time, const std::string& presetName); private: @@ -137,7 +137,7 @@ private: static LLFloaterDayCycle* sDayCycle; // map of sliders to parameters - static std::map<LLString, LLWLSkyKey> sSliderToKey; + static std::map<std::string, LLWLSkyKey> sSliderToKey; static const F32 sHoursPerDay; }; diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index 8570515f07..b28cc04047 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -53,7 +53,7 @@ LLFloaterEnvSettings* LLFloaterEnvSettings::sEnvSettings = NULL; -LLFloaterEnvSettings::LLFloaterEnvSettings() : LLFloater("Environment Settings Floater") +LLFloaterEnvSettings::LLFloaterEnvSettings() : LLFloater(std::string("Environment Settings Floater")) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_env_settings.xml"); @@ -110,7 +110,7 @@ void LLFloaterEnvSettings::syncMenu() // sync the clock F32 val = (F32)LLWLParamManager::instance()->mAnimator.getDayTime(); - LLString timeStr = timeToString(val); + std::string timeStr = timeToString(val); LLTextBox* textBox; textBox = sEnvSettings->getChild<LLTextBox>("EnvTimeText"); @@ -308,7 +308,7 @@ void LLFloaterEnvSettings::onUseEstateTime(void* userData) LLWLParamManager::instance()->mAnimator.mUseLindenTime = true; } -LLString LLFloaterEnvSettings::timeToString(F32 curTime) +std::string LLFloaterEnvSettings::timeToString(F32 curTime) { S32 hours; S32 min; diff --git a/indra/newview/llfloaterenvsettings.h b/indra/newview/llfloaterenvsettings.h index 2ac555083e..4208e7c0b9 100644 --- a/indra/newview/llfloaterenvsettings.h +++ b/indra/newview/llfloaterenvsettings.h @@ -95,7 +95,7 @@ public: void syncMenu(); /// convert the present time to a digital clock time - LLString timeToString(F32 curTime); + std::string timeToString(F32 curTime); private: // one instance on the inside diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp index b7e50145c3..55d9aeead9 100644 --- a/indra/newview/llfloaterfriends.cpp +++ b/indra/newview/llfloaterfriends.cpp @@ -200,8 +200,8 @@ BOOL LLPanelFriends::postBuild() refreshUI(); // primary sort = online status, secondary sort = name - mFriendsList->sortByColumn("friend_name", TRUE); - mFriendsList->sortByColumn("icon_online_status", FALSE); + mFriendsList->sortByColumn(std::string("friend_name"), TRUE); + mFriendsList->sortByColumn(std::string("icon_online_status"), FALSE); return TRUE; } @@ -274,7 +274,7 @@ BOOL LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationsh std::string fullname; BOOL have_name = gCacheName->getFullName(agent_id, fullname); - itemp->getColumn(LIST_ONLINE_STATUS)->setValue(info->isOnline() ? "icon_avatar_online.tga" : LLString::null); + itemp->getColumn(LIST_ONLINE_STATUS)->setValue(info->isOnline() ? std::string("icon_avatar_online.tga") : LLStringUtil::null); itemp->getColumn(LIST_FRIEND_NAME)->setValue(fullname); // render name of online friends in bold text ((LLScrollListText*)itemp->getColumn(LIST_FRIEND_NAME))->setFontStyle(info->isOnline() ? LLFontGL::BOLD : LLFontGL::NORMAL); @@ -443,7 +443,7 @@ void LLPanelFriends::refreshUI() } else { - childSetText("friend_name_label", LLString::null); + childSetText("friend_name_label", LLStringUtil::null); } @@ -488,7 +488,7 @@ void LLPanelFriends::onSelectName(LLUICtrl* ctrl, void* user_data) //static void LLPanelFriends::onMaximumSelect(void* user_data) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MAX_SELECT]"] = llformat("%d", MAX_FRIEND_SELECT); LLNotifyBox::showXml("MaxListSelectMessage", args); }; @@ -539,14 +539,14 @@ void LLPanelFriends::onClickIM(void* user_data) } // static -void LLPanelFriends::requestFriendship(const LLUUID& target_id, const LLString& target_name) +void LLPanelFriends::requestFriendship(const LLUUID& target_id, const std::string& target_name) { // HACK: folder id stored as "message" LLUUID calling_card_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD); std::string message = calling_card_folder_id.asString(); send_improved_im(target_id, - target_name.c_str(), - message.c_str(), + target_name, + message, IM_ONLINE, IM_FRIENDSHIP_OFFERED); } @@ -593,7 +593,7 @@ void LLPanelFriends::requestFriendshipDialog(const LLUUID& id, data->mName = name; // TODO: accept a line of text with this dialog - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = name; gViewerWindow->alertXml("AddFriend", args, callbackAddFriend, data); } @@ -617,10 +617,10 @@ void LLPanelFriends::onClickRemove(void* user_data) //llinfos << "LLPanelFriends::onClickRemove()" << llendl; LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs(); - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; if(ids.size() > 0) { - LLString msgType = "RemoveFromFriends"; + std::string msgType = "RemoveFromFriends"; if(ids.size() == 1) { LLUUID agent_id = ids[0]; @@ -670,7 +670,7 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command { if (ids.empty()) return; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; if(ids.size() > 0) { // copy map of ids onto heap diff --git a/indra/newview/llfloaterfriends.h b/indra/newview/llfloaterfriends.h index 2e87688f8e..211c6cf487 100644 --- a/indra/newview/llfloaterfriends.h +++ b/indra/newview/llfloaterfriends.h @@ -79,7 +79,7 @@ public: // Just request friendship, no dialog. static void requestFriendship(const LLUUID& target_id, - const LLString& target_name); + const std::string& target_name); private: @@ -138,7 +138,7 @@ private: // member data LLFriendObserver* mObserver; LLUUID mAddFriendID; - LLString mAddFriendName; + std::string mAddFriendName; LLScrollListCtrl* mFriendsList; BOOL mShowMaxSelectWarning; BOOL mAllowRightsChange; diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index e361309a61..03c13bb913 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -65,7 +65,7 @@ LLFloaterGestureObserver* LLFloaterGesture::sObserver = NULL; BOOL item_name_precedes( LLInventoryItem* a, LLInventoryItem* b ) { - return LLString::precedesDict( a->getName(), b->getName() ); + return LLStringUtil::precedesDict( a->getName(), b->getName() ); } class LLFloaterGestureObserver : public LLGestureManagerObserver @@ -80,7 +80,7 @@ public: // LLFloaterGesture //--------------------------------------------------------------------------- LLFloaterGesture::LLFloaterGesture() -: LLFloater("Gesture Floater") +: LLFloater(std::string("Gesture Floater")) { sInstance = this; @@ -105,7 +105,7 @@ LLFloaterGesture::~LLFloaterGesture() // virtual BOOL LLFloaterGesture::postBuild() { - LLString label; + std::string label; // Translate title label = getTitle(); @@ -159,7 +159,7 @@ void LLFloaterGesture::show() if (list) { const BOOL ascending = TRUE; - list->sortByColumn("name", ascending); + list->sortByColumn(std::string("name"), ascending); list->selectFirstItem(); } @@ -236,7 +236,7 @@ void LLFloaterGesture::buildGestureList() item_name = item->getName(); } - LLString font_style = "NORMAL"; + std::string font_style = "NORMAL"; // If gesture is playing, bold it LLSD element; @@ -254,8 +254,8 @@ void LLFloaterGesture::buildGestureList() element["columns"][0]["font"] = "SANSSERIF"; element["columns"][0]["font-style"] = font_style; - LLString key_string = LLKeyboard::stringFromKey(gesture->mKey); - LLString buffer; + std::string key_string = LLKeyboard::stringFromKey(gesture->mKey); + std::string buffer; { if (gesture->mKey == KEY_NONE) @@ -356,22 +356,22 @@ void LLFloaterGesture::onClickPlay(void* data) class GestureShowCallback : public LLInventoryCallback { public: - GestureShowCallback(LLString &title) + GestureShowCallback(std::string &title) { mTitle = title; } void fire(const LLUUID &inv_item) { - LLPreviewGesture::show(mTitle.c_str(), inv_item, LLUUID::null); + LLPreviewGesture::show(mTitle, inv_item, LLUUID::null); } private: - LLString mTitle; + std::string mTitle; }; // static void LLFloaterGesture::onClickNew(void* data) { - LLString title("Gesture: "); + std::string title("Gesture: "); title.append("New Gesture"); LLPointer<LLInventoryCallback> cb = new GestureShowCallback(title); create_inventory_item(gAgent.getID(), gAgent.getSessionID(), @@ -392,7 +392,7 @@ void LLFloaterGesture::onClickEdit(void* data) LLInventoryItem* item = gInventory.getItem(item_id); if (!item) return; - LLString title("Gesture: "); + std::string title("Gesture: "); title.append(item->getName()); LLPreviewGesture* previewp = LLPreviewGesture::show(title, item_id, LLUUID::null); diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp index c919302424..a4022d844a 100644 --- a/indra/newview/llfloatergodtools.cpp +++ b/indra/newview/llfloatergodtools.cpp @@ -115,7 +115,7 @@ void LLFloaterGodTools::refreshAll() LLFloaterGodTools::LLFloaterGodTools() -: LLFloater("godtools floater"), +: LLFloater(std::string("godtools floater")), mCurrentHost(LLHost::invalid), mUpdateTimer() { @@ -224,7 +224,7 @@ void LLFloaterGodTools::show(void *) } } -void LLFloaterGodTools::showPanel(const LLString& panel_name) +void LLFloaterGodTools::showPanel(const std::string& panel_name) { childShowTab("GodTools Tabs", panel_name); open(); /*Flawfinder: ignore*/ @@ -258,7 +258,7 @@ void LLFloaterGodTools::processRegionInfo(LLMessageSystem* msg) U32 region_flags; U8 sim_access; U8 agent_limit; - char sim_name[MAX_STRING]; /*Flawfinder: ignore*/ + std::string sim_name; U32 estate_id; U32 parent_estate_id; F32 water_height; @@ -271,7 +271,7 @@ void LLFloaterGodTools::processRegionInfo(LLMessageSystem* msg) S32 redirect_grid_y; LLUUID cache_id; - msg->getStringFast(_PREHASH_RegionInfo, _PREHASH_SimName, MAX_STRING, sim_name); + msg->getStringFast(_PREHASH_RegionInfo, _PREHASH_SimName, sim_name); msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_EstateID, estate_id); msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_ParentEstateID, parent_estate_id); msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_RegionFlags, region_flags); @@ -375,7 +375,7 @@ void LLFloaterGodTools::sendGodUpdateRegionInfo() msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_RegionInfo); - msg->addStringFast(_PREHASH_SimName, rtool->getSimName().c_str()); + msg->addStringFast(_PREHASH_SimName, rtool->getSimName()); msg->addU32Fast(_PREHASH_EstateID, rtool->getEstateID()); msg->addU32Fast(_PREHASH_ParentEstateID, rtool->getParentEstateID()); msg->addU32Fast(_PREHASH_RegionFlags, computeRegionFlags()); @@ -707,7 +707,7 @@ S32 LLPanelRegionTools::getPricePerMeter() const return childGetValue("land cost"); } -void LLPanelRegionTools::setSimName(char *name) +void LLPanelRegionTools::setSimName(const std::string& name) { childSetValue("region name", name); } @@ -924,13 +924,13 @@ void LLPanelGridTools::onClickKickAll(void* userdata) gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect(left, top, left+400, top-300); - gViewerWindow->alertXmlEditText("KickAllUsers", LLString::format_map_t(), + gViewerWindow->alertXmlEditText("KickAllUsers", LLStringUtil::format_map_t(), NULL, NULL, LLPanelGridTools::confirmKick, self); } -void LLPanelGridTools::confirmKick(S32 option, const LLString& text, void* userdata) +void LLPanelGridTools::confirmKick(S32 option, const std::string& text, void* userdata) { LLPanelGridTools* self = (LLPanelGridTools*) userdata; @@ -957,7 +957,7 @@ void LLPanelGridTools::finishKick(S32 option, void* userdata) msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_AgentID, LL_UUID_ALL_AGENTS ); msg->addU32("KickFlags", KICK_FLAGS_DEFAULT ); - msg->addStringFast(_PREHASH_Reason, self->mKickMessage.c_str() ); + msg->addStringFast(_PREHASH_Reason, self->mKickMessage ); gAgent.sendReliableMessage(); } } @@ -1182,7 +1182,7 @@ void LLPanelObjectTools::onClickDeletePublicOwnedBy(void* userdata) panelp->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY | SWD_OTHERS_LAND_ONLY; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); gViewerWindow->alertXml( "GodDeleteAllScriptedPublicObjectsByUser", @@ -1201,7 +1201,7 @@ void LLPanelObjectTools::onClickDeleteAllScriptedOwnedBy(void* userdata) { panelp->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); gViewerWindow->alertXml( "GodDeleteAllScriptedObjectsByUser", @@ -1220,7 +1220,7 @@ void LLPanelObjectTools::onClickDeleteAllOwnedBy(void* userdata) { panelp->mSimWideDeletesFlags = 0; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); gViewerWindow->alertXml( "GodDeleteAllObjectsByUser", @@ -1260,12 +1260,12 @@ void LLPanelObjectTools::onClickSetBySelection(void* data) LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(NULL, non_root_ok); if (!node) return; - LLString owner_name; + std::string owner_name; LLUUID owner_id; LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); panelp->mTargetAvatar = owner_id; - LLString name = "Object " + node->mName + " owned by " + owner_name; + std::string name = "Object " + node->mName + " owned by " + owner_name; panelp->childSetValue("target_avatar_name", name); } @@ -1314,8 +1314,8 @@ void LLPanelObjectTools::onApplyChanges(void* userdata) // LLPanelRequestTools // -------------------- -const char SELECTION[] = "Selection"; -const char AGENT_REGION[] = "Agent Region"; +const std::string SELECTION = "Selection"; +const std::string AGENT_REGION = "Agent Region"; LLPanelRequestTools::LLPanelRequestTools(const std::string& name): LLPanel(name) @@ -1348,7 +1348,7 @@ void LLPanelRequestTools::refresh() iter != LLWorld::getInstance()->mActiveRegionList.end(); ++iter) { LLViewerRegion* regionp = *iter; - LLString name = regionp->getName(); + std::string name = regionp->getName(); if (!name.empty()) { list->addSimpleElement(name); @@ -1366,8 +1366,8 @@ void LLPanelRequestTools::refresh() // static -void LLPanelRequestTools::sendRequest(const char *request, - const char *parameter, +void LLPanelRequestTools::sendRequest(const std::string& request, + const std::string& parameter, const LLHost& host) { llinfos << "Sending request '" << request << "', '" @@ -1437,7 +1437,7 @@ void LLPanelRequestTools::sendRequest(const LLHost& host) std::string req = childGetValue("request"); if (req == "terrain download") { - gXferManager->requestFile("terrain.raw", "terrain.raw", LL_PATH_NONE, + gXferManager->requestFile(std::string("terrain.raw"), std::string("terrain.raw"), LL_PATH_NONE, host, FALSE, terrain_download_done, @@ -1446,7 +1446,7 @@ void LLPanelRequestTools::sendRequest(const LLHost& host) else { req = req.substr(0, req.find_first_of(" ")); - sendRequest(req.c_str(), childGetValue("parameter").asString().c_str(), host); + sendRequest(req, childGetValue("parameter").asString(), host); } } diff --git a/indra/newview/llfloatergodtools.h b/indra/newview/llfloatergodtools.h index 53e250f67e..7cc840cc97 100644 --- a/indra/newview/llfloatergodtools.h +++ b/indra/newview/llfloatergodtools.h @@ -81,7 +81,7 @@ public: static void refreshAll(); - void showPanel(const LLString& panel_name); + void showPanel(const std::string& panel_name); virtual void onClose(bool app_quitting); @@ -164,7 +164,7 @@ public: S32 getRedirectGridY() const; // set internal checkboxes/spinners/combos - void setSimName(char *name); + void setSimName(const std::string& name); void setEstateID(U32 id); void setParentEstateID(U32 id); void setCheckFlags(U32 flags); @@ -201,14 +201,14 @@ public: void refresh(); static void onClickKickAll(void *data); - static void confirmKick(S32 option, const LLString& text, void* userdata); + static void confirmKick(S32 option, const std::string& text, void* userdata); static void finishKick(S32 option, void* userdata); static void onDragSunPhase(LLUICtrl *ctrl, void *userdata); static void onClickFlushMapVisibilityCaches(void* data); static void flushMapVisibilityCachesConfirm(S32 option, void* data); protected: - LLString mKickMessage; // Message to send on kick + std::string mKickMessage; // Message to send on kick }; @@ -268,8 +268,8 @@ public: void refresh(); - static void sendRequest(const char* request, - const char* parameter, + static void sendRequest(const std::string& request, + const std::string& parameter, const LLHost& host); protected: diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp index d67ae2de2d..a85b4ec0e9 100644 --- a/indra/newview/llfloatergroups.cpp +++ b/indra/newview/llfloatergroups.cpp @@ -389,7 +389,7 @@ void LLPanelGroups::leave() if(i < count) { LLUUID* cb_data = new LLUUID((const LLUUID&)group_id); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[GROUP]"] = gAgent.mGroups.get(i).mName; gViewerWindow->alertXml("GroupLeaveConfirmMember", args, callbackLeaveGroup, (void*)cb_data); } @@ -439,7 +439,7 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 pow id = gAgent.mGroups.get(i).mID; LLGroupData* group_datap = &gAgent.mGroups.get(i); if ((group_datap->mPowers & powers_mask) != 0) { - LLString style = "NORMAL"; + std::string style = "NORMAL"; if(highlight_id == id) { style = "BOLD"; @@ -458,7 +458,7 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 pow // add "none" to list at top { - LLString style = "NORMAL"; + std::string style = "NORMAL"; if (highlight_id.isNull()) { style = "BOLD"; diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp index d58517ee92..e4c13b2ae4 100644 --- a/indra/newview/llfloaterhardwaresettings.cpp +++ b/indra/newview/llfloaterhardwaresettings.cpp @@ -47,7 +47,7 @@ LLFloaterHardwareSettings* LLFloaterHardwareSettings::sHardwareSettings = NULL; -LLFloaterHardwareSettings::LLFloaterHardwareSettings() : LLFloater("Hardware Settings Floater") +LLFloaterHardwareSettings::LLFloaterHardwareSettings() : LLFloater(std::string("Hardware Settings Floater")) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_hardware_settings.xml"); diff --git a/indra/newview/llfloaterhud.cpp b/indra/newview/llfloaterhud.cpp index 12b1f0b4f1..c5cb6a91d5 100644 --- a/indra/newview/llfloaterhud.cpp +++ b/indra/newview/llfloaterhud.cpp @@ -26,7 +26,7 @@ std::string LLFloaterHUD::sTutorialUrl = ""; // Default constructor LLFloaterHUD::LLFloaterHUD() -: LLFloater("floater_hud"), +: LLFloater(std::string("floater_hud")), mWebBrowser(0) { // Create floater from its XML definition @@ -59,7 +59,7 @@ LLFloaterHUD::LLFloaterHUD() // arrow keys during tutorial). mWebBrowser->setTakeFocusOnClick(false); - LLString language(gSavedSettings.getString("Language")); + std::string language(gSavedSettings.getString("Language")); if(language == "default") { language = gSavedSettings.getString("SystemLanguage"); @@ -97,7 +97,7 @@ LLFloaterHUD::~LLFloaterHUD() } // Show the HUD -void LLFloaterHUD::show() +void LLFloaterHUD::showHUD() { // do not build the floater if there the url is empty if (sTutorialUrl == "") @@ -112,7 +112,7 @@ void LLFloaterHUD::show() hud->setFrontmost(FALSE); } -void LLFloaterHUD::close() +void LLFloaterHUD::closeHUD() { if (sInstance) sInstance->close(); } diff --git a/indra/newview/llfloaterhud.h b/indra/newview/llfloaterhud.h index 06da9fb44e..975ab2daf5 100644 --- a/indra/newview/llfloaterhud.h +++ b/indra/newview/llfloaterhud.h @@ -29,8 +29,8 @@ public: static std::string sTutorialUrl; - static void show(); ///< show the HUD - static void close(); ///< close the HUD (destroys floater) + static void showHUD(); ///< show the HUD + static void closeHUD(); ///< close the HUD (destroys floater) protected: LLWebBrowserCtrl* mWebBrowser; ///< the actual web browser control diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index 830b38faf8..50b8b39bd0 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -68,13 +68,13 @@ const S32 PREVIEW_TEXTURE_HEIGHT = 300; //----------------------------------------------------------------------------- // LLFloaterImagePreview() //----------------------------------------------------------------------------- -LLFloaterImagePreview::LLFloaterImagePreview(const char* filename) : +LLFloaterImagePreview::LLFloaterImagePreview(const std::string& filename) : LLFloaterNameDesc(filename) { mLastMouseX = 0; mLastMouseY = 0; mGLName = 0; - loadImage(mFilenameAndPath.c_str()); + loadImage(mFilenameAndPath); } //----------------------------------------------------------------------------- @@ -314,28 +314,25 @@ void LLFloaterImagePreview::draw() //----------------------------------------------------------------------------- // loadImage() //----------------------------------------------------------------------------- -bool LLFloaterImagePreview::loadImage(const char *src_filename) +bool LLFloaterImagePreview::loadImage(const std::string& src_filename) { - // U32 length = strlen(src_filename); - const char* ext = strrchr(src_filename, '.'); - char error_message[MAX_STRING]; - error_message[0] = '\0'; - + std::string exten = gDirUtilp->getExtension(src_filename); + U32 codec = IMG_CODEC_INVALID; - LLString temp_str; - if( 0 == strnicmp(ext, ".bmp", 4) ) + std::string temp_str; + if( exten == "bmp") { codec = IMG_CODEC_BMP; } - else if( 0 == strnicmp(ext, ".tga", 4) ) + else if( exten == "tga") { codec = IMG_CODEC_TGA; } - else if( 0 == strnicmp(ext, ".jpg", 4) || 0 == strnicmp(ext, ".jpeg", 5)) + else if( exten == "jpg" || exten == "jpeg") { codec = IMG_CODEC_JPEG; } - else if( 0 == strnicmp(ext, ".png", 4) ) + else if( exten == "png" ) { codec = IMG_CODEC_PNG; } @@ -629,7 +626,7 @@ LLImagePreviewAvatar::~LLImagePreviewAvatar() } -void LLImagePreviewAvatar::setPreviewTarget(const char* joint_name, const char* mesh_name, LLImageRaw* imagep, F32 distance, BOOL male) +void LLImagePreviewAvatar::setPreviewTarget(const std::string& joint_name, const std::string& mesh_name, LLImageRaw* imagep, F32 distance, BOOL male) { mTargetJoint = mDummyAvatar->mRoot.findJoint(joint_name); // clear out existing test mesh diff --git a/indra/newview/llfloaterimagepreview.h b/indra/newview/llfloaterimagepreview.h index 365dc7eefd..0376ec2bcb 100644 --- a/indra/newview/llfloaterimagepreview.h +++ b/indra/newview/llfloaterimagepreview.h @@ -76,7 +76,7 @@ public: LLImagePreviewAvatar(S32 width, S32 height); virtual ~LLImagePreviewAvatar(); - void setPreviewTarget(const char* joint_name, const char *mesh_name, LLImageRaw* imagep, F32 distance, BOOL male); + void setPreviewTarget(const std::string& joint_name, const std::string& mesh_name, LLImageRaw* imagep, F32 distance, BOOL male); void setTexture(U32 name) { mTextureName = name; } BOOL render(); @@ -102,7 +102,7 @@ protected: class LLFloaterImagePreview : public LLFloaterNameDesc { public: - LLFloaterImagePreview(const char* filename); + LLFloaterImagePreview(const std::string& filename); virtual ~LLFloaterImagePreview(); virtual BOOL postBuild(); @@ -118,7 +118,7 @@ public: protected: static void onPreviewTypeCommit(LLUICtrl*,void*); void draw(); - bool loadImage(const char* filename); + bool loadImage(const std::string& filename); LLPointer<LLImageRaw> mRawImagep; LLImagePreviewAvatar* mAvatarPreview; diff --git a/indra/newview/llfloaterinspect.cpp b/indra/newview/llfloaterinspect.cpp index a2e26d27a8..16c26ac588 100644 --- a/indra/newview/llfloaterinspect.cpp +++ b/indra/newview/llfloaterinspect.cpp @@ -45,7 +45,7 @@ LLFloaterInspect* LLFloaterInspect::sInstance = NULL; LLFloaterInspect::LLFloaterInspect(void) : - LLFloater("Inspect Object"), + LLFloater(std::string("Inspect Object")), mDirty(FALSE) { sInstance = this; @@ -188,7 +188,7 @@ LLUUID LLFloaterInspect::getSelectedUUID() void LLFloaterInspect::refresh() { LLUUID creator_id; - LLString creator_name; + std::string creator_name; S32 pos = mObjectList->getScrollPos(); childSetEnabled("button owner", false); childSetEnabled("button creator", false); @@ -214,7 +214,7 @@ void LLFloaterInspect::refresh() char time[MAX_STRING]; std::string owner_name, creator_name; time_t timestamp = (time_t) (obj->mCreationDate/1000000); - LLString::copy(time, ctime(×tamp), MAX_STRING); + LLStringUtil::copy(time, ctime(×tamp), MAX_STRING); time[24] = '\0'; gCacheName->getFullName(obj->mPermissions->getOwner(), owner_name); gCacheName->getFullName(obj->mPermissions->getCreator(), creator_name); @@ -225,7 +225,7 @@ void LLFloaterInspect::refresh() // or top of the editable chain, for attachments if(!(obj->getObject()->isRoot() || obj->getObject()->isRootEdit())) { - row["columns"][0]["value"] = LLString(" ") + obj->mName; + row["columns"][0]["value"] = std::string(" ") + obj->mName; } else { diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp index 040ca8013e..de88b490d9 100644 --- a/indra/newview/llfloaterjoystick.cpp +++ b/indra/newview/llfloaterjoystick.cpp @@ -46,7 +46,7 @@ #include "llviewerjoystick.h" LLFloaterJoystick::LLFloaterJoystick(const LLSD& data) - : LLFloater("floater_joystick") + : LLFloater(std::string("floater_joystick")) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_joystick.xml"); center(); diff --git a/indra/newview/llfloaterlagmeter.cpp b/indra/newview/llfloaterlagmeter.cpp index b70ae9a227..96e4c819a8 100644 --- a/indra/newview/llfloaterlagmeter.cpp +++ b/indra/newview/llfloaterlagmeter.cpp @@ -45,12 +45,12 @@ #include "llfocusmgr.h" #include "lltextbox.h" -const LLString LAG_CRITICAL_IMAGE_NAME = "lag_status_critical.tga"; -const LLString LAG_WARNING_IMAGE_NAME = "lag_status_warning.tga"; -const LLString LAG_GOOD_IMAGE_NAME = "lag_status_good.tga"; +const std::string LAG_CRITICAL_IMAGE_NAME = "lag_status_critical.tga"; +const std::string LAG_WARNING_IMAGE_NAME = "lag_status_warning.tga"; +const std::string LAG_GOOD_IMAGE_NAME = "lag_status_good.tga"; LLFloaterLagMeter::LLFloaterLagMeter(const LLSD& key) - : LLFloater("floater_lagmeter") + : LLFloater(std::string("floater_lagmeter")) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_lagmeter.xml"); @@ -70,7 +70,7 @@ LLFloaterLagMeter::LLFloaterLagMeter(const LLSD& key) mServerText = getChild<LLTextBox>("server_text"); mServerCause = getChild<LLTextBox>("server_lag_cause"); - LLString config_string = getString("client_frame_rate_critical_fps", mStringArgs); + std::string config_string = getString("client_frame_rate_critical_fps", mStringArgs); mClientFrameTimeCritical = 1.0f / (float)atof( config_string.c_str() ); config_string = getString("client_frame_rate_warning_fps", mStringArgs); mClientFrameTimeWarning = 1.0f / (float)atof( config_string.c_str() ); @@ -152,7 +152,7 @@ void LLFloaterLagMeter::determineClient() { mClientButton->setImageUnselected(LAG_GOOD_IMAGE_NAME); mClientText->setText( getString("client_frame_time_window_bg_msg", mStringArgs) ); - mClientCause->setText( LLString::null ); + mClientCause->setText( LLStringUtil::null ); } else if(client_frame_time >= mClientFrameTimeCritical) { @@ -170,7 +170,7 @@ void LLFloaterLagMeter::determineClient() { mClientButton->setImageUnselected(LAG_GOOD_IMAGE_NAME); mClientText->setText( getString("client_frame_time_normal_msg", mStringArgs) ); - mClientCause->setText( LLString::null ); + mClientCause->setText( LLStringUtil::null ); } if(find_cause) @@ -241,7 +241,7 @@ void LLFloaterLagMeter::determineNetwork() } else { - mNetworkCause->setText( LLString::null ); + mNetworkCause->setText( LLStringUtil::null ); } } @@ -266,7 +266,7 @@ void LLFloaterLagMeter::determineServer() { mServerButton->setImageUnselected(LAG_GOOD_IMAGE_NAME); mServerText->setText( getString("server_frame_time_normal_msg", mStringArgs) ); - mServerCause->setText( LLString::null ); + mServerCause->setText( LLStringUtil::null ); } if(find_cause) diff --git a/indra/newview/llfloaterlagmeter.h b/indra/newview/llfloaterlagmeter.h index 6a034c840c..eca043398a 100644 --- a/indra/newview/llfloaterlagmeter.h +++ b/indra/newview/llfloaterlagmeter.h @@ -75,7 +75,7 @@ private: LLTextBox * mServerText; LLTextBox * mServerCause; - LLString::format_map_t mStringArgs; + LLStringUtil::format_map_t mStringArgs; }; #endif diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 595f4afd72..58ad07c5bb 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -31,6 +31,9 @@ #include "llviewerprecompiledheaders.h" +#include <sstream> +#include <time.h> + #include "llfloaterland.h" #include "llcachename.h" @@ -70,39 +73,9 @@ #include "llviewercontrol.h" #include "roles_constants.h" -#include <sstream> -#include <time.h> - -static const S32 EDIT_HEIGHT = 16; -static const S32 LEFT = HPAD; -static const S32 BOTTOM = VPAD; -static const S32 RULER0 = LEFT; -static const S32 RULER05 = RULER0 + 24; -static const S32 RULER1 = RULER05 + 16; -static const S32 RULER15 = RULER1 + 20; -static const S32 RULER2 = RULER1 + 32; -static const S32 RULER205= RULER2 + 32; -static const S32 RULER20 = RULER2 + 64; -static const S32 RULER21 = RULER20 + 16; -static const S32 RULER22 = RULER21 + 32; -static const S32 RULER225 = RULER20 + 64; -static const S32 RULER23 = RULER22 + 64; -static const S32 RULER24 = RULER23 + 26; -static const S32 RULER3 = RULER2 + 102; -static const S32 RULER4 = RULER3 + 8; -static const S32 RULER5 = RULER4 + 50; -static const S32 RULER6 = RULER5 + 52; -static const S32 RULER7 = RULER6 + 24; -static const S32 RIGHT = LEFT + 278; -static const S32 FAR_RIGHT = LEFT + 324 + 40; - -static const char PRICE[] = "Price:"; -static const char NO_PRICE[] = ""; -static const char AREA[] = "Area:"; - -static const char OWNER_ONLINE[] = "0"; -static const char OWNER_OFFLINE[] = "1"; -static const char OWNER_GROUP[] = "2"; +static std::string OWNER_ONLINE = "0"; +static std::string OWNER_OFFLINE = "1"; +static std::string OWNER_GROUP = "2"; // constants used in callbacks below - syntactic sugar. static const BOOL BUY_GROUP_LAND = TRUE; @@ -219,11 +192,11 @@ void LLFloaterLand::onClose(bool app_quitting) LLFloaterLand::LLFloaterLand(const LLSD& seed) -: LLFloater("floaterland", "FloaterLandRect5", "About Land") +: LLFloater(std::string("floaterland"), std::string("FloaterLandRect5"), std::string("About Land")) { - std::map<LLString, LLCallbackMap> factory_map; + LLCallbackMap::map_t factory_map; factory_map["land_general_panel"] = LLCallbackMap(createPanelLandGeneral, this); @@ -325,7 +298,7 @@ void* LLFloaterLand::createPanelLandAccess(void* data) LLPanelLandGeneral::LLPanelLandGeneral(LLParcelSelectionHandle& parcel) -: LLPanel("land_general_panel"), +: LLPanel(std::string("land_general_panel")), mUncheckedSell(FALSE), mParcel(parcel) { @@ -458,12 +431,12 @@ void LLPanelLandGeneral::refresh() { // nothing selected, disable panel mEditName->setEnabled(FALSE); - mEditName->setText(LLString::null); + mEditName->setText(LLStringUtil::null); mEditDesc->setEnabled(FALSE); - mEditDesc->setText(LLString::null); + mEditDesc->setText(LLStringUtil::null); - mTextSalePending->setText(LLString::null); + mTextSalePending->setText(LLStringUtil::null); mTextSalePending->setEnabled(FALSE); mBtnDeedToGroup->setEnabled(FALSE); @@ -475,13 +448,13 @@ void LLPanelLandGeneral::refresh() mCheckContributeWithDeed->set(FALSE); mCheckContributeWithDeed->setEnabled(FALSE); - mTextOwner->setText(LLString::null); + mTextOwner->setText(LLStringUtil::null); mBtnProfile->setLabel(getString("profile_text")); mBtnProfile->setEnabled(FALSE); - mTextClaimDate->setText(LLString::null); - mTextGroup->setText(LLString::null); - mTextPrice->setText(LLString::null); + mTextClaimDate->setText(LLStringUtil::null); + mTextGroup->setText(LLStringUtil::null); + mTextPrice->setText(LLStringUtil::null); mSaleInfoForSale1->setVisible(FALSE); mSaleInfoForSale2->setVisible(FALSE); @@ -491,8 +464,8 @@ void LLPanelLandGeneral::refresh() mBtnSellLand->setVisible(FALSE); mBtnStopSellLand->setVisible(FALSE); - mTextPriceLabel->setText(LLString::null); - mTextDwell->setText(LLString::null); + mTextPriceLabel->setText(LLStringUtil::null); + mTextDwell->setText(LLStringUtil::null); mBtnBuyLand->setEnabled(FALSE); mBtnBuyGroupLand->setEnabled(FALSE); @@ -528,12 +501,12 @@ void LLPanelLandGeneral::refresh() // Is it owned? if (is_public) { - mTextSalePending->setText(LLString::null); + mTextSalePending->setText(LLStringUtil::null); mTextSalePending->setEnabled(FALSE); mTextOwner->setText(getString("public_text")); mTextOwner->setEnabled(FALSE); mBtnProfile->setEnabled(FALSE); - mTextClaimDate->setText(LLString::null); + mTextClaimDate->setText(LLStringUtil::null); mTextClaimDate->setEnabled(FALSE); mTextGroup->setText(getString("none_text")); mTextGroup->setEnabled(FALSE); @@ -555,7 +528,7 @@ void LLPanelLandGeneral::refresh() else { // not the owner, or it is leased - mTextSalePending->setText(LLString::null); + mTextSalePending->setText(LLStringUtil::null); mTextSalePending->setEnabled(FALSE); } //refreshNames(); @@ -584,8 +557,7 @@ void LLPanelLandGeneral::refresh() // Display claim date // *TODO:Localize (Time format may need Translating) time_t claim_date = parcel->getClaimDate(); - char time_buf[TIME_STR_LENGTH]; /*Flawfinder: ignore*/ - mTextClaimDate->setText(LLString(formatted_time(claim_date, time_buf))); + mTextClaimDate->setText(formatted_time(claim_date)); mTextClaimDate->setEnabled(is_leased); BOOL enable_auction = (gAgent.getGodLevel() >= GOD_LIAISON) @@ -718,11 +690,11 @@ void LLPanelLandGeneral::refreshNames() LLParcel *parcel = mParcel->getParcel(); if (!parcel) { - mTextOwner->setText(LLString::null); + mTextOwner->setText(LLStringUtil::null); return; } - LLString owner; + std::string owner; if (parcel->getIsGroupOwned()) { owner = getString("group_owned_text"); @@ -739,7 +711,7 @@ void LLPanelLandGeneral::refreshNames() } mTextOwner->setText(owner); - LLString group; + std::string group; if(!parcel->getGroupID().isNull()) { gCacheName->getGroupName(parcel->getGroupID(), group); @@ -749,7 +721,7 @@ void LLPanelLandGeneral::refreshNames() const LLUUID& auth_buyer_id = parcel->getAuthorizedBuyerID(); if(auth_buyer_id.notNull()) { - LLString name; + std::string name; gCacheName->getFullName(auth_buyer_id, name); mSaleInfoForSale2->setTextArg("[BUYER]", name); } @@ -885,14 +857,14 @@ void LLPanelLandGeneral::onClickBuyPass(void* data) if (!parcel) return; S32 pass_price = parcel->getPassPrice(); - LLString parcel_name = parcel->getName(); + std::string parcel_name = parcel->getName(); F32 pass_hours = parcel->getPassHours(); - char cost[256], time[256]; /*Flawfinder: ignore*/ - snprintf(cost, sizeof(cost), "%d", pass_price); /* Flawfinder: ignore */ - snprintf(time, sizeof(time), "%.2f", pass_hours); /* Flawfinder: ignore */ + std::string cost, time; + cost = llformat("%d", pass_price); + time = llformat("%.2f", pass_hours); - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[COST]"] = cost; args["[PARCEL_NAME]"] = parcel_name; args["[TIME]"] = time; @@ -952,8 +924,8 @@ void LLPanelLandGeneral::onCommitAny(LLUICtrl *ctrl, void *userdata) // Valid data from UI // Stuff data into selected parcel - parcel->setName(name.c_str()); - parcel->setDesc(desc.c_str()); + parcel->setName(name); + parcel->setDesc(desc); BOOL allow_deed_to_group= panelp->mCheckDeedToGroup->get(); BOOL contribute_with_deed = panelp->mCheckContributeWithDeed->get(); @@ -991,7 +963,7 @@ void LLPanelLandGeneral::onClickStopSellLand(void* data) // LLPanelLandObjects //--------------------------------------------------------------------------- LLPanelLandObjects::LLPanelLandObjects(LLParcelSelectionHandle& parcel) -: LLPanel("land_objects_panel"), mParcel(parcel) +: LLPanel(std::string("land_objects_panel")), mParcel(parcel) { } @@ -1047,7 +1019,7 @@ BOOL LLPanelLandObjects::postBuild() mIconGroup = LLUIImageList::getInstance()->getUIImage("icon_group.tga"); mOwnerList = getChild<LLNameListCtrl>("owner list"); - mOwnerList->sortByColumn(3, FALSE); + mOwnerList->sortByColumnIndex(3, FALSE); childSetCommitCallback("owner list", onCommitList, this); mOwnerList->setDoubleClickCallback(onDoubleClickOwner); @@ -1279,7 +1251,7 @@ void LLPanelLandObjects::callbackReturnOwnerObjects(S32 option, void* userdata) if (parcel) { LLUUID owner_id = parcel->getOwnerID(); - LLString::format_map_t args; + LLStringUtil::format_map_t args; if (owner_id == gAgentID) { LLNotifyBox::showXml("OwnedObjectsReturned"); @@ -1312,7 +1284,7 @@ void LLPanelLandObjects::callbackReturnGroupObjects(S32 option, void* userdata) { std::string group_name; gCacheName->getGroupName(parcel->getGroupID(), group_name); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[GROUPNAME]"] = group_name; LLNotifyBox::showXml("GroupObjectsReturned", args); send_return_objects_message(parcel->getLocalID(), RT_GROUP); @@ -1354,7 +1326,7 @@ void LLPanelLandObjects::callbackReturnOwnerList(S32 option, void* userdata) uuid_list_t::iterator selected = self->mSelectedOwners.begin(); if (selected != self->mSelectedOwners.end()) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; if (self->mSelectedIsGroup) { args["[GROUPNAME]"] = self->mSelectedName; @@ -1394,7 +1366,7 @@ void LLPanelLandObjects::onClickReturnOwnerList(void* userdata) send_parcel_select_objects(parcelp->getLocalID(), RT_LIST, &(self->mSelectedOwners)); - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = self->mSelectedName; args["[N]"] = llformat("%d",self->mSelectedCount); if (self->mSelectedIsGroup) @@ -1423,7 +1395,7 @@ void LLPanelLandObjects::onClickRefresh(void* userdata) // ready the list for results self->mOwnerList->deleteAllItems(); - self->mOwnerList->addCommentText("Searching..."); + self->mOwnerList->addCommentText(std::string("Searching...")); // *TODO: Translate self->mOwnerList->setEnabled(FALSE); self->mFirstReply = TRUE; @@ -1459,7 +1431,7 @@ void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, vo BOOL is_group_owned; S32 object_count; BOOL is_online; - char object_count_str[MAX_STRING]; /*Flawfinder: ignore*/ + std::string object_count_str; //BOOL b_need_refresh = FALSE; // If we were waiting for the first reply, clear the "Searching..." text. @@ -1498,9 +1470,9 @@ void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, vo row->addColumn(OWNER_OFFLINE, FONT); } // Placeholder for name. - row->addColumn(LLString::null, FONT); + row->addColumn(LLStringUtil::null, FONT); - snprintf(object_count_str, sizeof(object_count_str), "%d", object_count); /* Flawfinder: ignore */ + object_count_str = llformat("%d", object_count); row->addColumn(object_count_str, FONT); if (is_group_owned) @@ -1518,7 +1490,7 @@ void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, vo // check for no results if (0 == self->mOwnerList->getItemCount()) { - self->mOwnerList->addCommentText("None found."); + self->mOwnerList->addCommentText(std::string("None found.")); // *TODO: Translate } else { @@ -1604,7 +1576,7 @@ void LLPanelLandObjects::onClickReturnOwnerObjects(void* userdata) LLUUID owner_id = parcel->getOwnerID(); - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[N]"] = llformat("%d",owned); if (owner_id == gAgent.getID()) @@ -1632,7 +1604,7 @@ void LLPanelLandObjects::onClickReturnGroupObjects(void* userdata) std::string group_name; gCacheName->getGroupName(parcel->getGroupID(), group_name); - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = group_name; args["[N]"] = llformat("%d", parcel->getGroupPrimCount()); @@ -1653,7 +1625,7 @@ void LLPanelLandObjects::onClickReturnOtherObjects(void* userdata) send_parcel_select_objects(parcel->getLocalID(), RT_OTHER); - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[N]"] = llformat("%d", other); if (parcel->getIsGroupOwned()) @@ -1709,7 +1681,7 @@ void LLPanelLandObjects::onCommitClean(LLUICtrl *caller, void* user_data) //--------------------------------------------------------------------------- LLPanelLandOptions::LLPanelLandOptions(LLParcelSelectionHandle& parcel) -: LLPanel("land_options_panel"), +: LLPanel(std::string("land_options_panel")), mCheckEditObjects(NULL), mCheckEditGroupObjects(NULL), mCheckAllObjectEntry(NULL), @@ -1903,8 +1875,8 @@ void LLPanelLandOptions::refresh() mPushRestrictionCtrl->setEnabled(FALSE); // *TODO:Translate - const char* none_string = LLParcel::getCategoryUIString(LLParcel::C_NONE); - mCategoryCombo->setSimple(LLString(none_string)); + const std::string& none_string = LLParcel::getCategoryUIString(LLParcel::C_NONE); + mCategoryCombo->setSimple(none_string); mCategoryCombo->setEnabled(FALSE); mLandingTypeCombo->setCurrentByIndex(0); @@ -1975,8 +1947,8 @@ void LLPanelLandOptions::refresh() // Set by string in case the order in UI doesn't match the order by index. // *TODO:Translate LLParcel::ECategory cat = parcel->getCategory(); - const char* category_string = LLParcel::getCategoryUIString(cat); - mCategoryCombo->setSimple(LLString(category_string)); + const std::string& category_string = LLParcel::getCategoryUIString(cat); + mCategoryCombo->setSimple(category_string); mCategoryCombo->setEnabled( can_change_identity ); BOOL can_change_landing_point = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, @@ -2188,7 +2160,7 @@ void LLPanelLandOptions::onClickPublishHelp(void*) //--------------------------------------------------------------------------- LLPanelLandAccess::LLPanelLandAccess(LLParcelSelectionHandle& parcel) -: LLPanel("land_access_panel"), mParcel(parcel) +: LLPanel(std::string("land_access_panel")), mParcel(parcel) { } @@ -2212,11 +2184,11 @@ BOOL LLPanelLandAccess::postBuild() mListAccess = getChild<LLNameListCtrl>("AccessList"); if (mListAccess) - mListAccess->sortByColumn(0, TRUE); // ascending + mListAccess->sortByColumnIndex(0, TRUE); // ascending mListBanned = getChild<LLNameListCtrl>("BannedList"); if (mListBanned) - mListBanned->sortByColumn(0, TRUE); // ascending + mListBanned->sortByColumnIndex(0, TRUE); // ascending return TRUE; } @@ -2260,7 +2232,7 @@ void LLPanelLandAccess::refresh() cit != parcel->mAccessList.end(); ++cit) { const LLAccessEntry& entry = (*cit).second; - LLString suffix; + std::string suffix; if (entry.mTime != 0) { S32 now = time(NULL); @@ -2299,7 +2271,7 @@ void LLPanelLandAccess::refresh() cit != parcel->mBanList.end(); ++cit) { const LLAccessEntry& entry = (*cit).second; - LLString suffix; + std::string suffix; if (entry.mTime != 0) { S32 now = time(NULL); @@ -2366,7 +2338,7 @@ void LLPanelLandAccess::refresh() childSetValue("limit_payment", FALSE); childSetValue("limit_age_verified", FALSE); childSetValue("GroupCheck", FALSE); - childSetLabelArg("GroupCheck", "[GROUP]", LLString::null ); + childSetLabelArg("GroupCheck", "[GROUP]", LLStringUtil::null ); childSetValue("PassCheck", FALSE); childSetValue("PriceSpin", (F32)PARCEL_PASS_PRICE_DEFAULT); childSetValue( "HoursSpin", PARCEL_PASS_HOURS_DEFAULT ); @@ -2425,7 +2397,7 @@ void LLPanelLandAccess::refresh_ui() } else { - childSetToolTip("Only Allow", LLString()); + childSetToolTip("Only Allow", std::string()); } childSetEnabled("GroupCheck", FALSE); childSetEnabled("PassCheck", FALSE); @@ -2436,7 +2408,8 @@ void LLPanelLandAccess::refresh_ui() { childSetEnabled("limit_payment", FALSE); childSetEnabled("limit_age_verified", FALSE); - char group_name[MAX_STRING]; /*Flawfinder: ignore*/ + + std::string group_name; if (gCacheName->getGroupName(parcel->getGroupID(), group_name)) { childSetEnabled("GroupCheck", can_manage_allowed); @@ -2499,7 +2472,7 @@ void LLPanelLandAccess::onCommitPublicAccess(LLUICtrl *ctrl, void *userdata) BOOL public_access = self->childGetValue("public_access").asBoolean(); if (public_access == FALSE) { - char group_name[MAX_STRING]; /*Flawfinder: ignore*/ + std::string group_name; if (gCacheName->getGroupName(parcel->getGroupID(), group_name)) { self->childSetValue("GroupCheck", public_access ? FALSE : TRUE); @@ -2682,7 +2655,7 @@ void LLPanelLandAccess::onClickRemoveBanned(void* data) // LLPanelLandCovenant //--------------------------------------------------------------------------- LLPanelLandCovenant::LLPanelLandCovenant(LLParcelSelectionHandle& parcel) -: LLPanel("land_covenant_panel"), mParcel(parcel) +: LLPanel(std::string("land_covenant_panel")), mParcel(parcel) { } diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index 9979e8b24a..9bed9d53ae 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -288,7 +288,7 @@ protected: BOOL mFirstReply; uuid_list_t mSelectedOwners; - LLString mSelectedName; + std::string mSelectedName; S32 mSelectedCount; BOOL mSelectedIsGroup; diff --git a/indra/newview/llfloaterlandholdings.cpp b/indra/newview/llfloaterlandholdings.cpp index 08ea7e1b8e..dfc3896a6a 100644 --- a/indra/newview/llfloaterlandholdings.cpp +++ b/indra/newview/llfloaterlandholdings.cpp @@ -82,7 +82,7 @@ void LLFloaterLandHoldings::show(void*) // protected LLFloaterLandHoldings::LLFloaterLandHoldings() -: LLFloater("land holdings floater"), +: LLFloater(std::string("land holdings floater")), mActualArea(0), mBillableArea(0), mFirstPacketReceived(FALSE), @@ -183,28 +183,28 @@ void LLFloaterLandHoldings::processPlacesReply(LLMessageSystem* msg, void**) } LLUUID owner_id; - char name[MAX_STRING]; /* Flawfinder: ignore */ - char desc[MAX_STRING]; /* Flawfinder: ignore */ + std::string name; + std::string desc; S32 actual_area; S32 billable_area; U8 flags; F32 global_x; F32 global_y; - char sim_name[MAX_STRING]; /* Flawfinder: ignore */ + std::string sim_name; S32 i; S32 count = msg->getNumberOfBlocks("QueryData"); for (i = 0; i < count; i++) { msg->getUUID("QueryData", "OwnerID", owner_id, i); - msg->getString("QueryData", "Name", MAX_STRING, name, i); - msg->getString("QueryData", "Desc", MAX_STRING, desc, i); + msg->getString("QueryData", "Name", name, i); + msg->getString("QueryData", "Desc", desc, i); msg->getS32("QueryData", "ActualArea", actual_area, i); msg->getS32("QueryData", "BillableArea", billable_area, i); msg->getU8("QueryData", "Flags", flags, i); msg->getF32("QueryData", "GlobalX", global_x, i); msg->getF32("QueryData", "GlobalY", global_y, i); - msg->getString("QueryData", "SimName", MAX_STRING, sim_name, i); + msg->getString("QueryData", "SimName", sim_name, i); self->mActualArea += actual_area; self->mBillableArea += billable_area; @@ -212,21 +212,21 @@ void LLFloaterLandHoldings::processPlacesReply(LLMessageSystem* msg, void**) S32 region_x = llround(global_x) % REGION_WIDTH_UNITS; S32 region_y = llround(global_y) % REGION_WIDTH_UNITS; - char location[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(location, MAX_STRING, "%s (%d, %d)", sim_name, region_x, region_y); /* Flawfinder: ignore */ + std::string location; + location = llformat("%s (%d, %d)", sim_name.c_str(), region_x, region_y); - char area[MAX_STRING]; /* Flawfinder: ignore */ + std::string area; if(billable_area == actual_area) { - snprintf(area, MAX_STRING, "%d", billable_area); /* Flawfinder: ignore */ + area = llformat("%d", billable_area); } else { - snprintf(area, MAX_STRING, "%d / %d", billable_area, actual_area); /* Flawfinder: ignore */ + area = llformat("%d / %d", billable_area, actual_area); } - char hidden[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(hidden, MAX_STRING, "%f %f", global_x, global_y); /* Flawfinder: ignore */ + std::string hidden; + hidden = llformat("%f %f", global_x, global_y); LLSD element; element["columns"][0]["column"] = "name"; @@ -256,7 +256,7 @@ void LLFloaterLandHoldings::buttonCore(S32 which) S32 index = list->getFirstSelectedIndex(); if (index < 0) return; - LLString location = list->getSelectedItemLabel(3); + std::string location = list->getSelectedItemLabel(3); F32 global_x = 0.f; F32 global_y = 0.f; diff --git a/indra/newview/llfloaterlandholdings.h b/indra/newview/llfloaterlandholdings.h index 3490547a75..7ec7e70c18 100644 --- a/indra/newview/llfloaterlandholdings.h +++ b/indra/newview/llfloaterlandholdings.h @@ -78,7 +78,7 @@ protected: // Used to clear out the mParcelList's "Loading..." indicator BOOL mFirstPacketReceived; - LLString mSortColumn; + std::string mSortColumn; BOOL mSortAscending; }; diff --git a/indra/newview/llfloatermap.cpp b/indra/newview/llfloatermap.cpp index d147f863ef..7067d4b055 100644 --- a/indra/newview/llfloatermap.cpp +++ b/indra/newview/llfloatermap.cpp @@ -86,8 +86,6 @@ const S32 MAP_SCALE_MIN = 35; // in pixels per sim const S32 MAP_SCALE_MAX = 180; // in pixels per sim const S32 MAP_SCALE_INCREMENT = 5; -const char MAP_TITLE[] = ""; - const S32 NETMAP_MIN_WIDTH = 128; const S32 NETMAP_MIN_HEIGHT = 128; @@ -118,8 +116,8 @@ LLFloaterMap *gFloaterMap = NULL; LLFloaterMap::LLFloaterMap(const std::string& name) : LLFloater(name, - "FloaterMiniMapRect", - MAP_TITLE, + std::string("FloaterMiniMapRect"), + LLStringUtil::null, TRUE, FLOATERMAP_MIN_WIDTH, FLOATERMAP_MIN_HEIGHT_LARGE, diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp index 2c7d40695b..a95cafa7e4 100644 --- a/indra/newview/llfloaternamedesc.cpp +++ b/indra/newview/llfloaternamedesc.cpp @@ -65,13 +65,12 @@ const S32 PREF_BUTTON_HEIGHT = 16; // LLFloaterNameDesc() //----------------------------------------------------------------------------- LLFloaterNameDesc::LLFloaterNameDesc(const std::string& filename ) - : - LLFloater("Name/Description Floater") + : LLFloater(std::string("Name/Description Floater")) { mFilenameAndPath = filename; - mFilename.assign(strrchr( filename.c_str(), gDirUtilp->getDirDelimiter()[0]) + 1); + mFilename = gDirUtilp->getBaseFileName(filename, false); // SL-5521 Maintain capitalization of filename when making the inventory item. JC - //LLString::toLower(mFilename); + //LLStringUtil::toLower(mFilename); mIsAudio = FALSE; } @@ -82,27 +81,18 @@ BOOL LLFloaterNameDesc::postBuild() { LLRect r; - LLString asset_name = mFilename; - LLString::replaceNonstandardASCII( asset_name, '?' ); - LLString::replaceChar(asset_name, '|', '?'); - LLString::stripNonprintable(asset_name); - LLString::trim(asset_name); + std::string asset_name = mFilename; + LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); + LLStringUtil::replaceChar(asset_name, '|', '?'); + LLStringUtil::stripNonprintable(asset_name); + LLStringUtil::trim(asset_name); - char* asset_name_str = (char*)asset_name.c_str(); - char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists - if( !end_p ) - { - end_p = asset_name_str + strlen( asset_name_str ); /* Flawfinder: ignore */ - } - else - if( !stricmp( end_p, ".wav") ) + std::string exten = gDirUtilp->getExtension(asset_name); + if (exten == "wav") { mIsAudio = TRUE; } - - S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) ); - - asset_name = asset_name.substr( 0, len ); + asset_name = gDirUtilp->getBaseFileName(asset_name, true); // no extsntion setTitle(mFilename); diff --git a/indra/newview/llfloaternamedesc.h b/indra/newview/llfloaternamedesc.h index 8c968329c2..22f8080662 100644 --- a/indra/newview/llfloaternamedesc.h +++ b/indra/newview/llfloaternamedesc.h @@ -54,8 +54,8 @@ protected: protected: BOOL mIsAudio; - LLString mFilenameAndPath; - LLString mFilename; + std::string mFilenameAndPath; + std::string mFilename; static void onBtnOK(void*); static void onBtnCancel(void*); diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp index a3350b5225..b1380ccd8c 100644 --- a/indra/newview/llfloateropenobject.cpp +++ b/indra/newview/llfloateropenobject.cpp @@ -57,7 +57,7 @@ LLFloaterOpenObject* LLFloaterOpenObject::sInstance = NULL; LLFloaterOpenObject::LLFloaterOpenObject() -: LLFloater("object_contents"), +: LLFloater(std::string("object_contents")), mPanelInventory(NULL), mDirty(TRUE) { @@ -67,7 +67,7 @@ LLFloaterOpenObject::LLFloaterOpenObject() childSetAction("copy_to_inventory_button", onClickMoveToInventory, this); childSetAction("copy_and_wear_button", onClickMoveAndWear, this); - childSetTextArg("object_name", "[DESC]", LLString("Object") ); // *Note: probably do not want to translate this + childSetTextArg("object_name", "[DESC]", std::string("Object") ); // *Note: probably do not want to translate this } LLFloaterOpenObject::~LLFloaterOpenObject() @@ -215,6 +215,6 @@ void LLFloaterOpenObject::onClickMoveAndWear(void* data) void* LLFloaterOpenObject::createPanelInventory(void* data) { LLFloaterOpenObject* floater = (LLFloaterOpenObject*)data; - floater->mPanelInventory = new LLPanelInventory("Object Contents", LLRect()); + floater->mPanelInventory = new LLPanelInventory(std::string("Object Contents"), LLRect()); return floater->mPanelInventory; } diff --git a/indra/newview/llfloaterpostcard.cpp b/indra/newview/llfloaterpostcard.cpp index 8741cdf510..1e71872ea6 100644 --- a/indra/newview/llfloaterpostcard.cpp +++ b/indra/newview/llfloaterpostcard.cpp @@ -75,7 +75,7 @@ LLFloaterPostcard::instance_list_t LLFloaterPostcard::sInstances; ///---------------------------------------------------------------------------- LLFloaterPostcard::LLFloaterPostcard(LLImageJPEG* jpeg, LLImageGL *img, const LLVector2& img_scale, const LLVector3d& pos_taken_global) -: LLFloater("Postcard Floater"), +: LLFloater(std::string("Postcard Floater")), mJPEGImage(jpeg), mViewerImage(img), mImageScale(img_scale), @@ -282,7 +282,7 @@ void LLFloaterPostcard::uploadCallback(const LLUUID& asset_id, void *user_data, if (result) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); gViewerWindow->alertXml("ErrorUploadingPostcard", args); } @@ -312,13 +312,13 @@ void LLFloaterPostcard::uploadCallback(const LLUUID& asset_id, void *user_data, } // static -void LLFloaterPostcard::updateUserInfo(const char *email) +void LLFloaterPostcard::updateUserInfo(const std::string& email) { for (instance_list_t::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter) { LLFloaterPostcard *instance = *iter; - const LLString& text = instance->childGetValue("from_form").asString(); + const std::string& text = instance->childGetValue("from_form").asString(); if (text.empty()) { // there's no text in this field yet, pre-populate @@ -336,7 +336,7 @@ void LLFloaterPostcard::onMsgFormFocusRecieved(LLFocusableElement* receiver, voi if(msgForm && msgForm == receiver && msgForm->hasFocus() && !(self->mHasFirstMsgFocus)) { self->mHasFirstMsgFocus = true; - msgForm->setText(LLString::null); + msgForm->setText(LLStringUtil::null); } } } diff --git a/indra/newview/llfloaterpostcard.h b/indra/newview/llfloaterpostcard.h index 2e2fffb18a..28248f65df 100644 --- a/indra/newview/llfloaterpostcard.h +++ b/indra/newview/llfloaterpostcard.h @@ -62,7 +62,7 @@ public: void *user_data, S32 result, LLExtStat ext_status); - static void updateUserInfo(const char *email); + static void updateUserInfo(const std::string& email); static void onMsgFormFocusRecieved(LLFocusableElement* receiver, void* data); static void missingSubjMsgAlertCallback(S32 option, void* data); diff --git a/indra/newview/llfloaterpostprocess.cpp b/indra/newview/llfloaterpostprocess.cpp index 5c42f1222f..692b7e036f 100644 --- a/indra/newview/llfloaterpostprocess.cpp +++ b/indra/newview/llfloaterpostprocess.cpp @@ -46,7 +46,7 @@ LLFloaterPostProcess* LLFloaterPostProcess::sPostProcess = NULL; -LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater("Post-Process Floater") +LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater(std::string("Post-Process Floater")) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_post_process.xml"); diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index f78da984a9..981c9c41b3 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -302,10 +302,7 @@ void LLPreferenceCore::onTabChanged(void* user_data, bool from_click) } -void LLPreferenceCore::setPersonalInfo( - const char* visibility, - BOOL im_via_email, - const char* email) +void LLPreferenceCore::setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email) { mPrefsIM->setPersonalInfo(visibility, im_via_email, email); } @@ -435,7 +432,7 @@ void LLFloaterPreference::onBtnOK( void* userdata ) std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); // save all settings, even if equals defaults - gCrashSettings.saveToFile(crash_settings_filename.c_str(), FALSE); + gCrashSettings.saveToFile(crash_settings_filename, FALSE); } else { @@ -488,15 +485,11 @@ void LLFloaterPreference::onBtnCancel( void* userdata ) // static -void LLFloaterPreference::updateUserInfo( - const char* visibility, - BOOL im_via_email, - const char* email) +void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_via_email, const std::string& email) { if(sInstance && sInstance->mPreferenceCore) { - sInstance->mPreferenceCore->setPersonalInfo( - visibility, im_via_email, email); + sInstance->mPreferenceCore->setPersonalInfo(visibility, im_via_email, email); } } diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index b915dff660..1a580a0e8c 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -68,10 +68,7 @@ public: LLTabContainer* getTabContainer() { return mTabContainer; } - void setPersonalInfo( - const char* visibility, - BOOL im_via_email, - const char* email); + void setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email); static void onTabChanged(void* user_data, bool from_click); @@ -107,10 +104,7 @@ public: static void show(void*); // static data update, called from message handler - static void updateUserInfo( - const char* visibility, - BOOL im_via_email, - const char* email); + static void updateUserInfo(const std::string& visibility, bool im_via_email, const std::string& email); // refresh all the graphics preferences menus static void refreshEnabledGraphics(); diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp index 21ed153920..4a996a9c06 100644 --- a/indra/newview/llfloaterproperties.cpp +++ b/indra/newview/llfloaterproperties.cpp @@ -346,7 +346,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) //////////////// if(perm.isOwned()) { - LLString name; + std::string name; if (perm.isGroupOwned()) { gCacheName->getGroupName(perm.getGroup(), name); @@ -380,7 +380,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) } else { - childSetText("LabelAcquiredDate", LLString(ctime(&time_utc)) ); + childSetText("LabelAcquiredDate", std::string(ctime(&time_utc)) ); } /////////////////////// @@ -942,7 +942,7 @@ void LLFloaterProperties::closeByID(const LLUUID& item_id, const LLUUID &object_ /// LLMultiProperties ///---------------------------------------------------------------------------- -LLMultiProperties::LLMultiProperties(const LLRect &rect) : LLMultiFloater("Properties", rect) +LLMultiProperties::LLMultiProperties(const LLRect &rect) : LLMultiFloater(std::string("Properties"), rect) { } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 925ba0156d..fc3c0952cb 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -47,6 +47,7 @@ #include "llagent.h" #include "llalertdialog.h" +#include "llappviewer.h" #include "llfloateravatarpicker.h" #include "llbutton.h" #include "llcheckboxctrl.h" @@ -80,9 +81,6 @@ const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; -extern LLString gLastVersionChannel; - - ///---------------------------------------------------------------------------- /// Local class declaration ///---------------------------------------------------------------------------- @@ -263,7 +261,7 @@ void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) LLDispatcher::unpackMessage(msg, request, invoice, strings); if(invoice != getLastInvoice()) { - llwarns << "Mismatched Estate message: " << request.c_str() << llendl; + llwarns << "Mismatched Estate message: " << request << llendl; return; } @@ -294,7 +292,7 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); // extract message - char sim_name[MAX_STRING]; /* Flawfinder: ignore*/ + std::string sim_name; U32 region_flags; U8 agent_limit; F32 object_bonus_factor; @@ -304,7 +302,7 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) F32 terrain_lower_limit; BOOL use_estate_sun; F32 sun_hour; - msg->getString("RegionInfo", "SimName", MAX_STRING, sim_name); + msg->getString("RegionInfo", "SimName", sim_name); msg->getU32("RegionInfo", "RegionFlags", region_flags); msg->getU8("RegionInfo", "MaxAgents", agent_limit); msg->getF32("RegionInfo", "ObjectBonusFactor", object_bonus_factor); @@ -488,7 +486,7 @@ bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region) void LLPanelRegionInfo::sendEstateOwnerMessage( LLMessageSystem* msg, - const char* request, + const std::string& request, const LLUUID& invoice, const strings_t& strings) { @@ -513,43 +511,44 @@ void LLPanelRegionInfo::sendEstateOwnerMessage( for(; it != end; ++it) { msg->nextBlock("ParamList"); - msg->addString("Parameter", (*it).c_str()); + msg->addString("Parameter", *it); } } msg->sendReliable(mHost); } -void LLPanelRegionInfo::enableButton(const char* btn_name, BOOL enable) +void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable) { childSetEnabled(btn_name, enable); } -void LLPanelRegionInfo::disableButton(const char* btn_name) +void LLPanelRegionInfo::disableButton(const std::string& btn_name) { childDisable(btn_name); } -void LLPanelRegionInfo::initCtrl(const char* name) +void LLPanelRegionInfo::initCtrl(const std::string& name) { childSetCommitCallback(name, onChangeAnything, this); } -void LLPanelRegionInfo::initTextCtrl(const char* name) +void LLPanelRegionInfo::initTextCtrl(const std::string& name) { childSetCommitCallback(name, onChangeAnything, this); childSetKeystrokeCallback("abuse_email_address", onChangeText, this); } -void LLPanelRegionInfo::initHelpBtn(const char* name, const char* xml_alert) +void LLPanelRegionInfo::initHelpBtn(const std::string& name, const std::string& xml_alert) { - childSetAction(name, onClickHelp, (void*)xml_alert); + childSetAction(name, onClickHelp, new std::string(xml_alert)); } // static void LLPanelRegionInfo::onClickHelp(void* data) { - const char* xml_alert = (const char*)data; - gViewerWindow->alertXml(xml_alert); + const std::string* xml_alert = (std::string*)data; + gViewerWindow->alertXml(*xml_alert); + delete xml_alert; } ///////////////////////////////////////////////////////////////////////////// @@ -630,7 +629,7 @@ void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& name strings_t strings; // [0] = our agent id // [1] = target agent id - char buffer[MAX_STRING]; /* Flawfinder: ignore*/ + std::string buffer; gAgent.getID().toString(buffer); strings.push_back(buffer); @@ -658,7 +657,7 @@ void LLPanelRegionGeneralInfo::onKickAllCommit(S32 option, void* userdata) if(!self) return; strings_t strings; // [0] = our agent id - char buffer[MAX_STRING]; /* Flawfinder: ignore*/ + std::string buffer; gAgent.getID().toString(buffer); strings.push_back(buffer); @@ -672,13 +671,13 @@ void LLPanelRegionGeneralInfo::onKickAllCommit(S32 option, void* userdata) void LLPanelRegionGeneralInfo::onClickMessage(void* userdata) { llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl; - gViewerWindow->alertXmlEditText("MessageRegion", LLString::format_map_t(), + gViewerWindow->alertXmlEditText("MessageRegion", LLStringUtil::format_map_t(), NULL, NULL, onMessageCommit, userdata); } // static -void LLPanelRegionGeneralInfo::onMessageCommit(S32 option, const LLString& text, void* userdata) +void LLPanelRegionGeneralInfo::onMessageCommit(S32 option, const std::string& text, void* userdata) { if(option != 0) return; if(text.empty()) return; @@ -693,7 +692,7 @@ void LLPanelRegionGeneralInfo::onMessageCommit(S32 option, const LLString& text, // [4] message strings.push_back("-1"); strings.push_back("-1"); - char buffer[MAX_STRING]; /* Flawfinder: ignore*/ + std::string buffer; gAgent.getID().toString(buffer); strings.push_back(buffer); std::string name; @@ -740,7 +739,7 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() body["prim_bonus"] = childGetValue("object_bonus_spin"); // the combo box stores strings "Mature" and "PG", but we have to convert back to a number, // because the sim doesn't know from strings for this stuff - body["sim_access"] = LLViewerRegion::stringToAccess(childGetValue("access_combo").asString().c_str()); + body["sim_access"] = LLViewerRegion::stringToAccess(childGetValue("access_combo").asString()); body["restrict_pushobject"] = childGetValue("restrict_pushobject"); body["allow_parcel_changes"] = childGetValue("allow_parcel_changes_check"); body["block_parcel_search"] = childGetValue("block_parcel_search_check"); @@ -750,44 +749,43 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() else { strings_t strings; - char buffer[MAX_STRING]; /* Flawfinder: ignore*/ + std::string buffer; - snprintf(buffer, MAX_STRING, "%s", (childGetValue("block_terraform_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("block_terraform_check").asBoolean() ? "Y" : "N")); strings.push_back(strings_t::value_type(buffer)); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("block_fly_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("block_fly_check").asBoolean() ? "Y" : "N")); strings.push_back(strings_t::value_type(buffer)); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("allow_damage_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("allow_damage_check").asBoolean() ? "Y" : "N")); strings.push_back(strings_t::value_type(buffer)); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("allow_land_resell_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("allow_land_resell_check").asBoolean() ? "Y" : "N")); strings.push_back(strings_t::value_type(buffer)); F32 value = (F32)childGetValue("agent_limit_spin").asReal(); - snprintf(buffer, MAX_STRING, "%f", value); /* Flawfinder: ignore */ + buffer = llformat("%f", value); strings.push_back(strings_t::value_type(buffer)); value = (F32)childGetValue("object_bonus_spin").asReal(); - snprintf(buffer, MAX_STRING, "%f", value); /* Flawfinder: ignore */ + buffer = llformat("%f", value); strings.push_back(strings_t::value_type(buffer)); - U8 access = LLViewerRegion::stringToAccess(childGetValue("access_combo").asString().c_str()); - snprintf(buffer, MAX_STRING, "%d", (S32)access); /* Flawfinder: ignore */ + U8 access = LLViewerRegion::stringToAccess(childGetValue("access_combo").asString()); + buffer = llformat("%d", (S32)access); strings.push_back(strings_t::value_type(buffer)); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("restrict_pushobject").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("restrict_pushobject").asBoolean() ? "Y" : "N")); strings.push_back(strings_t::value_type(buffer)); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("allow_parcel_changes_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("allow_parcel_changes_check").asBoolean() ? "Y" : "N")); strings.push_back(strings_t::value_type(buffer)); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings); LLViewerRegion* region = gAgent.getRegion(); - if (region - && access != region->getSimAccess() ) /* Flawfinder: ignore */ + if (region && access != region->getSimAccess() ) { gViewerWindow->alertXml("RegionMaturityChange"); } @@ -851,15 +849,15 @@ BOOL LLPanelRegionDebugInfo::sendUpdate() { llinfos << "LLPanelRegionDebugInfo::sendUpdate" << llendl; strings_t strings; - char buffer[MAX_STRING]; /* Flawfinder: ignore */ + std::string buffer; - snprintf(buffer, MAX_STRING, "%s", (childGetValue("disable_scripts_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("disable_scripts_check").asBoolean() ? "Y" : "N")); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("disable_collisions_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("disable_collisions_check").asBoolean() ? "Y" : "N")); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("disable_physics_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("disable_physics_check").asBoolean() ? "Y" : "N")); strings.push_back(buffer); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); @@ -888,7 +886,7 @@ void LLPanelRegionDebugInfo::onClickReturnScriptedOtherLand(void* data) LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data; if (panelp->mTargetAvatar.isNull()) return; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[USER_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); gViewerWindow->alertXml("ReturnScriptedOnOthersLand", args, callbackReturnScriptedOtherLand, data); } @@ -917,7 +915,7 @@ void LLPanelRegionDebugInfo::onClickReturnScriptedAll(void* data) if (panelp->mTargetAvatar.isNull()) return; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[USER_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); gViewerWindow->alertXml("ReturnScriptedOnAllLand", args, callbackReturnScriptedAll, data); } @@ -1018,10 +1016,10 @@ bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region) LLVLComposition* compp = region->getComposition(); LLTextureCtrl* texture_ctrl; - char buffer[MAX_STRING]; /* Flawfinder: ignore */ + std::string buffer; for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { - snprintf(buffer, MAX_STRING, "texture_detail_%d", i); /* Flawfinder: ignore */ + buffer = llformat("texture_detail_%d", i); texture_ctrl = getChild<LLTextureCtrl>(buffer); if(texture_ctrl) { @@ -1034,9 +1032,9 @@ bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region) for(S32 i = 0; i < CORNER_COUNT; ++i) { - snprintf(buffer, MAX_STRING, "height_start_spin_%d", i); /* Flawfinder: ignore */ + buffer = llformat("height_start_spin_%d", i); childSetValue(buffer, LLSD(compp->getStartHeight(i))); - snprintf(buffer, MAX_STRING, "height_range_spin_%d", i); /* Flawfinder: ignore */ + buffer = llformat("height_range_spin_%d", i); childSetValue(buffer, LLSD(compp->getHeightRange(i))); } @@ -1048,18 +1046,18 @@ bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region) BOOL LLPanelRegionTextureInfo::postBuild() { LLPanelRegionInfo::postBuild(); - char buffer[MAX_STRING]; /* Flawfinder: ignore */ + std::string buffer; for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { - snprintf(buffer, MAX_STRING, "texture_detail_%d", i); /* Flawfinder: ignore */ + buffer = llformat("texture_detail_%d", i); initCtrl(buffer); } for(S32 i = 0; i < CORNER_COUNT; ++i) { - snprintf(buffer, MAX_STRING, "height_start_spin_%d", i); /* Flawfinder: ignore */ + buffer = llformat("height_start_spin_%d", i); initCtrl(buffer); - snprintf(buffer, MAX_STRING, "height_range_spin_%d", i); /* Flawfinder: ignore */ + buffer = llformat("height_range_spin_%d", i); initCtrl(buffer); } @@ -1081,9 +1079,8 @@ BOOL LLPanelRegionTextureInfo::sendUpdate() } LLTextureCtrl* texture_ctrl; - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - char buffer2[MAX_STRING]; /* Flawfinder: ignore */ - char id_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string buffer; + std::string id_str; LLMessageSystem* msg = gMessageSystem; strings_t strings; @@ -1091,24 +1088,24 @@ BOOL LLPanelRegionTextureInfo::sendUpdate() for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { - snprintf(buffer, MAX_STRING, "texture_detail_%d", i); /* Flawfinder: ignore */ + buffer = llformat("texture_detail_%d", i); texture_ctrl = getChild<LLTextureCtrl>(buffer); if(texture_ctrl) { LLUUID tmp_id(texture_ctrl->getImageAssetID()); tmp_id.toString(id_str); - snprintf(buffer, MAX_STRING, "%d %s", i, id_str); /* Flawfinder: ignore */ - strings.push_back(strings_t::value_type(buffer)); + buffer = llformat("%d %s", i, id_str.c_str()); + strings.push_back(buffer); } } sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); strings.clear(); for(S32 i = 0; i < CORNER_COUNT; ++i) { - snprintf(buffer, MAX_STRING, "height_start_spin_%d", i); /* Flawfinder: ignore */ - snprintf(buffer2, MAX_STRING, "height_range_spin_%d", i); /* Flawfinder: ignore */ - snprintf(buffer, MAX_STRING, "%d %f %f", i, (F32)childGetValue(buffer).asReal(), (F32)childGetValue(buffer2).asReal()); /* Flawfinder: ignore */ - strings.push_back(strings_t::value_type(buffer)); + buffer = llformat("height_start_spin_%d", i); + std::string buffer2 = llformat("height_range_spin_%d", i); + std::string buffer3 = llformat("%d %f %f", i, (F32)childGetValue(buffer).asReal(), (F32)childGetValue(buffer2).asReal()); + strings.push_back(buffer3); } sendEstateOwnerMessage(msg, "textureheights", invoice, strings); strings.clear(); @@ -1120,8 +1117,8 @@ BOOL LLPanelRegionTextureInfo::validateTextureSizes() { for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buffer, MAX_STRING, "texture_detail_%d", i); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat("texture_detail_%d", i); LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>(buffer); if (!texture_ctrl) continue; @@ -1136,7 +1133,7 @@ BOOL LLPanelRegionTextureInfo::validateTextureSizes() if (components != 3) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[TEXTURE_NUM]"] = llformat("%d",i+1); args["[TEXTURE_BIT_DEPTH]"] = llformat("%d",components * 8); gViewerWindow->alertXml("InvalidTerrainBitDepth", args); @@ -1146,7 +1143,7 @@ BOOL LLPanelRegionTextureInfo::validateTextureSizes() if (width > 512 || height > 512) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[TEXTURE_NUM]"] = llformat("%d",i+1); args["[TEXTURE_SIZE_X]"] = llformat("%d",width); args["[TEXTURE_SIZE_Y]"] = llformat("%d",height); @@ -1222,21 +1219,21 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) BOOL LLPanelRegionTerrainInfo::sendUpdate() { llinfos << "LLPanelRegionTerrainInfo::sendUpdate" << llendl; - char buffer[MAX_STRING]; /* Flawfinder: ignore */ + std::string buffer; strings_t strings; LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - snprintf(buffer, MAX_STRING, "%f", (F32)childGetValue("water_height_spin").asReal()); /* Flawfinder: ignore */ + buffer = llformat("%f", (F32)childGetValue("water_height_spin").asReal()); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%f", (F32)childGetValue("terrain_raise_spin").asReal()); /* Flawfinder: ignore */ + buffer = llformat("%f", (F32)childGetValue("terrain_raise_spin").asReal()); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%f", (F32)childGetValue("terrain_lower_spin").asReal()); /* Flawfinder: ignore */ + buffer = llformat("%f", (F32)childGetValue("terrain_lower_spin").asReal()); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("use_estate_sun_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("use_estate_sun_check").asBoolean() ? "Y" : "N")); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%s", (childGetValue("fixed_sun_check").asBoolean() ? "Y" : "N")); /* Flawfinder: ignore */ + buffer = llformat("%s", (childGetValue("fixed_sun_check").asBoolean() ? "Y" : "N")); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%f", (F32)childGetValue("sun_hour_slider").asReal() ); /* Flawfinder: ignore */ + buffer = llformat("%f", (F32)childGetValue("sun_hour_slider").asReal() ); strings.push_back(buffer); // Grab estate information in case the user decided to set the @@ -1262,11 +1259,11 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() estate_sun_hour = panel->getSunHour(); } - snprintf(buffer, MAX_STRING, "%s", (estate_global_time ? "Y" : "N") ); /* Flawfinder: ignore */ + buffer = llformat("%s", (estate_global_time ? "Y" : "N") ); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%s", (estate_fixed_sun ? "Y" : "N") ); /* Flawfinder: ignore */ + buffer = llformat("%s", (estate_fixed_sun ? "Y" : "N") ); strings.push_back(buffer); - snprintf(buffer, MAX_STRING, "%f", estate_sun_hour); /* Flawfinder: ignore */ + buffer = llformat("%f", estate_sun_hour); strings.push_back(buffer); sendEstateOwnerMessage(gMessageSystem, "setregionterrain", invoice, strings); @@ -1317,7 +1314,7 @@ void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data) llwarns << "No file" << llendl; return; } - LLString filepath = picker.getFirstFile(); + std::string filepath = picker.getFirstFile(); LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; strings_t strings; @@ -1336,7 +1333,7 @@ void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data) llwarns << "No file" << llendl; return; } - LLString filepath = picker.getFirstFile(); + std::string filepath = picker.getFirstFile(); LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; strings_t strings; @@ -1451,7 +1448,7 @@ void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data) { //args - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MAX_AGENTS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); gViewerWindow->alertXml("MaxAllowedAgentOnRegion", args); return; @@ -1473,7 +1470,7 @@ void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data) if (!list) return; if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MAX_GROUPS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); gViewerWindow->alertXml("MaxAllowedGroupsOnRegion", args); return; @@ -1525,7 +1522,7 @@ void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data) if (!list) return; if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MAX_BANNED]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); gViewerWindow->alertXml("MaxBannedAgentsOnRegion", args); return; @@ -1547,7 +1544,7 @@ void LLPanelEstateInfo::onClickAddEstateManager(void* user_data) if (!list) return; if (list->getItemCount() >= ESTATE_MAX_MANAGERS) { // Tell user they can't add more managers - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MAX_MANAGER]"] = llformat("%d",ESTATE_MAX_MANAGERS); gViewerWindow->alertXml("MaxManagersOnRegion", args); } @@ -1569,7 +1566,7 @@ void LLPanelEstateInfo::onClickRemoveEstateManager(void* user_data) struct LLKickFromEstateInfo { LLPanelEstateInfo *mEstatePanelp; - LLString mDialogName; + std::string mDialogName; LLUUID mAgentID; }; @@ -1605,7 +1602,7 @@ void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names, kick_info->mAgentID = ids[0]; //Bring up a confirmation dialog - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[EVIL_USER]"] = names[0]; gViewerWindow->alertXml(kick_info->mDialogName, args, LLPanelEstateInfo::kickUserConfirm, (void*)kick_info); @@ -1619,14 +1616,14 @@ void LLPanelEstateInfo::kickUserConfirm(S32 option, void* userdata) LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); strings_t strings; - char buffer[MAX_STRING]; /* Flawfinder: ignore*/ + std::string buffer; switch(option) { case 0: //Kick User kick_info->mAgentID.toString(buffer); - strings.push_back(strings_t::value_type(buffer)); + strings.push_back(buffer); kick_info->mEstatePanelp->sendEstateOwnerMessage(gMessageSystem, "kickestate", invoice, strings); break; @@ -1681,7 +1678,7 @@ typedef std::vector<LLUUID> AgentOrGroupIDsVector; struct LLEstateAccessChangeInfo { U32 mOperationFlag; // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc. - LLString mDialogName; + std::string mDialogName; AgentOrGroupIDsVector mAgentOrGroupIDs; // List of agent IDs to apply to this change }; @@ -1700,14 +1697,14 @@ void LLPanelEstateInfo::addAllowedGroup2(LLUUID id, void* user_data) } else { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[ALL_ESTATES]"] = all_estates_text(); gViewerWindow->alertXml(change_info->mDialogName, args, accessCoreConfirm, (void*)change_info); } } // static -void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const char* dialog_name) +void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const std::string& dialog_name) { LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo; change_info->mOperationFlag = operation_flag; @@ -1767,7 +1764,7 @@ void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, co int currentCount = (list ? list->getItemCount() : 0); if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NUM_ADDED]"] = llformat("%d",ids.size()); args["[MAX_AGENTS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); args["[LIST_TYPE]"] = "Allowed Residents"; @@ -1783,7 +1780,7 @@ void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, co int currentCount = (list ? list->getItemCount() : 0); if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NUM_ADDED]"] = llformat("%d",ids.size()); args["[MAX_AGENTS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); args["[LIST_TYPE]"] = "Banned Residents"; @@ -1802,14 +1799,14 @@ void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, co else { // ask if this estate or all estates with this owner - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[ALL_ESTATES]"] = all_estates_text(); gViewerWindow->alertXml(change_info->mDialogName, args, accessCoreConfirm, (void*)change_info); } } // static -void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const char* dialog_name, const char* list_ctrl_name) +void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name) { LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); if (!panel) return; @@ -1866,7 +1863,7 @@ void LLPanelEstateInfo::accessRemoveCore2(S32 option, void* data) } else { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[ALL_ESTATES]"] = all_estates_text(); gViewerWindow->alertXml(change_info->mDialogName, args, @@ -1953,12 +1950,12 @@ void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_ msg->addString("Method", "estateaccessdelta"); msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); - char buf[MAX_STRING]; /* Flawfinder: ignore*/ + std::string buf; gAgent.getID().toString(buf); msg->nextBlock("ParamList"); msg->addString("Parameter", buf); - snprintf(buf, MAX_STRING, "%u", flags); /* Flawfinder: ignore */ + buf = llformat("%u", flags); msg->nextBlock("ParamList"); msg->addString("Parameter", buf); @@ -2305,10 +2302,10 @@ void LLPanelEstateInfo::commitEstateInfoDataserver() msg->nextBlock("ParamList"); msg->addString("Parameter", getEstateName()); - char buf[MAX_STRING]; /* Flawfinder: ignore*/ - snprintf(buf, MAX_STRING, "%u", computeEstateFlags()); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat("%u", computeEstateFlags()); msg->nextBlock("ParamList"); - msg->addString("Parameter", buf); + msg->addString("Parameter", buffer); F32 sun_hour = getSunHour(); if (childGetValue("use_global_time_check").asBoolean()) @@ -2316,9 +2313,9 @@ void LLPanelEstateInfo::commitEstateInfoDataserver() sun_hour = 0.f; // 0 = global time } - snprintf(buf, MAX_STRING, "%d", (S32)(sun_hour*1024.0f)); /* Flawfinder: ignore */ + buffer = llformat("%d", (S32)(sun_hour*1024.0f)); msg->nextBlock("ParamList"); - msg->addString("Parameter", buf); + msg->addString("Parameter", buffer); gAgent.sendMessage(); } @@ -2489,8 +2486,8 @@ void LLPanelEstateInfo::setAccessAllowedEnabled(bool enable_agent, // static void LLPanelEstateInfo::callbackCacheName( const LLUUID& id, - const char* first, - const char* last, + const std::string& first, + const std::string& last, BOOL is_group, void*) { @@ -2505,9 +2502,7 @@ void LLPanelEstateInfo::callbackCacheName( } else { - name = first; - name += " "; - name += last; + name = first + " " + last; } self->setOwnerName(name); @@ -2556,7 +2551,7 @@ BOOL LLPanelEstateInfo::checkRemovalButton(std::string name) // enable the remove button if something is selected LLNameListCtrl* name_list = getChild<LLNameListCtrl>(name); - childSetEnabled(btn_name.c_str(), name_list && name_list->getFirstSelected() ? TRUE : FALSE); + childSetEnabled(btn_name, name_list && name_list->getFirstSelected() ? TRUE : FALSE); return (btn_name != ""); } @@ -2576,13 +2571,13 @@ BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl) void LLPanelEstateInfo::onClickMessageEstate(void* userdata) { llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl; - gViewerWindow->alertXmlEditText("MessageEstate", LLString::format_map_t(), + gViewerWindow->alertXmlEditText("MessageEstate", LLStringUtil::format_map_t(), NULL, NULL, onMessageCommit, userdata); } // static -void LLPanelEstateInfo::onMessageCommit(S32 option, const LLString& text, void* userdata) +void LLPanelEstateInfo::onMessageCommit(S32 option, const std::string& text, void* userdata) { if(option != 0) return; if(text.empty()) return; @@ -2683,7 +2678,7 @@ BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { LLInventoryItem* item = (LLInventoryItem*)cargo_data; @@ -2809,7 +2804,7 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) ) { - if( !panelp->mEditor->importBuffer( buffer ) ) + if( !panelp->mEditor->importBuffer( buffer, file_length+1 ) ) { llwarns << "Problem importing estate covenant." << llendl; gViewerWindow->alertXml("ProblemImportingEstateCovenant"); @@ -2972,12 +2967,12 @@ bool LLDispatchEstateUpdateInfo::operator()( // NOTE: LLDispatcher extracts strings with an extra \0 at the // end. If we pass the std::string direct to the UI/renderer // it draws with a weird character at the end of the string. - std::string estate_name = strings[0].c_str(); + std::string estate_name = strings[0].c_str(); // preserve c_str() call! panel->setEstateName(estate_name); if (strings.size() > 9) { - std::string abuse_email = strings[9].c_str(); + std::string abuse_email = strings[9].c_str(); // preserve c_str() call! panel->setAbuseEmailAddress(abuse_email); } else @@ -2987,7 +2982,7 @@ bool LLDispatchEstateUpdateInfo::operator()( LLViewerRegion* regionp = gAgent.getRegion(); - LLUUID owner_id(strings[1].c_str()); + LLUUID owner_id(strings[1]); regionp->setOwner(owner_id); // Update estate owner name in UI const BOOL is_group = FALSE; @@ -3105,7 +3100,7 @@ bool LLDispatchSetEstateAccess::operator()( allowed_agent_name_list->addNameItem(id); } panel->childSetEnabled("remove_allowed_avatar_btn", allowed_agent_name_list->getFirstSelected() ? TRUE : FALSE); - allowed_agent_name_list->sortByColumn(0, TRUE); + allowed_agent_name_list->sortByColumnIndex(0, TRUE); } } @@ -3129,7 +3124,7 @@ bool LLDispatchSetEstateAccess::operator()( allowed_group_name_list->addGroupNameItem(id); } panel->childSetEnabled("remove_allowed_group_btn", allowed_group_name_list->getFirstSelected() ? TRUE : FALSE); - allowed_group_name_list->sortByColumn(0, TRUE); + allowed_group_name_list->sortByColumnIndex(0, TRUE); } } @@ -3161,7 +3156,7 @@ bool LLDispatchSetEstateAccess::operator()( banned_agent_name_list->addNameItem(id); } panel->childSetEnabled("remove_banned_avatar_btn", banned_agent_name_list->getFirstSelected() ? TRUE : FALSE); - banned_agent_name_list->sortByColumn(0, TRUE); + banned_agent_name_list->sortByColumnIndex(0, TRUE); } } @@ -3188,7 +3183,7 @@ bool LLDispatchSetEstateAccess::operator()( estate_manager_name_list->addNameItem(id); } panel->childSetEnabled("remove_estate_manager_btn", estate_manager_name_list->getFirstSelected() ? TRUE : FALSE); - estate_manager_name_list->sortByColumn(0, TRUE); + estate_manager_name_list->sortByColumnIndex(0, TRUE); } } diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index b7ee1cc17b..7d05ffa5bc 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -102,7 +102,7 @@ protected: class LLPanelRegionInfo : public LLPanel { public: - LLPanelRegionInfo() : LLPanel("Region Info Panel") {} + LLPanelRegionInfo() : LLPanel(std::string("Region Info Panel")) {} static void onBtnSet(void* user_data); static void onChangeChildCtrl(LLUICtrl* ctrl, void* user_data); static void onChangeAnything(LLUICtrl* ctrl, void* user_data); @@ -114,13 +114,13 @@ public: virtual BOOL postBuild(); virtual void updateChild(LLUICtrl* child_ctrl); - void enableButton(const char* btn_name, BOOL enable = TRUE); - void disableButton(const char* btn_name); + void enableButton(const std::string& btn_name, BOOL enable = TRUE); + void disableButton(const std::string& btn_name); protected: - void initCtrl(const char* name); - void initTextCtrl(const char* name); - void initHelpBtn(const char* name, const char* xml_alert); + void initCtrl(const std::string& name); + void initTextCtrl(const std::string& name); + void initHelpBtn(const std::string& name, const std::string& xml_alert); // Callback for all help buttons, data is name of XML alert to show. static void onClickHelp(void* data); @@ -133,7 +133,7 @@ protected: //typedef std::vector<U32> integers_t; void sendEstateOwnerMessage( LLMessageSystem* msg, - const char* request, + const std::string& request, const LLUUID& invoice, const strings_t& strings); @@ -164,7 +164,7 @@ protected: static void onClickKickAll(void* userdata); static void onKickAllCommit(S32 option, void* userdata); static void onClickMessage(void* userdata); - static void onMessageCommit(S32 option, const LLString& text, void* userdata); + static void onMessageCommit(S32 option, const std::string& text, void* userdata); static void onClickManageTelehub(void* data); }; @@ -276,11 +276,11 @@ public: static void addAllowedGroup2(LLUUID id, void* data); // Core methods for all above add/remove button clicks - static void accessAddCore(U32 operation_flag, const char* dialog_name); + static void accessAddCore(U32 operation_flag, const std::string& dialog_name); static void accessAddCore2(S32 option, void* data); static void accessAddCore3(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data); - static void accessRemoveCore(U32 operation_flag, const char* dialog_name, const char* list_ctrl_name); + static void accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name); static void accessRemoveCore2(S32 option, void* data); // used for both add and remove operations @@ -292,7 +292,7 @@ public: static void onKickUserCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata); static void onClickMessageEstate(void* data); - static void onMessageCommit(S32 option, const LLString& text, void* data); + static void onMessageCommit(S32 option, const std::string& text, void* data); LLPanelEstateInfo(); ~LLPanelEstateInfo() {} @@ -337,8 +337,8 @@ public: // llmessage/llcachename.h:LLCacheNameCallback static void callbackCacheName( const LLUUID& id, - const char* first, - const char* last, + const std::string& first, + const std::string& last, BOOL is_group, void*); @@ -377,7 +377,7 @@ public: BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg); + std::string& tooltip_msg); static void confirmChangeCovenantCallback(S32 option, void* userdata); static void resetCovenantID(void* userdata); static void confirmResetCovenantCallback(S32 option, void* userdata); diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 369ac4f3ee..d00157da76 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -137,8 +137,8 @@ LLFloaterReporter::LLFloaterReporter( if (pick_btn) { // XUI: Why aren't these in viewerart.ini? - pick_btn->setImages( "UIImgFaceUUID", - "UIImgFaceSelectedUUID" ); + pick_btn->setImages( std::string("UIImgFaceUUID"), + std::string("UIImgFaceSelectedUUID") ); childSetAction("pick_btn", onClickObjPicker, this); } @@ -173,8 +173,8 @@ LLFloaterReporter::LLFloaterReporter( setVisible(TRUE); // Default text to be blank - childSetText("object_name", LLString::null); - childSetText("owner_name", LLString::null); + childSetText("object_name", LLStringUtil::null); + childSetText("owner_name", LLStringUtil::null); childSetFocus("summary_edit"); @@ -308,7 +308,7 @@ void LLFloaterReporter::getObjectInfo(const LLUUID& object_id) if (objectp->isAvatar()) { // we have the information we need - LLString object_owner; + std::string object_owner; LLNameValue* firstname = objectp->getNVPair("FirstName"); LLNameValue* lastname = objectp->getNVPair("LastName"); @@ -391,10 +391,10 @@ void LLFloaterReporter::onClickSend(void *userdata) { if ( ! self->mCopyrightWarningSeen ) { - LLString details_lc = self->childGetText("details_edit"); - LLString::toLower( details_lc ); - LLString summary_lc = self->childGetText("summary_edit"); - LLString::toLower( summary_lc ); + std::string details_lc = self->childGetText("details_edit"); + LLStringUtil::toLower( details_lc ); + std::string summary_lc = self->childGetText("summary_edit"); + LLStringUtil::toLower( summary_lc ); if ( details_lc.find( "copyright" ) != std::string::npos || summary_lc.find( "copyright" ) != std::string::npos ) { @@ -457,8 +457,8 @@ void LLFloaterReporter::onClickObjPicker(void *userdata) LLToolObjPicker::getInstance()->setExitCallback(LLFloaterReporter::closePickTool, self); LLToolMgr::getInstance()->setTransientTool(LLToolObjPicker::getInstance()); self->mPicking = TRUE; - self->childSetText("object_name", LLString::null); - self->childSetText("owner_name", LLString::null); + self->childSetText("object_name", LLStringUtil::null); + self->childSetText("owner_name", LLStringUtil::null); LLButton* pick_btn = self->getChild<LLButton>("pick_btn"); if (pick_btn) pick_btn->setToggleState(TRUE); } @@ -517,7 +517,7 @@ void LLFloaterReporter::showFromMenu(EReportType report_type) } // grab the user's name - LLString fullname; + std::string fullname; gAgent.buildFullname(fullname); f->childSetText("reporter_field", fullname); } @@ -532,7 +532,7 @@ void LLFloaterReporter::showFromObject(const LLUUID& object_id) f->setFocus(TRUE); // grab the user's name - LLString fullname; + std::string fullname; gAgent.buildFullname(fullname); f->childSetText("reporter_field", fullname); @@ -577,7 +577,7 @@ LLFloaterReporter* LLFloaterReporter::createNewBugReporter() -void LLFloaterReporter::setPickedObjectProperties(const LLString& object_name, const LLString& owner_name, const LLUUID owner_id) +void LLFloaterReporter::setPickedObjectProperties(const std::string& object_name, const std::string& owner_name, const LLUUID owner_id) { childSetText("object_name", object_name); childSetText("owner_name", owner_name); @@ -661,7 +661,7 @@ LLSD LLFloaterReporter::gatherReport() summary << "Preview "; } - LLString category_name; + std::string category_name; LLComboBox* combo = getChild<LLComboBox>( "category_combo"); if (combo) { @@ -711,8 +711,8 @@ LLSD LLFloaterReporter::gatherReport() << LL_VERSION_PATCH << "." << LL_VIEWER_BUILD << std::endl << std::endl; } - LLString object_name = childGetText("object_name"); - LLString owner_name = childGetText("owner_name"); + std::string object_name = childGetText("object_name"); + std::string owner_name = childGetText("owner_name"); if (!object_name.empty() && !owner_name.empty()) { details << "Object: " << object_name << "\n"; @@ -727,9 +727,8 @@ LLSD LLFloaterReporter::gatherReport() details << childGetValue("details_edit").asString(); - char version_string[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(version_string, /* Flawfinder: ignore */ - MAX_STRING, + std::string version_string; + version_string = llformat( "%d.%d.%d %s %s %s %s", LL_VERSION_MAJOR, LL_VERSION_MINOR, @@ -794,7 +793,7 @@ void LLFloaterReporter::sendReportViaLegacy(const LLSD & report) msg->addString("AbuseRegionName", report["abuse-region-name"].asString()); msg->addUUID("AbuseRegionID", report["abuse-region-id"].asUUID()); - msg->addStringFast(_PREHASH_Summary, report["summary"].asString().c_str()); + msg->addStringFast(_PREHASH_Summary, report["summary"].asString()); msg->addString("VersionString", report["version-string"]); msg->addStringFast(_PREHASH_Details, report["details"] ); @@ -908,7 +907,7 @@ void LLFloaterReporter::takeScreenshot() { texture->setImageAssetID(mResourceDatap->mAssetInfo.mUuid); texture->setDefaultImageAssetID(mResourceDatap->mAssetInfo.mUuid); - texture->setCaption("Screenshot"); + texture->setCaption(std::string("Screenshot")); } } @@ -937,7 +936,7 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, if(result < 0) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); gViewerWindow->alertXml("ErrorUploadingReportScreenshot", args); @@ -975,14 +974,14 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, void LLFloaterReporter::setPosBox(const LLVector3d &pos) { mPosition.setVec(pos); - LLString pos_string = llformat("{%.1f, %.1f, %.1f}", + std::string pos_string = llformat("{%.1f, %.1f, %.1f}", mPosition.mV[VX], mPosition.mV[VY], mPosition.mV[VZ]); childSetText("pos_field", pos_string); } -void LLFloaterReporter::setDescription(const LLString& description, LLMeanCollisionData *mcd) +void LLFloaterReporter::setDescription(const std::string& description, LLMeanCollisionData *mcd) { LLFloaterReporter *self = gReporterInstances[COMPLAINT_REPORT]; if (self) @@ -998,7 +997,7 @@ void LLFloaterReporter::setDescription(const LLString& description, LLMeanCollis } } -void LLFloaterReporter::addDescription(const LLString& description, LLMeanCollisionData *mcd) +void LLFloaterReporter::addDescription(const std::string& description, LLMeanCollisionData *mcd) { LLFloaterReporter *self = gReporterInstances[COMPLAINT_REPORT]; if (self) diff --git a/indra/newview/llfloaterreporter.h b/indra/newview/llfloaterreporter.h index d015b88197..db6d3ef38a 100644 --- a/indra/newview/llfloaterreporter.h +++ b/indra/newview/llfloaterreporter.h @@ -100,8 +100,8 @@ public: static void onClickSelectAbuser (void *userdata); static void closePickTool (void *userdata); static void uploadDoneCallback(const LLUUID &uuid, void* user_data, S32 result, LLExtStat ext_status); - static void addDescription(const LLString& description, LLMeanCollisionData *mcd = NULL); - static void setDescription(const LLString& description, LLMeanCollisionData *mcd = NULL); + static void addDescription(const std::string& description, LLMeanCollisionData *mcd = NULL); + static void setDescription(const std::string& description, LLMeanCollisionData *mcd = NULL); // returns a pointer to reporter of report_type static LLFloaterReporter* getReporter(EReportType report_type); @@ -111,7 +111,7 @@ public: // static static void processRegionInfo(LLMessageSystem* msg); - void setPickedObjectProperties(const LLString& object_name, const LLString& owner_name, const LLUUID owner_id); + void setPickedObjectProperties(const std::string& object_name, const std::string& owner_name, const LLUUID owner_id); private: void takeScreenshot(); @@ -137,7 +137,7 @@ private: LLVector3 mPosition; BOOL mCopyrightWarningSeen; std::list<LLMeanCollisionData*> mMCDList; - LLString mDefaultSummary; + std::string mDefaultSummary; LLResourceData* mResourceDatap; }; diff --git a/indra/newview/llfloaterscriptdebug.cpp b/indra/newview/llfloaterscriptdebug.cpp index 14bc721e8e..7992abad94 100644 --- a/indra/newview/llfloaterscriptdebug.cpp +++ b/indra/newview/llfloaterscriptdebug.cpp @@ -124,7 +124,7 @@ LLFloater* LLFloaterScriptDebug::addOutputWindow(const LLUUID &object_id) void LLFloaterScriptDebug::addScriptLine(const std::string &utf8mesg, const std::string &user_name, const LLColor4& color, const LLUUID& source_id) { LLViewerObject* objectp = gObjectList.findObject(source_id); - LLString floater_label; + std::string floater_label; if (objectp) { @@ -161,7 +161,7 @@ LLFloaterScriptDebugOutput::LLFloaterScriptDebugOutput() } LLFloaterScriptDebugOutput::LLFloaterScriptDebugOutput(const LLUUID& object_id) -: LLFloater("script instance floater", LLRect(0, 200, 200, 0), "Script", TRUE), mObjectID(object_id) +: LLFloater(std::string("script instance floater"), LLRect(0, 200, 200, 0), std::string("Script"), TRUE), mObjectID(object_id) { S32 y = getRect().getHeight() - LLFLOATER_HEADER_SIZE - LLFLOATER_VPAD; S32 x = LLFLOATER_HPAD; @@ -172,8 +172,8 @@ LLFloaterScriptDebugOutput::LLFloaterScriptDebugOutput(const LLUUID& object_id) y, getRect().getWidth() - LLFLOATER_HPAD, LLFLOATER_VPAD ); - mHistoryEditor = new LLViewerTextEditor( "Chat History Editor", - history_editor_rect, S32_MAX, "", LLFontGL::sSansSerif); + mHistoryEditor = new LLViewerTextEditor( std::string("Chat History Editor"), + history_editor_rect, S32_MAX, LLStringUtil::null, LLFontGL::sSansSerif); mHistoryEditor->setWordWrap( TRUE ); mHistoryEditor->setFollowsAll(); mHistoryEditor->setEnabled( FALSE ); @@ -181,7 +181,7 @@ LLFloaterScriptDebugOutput::LLFloaterScriptDebugOutput(const LLUUID& object_id) addChild(mHistoryEditor); } -void LLFloaterScriptDebugOutput::initFloater(const LLString& title, BOOL resizable, +void LLFloaterScriptDebugOutput::initFloater(const std::string& title, BOOL resizable, S32 min_width, S32 min_height, BOOL drag_on_left, BOOL minimizable, BOOL close_btn) { @@ -195,8 +195,8 @@ void LLFloaterScriptDebugOutput::initFloater(const LLString& title, BOOL resizab y, getRect().getWidth() - LLFLOATER_HPAD, LLFLOATER_VPAD ); - mHistoryEditor = new LLViewerTextEditor( "Chat History Editor", - history_editor_rect, S32_MAX, "", LLFontGL::sSansSerif); + mHistoryEditor = new LLViewerTextEditor( std::string("Chat History Editor"), + history_editor_rect, S32_MAX, LLStringUtil::null, LLFontGL::sSansSerif); mHistoryEditor->setWordWrap( TRUE ); mHistoryEditor->setFollowsAll(); mHistoryEditor->setEnabled( FALSE ); diff --git a/indra/newview/llfloaterscriptdebug.h b/indra/newview/llfloaterscriptdebug.h index 05e6629913..96365465f9 100644 --- a/indra/newview/llfloaterscriptdebug.h +++ b/indra/newview/llfloaterscriptdebug.h @@ -62,7 +62,7 @@ public: LLFloaterScriptDebugOutput(const LLUUID& object_id); ~LLFloaterScriptDebugOutput(); - virtual void initFloater(const LLString& title, BOOL resizable, + virtual void initFloater(const std::string& title, BOOL resizable, S32 min_width, S32 min_height, BOOL drag_on_left, BOOL minimizable, BOOL close_btn); diff --git a/indra/newview/llfloatersellland.cpp b/indra/newview/llfloatersellland.cpp index 025d726b82..749ccbe7fa 100644 --- a/indra/newview/llfloatersellland.cpp +++ b/indra/newview/llfloatersellland.cpp @@ -138,7 +138,7 @@ LLFloaterSellLandUI* LLFloaterSellLandUI::soleInstance(bool createIfNeeded) } LLFloaterSellLandUI::LLFloaterSellLandUI() -: LLFloater("Sell Land"), +: LLFloater(std::string("Sell Land")), mRegion(0) { } @@ -243,7 +243,7 @@ void LLFloaterSellLandUI::updateParcelInfo() if(mSellToBuyer) { - LLString name; + std::string name; gCacheName->getFullName(mAuthorizedBuyer, name); childSetText("sell_to_agent", name); } @@ -251,12 +251,12 @@ void LLFloaterSellLandUI::updateParcelInfo() void LLFloaterSellLandUI::setBadge(const char* id, Badge badge) { - static LLString badgeOK("badge_ok.j2c"); - static LLString badgeNote("badge_note.j2c"); - static LLString badgeWarn("badge_warn.j2c"); - static LLString badgeError("badge_error.j2c"); + static std::string badgeOK("badge_ok.j2c"); + static std::string badgeNote("badge_note.j2c"); + static std::string badgeWarn("badge_warn.j2c"); + static std::string badgeError("badge_error.j2c"); - LLString badgeName; + std::string badgeName; switch (badge) { default: @@ -283,7 +283,7 @@ void LLFloaterSellLandUI::refreshUI() childSetText("info_parcel", parcelp->getName()); childSetTextArg("info_size", "[AREA]", llformat("%d", mParcelActualArea)); - LLString price_str = childGetValue("price").asString(); + std::string price_str = childGetValue("price").asString(); bool valid_price = false; valid_price = (price_str != "") && LLLineEditor::prevalidateNonNegativeS32(utf8str_to_wstring(price_str)); @@ -331,7 +331,7 @@ void LLFloaterSellLandUI::refreshUI() } // Must select Sell To: Anybody, or User (with a specified username) - LLString sell_to = childGetValue("sell_to").asString(); + std::string sell_to = childGetValue("sell_to").asString(); bool valid_sell_to = "select" != sell_to && ("user" != sell_to || mAuthorizedBuyer.notNull()); @@ -370,7 +370,7 @@ void LLFloaterSellLandUI::onChangeValue(LLUICtrl *ctrl, void *userdata) { LLFloaterSellLandUI *self = (LLFloaterSellLandUI *)userdata; - LLString sell_to = self->childGetValue("sell_to").asString(); + std::string sell_to = self->childGetValue("sell_to").asString(); if (sell_to == "user") { @@ -481,7 +481,7 @@ void LLFloaterSellLandUI::doSellLand(void *userdata) return; } - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[LAND_SIZE]"] = llformat("%d",area); args["[SALE_PRICE]"] = llformat("%d",sale_price); args["[NAME]"] = authorizedBuyerName; diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp index 2b7d10a7a9..e362da411d 100644 --- a/indra/newview/llfloatersettingsdebug.cpp +++ b/indra/newview/llfloatersettingsdebug.cpp @@ -41,7 +41,7 @@ LLFloaterSettingsDebug* LLFloaterSettingsDebug::sInstance = NULL; -LLFloaterSettingsDebug::LLFloaterSettingsDebug() : LLFloater("Configuration Editor") +LLFloaterSettingsDebug::LLFloaterSettingsDebug() : LLFloater(std::string("Configuration Editor")) { } @@ -58,7 +58,7 @@ BOOL LLFloaterSettingsDebug::postBuild() { LLComboBox* combo; f(LLComboBox* c) : combo(c) {} - virtual void apply(const LLString& name, LLControlVariable* control) + virtual void apply(const std::string& name, LLControlVariable* control) { combo->add(name, (void*)control); } @@ -235,7 +235,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) spinner4->setVisible(FALSE); color_swatch->setVisible(FALSE); childSetVisible("val_text", FALSE); - mComment->setText(LLString::null); + mComment->setText(LLStringUtil::null); if (controlp) { @@ -276,7 +276,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) { case TYPE_U32: spinner1->setVisible(TRUE); - spinner1->setLabel(LLString("value")); // Debug, don't translate + spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setValue(sd); @@ -288,7 +288,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) break; case TYPE_S32: spinner1->setVisible(TRUE); - spinner1->setLabel(LLString("value")); // Debug, don't translate + spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setValue(sd); @@ -300,7 +300,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) break; case TYPE_F32: spinner1->setVisible(TRUE); - spinner1->setLabel(LLString("value")); // Debug, don't translate + spinner1->setLabel(std::string("value")); // Debug, don't translate if (!spinner1->hasFocus()) { spinner1->setPrecision(3); @@ -332,11 +332,11 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) LLVector3 v; v.setValue(sd); spinner1->setVisible(TRUE); - spinner1->setLabel(LLString("X")); + spinner1->setLabel(std::string("X")); spinner2->setVisible(TRUE); - spinner2->setLabel(LLString("Y")); + spinner2->setLabel(std::string("Y")); spinner3->setVisible(TRUE); - spinner3->setLabel(LLString("Z")); + spinner3->setLabel(std::string("Z")); if (!spinner1->hasFocus()) { spinner1->setPrecision(3); @@ -359,11 +359,11 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) LLVector3d v; v.setValue(sd); spinner1->setVisible(TRUE); - spinner1->setLabel(LLString("X")); + spinner1->setLabel(std::string("X")); spinner2->setVisible(TRUE); - spinner2->setLabel(LLString("Y")); + spinner2->setLabel(std::string("Y")); spinner3->setVisible(TRUE); - spinner3->setLabel(LLString("Z")); + spinner3->setLabel(std::string("Z")); if (!spinner1->hasFocus()) { spinner1->setPrecision(3); @@ -386,13 +386,13 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) LLRect r; r.setValue(sd); spinner1->setVisible(TRUE); - spinner1->setLabel(LLString("Left")); + spinner1->setLabel(std::string("Left")); spinner2->setVisible(TRUE); - spinner2->setLabel(LLString("Right")); + spinner2->setLabel(std::string("Right")); spinner3->setVisible(TRUE); - spinner3->setLabel(LLString("Bottom")); + spinner3->setLabel(std::string("Bottom")); spinner4->setVisible(TRUE); - spinner4->setLabel(LLString("Top")); + spinner4->setLabel(std::string("Top")); if (!spinner1->hasFocus()) { spinner1->setPrecision(0); @@ -442,7 +442,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) color_swatch->set(LLColor4(sd), TRUE, FALSE); } spinner4->setVisible(TRUE); - spinner4->setLabel(LLString("Alpha")); + spinner4->setLabel(std::string("Alpha")); if (!spinner4->hasFocus()) { spinner4->setPrecision(3); @@ -470,7 +470,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) color_swatch->set(LLColor4(clr), TRUE, FALSE); } spinner4->setVisible(TRUE); - spinner4->setLabel(LLString("Alpha")); + spinner4->setLabel(std::string("Alpha")); if(!spinner4->hasFocus()) { spinner4->setPrecision(0); @@ -484,7 +484,7 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) break; } default: - mComment->setText(LLString("unknown")); + mComment->setText(std::string("unknown")); break; } } diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 7dd4f293c4..1f601e6dc1 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -192,7 +192,7 @@ public: std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList; LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : - LLView("snapshot_live_preview", rect, FALSE), + LLView(std::string("snapshot_live_preview"), rect, FALSE), mColor(1.f, 0.f, 0.f, 0.5f), mCurImageIndex(0), mRawImage(NULL), @@ -1771,7 +1771,7 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat // Default constructor LLFloaterSnapshot::LLFloaterSnapshot() - : LLFloater("Snapshot Floater"), + : LLFloater(std::string("Snapshot Floater")), impl (*(new Impl)) { } @@ -1879,7 +1879,7 @@ void LLFloaterSnapshot::draw() { LLLocale locale(LLLocale::USER_LOCALE); - LLString bytes_string; + std::string bytes_string; if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_POSTCARD && previewp->getDataSize() > MAX_POSTCARD_DATASIZE) { @@ -1894,7 +1894,7 @@ void LLFloaterSnapshot::draw() if (previewp->getSnapshotUpToDate()) { - LLString bytes_string; + std::string bytes_string; LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); childSetTextArg("file_size_label", "[SIZE]", bytes_string); } @@ -1909,7 +1909,7 @@ void LLFloaterSnapshot::draw() } else { - childSetTextArg("file_size_label", "[SIZE]", LLString("???")); + childSetTextArg("file_size_label", "[SIZE]", std::string("???")); childSetEnabled("upload_btn", FALSE); childSetEnabled("send_btn", FALSE); childSetEnabled("save_btn", FALSE); @@ -1917,7 +1917,7 @@ void LLFloaterSnapshot::draw() BOOL ui_in_snapshot = gSavedSettings.getBOOL("RenderUIInSnapshot"); childSetValue("ui_check", ui_in_snapshot); - childSetToolTip("ui_check", "If selected shows the UI in the snapshot"); + childSetToolTip("ui_check", std::string("If selected shows the UI in the snapshot")); } LLFloater::draw(); @@ -2025,7 +2025,7 @@ void LLFloaterSnapshot::update() //============================================================================ -LLSnapshotFloaterView::LLSnapshotFloaterView( const LLString& name, const LLRect& rect ) : LLFloaterView(name, rect) +LLSnapshotFloaterView::LLSnapshotFloaterView( const std::string& name, const LLRect& rect ) : LLFloaterView(name, rect) { setMouseOpaque(TRUE); setEnabled(FALSE); diff --git a/indra/newview/llfloatersnapshot.h b/indra/newview/llfloatersnapshot.h index fecc3f0fd5..a7aee1143c 100644 --- a/indra/newview/llfloatersnapshot.h +++ b/indra/newview/llfloatersnapshot.h @@ -69,7 +69,7 @@ private: class LLSnapshotFloaterView : public LLFloaterView { public: - LLSnapshotFloaterView( const LLString& name, const LLRect& rect ); + LLSnapshotFloaterView( const std::string& name, const LLRect& rect ); virtual ~LLSnapshotFloaterView(); /*virtual*/ BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); diff --git a/indra/newview/llfloatertelehub.cpp b/indra/newview/llfloatertelehub.cpp index 65b6d55480..0b4a05867f 100644 --- a/indra/newview/llfloatertelehub.cpp +++ b/indra/newview/llfloatertelehub.cpp @@ -81,7 +81,7 @@ void LLFloaterTelehub::show() } LLFloaterTelehub::LLFloaterTelehub() -: LLFloater("telehub"), +: LLFloater(std::string("telehub")), mTelehubObjectID(), mTelehubObjectName(), mTelehubPos(), @@ -244,8 +244,8 @@ void LLFloaterTelehub::onClickRemoveSpawnPoint(void* data) msg->nextBlock("ParamList"); msg->addString("Parameter", "spawnpoint remove"); - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buffer, MAX_STRING, "%d", spawn_index); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat("%d", spawn_index); msg->nextBlock("ParamList"); msg->addString("Parameter", buffer); @@ -263,11 +263,8 @@ void LLFloaterTelehub::processTelehubInfo(LLMessageSystem* msg, void**) void LLFloaterTelehub::unpackTelehubInfo(LLMessageSystem* msg) { - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - msg->getUUID("TelehubBlock", "ObjectID", mTelehubObjectID); - msg->getString("TelehubBlock", "ObjectName", MAX_STRING, buffer); - mTelehubObjectName = buffer; + msg->getString("TelehubBlock", "ObjectName", mTelehubObjectName); msg->getVector3("TelehubBlock", "TelehubPos", mTelehubPos); msg->getQuat("TelehubBlock", "TelehubRot", mTelehubRot); @@ -301,7 +298,7 @@ void LLFloaterTelehub::unpackTelehubInfo(LLMessageSystem* msg) list->deleteAllItems(); for (S32 i = 0; i < mNumSpawn; i++) { - LLString pos = llformat("%.1f, %.1f, %.1f", + std::string pos = llformat("%.1f, %.1f, %.1f", mSpawnPointPos[i].mV[VX], mSpawnPointPos[i].mV[VY], mSpawnPointPos[i].mV[VZ]); diff --git a/indra/newview/llfloatertelehub.h b/indra/newview/llfloatertelehub.h index dd7631f6dd..9957d60ec9 100644 --- a/indra/newview/llfloatertelehub.h +++ b/indra/newview/llfloatertelehub.h @@ -68,7 +68,7 @@ private: private: LLUUID mTelehubObjectID; // null if no telehub - LLString mTelehubObjectName; + std::string mTelehubObjectName; LLVector3 mTelehubPos; // region local, fallback if viewer can't see the object LLQuaternion mTelehubRot; diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index b8f7e3ed0a..a8192e544c 100644 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -82,13 +82,13 @@ LLFloaterTools *gFloaterTools = NULL; -const LLString PANEL_NAMES[LLFloaterTools::PANEL_COUNT] = +const std::string PANEL_NAMES[LLFloaterTools::PANEL_COUNT] = { - LLString("General"), // PANEL_GENERAL, - LLString("Object"), // PANEL_OBJECT, - LLString("Features"), // PANEL_FEATURES, - LLString("Texture"), // PANEL_FACE, - LLString("Content"), // PANEL_CONTENTS, + std::string("General"), // PANEL_GENERAL, + std::string("Object"), // PANEL_OBJECT, + std::string("Features"), // PANEL_FEATURES, + std::string("Texture"), // PANEL_FACE, + std::string("Content"), // PANEL_CONTENTS, }; // Local prototypes @@ -158,7 +158,7 @@ void* LLFloaterTools::createPanelContents(void* data) void* LLFloaterTools::createPanelContentsInventory(void* data) { LLFloaterTools* floater = (LLFloaterTools*)data; - floater->mPanelContents->mPanelInventory = new LLPanelInventory("ContentsInventory", LLRect()); + floater->mPanelContents->mPanelInventory = new LLPanelInventory(std::string("ContentsInventory"), LLRect()); return floater->mPanelContents->mPanelInventory; } @@ -166,7 +166,7 @@ void* LLFloaterTools::createPanelContentsInventory(void* data) void* LLFloaterTools::createPanelLandInfo(void* data) { LLFloaterTools* floater = (LLFloaterTools*)data; - floater->mPanelLandInfo = new LLPanelLandInfo("land info panel"); + floater->mPanelLandInfo = new LLPanelLandInfo(std::string("land info panel")); return floater->mPanelLandInfo; } @@ -236,7 +236,7 @@ BOOL LLFloaterTools::postBuild() // Create Buttons // - static const LLString toolNames[]={ + static const std::string toolNames[]={ "ToolCube", "ToolPrism", "ToolPyramid", @@ -335,7 +335,7 @@ BOOL LLFloaterTools::postBuild() // Create the popupview with a dummy center. It will be moved into place // during LLViewerWindow's per-frame hover processing. LLFloaterTools::LLFloaterTools() -: LLFloater("toolbox floater"), +: LLFloater(std::string("toolbox floater")), mBtnFocus(NULL), mBtnMove(NULL), mBtnEdit(NULL), @@ -765,7 +765,7 @@ void LLFloaterTools::onOpen() mParcelSelection = LLViewerParcelMgr::getInstance()->getFloatingParcelSelection(); mObjectSelection = LLSelectMgr::getInstance()->getEditSelection(); - gMenuBarView->setItemVisible("Tools", TRUE); + gMenuBarView->setItemVisible(std::string("Tools"), TRUE); gMenuBarView->arrange(); } @@ -799,7 +799,7 @@ void LLFloaterTools::onClose(bool app_quitting) // so manually reset tool to default (pie menu tool) LLToolMgr::getInstance()->getCurrentToolset()->selectFirstTool(); - gMenuBarView->setItemVisible("Tools", FALSE); + gMenuBarView->setItemVisible(std::string("Tools"), FALSE); gMenuBarView->arrange(); } diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp index 5d2f21e370..93622ed94e 100644 --- a/indra/newview/llfloatertopobjects.cpp +++ b/indra/newview/llfloatertopobjects.cpp @@ -67,7 +67,7 @@ void LLFloaterTopObjects::show() } LLFloaterTopObjects::LLFloaterTopObjects() -: LLFloater("top_objects"), +: LLFloater(std::string("top_objects")), mInitialized(FALSE), mtotalScore(0.f) { @@ -124,7 +124,7 @@ BOOL LLFloaterTopObjects::postBuild() mCurrentMode = STAT_REPORT_TOP_SCRIPTS; mFlags = 0; - mFilter = ""; + mFilter.clear(); return TRUE; } @@ -164,8 +164,8 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data) LLUUID task_id; F32 location_x, location_y, location_z; F32 score; - char name_buf[MAX_STRING]; /* Flawfinder: ignore */ - char owner_buf[MAX_STRING]; /* Flawfinder: ignore */ + std::string name_buf; + std::string owner_buf; msg->getU32Fast(_PREHASH_ReportData, _PREHASH_TaskLocalID, task_local_id, block); msg->getUUIDFast(_PREHASH_ReportData, _PREHASH_TaskID, task_id, block); @@ -173,14 +173,14 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data) msg->getF32Fast(_PREHASH_ReportData, _PREHASH_LocationY, location_y, block); msg->getF32Fast(_PREHASH_ReportData, _PREHASH_LocationZ, location_z, block); msg->getF32Fast(_PREHASH_ReportData, _PREHASH_Score, score, block); - msg->getStringFast(_PREHASH_ReportData, _PREHASH_TaskName, MAX_STRING, name_buf, block); - msg->getStringFast(_PREHASH_ReportData, _PREHASH_OwnerName, MAX_STRING, owner_buf, block); + msg->getStringFast(_PREHASH_ReportData, _PREHASH_TaskName, name_buf, block); + msg->getStringFast(_PREHASH_ReportData, _PREHASH_OwnerName, owner_buf, block); LLSD element; element["id"] = task_id; - element["object_name"] = LLString(name_buf); - element["owner_name"] = LLString(owner_buf); + element["object_name"] = name_buf; + element["owner_name"] = owner_buf; element["columns"][0]["column"] = "score"; element["columns"][0]["value"] = llformat("%0.3f", score); element["columns"][0]["font"] = "SANSSERIF"; @@ -393,7 +393,7 @@ void LLFloaterTopObjects::onRefresh(void* data) { U32 mode = STAT_REPORT_TOP_SCRIPTS; U32 flags = 0; - LLString filter = ""; + std::string filter = ""; if (sInstance) { @@ -418,7 +418,7 @@ void LLFloaterTopObjects::onRefresh(void* data) if (sInstance) { - sInstance->mFilter = ""; + sInstance->mFilter.clear(); sInstance->mFlags = 0; } } @@ -451,8 +451,8 @@ void LLFloaterTopObjects::showBeacon() LLScrollListItem* first_selected = list->getFirstSelected(); if (!first_selected) return; - LLString name = first_selected->getColumn(1)->getValue().asString(); - LLString pos_string = first_selected->getColumn(3)->getValue().asString(); + std::string name = first_selected->getColumn(1)->getValue().asString(); + std::string pos_string = first_selected->getColumn(3)->getValue().asString(); F32 x, y, z; S32 matched = sscanf(pos_string.c_str(), "<%g,%g,%g>", &x, &y, &z); @@ -460,6 +460,6 @@ void LLFloaterTopObjects::showBeacon() LLVector3 pos_agent(x, y, z); LLVector3d pos_global = gAgent.getPosGlobalFromAgent(pos_agent); - LLString tooltip(""); + std::string tooltip(""); LLTracker::trackLocation(pos_global, name, tooltip, LLTracker::LOCATION_ITEM); } diff --git a/indra/newview/llfloatertopobjects.h b/indra/newview/llfloatertopobjects.h index cab99c9792..5b23e737d7 100644 --- a/indra/newview/llfloatertopobjects.h +++ b/indra/newview/llfloatertopobjects.h @@ -84,14 +84,14 @@ private: void showBeacon(); private: - LLString mMethod; + std::string mMethod; LLSD mObjectListData; std::vector<LLUUID> mObjectListIDs; U32 mCurrentMode; U32 mFlags; - LLString mFilter; + std::string mFilter; BOOL mInitialized; diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index af3321c814..5ace957694 100644 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -74,7 +74,7 @@ LLFloaterTOS* LLFloaterTOS::show(ETOSType type, const std::string & message) LLFloaterTOS::LLFloaterTOS(ETOSType type, const std::string & message) -: LLModalDialog( " ", 100, 100 ), +: LLModalDialog( std::string(" "), 100, 100 ), mType(type), mMessage(message), mWebBrowserWindowId( 0 ), diff --git a/indra/newview/llfloatertos.h b/indra/newview/llfloatertos.h index e6c487d1a8..2affd66ad5 100644 --- a/indra/newview/llfloatertos.h +++ b/indra/newview/llfloatertos.h @@ -77,7 +77,7 @@ private: private: ETOSType mType; - LLString mMessage; + std::string mMessage; int mWebBrowserWindowId; int mLoadCompleteCount; diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp index 400927632c..69916f80ea 100644 --- a/indra/newview/llfloaterurlentry.cpp +++ b/indra/newview/llfloaterurlentry.cpp @@ -213,7 +213,7 @@ void LLFloaterURLEntry::onBtnOK( void* userdata ) } // leading whitespace causes problems with the MIME-type detection so strip it - LLString::trim( media_url ); + LLStringUtil::trim( media_url ); // First check the URL scheme LLURI url(media_url); diff --git a/indra/newview/llfloatervoicedevicesettings.cpp b/indra/newview/llfloatervoicedevicesettings.cpp index 699f89c944..74d04c7aad 100644 --- a/indra/newview/llfloatervoicedevicesettings.cpp +++ b/indra/newview/llfloatervoicedevicesettings.cpp @@ -105,7 +105,7 @@ void LLPanelVoiceDeviceSettings::draw() { for(S32 power_bar_idx = 0; power_bar_idx < 5; power_bar_idx++) { - LLString view_name = llformat("%s%d", "bar", power_bar_idx); + std::string view_name = llformat("%s%d", "bar", power_bar_idx); LLView* bar_view = getChild<LLView>(view_name); if (bar_view) { @@ -260,7 +260,9 @@ void LLPanelVoiceDeviceSettings::onCommitOutputDevice(LLUICtrl* ctrl, void* user // LLFloaterVoiceDeviceSettings // -LLFloaterVoiceDeviceSettings::LLFloaterVoiceDeviceSettings(const LLSD& seed) : LLFloater("floater_device_settings"), mDevicePanel(NULL) +LLFloaterVoiceDeviceSettings::LLFloaterVoiceDeviceSettings(const LLSD& seed) + : LLFloater(std::string("floater_device_settings")), + mDevicePanel(NULL) { mFactoryMap["device_settings"] = LLCallbackMap(createPanelVoiceDeviceSettings, this); // do not automatically open singleton floaters (as result of getInstance()) diff --git a/indra/newview/llfloaterwater.cpp b/indra/newview/llfloaterwater.cpp index f3f25f7847..c540a0b37c 100644 --- a/indra/newview/llfloaterwater.cpp +++ b/indra/newview/llfloaterwater.cpp @@ -65,7 +65,7 @@ LLFloaterWater* LLFloaterWater::sWaterMenu = NULL; std::set<std::string> LLFloaterWater::sDefaultPresets; -LLFloaterWater::LLFloaterWater() : LLFloater("water floater") +LLFloaterWater::LLFloaterWater() : LLFloater(std::string("water floater")) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_water.xml"); @@ -85,14 +85,14 @@ LLFloaterWater::LLFloaterWater() : LLFloater("water floater") comboBox->selectByValue(LLSD("Default")); } - LLString def_water = getString("WLDefaultWaterNames"); + std::string def_water = getString("WLDefaultWaterNames"); // no editing or deleting of the blank string sDefaultPresets.insert(""); boost_tokenizer tokens(def_water, boost::char_separator<char>(":")); for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) { - LLString tok(*token_iter); + std::string tok(*token_iter); sDefaultPresets.insert(tok); } @@ -175,8 +175,8 @@ void LLFloaterWater::onClickHelp(void* data) { LLFloaterWater* self = LLFloaterWater::instance(); - const char* xml_alert = (const char*) data; - LLAlertDialog* dialogp = gViewerWindow->alertXml(xml_alert); + const std::string* xml_alert = (std::string*)data; + LLAlertDialog* dialogp = gViewerWindow->alertXml(*xml_alert); if (dialogp) { LLFloater* root_floater = gFloaterView->getParentFloater(self); @@ -185,14 +185,15 @@ void LLFloaterWater::onClickHelp(void* data) root_floater->addDependentFloater(dialogp); } } + delete xml_alert; } -void LLFloaterWater::initHelpBtn(const char* name, const char* xml_alert) +void LLFloaterWater::initHelpBtn(const std::string& name, const std::string& xml_alert) { - childSetAction(name, onClickHelp, (void*)xml_alert); + childSetAction(name, onClickHelp, new std::string(xml_alert)); } -void LLFloaterWater::newPromptCallback(S32 option, const LLString& text, void* userData) +void LLFloaterWater::newPromptCallback(S32 option, const std::string& text, void* userData) { if(text == "") { @@ -207,13 +208,12 @@ void LLFloaterWater::newPromptCallback(S32 option, const LLString& text, void* u // add the current parameters to the list // see if it's there first std::map<std::string, LLWaterParamSet>::iterator mIt = - param_mgr->mParamList.find(text.c_str()); + param_mgr->mParamList.find(text); // if not there, add a new one if(mIt == param_mgr->mParamList.end()) { - param_mgr->addParamSet(text.c_str(), - param_mgr->mCurParams); + param_mgr->addParamSet(text, param_mgr->mCurParams); comboBox->add(text); comboBox->sortByName(); @@ -537,9 +537,9 @@ void LLFloaterWater::onColorControlIMoved(LLUICtrl* ctrl, void* userData) } // set the sliders to the new vals - sWaterMenu->childSetValue(rName.c_str(), colorControl->mR); - sWaterMenu->childSetValue(gName.c_str(), colorControl->mG); - sWaterMenu->childSetValue(bName.c_str(), colorControl->mB); + sWaterMenu->childSetValue(rName, colorControl->mR); + sWaterMenu->childSetValue(gName, colorControl->mG); + sWaterMenu->childSetValue(bName, colorControl->mB); } // now update the current parameters and send them to shaders @@ -597,7 +597,7 @@ void LLFloaterWater::onNormalMapPicked(LLUICtrl* ctrl, void* userData) void LLFloaterWater::onNewPreset(void* userData) { - gViewerWindow->alertXmlEditText("NewWaterPreset", LLString::format_map_t(), + gViewerWindow->alertXmlEditText("NewWaterPreset", LLStringUtil::format_map_t(), NULL, NULL, newPromptCallback, NULL); } @@ -617,7 +617,7 @@ void LLFloaterWater::onSavePreset(void* userData) // check to see if it's a default and shouldn't be overwritten std::set<std::string>::iterator sIt = sDefaultPresets.find( - comboBox->getSelectedItemLabel().c_str()); + comboBox->getSelectedItemLabel()); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("WaterEditPresets")) { gViewerWindow->alertXml("WLNoEditDefault"); @@ -653,7 +653,7 @@ void LLFloaterWater::onDeletePreset(void* userData) return; } - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[SKY]"] = combo_box->getSelectedValue().asString(); gViewerWindow->alertXml("WLDeletePresetAlert", args, deleteAlertCallback, sWaterMenu); } @@ -675,10 +675,10 @@ void LLFloaterWater::deleteAlertCallback(S32 option, void* userdata) mult_sldr = day_cycle->getChild<LLMultiSliderCtrl>("WaterDayCycleKeys"); } - LLString name = combo_box->getSelectedValue().asString(); + std::string name = combo_box->getSelectedValue().asString(); // check to see if it's a default and shouldn't be deleted - std::set<std::string>::iterator sIt = sDefaultPresets.find(name.c_str()); + std::set<std::string>::iterator sIt = sDefaultPresets.find(name); if(sIt != sDefaultPresets.end()) { gViewerWindow->alertXml("WaterNoEditDefault"); diff --git a/indra/newview/llfloaterwater.h b/indra/newview/llfloaterwater.h index 311ef9a75e..883b2a35f1 100644 --- a/indra/newview/llfloaterwater.h +++ b/indra/newview/llfloaterwater.h @@ -61,9 +61,9 @@ public: // help button stuff static void onClickHelp(void* data); - void initHelpBtn(const char* name, const char* xml_alert); + void initHelpBtn(const std::string& name, const std::string& xml_alert); - static void newPromptCallback(S32 option, const LLString& text, void* userData); + static void newPromptCallback(S32 option, const std::string& text, void* userData); /// general purpose callbacks for dealing with color controllers static void onColorControlRMoved(LLUICtrl* ctrl, void* userData); diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp index a83530e53c..f03579a97b 100644 --- a/indra/newview/llfloaterwindlight.cpp +++ b/indra/newview/llfloaterwindlight.cpp @@ -66,7 +66,7 @@ std::set<std::string> LLFloaterWindLight::sDefaultPresets; static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; -LLFloaterWindLight::LLFloaterWindLight() : LLFloater("windlight floater") +LLFloaterWindLight::LLFloaterWindLight() : LLFloater(std::string("windlight floater")) { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_windlight_options.xml"); @@ -83,21 +83,21 @@ LLFloaterWindLight::LLFloaterWindLight() : LLFloater("windlight floater") } // entry for when we're in estate time - comboBox->add(""); + comboBox->add(LLStringUtil::null); // set defaults on combo boxes comboBox->selectByValue(LLSD("Default")); } // add the list of presets - LLString def_days = getString("WLDefaultSkyNames"); + std::string def_days = getString("WLDefaultSkyNames"); // no editing or deleting of the blank string sDefaultPresets.insert(""); boost_tokenizer tokens(def_days, boost::char_separator<char>(":")); for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) { - LLString tok(*token_iter); + std::string tok(*token_iter); sDefaultPresets.insert(tok); } @@ -233,8 +233,8 @@ void LLFloaterWindLight::onClickHelp(void* data) { LLFloaterWindLight* self = LLFloaterWindLight::instance(); - const char* xml_alert = (const char*) data; - LLAlertDialog* dialogp = gViewerWindow->alertXml(xml_alert); + const std::string* xml_alert = (std::string*)data; + LLAlertDialog* dialogp = gViewerWindow->alertXml(*xml_alert); if (dialogp) { LLFloater* root_floater = gFloaterView->getParentFloater(self); @@ -243,15 +243,15 @@ void LLFloaterWindLight::onClickHelp(void* data) root_floater->addDependentFloater(dialogp); } } - + delete xml_alert; } -void LLFloaterWindLight::initHelpBtn(const char* name, const char* xml_alert) +void LLFloaterWindLight::initHelpBtn(const std::string& name, const std::string& xml_alert) { - childSetAction(name, onClickHelp, (void*)xml_alert); + childSetAction(name, onClickHelp, new std::string(xml_alert)); } -void LLFloaterWindLight::newPromptCallback(S32 option, const LLString& text, void* userData) +void LLFloaterWindLight::newPromptCallback(S32 option, const std::string& text, void* userData) { if(text == "") { @@ -274,12 +274,12 @@ void LLFloaterWindLight::newPromptCallback(S32 option, const LLString& text, voi // add the current parameters to the list // see if it's there first std::map<std::string, LLWLParamSet>::iterator mIt = - LLWLParamManager::instance()->mParamList.find(text.c_str()); + LLWLParamManager::instance()->mParamList.find(text); // if not there, add a new one if(mIt == LLWLParamManager::instance()->mParamList.end()) { - LLWLParamManager::instance()->addParamSet(text.c_str(), + LLWLParamManager::instance()->addParamSet(text, LLWLParamManager::instance()->mCurParams); comboBox->add(text); comboBox->sortByName(); @@ -290,7 +290,7 @@ void LLFloaterWindLight::newPromptCallback(S32 option, const LLString& text, voi { comboBox->remove(0); } - comboBox->add(""); + comboBox->add(LLStringUtil::null); comboBox->setSelectedByValue(text, true); if(LLFloaterDayCycle::isOpen()) @@ -319,7 +319,7 @@ void LLFloaterWindLight::syncMenu() //std::map<std::string, LLVector4> & currentParams = param_mgr->mCurParams.mParamValues; // blue horizon - param_mgr->mBlueHorizon = currentParams.getVector(param_mgr->mBlueHorizon.name, err); + param_mgr->mBlueHorizon = currentParams.getVector(param_mgr->mBlueHorizon.mName, err); childSetValue("WLBlueHorizonR", param_mgr->mBlueHorizon.r / 2.0); childSetValue("WLBlueHorizonG", param_mgr->mBlueHorizon.g / 2.0); childSetValue("WLBlueHorizonB", param_mgr->mBlueHorizon.b / 2.0); @@ -329,18 +329,18 @@ void LLFloaterWindLight::syncMenu() param_mgr->mBlueHorizon.b / 2.0))); // haze density, horizon, mult, and altitude - param_mgr->mHazeDensity = currentParams.getVector(param_mgr->mHazeDensity.name, err); + param_mgr->mHazeDensity = currentParams.getVector(param_mgr->mHazeDensity.mName, err); childSetValue("WLHazeDensity", param_mgr->mHazeDensity.r); - param_mgr->mHazeHorizon = currentParams.getVector(param_mgr->mHazeHorizon.name, err); + param_mgr->mHazeHorizon = currentParams.getVector(param_mgr->mHazeHorizon.mName, err); childSetValue("WLHazeHorizon", param_mgr->mHazeHorizon.r); - param_mgr->mDensityMult = currentParams.getVector(param_mgr->mDensityMult.name, err); + param_mgr->mDensityMult = currentParams.getVector(param_mgr->mDensityMult.mName, err); childSetValue("WLDensityMult", param_mgr->mDensityMult.x * param_mgr->mDensityMult.mult); - param_mgr->mMaxAlt = currentParams.getVector(param_mgr->mMaxAlt.name, err); + param_mgr->mMaxAlt = currentParams.getVector(param_mgr->mMaxAlt.mName, err); childSetValue("WLMaxAltitude", param_mgr->mMaxAlt.x); // blue density - param_mgr->mBlueDensity = currentParams.getVector(param_mgr->mBlueDensity.name, err); + param_mgr->mBlueDensity = currentParams.getVector(param_mgr->mBlueDensity.mName, err); childSetValue("WLBlueDensityR", param_mgr->mBlueDensity.r / 2.0); childSetValue("WLBlueDensityG", param_mgr->mBlueDensity.g / 2.0); childSetValue("WLBlueDensityB", param_mgr->mBlueDensity.b / 2.0); @@ -351,7 +351,7 @@ void LLFloaterWindLight::syncMenu() // Lighting // sunlight - param_mgr->mSunlight = currentParams.getVector(param_mgr->mSunlight.name, err); + param_mgr->mSunlight = currentParams.getVector(param_mgr->mSunlight.mName, err); childSetValue("WLSunlightR", param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE); childSetValue("WLSunlightG", param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE); childSetValue("WLSunlightB", param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE); @@ -360,12 +360,12 @@ void LLFloaterWindLight::syncMenu() std::max(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE))); // glow - param_mgr->mGlow = currentParams.getVector(param_mgr->mGlow.name, err); + param_mgr->mGlow = currentParams.getVector(param_mgr->mGlow.mName, err); childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f); childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f); // ambient - param_mgr->mAmbient = currentParams.getVector(param_mgr->mAmbient.name, err); + param_mgr->mAmbient = currentParams.getVector(param_mgr->mAmbient.mName, err); childSetValue("WLAmbientR", param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE); childSetValue("WLAmbientG", param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE); childSetValue("WLAmbientB", param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE); @@ -379,7 +379,7 @@ void LLFloaterWindLight::syncMenu() // Clouds // Cloud Color - param_mgr->mCloudColor = currentParams.getVector(param_mgr->mCloudColor.name, err); + param_mgr->mCloudColor = currentParams.getVector(param_mgr->mCloudColor.mName, err); childSetValue("WLCloudColorR", param_mgr->mCloudColor.r); childSetValue("WLCloudColorG", param_mgr->mCloudColor.g); childSetValue("WLCloudColorB", param_mgr->mCloudColor.b); @@ -388,20 +388,20 @@ void LLFloaterWindLight::syncMenu() std::max(param_mgr->mCloudColor.g, param_mgr->mCloudColor.b))); // Cloud - param_mgr->mCloudMain = currentParams.getVector(param_mgr->mCloudMain.name, err); + param_mgr->mCloudMain = currentParams.getVector(param_mgr->mCloudMain.mName, err); childSetValue("WLCloudX", param_mgr->mCloudMain.r); childSetValue("WLCloudY", param_mgr->mCloudMain.g); childSetValue("WLCloudDensity", param_mgr->mCloudMain.b); // Cloud Detail - param_mgr->mCloudDetail = currentParams.getVector(param_mgr->mCloudDetail.name, err); + param_mgr->mCloudDetail = currentParams.getVector(param_mgr->mCloudDetail.mName, err); childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r); childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g); childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b); // Cloud extras - param_mgr->mCloudCoverage = currentParams.getVector(param_mgr->mCloudCoverage.name, err); - param_mgr->mCloudScale = currentParams.getVector(param_mgr->mCloudScale.name, err); + param_mgr->mCloudCoverage = currentParams.getVector(param_mgr->mCloudCoverage.mName, err); + param_mgr->mCloudScale = currentParams.getVector(param_mgr->mCloudScale.mName, err); childSetValue("WLCloudCoverage", param_mgr->mCloudCoverage.x); childSetValue("WLCloudScale", param_mgr->mCloudScale.x); @@ -430,12 +430,12 @@ void LLFloaterWindLight::syncMenu() childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f); childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f); - param_mgr->mDistanceMult = currentParams.getVector(param_mgr->mDistanceMult.name, err); + param_mgr->mDistanceMult = currentParams.getVector(param_mgr->mDistanceMult.mName, err); childSetValue("WLDistanceMult", param_mgr->mDistanceMult.x); // Tweak extras - param_mgr->mWLGamma = currentParams.getVector(param_mgr->mWLGamma.name, err); + param_mgr->mWLGamma = currentParams.getVector(param_mgr->mWLGamma.mName, err); childSetValue("WLGamma", param_mgr->mWLGamma.x); childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness()); @@ -653,24 +653,24 @@ void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, void* userData) // divide sun color vals by three if(colorControl->isSunOrAmbientColor) { - sWindLight->childSetValue(rName.c_str(), colorControl->r/3); - sWindLight->childSetValue(gName.c_str(), colorControl->g/3); - sWindLight->childSetValue(bName.c_str(), colorControl->b/3); + sWindLight->childSetValue(rName, colorControl->r/3); + sWindLight->childSetValue(gName, colorControl->g/3); + sWindLight->childSetValue(bName, colorControl->b/3); } else if(colorControl->isBlueHorizonOrDensity) { - sWindLight->childSetValue(rName.c_str(), colorControl->r/2); - sWindLight->childSetValue(gName.c_str(), colorControl->g/2); - sWindLight->childSetValue(bName.c_str(), colorControl->b/2); + sWindLight->childSetValue(rName, colorControl->r/2); + sWindLight->childSetValue(gName, colorControl->g/2); + sWindLight->childSetValue(bName, colorControl->b/2); } else { // set the sliders to the new vals - sWindLight->childSetValue(rName.c_str(), colorControl->r); - sWindLight->childSetValue(gName.c_str(), colorControl->g); - sWindLight->childSetValue(bName.c_str(), colorControl->b); + sWindLight->childSetValue(rName, colorControl->r); + sWindLight->childSetValue(gName, colorControl->g); + sWindLight->childSetValue(bName, colorControl->b); } } @@ -785,7 +785,7 @@ void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl, void* userData) void LLFloaterWindLight::onNewPreset(void* userData) { - gViewerWindow->alertXmlEditText("NewSkyPreset", LLString::format_map_t(), + gViewerWindow->alertXmlEditText("NewSkyPreset", LLStringUtil::format_map_t(), NULL, NULL, newPromptCallback, NULL); } @@ -803,7 +803,7 @@ void LLFloaterWindLight::onSavePreset(void* userData) // check to see if it's a default and shouldn't be overwritten std::set<std::string>::iterator sIt = sDefaultPresets.find( - comboBox->getSelectedItemLabel().c_str()); + comboBox->getSelectedItemLabel()); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets")) { gViewerWindow->alertXml("WLNoEditDefault"); @@ -841,7 +841,7 @@ void LLFloaterWindLight::onDeletePreset(void* userData) return; } - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[SKY]"] = combo_box->getSelectedValue().asString(); gViewerWindow->alertXml("WLDeletePresetAlert", args, deleteAlertCallback, sWindLight); } @@ -865,10 +865,10 @@ void LLFloaterWindLight::deleteAlertCallback(S32 option, void* userdata) mult_sldr = day_cycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); } - LLString name(combo_box->getSelectedValue().asString()); + std::string name(combo_box->getSelectedValue().asString()); // check to see if it's a default and shouldn't be deleted - std::set<std::string>::iterator sIt = sDefaultPresets.find(name.c_str()); + std::set<std::string>::iterator sIt = sDefaultPresets.find(name); if(sIt != sDefaultPresets.end()) { gViewerWindow->alertXml("WLNoEditDefault"); diff --git a/indra/newview/llfloaterwindlight.h b/indra/newview/llfloaterwindlight.h index 9bb7f1371c..d9e02b1117 100644 --- a/indra/newview/llfloaterwindlight.h +++ b/indra/newview/llfloaterwindlight.h @@ -61,9 +61,9 @@ public: // help button stuff static void onClickHelp(void* data); - void initHelpBtn(const char* name, const char* xml_alert); + void initHelpBtn(const std::string& name, const std::string& xml_alert); - static void newPromptCallback(S32 option, const LLString& text, void* userData); + static void newPromptCallback(S32 option, const std::string& text, void* userData); /// general purpose callbacks for dealing with color controllers static void onColorControlRMoved(LLUICtrl* ctrl, void* userData); diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 401cc9fc6c..d38121047a 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -150,7 +150,7 @@ const LLUUID LLFloaterWorldMap::sHomeID( "10000000-0000-0000-0000-000000000001" LLFloaterWorldMap::LLFloaterWorldMap() -: LLFloater("worldmap"), +: LLFloater(std::string("worldmap")), mInventory(NULL), mInventoryObserver(NULL), mFriendObserver(NULL), @@ -171,7 +171,7 @@ LLFloaterWorldMap::LLFloaterWorldMap() // static void* LLFloaterWorldMap::createWorldMapView(void* data) { - return new LLWorldMapView("mapview", LLRect(0,300,400,0)); + return new LLWorldMapView(std::string("mapview"), LLRect(0,300,400,0)); } BOOL LLFloaterWorldMap::postBuild() @@ -515,7 +515,7 @@ void LLFloaterWorldMap::draw() //------------------------------------------------------------------------- -void LLFloaterWorldMap::trackAvatar( const LLUUID& avatar_id, const LLString& name ) +void LLFloaterWorldMap::trackAvatar( const LLUUID& avatar_id, const std::string& name ) { LLCtrlSelectionInterface *iface = childGetSelectionInterface("friend combo"); if (!iface) return; @@ -565,7 +565,7 @@ void LLFloaterWorldMap::trackLandmark( const LLUUID& landmark_item_id ) if (found && iface->setCurrentByID( landmark_item_id ) ) { LLUUID asset_id = mLandmarkAssetIDList.get( idx ); - LLString name; + std::string name; LLComboBox* combo = getChild<LLComboBox>( "landmark combo"); if (combo) name = combo->getSimple(); mTrackedStatus = LLTracker::TRACKING_LANDMARK; @@ -630,17 +630,17 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global) return; } - LLString sim_name; + std::string sim_name; LLWorldMap::getInstance()->simNameFromPosGlobal( pos_global, sim_name ); F32 region_x = (F32)fmod( pos_global.mdV[VX], (F64)REGION_WIDTH_METERS ); F32 region_y = (F32)fmod( pos_global.mdV[VY], (F64)REGION_WIDTH_METERS ); - LLString full_name = llformat("%s (%d, %d, %d)", + std::string full_name = llformat("%s (%d, %d, %d)", sim_name.c_str(), llround(region_x), llround(region_y), llround((F32)pos_global.mdV[VZ])); - LLString tooltip(""); + std::string tooltip(""); mTrackedStatus = LLTracker::TRACKING_LOCATION; LLTracker::trackLocation(pos_global, full_name, tooltip); LLWorldMap::getInstance()->mIsTrackingUnknownLocation = FALSE; @@ -667,7 +667,7 @@ void LLFloaterWorldMap::updateLocation() if ( status == LLTracker::TRACKING_NOTHING && mSetToUserPosition ) { // Make sure we know where we are before setting the current user position - LLString agent_sim_name; + std::string agent_sim_name; gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( agentPos, agent_sim_name ); if ( gotSimName ) { @@ -694,7 +694,7 @@ void LLFloaterWorldMap::updateLocation() return; // invalid location } - LLString sim_name; + std::string sim_name; gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( pos_global, sim_name ); if ((status != LLTracker::TRACKING_NOTHING) && (status != mTrackedStatus || pos_global != mTrackedLocation || sim_name != mTrackedSimName)) @@ -734,7 +734,7 @@ void LLFloaterWorldMap::updateLocation() } } -void LLFloaterWorldMap::trackURL(const LLString& region_name, S32 x_coord, S32 y_coord, S32 z_coord) +void LLFloaterWorldMap::trackURL(const std::string& region_name, S32 x_coord, S32 y_coord, S32 z_coord) { LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromName(region_name); z_coord = llclamp(z_coord, 0, 1000); @@ -759,7 +759,7 @@ void LLFloaterWorldMap::trackURL(const LLString& region_name, S32 x_coord, S32 y // pass sim name to combo box gFloaterWorldMap->mCompletingRegionName = region_name; LLWorldMap::getInstance()->sendNamedRegionRequest(region_name); - LLString::toLower(gFloaterWorldMap->mCompletingRegionName); + LLStringUtil::toLower(gFloaterWorldMap->mCompletingRegionName); LLWorldMap::getInstance()->mIsTrackingCommit = TRUE; } } @@ -906,8 +906,7 @@ void LLFloaterWorldMap::buildLandmarkIDLists() mLandmarkAssetIDList.put( item->getAssetUUID() ); mLandmarkItemIDList.put( item->getUUID() ); } - - list->sortByColumn("landmark name", TRUE); + list->sortByColumn(std::string("landmark name"), TRUE); list->selectFirstItem(); } @@ -1184,7 +1183,7 @@ void LLFloaterWorldMap::onAvatarComboCommit( LLUICtrl* ctrl, void* userdata ) const LLUUID& new_avatar_id = list->getCurrentID(); if (new_avatar_id.notNull()) { - LLString name; + std::string name; LLComboBox* combo = gFloaterWorldMap->getChild<LLComboBox>("friend combo"); if (combo) name = combo->getSimple(); self->trackAvatar(new_avatar_id, name); @@ -1230,17 +1229,17 @@ void LLFloaterWorldMap::onLocationCommit( void* userdata ) self->mCompletingRegionName = ""; self->mLastRegionName = ""; - LLString str = self->childGetValue("location").asString(); + std::string str = self->childGetValue("location").asString(); // Trim any leading and trailing spaces in the search target - LLString saved_str = str; - LLString::trim( str ); + std::string saved_str = str; + LLStringUtil::trim( str ); if ( str != saved_str ) { // Set the value in the UI if any spaces were removed self->childSetValue("location", str); } - LLString::toLower(str); + LLStringUtil::toLower(str); gFloaterWorldMap->mCompletingRegionName = str; LLWorldMap::getInstance()->mIsTrackingCommit = TRUE; self->mExactMatch = FALSE; @@ -1302,7 +1301,7 @@ void LLFloaterWorldMap::onCopySLURL(void* data) LLFloaterWorldMap* self = (LLFloaterWorldMap*)data; gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(self->mSLURL)); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[SLURL]"] = self->mSLURL; LLAlertDialog::showXml("CopySLURL", args); @@ -1554,9 +1553,9 @@ void LLFloaterWorldMap::updateSims(bool found_null_sim) for (it = LLWorldMap::getInstance()->mSimInfoMap.begin(); it != LLWorldMap::getInstance()->mSimInfoMap.end(); ++it) { LLSimInfo* info = (*it).second; - LLString sim_name = info->mName; - LLString sim_name_lower = sim_name; - LLString::toLower(sim_name_lower); + std::string sim_name = info->mName; + std::string sim_name_lower = sim_name; + LLStringUtil::toLower(sim_name_lower); if (sim_name_lower.substr(0, name_length) == mCompletingRegionName) { @@ -1599,7 +1598,7 @@ void LLFloaterWorldMap::updateSims(bool found_null_sim) } else { - list->addCommentText("None found."); + list->addCommentText(std::string("None found.")); list->operateOnAll(LLCtrlListInterface::OP_DESELECT); } } @@ -1631,19 +1630,19 @@ void LLFloaterWorldMap::onCommitSearchResult(LLUICtrl*, void* userdata) if (!list) return; LLSD selected_value = list->getSelectedValue(); - LLString sim_name = selected_value.asString(); + std::string sim_name = selected_value.asString(); if (sim_name.empty()) { return; } - LLString::toLower(sim_name); + LLStringUtil::toLower(sim_name); std::map<U64, LLSimInfo*>::const_iterator it; for (it = LLWorldMap::getInstance()->mSimInfoMap.begin(); it != LLWorldMap::getInstance()->mSimInfoMap.end(); ++it) { LLSimInfo* info = (*it).second; - LLString info_sim_name = info->mName; - LLString::toLower(info_sim_name); + std::string info_sim_name = info->mName; + LLStringUtil::toLower(info_sim_name); if (sim_name == info_sim_name) { diff --git a/indra/newview/llfloaterworldmap.h b/indra/newview/llfloaterworldmap.h index 3cf12a9eb7..f4c2b1abed 100644 --- a/indra/newview/llfloaterworldmap.h +++ b/indra/newview/llfloaterworldmap.h @@ -85,12 +85,12 @@ public: void friendsChanged(); // tracking methods - void trackAvatar( const LLUUID& avatar_id, const LLString& name ); + void trackAvatar( const LLUUID& avatar_id, const std::string& name ); void trackLandmark( const LLUUID& landmark_item_id ); void trackLocation(const LLVector3d& pos); void trackEvent(const LLItemInfo &event_info); void trackGenericItem(const LLItemInfo &item); - void trackURL(const LLString& region_name, S32 x_coord, S32 y_coord, S32 z_coord); + void trackURL(const std::string& region_name, S32 x_coord, S32 y_coord, S32 z_coord); static const LLUUID& getHomeID() { return sHomeID; } @@ -177,8 +177,8 @@ protected: LLInventoryObserver* mInventoryObserver; LLFriendObserver* mFriendObserver; - LLString mCompletingRegionName; - LLString mLastRegionName; + std::string mCompletingRegionName; + std::string mLastRegionName; BOOL mWaitingForTracker; BOOL mExactMatch; @@ -187,9 +187,9 @@ protected: LLVector3d mTrackedLocation; LLTracker::ETrackingStatus mTrackedStatus; - LLString mTrackedSimName; - LLString mTrackedAvatarName; - LLString mSLURL; + std::string mTrackedSimName; + std::string mTrackedAvatarName; + std::string mSLURL; }; extern LLFloaterWorldMap* gFloaterWorldMap; diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index a514d9b997..2739a30031 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -118,7 +118,7 @@ LLColor4 LLFolderViewItem::sSuffixColor; LLColor4 LLFolderViewItem::sSearchStatusColor; // Default constructor -LLFolderViewItem::LLFolderViewItem( const LLString& name, LLUIImagePtr icon, +LLFolderViewItem::LLFolderViewItem( const std::string& name, LLUIImagePtr icon, S32 creation_date, LLFolderView* root, LLFolderViewEventListener* listener ) : @@ -137,7 +137,7 @@ LLFolderViewItem::LLFolderViewItem( const LLString& name, LLUIImagePtr icon, mNumDescendantsSelected(0), mFiltered(FALSE), mLastFilterGeneration(-1), - mStringMatchOffset(LLString::npos), + mStringMatchOffset(std::string::npos), mControlLabelRotation(0.f), mRoot( root ), mDragAndDropTarget(FALSE), @@ -280,8 +280,7 @@ void LLFolderViewItem::refresh() { if(mListener) { - const char* label = mListener->getDisplayName().c_str(); - mLabel = label ? label : ""; + mLabel = mListener->getDisplayName(); setIcon(mListener->getIcon()); time_t creation_date = mListener->getCreationDate(); if (mCreationDate != creation_date) @@ -292,9 +291,9 @@ void LLFolderViewItem::refresh() mLabelStyle = mListener->getLabelStyle(); mLabelSuffix = mListener->getLabelSuffix(); - LLString searchable_label(mLabel); + std::string searchable_label(mLabel); searchable_label.append(mLabelSuffix); - LLString::toUpper(searchable_label); + LLStringUtil::toUpper(searchable_label); if (mSearchableLabel.compare(searchable_label)) { @@ -564,11 +563,11 @@ void LLFolderViewItem::preview( void ) } } -void LLFolderViewItem::rename(const LLString& new_name) +void LLFolderViewItem::rename(const std::string& new_name) { if( !new_name.empty() ) { - mLabel = new_name.c_str(); + mLabel = new_name; if( mListener ) { mListener->renameItem(new_name); @@ -581,12 +580,12 @@ void LLFolderViewItem::rename(const LLString& new_name) } } -const LLString& LLFolderViewItem::getSearchableLabel() const +const std::string& LLFolderViewItem::getSearchableLabel() const { return mSearchableLabel; } -const LLString& LLFolderViewItem::getName( void ) const +const std::string& LLFolderViewItem::getName( void ) const { if(mListener) { @@ -757,7 +756,7 @@ BOOL LLFolderViewItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL accepted = FALSE; BOOL handled = FALSE; @@ -922,7 +921,8 @@ void LLFolderViewItem::draw() if ( mIsLoading && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime") ) { - sFont->renderUTF8( "Loading... ", 0, text_left, y, sSearchStatusColor, + // *TODO: Translate + sFont->renderUTF8( std::string("Loading... "), 0, text_left, y, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, S32_MAX, S32_MAX, &right_x, FALSE); text_left = right_x; } @@ -937,13 +937,13 @@ void LLFolderViewItem::draw() S32_MAX, S32_MAX, &right_x, FALSE ); } - if (mBoxImage.notNull() && mStringMatchOffset != LLString::npos) + if (mBoxImage.notNull() && mStringMatchOffset != std::string::npos) { // don't draw backgrounds for zero-length strings S32 filter_string_length = mRoot->getFilterSubString().size(); if (filter_string_length > 0) { - LLString combined_string = mLabel + mLabelSuffix; + std::string combined_string = mLabel + mLabelSuffix; S32 left = llround(text_left) + sFont->getWidth(combined_string, 0, mStringMatchOffset) - 1; S32 right = left + sFont->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2; S32 bottom = llfloor(getRect().getHeight() - sFont->getLineHeight() - 3); @@ -972,7 +972,7 @@ void LLFolderViewItem::draw() ///---------------------------------------------------------------------------- // Default constructor -LLFolderViewFolder::LLFolderViewFolder( const LLString& name, LLUIImagePtr icon, +LLFolderViewFolder::LLFolderViewFolder( const std::string& name, LLUIImagePtr icon, LLFolderView* root, LLFolderViewEventListener* listener ): LLFolderViewItem( name, icon, 0, root, listener ), // 0 = no create time @@ -988,7 +988,7 @@ LLFolderViewFolder::LLFolderViewFolder( const LLString& name, LLUIImagePtr icon, mCompletedFilterGeneration(-1), mMostFilteredDescendantGeneration(-1) { - mType = "(folder)"; + mType = std::string("(folder)"); } // Destroys the object @@ -1958,7 +1958,7 @@ BOOL LLFolderViewFolder::handleDragAndDropFromChild(MASK mask, EDragAndDropType c_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL accepted = mListener && mListener->dragOrDrop(mask,drop,c_type,cargo_data); if (accepted) @@ -2023,7 +2023,7 @@ BOOL LLFolderViewFolder::handleDragAndDrop(S32 x, S32 y, MASK mask, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { LLFolderView* root_view = getRoot(); @@ -2487,7 +2487,7 @@ void LLCloseAllFoldersFunctor::doItem(LLFolderViewItem* item) ///---------------------------------------------------------------------------- // Default constructor -LLFolderView::LLFolderView( const LLString& name, LLUIImagePtr root_folder_icon, +LLFolderView::LLFolderView( const std::string& name, LLUIImagePtr root_folder_icon, const LLRect& rect, const LLUUID& source_id, LLView *parent_view ) : #if LL_WINDOWS #pragma warning( push ) @@ -2534,9 +2534,9 @@ LLFolderView::LLFolderView( const LLString& name, LLUIImagePtr root_folder_icon, //clear label // go ahead and render root folder as usual // just make sure the label ("Inventory Folder") never shows up - mLabel = LLString::null; + mLabel = LLStringUtil::null; - mRenamer = new LLLineEditor("ren", getRect(), "", sFont, + mRenamer = new LLLineEditor(std::string("ren"), getRect(), LLStringUtil::null, sFont, DB_INV_ITEM_NAME_STR_LEN, &LLFolderView::commitRename, NULL, @@ -2553,7 +2553,7 @@ LLFolderView::LLFolderView( const LLString& name, LLUIImagePtr root_folder_icon, LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_inventory.xml", parent_view); if (!menu) { - menu = new LLMenuGL(""); + menu = new LLMenuGL(LLStringUtil::null); } menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); menu->setVisible(FALSE); @@ -2665,7 +2665,7 @@ void LLFolderView::closeAllFolders() setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); } -void LLFolderView::openFolder(const LLString& foldername) +void LLFolderView::openFolder(const std::string& foldername) { LLFolderViewFolder* inv = getChild<LLFolderViewFolder>(foldername); if (inv) @@ -2771,7 +2771,7 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen return llround(mTargetHeight); } -const LLString LLFolderView::getFilterSubString(BOOL trim) +const std::string LLFolderView::getFilterSubString(BOOL trim) { return mFilter.getFilterSubString(trim); } @@ -3119,7 +3119,7 @@ void LLFolderView::draw() { if (mDebugFilters) { - LLString current_filter_string = llformat("Current Filter: %d, Least Filter: %d, Auto-accept Filter: %d", + std::string current_filter_string = llformat("Current Filter: %d, Least Filter: %d, Auto-accept Filter: %d", mFilter.getCurrentGeneration(), mFilter.getMinRequiredGeneration(), mFilter.getMustPassGeneration()); sSmallFont->renderUTF8(current_filter_string, 0, 2, getRect().getHeight() - sSmallFont->getLineHeight(), LLColor4(0.5f, 0.5f, 0.8f, 1.f), @@ -3169,12 +3169,12 @@ void LLFolderView::draw() { if (gInventory.backgroundFetchActive() || mCompletedFilterGeneration < mFilter.getMinRequiredGeneration()) { - mStatusText = "Searching..."; // *TODO:translate + mStatusText = std::string("Searching..."); // *TODO:translate sFont->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, S32_MAX, S32_MAX, NULL, FALSE ); } else { - mStatusText = "No matching items found in inventory."; // *TODO:translate + mStatusText = std::string("No matching items found in inventory."); // *TODO:translate sFont->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, S32_MAX, S32_MAX, NULL, FALSE ); } } @@ -3192,7 +3192,7 @@ void LLFolderView::finishRenamingItem( void ) } if( mRenameItem ) { - mRenameItem->rename( mRenamer->getText().c_str() ); + mRenameItem->rename( mRenamer->getText() ); } mRenamer->setCommitOnFocusLost( FALSE ); @@ -3862,7 +3862,7 @@ BOOL LLFolderView::handleKeyHere( KEY key, MASK mask ) { mSearchString.erase(mSearchString.size() - 1, 1); } - search(getCurSelectedItem(), mSearchString.c_str(), FALSE); + search(getCurSelectedItem(), mSearchString, FALSE); handled = TRUE; } } @@ -3905,7 +3905,7 @@ BOOL LLFolderView::handleUnicodeCharHere(llwchar uni_char) { mSearchString += uni_char; } - search(getCurSelectedItem(), mSearchString.c_str(), FALSE); + search(getCurSelectedItem(), mSearchString, FALSE); handled = TRUE; } @@ -3956,14 +3956,14 @@ void LLFolderView::onFocusLost( ) LLUICtrl::onFocusLost(); } -BOOL LLFolderView::search(LLFolderViewItem* first_item, const LLString &search_string, BOOL backward) +BOOL LLFolderView::search(LLFolderViewItem* first_item, const std::string &search_string, BOOL backward) { // get first selected item LLFolderViewItem* search_item = first_item; // make sure search string is upper case - LLString upper_case_string = search_string; - LLString::toUpper(upper_case_string); + std::string upper_case_string = search_string; + LLStringUtil::toUpper(upper_case_string); // if nothing selected, select first item in folder if (!search_item) @@ -3994,7 +3994,7 @@ BOOL LLFolderView::search(LLFolderViewItem* first_item, const LLString &search_s } } - const LLString current_item_label(search_item->getSearchableLabel()); + const std::string current_item_label(search_item->getSearchableLabel()); S32 search_string_length = llmin(upper_case_string.size(), current_item_label.size()); if (!current_item_label.compare(0, search_string_length, upper_case_string)) { @@ -4082,7 +4082,7 @@ BOOL LLFolderView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { mDragAndDropThisFrame = TRUE; BOOL handled = LLView::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, @@ -4374,7 +4374,7 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde if (by_name) { - S32 compare = LLString::compareDict(a->getLabel(), b->getLabel()); + S32 compare = LLStringUtil::compareDict(a->getLabel(), b->getLabel()); if (0 == compare) { return (a->getCreationDate() > b->getCreationDate()); @@ -4392,7 +4392,7 @@ bool LLInventorySort::operator()(const LLFolderViewItem* const& a, const LLFolde time_t second_create = b->getCreationDate(); if (first_create == second_create) { - return (LLString::compareDict(a->getLabel(), b->getLabel()) < 0); + return (LLStringUtil::compareDict(a->getLabel(), b->getLabel()) < 0); } else { @@ -4477,7 +4477,7 @@ void LLFolderViewEventListener::arrangeAndSet(LLFolderViewItem* focus, ///---------------------------------------------------------------------------- /// Class LLInventoryFilter ///---------------------------------------------------------------------------- -LLInventoryFilter::LLInventoryFilter(const LLString& name) : +LLInventoryFilter::LLInventoryFilter(const std::string& name) : mName(name), mModified(FALSE), mNeedTextRebuild(TRUE) @@ -4492,7 +4492,7 @@ LLInventoryFilter::LLInventoryFilter(const LLString& name) : mOrder = SO_FOLDERS_BY_NAME; // This gets overridden by a pref immediately mSubStringMatchOffset = 0; - mFilterSubString = ""; + mFilterSubString.clear(); mFilterGeneration = 0; mMustPassGeneration = S32_MAX; mMinRequiredGeneration = 0; @@ -4524,15 +4524,15 @@ BOOL LLInventoryFilter::check(LLFolderViewItem* item) earliest = 0; } LLFolderViewEventListener* listener = item->getListener(); - mSubStringMatchOffset = mFilterSubString.size() ? item->getSearchableLabel().find(mFilterSubString) : LLString::npos; + mSubStringMatchOffset = mFilterSubString.size() ? item->getSearchableLabel().find(mFilterSubString) : std::string::npos; BOOL passed = (0x1 << listener->getInventoryType() & mFilterOps.mFilterTypes || listener->getInventoryType() == LLInventoryType::IT_NONE) - && (mFilterSubString.size() == 0 || mSubStringMatchOffset != LLString::npos) + && (mFilterSubString.size() == 0 || mSubStringMatchOffset != std::string::npos) && ((listener->getPermissionMask() & mFilterOps.mPermissions) == mFilterOps.mPermissions) && (listener->getCreationDate() >= earliest && listener->getCreationDate() <= mFilterOps.mMaxDate); return passed; } -const LLString LLInventoryFilter::getFilterSubString(BOOL trim) +const std::string LLInventoryFilter::getFilterSubString(BOOL trim) { return mFilterSubString; } @@ -4603,7 +4603,7 @@ void LLInventoryFilter::setFilterTypes(U32 types) } } -void LLInventoryFilter::setFilterSubString(const LLString& string) +void LLInventoryFilter::setFilterSubString(const std::string& string) { if (mFilterSubString != string) { @@ -4612,8 +4612,8 @@ void LLInventoryFilter::setFilterSubString(const LLString& string) // appending new characters BOOL more_restrictive = mFilterSubString.size() < string.size() && !string.substr(0, mFilterSubString.size()).compare(mFilterSubString); mFilterSubString = string; - LLString::toUpper(mFilterSubString); - LLString::trimHead(mFilterSubString); + LLStringUtil::toUpper(mFilterSubString); + LLStringUtil::trimHead(mFilterSubString); if (less_restrictive) { @@ -4808,7 +4808,7 @@ BOOL LLInventoryFilter::isFilterWith(LLInventoryType::EType t) return mFilterOps.mFilterTypes & (0x01 << t); } -LLString LLInventoryFilter::getFilterText() +std::string LLInventoryFilter::getFilterText() { if (!mNeedTextRebuild) { @@ -4816,12 +4816,12 @@ LLString LLInventoryFilter::getFilterText() } mNeedTextRebuild = FALSE; - LLString filtered_types; - LLString not_filtered_types; + std::string filtered_types; + std::string not_filtered_types; BOOL filtered_by_type = FALSE; BOOL filtered_by_all_types = TRUE; S32 num_filter_types = 0; - mFilterText = ""; + mFilterText.clear(); if (isFilterWith(LLInventoryType::IT_ANIMATION)) { @@ -5020,7 +5020,7 @@ void LLInventoryFilter::fromLLSD(LLSD& data) if(data.has("substring")) { - setFilterSubString(LLString(data["substring"].asString())); + setFilterSubString(std::string(data["substring"].asString())); } if(data.has("sort_order")) diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index c6b1e52157..32b0580a5c 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -70,26 +70,25 @@ class LLFolderViewItem; class LLFolderView; class LLInventoryModel; class LLScrollableContainerView; -typedef BOOL (*LLFolderSearchFunction)(LLFolderViewItem* first_item, const char *find_text, BOOL backward); class LLFolderViewEventListener { public: virtual ~LLFolderViewEventListener( void ) {} - virtual const LLString& getName() const = 0; - virtual const LLString& getDisplayName() const = 0; + virtual const std::string& getName() const = 0; + virtual const std::string& getDisplayName() const = 0; virtual const LLUUID& getUUID() const = 0; virtual time_t getCreationDate() const = 0; // UTC seconds virtual PermissionMask getPermissionMask() const = 0; virtual LLUIImagePtr getIcon() const = 0; virtual LLFontGL::StyleFlags getLabelStyle() const = 0; - virtual LLString getLabelSuffix() const = 0; + virtual std::string getLabelSuffix() const = 0; virtual void openItem( void ) = 0; virtual void previewItem( void ) = 0; virtual void selectItem(void) = 0; virtual void showProperties(void) = 0; virtual BOOL isItemRenameable() const = 0; - virtual BOOL renameItem(const LLString& new_name) = 0; + virtual BOOL renameItem(const std::string& new_name) = 0; virtual BOOL isItemMovable( void ) = 0; // Can be moved to another folder virtual BOOL isItemRemovable( void ) = 0; // Can be destroyed virtual BOOL removeItem() = 0; @@ -104,7 +103,7 @@ public: virtual BOOL isUpToDate() const = 0; virtual BOOL hasChildren() const = 0; virtual LLInventoryType::EType getInventoryType() const = 0; - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) {} + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) {} // This method should be called when a drag begins. returns TRUE // if the drag can begin, otherwise FALSE. @@ -186,14 +185,14 @@ public: static const U32 SO_FOLDERS_BY_NAME = 2; static const U32 SO_SYSTEM_FOLDERS_TO_TOP = 4; - LLInventoryFilter(const LLString& name); + LLInventoryFilter(const std::string& name); virtual ~LLInventoryFilter(); void setFilterTypes(U32 types); U32 getFilterTypes() const { return mFilterOps.mFilterTypes; } - void setFilterSubString(const LLString& string); - const LLString getFilterSubString(BOOL trim = FALSE); + void setFilterSubString(const std::string& string); + const std::string getFilterSubString(BOOL trim = FALSE); void setFilterPermissions(PermissionMask perms); PermissionMask getFilterPermissions() const { return mFilterOps.mPermissions; } @@ -220,8 +219,8 @@ public: BOOL isModifiedAndClear(); BOOL isSinceLogoff(); void clearModified() { mModified = FALSE; mFilterBehavior = FILTER_NONE; } - const LLString getName() const { return mName; } - LLString getFilterText(); + const std::string getName() const { return mName; } + std::string getFilterText(); void setFilterCount(S32 count) { mFilterCount = count; } S32 getFilterCount() { return mFilterCount; } @@ -255,9 +254,9 @@ protected: filter_ops mFilterOps; filter_ops mDefaultFilterOps; std::string::size_type mSubStringMatchOffset; - LLString mFilterSubString; + std::string mFilterSubString; U32 mOrder; - const LLString mName; + const std::string mName; S32 mFilterGeneration; S32 mMustPassGeneration; S32 mMinRequiredGeneration; @@ -269,7 +268,7 @@ private: U32 mLastLogoff; BOOL mModified; BOOL mNeedTextRebuild; - LLString mFilterText; + std::string mFilterText; }; // These are grouping of inventory types. @@ -329,9 +328,9 @@ protected: static LLColor4 sSuffixColor; static LLColor4 sSearchStatusColor; - LLString mLabel; - LLString mSearchableLabel; - LLString mType; + std::string mLabel; + std::string mSearchableLabel; + std::string mType; S32 mLabelWidth; U32 mCreationDate; LLFolderViewFolder* mParentFolder; @@ -340,9 +339,9 @@ protected: BOOL mIsCurSelection; BOOL mSelectPending; LLFontGL::StyleFlags mLabelStyle; - LLString mLabelSuffix; + std::string mLabelSuffix; LLUIImagePtr mIcon; - LLString mStatusText; + std::string mStatusText; BOOL mHasVisibleChildren; S32 mIndentation; S32 mNumDescendantsSelected; @@ -383,7 +382,7 @@ public: void filterFromRoot( void ); // creation_date is in UTC seconds - LLFolderViewItem( const LLString& name, LLUIImagePtr icon, S32 creation_date, LLFolderView* root, LLFolderViewEventListener* listener ); + LLFolderViewItem( const std::string& name, LLUIImagePtr icon, S32 creation_date, LLFolderView* root, LLFolderViewEventListener* listener ); virtual ~LLFolderViewItem( void ); // addToFolder() returns TRUE if it succeeds. FALSE otherwise @@ -454,14 +453,14 @@ public: // This method returns the actual name of the thing being // viewed. This method will ask the viewed object itself. - const LLString& getName( void ) const; + const std::string& getName( void ) const; - const LLString& getSearchableLabel( void ) const; + const std::string& getSearchableLabel( void ) const; // This method returns the label displayed on the view. This // method was primarily added to allow sorting on the folder // contents possible before the entire view has been constructed. - const char* getLabel() const { return mLabel.c_str(); } + const std::string& getLabel() const { return mLabel; } // Used for sorting, like getLabel() above. virtual time_t getCreationDate() const { return mCreationDate; } @@ -476,7 +475,7 @@ public: LLFolderViewEventListener* getListener( void ) { return mListener; } // just rename the object. - void rename(const LLString& new_name); + void rename(const std::string& new_name); // open virtual void openItem( void ); @@ -519,7 +518,7 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); }; @@ -570,7 +569,7 @@ public: RECURSE_UP_DOWN } ERecurseType; - LLFolderViewFolder( const LLString& name, LLUIImagePtr icon, + LLFolderViewFolder( const std::string& name, LLUIImagePtr icon, LLFolderView* root, LLFolderViewEventListener* listener ); virtual ~LLFolderViewFolder( void ); @@ -681,7 +680,7 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); void applyFunctorRecursively(LLFolderViewFunctor& functor); virtual void applyListenerFunctorRecursively(LLFolderViewListenerFunctor& functor); @@ -699,7 +698,7 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); virtual void draw(); time_t getCreationDate() const; @@ -724,7 +723,7 @@ public: static F32 sAutoOpenTime; - LLFolderView( const LLString& name, LLUIImagePtr root_folder_icon, const LLRect& rect, + LLFolderView( const std::string& name, LLUIImagePtr root_folder_icon, const LLRect& rect, const LLUUID& source_id, LLView *parent_view ); virtual ~LLFolderView( void ); @@ -739,7 +738,7 @@ public: void setAllowMultiSelect(BOOL allow) { mAllowMultiSelect = allow; } LLInventoryFilter* getFilter() { return &mFilter; } - const LLString getFilterSubString(BOOL trim = FALSE); + const std::string getFilterSubString(BOOL trim = FALSE); U32 getFilterTypes() const { return mFilter.getFilterTypes(); } PermissionMask getFilterPermissions() const { return mFilter.getFilterPermissions(); } LLInventoryFilter::EFolderShow getShowFolderState() { return mFilter.getShowFolderState(); } @@ -749,7 +748,7 @@ public: // Close all folders in the view void closeAllFolders(); - void openFolder(const LLString& foldername); + void openFolder(const std::string& foldername); virtual void toggleOpen() {}; virtual void setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse); @@ -839,7 +838,7 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); /*virtual*/ void onFocusLost(); virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); @@ -851,7 +850,7 @@ public: void setScrollContainer( LLScrollableContainerView* parent ) { mScrollContainer = parent; } LLRect getVisibleRect(); - BOOL search(LLFolderViewItem* first_item, const LLString &search_string, BOOL backward); + BOOL search(LLFolderViewItem* first_item, const std::string &search_string, BOOL backward); void setShowSelectionContext(BOOL show) { mShowSelectionContext = show; } BOOL getShowSelectionContext(); void setShowSingleSelection(BOOL show); @@ -910,7 +909,7 @@ protected: LLFolderViewFolder* mAutoOpenCandidate; LLFrameTimer mAutoOpenTimer; LLFrameTimer mSearchTimer; - LLString mSearchString; + std::string mSearchString; LLInventoryFilter mFilter; BOOL mShowSelectionContext; BOOL mShowSingleSelection; diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index adafd8e4c2..9af4bbd532 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -489,7 +489,7 @@ void LLGestureManager::playGesture(const LLUUID& item_id) // and (as a minor side effect) has multiple spaces in a row replaced by single spaces. BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::string* revised_string) { - LLString tokenized = LLString(utf8str.c_str()); + std::string tokenized = utf8str; BOOL found_gestures = FALSE; BOOL first_token = TRUE; @@ -507,8 +507,8 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s // Only pay attention to the first gesture in the string. if( !found_gestures ) { - LLString cur_token_lower = cur_token; - LLString::toLower(cur_token_lower); + std::string cur_token_lower = cur_token; + LLStringUtil::toLower(cur_token_lower); // collect gestures that match std::vector <LLMultiGesture *> matching; @@ -520,7 +520,7 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s // Gesture asset data might not have arrived yet if (!gesture) continue; - if (!stricmp(gesture->mTrigger.c_str(), cur_token_lower.c_str())) + if (gesture->mTrigger == cur_token_lower) { matching.push_back(gesture); } @@ -548,9 +548,9 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s } // Don't muck with the user's capitalization if we don't have to. - LLString output = gesture->mReplaceText.c_str(); - LLString output_lower = output; - LLString::toLower(output_lower); + std::string output = gesture->mReplaceText; + std::string output_lower = output; + LLStringUtil::toLower(output_lower); if( cur_token_lower == output_lower ) { if (revised_string) @@ -958,7 +958,7 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs, && gGestureManager.mDeactivateSimilarNames.length() > 0) { // we're done with this set of deactivations - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NAMES]"] = gGestureManager.mDeactivateSimilarNames; LLNotifyBox::showXml("DeactivatedGesturesTrigger", args); } @@ -1123,9 +1123,9 @@ BOOL LLGestureManager::matchPrefix(const std::string& in_str, std::string* out_s continue; } - LLString trigger_trunc = trigger; - LLString::truncate(trigger_trunc, in_len); - if (!LLString::compareInsensitive(in_str.c_str(), trigger_trunc.c_str())) + std::string trigger_trunc = trigger; + LLStringUtil::truncate(trigger_trunc, in_len); + if (!LLStringUtil::compareInsensitive(in_str, trigger_trunc)) { *out_str = trigger; return TRUE; diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index f4ef00d310..6b89d52b68 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -1102,7 +1102,7 @@ void LLViewerObjectList::renderObjectBeacons() color = debug_beacon.mTextColor; color.mV[3] *= 1.f; - hud_textp->setString(utf8str_to_wstring(debug_beacon.mString.c_str())); + hud_textp->setString(utf8str_to_wstring(debug_beacon.mString)); hud_textp->setColor(color); hud_textp->setPositionAgent(debug_beacon.mPositionAgent); debug_beacon.mHUDObject = hud_textp; diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 542274b295..32ccc761f8 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -821,8 +821,8 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) if (group_datap->mMemberCount > 0) { S32 contribution = 0; - char online_status[DB_DATETIME_BUF_SIZE]; /* Flawfinder: ignore */ - char title[DB_GROUP_TITLE_BUF_SIZE]; /* Flawfinder: ignore */ + std::string online_status; + std::string title; U64 agent_powers = 0; BOOL is_owner = FALSE; @@ -834,8 +834,8 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) msg->getUUIDFast(_PREHASH_MemberData, _PREHASH_AgentID, member_id, i ); msg->getS32(_PREHASH_MemberData, _PREHASH_Contribution, contribution, i); msg->getU64(_PREHASH_MemberData, "AgentPowers", agent_powers, i); - msg->getStringFast(_PREHASH_MemberData, _PREHASH_OnlineStatus, DB_DATETIME_BUF_SIZE, online_status, i); - msg->getString(_PREHASH_MemberData, "Title", DB_GROUP_TITLE_BUF_SIZE, title, i); + msg->getStringFast(_PREHASH_MemberData, _PREHASH_OnlineStatus, online_status, i); + msg->getString(_PREHASH_MemberData, "Title", title, i); msg->getBOOL(_PREHASH_MemberData,"IsOwner",is_owner,i); if (member_id.notNull()) @@ -844,8 +844,8 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) LLGroupMemberData* newdata = new LLGroupMemberData(member_id, contribution, agent_powers, - std::string(title), - std::string(online_status), + title, + online_status, is_owner); #if LL_DEBUG LLGroupMgrGroupData::member_list_t::iterator mit = group_datap->mMembers.find(member_id); @@ -898,13 +898,13 @@ void LLGroupMgr::processGroupPropertiesReply(LLMessageSystem* msg, void** data) } LLUUID group_id; - char name[DB_GROUP_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - char charter[DB_GROUP_CHARTER_BUF_SIZE]; /* Flawfinder: ignore */ + std::string name; + std::string charter; BOOL show_in_list = FALSE; LLUUID founder_id; U64 powers_mask = GP_NO_POWERS; S32 money = 0; - char member_title[DB_GROUP_TITLE_BUF_SIZE]; /* Flawfinder: ignore */ + std::string member_title; LLUUID insignia_id; LLUUID owner_role; U32 membership_fee = 0; @@ -915,18 +915,18 @@ void LLGroupMgr::processGroupPropertiesReply(LLMessageSystem* msg, void** data) BOOL mature = FALSE; msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_GroupID, group_id ); - msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_FounderID, founder_id); - msg->getStringFast(_PREHASH_GroupData, _PREHASH_Name, DB_GROUP_NAME_BUF_SIZE, name ); - msg->getStringFast(_PREHASH_GroupData, _PREHASH_Charter, DB_GROUP_CHARTER_BUF_SIZE, charter ); - msg->getBOOLFast(_PREHASH_GroupData, _PREHASH_ShowInList, show_in_list ); - msg->getStringFast(_PREHASH_GroupData, _PREHASH_MemberTitle, DB_GROUP_TITLE_BUF_SIZE, member_title ); - msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_InsigniaID, insignia_id ); - msg->getU64Fast(_PREHASH_GroupData, _PREHASH_PowersMask, powers_mask ); - msg->getU32Fast(_PREHASH_GroupData, _PREHASH_MembershipFee, membership_fee ); - msg->getBOOLFast(_PREHASH_GroupData, _PREHASH_OpenEnrollment, open_enrollment ); - msg->getS32Fast(_PREHASH_GroupData, _PREHASH_GroupMembershipCount, num_group_members); - msg->getS32(_PREHASH_GroupData, "GroupRolesCount", num_group_roles); - msg->getS32Fast(_PREHASH_GroupData, _PREHASH_Money, money); + msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_FounderID, founder_id); + msg->getStringFast(_PREHASH_GroupData, _PREHASH_Name, name ); + msg->getStringFast(_PREHASH_GroupData, _PREHASH_Charter, charter ); + msg->getBOOLFast(_PREHASH_GroupData, _PREHASH_ShowInList, show_in_list ); + msg->getStringFast(_PREHASH_GroupData, _PREHASH_MemberTitle, member_title ); + msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_InsigniaID, insignia_id ); + msg->getU64Fast(_PREHASH_GroupData, _PREHASH_PowersMask, powers_mask ); + msg->getU32Fast(_PREHASH_GroupData, _PREHASH_MembershipFee, membership_fee ); + msg->getBOOLFast(_PREHASH_GroupData, _PREHASH_OpenEnrollment, open_enrollment ); + msg->getS32Fast(_PREHASH_GroupData, _PREHASH_GroupMembershipCount, num_group_members); + msg->getS32(_PREHASH_GroupData, "GroupRolesCount", num_group_roles); + msg->getS32Fast(_PREHASH_GroupData, _PREHASH_Money, money); msg->getBOOL("GroupData", "AllowPublish", allow_publish); msg->getBOOL("GroupData", "MaturePublish", mature); msg->getUUID(_PREHASH_GroupData, "OwnerRole", owner_role); @@ -979,9 +979,9 @@ void LLGroupMgr::processGroupRoleDataReply(LLMessageSystem* msg, void** data) msg->getS32(_PREHASH_GroupData, "RoleCount", group_data->mRoleCount ); - char name[DB_GROUP_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - char title[DB_GROUP_TITLE_BUF_SIZE]; /* Flawfinder: ignore */ - char desc[DB_GROUP_CHARTER_BUF_SIZE]; /* Flawfinder: ignore */ + std::string name; + std::string title; + std::string desc; U64 powers = 0; U32 member_count = 0; LLUUID role_id; @@ -992,9 +992,9 @@ void LLGroupMgr::processGroupRoleDataReply(LLMessageSystem* msg, void** data) { msg->getUUID("RoleData", "RoleID", role_id, i ); - msg->getString("RoleData","Name",DB_GROUP_NAME_BUF_SIZE,name,i); - msg->getString("RoleData","Title",DB_GROUP_TITLE_BUF_SIZE,title,i); - msg->getString("RoleData","Description",DB_GROUP_CHARTER_BUF_SIZE,desc,i); + msg->getString("RoleData","Name",name,i); + msg->getString("RoleData","Title",title,i); + msg->getString("RoleData","Description",desc,i); msg->getU64("RoleData","Powers",powers,i); msg->getU32("RoleData","Members",member_count,i); @@ -1154,20 +1154,17 @@ void LLGroupMgr::processGroupTitlesReply(LLMessageSystem* msg, void** data) return; } - char title_buf[DB_GROUP_TITLE_BUF_SIZE]; /* Flawfinder: ignore */ - LLGroupTitle title; S32 i = 0; S32 blocks = msg->getNumberOfBlocksFast(_PREHASH_GroupData); for (i=0; i<blocks; ++i) { - msg->getString("GroupData","Title",DB_GROUP_TITLE_BUF_SIZE,title_buf,i); - title.mTitle = title_buf; + msg->getString("GroupData","Title",title.mTitle,i); msg->getUUID("GroupData","RoleID",title.mRoleID,i); msg->getBOOL("GroupData","Selected",title.mSelected,i); - if (title_buf[0] != '\0') + if (!title.mTitle.empty()) { lldebugs << "LLGroupMgr adding title: " << title.mTitle << ", " << title.mRoleID << ", " << (title.mSelected ? 'Y' : 'N') << llendl; group_data->mTitles.push_back(title); @@ -1243,12 +1240,12 @@ void LLGroupMgr::processCreateGroupReply(LLMessageSystem* msg, void ** data) { LLUUID group_id; BOOL success; - char message[MAX_STRING]; /* Flawfinder: ignore */ + std::string message; msg->getUUIDFast(_PREHASH_ReplyData, _PREHASH_GroupID, group_id ); msg->getBOOLFast(_PREHASH_ReplyData, _PREHASH_Success, success ); - msg->getStringFast(_PREHASH_ReplyData, _PREHASH_Message, MAX_STRING, message ); + msg->getStringFast(_PREHASH_ReplyData, _PREHASH_Message, message ); if (success) { @@ -1274,7 +1271,7 @@ void LLGroupMgr::processCreateGroupReply(LLMessageSystem* msg, void ** data) else { // *TODO:translate - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = message; gViewerWindow->alertXml("UnableToCreateGroup", args); } @@ -1723,7 +1720,7 @@ void LLGroupMgr::cancelGroupRoleChanges(const LLUUID& group_id) } //static -bool LLGroupMgr::parseRoleActions(const LLString& xml_filename) +bool LLGroupMgr::parseRoleActions(const std::string& xml_filename) { LLXMLNodePtr root; @@ -1747,7 +1744,7 @@ bool LLGroupMgr::parseRoleActions(const LLString& xml_filename) LLRoleAction* role_action_data = new LLRoleAction(); // name= - LLString action_set_name; + std::string action_set_name; if (action_set->getAttributeString("name", action_set_name)) { lldebugs << "Loading action set " << action_set_name << llendl; @@ -1761,13 +1758,13 @@ bool LLGroupMgr::parseRoleActions(const LLString& xml_filename) continue; } // description= - LLString set_description; + std::string set_description; if (action_set->getAttributeString("description", set_description)) { role_action_data->mDescription = set_description; } // long description= - LLString set_longdescription; + std::string set_longdescription; if (action_set->getAttributeString("longdescription", set_longdescription)) { role_action_data->mLongDescription = set_longdescription; @@ -1788,7 +1785,7 @@ bool LLGroupMgr::parseRoleActions(const LLString& xml_filename) LLRoleAction* role_action = new LLRoleAction(); // name= - LLString action_name; + std::string action_name; if (action->getAttributeString("name", action_name)) { lldebugs << "Loading action " << action_name << llendl; @@ -1801,13 +1798,13 @@ bool LLGroupMgr::parseRoleActions(const LLString& xml_filename) continue; } // description= - LLString description; + std::string description; if (action->getAttributeString("description", description)) { role_action->mDescription = description; } // long description= - LLString longdescription; + std::string longdescription; if (action->getAttributeString("longdescription", longdescription)) { role_action->mLongDescription = longdescription; diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 2cab236954..cbfeca31e1 100644 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -343,7 +343,7 @@ public: static void processEjectGroupMemberReply(LLMessageSystem* msg, void ** data); static void processLeaveGroupReply(LLMessageSystem* msg, void ** data); - static bool parseRoleActions(const LLString& xml_filename); + static bool parseRoleActions(const std::string& xml_filename); std::vector<LLRoleActionSet*> mRoleActionSets; diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index 432096e781..ea7413ea3f 100644 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -77,12 +77,12 @@ public: : mTimeout(0.f), mPriority(0.f) {} - LLAttention(F32 timeout, F32 priority, LLString name, LLColor3 color) : + LLAttention(F32 timeout, F32 priority, const std::string& name, LLColor3 color) : mTimeout(timeout), mPriority(priority), mName(name), mColor(color) { } F32 mTimeout, mPriority; - LLString mName; + std::string mName; LLColor3 mColor; }; @@ -150,7 +150,7 @@ static BOOL loadGender(LLXmlTreeNode* gender) { return FALSE; } - LLString str; + std::string str; gender->getAttributeString("name", str); LLAttentionSet& attentions = (str.compare("Masculine") == 0) ? gBoyAttentions : gGirlAttentions; for (LLXmlTreeNode* attention_node = gender->getChildByName( "param" ); @@ -189,9 +189,8 @@ static BOOL loadAttentions() } first_time = FALSE; - char filename[MAX_PATH]; /*Flawfinder: ignore*/ - strncpy(filename,gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"attentions.xml").c_str(), sizeof(filename) -1); /*Flawfinder: ignore*/ - filename[sizeof(filename) -1] = '\0'; + std::string filename; + filename = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"attentions.xml"); LLXmlTree xml_tree; BOOL success = xml_tree.parseFile( filename, FALSE ); if( !success ) @@ -213,7 +212,7 @@ static BOOL loadAttentions() return FALSE; } - LLString version; + std::string version; static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version"); if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") ) { diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index df03f8d45e..da9441e108 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -1,3 +1,4 @@ + /** * @file llhudtext.cpp * @brief LLHUDText class implementation @@ -921,8 +922,7 @@ void LLHUDText::setLOD(S32 lod) { mLOD = lod; //RN: uncomment this to visualize LOD levels - //char label[255]; - //sprintf(label, "%d", lod); + //std::string label = llformat("%d", lod); //setLabel(label); } diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index ebcbc20270..8a8321f9a0 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -86,9 +86,9 @@ const U32 DEFAULT_RETRIES_COUNT = 3; // Statics // // -static LLString sTitleString = "Instant Message with [NAME]"; -static LLString sTypingStartString = "[NAME]: ..."; -static LLString sSessionStartString = "Starting session with [NAME] please wait."; +static std::string sTitleString = "Instant Message with [NAME]"; +static std::string sTypingStartString = "[NAME]: ..."; +static std::string sSessionStartString = "Starting session with [NAME] please wait."; LLVoiceChannel::voice_channel_map_t LLVoiceChannel::sVoiceChannelMap; LLVoiceChannel::voice_channel_map_uri_t LLVoiceChannel::sVoiceChannelURIMap; @@ -121,7 +121,7 @@ void session_starter_helper( gAgent.buildFullname(name); msg->addStringFast(_PREHASH_FromAgentName, name); - msg->addStringFast(_PREHASH_Message, LLString::null); + msg->addStringFast(_PREHASH_Message, LLStringUtil::null); msg->addU32Fast(_PREHASH_ParentEstateID, 0); msg->addUUIDFast(_PREHASH_RegionID, LLUUID::null); msg->addVector3Fast(_PREHASH_Position, gAgent.getPositionAgent()); @@ -342,7 +342,7 @@ void LLVoiceCallCapResponder::result(const LLSD& content) // // LLVoiceChannel // -LLVoiceChannel::LLVoiceChannel(const LLUUID& session_id, const LLString& session_name) : +LLVoiceChannel::LLVoiceChannel(const LLUUID& session_id, const std::string& session_name) : mSessionID(session_id), mState(STATE_NO_CHANNEL_INFO), mSessionName(session_name), @@ -373,8 +373,8 @@ LLVoiceChannel::~LLVoiceChannel() } void LLVoiceChannel::setChannelInfo( - const LLString& uri, - const LLString& credentials) + const std::string& uri, + const std::string& credentials) { setURI(uri); @@ -563,7 +563,7 @@ LLVoiceChannel* LLVoiceChannel::getChannelByID(const LLUUID& session_id) } //static -LLVoiceChannel* LLVoiceChannel::getChannelByURI(LLString uri) +LLVoiceChannel* LLVoiceChannel::getChannelByURI(std::string uri) { voice_channel_map_uri_t::iterator found_it = sVoiceChannelURIMap.find(uri); if (found_it == sVoiceChannelURIMap.end()) @@ -584,7 +584,7 @@ void LLVoiceChannel::updateSessionID(const LLUUID& new_session_id) sVoiceChannelMap.insert(std::make_pair(mSessionID, this)); } -void LLVoiceChannel::setURI(LLString uri) +void LLVoiceChannel::setURI(std::string uri) { sVoiceChannelURIMap.erase(mURI); mURI = uri; @@ -654,7 +654,7 @@ void LLVoiceChannel::resume() // LLVoiceChannelGroup // -LLVoiceChannelGroup::LLVoiceChannelGroup(const LLUUID& session_id, const LLString& session_name) : +LLVoiceChannelGroup::LLVoiceChannelGroup(const LLUUID& session_id, const std::string& session_name) : LLVoiceChannel(session_id, session_name) { mRetries = DEFAULT_RETRIES_COUNT; @@ -701,8 +701,8 @@ void LLVoiceChannelGroup::getChannelInfo() } void LLVoiceChannelGroup::setChannelInfo( - const LLString& uri, - const LLString& credentials) + const std::string& uri, + const std::string& credentials) { setURI(uri); @@ -795,7 +795,7 @@ void LLVoiceChannelGroup::handleError(EStatusType status) { LLNotifyBox::showXml(notify, mNotifyArgs); // echo to im window - gIMMgr->addMessage(mSessionID, LLUUID::null, SYSTEM_FROM, LLNotifyBox::getTemplateMessage(notify, mNotifyArgs).c_str()); + gIMMgr->addMessage(mSessionID, LLUUID::null, SYSTEM_FROM, LLNotifyBox::getTemplateMessage(notify, mNotifyArgs)); } LLVoiceChannel::handleError(status); @@ -822,7 +822,7 @@ void LLVoiceChannelGroup::setState(EState state) // LLVoiceChannelProximal // LLVoiceChannelProximal::LLVoiceChannelProximal() : - LLVoiceChannel(LLUUID::null, LLString::null) + LLVoiceChannel(LLUUID::null, LLStringUtil::null) { activate(); } @@ -914,7 +914,7 @@ void LLVoiceChannelProximal::deactivate() // // LLVoiceChannelP2P // -LLVoiceChannelP2P::LLVoiceChannelP2P(const LLUUID& session_id, const LLString& session_name, const LLUUID& other_user_id) : +LLVoiceChannelP2P::LLVoiceChannelP2P(const LLUUID& session_id, const std::string& session_name, const LLUUID& other_user_id) : LLVoiceChannelGroup(session_id, session_name), mOtherUserID(other_user_id), mReceivedCall(FALSE) @@ -1000,7 +1000,7 @@ void LLVoiceChannelP2P::getChannelInfo() } // receiving session from other user who initiated call -void LLVoiceChannelP2P::setSessionHandle(const LLString& handle) +void LLVoiceChannelP2P::setSessionHandle(const std::string& handle) { BOOL needs_activate = FALSE; if (callStarted()) @@ -1109,11 +1109,11 @@ LLFloaterIMPanel::LLFloaterIMPanel( } -void LLFloaterIMPanel::init(const LLString& session_label) +void LLFloaterIMPanel::init(const std::string& session_label) { mSessionLabel = session_label; - LLString xml_filename; + std::string xml_filename; switch(mDialog) { case IM_SESSION_GROUP_START: @@ -1454,7 +1454,7 @@ BOOL LLFloaterIMPanel::inviteToSession(const LLDynamicArray<LLUUID>& ids) return TRUE; } -void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, const LLColor4& color, bool log_to_file, const LLUUID& source, const char *name) +void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, const LLColor4& color, bool log_to_file, const LLUUID& source, const std::string& name) { // start tab flashing when receiving im for background session from user if (source != LLUUID::null) @@ -1474,7 +1474,7 @@ void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, const LLColor4 removeTypingIndicator(NULL); // Actually add the line - LLString timestring; + std::string timestring; bool prepend_newline = true; if (gSavedSettings.getBOOL("IMShowTimestamps")) { @@ -1483,10 +1483,10 @@ void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, const LLColor4 } // 'name' is a sender name that we want to hotlink so that clicking on it opens a profile. - if (name != NULL) // If name exists, then add it to the front of the message. + if (!name.empty()) // If name exists, then add it to the front of the message. { // Don't hotlink any messages from the system (e.g. "Second Life:"), so just add those in plain text. - if (!strcmp(name,SYSTEM_FROM)) + if (name == SYSTEM_FROM) { mHistoryEditor->appendColoredText(name,false,prepend_newline,color); } @@ -1503,11 +1503,11 @@ void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, const LLColor4 if (log_to_file && gSavedPerAccountSettings.getBOOL("LogInstantMessages") ) { - LLString histstr; + std::string histstr; if (gSavedPerAccountSettings.getBOOL("IMLogTimestamp")) - histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + LLString(name) + utf8msg; + histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + name + utf8msg; else - histstr = LLString(name) + utf8msg; + histstr = name + utf8msg; LLLogChat::saveHistory(getTitle(),histstr); } @@ -1597,7 +1597,7 @@ BOOL LLFloaterIMPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL accepted = FALSE; switch(cargo_type) @@ -1812,7 +1812,7 @@ void LLFloaterIMPanel::onInputEditorFocusLost(LLFocusableElement* caller, void* void LLFloaterIMPanel::onInputEditorKeystroke(LLLineEditor* caller, void* userdata) { LLFloaterIMPanel* self = (LLFloaterIMPanel*)userdata; - LLString text = self->mInputEditor->getText(); + std::string text = self->mInputEditor->getText(); if (!text.empty()) { self->setTyping(TRUE); @@ -1838,8 +1838,8 @@ void LLFloaterIMPanel::onClose(bool app_quitting) FALSE, gAgent.getSessionID(), mOtherParticipantUUID, - name.c_str(), - "", + name, + LLStringUtil::null, IM_ONLINE, IM_SESSION_LEAVE, mSessionUUID); @@ -1885,8 +1885,8 @@ void deliver_message(const std::string& utf8_text, FALSE, gAgent.getSessionID(), other_participant_id, - name.c_str(), - utf8_text.c_str(), + name, + utf8_text, offline, (EInstantMessage)new_dialog, im_session_id); @@ -1901,7 +1901,7 @@ void deliver_message(const std::string& utf8_text, void LLFloaterIMPanel::sendMsg() { LLWString text = mInputEditor->getWText(); - LLWString::trim(text); + LLWStringUtil::trim(text); if (!gAgent.isGodlike() && (mDialog == IM_NOTHING_SPECIAL) && mOtherParticipantUUID.isNull()) @@ -1930,13 +1930,8 @@ void LLFloaterIMPanel::sendMsg() gAgent.buildFullname(history_echo); // Look for IRC-style emotes here. - char tmpstr[5]; /* Flawfinder: ignore */ - strncpy(tmpstr, - utf8_text.substr(0,4).c_str(), - sizeof(tmpstr) -1); /* Flawfinder: ignore */ - tmpstr[sizeof(tmpstr) -1] = '\0'; - if (!strncmp(tmpstr, "/me ", 4) || - !strncmp(tmpstr, "/me'", 4)) + std::string prefix = utf8_text.substr(0, 4); + if (prefix == "/me " || prefix == "/me'") { utf8_text.replace(0,3,""); } @@ -1966,7 +1961,7 @@ void LLFloaterIMPanel::sendMsg() LLViewerStats::getInstance()->incStat(LLViewerStats::ST_IM_COUNT); } - mInputEditor->setText(LLString::null); + mInputEditor->setText(LLStringUtil::null); // Don't need to actually send the typing stop message, the other // client will infer it from receiving the message. @@ -1989,7 +1984,7 @@ void LLFloaterIMPanel::processSessionUpdate(const LLSD& session_update) if (voice_moderated) { - setTitle(mSessionLabel + LLString(" ") + getString("moderated_chat_label")); + setTitle(mSessionLabel + std::string(" ") + getString("moderated_chat_label")); } else { @@ -2086,8 +2081,8 @@ void LLFloaterIMPanel::sendTypingState(BOOL typing) FALSE, gAgent.getSessionID(), mOtherParticipantUUID, - name.c_str(), - "typing", + name, + std::string("typing"), IM_ONLINE, (typing ? IM_TYPING_START : IM_TYPING_STOP), mSessionUUID); @@ -2144,7 +2139,7 @@ void LLFloaterIMPanel::removeTypingIndicator(const LLIMInfo* im_info) } //static -void LLFloaterIMPanel::chatFromLogFile(LLLogChat::ELogLineType type, LLString line, void* userdata) +void LLFloaterIMPanel::chatFromLogFile(LLLogChat::ELogLineType type, std::string line, void* userdata) { LLFloaterIMPanel* self = (LLFloaterIMPanel*)userdata; LLUIString message = line; @@ -2184,7 +2179,7 @@ void LLFloaterIMPanel::showSessionStartError( //their own XML file which would be read in by any LLIMPanel //post build function instead of repeating the same info //in the group, adhoc and normal IM xml files. - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = LLFloaterIM::sErrorStringsMap[error_string]; args["[RECIPIENT]"] = getTitle(); @@ -2200,7 +2195,7 @@ void LLFloaterIMPanel::showSessionEventError( const std::string& event_string, const std::string& error_string) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = LLFloaterIM::sErrorStringsMap[error_string]; args["[EVENT]"] = @@ -2215,7 +2210,7 @@ void LLFloaterIMPanel::showSessionEventError( void LLFloaterIMPanel::showSessionForceClose( const std::string& reason_string) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = getTitle(); args["[REASON]"] = LLFloaterIM::sForceCloseSessionMap[reason_string]; diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h index a3ece98727..b20dcd02bd 100644 --- a/indra/newview/llimpanel.h +++ b/indra/newview/llimpanel.h @@ -61,7 +61,7 @@ public: STATE_CONNECTED } EState; - LLVoiceChannel(const LLUUID& session_id, const LLString& session_name); + LLVoiceChannel(const LLUUID& session_id, const std::string& session_name); virtual ~LLVoiceChannel(); /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal); @@ -71,8 +71,8 @@ public: virtual void deactivate(); virtual void activate(); virtual void setChannelInfo( - const LLString& uri, - const LLString& credentials); + const std::string& uri, + const std::string& credentials); virtual void getChannelInfo(); virtual BOOL isActive(); virtual BOOL callStarted(); @@ -81,10 +81,10 @@ public: EState getState() { return mState; } void updateSessionID(const LLUUID& new_session_id); - const LLString::format_map_t& getNotifyArgs() { return mNotifyArgs; } + const LLStringUtil::format_map_t& getNotifyArgs() { return mNotifyArgs; } static LLVoiceChannel* getChannelByID(const LLUUID& session_id); - static LLVoiceChannel* getChannelByURI(LLString uri); + static LLVoiceChannel* getChannelByURI(std::string uri); static LLVoiceChannel* getCurrentVoiceChannel() { return sCurrentVoiceChannel; } static void initClass(); @@ -93,21 +93,21 @@ public: protected: virtual void setState(EState state); - void setURI(LLString uri); + void setURI(std::string uri); - LLString mURI; - LLString mCredentials; + std::string mURI; + std::string mCredentials; LLUUID mSessionID; EState mState; - LLString mSessionName; - LLString::format_map_t mNotifyArgs; + std::string mSessionName; + LLStringUtil::format_map_t mNotifyArgs; BOOL mIgnoreNextSessionLeave; LLHandle<LLPanel> mLoginNotificationHandle; typedef std::map<LLUUID, LLVoiceChannel*> voice_channel_map_t; static voice_channel_map_t sVoiceChannelMap; - typedef std::map<LLString, LLVoiceChannel*> voice_channel_map_uri_t; + typedef std::map<std::string, LLVoiceChannel*> voice_channel_map_uri_t; static voice_channel_map_uri_t sVoiceChannelURIMap; static LLVoiceChannel* sCurrentVoiceChannel; @@ -118,15 +118,15 @@ protected: class LLVoiceChannelGroup : public LLVoiceChannel { public: - LLVoiceChannelGroup(const LLUUID& session_id, const LLString& session_name); + LLVoiceChannelGroup(const LLUUID& session_id, const std::string& session_name); /*virtual*/ void handleStatusChange(EStatusType status); /*virtual*/ void handleError(EStatusType status); /*virtual*/ void activate(); /*virtual*/ void deactivate(); /*vritual*/ void setChannelInfo( - const LLString& uri, - const LLString& credentials); + const std::string& uri, + const std::string& credentials); /*virtual*/ void getChannelInfo(); protected: @@ -154,20 +154,20 @@ public: class LLVoiceChannelP2P : public LLVoiceChannelGroup { public: - LLVoiceChannelP2P(const LLUUID& session_id, const LLString& session_name, const LLUUID& other_user_id); + LLVoiceChannelP2P(const LLUUID& session_id, const std::string& session_name, const LLUUID& other_user_id); /*virtual*/ void handleStatusChange(EStatusType status); /*virtual*/ void handleError(EStatusType status); /*virtual*/ void activate(); /*virtual*/ void getChannelInfo(); - void setSessionHandle(const LLString& handle); + void setSessionHandle(const std::string& handle); protected: virtual void setState(EState state); private: - LLString mSessionHandle; + std::string mSessionHandle; LLUUID mOtherUserID; BOOL mReceivedCall; }; @@ -207,7 +207,7 @@ public: const LLColor4& color = LLColor4::white, bool log_to_file = true, const LLUUID& source = LLUUID::null, - const char *name = NULL); + const std::string& name = LLStringUtil::null); void setInputFocus( BOOL b ); @@ -221,7 +221,7 @@ public: BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg); + std::string& tooltip_msg); static void onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata ); static void onInputEditorFocusLost(LLFocusableElement* caller, void* userdata); @@ -257,7 +257,7 @@ public: // Handle other participant in the session typing. void processIMTyping(const LLIMInfo* im_info, BOOL typing); - static void chatFromLogFile(LLLogChat::ELogLineType type, LLString line, void* userdata); + static void chatFromLogFile(LLLogChat::ELogLineType type, std::string line, void* userdata); //show error statuses to the user void showSessionStartError(const std::string& error_string); @@ -270,7 +270,7 @@ public: private: // called by constructors - void init(const LLString& session_label); + void init(const std::string& session_label); // Called by UI methods. void sendMsg(); @@ -307,7 +307,7 @@ private: // 911 ==> Gaurdian_Angel_Group_ID ^ gAgent.getID() LLUUID mSessionUUID; - LLString mSessionLabel; + std::string mSessionLabel; LLVoiceChannel* mVoiceChannel; BOOL mSessionInitialized; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 75aacabeea..6f473dfba9 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -81,14 +81,14 @@ LLIMMgr* gIMMgr = NULL; // Statics // // *FIXME: make these all either UIStrings or Strings -static LLString sOnlyUserMessage; +static std::string sOnlyUserMessage; static LLUIString sOfflineMessage; -static LLString sMutedMessage; +static std::string sMutedMessage; static LLUIString sInviteMessage; -std::map<std::string,LLString> LLFloaterIM::sEventStringsMap; -std::map<std::string,LLString> LLFloaterIM::sErrorStringsMap; -std::map<std::string,LLString> LLFloaterIM::sForceCloseSessionMap; +std::map<std::string,std::string> LLFloaterIM::sEventStringsMap; +std::map<std::string,std::string> LLFloaterIM::sErrorStringsMap; +std::map<std::string,std::string> LLFloaterIM::sForceCloseSessionMap; // // Helper Functions @@ -97,7 +97,7 @@ std::map<std::string,LLString> LLFloaterIM::sForceCloseSessionMap; // returns true if a should appear before b //static BOOL group_dictionary_sort( LLGroupData* a, LLGroupData* b ) //{ -// return (LLString::compareDict( a->mName, b->mName ) < 0); +// return (LLStringUtil::compareDict( a->mName, b->mName ) < 0); //} @@ -269,13 +269,13 @@ class LLIMMgr::LLIMSessionInvite public: LLIMSessionInvite( const LLUUID& session_id, - const LLString& session_name, + const std::string& session_name, const LLUUID& caller_id, - const LLString& caller_name, + const std::string& caller_name, EInstantMessage type, EInvitationType inv_type, - const LLString& session_handle, - const LLString& notify_box) : + const std::string& session_handle, + const std::string& notify_box) : mSessionID(session_id), mSessionName(session_name), mCallerID(caller_id), @@ -287,13 +287,13 @@ public: {}; LLUUID mSessionID; - LLString mSessionName; + std::string mSessionName; LLUUID mCallerID; - LLString mCallerName; + std::string mCallerName; EInstantMessage mType; EInvitationType mInvType; - LLString mSessionHandle; - LLString mNotifyBox; + std::string mSessionHandle; + std::string mNotifyBox; }; @@ -396,9 +396,9 @@ LLIMMgr::~LLIMMgr() void LLIMMgr::addMessage( const LLUUID& session_id, const LLUUID& target_id, - const char* from, - const char* msg, - const char* session_name, + const std::string& from, + const std::string& msg, + const std::string& session_name, EInstantMessage dialog, U32 parent_estate_id, const LLUUID& region_id, @@ -443,8 +443,8 @@ void LLIMMgr::addMessage( // create IM window as necessary if(!floater) { - const char* name = from; - if(session_name && (strlen(session_name)>1)) + std::string name = from; + if(!session_name.empty() && session_name.size()>1) { name = session_name; } @@ -482,7 +482,7 @@ void LLIMMgr::addMessage( } // now add message to floater - bool is_from_system = target_id.isNull() || !strcmp(from, SYSTEM_FROM); + bool is_from_system = target_id.isNull() || (from == SYSTEM_FROM); const LLColor4& color = ( is_from_system ? gSavedSettings.getColor4("SystemChatColor") : gSavedSettings.getColor("IMChatColor")); @@ -518,7 +518,7 @@ void LLIMMgr::addMessage( } } -void LLIMMgr::addSystemMessage(const LLUUID& session_id, const LLString& message_name, const LLString::format_map_t& args) +void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLStringUtil::format_map_t& args) { LLUIString message; @@ -542,7 +542,7 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const LLString& message message = floaterp->getUIString(message_name); message.setArgList(args); - gIMMgr->addMessage(session_id, LLUUID::null, SYSTEM_FROM, message.getString().c_str()); + gIMMgr->addMessage(session_id, LLUUID::null, SYSTEM_FROM, message.getString()); } } } @@ -576,7 +576,7 @@ BOOL LLIMMgr::isIMSessionOpen(const LLUUID& uuid) LLUUID LLIMMgr::addP2PSession(const std::string& name, const LLUUID& other_participant_id, - const LLString& voice_session_handle) + const std::string& voice_session_handle) { LLUUID session_id = addSession(name, IM_NOTHING_SPECIAL, other_participant_id); @@ -692,12 +692,12 @@ void LLIMMgr::removeSession(const LLUUID& session_id) void LLIMMgr::inviteToSession( const LLUUID& session_id, - const LLString& session_name, + const std::string& session_name, const LLUUID& caller_id, - const LLString& caller_name, + const std::string& caller_name, EInstantMessage type, EInvitationType inv_type, - const LLString& session_handle) + const std::string& session_handle) { //ignore invites from muted residents if (LLMuteList::getInstance()->isMuted(caller_id)) @@ -705,7 +705,7 @@ void LLIMMgr::inviteToSession( return; } - LLString notify_box_type; + std::string notify_box_type; BOOL ad_hoc_invite = FALSE; if(type == IM_SESSION_P2P_INVITE) @@ -769,11 +769,11 @@ void LLIMMgr::inviteToSession( { if (caller_name.empty()) { - gCacheName->getName(caller_id, onInviteNameLookup, invite); + gCacheName->get(caller_id, FALSE, onInviteNameLookup, invite); } else { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = caller_name; args["[GROUP]"] = session_name; @@ -792,14 +792,14 @@ void LLIMMgr::inviteToSession( } //static -void LLIMMgr::onInviteNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* userdata) +void LLIMMgr::onInviteNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* userdata) { LLIMSessionInvite* invite = (LLIMSessionInvite*)userdata; - invite->mCallerName = llformat("%s %s", first, last); + invite->mCallerName = first + " " + last; invite->mSessionName = invite->mCallerName; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = invite->mCallerName; LLNotifyBox::showXml( @@ -1248,8 +1248,7 @@ void LLIMMgr::noteMutedUsers(LLFloaterIMPanel* floater, for(S32 i = 0; i < count; ++i) { info = at.getBuddyInfo(ids.get(i)); - char first[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ - char last[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string first, last; if(info && LLMuteList::getInstance() && LLMuteList::getInstance()->isMuted(ids.get(i)) && gCacheName->getName(ids.get(i), first, last)) { @@ -1413,7 +1412,7 @@ public: const LLSD& input) const { LLUUID session_id; - LLString reason; + std::string reason; session_id = input["body"]["session_id"].asUUID(); reason = input["body"]["reason"].asString(); @@ -1495,7 +1494,6 @@ public: { return; } - char buffer[DB_IM_MSG_BUF_SIZE * 2]; /* Flawfinder: ignore */ LLChat chat; std::string message = message_params["message"].asString(); @@ -1511,19 +1509,18 @@ public: BOOL is_busy = gAgent.getBusy(); BOOL is_muted = LLMuteList::getInstance()->isMuted( from_id, - name.c_str(), + name, LLMute::flagTextChat); - BOOL is_linden = LLMuteList::getInstance()->isLinden( - name.c_str()); - char separator_string[3]=": "; /* Flawfinder: ignore */ + BOOL is_linden = LLMuteList::getInstance()->isLinden(name); + std::string separator_string(": "); int message_offset=0; //Handle IRC styled /me messages. - if (!strncmp(message.c_str(), "/me ", 4) || - !strncmp(message.c_str(), "/me'", 4)) + std::string prefix = message.substr(0, 4); + if (prefix == "/me " || prefix == "/me'") { - strcpy(separator_string,""); /* Flawfinder: ignore */ + separator_string = ""; message_offset = 3; } @@ -1537,23 +1534,12 @@ public: } // standard message, not from system - char saved[MAX_STRING]; /* Flawfinder: ignore */ - saved[0] = '\0'; + std::string saved; if(offline == IM_OFFLINE) { - char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ - snprintf(saved, /* Flawfinder: ignore */ - MAX_STRING, - "(Saved %s) ", - formatted_time(timestamp, time_buf)); + saved = llformat("(Saved %s) ", formatted_time(timestamp).c_str()); } - snprintf( - buffer, - sizeof(buffer), - "%s%s%s", - separator_string, - saved, - (message.c_str() + message_offset)); /*Flawfinder: ignore*/ + std::string buffer = separator_string + saved + message.substr(message_offset); BOOL is_this_agent = FALSE; if(from_id == gAgentID) @@ -1563,24 +1549,16 @@ public: gIMMgr->addMessage( session_id, from_id, - name.c_str(), + name, buffer, - (char*)&bin_bucket[0], + std::string((char*)&bin_bucket[0]), IM_SESSION_INVITE, message_params["parent_estate_id"].asInteger(), message_params["region_id"].asUUID(), ll_vector3_from_sd(message_params["position"]), true); - snprintf( - buffer, - sizeof(buffer), - "IM: %s%s%s%s", - name.c_str(), - separator_string, - saved, - (message.c_str()+message_offset)); /* Flawfinder: ignore */ - chat.mText = buffer; + chat.mText = std::string("IM: ") + name + separator_string + saved + message.substr(message_offset); LLFloaterChat::addChat(chat, TRUE, is_this_agent); //K now we want to accept the invitation diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index 91768132ed..da64cd3bab 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -59,16 +59,16 @@ public: // or agent id. void addMessage(const LLUUID& session_id, const LLUUID& target_id, - const char* from, - const char* msg, - const char* session_name = NULL, + const std::string& from, + const std::string& msg, + const std::string& session_name = LLStringUtil::null, EInstantMessage dialog = IM_NOTHING_SPECIAL, U32 parent_estate_id = 0, const LLUUID& region_id = LLUUID::null, const LLVector3& position = LLVector3::zero, bool link_name = false); - void addSystemMessage(const LLUUID& session_id, const LLString& message_name, const LLString::format_map_t& args); + void addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLStringUtil::format_map_t& args); // This method returns TRUE if the local viewer has a session // currently open keyed to the uuid. The uuid can be keyed by @@ -97,7 +97,7 @@ public: // Creates a P2P session with the requisite handle for responding to voice calls LLUUID addP2PSession(const std::string& name, const LLUUID& other_participant_id, - const LLString& voice_session_handle); + const std::string& voice_session_handle); // This removes the panel referenced by the uuid, and then // restores internal consistency. The internal pointer is not @@ -106,12 +106,12 @@ public: void inviteToSession( const LLUUID& session_id, - const LLString& session_name, + const std::string& session_name, const LLUUID& caller, - const LLString& caller_name, + const std::string& caller_name, EInstantMessage type, EInvitationType inv_type, - const LLString& session_handle = LLString::null); + const std::string& session_handle = LLStringUtil::null); //Updates a given session's session IDs. Does not open, //create or do anything new. If the old session doesn't @@ -198,7 +198,7 @@ private: void processIMTypingCore(const LLIMInfo* im_info, BOOL typing); static void inviteUserResponse(S32 option, void* user_data); - static void onInviteNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* userdata); + static void onInviteNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* userdata); private: std::set<LLHandle<LLFloater> > mFloaters; @@ -218,9 +218,9 @@ public: LLFloaterIM(); /*virtual*/ BOOL postBuild(); - static std::map<std::string,LLString> sEventStringsMap; - static std::map<std::string,LLString> sErrorStringsMap; - static std::map<std::string,LLString> sForceCloseSessionMap; + static std::map<std::string,std::string> sEventStringsMap; + static std::map<std::string,std::string> sErrorStringsMap; + static std::map<std::string,std::string> sForceCloseSessionMap; }; // Globals diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index e948b64459..8aa51ad048 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -111,7 +111,7 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata); void move_task_inventory_callback(S32 option, void* user_data); void confirm_replace_attachment_rez(S32 option, void* user_data); -const char* ICON_NAME[ICON_NAME_COUNT] = +std::string ICON_NAME[ICON_NAME_COUNT] = { "inv_item_texture.tga", "inv_item_sound.tga", @@ -157,17 +157,17 @@ BOOL gAddToOutfit = FALSE; // | LLInvFVBridge | // +=================================================+ -const LLString& LLInvFVBridge::getName() const +const std::string& LLInvFVBridge::getName() const { LLInventoryObject* obj = getInventoryObject(); if(obj) { return obj->getName(); } - return LLString::null; + return LLStringUtil::null; } -const LLString& LLInvFVBridge::getDisplayName() const +const std::string& LLInvFVBridge::getDisplayName() const { return getName(); } @@ -377,15 +377,15 @@ BOOL LLInvFVBridge::isClipboardPasteable() const } void hideContextEntries(LLMenuGL& menu, - const std::vector<LLString> &entries_to_show, - const std::vector<LLString> &disabled_entries) + const std::vector<std::string> &entries_to_show, + const std::vector<std::string> &disabled_entries) { const LLView::child_list_t *list = menu.getChildList(); LLView::child_list_t::const_iterator itor; for (itor = list->begin(); itor != list->end(); ++itor) { - LLString name = (*itor)->getName(); + std::string name = (*itor)->getName(); // descend into split menus: LLMenuItemBranchGL* branchp = dynamic_cast<LLMenuItemBranchGL*>(*itor); @@ -396,7 +396,7 @@ void hideContextEntries(LLMenuGL& menu, bool found = false; - std::vector<LLString>::const_iterator itor2; + std::vector<std::string>::const_iterator itor2; for (itor2 = entries_to_show.begin(); itor2 != entries_to_show.end(); ++itor2) { if (*itor2 == name) @@ -422,66 +422,68 @@ void hideContextEntries(LLMenuGL& menu, } // Helper for commonly-used entries -void LLInvFVBridge::getClipboardEntries(bool show_asset_id, std::vector<LLString> &items, - std::vector<LLString> &disabled_items, U32 flags) +void LLInvFVBridge::getClipboardEntries(bool show_asset_id, std::vector<std::string> &items, + std::vector<std::string> &disabled_items, U32 flags) { - items.push_back("Rename"); + // *TODO: Translate + items.push_back(std::string("Rename")); if (!isItemRenameable() || (flags & FIRST_SELECTED_ITEM) == 0) { - disabled_items.push_back("Rename"); + disabled_items.push_back(std::string("Rename")); } if (show_asset_id) { - items.push_back("Copy Asset UUID"); + items.push_back(std::string("Copy Asset UUID")); if ( (! ( isItemPermissive() || gAgent.isGodlike() ) ) || (flags & FIRST_SELECTED_ITEM) == 0) { - disabled_items.push_back("Copy Asset UUID"); + disabled_items.push_back(std::string("Copy Asset UUID")); } } - items.push_back("Copy Separator"); + items.push_back(std::string("Copy Separator")); - items.push_back("Copy"); + items.push_back(std::string("Copy")); if (!isItemCopyable()) { - disabled_items.push_back("Copy"); + disabled_items.push_back(std::string("Copy")); } - items.push_back("Paste"); + items.push_back(std::string("Paste")); if (!isClipboardPasteable() || (flags & FIRST_SELECTED_ITEM) == 0) { - disabled_items.push_back("Paste"); + disabled_items.push_back(std::string("Paste")); } - items.push_back("Paste Separator"); + items.push_back(std::string("Paste Separator")); - items.push_back("Delete"); + items.push_back(std::string("Delete")); if (!isItemRemovable()) { - disabled_items.push_back("Delete"); + disabled_items.push_back(std::string("Delete")); } } void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { + // *TODO: Translate lldebugs << "LLInvFVBridge::buildContextMenu()" << llendl; - std::vector<LLString> items; - std::vector<LLString> disabled_items; + std::vector<std::string> items; + std::vector<std::string> disabled_items; if(isInTrash()) { - items.push_back("Purge Item"); + items.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - disabled_items.push_back("Purge Item"); + disabled_items.push_back(std::string("Purge Item")); } - items.push_back("Restore Item"); + items.push_back(std::string("Restore Item")); } else { - items.push_back("Open"); - items.push_back("Properties"); + items.push_back(std::string("Open")); + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); } @@ -728,7 +730,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type, // | LLItemBridge | // +=================================================+ -void LLItemBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) +void LLItemBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { if ("open" == action) { @@ -762,7 +764,7 @@ void LLItemBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLInventoryItem* item = model->getItem(mUUID); if(!item) return; LLUUID asset_id = item->getAssetUUID(); - char buffer[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string buffer; asset_id.toString(buffer); gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(buffer)); @@ -832,7 +834,7 @@ PermissionMask LLItemBridge::getPermissionMask() const return perm_mask; } -const LLString& LLItemBridge::getDisplayName() const +const std::string& LLItemBridge::getDisplayName() const { if(mDisplayName.empty()) { @@ -841,7 +843,7 @@ const LLString& LLItemBridge::getDisplayName() const return mDisplayName; } -void LLItemBridge::buildDisplayName(LLInventoryItem* item, LLString& name) +void LLItemBridge::buildDisplayName(LLInventoryItem* item, std::string& name) { if(item) { @@ -849,13 +851,13 @@ void LLItemBridge::buildDisplayName(LLInventoryItem* item, LLString& name) } else { - name.assign(LLString::null); + name.assign(LLStringUtil::null); } } -LLString LLItemBridge::getLabelSuffix() const +std::string LLItemBridge::getLabelSuffix() const { - LLString suffix; + std::string suffix; LLInventoryItem* item = getItem(); if(item) { @@ -867,6 +869,7 @@ LLString LLItemBridge::getLabelSuffix() const BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID()); BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()); + // *TODO: Translate const char* EMPTY = ""; const char* NO_COPY = " (no copy)"; const char* NO_MOD = " (no modify)"; @@ -880,15 +883,7 @@ LLString LLItemBridge::getLabelSuffix() const const char* sxfer; if(xfer) sxfer = EMPTY; else sxfer = NO_XFER; - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf( /* Flawfinder: ignore */ - buffer, - MAX_STRING, - "%s%s%s", - scopy, - smod, - sxfer); - suffix.assign(buffer); + suffix = llformat("%s%s%s",scopy,smod,sxfer); } } return suffix; @@ -915,7 +910,7 @@ BOOL LLItemBridge::isItemRenameable() const return FALSE; } -BOOL LLItemBridge::renameItem(const LLString& new_name) +BOOL LLItemBridge::renameItem(const std::string& new_name) { if(!isItemRenameable()) return FALSE; LLPreview::rename(mUUID, getPrefix() + new_name); @@ -1543,7 +1538,7 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask) -void LLFolderBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) +void LLFolderBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { if ("open" == action) { @@ -1692,7 +1687,7 @@ LLUIImagePtr LLFolderBridge::getIcon() const return LLUI::getUIImage(control); } -BOOL LLFolderBridge::renameItem(const LLString& new_name) +BOOL LLFolderBridge::renameItem(const std::string& new_name) { if(!isItemRenameable()) return FALSE; LLInventoryModel* model = mInventoryPanel->getModel(); @@ -1796,8 +1791,10 @@ void LLFolderBridge::staticFolderOptionsMenu() void LLFolderBridge::folderOptionsMenu() { - std::vector<LLString> disabled_items; + std::vector<std::string> disabled_items; + // *TODO: Translate + LLInventoryModel* model = mInventoryPanel->getModel(); if(!model) return; @@ -1806,9 +1803,9 @@ void LLFolderBridge::folderOptionsMenu() LLIsType is_callingcard(LLAssetType::AT_CALLINGCARD); if (mCallingCards || checkFolderForContentsOfType(model, is_callingcard)) { - mItems.push_back("Calling Card Separator"); - mItems.push_back("Conference Chat Folder"); - mItems.push_back("IM All Contacts In Folder"); + mItems.push_back(std::string("Calling Card Separator")); + mItems.push_back(std::string("Conference Chat Folder")); + mItems.push_back(std::string("IM All Contacts In Folder")); } // wearables related functionality for folders. @@ -1822,16 +1819,16 @@ void LLFolderBridge::folderOptionsMenu() checkFolderForContentsOfType(model, is_object) || checkFolderForContentsOfType(model, is_gesture) ) { - mItems.push_back("Folder Wearables Separator"); + mItems.push_back(std::string("Folder Wearables Separator")); // Only enable add/replace outfit for non-default folders. const LLInventoryCategory* category = model->getCategory(mUUID); if (!category || (LLAssetType::AT_NONE == category->getPreferredType())) { - mItems.push_back("Add To Outfit"); - mItems.push_back("Replace Outfit"); + mItems.push_back(std::string("Add To Outfit")); + mItems.push_back(std::string("Replace Outfit")); } - mItems.push_back("Take Off Items"); + mItems.push_back(std::string("Take Off Items")); } hideContextEntries(*mMenu, mItems, disabled_items); } @@ -1851,8 +1848,9 @@ BOOL LLFolderBridge::checkFolderForContentsOfType(LLInventoryModel* model, LLInv // Flags unused void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { + // *TODO: Translate lldebugs << "LLFolderBridge::buildContextMenu()" << llendl; -// std::vector<LLString> disabled_items; +// std::vector<std::string> disabled_items; LLInventoryModel* model = mInventoryPanel->getModel(); if(!model) return; LLUUID trash_id = model->findCategoryUUIDForType(LLAssetType::AT_TRASH); @@ -1861,25 +1859,25 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) if (lost_and_found_id == mUUID) { // This is the lost+found folder. - mItems.push_back("Empty Lost And Found"); + mItems.push_back(std::string("Empty Lost And Found")); } if(trash_id == mUUID) { // This is the trash. - mItems.push_back("Empty Trash"); + mItems.push_back(std::string("Empty Trash")); } else if(model->isObjectDescendentOf(mUUID, trash_id)) { // This is a folder in the trash. mItems.clear(); // clear any items that used to exist - mItems.push_back("Purge Item"); + mItems.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - mDisabledItems.push_back("Purge Item"); + mDisabledItems.push_back(std::string("Purge Item")); } - mItems.push_back("Restore Item"); + mItems.push_back(std::string("Restore Item")); } else if(isAgentInventory()) // do not allow creating in library { @@ -1908,12 +1906,12 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) is_callingcard); if(item_array.count() > 0) contains_calling_cards = TRUE; */ - mItems.push_back("New Folder"); - mItems.push_back("New Script"); - mItems.push_back("New Note"); - mItems.push_back("New Gesture"); - mItems.push_back("New Clothes"); - mItems.push_back("New Body Parts"); + mItems.push_back(std::string("New Folder")); + mItems.push_back(std::string("New Script")); + mItems.push_back(std::string("New Note")); + mItems.push_back(std::string("New Gesture")); + mItems.push_back(std::string("New Clothes")); + mItems.push_back(std::string("New Body Parts")); getClipboardEntries(false, mItems, mDisabledItems, flags); @@ -1960,8 +1958,8 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } else { - mItems.push_back("--no options--"); - mDisabledItems.push_back("--no options--"); + mItems.push_back(std::string("--no options--")); + mDisabledItems.push_back(std::string("--no options--")); } hideContextEntries(menu, mItems, mDisabledItems); } @@ -2036,7 +2034,7 @@ void LLFolderBridge::createNewCategory(void* user_data) LLUUID id; id = model->createNewCategory(bridge->getUUID(), LLAssetType::AT_NONE, - NULL); + LLStringUtil::null); model->notifyObservers(); // At this point, the bridge has probably been deleted, but the @@ -2361,7 +2359,7 @@ LLUIImagePtr LLScriptBridge::getIcon() const // | LLTextureBridge | // +=================================================+ -LLString LLTextureBridge::sPrefix("Texture: "); +std::string LLTextureBridge::sPrefix("Texture: "); LLUIImagePtr LLTextureBridge::getIcon() const @@ -2370,7 +2368,7 @@ LLUIImagePtr LLTextureBridge::getIcon() const } void open_texture(const LLUUID& item_id, - const LLString& title, + const std::string& title, BOOL show_keep_discard, const LLUUID& source_id, BOOL take_focus) @@ -2411,7 +2409,7 @@ void LLTextureBridge::openItem() // | LLSoundBridge | // +=================================================+ -LLString LLSoundBridge::sPrefix("Sound: "); +std::string LLSoundBridge::sPrefix("Sound: "); LLUIImagePtr LLSoundBridge::getIcon() const @@ -2476,29 +2474,30 @@ void LLSoundBridge::openSoundPreview(void* which) void LLSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { lldebugs << "LLTextureBridge::buildContextMenu()" << llendl; - std::vector<LLString> items; - std::vector<LLString> disabled_items; + std::vector<std::string> items; + std::vector<std::string> disabled_items; + // *TODO: Translate if(isInTrash()) { - items.push_back("Purge Item"); + items.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - disabled_items.push_back("Purge Item"); + disabled_items.push_back(std::string("Purge Item")); } - items.push_back("Restore Item"); + items.push_back(std::string("Restore Item")); } else { - items.push_back("Sound Open"); - items.push_back("Properties"); + items.push_back(std::string("Sound Open")); + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); } - items.push_back("Sound Separator"); - items.push_back("Sound Play"); + items.push_back(std::string("Sound Separator")); + items.push_back(std::string("Sound Play")); hideContextEntries(menu, items, disabled_items); } @@ -2507,7 +2506,7 @@ void LLSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags) // | LLLandmarkBridge | // +=================================================+ -LLString LLLandmarkBridge::sPrefix("Landmark: "); +std::string LLLandmarkBridge::sPrefix("Landmark: "); LLUIImagePtr LLLandmarkBridge::getIcon() const { @@ -2516,37 +2515,38 @@ LLUIImagePtr LLLandmarkBridge::getIcon() const void LLLandmarkBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - std::vector<LLString> items; - std::vector<LLString> disabled_items; + std::vector<std::string> items; + std::vector<std::string> disabled_items; + // *TODO: Translate lldebugs << "LLLandmarkBridge::buildContextMenu()" << llendl; if(isInTrash()) { - items.push_back("Purge Item"); + items.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - disabled_items.push_back("Purge Item"); + disabled_items.push_back(std::string("Purge Item")); } - items.push_back("Restore Item"); + items.push_back(std::string("Restore Item")); } else { - items.push_back("Landmark Open"); - items.push_back("Properties"); + items.push_back(std::string("Landmark Open")); + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); } - items.push_back("Landmark Separator"); - items.push_back("Teleport To Landmark"); + items.push_back(std::string("Landmark Separator")); + items.push_back(std::string("Teleport To Landmark")); hideContextEntries(menu, items, disabled_items); } // virtual -void LLLandmarkBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) +void LLLandmarkBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { if ("teleport" == action) { @@ -2568,14 +2568,14 @@ void LLLandmarkBridge::performAction(LLFolderView* folder, LLInventoryModel* mod LLViewerInventoryItem* item = getItem(); if(item) { - open_landmark(item, LLString(" ") + getPrefix() + item->getName(), FALSE); + open_landmark(item, std::string(" ") + getPrefix() + item->getName(), FALSE); } } else LLItemBridge::performAction(folder, model, action); } void open_landmark(LLViewerInventoryItem* inv_item, - const LLString& title, + const std::string& title, BOOL show_keep_discard, const LLUUID& source_id, BOOL take_focus) @@ -2627,7 +2627,7 @@ void LLLandmarkBridge::openItem() { // Opening (double-clicking) a landmark immediately teleports, // but warns you the first time. - // open_landmark(item, LLString(" ") + getPrefix() + item->getName(), FALSE); + // open_landmark(item, std::string(" ") + getPrefix() + item->getName(), FALSE); LLUUID* asset_idp = new LLUUID(item->getAssetUUID()); LLAlertDialog::showXml("TeleportFromLandmark", open_landmark_callback, (void*)asset_idp); @@ -2647,7 +2647,7 @@ void LLCallingCardObserver::changed(U32 mask) // | LLCallingCardBridge | // +=================================================+ -LLString LLCallingCardBridge::sPrefix("Calling Card: "); +std::string LLCallingCardBridge::sPrefix("Calling Card: "); LLCallingCardBridge::LLCallingCardBridge( LLInventoryPanel* inventory, const LLUUID& uuid ) : LLItemBridge(inventory, uuid) @@ -2672,7 +2672,7 @@ void LLCallingCardBridge::refreshFolderViewItem() } // virtual -void LLCallingCardBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) +void LLCallingCardBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { if ("begin_im" == action) { @@ -2707,7 +2707,7 @@ LLUIImagePtr LLCallingCardBridge::getIcon() const return get_item_icon(LLAssetType::AT_CALLINGCARD, LLInventoryType::IT_CALLINGCARD, online, FALSE); } -LLString LLCallingCardBridge::getLabelSuffix() const +std::string LLCallingCardBridge::getLabelSuffix() const { LLViewerInventoryItem* item = getItem(); if( item && LLAvatarTracker::instance().isBuddyOnline(item->getCreatorUUID()) ) @@ -2733,24 +2733,25 @@ void LLCallingCardBridge::openItem() void LLCallingCardBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { + // *TODO: Translate lldebugs << "LLCallingCardBridge::buildContextMenu()" << llendl; - std::vector<LLString> items; - std::vector<LLString> disabled_items; + std::vector<std::string> items; + std::vector<std::string> disabled_items; if(isInTrash()) { - items.push_back("Purge Item"); + items.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - disabled_items.push_back("Purge Item"); + disabled_items.push_back(std::string("Purge Item")); } - items.push_back("Restore Item"); + items.push_back(std::string("Restore Item")); } else { - items.push_back("Open"); - items.push_back("Properties"); + items.push_back(std::string("Open")); + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); @@ -2759,19 +2760,19 @@ void LLCallingCardBridge::buildContextMenu(LLMenuGL& menu, U32 flags) && (LLUUID::null != item->getCreatorUUID()) && (item->getCreatorUUID() != gAgent.getID())); BOOL user_online = (LLAvatarTracker::instance().isBuddyOnline(item->getCreatorUUID())); - items.push_back("Send Instant Message Separator"); - items.push_back("Send Instant Message"); - items.push_back("Offer Teleport..."); - items.push_back("Conference Chat"); + items.push_back(std::string("Send Instant Message Separator")); + items.push_back(std::string("Send Instant Message")); + items.push_back(std::string("Offer Teleport...")); + items.push_back(std::string("Conference Chat")); if (!good_card) { - disabled_items.push_back("Send Instant Message"); + disabled_items.push_back(std::string("Send Instant Message")); } if (!good_card || !user_online) { - disabled_items.push_back("Offer Teleport..."); - disabled_items.push_back("Conference Chat"); + disabled_items.push_back(std::string("Offer Teleport...")); + disabled_items.push_back(std::string("Conference Chat")); } } hideContextEntries(menu, items, disabled_items); @@ -2853,7 +2854,7 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop, // | LLNotecardBridge | // +=================================================+ -LLString LLNotecardBridge::sPrefix("Note: "); +std::string LLNotecardBridge::sPrefix("Note: "); LLUIImagePtr LLNotecardBridge::getIcon() const @@ -2862,7 +2863,7 @@ LLUIImagePtr LLNotecardBridge::getIcon() const } void open_notecard(LLViewerInventoryItem* inv_item, - const LLString& title, + const std::string& title, const LLUUID& object_id, BOOL show_keep_discard, const LLUUID& source_id, @@ -2922,7 +2923,7 @@ void LLNotecardBridge::openItem() // | LLGestureBridge | // +=================================================+ -LLString LLGestureBridge::sPrefix("Gesture: "); +std::string LLGestureBridge::sPrefix("Gesture: "); LLUIImagePtr LLGestureBridge::getIcon() const { @@ -2941,7 +2942,7 @@ LLFontGL::StyleFlags LLGestureBridge::getLabelStyle() const } } -LLString LLGestureBridge::getLabelSuffix() const +std::string LLGestureBridge::getLabelSuffix() const { if( gGestureManager.isGestureActive(mUUID) ) { @@ -2954,7 +2955,7 @@ LLString LLGestureBridge::getLabelSuffix() const } // virtual -void LLGestureBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) +void LLGestureBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { if ("activate" == action) { @@ -2992,7 +2993,7 @@ void LLGestureBridge::openItem() if(!LLPreview::show(mUUID)) { LLUUID item_id = mUUID; - LLString title = getPrefix() + item->getName(); + std::string title = getPrefix() + item->getName(); LLUUID object_id = LLUUID::null; // TODO: save the rectangle @@ -3013,29 +3014,30 @@ BOOL LLGestureBridge::removeItem() void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { + // *TODO: Translate lldebugs << "LLGestureBridge::buildContextMenu()" << llendl; - std::vector<LLString> items; - std::vector<LLString> disabled_items; + std::vector<std::string> items; + std::vector<std::string> disabled_items; if(isInTrash()) { - items.push_back("Purge Item"); + items.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - disabled_items.push_back("Purge Item"); + disabled_items.push_back(std::string("Purge Item")); } - items.push_back("Restore Item"); + items.push_back(std::string("Restore Item")); } else { - items.push_back("Open"); - items.push_back("Properties"); + items.push_back(std::string("Open")); + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); - items.push_back("Gesture Separator"); - items.push_back("Activate"); - items.push_back("Deactivate"); + items.push_back(std::string("Gesture Separator")); + items.push_back(std::string("Activate")); + items.push_back(std::string("Deactivate")); /*menu.append(new LLMenuItemCallGL("Activate", handleActivateGesture, @@ -3053,7 +3055,7 @@ void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) // | LLAnimationBridge | // +=================================================+ -LLString LLAnimationBridge::sPrefix("Animation: "); +std::string LLAnimationBridge::sPrefix("Animation: "); LLUIImagePtr LLAnimationBridge::getIcon() const @@ -3063,38 +3065,39 @@ LLUIImagePtr LLAnimationBridge::getIcon() const void LLAnimationBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - std::vector<LLString> items; - std::vector<LLString> disabled_items; + // *TODO: Translate + std::vector<std::string> items; + std::vector<std::string> disabled_items; lldebugs << "LLAnimationBridge::buildContextMenu()" << llendl; if(isInTrash()) { - items.push_back("Purge Item"); + items.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - disabled_items.push_back("Purge Item"); + disabled_items.push_back(std::string("Purge Item")); } - items.push_back("Restore Item"); + items.push_back(std::string("Restore Item")); } else { - items.push_back("Animation Open"); - items.push_back("Properties"); + items.push_back(std::string("Animation Open")); + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); } - items.push_back("Animation Separator"); - items.push_back("Animation Play"); - items.push_back("Animation Audition"); + items.push_back(std::string("Animation Separator")); + items.push_back(std::string("Animation Play")); + items.push_back(std::string("Animation Audition")); hideContextEntries(menu, items, disabled_items); } // virtual -void LLAnimationBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) +void LLAnimationBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { S32 activate = 0; @@ -3161,7 +3164,7 @@ void LLAnimationBridge::openItem() // +=================================================+ // static -LLString LLObjectBridge::sPrefix("Object: "); +std::string LLObjectBridge::sPrefix("Object: "); // static LLUUID LLObjectBridge::sContextMenuItemID; @@ -3182,7 +3185,7 @@ LLUIImagePtr LLObjectBridge::getIcon() const void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment); // virtual -void LLObjectBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) +void LLObjectBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { if ("attach" == action) { @@ -3255,14 +3258,14 @@ LLFontGL::StyleFlags LLObjectBridge::getLabelStyle() const } } -LLString LLObjectBridge::getLabelSuffix() const +std::string LLObjectBridge::getLabelSuffix() const { LLVOAvatar* avatar = gAgent.getAvatarObject(); if( avatar && avatar->isWearingAttachment( mUUID ) ) { - LLString attachment_point_name = avatar->getAttachedPointName(mUUID); - LLString::toLower(attachment_point_name); - return LLItemBridge::getLabelSuffix() + LLString(" (worn on ") + attachment_point_name + LLString(")"); + std::string attachment_point_name = avatar->getAttachedPointName(mUUID); + LLStringUtil::toLower(attachment_point_name); + return LLItemBridge::getLabelSuffix() + std::string(" (worn on ") + attachment_point_name + std::string(")"); } else { @@ -3330,21 +3333,22 @@ void confirm_replace_attachment_rez(S32 option, void* user_data) void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { - std::vector<LLString> items; - std::vector<LLString> disabled_items; + // *TODO: Translate + std::vector<std::string> items; + std::vector<std::string> disabled_items; if(isInTrash()) { - items.push_back("Purge Item"); + items.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - disabled_items.push_back("Purge Item"); + disabled_items.push_back(std::string("Purge Item")); } - items.push_back("Restore Item"); + items.push_back(std::string("Restore Item")); } else { - items.push_back("Properties"); + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); @@ -3361,15 +3365,15 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) if( avatarp->isWearingAttachment( mUUID ) ) { - items.push_back("Detach From Yourself"); + items.push_back(std::string("Detach From Yourself")); } else if( !isInTrash() ) { - items.push_back("Attach Separator"); - items.push_back("Object Wear"); - items.push_back("Attach To"); - items.push_back("Attach To HUD"); + items.push_back(std::string("Attach Separator")); + items.push_back(std::string("Object Wear")); + items.push_back(std::string("Attach To")); + items.push_back(std::string("Attach To HUD")); LLMenuGL* attach_menu = menu.getChildMenuByName("Attach To", TRUE); LLMenuGL* attach_hud_menu = menu.getChildMenuByName("Attach To HUD", TRUE); @@ -3411,7 +3415,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) hideContextEntries(menu, items, disabled_items); } -BOOL LLObjectBridge::renameItem(const LLString& new_name) +BOOL LLObjectBridge::renameItem(const std::string& new_name) { if(!isItemRenameable()) return FALSE; LLPreview::rename(mUUID, getPrefix() + new_name); @@ -3449,7 +3453,7 @@ BOOL LLObjectBridge::renameItem(const LLString& new_name) // | LLLSLTextBridge | // +=================================================+ -LLString LLLSLTextBridge::sPrefix("Script: "); +std::string LLLSLTextBridge::sPrefix("Script: "); LLUIImagePtr LLLSLTextBridge::getIcon() const { @@ -3505,7 +3509,7 @@ struct LLFoundData { LLFoundData(const LLUUID& item_id, const LLUUID& asset_id, - const LLString& name, + const std::string& name, LLAssetType::EType asset_type) : mItemID(item_id), mAssetID(asset_id), @@ -3515,7 +3519,7 @@ struct LLFoundData LLUUID mItemID; LLUUID mAssetID; - LLString mName; + std::string mName; LLAssetType::EType mAssetType; LLWearable* mWearable; }; @@ -3598,7 +3602,7 @@ void LLOutfitObserver::done() if(mCopyItems) { LLInventoryCategory* cat = gInventory.getCategory(mCatID); - LLString name; + std::string name; if(!cat) { // should never happen. @@ -3729,7 +3733,7 @@ void LLOutfitFetch::done() } } -void wear_outfit_by_name(const char* name) +void wear_outfit_by_name(const std::string& name) { llinfos << "Wearing category " << name << llendl; inc_busy_count(); @@ -4204,7 +4208,7 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata) category_id = NULL; } -BOOL LLWearableBridge::renameItem(const LLString& new_name) +BOOL LLWearableBridge::renameItem(const std::string& new_name) { if( gAgent.isWearingItem( mUUID ) ) { @@ -4232,7 +4236,7 @@ LLFontGL::StyleFlags LLWearableBridge::getLabelStyle() const } } -LLString LLWearableBridge::getLabelSuffix() const +std::string LLWearableBridge::getLabelSuffix() const { if( gAgent.isWearingItem( mUUID ) ) { @@ -4250,7 +4254,7 @@ LLUIImagePtr LLWearableBridge::getIcon() const } // virtual -void LLWearableBridge::performAction(LLFolderView* folder, LLInventoryModel* model, LLString action) +void LLWearableBridge::performAction(LLFolderView* folder, LLInventoryModel* model, std::string action) { if ("wear" == action) { @@ -4319,18 +4323,19 @@ void LLWearableBridge::openItem() void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { + // *TODO: Translate lldebugs << "LLWearableBridge::buildContextMenu()" << llendl; - std::vector<LLString> items; - std::vector<LLString> disabled_items; + std::vector<std::string> items; + std::vector<std::string> disabled_items; if(isInTrash()) { - items.push_back("Purge Item"); + items.push_back(std::string("Purge Item")); if (!isItemRemovable()) { - disabled_items.push_back("Purge Item"); + disabled_items.push_back(std::string("Purge Item")); } - items.push_back("Restore Item"); + items.push_back(std::string("Restore Item")); } else { // FWIW, it looks like SUPPRESS_OPEN_ITEM is not set anywhere @@ -4345,22 +4350,22 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } if (!no_open) { - items.push_back("Open"); + items.push_back(std::string("Open")); } - items.push_back("Properties"); + items.push_back(std::string("Properties")); getClipboardEntries(true, items, disabled_items, flags); - items.push_back("Wearable Separator"); + items.push_back(std::string("Wearable Separator")); - items.push_back("Wearable Wear"); - items.push_back("Wearable Edit"); + items.push_back(std::string("Wearable Wear")); + items.push_back(std::string("Wearable Edit")); if ((flags & FIRST_SELECTED_ITEM) == 0) { - disabled_items.push_back("Wearable Edit"); + disabled_items.push_back(std::string("Wearable Edit")); } //menu.appendSeparator(); //menu.append(new LLMenuItemCallGL("Wear", @@ -4374,7 +4379,7 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) if( item && (item->getType() == LLAssetType::AT_CLOTHING) ) { - items.push_back("Take Off"); + items.push_back(std::string("Take Off")); /*menu.append(new LLMenuItemCallGL("Take Off", LLWearableBridge::onRemoveFromAvatar, LLWearableBridge::canRemoveFromAvatar, diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 2646dab96c..d038c10c73 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -70,7 +70,7 @@ enum EInventoryIcon ICON_NAME_COUNT }; -extern const char* ICON_NAME[ICON_NAME_COUNT]; +extern std::string ICON_NAME[ICON_NAME_COUNT]; typedef std::pair<LLUUID, LLUUID> two_uuids_t; typedef std::list<two_uuids_t> two_uuids_list_t; @@ -157,24 +157,24 @@ public: virtual const LLUUID& getUUID() const { return mUUID; } - virtual const LLString& getPrefix() { return LLString::null; } + virtual const std::string& getPrefix() { return LLStringUtil::null; } virtual void restoreItem() {} // LLFolderViewEventListener functions - virtual const LLString& getName() const; - virtual const LLString& getDisplayName() const; + virtual const std::string& getName() const; + virtual const std::string& getDisplayName() const; virtual PermissionMask getPermissionMask() const; virtual time_t getCreationDate() const; virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; } - virtual LLString getLabelSuffix() const { return LLString::null; } + virtual std::string getLabelSuffix() const { return LLStringUtil::null; } virtual void openItem() {} virtual void previewItem() {openItem();} virtual void showProperties(); virtual BOOL isItemRenameable() const { return TRUE; } - //virtual BOOL renameItem(const LLString& new_name) {} + //virtual BOOL renameItem(const std::string& new_name) {} virtual BOOL isItemRemovable(); virtual BOOL isItemMovable(); //virtual BOOL removeItem() = 0; @@ -185,8 +185,8 @@ public: virtual void cutToClipboard() {} virtual BOOL isClipboardPasteable() const; virtual void pasteFromClipboard() {} - void getClipboardEntries(bool show_asset_id, std::vector<LLString> &items, - std::vector<LLString> &disabled_items, U32 flags); + void getClipboardEntries(bool show_asset_id, std::vector<std::string> &items, + std::vector<std::string> &disabled_items, U32 flags); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const; virtual BOOL dragOrDrop(MASK mask, BOOL drop, @@ -230,18 +230,18 @@ public: LLItemBridge(LLInventoryPanel* inventory, const LLUUID& uuid) : LLInvFVBridge(inventory, uuid) {} - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); virtual void selectItem(); virtual void restoreItem(); virtual LLUIImagePtr getIcon() const; - virtual const LLString& getDisplayName() const; - virtual LLString getLabelSuffix() const; + virtual const std::string& getDisplayName() const; + virtual std::string getLabelSuffix() const; virtual PermissionMask getPermissionMask() const; virtual time_t getCreationDate() const; virtual BOOL isItemRenameable() const; - virtual BOOL renameItem(const LLString& new_name); + virtual BOOL renameItem(const std::string& new_name); virtual BOOL removeItem(); virtual BOOL isItemCopyable() const; virtual BOOL copyToClipboard() const; @@ -255,8 +255,8 @@ public: protected: virtual BOOL isItemPermissive() const; - static void buildDisplayName(LLInventoryItem* item, LLString& name); - mutable LLString mDisplayName; + static void buildDisplayName(LLInventoryItem* item, std::string& name); + mutable std::string mDisplayName; }; @@ -268,7 +268,7 @@ public: BOOL drop); BOOL dragCategoryIntoFolder(LLInventoryCategory* inv_category, BOOL drop); - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); virtual void openItem(); virtual BOOL isItemRenameable() const; virtual void selectItem(); @@ -276,7 +276,7 @@ public: virtual LLUIImagePtr getIcon() const; - virtual BOOL renameItem(const LLString& new_name); + virtual BOOL renameItem(const std::string& new_name); virtual BOOL removeItem(); virtual BOOL isClipboardPasteable() const; virtual void pasteFromClipboard(); @@ -328,8 +328,8 @@ private: BOOL mCallingCards; BOOL mWearables; LLMenuGL* mMenu; - std::vector<LLString> mItems; - std::vector<LLString> mDisabledItems; + std::vector<std::string> mItems; + std::vector<std::string> mDisabledItems; }; // DEPRECATED @@ -349,7 +349,7 @@ class LLTextureBridge : public LLItemBridge { friend class LLInvFVBridge; public: - virtual const LLString& getPrefix() { return sPrefix; } + virtual const std::string& getPrefix() { return sPrefix; } virtual LLUIImagePtr getIcon() const; virtual void openItem(); @@ -357,7 +357,7 @@ public: protected: LLTextureBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLInventoryType::EType type) : LLItemBridge(inventory, uuid), mInvType(type) {} - static LLString sPrefix; + static std::string sPrefix; LLInventoryType::EType mInvType; }; @@ -365,7 +365,7 @@ class LLSoundBridge : public LLItemBridge { friend class LLInvFVBridge; public: - virtual const LLString& getPrefix() { return sPrefix; } + virtual const std::string& getPrefix() { return sPrefix; } virtual LLUIImagePtr getIcon() const; virtual void openItem(); @@ -376,16 +376,16 @@ public: protected: LLSoundBridge(LLInventoryPanel* inventory, const LLUUID& uuid) : LLItemBridge(inventory, uuid) {} - static LLString sPrefix; + static std::string sPrefix; }; class LLLandmarkBridge : public LLItemBridge { friend class LLInvFVBridge; public: - static const LLString& prefix() { return sPrefix; } - virtual const LLString& getPrefix() { return sPrefix; } - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); + static const std::string& prefix() { return sPrefix; } + virtual const std::string& getPrefix() { return sPrefix; } + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual LLUIImagePtr getIcon() const; virtual void openItem(); @@ -402,7 +402,7 @@ protected: } protected: - static LLString sPrefix; + static std::string sPrefix; BOOL mVisited; }; @@ -423,15 +423,15 @@ class LLCallingCardBridge : public LLItemBridge { friend class LLInvFVBridge; public: - virtual const LLString& getPrefix() { return sPrefix; } + virtual const std::string& getPrefix() { return sPrefix; } - virtual LLString getLabelSuffix() const; - //virtual const LLString& getDisplayName() const; + virtual std::string getLabelSuffix() const; + //virtual const std::string& getDisplayName() const; virtual LLUIImagePtr getIcon() const; - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); virtual void openItem(); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); - //virtual void renameItem(const LLString& new_name); + //virtual void renameItem(const std::string& new_name); //virtual BOOL removeItem(); virtual BOOL dragOrDrop(MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -443,7 +443,7 @@ protected: ~LLCallingCardBridge(); protected: - static LLString sPrefix; + static std::string sPrefix; LLCallingCardObserver* mObserver; }; @@ -452,7 +452,7 @@ class LLNotecardBridge : public LLItemBridge { friend class LLInvFVBridge; public: - virtual const LLString& getPrefix() { return sPrefix; } + virtual const std::string& getPrefix() { return sPrefix; } virtual LLUIImagePtr getIcon() const; virtual void openItem(); @@ -462,23 +462,23 @@ protected: LLItemBridge(inventory, uuid) {} protected: - static LLString sPrefix; + static std::string sPrefix; }; class LLGestureBridge : public LLItemBridge { friend class LLInvFVBridge; public: - virtual const LLString& getPrefix() { return sPrefix; } + virtual const std::string& getPrefix() { return sPrefix; } virtual LLUIImagePtr getIcon() const; // Only suffix for gesture items, not task items, because only // gestures in your inventory can be active. virtual LLFontGL::StyleFlags getLabelStyle() const; - virtual LLString getLabelSuffix() const; + virtual std::string getLabelSuffix() const; - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); virtual void openItem(); virtual BOOL removeItem(); @@ -489,7 +489,7 @@ protected: : LLItemBridge(inventory, uuid) {} protected: - static LLString sPrefix; + static std::string sPrefix; }; @@ -497,8 +497,8 @@ class LLAnimationBridge : public LLItemBridge { friend class LLInvFVBridge; public: - virtual const LLString& getPrefix() { return sPrefix; } - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); + virtual const std::string& getPrefix() { return sPrefix; } + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual LLUIImagePtr getIcon() const; @@ -509,7 +509,7 @@ protected: LLItemBridge(inventory, uuid) {} protected: - static LLString sPrefix; + static std::string sPrefix; }; @@ -517,16 +517,16 @@ class LLObjectBridge : public LLItemBridge { friend class LLInvFVBridge; public: - virtual const LLString& getPrefix() { return sPrefix; } + virtual const std::string& getPrefix() { return sPrefix; } virtual LLUIImagePtr getIcon() const; - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); virtual void openItem(); virtual LLFontGL::StyleFlags getLabelStyle() const; - virtual LLString getLabelSuffix() const; + virtual std::string getLabelSuffix() const; virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual BOOL isItemRemovable(); - virtual BOOL renameItem(const LLString& new_name); + virtual BOOL renameItem(const std::string& new_name); protected: LLObjectBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLInventoryType::EType type, U32 flags) : @@ -538,7 +538,7 @@ protected: } protected: - static LLString sPrefix; + static std::string sPrefix; static LLUUID sContextMenuItemID; // Only valid while the context menu is open. LLInventoryType::EType mInvType; U32 mAttachPt; @@ -550,7 +550,7 @@ class LLLSLTextBridge : public LLItemBridge { friend class LLInvFVBridge; public: - virtual const LLString& getPrefix() { return sPrefix; } + virtual const std::string& getPrefix() { return sPrefix; } virtual LLUIImagePtr getIcon() const; virtual void openItem(); @@ -560,7 +560,7 @@ protected: LLItemBridge(inventory, uuid) {} protected: - static LLString sPrefix; + static std::string sPrefix; }; @@ -569,13 +569,13 @@ class LLWearableBridge : public LLItemBridge friend class LLInvFVBridge; public: virtual LLUIImagePtr getIcon() const; - virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); + virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); virtual void openItem(); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual LLFontGL::StyleFlags getLabelStyle() const; - virtual LLString getLabelSuffix() const; + virtual std::string getLabelSuffix() const; virtual BOOL isItemRemovable(); - virtual BOOL renameItem(const LLString& new_name); + virtual BOOL renameItem(const std::string& new_name); static void onWearOnAvatar( void* userdata ); // Access to wearOnAvatar() from menu static BOOL canWearOnAvatar( void* userdata ); diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 8cbc55892f..01b2942a37 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -303,7 +303,7 @@ LLUUID LLInventoryModel::findCategoryUUIDForType(LLAssetType::EType t, bool crea LLUUID root_id = gAgent.getInventoryRootID(); if(root_id.notNull()) { - rv = createNewCategory(root_id, t, NULL); + rv = createNewCategory(root_id, t, LLStringUtil::null); } } return rv; @@ -343,7 +343,7 @@ LLUUID LLInventoryModel::findCatUUID(LLAssetType::EType preferred_type) // based on preferred type. Returns the UUID of the new category. LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, LLAssetType::EType preferred_type, - const LLString& pname) + const std::string& pname) { LLUUID id; if(!isInventoryUsable()) @@ -353,7 +353,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, } id.generate(); - LLString name = pname; + std::string name = pname; if(!pname.empty()) { name.assign(pname); @@ -466,13 +466,13 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id, // Generates a string containing the path to the item specified by // item_id. -void LLInventoryModel::appendPath(const LLUUID& id, LLString& path) +void LLInventoryModel::appendPath(const LLUUID& id, std::string& path) { - LLString temp; + std::string temp; LLInventoryObject* obj = getObject(id); LLUUID parent_id; if(obj) parent_id = obj->getParentUUID(); - LLString forward_slash("/"); + std::string forward_slash("/"); while(obj) { obj = getCategory(parent_id); @@ -1509,19 +1509,15 @@ void LLInventoryModel::cache( items, INCLUDE_TRASH, can_cache); - char agent_id_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ - char inventory_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ + std::string agent_id_str; + std::string inventory_filename; agent_id.toString(agent_id_str); std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, agent_id_str)); - snprintf( /* Flawfinder: ignore */ - inventory_filename, - LL_MAX_PATH, - CACHE_FORMAT_STRING, - path.c_str()); + inventory_filename = llformat(CACHE_FORMAT_STRING, path.c_str()); saveToFile(inventory_filename, categories, items); std::string gzip_filename(inventory_filename); gzip_filename.append(".gz"); - if(gzip_file(inventory_filename, gzip_filename.c_str())) + if(gzip_file(inventory_filename, gzip_filename)) { lldebugs << "Successfully compressed " << inventory_filename << llendl; LLFile::remove(inventory_filename); @@ -1759,16 +1755,16 @@ bool LLInventoryModel::loadSkeleton( response_t::const_iterator skel; skel = (*it).find("name"); if(skel == no_response) goto clean_cat; - cat->rename(LLString((*skel).second.c_str())); + cat->rename(std::string((*skel).second)); skel = (*it).find("folder_id"); if(skel == no_response) goto clean_cat; - id.set((*skel).second.c_str()); + id.set((*skel).second); // if an id is null, it locks the viewer. if(id.isNull()) goto clean_cat; cat->setUUID(id); skel = (*it).find("parent_id"); if(skel == no_response) goto clean_cat; - id.set((*skel).second.c_str()); + id.set((*skel).second); cat->setParent(id); skel = (*it).find("type_default"); if(skel == no_response) @@ -1798,25 +1794,21 @@ bool LLInventoryModel::loadSkeleton( { cat_array_t categories; item_array_t items; - char owner_id_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string owner_id_str; owner_id.toString(owner_id_str); std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str)); - char inventory_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ - snprintf( /* Flawfinder: ignore */ - inventory_filename, - LL_MAX_PATH, - CACHE_FORMAT_STRING, - path.c_str()); + std::string inventory_filename; + inventory_filename = llformat(CACHE_FORMAT_STRING, path.c_str()); const S32 NO_VERSION = LLViewerInventoryCategory::VERSION_UNKNOWN; std::string gzip_filename(inventory_filename); gzip_filename.append(".gz"); - LLFILE* fp = LLFile::fopen(gzip_filename.c_str(), "rb"); /*Flawfinder: ignore*/ + LLFILE* fp = LLFile::fopen(gzip_filename, "rb"); bool remove_inventory_file = false; if(fp) { fclose(fp); fp = NULL; - if(gunzip_file(gzip_filename.c_str(), inventory_filename)) + if(gunzip_file(gzip_filename, inventory_filename)) { // we only want to remove the inventory file if it was // gzipped before we loaded, and we successfully @@ -1970,14 +1962,14 @@ bool LLInventoryModel::loadMeat( response_t::const_iterator meat; meat = (*it).find("name"); if(meat == no_response) goto clean_item; - item->rename(LLString((*meat).second.c_str())); + item->rename(std::string((*meat).second)); meat = (*it).find("item_id"); if(meat == no_response) goto clean_item; - id.set((*meat).second.c_str()); + id.set((*meat).second); item->setUUID(id); meat = (*it).find("parent_id"); if(meat == no_response) goto clean_item; - id.set((*meat).second.c_str()); + id.set((*meat).second); item->setParent(id); meat = (*it).find("type"); if(meat == no_response) goto clean_item; @@ -1991,7 +1983,7 @@ bool LLInventoryModel::loadMeat( } meat = (*it).find("data_id"); if(meat == no_response) goto clean_item; - id.set((*meat).second.c_str()); + id.set((*meat).second); if(LLAssetType::AT_CALLINGCARD == type) { LLPermissions perm; @@ -2236,16 +2228,16 @@ void LLInventoryModel::buildParentChildMap() struct LLUUIDAndName { LLUUIDAndName() {} - LLUUIDAndName(const LLUUID& id, const LLString& name); + LLUUIDAndName(const LLUUID& id, const std::string& name); bool operator==(const LLUUIDAndName& rhs) const; bool operator<(const LLUUIDAndName& rhs) const; bool operator>(const LLUUIDAndName& rhs) const; LLUUID mID; - LLString mName; + std::string mName; }; -LLUUIDAndName::LLUUIDAndName(const LLUUID& id, const LLString& name) : +LLUUIDAndName::LLUUIDAndName(const LLUUID& id, const std::string& name) : mID(id), mName(name) { } @@ -2333,12 +2325,11 @@ bool LLUUIDAndName::operator>(const LLUUIDAndName& rhs) const //} // static -bool LLInventoryModel::loadFromFile( - const char* filename, - LLInventoryModel::cat_array_t& categories, - LLInventoryModel::item_array_t& items) +bool LLInventoryModel::loadFromFile(const std::string& filename, + LLInventoryModel::cat_array_t& categories, + LLInventoryModel::item_array_t& items) { - if(!filename) + if(filename.empty()) { llerrs << "Filename is Null!" << llendl; return false; @@ -2406,12 +2397,11 @@ bool LLInventoryModel::loadFromFile( } // static -bool LLInventoryModel::saveToFile( - const char* filename, - const cat_array_t& categories, - const item_array_t& items) +bool LLInventoryModel::saveToFile(const std::string& filename, + const cat_array_t& categories, + const item_array_t& items) { - if(!filename) + if(filename.empty()) { llerrs << "Filename is Null!" << llendl; return false; @@ -2986,7 +2976,7 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**) LLUUID item_id; LLUUID folder_id; - char new_name[MAX_STRING]; /*Flawfinder: ignore*/ + std::string new_name; bool anything_changed = false; S32 count = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); for(S32 i = 0; i < count; ++i) @@ -2997,7 +2987,7 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**) { LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); msg->getUUIDFast(_PREHASH_InventoryData, _PREHASH_FolderID, folder_id, i); - msg->getString("InventoryData", "NewName", MAX_STRING, new_name, i); + msg->getString("InventoryData", "NewName", new_name, i); lldebugs << "moving item " << item_id << " to folder " << folder_id << llendl; @@ -3009,7 +2999,7 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**) gInventory.accountForUpdate(update); new_item->setParent(folder_id); - if(strlen(new_name) > 0) /*Flawfinder: ignore*/ + if (new_name.length() > 0) { new_item->rename(new_name); } @@ -3199,7 +3189,7 @@ bool LLNameCategoryCollector::operator()( { if(cat) { - if (!LLString::compareInsensitive(mName.c_str(), cat->getName().c_str())) + if (!LLStringUtil::compareInsensitive(mName, cat->getName())) { return true; } @@ -3593,11 +3583,14 @@ void LLInventoryAddedObserver::changed(U32 mask) // the network, figure out which item was updated. // Code from Gigs Taggert, sin allowed by JC. LLMessageSystem* msg = gMessageSystem; - const char* msg_name = msg->getMessageName(); - if (!msg_name) return; - + std::string msg_name = msg->getMessageName(); + if (msg_name.empty()) + { + return; + } + // We only want newly created inventory items. JC - if ( strcmp(msg_name, "UpdateCreateInventoryItem") ) + if ( msg_name != "UpdateCreateInventoryItem") { return; } diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 6ec2af5d7b..8d554e2673 100644 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -292,7 +292,7 @@ public: // Generates a string containing the path to the item specified by // item_id. - void appendPath(const LLUUID& id, LLString& path); + void appendPath(const LLUUID& id, std::string& path); // message handling functionality static void registerCallbacks(LLMessageSystem* msg); @@ -305,7 +305,7 @@ public: // pass in a NULL to the 'name parameter. LLUUID createNewCategory(const LLUUID& parent_id, LLAssetType::EType preferred_type, - const LLString& name); + const std::string& name); // methods to load up inventory skeleton & meat. These are used // during authentication. return true if everything parsed. @@ -392,14 +392,12 @@ protected: //void recalculateCloneInformation(); // file import/export. - static bool loadFromFile( - const char* filename, - cat_array_t& categories, - item_array_t& items); - static bool saveToFile( - const char* filename, - const cat_array_t& categories, - const item_array_t& items); + static bool loadFromFile(const std::string& filename, + cat_array_t& categories, + item_array_t& items); + static bool saveToFile(const std::string& filename, + const cat_array_t& categories, + const item_array_t& items); // message handling functionality //static void processUseCachedInventory(LLMessageSystem* msg, void**); @@ -645,7 +643,7 @@ protected: class LLNameCategoryCollector : public LLInventoryCollectFunctor { public: - LLNameCategoryCollector(const char* name) : mName(name) {} + LLNameCategoryCollector(const std::string& name) : mName(name) {} virtual ~LLNameCategoryCollector() {} virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item); diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 8a685d5479..994bf39300 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -59,13 +59,13 @@ const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed // Public Methods // LLJoystick::LLJoystick( - const LLString& name, + const std::string& name, LLRect rect, - const LLString &default_image, - const LLString &selected_image, + const std::string &default_image, + const std::string &selected_image, EJoystickQuadrant initial_quadrant ) : - LLButton(name, rect, default_image, selected_image, NULL, NULL), + LLButton(name, rect, default_image, selected_image, LLStringUtil::null, NULL, NULL), mInitialQuadrant(initial_quadrant), mInitialOffset(0, 0), mLastMouse(0, 0), @@ -196,27 +196,27 @@ EJoystickQuadrant LLJoystick::selectQuadrant(LLXMLNodePtr node) if (node->hasAttribute("quadrant")) { - LLString quadrant_name; + std::string quadrant_name; node->getAttributeString("quadrant", quadrant_name); - quadrant = quadrantFromName(quadrant_name.c_str()); + quadrant = quadrantFromName(quadrant_name); } return quadrant; } -LLString LLJoystick::nameFromQuadrant(EJoystickQuadrant quadrant) +std::string LLJoystick::nameFromQuadrant(EJoystickQuadrant quadrant) { - if (quadrant == JQ_ORIGIN) return LLString("origin"); - else if (quadrant == JQ_UP) return LLString("up"); - else if (quadrant == JQ_DOWN) return LLString("down"); - else if (quadrant == JQ_LEFT) return LLString("left"); - else if (quadrant == JQ_RIGHT) return LLString("right"); - else return LLString(); + if (quadrant == JQ_ORIGIN) return std::string("origin"); + else if (quadrant == JQ_UP) return std::string("up"); + else if (quadrant == JQ_DOWN) return std::string("down"); + else if (quadrant == JQ_LEFT) return std::string("left"); + else if (quadrant == JQ_RIGHT) return std::string("right"); + else return std::string(); } -EJoystickQuadrant LLJoystick::quadrantFromName(const LLString& sQuadrant) +EJoystickQuadrant LLJoystick::quadrantFromName(const std::string& sQuadrant) { EJoystickQuadrant quadrant = JQ_RIGHT; @@ -252,8 +252,8 @@ LLXMLNodePtr LLJoystick::getXML(bool save_children) const node->createChild("halign", TRUE)->setStringValue(LLFontGL::nameFromHAlign(getHAlign())); node->createChild("quadrant", TRUE)->setStringValue(nameFromQuadrant(mInitialQuadrant)); - addImageAttributeToXML(node,getImageUnselectedName(),getImageUnselectedID(),"image_unselected"); - addImageAttributeToXML(node,getImageSelectedName(),getImageSelectedID(),"image_selected"); + addImageAttributeToXML(node,getImageUnselectedName(),getImageUnselectedID(),std::string("image_unselected")); + addImageAttributeToXML(node,getImageSelectedName(),getImageSelectedID(),std::string("image_selected")); node->createChild("scale_image", TRUE)->setBoolValue(getScaleImage()); @@ -328,13 +328,13 @@ void LLJoystickAgentTurn::onHeldDown() LLView* LLJoystickAgentTurn::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("button"); + std::string name("button"); node->getAttributeString("name", name); - LLString image_unselected; + std::string image_unselected; if (node->hasAttribute("image_unselected")) node->getAttributeString("image_unselected",image_unselected); - LLString image_selected; + std::string image_selected; if (node->hasAttribute("image_selected")) node->getAttributeString("image_selected",image_selected); EJoystickQuadrant quad = JQ_ORIGIN; @@ -437,13 +437,13 @@ void LLJoystickAgentSlide::onHeldDown() // static LLView* LLJoystickAgentSlide::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("button"); + std::string name("button"); node->getAttributeString("name", name); - LLString image_unselected; + std::string image_unselected; if (node->hasAttribute("image_unselected")) node->getAttributeString("image_unselected",image_unselected); - LLString image_selected; + std::string image_selected; if (node->hasAttribute("image_selected")) node->getAttributeString("image_selected",image_selected); @@ -479,7 +479,7 @@ LLView* LLJoystickAgentSlide::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtr // LLJoystickCameraRotate //------------------------------------------------------------------------------- -LLJoystickCameraRotate::LLJoystickCameraRotate(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img) +LLJoystickCameraRotate::LLJoystickCameraRotate(const std::string& name, LLRect rect, const std::string &out_img, const std::string &in_img) : LLJoystick(name, rect, out_img, in_img, JQ_ORIGIN), mInLeft( FALSE ), @@ -716,9 +716,9 @@ void LLJoystickCameraTrack::onHeldDown() // LLJoystickCameraZoom //------------------------------------------------------------------------------- -LLJoystickCameraZoom::LLJoystickCameraZoom(const LLString& name, LLRect rect, const LLString &out_img, const LLString &plus_in_img, const LLString &minus_in_img) +LLJoystickCameraZoom::LLJoystickCameraZoom(const std::string& name, LLRect rect, const std::string &out_img, const std::string &plus_in_img, const std::string &minus_in_img) : - LLJoystick(name, rect, out_img, "", JQ_ORIGIN), + LLJoystick(name, rect, out_img, LLStringUtil::null, JQ_ORIGIN), mInTop( FALSE ), mInBottom( FALSE ) { diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index e2d95e184e..91c660fbf8 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -49,7 +49,7 @@ class LLJoystick : public LLButton { public: - LLJoystick(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial); + LLJoystick(const std::string& name, LLRect rect, const std::string &default_image, const std::string &selected_image, EJoystickQuadrant initial); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -63,8 +63,8 @@ public: void setInitialQuadrant(EJoystickQuadrant initial) { mInitialQuadrant = initial; }; virtual LLXMLNodePtr getXML(bool save_children = true) const; - static LLString nameFromQuadrant(const EJoystickQuadrant quadrant); - static EJoystickQuadrant quadrantFromName(const LLString& name); + static std::string nameFromQuadrant(const EJoystickQuadrant quadrant); + static EJoystickQuadrant quadrantFromName(const std::string& name); static EJoystickQuadrant selectQuadrant(LLXMLNodePtr node); @@ -90,7 +90,7 @@ class LLJoystickAgentTurn : public LLJoystick { public: - LLJoystickAgentTurn(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial) + LLJoystickAgentTurn(const std::string& name, LLRect rect, const std::string &default_image, const std::string &selected_image, EJoystickQuadrant initial) : LLJoystick(name, rect, default_image, selected_image, initial) { } @@ -106,7 +106,7 @@ class LLJoystickAgentSlide : public LLJoystick { public: - LLJoystickAgentSlide(const LLString& name, LLRect rect, const LLString &default_image, const LLString &selected_image, EJoystickQuadrant initial) + LLJoystickAgentSlide(const std::string& name, LLRect rect, const std::string &default_image, const std::string &selected_image, EJoystickQuadrant initial) : LLJoystick(name, rect, default_image, selected_image, initial) { } @@ -122,7 +122,7 @@ class LLJoystickCameraRotate : public LLJoystick { public: - LLJoystickCameraRotate(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img); + LLJoystickCameraRotate(const std::string& name, LLRect rect, const std::string &out_img, const std::string &in_img); virtual void setToggleState( BOOL left, BOOL top, BOOL right, BOOL bottom ); @@ -148,7 +148,7 @@ class LLJoystickCameraTrack : public LLJoystickCameraRotate { public: - LLJoystickCameraTrack(const LLString& name, LLRect rect, const LLString &out_img, const LLString &in_img) + LLJoystickCameraTrack(const std::string& name, LLRect rect, const std::string &out_img, const std::string &in_img) : LLJoystickCameraRotate(name, rect, out_img, in_img) { } @@ -161,7 +161,7 @@ class LLJoystickCameraZoom : public LLJoystick { public: - LLJoystickCameraZoom(const LLString& name, LLRect rect, const LLString &out_img, const LLString &plus_in_img, const LLString &minus_in_img); + LLJoystickCameraZoom(const std::string& name, LLRect rect, const std::string &out_img, const std::string &plus_in_img, const std::string &minus_in_img); virtual void setToggleState( BOOL top, BOOL bottom ); diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 76a4ec99b1..cb7af207d2 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -38,14 +38,14 @@ const S32 LOG_RECALL_SIZE = 2048; //static -LLString LLLogChat::makeLogFileName(LLString filename) +std::string LLLogChat::makeLogFileName(std::string filename) { - filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename.c_str()); + filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename); filename += ".txt"; return filename; } -LLString LLLogChat::timestamp(bool withdate) +std::string LLLogChat::timestamp(bool withdate) { time_t utc_time; utc_time = time_corrected(); @@ -57,7 +57,7 @@ LLString LLLogChat::timestamp(bool withdate) // it's daylight savings time there. timep = utc_to_pacific_time(utc_time, gPacificDaylightTime); - LLString text; + std::string text; if (withdate) text = llformat("[%d/%02d/%02d %d:%02d] ", (timep->tm_year-100)+2000, timep->tm_mon+1, timep->tm_mday, timep->tm_hour, timep->tm_min); else @@ -68,7 +68,7 @@ LLString LLLogChat::timestamp(bool withdate) //static -void LLLogChat::saveHistory(LLString filename, LLString line) +void LLLogChat::saveHistory(std::string filename, std::string line) { if(!filename.size()) { @@ -76,7 +76,7 @@ void LLLogChat::saveHistory(LLString filename, LLString line) return; } - LLFILE* fp = LLFile::fopen(LLLogChat::makeLogFileName(filename).c_str(), "a"); /*Flawfinder: ignore*/ + LLFILE* fp = LLFile::fopen(LLLogChat::makeLogFileName(filename), "a"); /*Flawfinder: ignore*/ if (!fp) { llinfos << "Couldn't open chat history log!" << llendl; @@ -89,19 +89,19 @@ void LLLogChat::saveHistory(LLString filename, LLString line) } } -void LLLogChat::loadHistory(LLString filename , void (*callback)(ELogLineType,LLString,void*), void* userdata) +void LLLogChat::loadHistory(std::string filename , void (*callback)(ELogLineType,std::string,void*), void* userdata) { if(!filename.size()) { llerrs << "Filename is Empty!" << llendl; } - LLFILE* fptr = LLFile::fopen(makeLogFileName(filename).c_str(), "r"); /*Flawfinder: ignore*/ + LLFILE* fptr = LLFile::fopen(makeLogFileName(filename), "r"); /*Flawfinder: ignore*/ if (!fptr) { //LLUIString message = LLFloaterChat::getInstance()->getUIString("IM_logging_string"); //callback(LOG_EMPTY,"IM_logging_string",userdata); - callback(LOG_EMPTY,"",userdata); + callback(LOG_EMPTY,LLStringUtil::null,userdata); return; //No previous conversation with this name. } else @@ -128,14 +128,14 @@ void LLLogChat::loadHistory(LLString filename , void (*callback)(ELogLineType,LL if (!firstline) { - callback(LOG_LINE,buffer,userdata); + callback(LOG_LINE,std::string(buffer),userdata); } else { firstline = FALSE; } } - callback(LOG_END,"",userdata); + callback(LOG_END,LLStringUtil::null,userdata); fclose(fptr); } diff --git a/indra/newview/lllogchat.h b/indra/newview/lllogchat.h index 0fcee48dfc..45279fd6ae 100644 --- a/indra/newview/lllogchat.h +++ b/indra/newview/lllogchat.h @@ -42,11 +42,11 @@ public: LOG_LINE, LOG_END }; - static LLString timestamp(bool withdate = false); - static LLString makeLogFileName(LLString(filename)); - static void saveHistory(LLString filename, LLString line); - static void loadHistory(LLString filename, - void (*callback)(ELogLineType,LLString,void*), + static std::string timestamp(bool withdate = false); + static std::string makeLogFileName(std::string(filename)); + static void saveHistory(std::string filename, std::string line); + static void loadHistory(std::string filename, + void (*callback)(ELogLineType,std::string,void*), void* userdata); }; diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index b6980d0382..5e09e69e2b 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -92,7 +92,7 @@ void LLManip::rebuild(LLViewerObject* vobj) // LLManip -LLManip::LLManip( const LLString& name, LLToolComposite* composite ) +LLManip::LLManip( const std::string& name, LLToolComposite* composite ) : LLTool( name, composite ), mInSnapRegime(FALSE), @@ -422,7 +422,7 @@ void LLManip::renderGuidelines(BOOL draw_x, BOOL draw_y, BOOL draw_z) void LLManip::renderXYZ(const LLVector3 &vec) { const S32 PAD = 10; - char feedback_string[128]; /*Flawfinder: ignore*/ + std::string feedback_string; LLVector3 camera_pos = LLViewerCamera::getInstance()->getOrigin() + LLViewerCamera::getInstance()->getAtAxis(); S32 vertical_offset = gViewerWindow->getWindowHeight() / 2 - VERTICAL_OFFSET; S32 window_center_x = gViewerWindow->getWindowWidth() / 2; @@ -451,30 +451,30 @@ void LLManip::renderXYZ(const LLVector3 &vec) LLLocale locale(LLLocale::USER_LOCALE); LLGLDepthTest gls_depth(GL_FALSE); // render drop shadowed text - snprintf(feedback_string, sizeof(feedback_string), "X: %.3f", vec.mV[VX]); /* Flawfinder: ignore */ + feedback_string = llformat("X: %.3f", vec.mV[VX]); hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -102.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); - snprintf(feedback_string, sizeof(feedback_string), "Y: %.3f", vec.mV[VY]); /* Flawfinder: ignore */ + feedback_string = llformat("Y: %.3f", vec.mV[VY]); hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -27.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); - snprintf(feedback_string, sizeof(feedback_string), "Z: %.3f", vec.mV[VZ]); /* Flawfinder: ignore */ + feedback_string = llformat("Z: %.3f", vec.mV[VZ]); hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, 48.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); // render text on top - snprintf(feedback_string, sizeof(feedback_string), "X: %.3f", vec.mV[VX]); /* Flawfinder: ignore */ + feedback_string = llformat("X: %.3f", vec.mV[VX]); hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -102.f, (F32)vertical_offset, LLColor4(1.f, 0.5f, 0.5f, 1.f), FALSE); glColor3f(0.5f, 1.f, 0.5f); - snprintf(feedback_string, sizeof(feedback_string), "Y: %.3f", vec.mV[VY]); /* Flawfinder: ignore */ + feedback_string = llformat("Y: %.3f", vec.mV[VY]); hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -27.f, (F32)vertical_offset, LLColor4(0.5f, 1.f, 0.5f, 1.f), FALSE); glColor3f(0.5f, 0.5f, 1.f); - snprintf(feedback_string, sizeof(feedback_string), "Z: %.3f", vec.mV[VZ]); /* Flawfinder: ignore */ + feedback_string = llformat("Z: %.3f", vec.mV[VZ]); hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, 48.f, (F32)vertical_offset, LLColor4(0.5f, 0.5f, 1.f, 1.f), FALSE); } } -void LLManip::renderTickText(const LLVector3& pos, const char* text, const LLColor4 &color) +void LLManip::renderTickText(const LLVector3& pos, const std::string& text, const LLColor4 &color) { const LLFontGL* big_fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ); @@ -502,37 +502,37 @@ void LLManip::renderTickText(const LLVector3& pos, const char* text, const LLCol glPopMatrix(); } -void LLManip::renderTickValue(const LLVector3& pos, F32 value, const char* suffix, const LLColor4 &color) +void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string& suffix, const LLColor4 &color) { LLLocale locale(LLLocale::USER_LOCALE); const LLFontGL* big_fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ); const LLFontGL* small_fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); - char val_string[128]; /*Flawfinder: ignore*/ - char fraction_string[128]; /*Flawfinder: ignore*/ + std::string val_string; + std::string fraction_string; F32 val_to_print = llround(value, 0.001f); S32 fractional_portion = llround(fmodf(llabs(val_to_print), 1.f) * 100.f); if (val_to_print < 0.f) { if (fractional_portion == 0) { - snprintf(val_string, sizeof(val_string), "-%d%s", lltrunc(llabs(val_to_print)), suffix); /* Flawfinder: ignore */ + val_string = llformat("-%d%s", lltrunc(llabs(val_to_print)), suffix.c_str()); } else { - snprintf(val_string, sizeof(val_string), "-%d", lltrunc(llabs(val_to_print))); /* Flawfinder: ignore */ + val_string = llformat("-%d", lltrunc(llabs(val_to_print))); } } else { if (fractional_portion == 0) { - snprintf(val_string, sizeof(val_string), "%d%s", lltrunc(llabs(val_to_print)), suffix); /* Flawfinder: ignore */ + val_string = llformat("%d%s", lltrunc(llabs(val_to_print)), suffix.c_str()); } else { - snprintf(val_string, sizeof(val_string), "%d", lltrunc(val_to_print)); /* Flawfinder: ignore */ + val_string = llformat("%d", lltrunc(val_to_print)); } } @@ -554,7 +554,7 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const char* suffi if (fractional_portion != 0) { - snprintf(fraction_string, sizeof(fraction_string), "%c%02d%s", LLResMgr::getInstance()->getDecimalPoint(), fractional_portion, suffix); /* Flawfinder: ignore */ + fraction_string = llformat("%c%02d%s", LLResMgr::getInstance()->getDecimalPoint(), fractional_portion, suffix.c_str()); gViewerWindow->setupViewport(1, -1); hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection); diff --git a/indra/newview/llmanip.h b/indra/newview/llmanip.h index a2ad464f3c..1313f77c5b 100644 --- a/indra/newview/llmanip.h +++ b/indra/newview/llmanip.h @@ -120,7 +120,7 @@ public: public: static void rebuild(LLViewerObject* vobj); - LLManip( const LLString& name, LLToolComposite* composite ); + LLManip( const std::string& name, LLToolComposite* composite ); virtual BOOL handleMouseDownOnPart(S32 x, S32 y, MASK mask) = 0; void renderGuidelines(BOOL draw_x = TRUE, BOOL draw_y = TRUE, BOOL draw_z = TRUE); @@ -143,8 +143,8 @@ protected: void getManipNormal(LLViewerObject* object, EManipPart manip, LLVector3 &normal); BOOL getManipAxis(LLViewerObject* object, EManipPart manip, LLVector3 &axis); F32 getSubdivisionLevel(const LLVector3 &reference_point, const LLVector3 &translate_axis, F32 grid_scale, S32 min_pixel_spacing = MIN_DIVISION_PIXEL_WIDTH); - void renderTickValue(const LLVector3& pos, F32 value, const char* suffix, const LLColor4 &color); - void renderTickText(const LLVector3& pos, const char* suffix, const LLColor4 &color); + void renderTickValue(const LLVector3& pos, F32 value, const std::string& suffix, const LLColor4 &color); + void renderTickText(const LLVector3& pos, const std::string& suffix, const LLColor4 &color); void updateGridSettings(); BOOL getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVector3d origin, LLVector3 normal) const; BOOL getMousePointOnPlaneAgent(LLVector3& point, S32 x, S32 y, LLVector3 origin, LLVector3 normal); diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp index 77e6112e95..e98ded2a87 100644 --- a/indra/newview/llmaniprotate.cpp +++ b/indra/newview/llmaniprotate.cpp @@ -86,7 +86,7 @@ const F32 MANIPULATOR_SCALE_HALF_LIFE = 0.07f; extern void handle_reset_rotation(void*); // in LLViewerWindow LLManipRotate::LLManipRotate( LLToolComposite* composite ) -: LLManip( "Rotate", composite ), +: LLManip( std::string("Rotate"), composite ), mRotationCenter(), mCenterScreen(), mRotation(), @@ -926,6 +926,7 @@ void LLManipRotate::renderSnapGuides() } gGL.end(); + // *TODO: Translate //RN: text rendering does own shadow pass, so only render once if (pass == 1 && render_text && i % 16 == 0) { @@ -933,32 +934,32 @@ void LLManipRotate::renderSnapGuides() { if (i == 0) { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Forward" : "East", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Forward") : std::string("East"), LLColor4::white); } else if (i == 16) { if (constraint_axis.mV[VZ] > 0.f) { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Left" : "North", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Left") : std::string("North"), LLColor4::white); } else { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Right" : "South", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Right") : std::string("South"), LLColor4::white); } } else if (i == 32) { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Back" : "West", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Back") : std::string("West"), LLColor4::white); } else { if (constraint_axis.mV[VZ] > 0.f) { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Right" : "South", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Right") : std::string("South"), LLColor4::white); } else { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Left" : "North", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Left") : std::string("North"), LLColor4::white); } } } @@ -966,32 +967,32 @@ void LLManipRotate::renderSnapGuides() { if (i == 0) { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Left" : "North", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Left") : std::string("North"), LLColor4::white); } else if (i == 16) { if (constraint_axis.mV[VX] > 0.f) { - renderTickText(text_point, "Up", LLColor4::white); + renderTickText(text_point, std::string("Up"), LLColor4::white); } else { - renderTickText(text_point, "Down", LLColor4::white); + renderTickText(text_point, std::string("Down"), LLColor4::white); } } else if (i == 32) { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Right" : "South", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Right") : std::string("South"), LLColor4::white); } else { if (constraint_axis.mV[VX] > 0.f) { - renderTickText(text_point, "Down", LLColor4::white); + renderTickText(text_point, std::string("Down"), LLColor4::white); } else { - renderTickText(text_point, "Up", LLColor4::white); + renderTickText(text_point, std::string("Up"), LLColor4::white); } } } @@ -999,32 +1000,32 @@ void LLManipRotate::renderSnapGuides() { if (i == 0) { - renderTickText(text_point, "Up", LLColor4::white); + renderTickText(text_point, std::string("Up"), LLColor4::white); } else if (i == 16) { if (constraint_axis.mV[VY] > 0.f) { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Forward" : "East", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Forward") : std::string("East"), LLColor4::white); } else { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Back" : "West", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Back") : std::string("West"), LLColor4::white); } } else if (i == 32) { - renderTickText(text_point, "Down", LLColor4::white); + renderTickText(text_point, std::string("Down"), LLColor4::white); } else { if (constraint_axis.mV[VY] > 0.f) { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Back" : "West", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Back") : std::string("West"), LLColor4::white); } else { - renderTickText(text_point, mObjectSelection->isAttachment() ? "Forward" : "East", LLColor4::white); + renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Forward") : std::string("East"), LLColor4::white); } } } diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 3a3a22081a..57c901e9bc 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -175,7 +175,7 @@ void LLManipScale::handleDeselect() LLManipScale::LLManipScale( LLToolComposite* composite ) : - LLManip( "Scale", composite ), + LLManip( std::string("Scale"), composite ), mBoxHandleSize( 1.f ), mScaledBoxHandleSize( 1.f ), mManipPart( LL_NO_PART ), @@ -1751,7 +1751,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) text_highlight = 1.f; } - renderTickValue(text_origin, tick_val, grid_mode == GRID_MODE_WORLD ? "m" : "x", LLColor4(text_highlight, text_highlight, text_highlight, alpha)); + renderTickValue(text_origin, tick_val, grid_mode == GRID_MODE_WORLD ? std::string("m") : std::string("x"), LLColor4(text_highlight, text_highlight, text_highlight, alpha)); } } @@ -1803,7 +1803,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) text_highlight = 1.f; } - renderTickValue(text_origin, tick_val, grid_mode == GRID_MODE_WORLD ? "m" : "x", LLColor4(text_highlight, text_highlight, text_highlight, alpha)); + renderTickValue(text_origin, tick_val, grid_mode == GRID_MODE_WORLD ? std::string("m") : std::string("x"), LLColor4(text_highlight, text_highlight, text_highlight, alpha)); } } } diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index e179e01030..f4f3a535de 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -101,7 +101,7 @@ const U32 ARROW_TO_AXIS[4] = }; LLManipTranslate::LLManipTranslate( LLToolComposite* composite ) -: LLManip( "Move", composite ), +: LLManip( std::string("Move"), composite ), mLastHoverMouseX(-1), mLastHoverMouseY(-1), mSendUpdateOnMouseUp(FALSE), @@ -1412,11 +1412,11 @@ void LLManipTranslate::renderSnapGuides() { // rescale units to meters from multiple of grid scale offset_val *= 2.f * grid_scale[ARROW_TO_AXIS[mManipPart]]; - renderTickValue(text_origin, offset_val, "m", LLColor4(text_highlight, text_highlight, text_highlight, alpha)); + renderTickValue(text_origin, offset_val, std::string("m"), LLColor4(text_highlight, text_highlight, text_highlight, alpha)); } else { - renderTickValue(text_origin, offset_val, "x", LLColor4(text_highlight, text_highlight, text_highlight, alpha)); + renderTickValue(text_origin, offset_val, std::string("x"), LLColor4(text_highlight, text_highlight, text_highlight, alpha)); } } } diff --git a/indra/newview/llmimetypes.cpp b/indra/newview/llmimetypes.cpp index 821f21313c..a7f6d0e9f0 100644 --- a/indra/newview/llmimetypes.cpp +++ b/indra/newview/llmimetypes.cpp @@ -39,17 +39,17 @@ LLMIMETypes::mime_info_map_t LLMIMETypes::sMap; LLMIMETypes::mime_widget_set_map_t LLMIMETypes::sWidgetMap; -LLString sDefaultLabel; +std::string sDefaultLabel; // Returned when we don't know what to do with the mime type -LLString sDefaultWidgetType; +std::string sDefaultWidgetType; // Returned when we don't know what widget set to use -LLString sDefaultImpl; +std::string sDefaultImpl; // Returned when we don't know what impl to use ///////////////////////////////////////////////////////////////////////////// // static -bool LLMIMETypes::parseMIMETypes(const LLString& xml_filename) +bool LLMIMETypes::parseMIMETypes(const std::string& xml_filename) { LLXMLNodePtr root; bool success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); @@ -78,7 +78,7 @@ bool LLMIMETypes::parseMIMETypes(const LLString& xml_filename) } else if (node->hasName("mimetype") || node->hasName("scheme")) { - LLString mime_type; + std::string mime_type; node->getAttributeString("name", mime_type); LLMIMEInfo info; for (LLXMLNode* child = node->getFirstChild(); @@ -102,7 +102,7 @@ bool LLMIMETypes::parseMIMETypes(const LLString& xml_filename) } else if (node->hasName("widgetset")) { - LLString set_name; + std::string set_name; node->getAttributeString("name", set_name); LLMIMEWidgetSet info; for (LLXMLNode* child = node->getFirstChild(); @@ -149,7 +149,7 @@ bool LLMIMETypes::parseMIMETypes(const LLString& xml_filename) } // static -LLString LLMIMETypes::translate(const LLString& mime_type) +std::string LLMIMETypes::translate(const std::string& mime_type) { mime_info_map_t::const_iterator it = sMap.find(mime_type); if (it != sMap.end()) @@ -163,7 +163,7 @@ LLString LLMIMETypes::translate(const LLString& mime_type) } // static -LLString LLMIMETypes::widgetType(const LLString& mime_type) +std::string LLMIMETypes::widgetType(const std::string& mime_type) { mime_info_map_t::const_iterator it = sMap.find(mime_type); if (it != sMap.end()) @@ -177,7 +177,7 @@ LLString LLMIMETypes::widgetType(const LLString& mime_type) } // static -LLString LLMIMETypes::implType(const LLString& mime_type) +std::string LLMIMETypes::implType(const std::string& mime_type) { mime_info_map_t::const_iterator it = sMap.find(mime_type); if (it != sMap.end()) @@ -191,10 +191,10 @@ LLString LLMIMETypes::implType(const LLString& mime_type) } // static -LLString LLMIMETypes::findIcon(const LLString& mime_type) +std::string LLMIMETypes::findIcon(const std::string& mime_type) { - LLString icon = ""; - LLString widget_type = LLMIMETypes::widgetType(mime_type); + std::string icon = ""; + std::string widget_type = LLMIMETypes::widgetType(mime_type); mime_widget_set_map_t::iterator it = sWidgetMap.find(widget_type); if(it != sWidgetMap.end()) { @@ -204,9 +204,9 @@ LLString LLMIMETypes::findIcon(const LLString& mime_type) } // static -LLString LLMIMETypes::findDefaultMimeType(const LLString& widget_type) +std::string LLMIMETypes::findDefaultMimeType(const std::string& widget_type) { - LLString mime_type = "none/none"; + std::string mime_type = "none/none"; mime_widget_set_map_t::iterator it = sWidgetMap.find(widget_type); if(it != sWidgetMap.end()) { @@ -216,10 +216,10 @@ LLString LLMIMETypes::findDefaultMimeType(const LLString& widget_type) } // static -LLString LLMIMETypes::findToolTip(const LLString& mime_type) +std::string LLMIMETypes::findToolTip(const std::string& mime_type) { - LLString tool_tip = ""; - LLString widget_type = LLMIMETypes::widgetType(mime_type); + std::string tool_tip = ""; + std::string widget_type = LLMIMETypes::widgetType(mime_type); mime_widget_set_map_t::iterator it = sWidgetMap.find(widget_type); if(it != sWidgetMap.end()) { @@ -229,10 +229,10 @@ LLString LLMIMETypes::findToolTip(const LLString& mime_type) } // static -LLString LLMIMETypes::findPlayTip(const LLString& mime_type) +std::string LLMIMETypes::findPlayTip(const std::string& mime_type) { - LLString play_tip = ""; - LLString widget_type = LLMIMETypes::widgetType(mime_type); + std::string play_tip = ""; + std::string widget_type = LLMIMETypes::widgetType(mime_type); mime_widget_set_map_t::iterator it = sWidgetMap.find(widget_type); if(it != sWidgetMap.end()) { @@ -242,10 +242,10 @@ LLString LLMIMETypes::findPlayTip(const LLString& mime_type) } // static -bool LLMIMETypes::findAllowResize(const LLString& mime_type) +bool LLMIMETypes::findAllowResize(const std::string& mime_type) { bool allow_resize = false; - LLString widget_type = LLMIMETypes::widgetType(mime_type); + std::string widget_type = LLMIMETypes::widgetType(mime_type); mime_widget_set_map_t::iterator it = sWidgetMap.find(widget_type); if(it != sWidgetMap.end()) { @@ -255,10 +255,10 @@ bool LLMIMETypes::findAllowResize(const LLString& mime_type) } // static -bool LLMIMETypes::findAllowLooping(const LLString& mime_type) +bool LLMIMETypes::findAllowLooping(const std::string& mime_type) { bool allow_looping = false; - LLString widget_type = LLMIMETypes::widgetType(mime_type); + std::string widget_type = LLMIMETypes::widgetType(mime_type); mime_widget_set_map_t::iterator it = sWidgetMap.find(widget_type); if(it != sWidgetMap.end()) { diff --git a/indra/newview/llmimetypes.h b/indra/newview/llmimetypes.h index 61359e1933..dcdd347499 100644 --- a/indra/newview/llmimetypes.h +++ b/indra/newview/llmimetypes.h @@ -33,71 +33,71 @@ #ifndef LLMIMETYPES_H #define LLMIMETYPES_H -#include "llstring.h" // because XML parsing lib uses LLString, ugh +#include <string> #include <map> class LLMIMETypes { public: - static bool parseMIMETypes(const LLString& xml_file_path); + static bool parseMIMETypes(const std::string& xml_file_path); // Loads the MIME string definition XML file, usually // from the application skins directory - static LLString translate(const LLString& mime_type); + static std::string translate(const std::string& mime_type); // Returns "QuickTime Movie" from "video/quicktime" - static LLString widgetType(const LLString& mime_type); + static std::string widgetType(const std::string& mime_type); // Type of control widgets for this MIME type // Returns "movie" from "video/quicktime" - static LLString implType(const LLString& mime_type); + static std::string implType(const std::string& mime_type); // Type of Impl to use for decoding media. - static LLString findIcon(const LLString& mime_type); + static std::string findIcon(const std::string& mime_type); // Icon from control widget type for this MIME type - static LLString findToolTip(const LLString& mime_type); + static std::string findToolTip(const std::string& mime_type); // Tool tip from control widget type for this MIME type - static LLString findPlayTip(const LLString& mime_type); + static std::string findPlayTip(const std::string& mime_type); // Play button tool tip from control widget type for this MIME type - static LLString findDefaultMimeType(const LLString& widget_type); + static std::string findDefaultMimeType(const std::string& widget_type); // Canonical mime type associated with this widget set - static bool findAllowResize(const LLString& mime_type); + static bool findAllowResize(const std::string& mime_type); // accessor for flag to enable/disable media size edit fields - static bool findAllowLooping(const LLString& mime_type); + static bool findAllowLooping(const std::string& mime_type); // accessor for flag to enable/disable media looping checkbox public: struct LLMIMEInfo { - LLString mLabel; + std::string mLabel; // friendly label like "QuickTime Movie" - LLString mWidgetType; + std::string mWidgetType; // "web" means use web media UI widgets - LLString mImpl; + std::string mImpl; // which impl to use with this mime type }; struct LLMIMEWidgetSet { - LLString mLabel; + std::string mLabel; // friendly label like "QuickTime Movie" - LLString mIcon; + std::string mIcon; // Name of icon asset to display in toolbar - LLString mDefaultMimeType; + std::string mDefaultMimeType; // Mime type string to use in absence of a specific one - LLString mToolTip; + std::string mToolTip; // custom tool tip for this mime type - LLString mPlayTip; + std::string mPlayTip; // custom tool tip to display for Play button bool mAllowResize; @@ -106,8 +106,8 @@ public: bool mAllowLooping; // enable/disable media looping checkbox }; - typedef std::map< LLString, LLMIMEInfo > mime_info_map_t; - typedef std::map< LLString, LLMIMEWidgetSet > mime_widget_set_map_t; + typedef std::map< std::string, LLMIMEInfo > mime_info_map_t; + typedef std::map< std::string, LLMIMEWidgetSet > mime_widget_set_map_t; // Public so users can iterate over it static mime_info_map_t sMap; diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp index 4819d5bd10..58401a804a 100644 --- a/indra/newview/llmoveview.cpp +++ b/indra/newview/llmoveview.cpp @@ -58,7 +58,7 @@ const F32 NUDGE_TIME = 0.25f; // in seconds // protected LLFloaterMove::LLFloaterMove(const LLSD& key) -: LLFloater("move floater") +: LLFloater(std::string("move floater")) { setIsChrome(TRUE); diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index e9a5648b7b..e2b5c821ae 100644 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -100,9 +100,9 @@ const char AGENT_SUFFIX[] = " (resident)"; const char OBJECT_SUFFIX[] = " (object)"; const char GROUP_SUFFIX[] = " (group)"; -LLString LLMute::getDisplayName() const +std::string LLMute::getDisplayName() const { - LLString name_with_suffix = mName; + std::string name_with_suffix = mName; switch (mType) { case BY_NAME: @@ -122,7 +122,7 @@ LLString LLMute::getDisplayName() const return name_with_suffix; } -void LLMute::setFromDisplayName(const LLString& display_name) +void LLMute::setFromDisplayName(const std::string& display_name) { size_t pos = 0; mName = display_name; @@ -192,7 +192,7 @@ LLMuteList::LLMuteList() : LLSD settings_llsd; llifstream file; - file.open(filename.c_str()); + file.open(filename); if (file.is_open()) { LLSDSerialize::fromXML(settings_llsd, file); @@ -219,11 +219,11 @@ LLMuteList::~LLMuteList() } llofstream file; - file.open(filename.c_str()); + file.open(filename); LLSDSerialize::toPrettyXML(settings_llsd, file); } -BOOL LLMuteList::isLinden(const LLString& name) const +BOOL LLMuteList::isLinden(const std::string& name) const { typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep(" "); @@ -234,7 +234,7 @@ BOOL LLMuteList::isLinden(const LLString& name) const token_iter++; if (token_iter == tokens.end()) return FALSE; - LLString last_name = *token_iter; + std::string last_name = *token_iter; return last_name == "Linden"; } @@ -443,7 +443,7 @@ void LLMuteList::updateRemove(const LLMute& mute) gAgent.sendReliableMessage(); } -void notify_automute_callback(const LLUUID& agent_id, const char* first_name, const char* last_name, BOOL is_group, void* user_data) +void notify_automute_callback(const LLUUID& agent_id, const std::string& first_name, const std::string& last_name, BOOL is_group, void* user_data) { U32 temp_data = (U32) (uintptr_t) user_data; LLMuteList::EAutoReason reason = (LLMuteList::EAutoReason)temp_data; @@ -480,20 +480,19 @@ void notify_automute_callback(const LLUUID& agent_id, const char* first_name, co } -BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason, const LLString& first_name, const LLString& last_name) +BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason, const std::string& first_name, const std::string& last_name) { BOOL removed = FALSE; if (isMuted(agent_id)) { - LLMute automute(agent_id, "", LLMute::AGENT); + LLMute automute(agent_id, LLStringUtil::null, LLMute::AGENT); removed = TRUE; remove(automute); if (first_name.empty() && last_name.empty()) { - char cache_first[DB_FIRST_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - char cache_last[DB_LAST_NAME_BUF_SIZE]; /* Flawfinder: ignore */ + std::string cache_first, cache_last; if (gCacheName->getName(agent_id, cache_first, cache_last)) { // name in cache, call callback directly @@ -508,7 +507,7 @@ BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason, co else { // call callback directly - notify_automute_callback(agent_id, first_name.c_str(), last_name.c_str(), FALSE, (void *)reason); + notify_automute_callback(agent_id, first_name, last_name, FALSE, (void *)reason); } } @@ -542,7 +541,7 @@ std::vector<LLMute> LLMuteList::getMutes() const //----------------------------------------------------------------------------- // loadFromFile() //----------------------------------------------------------------------------- -BOOL LLMuteList::loadFromFile(const LLString& filename) +BOOL LLMuteList::loadFromFile(const std::string& filename) { if(!filename.size()) { @@ -550,7 +549,7 @@ BOOL LLMuteList::loadFromFile(const LLString& filename) return FALSE; } - LLFILE* fp = LLFile::fopen(filename.c_str(), "rb"); /*Flawfinder: ignore*/ + LLFILE* fp = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ if (!fp) { llwarns << "Couldn't open mute list " << filename << llendl; @@ -573,7 +572,7 @@ BOOL LLMuteList::loadFromFile(const LLString& filename) buffer, " %d %254s %254[^|]| %u\n", &type, id_buffer, name_buffer, &flags); LLUUID id = LLUUID(id_buffer); - LLMute mute(id, name_buffer, (LLMute::EType)type, flags); + LLMute mute(id, std::string(name_buffer), (LLMute::EType)type, flags); if (mute.mID.isNull() || mute.mType == LLMute::BY_NAME) { @@ -592,7 +591,7 @@ BOOL LLMuteList::loadFromFile(const LLString& filename) //----------------------------------------------------------------------------- // saveToFile() //----------------------------------------------------------------------------- -BOOL LLMuteList::saveToFile(const LLString& filename) +BOOL LLMuteList::saveToFile(const std::string& filename) { if(!filename.size()) { @@ -600,35 +599,35 @@ BOOL LLMuteList::saveToFile(const LLString& filename) return FALSE; } - LLFILE* fp = LLFile::fopen(filename.c_str(), "wb"); /*Flawfinder: ignore*/ + LLFILE* fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/ if (!fp) { llwarns << "Couldn't open mute list " << filename << llendl; return FALSE; } // legacy mutes have null uuid - char id_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string id_string; LLUUID::null.toString(id_string); for (string_set_t::iterator it = mLegacyMutes.begin(); it != mLegacyMutes.end(); ++it) { - fprintf(fp, "%d %s %s|\n", (S32)LLMute::BY_NAME, id_string, it->c_str()); + fprintf(fp, "%d %s %s|\n", (S32)LLMute::BY_NAME, id_string.c_str(), it->c_str()); } for (mute_set_t::iterator it = mMutes.begin(); it != mMutes.end(); ++it) { it->mID.toString(id_string); - const LLString& name = it->mName; - fprintf(fp, "%d %s %s|%u\n", (S32)it->mType, id_string, name.c_str(), it->mFlags); + const std::string& name = it->mName; + fprintf(fp, "%d %s %s|%u\n", (S32)it->mType, id_string.c_str(), name.c_str(), it->mFlags); } fclose(fp); return TRUE; } -BOOL LLMuteList::isMuted(const LLUUID& id, const LLString& name, U32 flags) const +BOOL LLMuteList::isMuted(const LLUUID& id, const std::string& name, U32 flags) const { LLUUID id_to_check = id; @@ -669,10 +668,10 @@ BOOL LLMuteList::isMuted(const LLUUID& id, const LLString& name, U32 flags) cons //----------------------------------------------------------------------------- void LLMuteList::requestFromServer(const LLUUID& agent_id) { - char agent_id_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ - char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ + std::string agent_id_string; + std::string filename; agent_id.toString(agent_id_string); - snprintf(filename, sizeof(filename), "%s.cached_mute", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string).c_str()); /* Flawfinder: ignore */ + filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string) + ".cached_mute"; LLCRC crc; crc.update(filename); @@ -695,10 +694,10 @@ void LLMuteList::cache(const LLUUID& agent_id) // Write to disk even if empty. if(mIsLoaded) { - char agent_id_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ - char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ + std::string agent_id_string; + std::string filename; agent_id.toString(agent_id_string); - snprintf(filename, sizeof(filename), "%s.cached_mute", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string).c_str()); /* Flawfinder: ignore */ + filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string) + ".cached_mute"; saveToFile(filename); } } @@ -737,12 +736,11 @@ void LLMuteList::processMuteListUpdate(LLMessageSystem* msg, void**) llwarns << "Got an mute list update for the wrong agent." << llendl; return; } - char filename[MAX_STRING]; /*Flawfinder: ignore*/ - filename[0] = '\0'; - msg->getStringFast(_PREHASH_MuteData, _PREHASH_Filename, MAX_STRING, filename); + std::string filename; + msg->getStringFast(_PREHASH_MuteData, _PREHASH_Filename, filename); std::string *local_filename_and_path = new std::string(gDirUtilp->getExpandedFilename( LL_PATH_CACHE, filename )); - gXferManager->requestFile(local_filename_and_path->c_str(), + gXferManager->requestFile(*local_filename_and_path, filename, LL_PATH_CACHE, msg->getSender(), @@ -756,10 +754,10 @@ void LLMuteList::processUseCachedMuteList(LLMessageSystem* msg, void**) { llinfos << "LLMuteList::processUseCachedMuteList()" << llendl; - char agent_id_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string agent_id_string; gAgent.getID().toString(agent_id_string); - char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ - snprintf(filename, sizeof(filename), "%s.cached_mute", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string).c_str()); /* Flawfinder: ignore */ + std::string filename; + filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string) + ".cached_mute"; LLMuteList::getInstance()->loadFromFile(filename); } @@ -767,11 +765,11 @@ void LLMuteList::onFileMuteList(void** user_data, S32 error_code, LLExtStat ext_ { llinfos << "LLMuteList::processMuteListFile()" << llendl; - std::string *local_filename_and_path = (std::string*)user_data; + std::string* local_filename_and_path = (std::string*)user_data; if(local_filename_and_path && !local_filename_and_path->empty() && (error_code == 0)) { - LLMuteList::getInstance()->loadFromFile(local_filename_and_path->c_str()); - LLFile::remove(local_filename_and_path->c_str()); + LLMuteList::getInstance()->loadFromFile(*local_filename_and_path); + LLFile::remove(*local_filename_and_path); } delete local_filename_and_path; } diff --git a/indra/newview/llmutelist.h b/indra/newview/llmutelist.h index 5f2306e0a6..cc6f5c9762 100644 --- a/indra/newview/llmutelist.h +++ b/indra/newview/llmutelist.h @@ -60,21 +60,21 @@ public: flagAll = 0x0000000F // Mask of all currently defined flags }; - LLMute(const LLUUID& id, const LLString& name = LLString(), EType type = BY_NAME, U32 flags = 0) + LLMute(const LLUUID& id, const std::string& name = std::string(), EType type = BY_NAME, U32 flags = 0) : mID(id), mName(name), mType(type),mFlags(flags) { } // Returns name + suffix based on type // For example: "James Tester (resident)" - LLString getDisplayName() const; + std::string getDisplayName() const; // Converts a UI name into just the agent or object name // For example: "James Tester (resident)" sets the name to "James Tester" // and the type to AGENT. - void setFromDisplayName(const LLString& display_name); + void setFromDisplayName(const std::string& display_name); public: LLUUID mID; // agent or object id - LLString mName; // agent or object name + std::string mName; // agent or object name EType mType; // needed for UI display of existing mutes U32 mFlags; // flags pertaining to this mute entry }; @@ -107,15 +107,15 @@ public: // Remove both normal and legacy mutes, for any or all properties. BOOL remove(const LLMute& mute, U32 flags = 0); - BOOL autoRemove(const LLUUID& agent_id, const EAutoReason reason, const LLString& first_name = "", const LLString& last_name = ""); + BOOL autoRemove(const LLUUID& agent_id, const EAutoReason reason, const std::string& first_name = LLStringUtil::null, const std::string& last_name = LLStringUtil::null); // Name is required to test against legacy text-only mutes. - BOOL isMuted(const LLUUID& id, const LLString& name = LLString::null, U32 flags = 0) const; + BOOL isMuted(const LLUUID& id, const std::string& name = LLStringUtil::null, U32 flags = 0) const; // Alternate (convenience) form for places we don't need to pass the name, but do need flags - BOOL isMuted(const LLUUID& id, U32 flags) const { return isMuted(id, LLString::null, flags); }; + BOOL isMuted(const LLUUID& id, U32 flags) const { return isMuted(id, LLStringUtil::null, flags); }; - BOOL isLinden(const LLString& name) const; + BOOL isLinden(const std::string& name) const; BOOL isLoaded() const { return mIsLoaded; } @@ -131,8 +131,8 @@ public: F32 getSavedResidentVolume(const LLUUID& id); private: - BOOL loadFromFile(const LLString& filename); - BOOL saveToFile(const LLString& filename); + BOOL loadFromFile(const std::string& filename); + BOOL saveToFile(const std::string& filename); void setLoaded(); void notifyObservers(); @@ -164,7 +164,7 @@ private: typedef std::set<LLMute, compare_by_id> mute_set_t; mute_set_t mMutes; - typedef std::set<LLString> string_set_t; + typedef std::set<std::string> string_set_t; string_set_t mLegacyMutes; typedef std::set<LLMuteListObserver*> observer_set_t; diff --git a/indra/newview/llnamebox.cpp b/indra/newview/llnamebox.cpp index 17185299a8..9f272dd0c1 100644 --- a/indra/newview/llnamebox.cpp +++ b/indra/newview/llnamebox.cpp @@ -47,7 +47,7 @@ std::set<LLNameBox*> LLNameBox::sInstances; LLNameBox::LLNameBox(const std::string& name, const LLRect& rect, const LLUUID& name_id, BOOL is_group, const LLFontGL* font, BOOL mouse_opaque) -: LLTextBox(name, rect, "(retrieving)", font, mouse_opaque), +: LLTextBox(name, rect, std::string("(retrieving)"), font, mouse_opaque), mNameID(name_id) { LLNameBox::sInstances.insert(this); @@ -57,7 +57,7 @@ LLNameBox::LLNameBox(const std::string& name, const LLRect& rect, const LLUUID& } else { - setText(LLString::null); + setText(LLStringUtil::null); } } @@ -84,26 +84,26 @@ void LLNameBox::setNameID(const LLUUID& name_id, BOOL is_group) setText(name); } -void LLNameBox::refresh(const LLUUID& id, const char* firstname, - const char* lastname, BOOL is_group) +void LLNameBox::refresh(const LLUUID& id, const std::string& firstname, + const std::string& lastname, BOOL is_group) { if (id == mNameID) { - LLString name; - - name.assign(firstname); + std::string name; if (!is_group) { - name.append(1, ' '); - name.append(lastname); + name = firstname + " " + lastname; + } + else + { + name = firstname; } - setText(name); } } -void LLNameBox::refreshAll(const LLUUID& id, const char* firstname, - const char* lastname, BOOL is_group) +void LLNameBox::refreshAll(const LLUUID& id, const std::string& firstname, + const std::string& lastname, BOOL is_group) { std::set<LLNameBox*>::iterator it; for (it = LLNameBox::sInstances.begin(); diff --git a/indra/newview/llnamebox.h b/indra/newview/llnamebox.h index da8df5c225..f45aa8bb2e 100644 --- a/indra/newview/llnamebox.h +++ b/indra/newview/llnamebox.h @@ -51,11 +51,10 @@ public: void setNameID(const LLUUID& name_id, BOOL is_group); - void refresh(const LLUUID& id, const char* first, const char* last, - BOOL is_group); + void refresh(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); - static void refreshAll(const LLUUID& id, const char* firstname, - const char* lastname, BOOL is_group); + static void refreshAll(const LLUUID& id, const std::string& firstname, + const std::string& lastname, BOOL is_group); private: static std::set<LLNameBox*> sInstances; diff --git a/indra/newview/llnameeditor.cpp b/indra/newview/llnameeditor.cpp index 31c9b41f30..ca47e50899 100644 --- a/indra/newview/llnameeditor.cpp +++ b/indra/newview/llnameeditor.cpp @@ -58,7 +58,7 @@ LLNameEditor::LLNameEditor(const std::string& name, const LLRect& rect, void* userdata, LLLinePrevalidateFunc prevalidate_func) : LLLineEditor(name, rect, - "(retrieving)", + std::string("(retrieving)"), glfont, max_text_length, commit_callback, @@ -99,26 +99,26 @@ void LLNameEditor::setNameID(const LLUUID& name_id, BOOL is_group) setText(name); } -void LLNameEditor::refresh(const LLUUID& id, const char* firstname, - const char* lastname, BOOL is_group) +void LLNameEditor::refresh(const LLUUID& id, const std::string& firstname, + const std::string& lastname, BOOL is_group) { if (id == mNameID) { - LLString name; - - name.assign(firstname); + std::string name; if (!is_group) { - name.append(1, ' '); - name.append(lastname); + name = firstname + " " + lastname; + } + else + { + name = firstname; } - setText(name); } } -void LLNameEditor::refreshAll(const LLUUID& id, const char* firstname, - const char* lastname, BOOL is_group) +void LLNameEditor::refreshAll(const LLUUID& id, const std::string& firstname, + const std::string& lastname, BOOL is_group) { std::set<LLNameEditor*>::iterator it; for (it = LLNameEditor::sInstances.begin(); @@ -142,7 +142,7 @@ LLSD LLNameEditor::getValue() const LLView* LLNameEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("name_editor"); + std::string name("name_editor"); node->getAttributeString("name", name); LLRect rect; @@ -162,7 +162,7 @@ LLView* LLNameEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory max_text_length, commit_callback); - LLString label; + std::string label; if(node->getAttributeString("label", label)) { line_editor->setLabel(label); diff --git a/indra/newview/llnameeditor.h b/indra/newview/llnameeditor.h index 70b20fc369..46df7c2a23 100644 --- a/indra/newview/llnameeditor.h +++ b/indra/newview/llnameeditor.h @@ -65,11 +65,10 @@ public: void setNameID(const LLUUID& name_id, BOOL is_group); - void refresh(const LLUUID& id, const char* first, const char* last, - BOOL is_group); + void refresh(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); - static void refreshAll(const LLUUID& id, const char* firstname, - const char* lastname, BOOL is_group); + static void refreshAll(const LLUUID& id, const std::string& firstname, + const std::string& lastname, BOOL is_group); // Take/return agent UUIDs diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp index 6e08eff6ee..dfc327e329 100644 --- a/indra/newview/llnamelistctrl.cpp +++ b/indra/newview/llnamelistctrl.cpp @@ -44,14 +44,14 @@ static LLRegisterWidget<LLNameListCtrl> r("name_list"); // statics std::set<LLNameListCtrl*> LLNameListCtrl::sInstances; -LLNameListCtrl::LLNameListCtrl(const LLString& name, +LLNameListCtrl::LLNameListCtrl(const std::string& name, const LLRect& rect, LLUICtrlCallback cb, void* userdata, BOOL allow_multiple_selection, BOOL draw_border, S32 name_column_index, - const LLString& tooltip) + const std::string& tooltip) : LLScrollListCtrl(name, rect, cb, userdata, allow_multiple_selection, draw_border), mNameColumnIndex(name_column_index), @@ -71,7 +71,7 @@ LLNameListCtrl::~LLNameListCtrl() // public BOOL LLNameListCtrl::addNameItem(const LLUUID& agent_id, EAddPosition pos, - BOOL enabled, LLString& suffix) + BOOL enabled, std::string& suffix) { //llinfos << "LLNameListCtrl::addNameItem " << agent_id << llendl; @@ -91,7 +91,7 @@ BOOL LLNameListCtrl::handleDragAndDrop( BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { if (!mAllowCallingCardDrop) { @@ -153,7 +153,7 @@ void LLNameListCtrl::addGroupNameItem(LLScrollListItem* item, EAddPosition pos) gCacheName->getGroupName(item->getUUID(), group_name); LLScrollListCell* cell = (LLScrollListCell*)item->getColumn(mNameColumnIndex); - ((LLScrollListText*)cell)->setText( LLString(group_name) ); + ((LLScrollListText*)cell)->setText( std::string(group_name) ); addItem(item, pos); } @@ -234,19 +234,20 @@ void LLNameListCtrl::removeNameItem(const LLUUID& agent_id) } // public -void LLNameListCtrl::refresh(const LLUUID& id, const char* first, - const char* last, - BOOL is_group) +void LLNameListCtrl::refresh(const LLUUID& id, const std::string& first, + const std::string& last, BOOL is_group) { //llinfos << "LLNameListCtrl::refresh " << id << " '" << first << " " // << last << "'" << llendl; - LLString fullname; - fullname.assign(first); - if (last[0] && !is_group) + std::string fullname; + if (!is_group) + { + fullname = first + " " + last; + } + else { - fullname.append(1, ' '); - fullname.append(last); + fullname = first; } // TODO: scan items for that ID, fix if necessary @@ -268,9 +269,8 @@ void LLNameListCtrl::refresh(const LLUUID& id, const char* first, // static -void LLNameListCtrl::refreshAll(const LLUUID& id, const char* first, - const char* last, - BOOL is_group) +void LLNameListCtrl::refreshAll(const LLUUID& id, const std::string& first, + const std::string& last, BOOL is_group) { std::set<LLNameListCtrl*>::iterator it; for (it = LLNameListCtrl::sInstances.begin(); @@ -301,7 +301,7 @@ LLXMLNodePtr LLNameListCtrl::getXML(bool save_children) const LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("name_list"); + std::string name("name_list"); node->getAttributeString("name", name); LLRect rect; @@ -355,16 +355,16 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto { if (child->hasName("column")) { - LLString labelname(""); + std::string labelname(""); child->getAttributeString("label", labelname); - LLString columnname(labelname); + std::string columnname(labelname); child->getAttributeString("name", columnname); BOOL columndynamicwidth = FALSE; child->getAttributeBOOL("dynamicwidth", columndynamicwidth); - LLString sortname(columnname); + std::string sortname(columnname); child->getAttributeString("sort", sortname); S32 columnwidth = -1; @@ -415,15 +415,15 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto { if (row_child->hasName("column")) { - LLString value = row_child->getTextContents(); + std::string value = row_child->getTextContents(); - LLString columnname(""); + std::string columnname(""); row_child->getAttributeString("name", columnname); - LLString font(""); + std::string font(""); row_child->getAttributeString("font", font); - LLString font_style(""); + std::string font_style(""); row_child->getAttributeString("font-style", font_style); row["columns"][column_idx]["column"] = columnname; @@ -437,7 +437,7 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto } } - LLString contents = node->getTextContents(); + std::string contents = node->getTextContents(); typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep("\t\n"); @@ -446,7 +446,7 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto while(token_iter != tokens.end()) { - const char* line = token_iter->c_str(); + const std::string& line = *token_iter; name_list->addCommentText(line); ++token_iter; } diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h index c49a163ba8..ebac31469e 100644 --- a/indra/newview/llnamelistctrl.h +++ b/indra/newview/llnamelistctrl.h @@ -41,14 +41,14 @@ class LLNameListCtrl : public LLScrollListCtrl { public: - LLNameListCtrl(const LLString& name, + LLNameListCtrl(const std::string& name, const LLRect& rect, LLUICtrlCallback callback, void* userdata, BOOL allow_multiple_selection, BOOL draw_border = TRUE, S32 name_column_index = 0, - const LLString& tooltip = LLString::null); + const std::string& tooltip = LLStringUtil::null); virtual ~LLNameListCtrl(); virtual LLXMLNodePtr getXML(bool save_children = true) const; @@ -57,7 +57,7 @@ public: // Add a user to the list by name. It will be added, the name // requested from the cache, and updated as necessary. BOOL addNameItem(const LLUUID& agent_id, EAddPosition pos = ADD_BOTTOM, - BOOL enabled = TRUE, LLString& suffix = LLString::null); + BOOL enabled = TRUE, std::string& suffix = LLStringUtil::null); BOOL addNameItem(LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM); virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL); @@ -71,16 +71,15 @@ public: void removeNameItem(const LLUUID& agent_id); - void refresh(const LLUUID& id, const char* first, const char* last, - BOOL is_group); + void refresh(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); - static void refreshAll(const LLUUID& id, const char* firstname, - const char* lastname, BOOL is_group); + static void refreshAll(const LLUUID& id, const std::string& firstname, + const std::string& lastname, BOOL is_group); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg); + std::string& tooltip_msg); void setAllowCallingCardDrop(BOOL b) { mAllowCallingCardDrop = b; } diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index ee184e74b4..3a33f62c38 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -114,52 +114,52 @@ LLNetMap::LLNetMap( //mTextBoxNorth = new LLTextBox( "N", major_dir_rect ); //mTextBoxNorth->setFontStyle(LLFontGL::DROP_SHADOW_SOFT); //addChild( mTextBoxNorth ); - mTextBoxNorth = new LLTextBox( "N", major_dir_rect ); + mTextBoxNorth = new LLTextBox( std::string("N"), major_dir_rect ); mTextBoxNorth->setColor( minor_color ); addChild( mTextBoxNorth ); - mTextBoxEast = new LLTextBox( "E", major_dir_rect ); + mTextBoxEast = new LLTextBox( std::string("E"), major_dir_rect ); mTextBoxEast->setColor( minor_color ); addChild( mTextBoxEast ); major_dir_rect.mRight += 1 ; - mTextBoxWest = new LLTextBox( "W", major_dir_rect ); + mTextBoxWest = new LLTextBox( std::string("W"), major_dir_rect ); mTextBoxWest->setColor( minor_color ); addChild( mTextBoxWest ); major_dir_rect.mRight -= 1 ; - mTextBoxSouth = new LLTextBox( "S", major_dir_rect ); + mTextBoxSouth = new LLTextBox( std::string("S"), major_dir_rect ); mTextBoxSouth->setColor( minor_color ); addChild( mTextBoxSouth ); - mTextBoxSouthEast = new LLTextBox( "SE", minor_dir_rect ); + mTextBoxSouthEast = new LLTextBox( std::string("SE"), minor_dir_rect ); mTextBoxSouthEast->setColor( minor_color ); addChild( mTextBoxSouthEast ); - mTextBoxNorthEast = new LLTextBox( "NE", minor_dir_rect ); + mTextBoxNorthEast = new LLTextBox( std::string("NE"), minor_dir_rect ); mTextBoxNorthEast->setColor( minor_color ); addChild( mTextBoxNorthEast ); - mTextBoxSouthWest = new LLTextBox( "SW", minor_dir_rect ); + mTextBoxSouthWest = new LLTextBox( std::string("SW"), minor_dir_rect ); mTextBoxSouthWest->setColor( minor_color ); addChild( mTextBoxSouthWest ); - mTextBoxNorthWest = new LLTextBox( "NW", minor_dir_rect ); + mTextBoxNorthWest = new LLTextBox( std::string("NW"), minor_dir_rect ); mTextBoxNorthWest->setColor( minor_color ); addChild( mTextBoxNorthWest ); // Right-click menu LLMenuGL* menu; - menu = new LLMenuGL("popup"); + menu = new LLMenuGL(std::string("popup")); menu->setCanTearOff(FALSE); - menu->append(new LLMenuItemCallGL("Zoom Close", handleZoomLevel, + menu->append(new LLMenuItemCallGL(std::string("Zoom Close"), handleZoomLevel, NULL, (void*)2) ); - menu->append(new LLMenuItemCallGL("Zoom Medium", handleZoomLevel, + menu->append(new LLMenuItemCallGL(std::string("Zoom Medium"), handleZoomLevel, NULL, (void*)1) ); - menu->append(new LLMenuItemCallGL("Zoom Far", handleZoomLevel, + menu->append(new LLMenuItemCallGL(std::string("Zoom Far"), handleZoomLevel, NULL, (void*)0) ); menu->appendSeparator(); - menu->append(new LLMenuItemCallGL("Stop Tracking", &LLTracker::stopTracking, + menu->append(new LLMenuItemCallGL(std::string("Stop Tracking"), &LLTracker::stopTracking, &LLTracker::isTracking, NULL) ); menu->setVisible(FALSE); addChild(menu); @@ -580,7 +580,7 @@ BOOL LLNetMap::handleScrollWheel(S32 x, S32 y, S32 clicks) return TRUE; } -BOOL LLNetMap::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen ) +BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen ) { BOOL handled = FALSE; if (gDisconnected) @@ -593,12 +593,12 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect_s msg.assign( region->getName() ); #ifndef LL_RELEASE_FOR_DOWNLOAD - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ + std::string buffer; msg.append("\n"); - region->getHost().getHostName(buffer, MAX_STRING); + buffer = region->getHost().getHostName(); msg.append(buffer); msg.append("\n"); - region->getHost().getString(buffer, MAX_STRING); + buffer = region->getHost().getString(); msg.append(buffer); #endif // *TODO: put this under the control of XUI so it can be diff --git a/indra/newview/llnetmap.h b/indra/newview/llnetmap.h index 5d506c473c..3950a08166 100644 --- a/indra/newview/llnetmap.h +++ b/indra/newview/llnetmap.h @@ -55,7 +55,7 @@ public: virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask ); virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask ); virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); - virtual BOOL handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen ); + virtual BOOL handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen ); void setScale( F32 scale ); void translatePan( F32 delta_x, F32 delta_y ); diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp index 23ba7163c2..483793cfad 100644 --- a/indra/newview/lloverlaybar.cpp +++ b/indra/newview/lloverlaybar.cpp @@ -87,7 +87,7 @@ void* LLOverlayBar::createMediaRemote(void* userdata) void* LLOverlayBar::createVoiceRemote(void* userdata) { LLOverlayBar *self = (LLOverlayBar*)userdata; - self->mVoiceRemote = new LLVoiceRemoteCtrl("voice_remote"); + self->mVoiceRemote = new LLVoiceRemoteCtrl(std::string("voice_remote")); return self->mVoiceRemote; } @@ -379,7 +379,7 @@ void LLOverlayBar::toggleMusicPlay(void*) // stream is stopped, it doesn't return the right thing - commenting out for now. // if ( gAudiop->isInternetStreamPlaying() == 0 ) { - gAudiop->startInternetStream(parcel->getMusicURL().c_str()); + gAudiop->startInternetStream(parcel->getMusicURL()); } } } diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index 94bf17f531..7162f9dc53 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -111,7 +111,7 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); void setAgentID(const LLUUID &agent_id) { mAgentID = agent_id; } protected: LLUUID mAgentID; @@ -138,7 +138,7 @@ BOOL LLDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL handled = FALSE; if(getParent()) @@ -234,7 +234,7 @@ void LLPanelAvatarTab::draw() LLPanel::draw(); } -void LLPanelAvatarTab::sendAvatarProfileRequestIfNeeded(const char* method) +void LLPanelAvatarTab::sendAvatarProfileRequestIfNeeded(const std::string& method) { if (!mDataRequested) { @@ -292,8 +292,8 @@ void LLPanelAvatarSecondLife::clearControls() childSetValue("born", ""); childSetValue("acct", ""); - childSetTextArg("partner_edit", "[FIRST]", LLString::null); - childSetTextArg("partner_edit", "[LAST]", LLString::null); + childSetTextArg("partner_edit", "[FIRST]", LLStringUtil::null); + childSetTextArg("partner_edit", "[LAST]", LLStringUtil::null); mPartnerID = LLUUID::null; @@ -502,7 +502,7 @@ BOOL LLPanelAvatarAdvanced::postBuild() mWantToCount = (8>kArraySize(mWantToCheck))?kArraySize(mWantToCheck):8; for(S32 tt=0; tt < mWantToCount; ++tt) { - LLString ctlname = llformat("chk%d", tt); + std::string ctlname = llformat("chk%d", tt); mWantToCheck[tt] = getChild<LLCheckBoxCtrl>(ctlname); } mSkillsCount = (6>kArraySize(mSkillsCheck))?kArraySize(mSkillsCheck):6; @@ -510,7 +510,7 @@ BOOL LLPanelAvatarAdvanced::postBuild() for(S32 tt=0; tt < mSkillsCount; ++tt) { //Find the Skills checkboxes and save off thier controls - LLString ctlname = llformat("schk%d",tt); + std::string ctlname = llformat("schk%d",tt); mSkillsCheck[tt] = getChild<LLCheckBoxCtrl>(ctlname); } @@ -545,7 +545,7 @@ void LLPanelAvatarWeb::enableControls(BOOL self) { childSetEnabled("url_edit",self); childSetVisible("status_text",!self && !mURL.empty()); - childSetText("status_text", LLString::null); + childSetText("status_text", LLStringUtil::null); } void LLPanelAvatarWeb::setWebURL(std::string url) @@ -780,7 +780,7 @@ void LLPanelAvatarNotes::onCommitNotes(LLUICtrl*, void* userdata) //----------------------------------------------------------------------------- // LLPanelAvatarClassified() //----------------------------------------------------------------------------- -LLPanelAvatarClassified::LLPanelAvatarClassified(const LLString& name, const LLRect& rect, +LLPanelAvatarClassified::LLPanelAvatarClassified(const std::string& name, const LLRect& rect, LLPanelAvatar* panel_avatar) : LLPanelAvatarTab(name, rect, panel_avatar) { @@ -885,7 +885,7 @@ void LLPanelAvatarClassified::processAvatarClassifiedReply(LLMessageSystem* msg, S32 block = 0; S32 block_count = 0; LLUUID classified_id; - char classified_name[DB_PICK_NAME_SIZE]; /*Flawfinder: ignore*/ + std::string classified_name; LLPanelClassified* panel_classified = NULL; LLTabContainer* tabs = getChild<LLTabContainer>("classified tab"); @@ -897,7 +897,7 @@ void LLPanelAvatarClassified::processAvatarClassifiedReply(LLMessageSystem* msg, for (block = 0; block < block_count; block++) { msg->getUUIDFast(_PREHASH_Data, _PREHASH_ClassifiedID, classified_id, block); - msg->getStringFast(_PREHASH_Data, _PREHASH_Name, DB_PICK_NAME_SIZE, classified_name, block); + msg->getStringFast(_PREHASH_Data, _PREHASH_Name, classified_name, block); panel_classified = new LLPanelClassified(false, false); @@ -969,7 +969,7 @@ void LLPanelAvatarClassified::onClickDelete(void* data) } if (!panel_classified) return; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = panel_classified->getClassifiedName(); gViewerWindow->alertXml("DeleteClassified", args, callbackDelete, self); @@ -1054,7 +1054,7 @@ void LLPanelAvatarPicks::processAvatarPicksReply(LLMessageSystem* msg, void**) S32 block = 0; S32 block_count = 0; LLUUID pick_id; - char pick_name[DB_PICK_NAME_SIZE]; /*Flawfinder: ignore*/ + std::string pick_name; LLPanelPick* panel_pick = NULL; LLTabContainer* tabs = getChild<LLTabContainer>("picks tab"); @@ -1070,7 +1070,7 @@ void LLPanelAvatarPicks::processAvatarPicksReply(LLMessageSystem* msg, void**) for (block = 0; block < block_count; block++) { msg->getUUID("Data", "PickID", pick_id, block); - msg->getString("Data", "PickName", DB_PICK_NAME_SIZE, pick_name, block); + msg->getString("Data", "PickName", pick_name, block); panel_pick = new LLPanelPick(FALSE); @@ -1127,7 +1127,7 @@ void LLPanelAvatarPicks::onClickDelete(void* data) if (!panel_pick) return; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[PICK]"] = panel_pick->getPickName(); gViewerWindow->alertXml("DeleteAvatarPick", args, @@ -1275,7 +1275,7 @@ void LLPanelAvatar::setAvatar(LLViewerObject *avatarp) LLNameValue *firstname = avatarp->getNVPair("FirstName"); LLNameValue *lastname = avatarp->getNVPair("LastName"); - LLString name; + std::string name; if (firstname && lastname) { name.assign( firstname->getString() ); @@ -1330,7 +1330,7 @@ void LLPanelAvatar::setOnlineStatus(EOnlineStatus online_status) } } -void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id, const LLString &name, +void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id, const std::string &name, EOnlineStatus online_status) { if (avatar_id.isNull()) return; @@ -1532,7 +1532,7 @@ void LLPanelAvatar::resetGroupList() row["columns"][0]["width"] = 0; group_list->addElement(row); } - group_list->sortByColumn(0, TRUE); + group_list->sortByColumnIndex(0, TRUE); } } } @@ -1742,9 +1742,9 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) LLUUID image_id; LLUUID fl_image_id; LLUUID partner_id; - char about_text[DB_USER_ABOUT_BUF_SIZE]; /*Flawfinder: ignore*/ - char fl_about_text[DB_USER_FL_ABOUT_BUF_SIZE]; /*Flawfinder: ignore*/ - char born_on[DB_BORN_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string about_text; + std::string fl_about_text; + std::string born_on; S32 charter_member_size = 0; BOOL allow_publish = FALSE; //BOOL mature = FALSE; @@ -1752,7 +1752,7 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) BOOL transacted = FALSE; BOOL age_verified = FALSE; BOOL online = FALSE; - char profile_url[DB_USER_PROFILE_URL_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string profile_url; U32 flags = 0x0; @@ -1780,10 +1780,10 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) msg->getUUIDFast( _PREHASH_PropertiesData, _PREHASH_ImageID, image_id ); msg->getUUIDFast( _PREHASH_PropertiesData, _PREHASH_FLImageID, fl_image_id ); msg->getUUIDFast(_PREHASH_PropertiesData, _PREHASH_PartnerID, partner_id); - msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_AboutText, DB_USER_ABOUT_BUF_SIZE, about_text ); - msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_FLAboutText, DB_USER_FL_ABOUT_BUF_SIZE, fl_about_text ); - msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_BornOn, DB_BORN_BUF_SIZE, born_on); - msg->getString("PropertiesData","ProfileURL", DB_USER_PROFILE_URL_BUF_SIZE, profile_url); + msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_AboutText, about_text ); + msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_FLAboutText, fl_about_text ); + msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_BornOn, born_on); + msg->getString("PropertiesData","ProfileURL", profile_url); msg->getU32Fast(_PREHASH_PropertiesData, _PREHASH_Flags, flags); identified = (flags & AVATAR_IDENTIFIED); @@ -1793,7 +1793,7 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) online = (flags & AVATAR_ONLINE); U8 caption_index = 0; - LLString caption_text; + std::string caption_text; charter_member_size = msg->getSize("PropertiesData", "CharterMember"); if(1 == charter_member_size) { @@ -1801,15 +1801,13 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) } else if(1 < charter_member_size) { - char caption[MAX_STRING]; /*Flawfinder: ignore*/ - msg->getString("PropertiesData", "CharterMember", MAX_STRING, caption); - caption_text = caption; + msg->getString("PropertiesData", "CharterMember", caption_text); } if(caption_text.empty()) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; caption_text = self->mPanelSecondLife->getString("CaptionTextAcctInfo"); const char* ACCT_TYPE[] = { @@ -1821,7 +1819,7 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) caption_index = llclamp(caption_index, (U8)0, (U8)(sizeof(ACCT_TYPE)/sizeof(ACCT_TYPE[0])-1)); args["[ACCTTYPE]"] = self->mPanelSecondLife->getString(ACCT_TYPE[caption_index]); - LLString payment_text = " "; + std::string payment_text = " "; const S32 DEFAULT_CAPTION_LINDEN_INDEX = 3; if(caption_index != DEFAULT_CAPTION_LINDEN_INDEX) { @@ -1838,7 +1836,7 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) payment_text = "NoPaymentInfoOnFile"; } args["[PAYMENTINFO]"] = self->mPanelSecondLife->getString(payment_text); - LLString age_text = age_verified ? "AgeVerified" : "NotAgeVerified"; + std::string age_text = age_verified ? "AgeVerified" : "NotAgeVerified"; // Do not display age verification status at this time //args["[AGEVERIFICATION]"] = self->mPanelSecondLife->getString(age_text); args["[AGEVERIFICATION]"] = " "; @@ -1848,7 +1846,7 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) args["[PAYMENTINFO]"] = " "; args["[AGEVERIFICATION]"] = " "; } - LLString::format(caption_text, args); + LLStringUtil::format(caption_text, args); } self->mPanelSecondLife->childSetValue("acct", caption_text); @@ -1858,7 +1856,7 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) self->setOnlineStatus(online_status); - self->mPanelWeb->setWebURL(std::string(profile_url)); + self->mPanelWeb->setWebURL(profile_url); LLTextureCtrl* image_ctrl = self->mPanelSecondLife->getChild<LLTextureCtrl>("img"); if(image_ctrl) @@ -1893,10 +1891,10 @@ void LLPanelAvatar::processAvatarInterestsReply(LLMessageSystem *msg, void**) LLUUID avatar_id; // target of this panel U32 want_to_mask; - char want_to_text[DB_USER_WANT_TO_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string want_to_text; U32 skills_mask; - char skills_text[DB_USER_SKILLS_BUF_SIZE]; /*Flawfinder: ignore*/ - char languages_text[DB_USER_SKILLS_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string skills_text; + std::string languages_text; //llinfos << "properties packet size " << msg->getReceiveSize() << llendl; @@ -1912,10 +1910,10 @@ void LLPanelAvatar::processAvatarInterestsReply(LLMessageSystem *msg, void**) } msg->getU32Fast( _PREHASH_PropertiesData, _PREHASH_WantToMask, want_to_mask ); - msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_WantToText, DB_USER_WANT_TO_BUF_SIZE, want_to_text ); + msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_WantToText, want_to_text ); msg->getU32Fast( _PREHASH_PropertiesData, _PREHASH_SkillsMask, skills_mask ); - msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_SkillsText, DB_USER_SKILLS_BUF_SIZE, skills_text ); - msg->getString(_PREHASH_PropertiesData, "LanguagesText", DB_USER_SKILLS_BUF_SIZE, languages_text ); + msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_SkillsText, skills_text ); + msg->getString(_PREHASH_PropertiesData, "LanguagesText", languages_text ); self->mPanelAdvanced->setWantSkills(want_to_mask, want_to_text, skills_mask, skills_text, languages_text); } @@ -1929,9 +1927,9 @@ void LLPanelAvatar::processAvatarGroupsReply(LLMessageSystem *msg, void**) LLUUID agent_id; // your id LLUUID avatar_id; // target of this panel U64 group_powers; - char group_title[DB_GROUP_TITLE_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string group_title; LLUUID group_id; - char group_name[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ + std::string group_name; LLUUID group_insignia_id; llinfos << "groups packet size " << msg->getReceiveSize() << llendl; @@ -1956,19 +1954,19 @@ void LLPanelAvatar::processAvatarGroupsReply(LLMessageSystem *msg, void**) S32 group_count = msg->getNumberOfBlocksFast(_PREHASH_GroupData); if (0 == group_count) { - if(group_list) group_list->addCommentText("None"); + if(group_list) group_list->addCommentText(std::string("None")); // *TODO: Translate } else { for(S32 i = 0; i < group_count; ++i) { msg->getU64( _PREHASH_GroupData, "GroupPowers", group_powers, i ); - msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupTitle, DB_GROUP_TITLE_BUF_SIZE, group_title, i ); - msg->getUUIDFast( _PREHASH_GroupData, _PREHASH_GroupID, group_id, i); - msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, DB_GROUP_NAME_BUF_SIZE, group_name, i ); + msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupTitle, group_title, i ); + msg->getUUIDFast( _PREHASH_GroupData, _PREHASH_GroupID, group_id, i); + msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, group_name, i ); msg->getUUIDFast( _PREHASH_GroupData, _PREHASH_GroupInsigniaID, group_insignia_id, i ); - LLString group_string; + std::string group_string; if (group_id.notNull()) { group_string.assign(group_name); @@ -1999,7 +1997,7 @@ void LLPanelAvatar::processAvatarGroupsReply(LLMessageSystem *msg, void**) } } } - if(group_list) group_list->sortByColumn(0, TRUE); + if(group_list) group_list->sortByColumnIndex(0, TRUE); } } @@ -2036,7 +2034,7 @@ void LLPanelAvatar::sendAvatarPropertiesUpdate() mPanelAdvanced->getWantSkills(&want_to_mask, want_to_text, &skills_mask, skills_text, languages_text); LLUUID first_life_image_id; - LLString first_life_about_text; + std::string first_life_about_text; if (mPanelFirstLife) { first_life_about_text = mPanelFirstLife->childGetValue("about").asString(); @@ -2047,7 +2045,7 @@ void LLPanelAvatar::sendAvatarPropertiesUpdate() } } - LLString about_text = mPanelSecondLife->childGetValue("about").asString(); + std::string about_text = mPanelSecondLife->childGetValue("about").asString(); LLMessageSystem *msg = gMessageSystem; @@ -2131,8 +2129,8 @@ void LLPanelAvatar::processAvatarNotesReply(LLMessageSystem *msg, void**) continue; } - char text[DB_USER_NOTE_SIZE]; /*Flawfinder: ignore*/ - msg->getString("Data", "Notes", DB_USER_NOTE_SIZE, text); + std::string text; + msg->getString("Data", "Notes", text); self->childSetValue("notes edit", text); self->childSetEnabled("notes edit", true); self->mHaveNotes = true; @@ -2192,13 +2190,13 @@ void LLPanelAvatar::onClickKick(void* userdata) gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect(left, top, left+400, top-300); - gViewerWindow->alertXmlEditText("KickUser", LLString::format_map_t(), + gViewerWindow->alertXmlEditText("KickUser", LLStringUtil::format_map_t(), NULL, NULL, LLPanelAvatar::finishKick, self); } // static -void LLPanelAvatar::finishKick(S32 option, const LLString& text, void* userdata) +void LLPanelAvatar::finishKick(S32 option, const std::string& text, void* userdata) { LLPanelAvatar* self = (LLPanelAvatar*) userdata; @@ -2220,13 +2218,13 @@ void LLPanelAvatar::finishKick(S32 option, const LLString& text, void* userdata) // static void LLPanelAvatar::onClickFreeze(void* userdata) { - gViewerWindow->alertXmlEditText("FreezeUser", LLString::format_map_t(), + gViewerWindow->alertXmlEditText("FreezeUser", LLStringUtil::format_map_t(), NULL, NULL, LLPanelAvatar::finishFreeze, userdata); } // static -void LLPanelAvatar::finishFreeze(S32 option, const LLString& text, void* userdata) +void LLPanelAvatar::finishFreeze(S32 option, const std::string& text, void* userdata) { LLPanelAvatar* self = (LLPanelAvatar*) userdata; @@ -2248,13 +2246,13 @@ void LLPanelAvatar::finishFreeze(S32 option, const LLString& text, void* userdat // static void LLPanelAvatar::onClickUnfreeze(void* userdata) { - gViewerWindow->alertXmlEditText("UnFreezeUser", LLString::format_map_t(), + gViewerWindow->alertXmlEditText("UnFreezeUser", LLStringUtil::format_map_t(), NULL, NULL, LLPanelAvatar::finishUnfreeze, userdata); } // static -void LLPanelAvatar::finishUnfreeze(S32 option, const LLString& text, void* userdata) +void LLPanelAvatar::finishUnfreeze(S32 option, const std::string& text, void* userdata) { LLPanelAvatar* self = (LLPanelAvatar*) userdata; @@ -2282,10 +2280,10 @@ void LLPanelAvatar::onClickCSR(void* userdata) LLNameEditor* name_edit = self->getChild<LLNameEditor>("name"); if (!name_edit) return; - LLString name = name_edit->getText(); + std::string name = name_edit->getText(); if (name.empty()) return; - LLString url = "http://csr.lindenlab.com/agent/"; + std::string url = "http://csr.lindenlab.com/agent/"; // slow and stupid, but it's late S32 len = name.length(); @@ -2308,21 +2306,21 @@ void LLPanelAvatar::onClickCSR(void* userdata) void* LLPanelAvatar::createPanelAvatarSecondLife(void* data) { LLPanelAvatar* self = (LLPanelAvatar*)data; - self->mPanelSecondLife = new LLPanelAvatarSecondLife("2nd Life",LLRect(),self); + self->mPanelSecondLife = new LLPanelAvatarSecondLife(std::string("2nd Life"),LLRect(),self); return self->mPanelSecondLife; } void* LLPanelAvatar::createPanelAvatarWeb(void* data) { LLPanelAvatar* self = (LLPanelAvatar*)data; - self->mPanelWeb = new LLPanelAvatarWeb("Web",LLRect(),self); + self->mPanelWeb = new LLPanelAvatarWeb(std::string("Web"),LLRect(),self); return self->mPanelWeb; } void* LLPanelAvatar::createPanelAvatarInterests(void* data) { LLPanelAvatar* self = (LLPanelAvatar*)data; - self->mPanelAdvanced = new LLPanelAvatarAdvanced("Interests",LLRect(),self); + self->mPanelAdvanced = new LLPanelAvatarAdvanced(std::string("Interests"),LLRect(),self); return self->mPanelAdvanced; } @@ -2330,27 +2328,27 @@ void* LLPanelAvatar::createPanelAvatarInterests(void* data) void* LLPanelAvatar::createPanelAvatarPicks(void* data) { LLPanelAvatar* self = (LLPanelAvatar*)data; - self->mPanelPicks = new LLPanelAvatarPicks("Picks",LLRect(),self); + self->mPanelPicks = new LLPanelAvatarPicks(std::string("Picks"),LLRect(),self); return self->mPanelPicks; } void* LLPanelAvatar::createPanelAvatarClassified(void* data) { LLPanelAvatar* self = (LLPanelAvatar*)data; - self->mPanelClassified = new LLPanelAvatarClassified("Classified",LLRect(),self); + self->mPanelClassified = new LLPanelAvatarClassified(std::string("Classified"),LLRect(),self); return self->mPanelClassified; } void* LLPanelAvatar::createPanelAvatarFirstLife(void* data) { LLPanelAvatar* self = (LLPanelAvatar*)data; - self->mPanelFirstLife = new LLPanelAvatarFirstLife("1st Life", LLRect(), self); + self->mPanelFirstLife = new LLPanelAvatarFirstLife(std::string("1st Life"), LLRect(), self); return self->mPanelFirstLife; } void* LLPanelAvatar::createPanelAvatarNotes(void* data) { LLPanelAvatar* self = (LLPanelAvatar*)data; - self->mPanelNotes = new LLPanelAvatarNotes("My Notes",LLRect(),self); + self->mPanelNotes = new LLPanelAvatarNotes(std::string("My Notes"),LLRect(),self); return self->mPanelNotes; } diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h index a598dfebf5..5aadb5c6d7 100644 --- a/indra/newview/llpanelavatar.h +++ b/indra/newview/llpanelavatar.h @@ -84,7 +84,7 @@ public: // when they are first displayed. // type is one of "avatarnotesrequest", "avatarpicksrequest", // or "avatarclassifiedsrequest" - void sendAvatarProfileRequestIfNeeded(const char* method); + void sendAvatarProfileRequestIfNeeded(const std::string& method); private: LLPanelAvatar* mPanelAvatar; @@ -207,7 +207,7 @@ public: class LLPanelAvatarClassified : public LLPanelAvatarTab { public: - LLPanelAvatarClassified(const LLString& name, const LLRect& rect, LLPanelAvatar* panel_avatar); + LLPanelAvatarClassified(const std::string& name, const LLRect& rect, LLPanelAvatar* panel_avatar); /*virtual*/ BOOL postBuild(void); @@ -279,7 +279,7 @@ public: // Fill in the avatar ID and handle some field fill-in, as well as // button enablement. // Pass one of the ONLINE_STATUS_foo constants above. - void setAvatarID(const LLUUID &avatar_id, const LLString &name, EOnlineStatus online_status); + void setAvatarID(const LLUUID &avatar_id, const std::string &name, EOnlineStatus online_status); void setOnlineStatus(EOnlineStatus online_status); @@ -326,9 +326,9 @@ public: private: void enableOKIfReady(); - static void finishKick(S32 option, const LLString& text, void* userdata); - static void finishFreeze(S32 option, const LLString& text, void* userdata); - static void finishUnfreeze(S32 option, const LLString& text, void* userdata); + static void finishKick(S32 option, const std::string& text, void* userdata); + static void finishFreeze(S32 option, const std::string& text, void* userdata); + static void finishUnfreeze(S32 option, const std::string& text, void* userdata); static void showProfileCallback(S32 option, void *userdata); @@ -374,7 +374,7 @@ private: }; // helper funcs -void add_left_label(LLPanel *panel, const LLString& name, S32 y); +void add_left_label(LLPanel *panel, const std::string& name, S32 y); #endif // LL_LLPANELAVATAR_H diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 7cdde04347..34731f653f 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -148,7 +148,7 @@ LLClassifiedTeleportHandler gClassifiedTeleportHandler; */ LLPanelClassified::LLPanelClassified(bool in_finder, bool from_search) -: LLPanel("Classified Panel"), +: LLPanel(std::string("Classified Panel")), mInFinder(in_finder), mFromSearch(from_search), mDirty(false), @@ -313,7 +313,7 @@ BOOL LLPanelClassified::titleIsValid() { // Disallow leading spaces, punctuation, etc. that screw up // sort order. - const LLString& name = mNameEditor->getText(); + const std::string& name = mNameEditor->getText(); if (name.empty()) { gViewerWindow->alertXml("BlankClassifiedName"); @@ -379,7 +379,7 @@ BOOL LLPanelClassified::canClose() if (mForceClose || !checkDirty()) return TRUE; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = mNameEditor->getText(); LLAlertDialog::showXml("ClassifiedSave", args, saveCallback, this); return FALSE; @@ -576,33 +576,27 @@ void LLPanelClassified::processClassifiedInfoReply(LLMessageSystem *msg, void ** LLUUID parcel_id; msg->getUUIDFast(_PREHASH_Data, _PREHASH_ParcelID, parcel_id); - char name[DB_PARCEL_NAME_SIZE]; /*Flawfinder: ignore*/ - msg->getStringFast(_PREHASH_Data, _PREHASH_Name, DB_PARCEL_NAME_SIZE, name); + std::string name; + msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name); - char desc[DB_PICK_DESC_SIZE]; /*Flawfinder: ignore*/ - msg->getStringFast(_PREHASH_Data, _PREHASH_Desc, DB_PICK_DESC_SIZE, desc); + std::string desc; + msg->getStringFast(_PREHASH_Data, _PREHASH_Desc, desc); LLUUID snapshot_id; msg->getUUIDFast(_PREHASH_Data, _PREHASH_SnapshotID, snapshot_id); // "Location text" is actually the original // name that owner gave the parcel, and the location. - char buffer[256]; /*Flawfinder: ignore*/ - LLString location_text; + std::string location_text; - msg->getStringFast(_PREHASH_Data, _PREHASH_ParcelName, 256, buffer); - if (buffer[0] != '\0') + msg->getStringFast(_PREHASH_Data, _PREHASH_ParcelName, location_text); + if (!location_text.empty()) { - location_text.assign(buffer); location_text.append(", "); } - else - { - location_text.assign(""); - } - char sim_name[256]; /*Flawfinder: ignore*/ - msg->getStringFast(_PREHASH_Data, _PREHASH_SimName, 256, sim_name); + std::string sim_name; + msg->getStringFast(_PREHASH_Data, _PREHASH_SimName, sim_name); LLVector3d pos_global; msg->getVector3dFast(_PREHASH_Data, _PREHASH_PosGlobal, pos_global); @@ -610,8 +604,8 @@ void LLPanelClassified::processClassifiedInfoReply(LLMessageSystem *msg, void ** S32 region_x = llround((F32)pos_global.mdV[VX]) % REGION_WIDTH_UNITS; S32 region_y = llround((F32)pos_global.mdV[VY]) % REGION_WIDTH_UNITS; S32 region_z = llround((F32)pos_global.mdV[VZ]); - - snprintf(buffer, sizeof(buffer), "%s (%d, %d, %d)", sim_name, region_x, region_y, region_z); /* Flawfinder: ignore */ + + std::string buffer = llformat("%s (%d, %d, %d)", sim_name.c_str(), region_x, region_y, region_z); location_text.append(buffer); U8 flags; @@ -654,8 +648,8 @@ void LLPanelClassified::processClassifiedInfoReply(LLMessageSystem *msg, void ** self->mPosGlobal = pos_global; // Update UI controls - self->mNameEditor->setText(LLString(name)); - self->mDescEditor->setText(LLString(desc)); + self->mNameEditor->setText(name); + self->mDescEditor->setText(desc); self->mSnapshotCtrl->setImageAssetID(snapshot_id); self->mLocationEditor->setText(location_text); self->mLocationChanged = false; @@ -674,8 +668,8 @@ void LLPanelClassified::processClassifiedInfoReply(LLMessageSystem *msg, void ** self->mAutoRenewCheck->set(auto_renew); } - LLString datestr = llformat("%02d/%02d/%d", now->tm_mon+1, now->tm_mday, now->tm_year+1900); - LLString::format_map_t string_args; + std::string datestr = llformat("%02d/%02d/%d", now->tm_mon+1, now->tm_mday, now->tm_year+1900); + LLStringUtil::format_map_t string_args; string_args["[DATE]"] = datestr; string_args["[AMT]"] = llformat("%d", price_for_listing); self->childSetText("classified_info_text", self->getString("ad_placed_paid", string_args)); @@ -790,7 +784,7 @@ void LLPanelClassified::onClickUpdate(void* data) // If user has not set mature, do not allow publish if(self->mMatureCombo->getCurrentIndex() == DECLINE_TO_STATE) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; gViewerWindow->alertXml("SetClassifiedMature", &callbackConfirmMature, self); return; } @@ -845,7 +839,7 @@ void LLPanelClassified::gotMature() } // static -void LLPanelClassified::callbackGotPriceForListing(S32 option, LLString text, void* data) +void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text, void* data) { LLPanelClassified* self = (LLPanelClassified*)data; @@ -855,8 +849,8 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, LLString text, vo S32 price_for_listing = strtol(text.c_str(), NULL, 10); if (price_for_listing < MINIMUM_PRICE_FOR_LISTING) { - LLString::format_map_t args; - LLString price_text = llformat("%d", MINIMUM_PRICE_FOR_LISTING); + LLStringUtil::format_map_t args; + std::string price_text = llformat("%d", MINIMUM_PRICE_FOR_LISTING); args["[MIN_PRICE]"] = price_text; gViewerWindow->alertXml("MinClassifiedPrice", args); @@ -867,7 +861,7 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, LLString text, vo // update send self->mPriceForListing = price_for_listing; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d", price_for_listing); gViewerWindow->alertXml("PublishClassified", args, &callbackConfirmPublish, self); @@ -907,7 +901,7 @@ void LLPanelClassified::confirmPublish(S32 option) { // TODO: enable this //LLPanelDirClassifieds* panel = (LLPanelDirClassifieds*)getParent(); - //panel->renameClassified(mClassifiedID, mNameEditor->getText().c_str()); + //panel->renameClassified(mClassifiedID, mNameEditor->getText()); } else { @@ -963,7 +957,7 @@ void LLPanelClassified::onClickProfile(void* data) void LLPanelClassified::onClickLandmark(void* data) { LLPanelClassified* self = (LLPanelClassified*)data; - create_landmark(self->mNameEditor->getText().c_str(), "", self->mPosGlobal); + create_landmark(self->mNameEditor->getText(), "", self->mPosGlobal); } */ @@ -975,7 +969,7 @@ void LLPanelClassified::onClickSet(void* data) // Save location for later. self->mPosGlobal = gAgent.getPositionGlobal(); - LLString location_text; + std::string location_text; location_text.assign("(will update after publish)"); location_text.append(", "); @@ -1029,7 +1023,7 @@ void LLPanelClassified::focusReceived(LLFocusableElement* ctrl, void* data) } -void LLPanelClassified::sendClassifiedClickMessage(const char* type) +void LLPanelClassified::sendClassifiedClickMessage(const std::string& type) { // You're allowed to click on your own ads to reassure yourself // that the system is working. @@ -1049,7 +1043,7 @@ void LLPanelClassified::sendClassifiedClickMessage(const char* type) //////////////////////////////////////////////////////////////////////////////////////////// LLFloaterPriceForListing::LLFloaterPriceForListing() -: LLFloater("PriceForListing"), +: LLFloater(std::string("PriceForListing")), mCallback(NULL), mUserData(NULL) { } @@ -1065,7 +1059,7 @@ BOOL LLFloaterPriceForListing::postBuild() if (edit) { edit->setPrevalidate(LLLineEditor::prevalidateNonNegativeS32); - LLString min_price = llformat("%d", MINIMUM_PRICE_FOR_LISTING); + std::string min_price = llformat("%d", MINIMUM_PRICE_FOR_LISTING); edit->setText(min_price); edit->selectAll(); edit->setFocus(TRUE); @@ -1080,7 +1074,7 @@ BOOL LLFloaterPriceForListing::postBuild() } //static -void LLFloaterPriceForListing::show( void (*callback)(S32, LLString, void*), void* userdata) +void LLFloaterPriceForListing::show( void (*callback)(S32, std::string, void*), void* userdata) { LLFloaterPriceForListing *self = new LLFloaterPriceForListing(); @@ -1111,7 +1105,7 @@ void LLFloaterPriceForListing::buttonCore(S32 button, void* data) if (self->mCallback) { - LLString text = self->childGetText("price_edit"); + std::string text = self->childGetText("price_edit"); self->mCallback(button, text, self->mUserData); self->close(); } diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h index 5552a3b9e1..ee84d89f43 100644 --- a/indra/newview/llpanelclassified.h +++ b/indra/newview/llpanelclassified.h @@ -103,11 +103,11 @@ public: static void callbackConfirmMature(S32 option, void* data); void confirmMature(S32 option); void gotMature(); - static void callbackGotPriceForListing(S32 option, LLString text, void* data); + static void callbackGotPriceForListing(S32 option, std::string text, void* data); static void callbackConfirmPublish(S32 option, void* data); void confirmPublish(S32 option); - void sendClassifiedClickMessage(const char* type); + void sendClassifiedClickMessage(const std::string& type); protected: static void saveCallback(S32 option, void* data); @@ -150,7 +150,7 @@ protected: // yet for this classified? That is, have they saved once? BOOL mPaidFor; - LLString mSimName; + std::string mSimName; LLVector3d mPosGlobal; // Values the user may change @@ -185,7 +185,7 @@ public: virtual ~LLFloaterPriceForListing(); virtual BOOL postBuild(); - static void show( void (*callback)(S32 option, LLString value, void* userdata), void* userdata ); + static void show( void (*callback)(S32 option, std::string value, void* userdata), void* userdata ); private: static void onClickSetPrice(void*); @@ -193,7 +193,7 @@ private: static void buttonCore(S32 button, void* data); private: - void (*mCallback)(S32 option, LLString, void*); + void (*mCallback)(S32 option, std::string, void*); void* mUserData; }; diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp index e76a3dd554..e9fb9d3a17 100644 --- a/indra/newview/llpanelcontents.cpp +++ b/indra/newview/llpanelcontents.cpp @@ -168,7 +168,7 @@ void LLPanelContents::onClickNewScript(void *userdata) PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); - LLString desc; + std::string desc; LLAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc); LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem( @@ -178,7 +178,7 @@ void LLPanelContents::onClickNewScript(void *userdata) LLUUID::null, LLAssetType::AT_LSL_TEXT, LLInventoryType::IT_LSL, - LLString("New Script"), + std::string("New Script"), desc, LLSaleInfo::DEFAULT, LLViewerInventoryItem::II_FLAGS_NONE, diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp index 42df0c2ac8..2d5f789141 100644 --- a/indra/newview/llpanelgroup.cpp +++ b/indra/newview/llpanelgroup.cpp @@ -112,10 +112,10 @@ void LLPanelGroupTab::onClickHelp(void* user_data) void LLPanelGroupTab::handleClickHelp() { // Display the help text. - LLString help_text( getHelpText() ); + std::string help_text( getHelpText() ); if ( !help_text.empty() ) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = help_text; LLAlertDialog* dialogp = gViewerWindow->alertXml("GenericAlert", args); if (dialogp) @@ -323,7 +323,7 @@ void LLPanelGroup::tabChanged() //based on if they need an apply if ( mApplyBtn ) { - LLString mesg; + std::string mesg; mApplyBtn->setEnabled(mCurrentTab->needsApply(mesg)); } } @@ -402,7 +402,7 @@ BOOL LLPanelGroup::canClose() BOOL LLPanelGroup::attemptTransition() { // Check if the current tab needs to be applied. - LLString mesg; + std::string mesg; if (mCurrentTab && mCurrentTab->needsApply(mesg)) { // If no message was provided, give a generic one. @@ -411,7 +411,7 @@ BOOL LLPanelGroup::attemptTransition() mesg = mDefaultNeedsApplyMesg; } // Create a notify box, telling the user about the unapplied tab. - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NEEDS_APPLY_MESSAGE]"] = mesg; args["[WANT_APPLY_MESSAGE]"] = mWantApplyMesg; gViewerWindow->alertXml("PanelGroupApply", args, @@ -547,7 +547,7 @@ bool LLPanelGroup::apply() LLPanelGroupTab* panelp = (LLPanelGroupTab*) mTabContainer->getCurrentPanel(); if (!panelp) return false; - LLString mesg; + std::string mesg; if ( !panelp->needsApply(mesg) ) { // We don't need to apply anything. @@ -557,7 +557,7 @@ bool LLPanelGroup::apply() // Ignore the needs apply message. // Try to do the actual apply. - LLString apply_mesg; + std::string apply_mesg; if ( panelp->apply( apply_mesg ) ) { // Everything worked. We're done. @@ -568,7 +568,7 @@ bool LLPanelGroup::apply() // Inform the user. if ( !apply_mesg.empty() ) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = apply_mesg; gViewerWindow->alertXml("GenericAlert", args); } @@ -595,7 +595,7 @@ void LLPanelGroup::draw() } if (mCurrentTab) { - LLString mesg; + std::string mesg; childSetEnabled("btn_apply", mCurrentTab->needsApply(mesg)); } @@ -627,11 +627,11 @@ void LLPanelGroup::close() } } -void LLPanelGroup::showNotice(const char* subject, - const char* message, - const bool& has_inventory, - const char* inventory_name, - LLOfferInfo* inventory_offer) +void LLPanelGroup::showNotice(const std::string& subject, + const std::string& message, + const bool& has_inventory, + const std::string& inventory_name, + LLOfferInfo* inventory_offer) { if (mCurrentTab->getName() != "notices_tab") { diff --git a/indra/newview/llpanelgroup.h b/indra/newview/llpanelgroup.h index 3928d1d2f5..f27ef75843 100644 --- a/indra/newview/llpanelgroup.h +++ b/indra/newview/llpanelgroup.h @@ -103,11 +103,11 @@ public: void setAllowEdit(BOOL v) { mAllowEdit = v; } - void showNotice(const char* subject, - const char* message, - const bool& has_inventory, - const char* inventory_name, - LLOfferInfo* inventory_offer); + void showNotice(const std::string& subject, + const std::string& message, + const bool& has_inventory, + const std::string& inventory_name, + LLOfferInfo* inventory_offer); protected: LLPanelGroupTab* mCurrentTab; LLPanelGroupTab* mRequestedTab; @@ -123,8 +123,8 @@ protected: std::string mInitialTab; std::string mFilename; - LLString mDefaultNeedsApplyMesg; - LLString mWantApplyMesg; + std::string mDefaultNeedsApplyMesg; + std::string mWantApplyMesg; BOOL mAllowEdit; BOOL mShowingNotifyDialog; @@ -148,14 +148,14 @@ public: // Asks if something needs to be applied. // If returning true, this function should modify the message to the user. - virtual bool needsApply(LLString& mesg) { return false; } + virtual bool needsApply(std::string& mesg) { return false; } // Asks if there is currently a modal dialog being shown. virtual BOOL hasModal() { return mHasModal; } // Request to apply current data. // If returning fail, this function should modify the message to the user. - virtual bool apply(LLString& mesg) { return true; } + virtual bool apply(std::string& mesg) { return true; } // Request a cancel of changes virtual void cancel() { } @@ -164,7 +164,7 @@ public: virtual void update(LLGroupChange gc) { } // This is the text to be displayed when a help button is pressed. - virtual LLString getHelpText() const { return mHelpText; } + virtual std::string getHelpText() const { return mHelpText; } // Display anything returned by getHelpText static void onClickHelp(void* data); @@ -184,7 +184,7 @@ public: protected: LLUUID mGroupID; LLTabContainer* mTabContainer; - LLString mHelpText; + std::string mHelpText; BOOL mAllowEdit; BOOL mHasModal; diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp index 72e7fb3abb..a70ca9444f 100644 --- a/indra/newview/llpanelgroupgeneral.cpp +++ b/indra/newview/llpanelgroupgeneral.cpp @@ -344,7 +344,7 @@ void LLPanelGroupGeneral::onClickJoin(void *userdata) if (gdatap) { S32 cost = gdatap->mMembershipFee; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[COST]"] = llformat("%d", cost); if (can_afford_transaction(cost)) @@ -394,7 +394,7 @@ void LLPanelGroupGeneral::openProfile(void* data) } } -bool LLPanelGroupGeneral::needsApply(LLString& mesg) +bool LLPanelGroupGeneral::needsApply(std::string& mesg) { mesg = getUIString("group_info_unchanged"); return mChanged || mGroupID.isNull(); @@ -432,7 +432,7 @@ void LLPanelGroupGeneral::draw() } } -bool LLPanelGroupGeneral::apply(LLString& mesg) +bool LLPanelGroupGeneral::apply(std::string& mesg) { BOOL has_power_in_group = gAgent.hasPowerInGroup(mGroupID,GP_GROUP_CHANGE_IDENTITY); @@ -443,7 +443,7 @@ bool LLPanelGroupGeneral::apply(LLString& mesg) // Check to make sure mature has been set if(mComboMature->getCurrentIndex() == DECLINE_TO_STATE) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; gViewerWindow->alertXml("SetGroupMature", &callbackConfirmMatureApply, new LLHandle<LLPanel>(getHandle())); return false; @@ -463,7 +463,7 @@ bool LLPanelGroupGeneral::apply(LLString& mesg) return false; } - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = mConfirmGroupCreateStr; gViewerWindow->alertXml("GenericAlertYesCancel", args, createGroupCallback, new LLHandle<LLPanel>(getHandle()) ); @@ -474,7 +474,8 @@ bool LLPanelGroupGeneral::apply(LLString& mesg) LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); if (!gdatap) { - mesg = "No group data found for group "; + // *TODO: Translate + mesg = std::string("No group data found for group "); mesg.append(mGroupID.asString()); return false; } @@ -575,7 +576,7 @@ void LLPanelGroupGeneral::confirmMatureApply(S32 option) } // If we got here it means they set a valid value - LLString mesg = ""; + std::string mesg = ""; apply(mesg); } @@ -721,7 +722,7 @@ void LLPanelGroupGeneral::update(LLGroupChange gc) } if ( mBtnJoinGroup ) { - char fee_buff[20]; /*Flawfinder: ignore*/ + std::string fee_buff; bool visible; visible = !is_member && gdatap->mOpenEnrollment; @@ -729,9 +730,9 @@ void LLPanelGroupGeneral::update(LLGroupChange gc) if ( visible ) { - snprintf(fee_buff, sizeof(fee_buff), "Join (L$%d)", gdatap->mMembershipFee); /* Flawfinder: ignore */ - mBtnJoinGroup->setLabelSelected(std::string(fee_buff)); - mBtnJoinGroup->setLabelUnselected(std::string(fee_buff)); + fee_buff = llformat( "Join (L$%d)", gdatap->mMembershipFee); + mBtnJoinGroup->setLabelSelected(fee_buff); + mBtnJoinGroup->setLabelUnselected(fee_buff); } } if ( mBtnInfo ) @@ -825,7 +826,7 @@ void LLPanelGroupGeneral::updateMembers() continue; } // Owners show up in bold. - LLString style = "NORMAL"; + std::string style = "NORMAL"; if ( member->isOwner() ) { style = "BOLD"; diff --git a/indra/newview/llpanelgroupgeneral.h b/indra/newview/llpanelgroupgeneral.h index 056d288094..982d0678dd 100644 --- a/indra/newview/llpanelgroupgeneral.h +++ b/indra/newview/llpanelgroupgeneral.h @@ -54,8 +54,8 @@ public: // LLPanelGroupTab static void* createTab(void* data); virtual void activate(); - virtual bool needsApply(LLString& mesg); - virtual bool apply(LLString& mesg); + virtual bool needsApply(std::string& mesg); + virtual bool apply(std::string& mesg); virtual void cancel(); static void createGroupCallback(S32 option, void* user_data); static void callbackConfirmMatureApply(S32 option, void* data); diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index fed7247816..c4af61587c 100644 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -71,13 +71,13 @@ public: public: LLUUID mGroupID; - LLString mLoadingText; + std::string mLoadingText; LLNameListCtrl *mInvitees; LLComboBox *mRoleNames; LLButton *mOKButton; LLButton *mRemoveButton; LLTextBox *mGroupName; - LLString mOwnerWarning; + std::string mOwnerWarning; bool mConfirmedOwnerInvite; void (*mCloseCallback)(void* data); @@ -158,7 +158,7 @@ void LLPanelGroupInvite::impl::submitInvitations() // owner role: display confirmation and wait for callback if ((role_id == gdatap->mOwnerRole) && (!mConfirmedOwnerInvite)) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = mOwnerWarning; gViewerWindow->alertXml("GenericAlertYesCancel", args, inviteOwnerCallback, this); return; // we'll be called again if user confirms @@ -395,8 +395,8 @@ void LLPanelGroupInvite::addUsers(std::vector<LLUUID>& agent_ids) LLViewerObject* dest = gObjectList.findObject(agent_id); if(dest && dest->isAvatar()) { - LLString fullname; - LLString::format_map_t args; + std::string fullname; + LLStringUtil::format_map_t args; LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp index fdeb3368e8..8483e43394 100644 --- a/indra/newview/llpanelgrouplandmoney.cpp +++ b/indra/newview/llpanelgrouplandmoney.cpp @@ -62,7 +62,7 @@ public: LLTextEditor* text_editor, LLTabContainer* tab_containerp, LLPanel* panelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id, S32 interval_length_days, S32 max_interval_days); @@ -94,7 +94,7 @@ public: LLTextEditor* text_editorp, LLTabContainer* tab_containerp, LLPanel* panelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id); virtual ~LLGroupMoneyDetailsTabEventHandler(); @@ -111,7 +111,7 @@ public: LLTextEditor* text_editorp, LLTabContainer* tab_containerp, LLPanel* panelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id); virtual ~LLGroupMoneySalesTabEventHandler(); @@ -125,7 +125,7 @@ public: LLGroupMoneyPlanningTabEventHandler(LLTextEditor* text_editor, LLTabContainer* tab_containerp, LLPanel* panelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id); virtual ~LLGroupMoneyPlanningTabEventHandler(); @@ -306,7 +306,7 @@ int LLPanelGroupLandMoney::impl::getStoredContribution() // Fills in the text field with the contribution, contrib void LLPanelGroupLandMoney::impl::setYourContributionTextField(int contrib) { - LLString buffer = llformat("%d", contrib); + std::string buffer = llformat("%d", contrib); if ( mYourContributionEditorp ) { @@ -405,41 +405,40 @@ void LLPanelGroupLandMoney::impl::processGroupLand(LLMessageSystem* msg) mMapButtonp->setEnabled(TRUE); } - char name[MAX_STRING]; /*Flawfinder: ignore*/ - char desc[MAX_STRING]; /*Flawfinder: ignore*/ + std::string name; + std::string desc; S32 actual_area; S32 billable_area; U8 flags; F32 global_x; F32 global_y; - char sim_name[MAX_STRING]; /*Flawfinder: ignore*/ + std::string sim_name; for(S32 i = first_block; i < count; ++i) { msg->getUUID("QueryData", "OwnerID", owner_id, i); - msg->getString("QueryData", "Name", MAX_STRING, name, i); - msg->getString("QueryData", "Desc", MAX_STRING, desc, i); + msg->getString("QueryData", "Name", name, i); + msg->getString("QueryData", "Desc", desc, i); msg->getS32("QueryData", "ActualArea", actual_area, i); msg->getS32("QueryData", "BillableArea", billable_area, i); msg->getU8("QueryData", "Flags", flags, i); msg->getF32("QueryData", "GlobalX", global_x, i); msg->getF32("QueryData", "GlobalY", global_y, i); - msg->getString("QueryData", "SimName", MAX_STRING, sim_name, i); + msg->getString("QueryData", "SimName", sim_name, i); S32 region_x = llround(global_x) % REGION_WIDTH_UNITS; S32 region_y = llround(global_y) % REGION_WIDTH_UNITS; - char location[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(location, MAX_STRING, "%s (%d, %d)", sim_name, region_x, region_y); /* Flawfinder: ignore */ - char area[MAX_STRING]; /*Flawfinder: ignore*/ + std::string location = sim_name + llformat(" (%d, %d)", region_x, region_y); + std::string area; if(billable_area == actual_area) { - snprintf(area, MAX_STRING, "%d", billable_area); /* Flawfinder: ignore */ + area = llformat("%d", billable_area); } else { - snprintf(area, MAX_STRING, "%d / %d", billable_area, actual_area); /* Flawfinder: ignore */ + area = llformat("%d / %d", billable_area, actual_area); } - char hidden[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(hidden, MAX_STRING, "%f %f", global_x, global_y); /* Flawfinder: ignore */ + std::string hidden; + hidden = llformat("%f %f", global_x, global_y); LLSD row; @@ -563,12 +562,12 @@ void LLPanelGroupLandMoney::update(LLGroupChange gc) mImplementationp->setYourContributionTextField(mImplementationp->getStoredContribution()); } -bool LLPanelGroupLandMoney::needsApply(LLString& mesg) +bool LLPanelGroupLandMoney::needsApply(std::string& mesg) { return mImplementationp->mNeedsApply; } -bool LLPanelGroupLandMoney::apply(LLString& mesg) +bool LLPanelGroupLandMoney::apply(std::string& mesg) { if (!mImplementationp->applyContribution() ) { @@ -679,7 +678,7 @@ BOOL LLPanelGroupLandMoney::postBuild() } } - LLString loading_text = getString("loading_txt"); + std::string loading_text = getString("loading_txt"); //pull out the widgets for the L$ details tab earlierp = getChild<LLButton>("earlier_details_button", true); @@ -777,7 +776,7 @@ public: LLButton* later_buttonp, LLTextEditor* text_editorp, LLPanel* tabpanelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id, S32 interval_length_days, S32 max_interval_days); @@ -803,14 +802,14 @@ public: LLButton* mEarlierButtonp; LLButton* mLaterButtonp; - LLString mLoadingText; + std::string mLoadingText; }; LLGroupMoneyTabEventHandler::impl::impl(LLButton* earlier_buttonp, LLButton* later_buttonp, LLTextEditor* text_editorp, LLPanel* tabpanelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id, S32 interval_length_days, S32 max_interval_days) @@ -868,7 +867,7 @@ LLGroupMoneyTabEventHandler::LLGroupMoneyTabEventHandler(LLButton* earlier_butto LLTextEditor* text_editorp, LLTabContainer* tab_containerp, LLPanel* panelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id, S32 interval_length_days, S32 max_interval_days) @@ -985,7 +984,7 @@ LLGroupMoneyDetailsTabEventHandler::LLGroupMoneyDetailsTabEventHandler(LLButton* LLTextEditor* text_editorp, LLTabContainer* tab_containerp, LLPanel* panelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id) : LLGroupMoneyTabEventHandler(earlier_buttonp, later_buttonp, @@ -1036,16 +1035,13 @@ void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg, return; } - char line[MAX_STRING]; /*Flawfinder: ignore*/ - LLString text; - - char start_date[MAX_STRING]; /*Flawfinder: ignore*/ + std::string start_date; S32 interval_days; S32 current_interval; msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days ); msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval ); - msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date); + msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, start_date); if ( interval_days != mImplementationp->mIntervalLength || current_interval != mImplementationp->mCurrentInterval ) @@ -1055,23 +1051,22 @@ void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg, return; } - snprintf(line, MAX_STRING, "%s\n\n", start_date); /* Flawfinder: ignore */ - text.append(line); + std::string text = start_date; + text.append("\n\n"); S32 total_amount = 0; S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData); for(S32 i = 0; i < transactions; i++) { - S32 amount = 0; - char desc[MAX_STRING]; /*Flawfinder: ignore*/ + S32 amount = 0; + std::string desc; - msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Description, MAX_STRING, desc, i ); - msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount, amount, i); + msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Description, desc, i ); + msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount, amount, i); if (amount != 0) { - snprintf(line, MAX_STRING, "%-24s %6d\n", desc, amount ); /* Flawfinder: ignore */ - text.append(line); + text.append(llformat("%-24s %6d\n", desc.c_str(), amount)); } else { @@ -1083,8 +1078,7 @@ void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg, text.append(1, '\n'); - snprintf(line, MAX_STRING, "%-24s %6d\n", "Total", total_amount ); /* Flawfinder: ignore */ - text.append(line); + text.append(llformat("%-24s %6d\n", "Total", total_amount)); if ( mImplementationp->mTextEditorp ) { @@ -1125,7 +1119,7 @@ LLGroupMoneySalesTabEventHandler::LLGroupMoneySalesTabEventHandler(LLButton* ear LLTextEditor* text_editorp, LLTabContainer* tab_containerp, LLPanel* panelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id) : LLGroupMoneyTabEventHandler(earlier_buttonp, later_buttonp, @@ -1176,16 +1170,15 @@ void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg, return; } - char line[MAX_STRING]; /*Flawfinder: ignore*/ std::string text = mImplementationp->mTextEditorp->getText(); - char start_date[MAX_STRING]; /*Flawfinder: ignore*/ + std::string start_date; S32 interval_days; S32 current_interval; msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days ); msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval ); - msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date); + msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, start_date); if (interval_days != mImplementationp->mIntervalLength || current_interval != mImplementationp->mCurrentInterval) @@ -1199,10 +1192,7 @@ void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg, // Start with the date. if (text == mImplementationp->mLoadingText) { - text.clear(); - - snprintf(line, MAX_STRING, "%s\n\n", start_date); /* Flawfinder: ignore */ - text.append(line); + text = start_date + "\n\n"; } S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData); @@ -1214,22 +1204,21 @@ void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg, { for(S32 i = 0; i < transactions; i++) { - const S32 SHORT_STRING = 64; - char time[SHORT_STRING]; /*Flawfinder: ignore*/ + std::string time; S32 type = 0; S32 amount = 0; - char user[SHORT_STRING]; /*Flawfinder: ignore*/ - char item[SHORT_STRING]; /*Flawfinder: ignore*/ + std::string user; + std::string item; - msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Time, SHORT_STRING, time, i); - msg->getStringFast(_PREHASH_HistoryData, _PREHASH_User, SHORT_STRING, user, i ); + msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Time, time, i); + msg->getStringFast(_PREHASH_HistoryData, _PREHASH_User, user, i ); msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Type, type, i); - msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Item, SHORT_STRING, item, i ); - msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount, amount, i); + msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Item, item, i ); + msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount, amount, i); if (amount != 0) { - const char* verb; + std::string verb; switch(type) { @@ -1256,7 +1245,7 @@ void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg, break; } - snprintf(line, sizeof(line), "%s %6d - %s %s %s\n", time, amount, user, verb, item); /* Flawfinder: ignore */ + std::string line = llformat("%s %6d - %s %s %s\n", time.c_str(), amount, user.c_str(), verb.c_str(), item.c_str()); text.append(line); } } @@ -1302,7 +1291,7 @@ void LLPanelGroupLandMoney::processGroupAccountTransactionsReply(LLMessageSystem LLGroupMoneyPlanningTabEventHandler::LLGroupMoneyPlanningTabEventHandler(LLTextEditor* text_editorp, LLTabContainer* tab_containerp, LLPanel* panelp, - const LLString& loading_text, + const std::string& loading_text, const LLUUID& group_id) : LLGroupMoneyTabEventHandler(NULL, NULL, @@ -1353,12 +1342,11 @@ void LLGroupMoneyPlanningTabEventHandler::processReply(LLMessageSystem* msg, return; } - char line[MAX_STRING]; /*Flawfinder: ignore*/ - LLString text; + std::string text; - char start_date[MAX_STRING]; /*Flawfinder: ignore*/ - char last_stipend_date[MAX_STRING]; /*Flawfinder: ignore*/ - char next_stipend_date[MAX_STRING]; /*Flawfinder: ignore*/ + std::string start_date; + std::string last_stipend_date; + std::string next_stipend_date; S32 interval_days; S32 current_interval; S32 balance; @@ -1395,9 +1383,9 @@ void LLGroupMoneyPlanningTabEventHandler::processReply(LLMessageSystem* msg, msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ParcelDirFeeEstimate, proj_parcel_dir_fee ); msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_NonExemptMembers, non_exempt_members ); - msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date); - msg->getStringFast(_PREHASH_MoneyData, _PREHASH_LastTaxDate, MAX_STRING, last_stipend_date); - msg->getStringFast(_PREHASH_MoneyData, _PREHASH_TaxDate, MAX_STRING, next_stipend_date); + msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, start_date); + msg->getStringFast(_PREHASH_MoneyData, _PREHASH_LastTaxDate, last_stipend_date); + msg->getStringFast(_PREHASH_MoneyData, _PREHASH_TaxDate, next_stipend_date); cur_total_tax = cur_object_tax + cur_light_tax + cur_land_tax + cur_group_tax + cur_parcel_dir_fee; proj_total_tax = proj_object_tax + proj_light_tax + proj_land_tax + proj_group_tax + proj_parcel_dir_fee; @@ -1410,27 +1398,22 @@ void LLGroupMoneyPlanningTabEventHandler::processReply(LLMessageSystem* msg, return; } - snprintf(line, MAX_STRING, "Summary for this week, beginning on %s\n", start_date); /* Flawfinder: ignore */ - text.append(line); + text.append("Summary for this week, beginning on "); + text.append(start_date); if (current_interval == 0) { - snprintf(line, MAX_STRING, "The next stipend day is %s\n\n", next_stipend_date); /* Flawfinder: ignore */ - text.append(line); - snprintf(line, MAX_STRING, "%-24sL$%6d\n", "Balance", balance ); /* Flawfinder: ignore */ - text.append(line); - + text.append("The next stipend day is "); + text.append(next_stipend_date); + text.append("\n\n"); + text.append(llformat("%-24sL$%6d\n", "Balance", balance )); text.append(1, '\n'); } - snprintf(line, MAX_STRING, " Group Individual Share\n"); /* Flawfinder: ignore */ - text.append(line); - snprintf(line, MAX_STRING, "%-24s %6d %6d \n", "Credits", total_credits, (S32)floor((F32)total_credits/(F32)non_exempt_members)); /* Flawfinder: ignore */ - text.append(line); - snprintf(line, MAX_STRING, "%-24s %6d %6d \n", "Debits", total_debits, (S32)floor((F32)total_debits/(F32)non_exempt_members)); /* Flawfinder: ignore */ - text.append(line); - snprintf(line, MAX_STRING, "%-24s %6d %6d \n", "Total", total_credits + total_debits, (S32)floor((F32)(total_credits + total_debits)/(F32)non_exempt_members)); /* Flawfinder: ignore */ - text.append(line); + text.append( " Group Individual Share\n"); + text.append(llformat( "%-24s %6d %6d \n", "Credits", total_credits, (S32)floor((F32)total_credits/(F32)non_exempt_members))); + text.append(llformat( "%-24s %6d %6d \n", "Debits", total_debits, (S32)floor((F32)total_debits/(F32)non_exempt_members))); + text.append(llformat( "%-24s %6d %6d \n", "Total", total_credits + total_debits, (S32)floor((F32)(total_credits + total_debits)/(F32)non_exempt_members))); if ( mImplementationp->mTextEditorp ) { diff --git a/indra/newview/llpanelgrouplandmoney.h b/indra/newview/llpanelgrouplandmoney.h index 83126f9906..ec3ca18e1f 100644 --- a/indra/newview/llpanelgrouplandmoney.h +++ b/indra/newview/llpanelgrouplandmoney.h @@ -51,8 +51,8 @@ public: static void* createTab(void* data); virtual void activate(); - virtual bool needsApply(LLString& mesg); - virtual bool apply(LLString& mesg); + virtual bool needsApply(std::string& mesg); + virtual bool apply(std::string& mesg); virtual void cancel(); virtual void update(LLGroupChange gc); diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index 3d5abc2fb9..18fcc9d291 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -80,7 +80,7 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); protected: LLPanelGroupNotices* mGroupNoticesPanel; LLUUID mGroupID; @@ -103,7 +103,7 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL handled = FALSE; @@ -168,14 +168,14 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, //----------------------------------------------------------------------------- // LLPanelGroupNotices //----------------------------------------------------------------------------- -char* build_notice_date(const time_t& the_time, char* buffer) +std::string build_notice_date(const time_t& the_time) { time_t t = the_time; if (!t) time(&t); tm* lt = localtime(&t); //for some reason, the month is off by 1. See other uses of //"local" time in the code... - snprintf(buffer, NOTICE_DATE_STRING_SIZE, "%i/%i/%i", lt->tm_mon + 1, lt->tm_mday, lt->tm_year + 1900); /*Flawfinder: ignore*/ + std::string buffer = llformat("%i/%i/%i", lt->tm_mon + 1, lt->tm_mday, lt->tm_year + 1900); return buffer; } @@ -316,7 +316,7 @@ void LLPanelGroupNotices::setItem(LLPointer<LLInventoryItem> inv_item) item_is_multi = TRUE; }; - LLString icon_name = get_item_icon_name(inv_item->getType(), + std::string icon_name = get_item_icon_name(inv_item->getType(), inv_item->getInventoryType(), inv_item->getFlags(), item_is_multi ); @@ -362,8 +362,8 @@ void LLPanelGroupNotices::onClickSendMessage(void* data) } send_group_notice( self->mGroupID, - self->mCreateSubject->getText().c_str(), - self->mCreateMessage->getText().c_str(), + self->mCreateSubject->getText(), + self->mCreateMessage->getText(), self->mInventoryItem); self->mCreateMessage->clear(); @@ -442,8 +442,8 @@ void LLPanelGroupNotices::processGroupNoticesListReply(LLMessageSystem* msg, voi void LLPanelGroupNotices::processNotices(LLMessageSystem* msg) { LLUUID id; - char subj[MAX_STRING]; /*Flawfinder: ignore*/ - char name[MAX_STRING]; /*Flawfinder: ignore*/ + std::string subj; + std::string name; U32 timestamp; BOOL has_attachment; U8 asset_type; @@ -461,8 +461,8 @@ void LLPanelGroupNotices::processNotices(LLMessageSystem* msg) return; } - msg->getString("Data","Subject",MAX_STRING,subj,i); - msg->getString("Data","FromName",MAX_STRING,name,i); + msg->getString("Data","Subject",subj,i); + msg->getString("Data","FromName",name,i); msg->getBOOL("Data","HasAttachment",has_attachment,i); msg->getU8("Data","AssetType",asset_type,i); msg->getU32("Data","Timestamp",timestamp,i); @@ -474,7 +474,7 @@ void LLPanelGroupNotices::processNotices(LLMessageSystem* msg) row["columns"][0]["column"] = "icon"; if (has_attachment) { - LLString icon_name = get_item_icon_name( + std::string icon_name = get_item_icon_name( (LLAssetType::EType)asset_type, LLInventoryType::IT_NONE,FALSE, FALSE); row["columns"][0]["type"] = "icon"; @@ -487,12 +487,11 @@ void LLPanelGroupNotices::processNotices(LLMessageSystem* msg) row["columns"][2]["column"] = "from"; row["columns"][2]["value"] = name; - char buffer[NOTICE_DATE_STRING_SIZE]; /*Flawfinder: ignore*/ - build_notice_date(t, buffer); + std::string buffer = build_notice_date(t); row["columns"][3]["column"] = "date"; row["columns"][3]["value"] = buffer; - snprintf(buffer, 30, "%u", timestamp); /* Flawfinder: ignore */ + buffer = llformat( "%u", timestamp); row["columns"][4]["column"] = "sort"; row["columns"][4]["value"] = buffer; @@ -522,16 +521,16 @@ void LLPanelGroupNotices::onSelectNotice(LLUICtrl* ctrl, void* data) lldebugs << "Item " << item->getUUID() << " selected." << llendl; } -void LLPanelGroupNotices::showNotice(const char* subject, - const char* message, - const bool& has_inventory, - const char* inventory_name, - LLOfferInfo* inventory_offer) +void LLPanelGroupNotices::showNotice(const std::string& subject, + const std::string& message, + const bool& has_inventory, + const std::string& inventory_name, + LLOfferInfo* inventory_offer) { arrangeNoticeView(VIEW_PAST_NOTICE); - if(mViewSubject) mViewSubject->setText(LLString(subject)); - if(mViewMessage) mViewMessage->setText(LLString(message)); + if(mViewSubject) mViewSubject->setText(subject); + if(mViewMessage) mViewMessage->setText(message); if (mInventoryOffer) { @@ -544,7 +543,7 @@ void LLPanelGroupNotices::showNotice(const char* subject, { mInventoryOffer = inventory_offer; - LLString icon_name = get_item_icon_name(mInventoryOffer->mType, + std::string icon_name = get_item_icon_name(mInventoryOffer->mType, LLInventoryType::IT_TEXTURE, 0, FALSE); diff --git a/indra/newview/llpanelgroupnotices.h b/indra/newview/llpanelgroupnotices.h index aaac23fd98..96cb35a567 100644 --- a/indra/newview/llpanelgroupnotices.h +++ b/indra/newview/llpanelgroupnotices.h @@ -52,8 +52,8 @@ public: // LLPanelGroupTab static void* createTab(void* data); virtual void activate(); - //virtual bool needsApply(LLString& mesg); - //virtual bool apply(LLString& mesg); + //virtual bool needsApply(std::string& mesg); + //virtual bool apply(std::string& mesg); //virtual void update(); virtual BOOL postBuild(); @@ -63,11 +63,11 @@ public: static void processGroupNoticesListReply(LLMessageSystem* msg, void** data); - void showNotice(const char* subject, - const char* message, - const bool& has_inventory, - const char* inventory_name, - LLOfferInfo* inventory_offer); + void showNotice(const std::string& subject, + const std::string& message, + const bool& has_inventory, + const std::string& inventory_name, + LLOfferInfo* inventory_offer); private: static void onClickRemoveAttachment(void* data); diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index 5f11c4ac80..ba4153b087 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -228,7 +228,7 @@ void LLPanelGroupRoles::handleClickSubTab() BOOL LLPanelGroupRoles::attemptTransition() { // Check if the current tab needs to be applied. - LLString mesg; + std::string mesg; if (mCurrentTab && mCurrentTab->needsApply(mesg)) { // If no message was provided, give a generic one. @@ -237,7 +237,7 @@ BOOL LLPanelGroupRoles::attemptTransition() mesg = mDefaultNeedsApplyMesg; } // Create a notify box, telling the user about the unapplied tab. - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NEEDS_APPLY_MESSAGE]"] = mesg; args["[WANT_APPLY_MESSAGE]"] = mWantApplyMesg; gViewerWindow->alertXml("PanelGroupApply", args, @@ -300,14 +300,14 @@ void LLPanelGroupRoles::handleNotifyCallback(S32 option) case 0: // "Apply Changes" { // Try to apply changes, and switch to the requested tab. - LLString apply_mesg; + std::string apply_mesg; if ( !apply( apply_mesg ) ) { // There was a problem doing the apply. if ( !apply_mesg.empty() ) { mHasModal = TRUE; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = apply_mesg; gViewerWindow->alertXml("GenericAlert", args, onModalClose, (void*) this); } @@ -350,7 +350,7 @@ void LLPanelGroupRoles::onModalClose(S32 option, void* user_data) } -bool LLPanelGroupRoles::apply(LLString& mesg) +bool LLPanelGroupRoles::apply(std::string& mesg) { // Pass this along to the currently visible sub tab. if (!mSubTabContainer) return false; @@ -359,7 +359,7 @@ bool LLPanelGroupRoles::apply(LLString& mesg) if (!panelp) return false; // Ignore the needs apply message. - LLString ignore_mesg; + std::string ignore_mesg; if ( !panelp->needsApply(ignore_mesg) ) { // We don't need to apply anything. @@ -383,7 +383,7 @@ void LLPanelGroupRoles::cancel() } // Pass all of these messages to the currently visible sub tab. -LLString LLPanelGroupRoles::getHelpText() const +std::string LLPanelGroupRoles::getHelpText() const { LLPanelGroupTab* panelp = (LLPanelGroupTab*) mSubTabContainer->getCurrentPanel(); if (panelp) @@ -458,7 +458,7 @@ void LLPanelGroupRoles::deactivate() if (panelp) panelp->deactivate(); } -bool LLPanelGroupRoles::needsApply(LLString& mesg) +bool LLPanelGroupRoles::needsApply(std::string& mesg) { LLPanelGroupTab* panelp = (LLPanelGroupTab*) mSubTabContainer->getCurrentPanel(); if (!panelp) return false; @@ -606,15 +606,15 @@ void LLPanelGroupSubTab::onClickShowAll(void* user_data) void LLPanelGroupSubTab::handleClickShowAll() { lldebugs << "LLPanelGroupSubTab::handleClickShowAll()" << llendl; - setSearchFilter( LLString::null ); + setSearchFilter( LLStringUtil::null ); mShowAllButton->setEnabled(FALSE); } -void LLPanelGroupSubTab::setSearchFilter(const LLString& filter) +void LLPanelGroupSubTab::setSearchFilter(const std::string& filter) { lldebugs << "LLPanelGroupSubTab::setSearchFilter() ==> '" << filter << "'" << llendl; mSearchFilter = filter; - LLString::toLower(mSearchFilter); + LLStringUtil::toLower(mSearchFilter); update(GC_ALL); } @@ -656,7 +656,7 @@ bool LLPanelGroupSubTab::matchesActionSearchFilter(std::string action) // If the search filter is empty, everything passes. if (mSearchFilter.empty()) return true; - LLString::toLower(action); + LLStringUtil::toLower(action); std::string::size_type match = action.find(mSearchFilter); if (std::string::npos == match) @@ -1338,7 +1338,7 @@ void LLPanelGroupMembersSubTab::deactivate() LLPanelGroupSubTab::deactivate(); } -bool LLPanelGroupMembersSubTab::needsApply(LLString& mesg) +bool LLPanelGroupMembersSubTab::needsApply(std::string& mesg) { return mChanged; } @@ -1357,7 +1357,7 @@ void LLPanelGroupMembersSubTab::cancel() } } -bool LLPanelGroupMembersSubTab::apply(LLString& mesg) +bool LLPanelGroupMembersSubTab::apply(std::string& mesg) { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); if (!gdatap) @@ -1375,7 +1375,7 @@ bool LLPanelGroupMembersSubTab::apply(LLString& mesg) if ( mNumOwnerAdditions > 0 ) { LLRoleData rd; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; if ( gdatap->getRoleData(gdatap->mOwnerRole, rd) ) { @@ -1465,7 +1465,7 @@ bool LLPanelGroupMembersSubTab::matchesSearchFilter(const std::string& fullname) // Create a full name, and compare it to the search filter. std::string fullname_lc(fullname); - LLString::toLower(fullname_lc); + LLStringUtil::toLower(fullname_lc); std::string::size_type match = fullname_lc.find(mSearchFilter); @@ -1721,7 +1721,7 @@ void LLPanelGroupMembersSubTab::updateMembers() else { mMembersList->setEnabled(FALSE); - mMembersList->addCommentText("No match."); + mMembersList->addCommentText(std::string("No match.")); } } else @@ -1855,7 +1855,7 @@ void LLPanelGroupRolesSubTab::deactivate() LLPanelGroupSubTab::deactivate(); } -bool LLPanelGroupRolesSubTab::needsApply(LLString& mesg) +bool LLPanelGroupRolesSubTab::needsApply(std::string& mesg) { lldebugs << "LLPanelGroupRolesSubTab::needsApply()" << llendl; @@ -1865,7 +1865,7 @@ bool LLPanelGroupRolesSubTab::needsApply(LLString& mesg) || (gdatap && gdatap->pendingRoleChanges())); // Pending role changes in the group } -bool LLPanelGroupRolesSubTab::apply(LLString& mesg) +bool LLPanelGroupRolesSubTab::apply(std::string& mesg) { lldebugs << "LLPanelGroupRolesSubTab::apply()" << llendl; @@ -1910,8 +1910,8 @@ bool LLPanelGroupRolesSubTab::matchesSearchFilter(std::string rolename, std::str // If the search filter is empty, everything passes. if (mSearchFilter.empty()) return true; - LLString::toLower(rolename); - LLString::toLower(roletitle); + LLStringUtil::toLower(rolename); + LLStringUtil::toLower(roletitle); std::string::size_type match_name = rolename.find(mSearchFilter); std::string::size_type match_title = roletitle.find(mSearchFilter); @@ -1978,7 +1978,7 @@ void LLPanelGroupRolesSubTab::update(LLGroupChange gc) } } - mRolesList->sortByColumn("name", TRUE); + mRolesList->sortByColumn(std::string("name"), TRUE); if ( (gdatap->mRoles.size() < (U32)MAX_ROLES) && gAgent.hasPowerInGroup(mGroupID, GP_ROLE_CREATE) ) @@ -2216,7 +2216,7 @@ void LLPanelGroupRolesSubTab::handleActionCheck(LLCheckBoxCtrl* check, bool forc check->set(FALSE); LLRoleData rd; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; if ( gdatap->getRoleData(role_id, rd) ) { @@ -2226,7 +2226,7 @@ void LLPanelGroupRolesSubTab::handleActionCheck(LLCheckBoxCtrl* check, bool forc cb_data->mSelf = this; cb_data->mCheck = check; mHasModal = TRUE; - LLString warning = "AssignDangerousActionWarning"; + std::string warning = "AssignDangerousActionWarning"; if (GP_ROLE_CHANGE_ACTIONS == power) { warning = "AssignDangerousAbilityWarning"; @@ -2404,7 +2404,7 @@ void LLPanelGroupRolesSubTab::handleDeleteRole() if (role_item->getUUID().isNull() || role_item->getUUID() == gdatap->mOwnerRole) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = mRemoveEveryoneTxt; LLNotifyBox::showXml("GenericNotify", args); return; @@ -2511,14 +2511,14 @@ void LLPanelGroupActionsSubTab::deactivate() LLPanelGroupSubTab::deactivate(); } -bool LLPanelGroupActionsSubTab::needsApply(LLString& mesg) +bool LLPanelGroupActionsSubTab::needsApply(std::string& mesg) { lldebugs << "LLPanelGroupActionsSubTab::needsApply()" << llendl; return false; } -bool LLPanelGroupActionsSubTab::apply(LLString& mesg) +bool LLPanelGroupActionsSubTab::apply(std::string& mesg) { lldebugs << "LLPanelGroupActionsSubTab::apply()" << llendl; return true; diff --git a/indra/newview/llpanelgrouproles.h b/indra/newview/llpanelgrouproles.h index 8d16d613e9..f55d70f018 100644 --- a/indra/newview/llpanelgrouproles.h +++ b/indra/newview/llpanelgrouproles.h @@ -78,12 +78,12 @@ public: static void onModalClose(S32 option, void* user_data); // Most of these messages are just passed on to the current sub-tab. - virtual LLString getHelpText() const; + virtual std::string getHelpText() const; virtual void activate(); virtual void deactivate(); - virtual bool needsApply(LLString& mesg); + virtual bool needsApply(std::string& mesg); virtual BOOL hasModal(); - virtual bool apply(LLString& mesg); + virtual bool apply(std::string& mesg); virtual void cancel(); virtual void update(LLGroupChange gc); @@ -97,8 +97,8 @@ protected: BOOL mFirstUse; BOOL mIgnoreTransition; - LLString mDefaultNeedsApplyMesg; - LLString mWantApplyMesg; + std::string mDefaultNeedsApplyMesg; + std::string mWantApplyMesg; }; class LLPanelGroupSubTab : public LLPanelGroupTab @@ -120,7 +120,7 @@ public: static void onClickShowAll(void*); void handleClickShowAll(); - virtual void setSearchFilter( const LLString& filter ); + virtual void setSearchFilter( const std::string& filter ); virtual void activate(); virtual void deactivate(); @@ -154,7 +154,7 @@ protected: LLButton* mSearchButton; LLButton* mShowAllButton; - LLString mSearchFilter; + std::string mSearchFilter; icon_map_t mActionIcons; @@ -193,8 +193,8 @@ public: virtual void activate(); virtual void deactivate(); virtual void cancel(); - virtual bool needsApply(LLString& mesg); - virtual bool apply(LLString& mesg); + virtual bool needsApply(std::string& mesg); + virtual bool apply(std::string& mesg); virtual void update(LLGroupChange gc); void updateMembers(); @@ -238,8 +238,8 @@ public: virtual void activate(); virtual void deactivate(); - virtual bool needsApply(LLString& mesg); - virtual bool apply(LLString& mesg); + virtual bool needsApply(std::string& mesg); + virtual bool apply(std::string& mesg); virtual void cancel(); bool matchesSearchFilter(std::string rolename, std::string roletitle); virtual void update(LLGroupChange gc); @@ -302,8 +302,8 @@ public: virtual void activate(); virtual void deactivate(); - virtual bool needsApply(LLString& mesg); - virtual bool apply(LLString& mesg); + virtual bool needsApply(std::string& mesg); + virtual bool apply(std::string& mesg); virtual void update(LLGroupChange gc); static void onActionSelect(LLUICtrl*, void*); diff --git a/indra/newview/llpanelland.cpp b/indra/newview/llpanelland.cpp index a994a94fb7..f0afa3434e 100644 --- a/indra/newview/llpanelland.cpp +++ b/indra/newview/llpanelland.cpp @@ -120,8 +120,8 @@ void LLPanelLandInfo::refresh() childSetVisible("label_area_price",false); childSetVisible("label_area",false); - //mTextPrice->setText(LLString::null); - childSetText("textbox price",LLString::null); + //mTextPrice->setText(LLStringUtil::null); + childSetText("textbox price",LLStringUtil::null); childSetEnabled("button buy land",FALSE); childSetEnabled("button abandon land",FALSE); diff --git a/indra/newview/llpanellandmedia.cpp b/indra/newview/llpanellandmedia.cpp index 085cbfa7a0..34a4ad3954 100644 --- a/indra/newview/llpanellandmedia.cpp +++ b/indra/newview/llpanellandmedia.cpp @@ -66,7 +66,7 @@ enum //--------------------------------------------------------------------------- LLPanelLandMedia::LLPanelLandMedia(LLParcelSelectionHandle& parcel) -: LLPanel("land_media_panel"), mParcel(parcel) +: LLPanel(std::string("land_media_panel")), mParcel(parcel) { } @@ -170,7 +170,7 @@ void LLPanelLandMedia::refresh() mMediaURLEdit->setText(parcel->getMediaURL()); mMediaURLEdit->setEnabled( FALSE ); - mMediaDescEdit->setText(LLString(parcel->getMediaDesc())); + mMediaDescEdit->setText(parcel->getMediaDesc()); mMediaDescEdit->setEnabled( can_change_media ); std::string mime_type = parcel->getMediaType(); @@ -267,12 +267,12 @@ void LLPanelLandMedia::refresh() void LLPanelLandMedia::populateMIMECombo() { - LLString default_mime_type = "none/none"; - LLString default_label; + std::string default_mime_type = "none/none"; + std::string default_label; LLMIMETypes::mime_widget_set_map_t::const_iterator it; for (it = LLMIMETypes::sWidgetMap.begin(); it != LLMIMETypes::sWidgetMap.end(); ++it) { - const LLString& mime_type = it->first; + const std::string& mime_type = it->first; const LLMIMETypes::LLMIMEWidgetSet& info = it->second; if (info.mDefaultMimeType == default_mime_type) { @@ -289,24 +289,24 @@ void LLPanelLandMedia::populateMIMECombo() mMediaTypeCombo->add( default_label, default_mime_type, ADD_BOTTOM ); } -void LLPanelLandMedia::setMediaType(const LLString& mime_type) +void LLPanelLandMedia::setMediaType(const std::string& mime_type) { LLParcel *parcel = mParcel->getParcel(); if(parcel) - parcel->setMediaType(mime_type.c_str()); + parcel->setMediaType(mime_type); - LLString media_key = LLMIMETypes::widgetType(mime_type); + std::string media_key = LLMIMETypes::widgetType(mime_type); mMediaTypeCombo->setValue(media_key); childSetText("mime_type", mime_type); } -void LLPanelLandMedia::setMediaURL(const LLString& media_url) +void LLPanelLandMedia::setMediaURL(const std::string& media_url) { mMediaURLEdit->setText(media_url); mMediaURLEdit->onCommit(); } -LLString LLPanelLandMedia::getMediaURL() +std::string LLPanelLandMedia::getMediaURL() { return mMediaURLEdit->getText(); } @@ -374,17 +374,17 @@ void LLPanelLandMedia::onCommitAny(LLUICtrl*, void *userdata) } // Remove leading/trailing whitespace (common when copying/pasting) - LLString::trim(music_url); - LLString::trim(media_url); + LLStringUtil::trim(music_url); + LLStringUtil::trim(media_url); // Push data into current parcel parcel->setParcelFlag(PF_ALLOW_VOICE_CHAT, voice_enabled); parcel->setParcelFlag(PF_USE_ESTATE_VOICE_CHAN, voice_estate_chan); parcel->setParcelFlag(PF_SOUND_LOCAL, sound_local); - parcel->setMusicURL(music_url.c_str()); - parcel->setMediaURL(media_url.c_str()); - parcel->setMediaType(mime_type.c_str()); - parcel->setMediaDesc(media_desc.c_str()); + parcel->setMusicURL(music_url); + parcel->setMediaURL(media_url); + parcel->setMediaType(mime_type); + parcel->setMediaDesc(media_desc); parcel->setMediaWidth(media_width); parcel->setMediaHeight(media_height); parcel->setMediaID(media_id); diff --git a/indra/newview/llpanellandmedia.h b/indra/newview/llpanellandmedia.h index e22e49ca35..4810a0a94c 100644 --- a/indra/newview/llpanellandmedia.h +++ b/indra/newview/llpanellandmedia.h @@ -46,9 +46,9 @@ public: /*virtual*/ ~LLPanelLandMedia(); /*virtual*/ BOOL postBuild(); void refresh(); - void setMediaType(const LLString& media_type); - void setMediaURL(const LLString& media_type); - LLString getMediaURL(); + void setMediaType(const std::string& media_type); + void setMediaURL(const std::string& media_type); + std::string getMediaURL(); private: void populateMIMECombo(); diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index a3526dff21..c252c54ad7 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -79,7 +79,7 @@ #define USE_VIEWER_AUTH 0 -LLString load_password_from_disk(void); +std::string load_password_from_disk(void); void save_password_to_disk(const char* hashed_password); const S32 BLACK_BORDER_HEIGHT = 160; @@ -204,7 +204,7 @@ void LLLoginHandler::parse(const LLSD& queryMap) LLViewerLogin::getInstance()->setGridChoice(grid_choice); } - LLString startLocation = queryMap["location"].asString(); + std::string startLocation = queryMap["location"].asString(); if (startLocation == "specify") { @@ -213,12 +213,12 @@ void LLLoginHandler::parse(const LLSD& queryMap) else if (startLocation == "home") { gSavedSettings.setBOOL("LoginLastLocation", FALSE); - LLURLSimString::setString(""); + LLURLSimString::setString(LLStringUtil::null); } else if (startLocation == "last") { gSavedSettings.setBOOL("LoginLastLocation", TRUE); - LLURLSimString::setString(""); + LLURLSimString::setString(LLStringUtil::null); } } @@ -234,7 +234,7 @@ bool LLLoginHandler::handle(const LLSD& tokens, return true; } - LLString password = queryMap["password"].asString(); + std::string password = queryMap["password"].asString(); if (!password.empty()) { @@ -245,7 +245,7 @@ bool LLLoginHandler::handle(const LLSD& tokens, LLMD5 pass((unsigned char*)password.c_str()); char md5pass[33]; /* Flawfinder: ignore */ pass.hex_digest(md5pass); - password = md5pass; + password = ll_safe_string(md5pass, 32); save_password_to_disk(password.c_str()); } } @@ -324,7 +324,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, BOOL show_server, void (*callback)(S32 option, void* user_data), void *cb_data) -: LLPanel("panel_login", LLRect(0,600,800,0), FALSE), // not bordered +: LLPanel(std::string("panel_login"), LLRect(0,600,800,0), FALSE), // not bordered mLogoImage(), mCallback(callback), mCallbackData(cb_data), @@ -386,7 +386,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, // 2 - "<Type region name>" BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); - LLString sim_string = LLURLSimString::sInstance.mSimString; + std::string sim_string = LLURLSimString::sInstance.mSimString; if (!sim_string.empty()) { // Replace "<Type region name>" with this region name @@ -415,7 +415,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, childSetAction("quit_btn", onClickQuit, this); LLTextBox* version_text = getChild<LLTextBox>("version_text"); - LLString version = llformat("%d.%d.%d (%d)", + std::string version = llformat("%d.%d.%d (%d)", LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, @@ -744,7 +744,7 @@ void LLPanelLogin::setFields(const std::string& firstname, const std::string& la // static -void LLPanelLogin::addServer(const char *server, S32 domain_name) +void LLPanelLogin::addServer(const std::string& server, S32 domain_name) { if (!sInstance) { @@ -758,7 +758,7 @@ void LLPanelLogin::addServer(const char *server, S32 domain_name) } // static -void LLPanelLogin::getFields(LLString &firstname, LLString &lastname, LLString &password, +void LLPanelLogin::getFields(std::string &firstname, std::string &lastname, std::string &password, BOOL &remember) { if (!sInstance) @@ -768,10 +768,10 @@ void LLPanelLogin::getFields(LLString &firstname, LLString &lastname, LLString & } firstname = sInstance->childGetText("first_name_edit"); - LLString::trim(firstname); + LLStringUtil::trim(firstname); lastname = sInstance->childGetText("last_name_edit"); - LLString::trim(lastname); + LLStringUtil::trim(lastname); password = sInstance->mMungedPassword; remember = sInstance->childGetValue("remember_check"); @@ -779,7 +779,7 @@ void LLPanelLogin::getFields(LLString &firstname, LLString &lastname, LLString & // static. Return TRUE if user made a choice from the popup -BOOL LLPanelLogin::getServer(LLString &server, S32 &domain_name) +BOOL LLPanelLogin::getServer(std::string &server, S32 &domain_name) { BOOL user_picked = FALSE; if (!sInstance) @@ -812,7 +812,7 @@ BOOL LLPanelLogin::getServer(LLString &server, S32 &domain_name) } // static -void LLPanelLogin::getLocation(LLString &location) +void LLPanelLogin::getLocation(std::string &location) { if (!sInstance) { @@ -914,7 +914,7 @@ void LLPanelLogin::loadLoginPage() } // Language - LLString language(gSavedSettings.getString("Language")); + std::string language(gSavedSettings.getString("Language")); if(language == "default") { language = gSavedSettings.getString("SystemLanguage"); @@ -928,7 +928,7 @@ void LLPanelLogin::loadLoginPage() } // Channel and Version - LLString version = llformat("%d.%d.%d (%d)", + std::string version = llformat("%d.%d.%d (%d)", LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VIEWER_BUILD); char* curl_channel = curl_escape(gSavedSettings.getString("VersionChannelName").c_str(), 0); @@ -941,7 +941,7 @@ void LLPanelLogin::loadLoginPage() curl_free(curl_version); // Grid - LLString grid; + std::string grid; S32 grid_index; getServer( grid, grid_index ); @@ -958,9 +958,9 @@ void LLPanelLogin::loadLoginPage() #if USE_VIEWER_AUTH LLURLSimString::sInstance.parse(); - LLString location; - LLString region; - LLString password; + std::string location; + std::string region; + std::string password; if (LLURLSimString::parse()) { @@ -983,7 +983,7 @@ void LLPanelLogin::loadLoginPage() } } - LLString firstname, lastname; + std::string firstname, lastname; if(gSavedSettings.getLLSD("UserLoginInfo").size() == 3) { @@ -1076,8 +1076,8 @@ void LLPanelLogin::onClickConnect(void *) // JC - Make sure the fields all get committed. sInstance->setFocus(FALSE); - LLString first = sInstance->childGetText("first_name_edit"); - LLString last = sInstance->childGetText("last_name_edit"); + std::string first = sInstance->childGetText("first_name_edit"); + std::string last = sInstance->childGetText("last_name_edit"); if (!first.empty() && !last.empty()) { // has both first and last name typed @@ -1167,7 +1167,7 @@ void LLPanelLogin::onSelectServer(LLUICtrl*, void*) { // The user twiddled with the grid choice ui. // apply the selection to the grid setting. - LLString grid; + std::string grid; S32 grid_index; getServer( grid, grid_index ); diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h index 6a1b5d7758..69bf54ecc4 100644 --- a/indra/newview/llpanellogin.h +++ b/indra/newview/llpanellogin.h @@ -58,8 +58,8 @@ class LLLoginHandler : public LLCommandHandler void parse(const LLSD& queryMap); LLUUID mWebLoginKey; - LLString mFirstName; - LLString mLastName; + std::string mFirstName; + std::string mLastName; }; extern LLLoginHandler gLoginHandler; @@ -86,14 +86,14 @@ public: static void setFields(const std::string& firstname, const std::string& lastname, const std::string& password, BOOL remember); - static void addServer(const char *server, S32 domain_name); + static void addServer(const std::string& server, S32 domain_name); static void refreshLocation( bool force_visible ); - static void getFields(LLString &firstname, LLString &lastname, - LLString &password, BOOL &remember); + static void getFields(std::string& firstname, std::string& lastname, + std::string& password, BOOL& remember); - static BOOL getServer(LLString &server, S32& domain_name); - static void getLocation(LLString &location); + static BOOL getServer(std::string& server, S32& domain_name); + static void getLocation(std::string& location); static void close(); diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp index 62115be473..b181aff62d 100644 --- a/indra/newview/llpanelobject.cpp +++ b/indra/newview/llpanelobject.cpp @@ -99,7 +99,7 @@ enum { }; //*TODO:translate (depricated, so very low priority) -static const LLString LEGACY_FULLBRIGHT_DESC("Fullbright (Legacy)"); +static const std::string LEGACY_FULLBRIGHT_DESC("Fullbright (Legacy)"); BOOL LLPanelObject::postBuild() { @@ -429,7 +429,7 @@ void LLPanelObject::getState( ) BOOL owners_identical; LLUUID owner_id; - LLString owner_name; + std::string owner_name; owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); // BUG? Check for all objects being editable? @@ -538,7 +538,7 @@ void LLPanelObject::getState( ) mComboMaterial->remove(LEGACY_FULLBRIGHT_DESC); } // *TODO:Translate - mComboMaterial->setSimple(LLString(LLMaterialTable::basic.getName(material_code))); + mComboMaterial->setSimple(std::string(LLMaterialTable::basic.getName(material_code))); } } else @@ -1191,10 +1191,10 @@ void LLPanelObject::onCommitMaterial( LLUICtrl* ctrl, void* userdata ) if (box) { // apply the currently selected material to the object - const LLString& material_name = box->getSimple(); + const std::string& material_name = box->getSimple(); if (material_name != LEGACY_FULLBRIGHT_DESC) { - U8 material_code = LLMaterialTable::basic.getMCode(material_name.c_str()); + U8 material_code = LLMaterialTable::basic.getMCode(material_name); LLSelectMgr::getInstance()->selectionSetMaterial(material_code); } } diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index ae0b9c2811..3dab6e62c6 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -135,7 +135,7 @@ void LLPanelPermissions::refresh() LLButton* BtnDeedToGroup = getChild<LLButton>("button deed"); if(BtnDeedToGroup) { - LLString deedText; + std::string deedText; if (gSavedSettings.getWarning("DeedObject")) { deedText = getString("text deed continued"); @@ -165,33 +165,33 @@ void LLPanelPermissions::refresh() { // ...nothing selected childSetEnabled("perm_modify",false); - childSetText("perm_modify",LLString::null); + childSetText("perm_modify",LLStringUtil::null); childSetEnabled("Creator:",false); - childSetText("Creator Name",LLString::null); + childSetText("Creator Name",LLStringUtil::null); childSetEnabled("Creator Name",false); childSetEnabled("button creator profile",false); childSetEnabled("Owner:",false); - childSetText("Owner Name",LLString::null); + childSetText("Owner Name",LLStringUtil::null); childSetEnabled("Owner Name",false); childSetEnabled("button owner profile",false); childSetEnabled("Group:",false); - childSetText("Group Name",LLString::null); + childSetText("Group Name",LLStringUtil::null); childSetEnabled("Group Name",false); childSetEnabled("button set group",false); - childSetText("Object Name",LLString::null); + childSetText("Object Name",LLStringUtil::null); childSetEnabled("Object Name",false); childSetEnabled("Name:",false); - childSetText("Group Name",LLString::null); + childSetText("Group Name",LLStringUtil::null); childSetEnabled("Group Name",false); childSetEnabled("Description:",false); - childSetText("Object Description",LLString::null); + childSetText("Object Description",LLStringUtil::null); childSetEnabled("Object Description",false); - childSetText("prim info",LLString::null); + childSetText("prim info",LLStringUtil::null); childSetEnabled("prim info",false); childSetEnabled("Permissions:",false); @@ -231,7 +231,7 @@ void LLPanelPermissions::refresh() childSetEnabled("Cost",false); childSetText("Cost",getString("Cost Default")); - childSetText("Edit Cost",LLString::null); + childSetText("Edit Cost",LLStringUtil::null); childSetEnabled("Edit Cost",false); childSetEnabled("label click action",false); @@ -260,7 +260,7 @@ void LLPanelPermissions::refresh() || LLSelectMgr::getInstance()->selectGetModify(); const LLView* keyboard_focus_view = gFocusMgr.getKeyboardFocus(); S32 string_index = 0; - LLString MODIFY_INFO_STRINGS[] = + std::string MODIFY_INFO_STRINGS[] = { getString("text modify info 1"), getString("text modify info 2"), @@ -283,7 +283,7 @@ void LLPanelPermissions::refresh() // Update creator text field childSetEnabled("Creator:",true); BOOL creators_identical; - LLString creator_name; + std::string creator_name; creators_identical = LLSelectMgr::getInstance()->selectGetCreator(mCreatorID, creator_name); @@ -295,7 +295,7 @@ void LLPanelPermissions::refresh() childSetEnabled("Owner:",true); BOOL owners_identical; - LLString owner_name; + std::string owner_name; owners_identical = LLSelectMgr::getInstance()->selectGetOwner(mOwnerID, owner_name); // llinfos << "owners_identical " << (owners_identical ? "TRUE": "FALSE") << llendl; @@ -309,7 +309,7 @@ void LLPanelPermissions::refresh() else { // Display last owner if public - LLString last_owner_name; + std::string last_owner_name; LLSelectMgr::getInstance()->selectGetLastOwner(mLastOwnerID, last_owner_name); // It should never happen that the last owner is null and the owner @@ -328,7 +328,7 @@ void LLPanelPermissions::refresh() // update group text field childSetEnabled("Group:",true); - childSetText("Group Name",LLString::null); + childSetText("Group Name",LLStringUtil::null); LLUUID group_id; BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id); if (groups_identical) @@ -344,7 +344,7 @@ void LLPanelPermissions::refresh() if(mLabelGroupName) { mLabelGroupName->setNameID(LLUUID::null, TRUE); - mLabelGroupName->refresh(LLUUID::null, "", "", TRUE); + mLabelGroupName->refresh(LLUUID::null, LLStringUtil::null, LLStringUtil::null, TRUE); mLabelGroupName->setEnabled(FALSE); } } @@ -393,16 +393,14 @@ void LLPanelPermissions::refresh() S32 prim_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); S32 obj_count = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount(); - LLString object_info_string; + std::string object_info_string; if (1 == obj_count) { object_info_string.assign("1 Object, "); } else { - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(buffer, MAX_STRING, "%d Objects, ", obj_count); /* Flawfinder: ignore */ - object_info_string.assign(buffer); + object_info_string = llformat( "%d Objects, ", obj_count); } if (1 == prim_count) { @@ -410,8 +408,8 @@ void LLPanelPermissions::refresh() } else { - char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - snprintf(buffer, MAX_STRING, "%d Primitives", prim_count); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat( "%d Primitives", prim_count); object_info_string.append(buffer); } childSetText("prim info",object_info_string); @@ -437,7 +435,7 @@ void LLPanelPermissions::refresh() if(!owners_identical) { childSetEnabled("Cost",false); - childSetText("Edit Cost",LLString::null); + childSetText("Edit Cost",LLStringUtil::null); childSetEnabled("Edit Cost",false); } // You own these objects. @@ -487,7 +485,7 @@ void LLPanelPermissions::refresh() if (num_for_sale) childSetText("Edit Cost",llformat("%d",total_sale_price)); else - childSetText("Edit Cost",LLString::null); + childSetText("Edit Cost",LLStringUtil::null); // If multiple items are for sale, set text to TOTAL PRICE. if (num_for_sale > 1) @@ -501,7 +499,7 @@ void LLPanelPermissions::refresh() childSetEnabled("Cost",false); childSetText("Cost",getString("Cost Default")); - childSetText("Edit Cost",LLString::null); + childSetText("Edit Cost",LLStringUtil::null); childSetEnabled("Edit Cost",false); } @@ -871,7 +869,7 @@ void LLPanelPermissions::onClickGroup(void* data) { LLPanelPermissions* panelp = (LLPanelPermissions*)data; LLUUID owner_id; - LLString name; + std::string name; BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, name); LLFloater* parent_floater = gFloaterView->getParentFloater(panelp); @@ -1056,11 +1054,11 @@ void LLPanelPermissions::setAllSaleInfo() if (editPrice) { // Don't extract the price if it's labeled as MIXED or is empty. - const char *editPriceString = editPrice->getText().c_str(); - if (0 != strcmp(editPriceString,getString("Cost Mixed").c_str()) && - 0 != strcmp(editPriceString,"")) + const std::string& editPriceString = editPrice->getText(); + if (editPriceString != getString("Cost Mixed") && + !editPriceString.empty()) { - price = atoi(editPriceString); + price = atoi(editPriceString.c_str()); } else { diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp index 674515273b..9bd118fa1d 100644 --- a/indra/newview/llpanelpick.cpp +++ b/indra/newview/llpanelpick.cpp @@ -63,7 +63,7 @@ std::list<LLPanelPick*> LLPanelPick::sAllPanels; LLPanelPick::LLPanelPick(BOOL top_pick) -: LLPanel("Top Picks Panel"), +: LLPanel(std::string("Top Picks Panel")), mTopPick(top_pick), mPickID(), mCreatorID(), @@ -292,33 +292,33 @@ void LLPanelPick::processPickInfoReply(LLMessageSystem *msg, void **) LLUUID parcel_id; msg->getUUID("Data", "ParcelID", parcel_id); - char name[DB_PARCEL_NAME_SIZE]; /*Flawfinder: ignore*/ - msg->getString("Data", "Name", DB_PARCEL_NAME_SIZE, name); + std::string name; + msg->getString("Data", "Name", name); - char desc[DB_PICK_DESC_SIZE]; /*Flawfinder: ignore*/ - msg->getString("Data", "Desc", DB_PICK_DESC_SIZE, desc); + std::string desc; + msg->getString("Data", "Desc", desc); LLUUID snapshot_id; msg->getUUID("Data", "SnapshotID", snapshot_id); // "Location text" is actually the owner name, the original // name that owner gave the parcel, and the location. - char buffer[256]; /*Flawfinder: ignore*/ - LLString location_text; - - msg->getString("Data", "User", 256, buffer); - location_text.assign(buffer); + std::string location_text; + msg->getString("Data", "User", location_text); location_text.append(", "); - msg->getString("Data", "OriginalName", 256, buffer); - if (buffer[0] != '\0') + std::string original_name; + msg->getString("Data", "OriginalName", original_name); + if (!original_name.empty()) { - location_text.append(buffer); + location_text.append(original_name); location_text.append(", "); } - char sim_name[256]; /*Flawfinder: ignore*/ - msg->getString("Data", "SimName", 256, sim_name); + std::string sim_name; + msg->getString("Data", "SimName", sim_name); + location_text.append(sim_name); + location_text.append(" "); LLVector3d pos_global; msg->getVector3d("Data", "PosGlobal", pos_global); @@ -327,7 +327,7 @@ void LLPanelPick::processPickInfoReply(LLMessageSystem *msg, void **) S32 region_y = llround((F32)pos_global.mdV[VY]) % REGION_WIDTH_UNITS; S32 region_z = llround((F32)pos_global.mdV[VZ]); - location_text.append(llformat("%s (%d, %d, %d)", sim_name, region_x, region_y, region_z)); + location_text.append(llformat("(%d, %d, %d)", region_x, region_y, region_z)); S32 sort_order; msg->getS32("Data", "SortOrder", sort_order); @@ -355,8 +355,8 @@ void LLPanelPick::processPickInfoReply(LLMessageSystem *msg, void **) self->mPosGlobal = pos_global; // Update UI controls - self->mNameEditor->setText(LLString(name)); - self->mDescEditor->setText(LLString(desc)); + self->mNameEditor->setText(std::string(name)); + self->mDescEditor->setText(std::string(desc)); self->mSnapshotCtrl->setImageAssetID(snapshot_id); self->mLocationEditor->setText(location_text); self->mEnabledCheck->set(enabled); @@ -448,7 +448,7 @@ void LLPanelPick::onClickMap(void* data) void LLPanelPick::onClickLandmark(void* data) { LLPanelPick* self = (LLPanelPick*)data; - create_landmark(self->mNameEditor->getText().c_str(), "", self->mPosGlobal); + create_landmark(self->mNameEditor->getText(), "", self->mPosGlobal); } */ @@ -460,7 +460,7 @@ void LLPanelPick::onClickSet(void* data) // Save location for later. self->mPosGlobal = gAgent.getPositionGlobal(); - LLString location_text; + std::string location_text; location_text.assign("(will update after save)"); location_text.append(", "); @@ -500,7 +500,7 @@ void LLPanelPick::onCommitAny(LLUICtrl* ctrl, void* data) /*if (self->mTopPick) { LLPanelDirPicks* panel = (LLPanelDirPicks*)self->getParent(); - panel->renamePick(self->mPickID, self->mNameEditor->getText().c_str()); + panel->renamePick(self->mPickID, self->mNameEditor->getText()); } else {*/ diff --git a/indra/newview/llpanelpick.h b/indra/newview/llpanelpick.h index d0ab562e46..953021934b 100644 --- a/indra/newview/llpanelpick.h +++ b/indra/newview/llpanelpick.h @@ -103,7 +103,7 @@ protected: BOOL mDataRequested; BOOL mDataReceived; - LLString mSimName; + std::string mSimName; LLVector3d mPosGlobal; LLTextureCtrl* mSnapshotCtrl; diff --git a/indra/newview/llpanelplace.cpp b/indra/newview/llpanelplace.cpp index 9985486170..963394b749 100644 --- a/indra/newview/llpanelplace.cpp +++ b/indra/newview/llpanelplace.cpp @@ -61,7 +61,7 @@ std::list<LLPanelPlace*> LLPanelPlace::sAllPanels; LLPanelPlace::LLPanelPlace() -: LLPanel("Places Panel"), +: LLPanel(std::string("Places Panel")), mParcelID(), mRequestedID(), mRegionID(), @@ -91,7 +91,7 @@ BOOL LLPanelPlace::postBuild() mNameEditor = getChild<LLTextBox>("name_editor"); // Text boxes appear to have a " " in them by default. This breaks the // emptiness test for filling in data from the network. Slam to empty. - mNameEditor->setText( LLString::null ); + mNameEditor->setText( LLStringUtil::null ); mDescEditor = getChild<LLTextEditor>("desc_editor"); @@ -144,10 +144,10 @@ void LLPanelPlace::resetLocation() mPosGlobal.clearVec(); mPosRegion.clearVec(); mAuctionID = 0; - mNameEditor->setText( LLString::null ); - mDescEditor->setText( LLString::null ); - mInfoEditor->setText( LLString::null ); - mLocationEditor->setText( LLString::null ); + mNameEditor->setText( LLStringUtil::null ); + mDescEditor->setText( LLStringUtil::null ); + mInfoEditor->setText( LLStringUtil::null ); + mLocationEditor->setText( LLStringUtil::null ); } void LLPanelPlace::setParcelID(const LLUUID& parcel_id) @@ -187,7 +187,7 @@ void LLPanelPlace::sendParcelInfoRequest() void LLPanelPlace::setErrorStatus(U32 status, const std::string& reason) { // We only really handle 404 and 499 errors - LLString error_text; + std::string error_text; if(status == 404) { error_text = getString("server_error_text"); @@ -205,15 +205,15 @@ void LLPanelPlace::processParcelInfoReply(LLMessageSystem *msg, void **) LLUUID agent_id; LLUUID parcel_id; LLUUID owner_id; - char name[MAX_STRING]; /*Flawfinder: ignore*/ - char desc[MAX_STRING]; /*Flawfinder: ignore*/ + std::string name; + std::string desc; S32 actual_area; S32 billable_area; U8 flags; F32 global_x; F32 global_y; F32 global_z; - char sim_name[MAX_STRING]; /*Flawfinder: ignore*/ + std::string sim_name; LLUUID snapshot_id; F32 dwell; S32 sale_price; @@ -232,15 +232,15 @@ void LLPanelPlace::processParcelInfoReply(LLMessageSystem *msg, void **) } msg->getUUID ("Data", "OwnerID", owner_id); - msg->getString ("Data", "Name", MAX_STRING, name); - msg->getString ("Data", "Desc", MAX_STRING, desc); + msg->getString ("Data", "Name", name); + msg->getString ("Data", "Desc", desc); msg->getS32 ("Data", "ActualArea", actual_area); msg->getS32 ("Data", "BillableArea", billable_area); msg->getU8 ("Data", "Flags", flags); msg->getF32 ("Data", "GlobalX", global_x); msg->getF32 ("Data", "GlobalY", global_y); msg->getF32 ("Data", "GlobalZ", global_z); - msg->getString ("Data", "SimName", MAX_STRING, sim_name); + msg->getString ("Data", "SimName", sim_name); msg->getUUID ("Data", "SnapshotID", snapshot_id); msg->getF32 ("Data", "Dwell", dwell); msg->getS32 ("Data", "SalePrice", sale_price); @@ -256,22 +256,20 @@ void LLPanelPlace::processParcelInfoReply(LLMessageSystem *msg, void **) // Only assign the name and description if they are not empty and there is not a // value present (passed in from a landmark, e.g.) - std::string name_str(name); - std::string desc_str(desc); - if( !name_str.empty() + if( !name.empty() && self->mNameEditor && self->mNameEditor->getText().empty()) { - self->mNameEditor->setText(name_str); + self->mNameEditor->setText(name); } - if( !desc_str.empty() + if( !desc.empty() && self->mDescEditor && self->mDescEditor->getText().empty()) { - self->mDescEditor->setText(desc_str); + self->mDescEditor->setText(desc); } - LLString info_text; + std::string info_text; LLUIString traffic = self->getUIString("traffic_text"); traffic.setArg("[TRAFFIC]", llformat("%d ", (int)dwell)); info_text = traffic; @@ -296,7 +294,7 @@ void LLPanelPlace::processParcelInfoReply(LLMessageSystem *msg, void **) } // HACK: Flag 0x1 == mature region, otherwise assume PG - const char* rating = LLViewerRegion::accessToString(SIM_ACCESS_PG); + std::string rating = LLViewerRegion::accessToString(SIM_ACCESS_PG); if (flags & 0x1) { rating = LLViewerRegion::accessToString(SIM_ACCESS_MATURE); @@ -320,8 +318,8 @@ void LLPanelPlace::processParcelInfoReply(LLMessageSystem *msg, void **) self->mPosGlobal.setVec(global_x, global_y, global_z); } - LLString location = llformat("%s %d, %d, %d (%s)", - sim_name, region_x, region_y, region_z, rating); + std::string location = llformat("%s %d, %d, %d (%s)", + sim_name.c_str(), region_x, region_y, region_z, rating.c_str()); if (self->mLocationEditor) { self->mLocationEditor->setText(location); @@ -430,8 +428,8 @@ void LLPanelPlace::callbackAuctionWebPage(S32 option, void* data) if (0 == option) { - char url[256]; /*Flawfinder: ignore*/ - snprintf(url, sizeof(url), "%s%010d", AUCTION_URL, self->mAuctionID); /* Flawfinder: ignore */ + std::string url; + url = AUCTION_URL + llformat( "%010d", self->mAuctionID); llinfos << "Loading auction page " << url << llendl; diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index c96f35d8dd..7681514257 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -182,7 +182,7 @@ void LLPanelVolume::getState( ) BOOL owners_identical; LLUUID owner_id; - LLString owner_name; + std::string owner_name; owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); // BUG? Check for all objects being editable? diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp index 64315e9e30..fef4726b12 100644 --- a/indra/newview/llpolymesh.cpp +++ b/indra/newview/llpolymesh.cpp @@ -261,12 +261,12 @@ BOOL LLPolyMeshSharedData::allocateJointNames( U32 numJointNames ) //-------------------------------------------------------------------- // LLPolyMeshSharedData::loadMesh() //-------------------------------------------------------------------- -BOOL LLPolyMeshSharedData::loadMesh( const char *fileName ) +BOOL LLPolyMeshSharedData::loadMesh( const std::string& fileName ) { //------------------------------------------------------------------------- // Open the file //------------------------------------------------------------------------- - if(!fileName) + if(fileName.empty()) { llerrs << "Filename is Empty!" << llendl; return FALSE; @@ -595,7 +595,7 @@ BOOL LLPolyMeshSharedData::loadMesh( const char *fileName ) // we reached the end of the morphs break; } - LLPolyMorphData* morph_data = new LLPolyMorphData(morphName); + LLPolyMorphData* morph_data = new LLPolyMorphData(std::string(morphName)); BOOL result = morph_data->loadBinary(fp, this); @@ -761,7 +761,7 @@ LLPolyMesh::~LLPolyMesh() //----------------------------------------------------------------------------- // LLPolyMesh::getMesh() //----------------------------------------------------------------------------- -LLPolyMesh *LLPolyMesh::getMesh(const LLString &name, LLPolyMesh* reference_mesh) +LLPolyMesh *LLPolyMesh::getMesh(const std::string &name, LLPolyMesh* reference_mesh) { //------------------------------------------------------------------------- // search for an existing mesh by this name @@ -777,8 +777,8 @@ LLPolyMesh *LLPolyMesh::getMesh(const LLString &name, LLPolyMesh* reference_mesh //------------------------------------------------------------------------- // if not found, create a new one, add it to the list //------------------------------------------------------------------------- - char full_path[LL_MAX_PATH]; /*Flawfinder: ignore*/ - snprintf(full_path, LL_MAX_PATH, "%s", (gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,name.c_str())).c_str()); /* Flawfinder: ignore */ + std::string full_path; + full_path = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,name); LLPolyMeshSharedData *mesh_data = new LLPolyMeshSharedData(); if (reference_mesh) @@ -935,7 +935,7 @@ void LLPolyMesh::initializeForMorph() //----------------------------------------------------------------------------- // getMorphData() //----------------------------------------------------------------------------- -LLPolyMorphData* LLPolyMesh::getMorphData(const char *morph_name) +LLPolyMorphData* LLPolyMesh::getMorphData(const std::string& morph_name) { if (!mSharedData) return NULL; @@ -943,7 +943,7 @@ LLPolyMorphData* LLPolyMesh::getMorphData(const char *morph_name) iter != mSharedData->mMorphData.end(); ++iter) { LLPolyMorphData *morph_data = *iter; - if (!strcmp(morph_data->getName(), morph_name)) + if (morph_data->getName() == morph_name) { return morph_data; } @@ -1009,7 +1009,7 @@ BOOL LLPolySkeletalDistortionInfo::parseXml(LLXmlTreeNode* node) { if (bone->hasName("bone")) { - LLString name; + std::string name; LLVector3 scale; LLVector3 pos; BOOL haspos = FALSE; diff --git a/indra/newview/llpolymesh.h b/indra/newview/llpolymesh.h index 32e500e19d..2af9cbafae 100644 --- a/indra/newview/llpolymesh.h +++ b/indra/newview/llpolymesh.h @@ -134,7 +134,7 @@ private: U32 getNumKB(); // Load mesh data from file - BOOL loadMesh( const char *fileName ); + BOOL loadMesh( const std::string& fileName ); public: void genIndices(S32 offset); @@ -171,7 +171,7 @@ public: // Requests a mesh by name. // If the mesh already exists in the global mesh table, it is returned, // otherwise it is loaded from file, added to the table, and returned. - static LLPolyMesh *getMesh( const LLString &name, LLPolyMesh* reference_mesh = NULL); + static LLPolyMesh *getMesh( const std::string &name, LLPolyMesh* reference_mesh = NULL); // Frees all loaded meshes. // This should only be called once you know there are no outstanding @@ -311,7 +311,7 @@ public: return mSharedData->mJointNames; } - LLPolyMorphData* getMorphData(const char *morph_name); + LLPolyMorphData* getMorphData(const std::string& morph_name); // void removeMorphData(LLPolyMorphData *morph_target); // void deleteAllMorphData(); @@ -362,7 +362,7 @@ protected: LLPolyMesh *mReferenceMesh; // global mesh list - typedef std::map<LLString, LLPolyMeshSharedData*> LLPolyMeshSharedDataTable; + typedef std::map<std::string, LLPolyMeshSharedData*> LLPolyMeshSharedDataTable; static LLPolyMeshSharedDataTable sGlobalSharedMeshList; // Backlink only; don't make this an LLPointer. @@ -375,12 +375,12 @@ protected: //----------------------------------------------------------------------------- struct LLPolySkeletalBoneInfo { - LLPolySkeletalBoneInfo(LLString &name, LLVector3 &scale, LLVector3 &pos, BOOL haspos) + LLPolySkeletalBoneInfo(std::string &name, LLVector3 &scale, LLVector3 &pos, BOOL haspos) : mBoneName(name), mScaleDeformation(scale), mPositionDeformation(pos), mHasPositionDeformation(haspos) {} - LLString mBoneName; + std::string mBoneName; LLVector3 mScaleDeformation; LLVector3 mPositionDeformation; BOOL mHasPositionDeformation; diff --git a/indra/newview/llpolymorph.cpp b/indra/newview/llpolymorph.cpp index 572a495f70..eafd8201ce 100644 --- a/indra/newview/llpolymorph.cpp +++ b/indra/newview/llpolymorph.cpp @@ -46,13 +46,9 @@ const F32 NORMAL_SOFTEN_FACTOR = 0.65f; //----------------------------------------------------------------------------- // LLPolyMorphData() //----------------------------------------------------------------------------- -LLPolyMorphData::LLPolyMorphData(char *morph_name) +LLPolyMorphData::LLPolyMorphData(const std::string& morph_name) + : mName(morph_name) { - llassert (morph_name); - - mName = new char[strlen(morph_name) + 1]; /*Flawfinder: ignore*/ - strcpy(mName, morph_name); /*Flawfinder: ignore*/ - mNumIndices = 0; mCurrentIndex = 0; mTotalDistortion = 0.f; @@ -72,7 +68,6 @@ LLPolyMorphData::LLPolyMorphData(char *morph_name) //----------------------------------------------------------------------------- LLPolyMorphData::~LLPolyMorphData() { - delete [] mName; delete [] mVertexIndices; delete [] mCoords; delete [] mNormals; @@ -226,7 +221,7 @@ BOOL LLPolyMorphTargetInfo::parseXml(LLXmlTreeNode* node) static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); if (child_node->hasName("volume_morph")) { - LLString volume_name; + std::string volume_name; if (child_node->getFastAttributeString(name_string, volume_name)) { LLVector3 scale; @@ -284,10 +279,9 @@ BOOL LLPolyMorphTarget::setInfo(LLPolyMorphTargetInfo* info) for (iter = getInfo()->mVolumeInfoList.begin(); iter != getInfo()->mVolumeInfoList.end(); iter++) { LLPolyVolumeMorphInfo *volume_info = &(*iter); - std::string vol_string(volume_info->mName); for (S32 i = 0; i < avatarp->mNumCollisionVolumes; i++) { - if (avatarp->mCollisionVolumes[i].getName() == vol_string) + if (avatarp->mCollisionVolumes[i].getName() == volume_info->mName) { mVolumeMorphs.push_back(LLPolyVolumeMorph(&avatarp->mCollisionVolumes[i], volume_info->mScale, @@ -297,7 +291,7 @@ BOOL LLPolyMorphTarget::setInfo(LLPolyMorphTargetInfo* info) } } - mMorphData = mMesh->getMorphData(getInfo()->mMorphName.c_str()); + mMorphData = mMesh->getMorphData(getInfo()->mMorphName); if (!mMorphData) { llwarns << "No morph target named " << getInfo()->mMorphName << " found in mesh." << llendl; diff --git a/indra/newview/llpolymorph.h b/indra/newview/llpolymorph.h index 8b4493ce86..71903cdbe0 100644 --- a/indra/newview/llpolymorph.h +++ b/indra/newview/llpolymorph.h @@ -48,15 +48,14 @@ class LLViewerJointCollisionVolume; class LLPolyMorphData { public: - LLPolyMorphData(char *morph_name); + LLPolyMorphData(const std::string& morph_name); ~LLPolyMorphData(); BOOL loadBinary(LLFILE* fp, LLPolyMeshSharedData *mesh); - char* loadASCII(char* text, LLPolyMeshSharedData *mesh); - char* getName() { return mName; } + const std::string& getName() { return mName; } public: - char* mName; + std::string mName; // morphology U32 mNumIndices; @@ -98,10 +97,10 @@ protected: //----------------------------------------------------------------------------- struct LLPolyVolumeMorphInfo { - LLPolyVolumeMorphInfo(LLString &name, LLVector3 &scale, LLVector3 &pos) + LLPolyVolumeMorphInfo(std::string &name, LLVector3 &scale, LLVector3 &pos) : mName(name), mScale(scale), mPos(pos) {}; - LLString mName; + std::string mName; LLVector3 mScale; LLVector3 mPos; }; @@ -130,7 +129,7 @@ public: /*virtual*/ BOOL parseXml(LLXmlTreeNode* node); protected: - LLString mMorphName; + std::string mMorphName; BOOL mIsClothingMorph; typedef std::vector<LLPolyVolumeMorphInfo> volume_info_list_t; volume_info_list_t mVolumeInfoList; diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp index d5f91596e8..7efafe17b2 100644 --- a/indra/newview/llpreview.cpp +++ b/indra/newview/llpreview.cpp @@ -541,7 +541,7 @@ void LLPreview::userSetShape(const LLRect& new_rect) // LLMultiPreview // -LLMultiPreview::LLMultiPreview(const LLRect& rect) : LLMultiFloater("Preview", rect) +LLMultiPreview::LLMultiPreview(const LLRect& rect) : LLMultiFloater(std::string("Preview"), rect) { setCanResize(TRUE); } diff --git a/indra/newview/llpreviewanim.h b/indra/newview/llpreviewanim.h index 28b09a49dd..5d2e4b4c27 100644 --- a/indra/newview/llpreviewanim.h +++ b/indra/newview/llpreviewanim.h @@ -53,7 +53,7 @@ protected: LLAnimPauseRequest mPauseRequest; LLUUID mItemID; - LLString mTitle; + std::string mTitle; LLUUID mObjectID; LLButton* mPlayBtn; LLButton* mAuditionBtn; diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 9b86690088..7661f9acd6 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -72,9 +72,9 @@ // *TODO: Translate? -const char NONE_LABEL[] = "---"; -const char SHIFT_LABEL[] = "Shift"; -const char CTRL_LABEL[] = "Ctrl"; +const std::string NONE_LABEL = "---"; +const std::string SHIFT_LABEL = "Shift"; +const std::string CTRL_LABEL = "Ctrl"; void dialog_refresh_all(); @@ -111,7 +111,7 @@ struct SortItemPtrsByName { bool operator()(const LLInventoryItem* i1, const LLInventoryItem* i2) { - return (LLString::compareDict(i1->getName(), i2->getName()) < 0); + return (LLStringUtil::compareDict(i1->getName(), i2->getName()) < 0); } }; @@ -203,7 +203,7 @@ BOOL LLPreviewGesture::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL handled = TRUE; switch(cargo_type) @@ -584,7 +584,7 @@ void LLPreviewGesture::addAnimations() combo->removeall(); - LLString none_text = getString("none_text"); + std::string none_text = getString("none_text"); combo->add(none_text, LLUUID::null); @@ -639,7 +639,7 @@ void LLPreviewGesture::addSounds() LLComboBox* combo = mSoundCombo; combo->removeall(); - LLString none_text = getString("none_text"); + std::string none_text = getString("none_text"); combo->add(none_text, LLUUID::null); @@ -775,7 +775,7 @@ void LLPreviewGesture::refresh() mWaitTimeCheck->setVisible(FALSE); mWaitTimeEditor->setVisible(FALSE); - LLString optionstext; + std::string optionstext; if (have_step) { @@ -995,13 +995,13 @@ void LLPreviewGesture::loadUIFromGesture(LLMultiGesture* gesture) { default: case MASK_NONE: - mModifierCombo->setSimple( LLString(NONE_LABEL) ); + mModifierCombo->setSimple( NONE_LABEL ); break; case MASK_SHIFT: - mModifierCombo->setSimple( LLString(SHIFT_LABEL) ); + mModifierCombo->setSimple( SHIFT_LABEL ); break; case MASK_CONTROL: - mModifierCombo->setSimple( LLString(CTRL_LABEL) ); + mModifierCombo->setSimple( CTRL_LABEL ); break; } @@ -1075,7 +1075,7 @@ void LLPreviewGesture::loadUIFromGesture(LLMultiGesture* gesture) // after the save finishes. struct LLSaveInfo { - LLSaveInfo(const LLUUID& item_id, const LLUUID& object_id, const LLString& desc, + LLSaveInfo(const LLUUID& item_id, const LLUUID& object_id, const std::string& desc, const LLTransactionID tid) : mItemUUID(item_id), mObjectUUID(object_id), mDesc(desc), mTransactionID(tid) { @@ -1083,7 +1083,7 @@ struct LLSaveInfo LLUUID mItemUUID; LLUUID mObjectUUID; - LLString mDesc; + std::string mDesc; LLTransactionID mTransactionID; }; @@ -1274,7 +1274,7 @@ void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data, else { llwarns << "Problem saving gesture: " << status << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("GestureSaveFailedReason",args); } @@ -1290,7 +1290,7 @@ LLMultiGesture* LLPreviewGesture::createGesture() gesture->mTrigger = mTriggerEditor->getText(); gesture->mReplaceText = mReplaceEditor->getText(); - const LLString& modifier = mModifierCombo->getSimple(); + const std::string& modifier = mModifierCombo->getSimple(); if (modifier == CTRL_LABEL) { gesture->mMask = MASK_CONTROL; @@ -1310,8 +1310,8 @@ LLMultiGesture* LLPreviewGesture::createGesture() } else { - const LLString& key_string = mKeyCombo->getSimple(); - LLKeyboard::keyFromString(key_string.c_str(), &(gesture->mKey)); + const std::string& key_string = mKeyCombo->getSimple(); + LLKeyboard::keyFromString(key_string, &(gesture->mKey)); } std::vector<LLScrollListItem*> data_list = mStepList->getAllData(); @@ -1609,19 +1609,19 @@ void LLPreviewGesture::onClickAdd(void* data) LLScrollListItem* LLPreviewGesture::addStep(const std::string& library_text) { LLGestureStep* step = NULL; - if (!LLString::compareInsensitive(library_text.c_str(), "Animation")) + if (!LLStringUtil::compareInsensitive(library_text, "Animation")) { step = new LLGestureStepAnimation(); } - else if (!LLString::compareInsensitive(library_text.c_str(), "Sound")) + else if (!LLStringUtil::compareInsensitive(library_text, "Sound")) { step = new LLGestureStepSound(); } - else if (!LLString::compareInsensitive(library_text.c_str(), "Chat")) + else if (!LLStringUtil::compareInsensitive(library_text, "Chat")) { step = new LLGestureStepChat(); } - else if (!LLString::compareInsensitive(library_text.c_str(), "Wait")) + else if (!LLStringUtil::compareInsensitive(library_text, "Wait")) { step = new LLGestureStepWait(); } diff --git a/indra/newview/llpreviewgesture.h b/indra/newview/llpreviewgesture.h index b4fa63b69b..3b07608134 100644 --- a/indra/newview/llpreviewgesture.h +++ b/indra/newview/llpreviewgesture.h @@ -58,7 +58,7 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); // LLPanel virtual BOOL postBuild(); diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index f9e1fc04dc..61ebe6cbbc 100644 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -281,7 +281,7 @@ void LLPreviewNotecard::loadAsset() mAssetID = item->getAssetUUID(); if(mAssetID.isNull()) { - editor->setText(LLString::null); + editor->setText(LLStringUtil::null); editor->makePristine(); editor->setEnabled(TRUE); mAssetStatus = PREVIEW_ASSET_LOADED; @@ -341,7 +341,7 @@ void LLPreviewNotecard::loadAsset() } else { - editor->setText(LLString::null); + editor->setText(LLStringUtil::null); editor->makePristine(); editor->setEnabled(TRUE); mAssetStatus = PREVIEW_ASSET_LOADED; @@ -376,7 +376,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) ) { - if( !previewEditor->importBuffer( buffer ) ) + if( !previewEditor->importBuffer( buffer, file_length+1 ) ) { llwarns << "Problem importing notecard" << llendl; } @@ -479,7 +479,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND); - LLString buffer; + std::string buffer; if (!editor->exportBuffer(buffer)) { return false; @@ -601,15 +601,15 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data else { llwarns << "Problem saving notecard: " << status << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("SaveNotecardFailReason",args); } - char uuid_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ + std::string uuid_string; asset_uuid.toString(uuid_string); - char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ - snprintf(filename, LL_MAX_PATH, "%s.tmp", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */ + std::string filename; + filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".tmp"; LLFile::remove(filename); delete info; } diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 2d87cae69b..75e8f52cfc 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -88,7 +88,7 @@ #include "llpanelinventory.h" -const char HELLO_LSL[] = +const std::string HELLO_LSL = "default\n" "{\n" " state_entry()\n" @@ -101,10 +101,10 @@ const char HELLO_LSL[] = " llSay(0, \"Touched.\");\n" " }\n" "}\n"; -const char HELP_LSL[] = "lsl_guide.html"; +const std::string HELP_LSL = "lsl_guide.html"; -const char DEFAULT_SCRIPT_NAME[] = "New Script"; // *TODO:Translate? -const char DEFAULT_SCRIPT_DESC[] = "(No Description)"; // *TODO:Translate? +const std::string DEFAULT_SCRIPT_NAME = "New Script"; // *TODO:Translate? +const std::string DEFAULT_SCRIPT_DESC = "(No Description)"; // *TODO:Translate? // Description and header information @@ -173,7 +173,7 @@ private: LLFloaterScriptSearch* LLFloaterScriptSearch::sInstance = NULL; LLFloaterScriptSearch::LLFloaterScriptSearch(std::string title, LLRect rect, LLScriptEdCore* editor_core) - : LLFloater("script search",rect,title), mEditorCore(editor_core) + : LLFloater(std::string("script search"),rect,title), mEditorCore(editor_core) { LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_search.xml"); @@ -296,7 +296,7 @@ LLScriptEdCore::LLScriptEdCore( void* userdata, S32 bottom_pad) : - LLPanel( "name", rect ), + LLPanel( std::string("name"), rect ), mSampleText(sample), mHelpFile ( help ), mEditor( NULL ), @@ -326,15 +326,15 @@ LLScriptEdCore::LLScriptEdCore( mEditor->setEnabled(TRUE); mEditor->setWordWrap(TRUE); - LLDynamicArray<const char*> funcs; - LLDynamicArray<const char*> tooltips; + std::vector<std::string> funcs; + std::vector<std::string> tooltips; for (S32 i = 0; i < gScriptLibrary.mNextNumber; i++) { // Make sure this isn't a god only function, or the agent is a god. if (!gScriptLibrary.mFunctions[i]->mGodOnly || gAgent.isGodlike()) { - funcs.put(gScriptLibrary.mFunctions[i]->mName); - tooltips.put(gScriptLibrary.mFunctions[i]->mDesc); + funcs.push_back(ll_safe_string(gScriptLibrary.mFunctions[i]->mName)); + tooltips.push_back(ll_safe_string(gScriptLibrary.mFunctions[i]->mDesc)); } } LLColor3 color(0.5f, 0.0f, 0.15f); @@ -458,7 +458,7 @@ void LLScriptEdCore::draw() } else { - childSetText("line_col", LLString::null); + childSetText("line_col", LLStringUtil::null); } updateDynamicHelp(); @@ -517,18 +517,18 @@ void LLScriptEdCore::updateDynamicHelp(BOOL immediate) } if (immediate || (mLiveHelpTimer.getStarted() && mLiveHelpTimer.getElapsedTimeF32() > LIVE_HELP_REFRESH_TIME)) { - LLString help_string = mEditor->getText().substr(segment->getStart(), segment->getEnd() - segment->getStart()); + std::string help_string = mEditor->getText().substr(segment->getStart(), segment->getEnd() - segment->getStart()); setHelpPage(help_string); mLiveHelpTimer.stop(); } } else if (immediate) { - setHelpPage(""); + setHelpPage(LLStringUtil::null); } } -void LLScriptEdCore::setHelpPage(const LLString& help_string) +void LLScriptEdCore::setHelpPage(const std::string& help_string) { LLFloater* help_floater = mLiveHelpHandle.get(); if (!help_floater) return; @@ -549,7 +549,7 @@ void LLScriptEdCore::setHelpPage(const LLString& help_string) } -void LLScriptEdCore::addHelpItemToHistory(const LLString& help_string) +void LLScriptEdCore::addHelpItemToHistory(const std::string& help_string) { if (help_string.empty()) return; @@ -640,7 +640,7 @@ void LLScriptEdCore::onHelpWebDialog(S32 option, void* userdata) switch(option) { case 0: - load_url_local_file(corep->mHelpFile.c_str()); + load_url_local_file(corep->mHelpFile); break; default: break; @@ -669,7 +669,7 @@ void LLScriptEdCore::onBtnDynamicHelp(void* userdata) return; } - live_help_floater = new LLFloater("lsl_help"); + live_help_floater = new LLFloater(std::string("lsl_help")); LLUICtrlFactory::getInstance()->buildFloater(live_help_floater, "floater_lsl_guide.xml"); ((LLFloater*)corep->getParent())->addDependentFloater(live_help_floater, TRUE); live_help_floater->childSetCommitCallback("lock_check", onCheckLock, userdata); @@ -760,7 +760,7 @@ void LLScriptEdCore::onHelpComboCommit(LLUICtrl* ctrl, void* userdata) LLFloater* live_help_floater = corep->mLiveHelpHandle.get(); if (live_help_floater) { - LLString help_string = ctrl->getValue().asString(); + std::string help_string = ctrl->getValue().asString(); corep->addHelpItemToHistory(help_string); @@ -947,10 +947,10 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data) S32 row = 0; S32 column = 0; const LLScrollListCell* cell = item->getColumn(0); - LLString line(cell->getValue().asString()); + std::string line(cell->getValue().asString()); line.erase(0, 1); - LLString::replaceChar(line, ',',' '); - LLString::replaceChar(line, ')',' '); + LLStringUtil::replaceChar(line, ',',' '); + LLStringUtil::replaceChar(line, ')',' '); sscanf(line.c_str(), "%d %d", &row, &column); //llinfos << "LLScriptEdCore::onErrorList() - " << row << ", " //<< column << llendl; @@ -1047,10 +1047,10 @@ BOOL LLScriptEdCore::handleKeyHere(KEY key, MASK mask) struct LLScriptSaveInfo { LLUUID mItemUUID; - LLString mDescription; + std::string mDescription; LLTransactionID mTransactionID; - LLScriptSaveInfo(const LLUUID& uuid, const LLString& desc, LLTransactionID tid) : + LLScriptSaveInfo(const LLUUID& uuid, const std::string& desc, LLTransactionID tid) : mItemUUID(uuid), mDescription(desc), mTransactionID(tid) {} }; @@ -1117,8 +1117,9 @@ LLPreviewLSL::LLPreviewLSL(const std::string& name, const LLRect& rect, void LLPreviewLSL::callbackLSLCompileSucceeded() { llinfos << "LSL Bytecode saved" << llendl; - mScriptEd->mErrorList->addCommentText("Compile successful!"); - mScriptEd->mErrorList->addCommentText("Save complete."); + // *TODO: Translate + mScriptEd->mErrorList->addCommentText(std::string("Compile successful!")); + mScriptEd->mErrorList->addCommentText(std::string("Save complete.")); closeIfNeeded(); } @@ -1189,7 +1190,7 @@ void LLPreviewLSL::loadAsset() } else { - mScriptEd->mEditor->setText(LLString(HELLO_LSL)); + mScriptEd->mEditor->setText(std::string(HELLO_LSL)); mAssetStatus = PREVIEW_ASSET_LOADED; } } @@ -1260,9 +1261,9 @@ void LLPreviewLSL::saveIfNeeded() tid.generate(); LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id.asString()); - std::string filename = llformat("%s.lsl", filepath.c_str()); + std::string filename = filepath + ".lsl"; - LLFILE* fp = LLFile::fopen(filename.c_str(), "wb"); + LLFILE* fp = LLFile::fopen(filename, "wb"); if(!fp) { llwarns << "Unable to write to " << filename << llendl; @@ -1274,7 +1275,7 @@ void LLPreviewLSL::saveIfNeeded() return; } - LLString utf8text = mScriptEd->mEditor->getText(); + std::string utf8text = mScriptEd->mEditor->getText(); fputs(utf8text.c_str(), fp); fclose(fp); fp = NULL; @@ -1315,7 +1316,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, LLScriptSaveInfo* info = new LLScriptSaveInfo(item_id, descEditor->getText(), tid); - gAssetStorage->storeAssetData(filename.c_str(), tid, + gAssetStorage->storeAssetData(filename, tid, LLAssetType::AT_LSL_TEXT, &LLPreviewLSL::onSaveComplete, info); @@ -1332,15 +1333,15 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, { llinfos << "Compile failed!" << llendl; //char command[256]; - //sprintf(command, "type %s\n", err_filename); + //sprintf(command, "type %s\n", err_filename.c_str()); //system(command); // load the error file into the error scrolllist - LLFILE* fp = LLFile::fopen(err_filename.c_str(), "r"); + LLFILE* fp = LLFile::fopen(err_filename, "r"); if(fp) { char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - LLString line; + std::string line; while(!feof(fp)) { if (fgets(buffer, MAX_STRING, fp) == NULL) @@ -1354,7 +1355,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, else { line.assign(buffer); - LLString::stripNonprintable(line); + LLStringUtil::stripNonprintable(line); LLSD row; row["columns"][0]["value"] = line; @@ -1374,7 +1375,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, getWindow()->incBusyCount(); mPendingUploads++; LLUUID* this_uuid = new LLUUID(mItemUUID); - gAssetStorage->storeAssetData(dst_filename.c_str(), + gAssetStorage->storeAssetData(dst_filename, tid, LLAssetType::AT_LSL_BYTECODE, &LLPreviewLSL::onSaveBytecodeComplete, @@ -1383,9 +1384,9 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, } // get rid of any temp files left lying around - LLFile::remove(filename.c_str()); - LLFile::remove(err_filename.c_str()); - LLFile::remove(dst_filename.c_str()); + LLFile::remove(filename); + LLFile::remove(err_filename); + LLFile::remove(dst_filename); } @@ -1431,7 +1432,7 @@ void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 else { llwarns << "Problem saving script: " << status << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("SaveScriptFailReason", args); } @@ -1469,7 +1470,7 @@ void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_d else { llwarns << "Problem saving LSL Bytecode (Preview)" << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("SaveBytecodeFailReason", args); } @@ -1661,8 +1662,9 @@ void LLLiveLSLEditor::callbackLSLCompileSucceeded(const LLUUID& task_id, bool is_script_running) { lldebugs << "LSL Bytecode saved" << llendl; - mScriptEd->mErrorList->addCommentText("Compile successful!"); - mScriptEd->mErrorList->addCommentText("Save complete."); + // *TODO: Translate + mScriptEd->mErrorList->addCommentText(std::string("Compile successful!")); + mScriptEd->mErrorList->addCommentText(std::string("Save complete.")); closeIfNeeded(); } @@ -1738,7 +1740,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) } else { - mScriptEd->mEditor->setText(LLString::null); + mScriptEd->mEditor->setText(LLStringUtil::null); mScriptEd->mEditor->makePristine(); mAssetStatus = PREVIEW_ASSET_LOADED; } @@ -1773,7 +1775,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) // This may be better than having a accessible null pointer around, // though this newly allocated object will most likely be replaced. mItem = new LLViewerInventoryItem(); - mScriptEd->mEditor->setText(LLString::null); + mScriptEd->mEditor->setText(LLStringUtil::null); mScriptEd->mEditor->makePristine(); mScriptEd->mEditor->setEnabled(FALSE); mAssetStatus = PREVIEW_ASSET_LOADED; @@ -1781,8 +1783,8 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new) } else { - mScriptEd->mEditor->setText(LLString(HELLO_LSL)); - //mScriptEd->mEditor->setText(LLString::null); + mScriptEd->mEditor->setText(std::string(HELLO_LSL)); + //mScriptEd->mEditor->setText(LLStringUtil::null); //mScriptEd->mEditor->makePristine(); LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, gAgent.getGroupID()); @@ -1844,37 +1846,38 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id, delete xored_id; } -void LLLiveLSLEditor::loadScriptText(const char* filename) -{ - if(!filename) - { - llerrs << "Filename is Empty!" << llendl; - return; - } - LLFILE* file = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ - if(file) - { - // read in the whole file - fseek(file, 0L, SEEK_END); - long file_length = ftell(file); - fseek(file, 0L, SEEK_SET); - char* buffer = new char[file_length+1]; - size_t nread = fread(buffer, 1, file_length, file); - if (nread < (size_t) file_length) - { - llwarns << "Short read" << llendl; - } - buffer[nread] = '\0'; - fclose(file); - mScriptEd->mEditor->setText(LLStringExplicit(buffer)); - mScriptEd->mEditor->makePristine(); - delete[] buffer; - } - else - { - llwarns << "Error opening " << filename << llendl; - } -} +// unused +// void LLLiveLSLEditor::loadScriptText(const std::string& filename) +// { +// if(!filename) +// { +// llerrs << "Filename is Empty!" << llendl; +// return; +// } +// LLFILE* file = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ +// if(file) +// { +// // read in the whole file +// fseek(file, 0L, SEEK_END); +// long file_length = ftell(file); +// fseek(file, 0L, SEEK_SET); +// char* buffer = new char[file_length+1]; +// size_t nread = fread(buffer, 1, file_length, file); +// if (nread < (size_t) file_length) +// { +// llwarns << "Short read" << llendl; +// } +// buffer[nread] = '\0'; +// fclose(file); +// mScriptEd->mEditor->setText(LLStringExplicit(buffer)); +// mScriptEd->mEditor->makePristine(); +// delete[] buffer; +// } +// else +// { +// llwarns << "Error opening " << filename << llendl; +// } +// } void LLLiveLSLEditor::loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type) { @@ -1974,7 +1977,8 @@ void LLLiveLSLEditor::draw() { // HACK: Display this information in the title bar. // Really ought to put in main window. - setTitle("Script (object out of range)"); + // *TODO: Translate + setTitle(std::string("Script (object out of range)")); runningCheckbox->setEnabled(FALSE); // object may have fallen out of range. mHaveRunningInfo = FALSE; @@ -2063,7 +2067,7 @@ void LLLiveLSLEditor::saveIfNeeded() mItem->setTransactionID(tid); // write out the data, and store it in the asset database - LLFILE* fp = LLFile::fopen(filename.c_str(), "wb"); + LLFILE* fp = LLFile::fopen(filename, "wb"); if(!fp) { llwarns << "Unable to write to " << filename << llendl; @@ -2074,7 +2078,7 @@ void LLLiveLSLEditor::saveIfNeeded() mScriptEd->mErrorList->addElement(row); return; } - LLString utf8text = mScriptEd->mEditor->getText(); + std::string utf8text = mScriptEd->mEditor->getText(); // Special case for a completely empty script - stuff in one space so it can store properly. See SL-46889 if ( utf8text.size() == 0 ) @@ -2125,7 +2129,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, LLLiveLSLSaveData* data = new LLLiveLSLSaveData(mObjectID, mItem, is_running); - gAssetStorage->storeAssetData(filename.c_str(), tid, + gAssetStorage->storeAssetData(filename, tid, LLAssetType::AT_LSL_TEXT, &onSaveTextComplete, (void*)data, @@ -2144,10 +2148,10 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, { // load the error file into the error scrolllist llinfos << "Compile failed!" << llendl; - if(NULL != (fp = LLFile::fopen(err_filename.c_str(), "r"))) + if(NULL != (fp = LLFile::fopen(err_filename, "r"))) { char buffer[MAX_STRING]; /*Flawfinder: ignore*/ - LLString line; + std::string line; while(!feof(fp)) { @@ -2162,7 +2166,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, else { line.assign(buffer); - LLString::stripNonprintable(line); + LLStringUtil::stripNonprintable(line); LLSD row; row["columns"][0]["value"] = line; @@ -2182,7 +2186,8 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, else { llinfos << "Compile worked!" << llendl; - mScriptEd->mErrorList->addCommentText("Compile successful, saving..."); + // *TODO: Translate + mScriptEd->mErrorList->addCommentText(std::string("Compile successful, saving...")); if(gAssetStorage) { llinfos << "LLLiveLSLEditor::saveAsset " @@ -2193,7 +2198,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, data = new LLLiveLSLSaveData(mObjectID, mItem, is_running); - gAssetStorage->storeAssetData(dst_filename.c_str(), + gAssetStorage->storeAssetData(dst_filename, tid, LLAssetType::AT_LSL_BYTECODE, &LLLiveLSLEditor::onSaveBytecodeComplete, @@ -2203,9 +2208,9 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, } // get rid of any temp files left lying around - LLFile::remove(filename.c_str()); - LLFile::remove(err_filename.c_str()); - LLFile::remove(dst_filename.c_str()); + LLFile::remove(filename); + LLFile::remove(err_filename); + LLFile::remove(dst_filename); // If we successfully saved it, then we should be able to check/uncheck the running box! LLCheckBoxCtrl* runningCheckbox = getChild<LLCheckBoxCtrl>( "running"); @@ -2220,7 +2225,7 @@ void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_da if (status) { llwarns << "Unable to save text for a script." << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("CompileQueueSaveText", args); } @@ -2256,7 +2261,8 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use if(self) { // Tell the user that the compile worked. - self->mScriptEd->mErrorList->addCommentText("Save complete."); + // *TODO: Translate + self->mScriptEd->mErrorList->addCommentText(std::string("Save complete.")); // close the window if this completes both uploads self->getWindow()->decBusyCount(); self->mPendingUploads--; @@ -2280,14 +2286,14 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use llinfos << "Problem saving LSL Bytecode (Live Editor)" << llendl; llwarns << "Unable to save a compiled script." << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); gViewerWindow->alertXml("CompileQueueSaveBytecode", args); } std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_uuid.asString()); std::string dst_filename = llformat("%s.lso", filepath.c_str()); - LLFile::remove(dst_filename.c_str()); + LLFile::remove(dst_filename); delete data; } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index d7d96e2037..aec4bb2ab7 100644 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -121,16 +121,16 @@ public: protected: void deleteBridges(); - void setHelpPage(const LLString& help_string); + void setHelpPage(const std::string& help_string); void updateDynamicHelp(BOOL immediate = FALSE); - void addHelpItemToHistory(const LLString& help_string); + void addHelpItemToHistory(const std::string& help_string); static void onErrorList(LLUICtrl*, void* user_data); virtual const char *getTitleName() const { return "Script"; } private: - LLString mSampleText; + std::string mSampleText; std::string mHelpFile; LLTextEditor* mEditor; void (*mLoadCallback)(void* userdata); @@ -253,7 +253,7 @@ protected: static void onRunningCheckboxClicked(LLUICtrl*, void* userdata); static void onReset(void* userdata); - void loadScriptText(const char* filename); +// void loadScriptText(const std::string& filename); // unused void loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type); static void onErrorList(LLUICtrl*, void* user_data); @@ -279,7 +279,4 @@ protected: static LLMap<LLUUID, LLLiveLSLEditor*> sInstances; }; -// name of help file for lsl -extern const char HELP_LSL[]; - #endif // LL_LLPREVIEWSCRIPT_H diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index e94e323850..6f2c57c055 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -240,7 +240,8 @@ void LLPreviewTexture::draw() if( mLoadingFullImage ) { - LLFontGL::sSansSerif->renderUTF8("Receiving:", 0, + // *TODO: Translate + LLFontGL::sSansSerif->renderUTF8(std::string("Receiving:"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, @@ -276,7 +277,8 @@ void LLPreviewTexture::draw() else if( !mSavedFileTimer.hasExpired() ) { - LLFontGL::sSansSerif->renderUTF8("File Saved", 0, + // *TODO: Translate + LLFontGL::sSansSerif->renderUTF8(std::string("File Saved"), 0, interior.mLeft + 4, interior.mBottom + 4, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM, @@ -349,13 +351,13 @@ void LLPreviewTexture::onFileLoadedForSave(BOOL success, LLPointer<LLImageTGA> image_tga = new LLImageTGA; if( !image_tga->encode( src ) ) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[FILE]"] = self->mSaveFileName; gViewerWindow->alertXml("CannotEncodeFile", args); } else if( !image_tga->save( self->mSaveFileName ) ) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[FILE]"] = self->mSaveFileName; gViewerWindow->alertXml("CannotWriteFile", args); } diff --git a/indra/newview/llpreviewtexture.h b/indra/newview/llpreviewtexture.h index 6cb5aebfa9..30feb79e77 100644 --- a/indra/newview/llpreviewtexture.h +++ b/indra/newview/llpreviewtexture.h @@ -86,7 +86,7 @@ private: LLUUID mImageID; LLPointer<LLViewerImage> mImage; BOOL mLoadingFullImage; - LLString mSaveFileName; + std::string mSaveFileName; LLFrameTimer mSavedFileTimer; BOOL mShowKeepDiscard; BOOL mCopyToInv; diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp index e5b063e6d7..9df60d67b5 100644 --- a/indra/newview/llprogressview.cpp +++ b/indra/newview/llprogressview.cpp @@ -59,8 +59,8 @@ S32 gStartImageWidth = 1; S32 gStartImageHeight = 1; const F32 FADE_IN_TIME = 1.f; -const LLString ANIMATION_FILENAME = "Login Sequence "; -const LLString ANIMATION_SUFFIX = ".jpg"; +const std::string ANIMATION_FILENAME = "Login Sequence "; +const std::string ANIMATION_SUFFIX = ".jpg"; const F32 TOTAL_LOGIN_TIME = 10.f; // seconds, wild guess at time from GL context to actual world view S32 gLastStartAnimationFrame = 0; // human-style indexing, first image = 1 const S32 ANIMATION_FRAMES = 1; //13; @@ -78,12 +78,11 @@ LLProgressView::LLProgressView(const std::string& name, const LLRect &rect) getRect().getWidth() - CANCEL_BTN_OFFSET - CANCEL_BTN_WIDTH, CANCEL_BTN_OFFSET, CANCEL_BTN_WIDTH, BTN_HEIGHT ); - mCancelBtn = new LLButton( - "Quit", - r, - "", - LLProgressView::onCancelButtonClicked, - NULL ); + mCancelBtn = new LLButton(std::string("Quit"), + r, + std::string(""), + LLProgressView::onCancelButtonClicked, + NULL ); mCancelBtn->setFollows( FOLLOWS_RIGHT | FOLLOWS_BOTTOM ); addChild( mCancelBtn ); mFadeTimer.stop(); @@ -264,7 +263,7 @@ void LLProgressView::draw() F32 alpha = 0.5f + 0.5f*0.5f*(1.f + (F32)sin(3.f*timer.getElapsedTimeF32())); // background_color.mV[3] = background_color.mV[3]*alpha; - LLString top_line = LLAppViewer::instance()->getSecondLifeTitle(); + std::string top_line = LLAppViewer::instance()->getSecondLifeTitle(); S32 bar_bottom = line_two_y - 30; S32 bar_height = 18; @@ -380,7 +379,7 @@ void LLProgressView::draw() LLView::draw(); } -void LLProgressView::setText(const LLString& text) +void LLProgressView::setText(const std::string& text) { mText = text; } @@ -390,12 +389,12 @@ void LLProgressView::setPercent(const F32 percent) mPercentDone = llclamp(percent, 0.f, 100.f); } -void LLProgressView::setMessage(const LLString& msg) +void LLProgressView::setMessage(const std::string& msg) { mMessage = msg; } -void LLProgressView::setCancelButtonVisible(BOOL b, const LLString& label) +void LLProgressView::setCancelButtonVisible(BOOL b, const std::string& label) { mCancelBtn->setVisible( b ); mCancelBtn->setEnabled( b ); diff --git a/indra/newview/llprogressview.h b/indra/newview/llprogressview.h index 63d19c27dc..84ae8f6e82 100644 --- a/indra/newview/llprogressview.h +++ b/indra/newview/llprogressview.h @@ -52,20 +52,20 @@ public: /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); /*virtual*/ void setVisible(BOOL visible); - void setText(const LLString& text); + void setText(const std::string& text); void setPercent(const F32 percent); // Set it to NULL when you want to eliminate the message. - void setMessage(const LLString& msg); + void setMessage(const std::string& msg); - void setCancelButtonVisible(BOOL b, const LLString& label); + void setCancelButtonVisible(BOOL b, const std::string& label); static void onCancelButtonClicked( void* ); protected: F32 mPercentDone; - LLString mText; - LLString mMessage; + std::string mText; + std::string mMessage; LLButton* mCancelBtn; LLFrameTimer mFadeTimer; LLFrameTimer mProgressTimer; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index a889388e85..7554778301 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1955,12 +1955,13 @@ void LLSelectMgr::selectionSetClickAction(U8 action) // godlike requests //----------------------------------------------------------------------------- -typedef std::pair<const LLString, const LLString> godlike_request_t; -void LLSelectMgr::sendGodlikeRequest(const LLString& request, const LLString& param) +typedef std::pair<const std::string, const std::string> godlike_request_t; + +void LLSelectMgr::sendGodlikeRequest(const std::string& request, const std::string& param) { // If the agent is neither godlike nor an estate owner, the server // will reject the request. - LLString message_type; + std::string message_type; if (gAgent.isGodlike()) { message_type = "GodlikeMessage"; @@ -1993,7 +1994,7 @@ void LLSelectMgr::packGodlikeHead(void* user_data) msg->addUUID("TransactionID", LLUUID::null); godlike_request_t* data = (godlike_request_t*)user_data; msg->nextBlock("MethodData"); - msg->addString("Method", data->first.c_str()); + msg->addString("Method", data->first); msg->addUUID("Invoice", LLUUID::null); // The parameters used to be restricted to either string or @@ -2011,8 +2012,7 @@ void LLSelectMgr::packGodlikeHead(void* user_data) // static void LLSelectMgr::packObjectIDAsParam(LLSelectNode* node, void *) { - char buf [MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buf, MAX_STRING, "%u", node->getObject()->getLocalID()); /* Flawfinder: ignore */ + std::string buf = llformat("%u", node->getObject()->getLocalID()); gMessageSystem->nextBlock("ParamList"); gMessageSystem->addString("Parameter", buf); } @@ -2304,7 +2304,7 @@ BOOL LLSelectMgr::selectGetRootsCopy() // selectGetCreator() // Creator information only applies to root objects. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetCreator(LLUUID& result_id, LLString& name) +BOOL LLSelectMgr::selectGetCreator(LLUUID& result_id, std::string& name) { BOOL identical = TRUE; BOOL first = TRUE; @@ -2356,7 +2356,7 @@ BOOL LLSelectMgr::selectGetCreator(LLUUID& result_id, LLString& name) // selectGetOwner() // Owner information only applies to roots. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetOwner(LLUUID& result_id, LLString& name) +BOOL LLSelectMgr::selectGetOwner(LLUUID& result_id, std::string& name) { BOOL identical = TRUE; BOOL first = TRUE; @@ -2424,7 +2424,7 @@ BOOL LLSelectMgr::selectGetOwner(LLUUID& result_id, LLString& name) // selectGetLastOwner() // Owner information only applies to roots. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetLastOwner(LLUUID& result_id, LLString& name) +BOOL LLSelectMgr::selectGetLastOwner(LLUUID& result_id, std::string& name) { BOOL identical = TRUE; BOOL first = TRUE; @@ -3471,7 +3471,7 @@ void LLSelectMgr::deselectAllIfTooFar() } -void LLSelectMgr::selectionSetObjectName(const LLString& name) +void LLSelectMgr::selectionSetObjectName(const std::string& name) { // we only work correctly if 1 object is selected. if(mSelectedObjects->getRootObjectCount() == 1) @@ -3479,7 +3479,7 @@ void LLSelectMgr::selectionSetObjectName(const LLString& name) sendListToRegions("ObjectName", packAgentAndSessionID, packObjectName, - (void*)name.c_str(), + (void*)(new std::string(name)), SEND_ONLY_ROOTS); } else if(mSelectedObjects->getObjectCount() == 1) @@ -3487,12 +3487,12 @@ void LLSelectMgr::selectionSetObjectName(const LLString& name) sendListToRegions("ObjectName", packAgentAndSessionID, packObjectName, - (void*)name.c_str(), + (void*)(new std::string(name)), SEND_INDIVIDUALS); } } -void LLSelectMgr::selectionSetObjectDescription(const LLString& desc) +void LLSelectMgr::selectionSetObjectDescription(const std::string& desc) { // we only work correctly if 1 object is selected. if(mSelectedObjects->getRootObjectCount() == 1) @@ -3500,7 +3500,7 @@ void LLSelectMgr::selectionSetObjectDescription(const LLString& desc) sendListToRegions("ObjectDescription", packAgentAndSessionID, packObjectDescription, - (void*)desc.c_str(), + (void*)(new std::string(desc)), SEND_ONLY_ROOTS); } else if(mSelectedObjects->getObjectCount() == 1) @@ -3508,7 +3508,7 @@ void LLSelectMgr::selectionSetObjectDescription(const LLString& desc) sendListToRegions("ObjectDescription", packAgentAndSessionID, packObjectDescription, - (void*)desc.c_str(), + (void*)(new std::string(desc)), SEND_INDIVIDUALS); } } @@ -3993,22 +3993,26 @@ void LLSelectMgr::packObjectLocalID(LLSelectNode* node, void *) // static void LLSelectMgr::packObjectName(LLSelectNode* node, void* user_data) { - char* name = (char*)user_data; - if(!name) return; - gMessageSystem->nextBlockFast(_PREHASH_ObjectData); - gMessageSystem->addU32Fast(_PREHASH_LocalID, node->getObject()->getLocalID()); - gMessageSystem->addStringFast(_PREHASH_Name, name); + const std::string* name = (const std::string*)user_data; + if(!name->empty()) + { + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addU32Fast(_PREHASH_LocalID, node->getObject()->getLocalID()); + gMessageSystem->addStringFast(_PREHASH_Name, *name); + } + delete name; } // static -void LLSelectMgr::packObjectDescription(LLSelectNode* node, - void* user_data) +void LLSelectMgr::packObjectDescription(LLSelectNode* node, void* user_data) { - char* desc = (char*)user_data; - if(!desc) return; - gMessageSystem->nextBlockFast(_PREHASH_ObjectData); - gMessageSystem->addU32Fast(_PREHASH_LocalID, node->getObject()->getLocalID()); - gMessageSystem->addStringFast(_PREHASH_Description, desc); + const std::string* desc = (const std::string*)user_data; + if(!desc->empty()) + { + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addU32Fast(_PREHASH_LocalID, node->getObject()->getLocalID()); + gMessageSystem->addStringFast(_PREHASH_Description, *desc); + } } // static @@ -4057,7 +4061,7 @@ void LLSelectMgr::packPermissions(LLSelectNode* node, void *user_data) // Utility function to send some information to every region containing // an object on the selection list. We want to do this to reduce the total // number of packets sent by the viewer. -void LLSelectMgr::sendListToRegions(const LLString& message_name, +void LLSelectMgr::sendListToRegions(const std::string& message_name, void (*pack_header)(void *user_data), void (*pack_body)(LLSelectNode* node, void *user_data), void *user_data, @@ -4297,15 +4301,15 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_LastOwnerID, last_owner_id, i); - char name[DB_INV_ITEM_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, DB_INV_ITEM_NAME_BUF_SIZE, name, i); - char desc[DB_INV_ITEM_DESC_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Description, DB_INV_ITEM_DESC_BUF_SIZE, desc, i); + std::string name; + msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, name, i); + std::string desc; + msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Description, desc, i); - char touch_name[DB_INV_ITEM_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_ObjectData, _PREHASH_TouchName, DB_INV_ITEM_NAME_BUF_SIZE, touch_name, i); - char sit_name[DB_INV_ITEM_DESC_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_ObjectData, _PREHASH_SitName, DB_INV_ITEM_DESC_BUF_SIZE, sit_name, i); + std::string touch_name; + msg->getStringFast(_PREHASH_ObjectData, _PREHASH_TouchName, touch_name, i); + std::string sit_name; + msg->getStringFast(_PREHASH_ObjectData, _PREHASH_SitName, sit_name, i); //unpack TE IDs std::vector<LLUUID> texture_ids; @@ -4448,11 +4452,11 @@ void LLSelectMgr::processObjectPropertiesFamily(LLMessageSystem* msg, void** use msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_LastOwnerID, last_owner_id ); // unpack name & desc - char name[DB_INV_ITEM_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, DB_INV_ITEM_NAME_BUF_SIZE, name); + std::string name; + msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, name); - char desc[DB_INV_ITEM_DESC_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Description, DB_INV_ITEM_DESC_BUF_SIZE, desc); + std::string desc; + msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Description, desc); // the reporter widget askes the server for info about picked objects if (request_flags & (COMPLAINT_REPORT_REQUEST | BUG_REPORT_REQUEST)) @@ -4961,10 +4965,10 @@ LLSelectNode::LLSelectNode(LLViewerObject* object, BOOL glow) mValid = FALSE; mPermissions = new LLPermissions(); mInventorySerial = 0; - mName = LLString::null; - mDescription = LLString::null; - mTouchName = LLString::null; - mSitName = LLString::null; + mName = LLStringUtil::null; + mDescription = LLStringUtil::null; + mTouchName = LLStringUtil::null; + mSitName = LLStringUtil::null; mSilhouetteExists = FALSE; mDuplicated = FALSE; diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 6ae688bae6..ecd065fdf8 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -159,8 +159,8 @@ public: LLAggregatePermissions mAggregatePerm; LLAggregatePermissions mAggregateTexturePerm; LLAggregatePermissions mAggregateTexturePermOwner; - LLString mName; - LLString mDescription; + std::string mName; + std::string mDescription; LLCategory mCategory; S16 mInventorySerial; LLVector3 mSavedPositionLocal; // for interactively modifying object position @@ -176,8 +176,8 @@ public: LLUUID mItemID; LLUUID mFolderID; LLUUID mFromTaskID; - LLString mTouchName; - LLString mSitName; + std::string mTouchName; + std::string mSitName; U64 mCreationDate; std::vector<LLColor4> mSavedColors; std::vector<LLUUID> mSavedTextures; @@ -506,8 +506,8 @@ public: void selectionSetGlow(const F32 glow); void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE); - void selectionSetObjectName(const LLString& name); - void selectionSetObjectDescription(const LLString& desc); + void selectionSetObjectName(const std::string& name); + void selectionSetObjectDescription(const std::string& desc); void selectionSetObjectCategory(const LLCategory& category); void selectionSetObjectSaleInfo(const LLSaleInfo& sale_info); @@ -520,7 +520,7 @@ public: U32 update_type); void sendSelectionMove(); - void sendGodlikeRequest(const LLString& request, const LLString& parameter); + void sendGodlikeRequest(const std::string& request, const std::string& parameter); // will make sure all selected object meet current criteria, or deselect them otherwise @@ -543,9 +543,9 @@ public: // returns TRUE if selected objects can be copied. BOOL selectGetRootsCopy(); - BOOL selectGetCreator(LLUUID& id, LLString& name); // TRUE if all have same creator, returns id - BOOL selectGetOwner(LLUUID& id, LLString& name); // TRUE if all objects have same owner, returns id - BOOL selectGetLastOwner(LLUUID& id, LLString& name); // TRUE if all objects have same owner, returns id + BOOL selectGetCreator(LLUUID& id, std::string& name); // TRUE if all have same creator, returns id + BOOL selectGetOwner(LLUUID& id, std::string& name); // TRUE if all objects have same owner, returns id + BOOL selectGetLastOwner(LLUUID& id, std::string& name); // TRUE if all objects have same owner, returns id // returns TRUE if all are the same. id is stuffed with // the value found if available. @@ -646,7 +646,7 @@ private: void addAsFamily(std::vector<LLViewerObject*>& objects, BOOL add_to_end = FALSE); void generateSilhouette(LLSelectNode *nodep, const LLVector3& view_point); // Send one message to each region containing an object on selection list. - void sendListToRegions( const LLString& message_name, + void sendListToRegions( const std::string& message_name, void (*pack_header)(void *user_data), void (*pack_body)(LLSelectNode* node, void *user_data), void *user_data, diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7480d4dd73..7fe55d6efd 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -190,8 +190,8 @@ // BOOL gAgentMovementCompleted = FALSE; -const char* SCREEN_HOME_FILENAME = "screen_home.bmp"; -const char* SCREEN_LAST_FILENAME = "screen_last.bmp"; +std::string SCREEN_HOME_FILENAME = "screen_home.bmp"; +std::string SCREEN_LAST_FILENAME = "screen_last.bmp"; // // Imported globals @@ -209,8 +209,8 @@ static LLHost gAgentSimHost; static BOOL gSkipOptionalUpdate = FALSE; static bool gGotUseCircuitCodeAck = false; -LLString gInitialOutfit; -LLString gInitialOutfitGender; // "male" or "female" +std::string gInitialOutfit; +std::string gInitialOutfitGender; // "male" or "female" static bool gUseCircuitCallbackCalled = false; @@ -223,12 +223,12 @@ S32 LLStartUp::gStartupState = STATE_FIRST; void login_show(); void login_callback(S32 option, void* userdata); -LLString load_password_from_disk(); +std::string load_password_from_disk(); void save_password_to_disk(const char* hashed_password); BOOL is_hex_string(U8* str, S32 len); void show_first_run_dialog(); void first_run_dialog_callback(S32 option, void* userdata); -void set_startup_status(const F32 frac, const char* string, const char* msg); +void set_startup_status(const F32 frac, const std::string& string, const std::string& msg); void login_alert_status(S32 option, void* user_data); void update_app(BOOL mandatory, const std::string& message); void update_dialog_callback(S32 option, void *userdata); @@ -243,7 +243,7 @@ void init_start_screen(S32 location_id); void release_start_screen(); void reset_login(); -void callback_cache_name(const LLUUID& id, const char* firstname, const char* lastname, BOOL is_group, void* data) +void callback_cache_name(const LLUUID& id, const std::string& firstname, const std::string& lastname, BOOL is_group, void* data) { LLNameListCtrl::refreshAll(id, firstname, lastname, is_group); LLNameBox::refreshAll(id, firstname, lastname, is_group); @@ -267,7 +267,7 @@ namespace class LLNullHTTPSender : public LLHTTPSender { virtual void send(const LLHost& host, - const char* message, const LLSD& body, + const std::string& message, const LLSD& body, LLHTTPClient::ResponderPtr response) const { LL_WARNS("AppInit") << " attemped to send " << message << " to " << host @@ -322,10 +322,10 @@ BOOL idle_startup() static std::string auth_method; static std::string auth_desc; static std::string auth_message; - static LLString firstname; - static LLString lastname; + static std::string firstname; + static std::string lastname; static LLUUID web_login_key; - static LLString password; + static std::string password; static std::vector<const char*> requested_options; static U64 first_sim_handle = 0; @@ -394,16 +394,16 @@ BOOL idle_startup() gSavedSettings.setS32("LastFeatureVersion", LLFeatureManager::getInstance()->getVersion()); - LLString xml_file = LLUI::locateSkin("xui_version.xml"); + std::string xml_file = LLUI::locateSkin("xui_version.xml"); LLXMLNodePtr root; bool xml_ok = false; if (LLXMLNode::parseFile(xml_file, root, NULL)) { if( (root->hasName("xui_version") ) ) { - LLString value = root->getValue(); + std::string value = root->getValue(); F32 version = 0.0f; - LLString::convertToF32(value, version); + LLStringUtil::convertToF32(value, version); if (version >= 1.0f) { xml_ok = true; @@ -414,7 +414,7 @@ BOOL idle_startup() { // *TODO:translate (maybe - very unlikely error message) // Note: alerts.xml may be invalid - if this gets translated it will need to be in the code - LLString bad_xui_msg = "An error occured while updating Second Life. Please download the latest version from www.secondlife.com."; + std::string bad_xui_msg = "An error occured while updating Second Life. Please download the latest version from www.secondlife.com."; LLAppViewer::instance()->earlyExit(bad_xui_msg); } // @@ -422,7 +422,7 @@ BOOL idle_startup() // // Load autopilot and stats stuff - gAgentPilot.load(gSavedSettings.getString("StatsPilotFile").c_str()); + gAgentPilot.load(gSavedSettings.getString("StatsPilotFile")); gFrameStats.setFilename(gSavedSettings.getString("StatsFile")); gFrameStats.setSummaryFilename(gSavedSettings.getString("StatsSummaryFile")); @@ -444,7 +444,7 @@ BOOL idle_startup() std::string message_template_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"message_template.msg"); LLFILE* found_template = NULL; - found_template = LLFile::fopen(message_template_path.c_str(), "r"); /* Flawfinder: ignore */ + found_template = LLFile::fopen(message_template_path, "r"); /* Flawfinder: ignore */ if (found_template) { fclose(found_template); @@ -645,7 +645,7 @@ BOOL idle_startup() if (STATE_MEDIA_INIT == LLStartUp::getStartupState()) { LL_DEBUGS("AppInit") << "Initializing Multimedia...." << LL_ENDL; - set_startup_status(0.03f, "Initializing Multimedia...", gAgent.mMOTD.c_str()); + set_startup_status(0.03f, "Initializing Multimedia...", gAgent.mMOTD); display_startup(); LLViewerMedia::initClass(); LLViewerParcelMedia::initClass(); @@ -778,8 +778,8 @@ BOOL idle_startup() // create necessary directories // *FIX: these mkdir's should error check - gDirUtilp->setLindenUserDir(firstname.c_str(), lastname.c_str()); - LLFile::mkdir(gDirUtilp->getLindenUserDir().c_str()); + gDirUtilp->setLindenUserDir(firstname, lastname); + LLFile::mkdir(gDirUtilp->getLindenUserDir()); // Set PerAccountSettingsFile to the default value. gSavedSettings.setString("PerAccountSettingsFile", @@ -809,15 +809,15 @@ BOOL idle_startup() gDirUtilp->setChatLogsDir(gSavedPerAccountSettings.getString("InstantMessageLogPath")); } - gDirUtilp->setPerAccountChatLogsDir(firstname.c_str(), lastname.c_str()); + gDirUtilp->setPerAccountChatLogsDir(firstname, lastname); - LLFile::mkdir(gDirUtilp->getChatLogsDir().c_str()); - LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir().c_str()); + LLFile::mkdir(gDirUtilp->getChatLogsDir()); + LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir()); if (show_connect_box) { // TODO only set loginuri based on server choice if ! USE_VIEWER_AUTH - LLString server_label; + std::string server_label; S32 domain_name_index; BOOL user_picked_server = LLPanelLogin::getServer( server_label, domain_name_index ); if((EGridInfo)domain_name_index == GRID_INFO_OTHER) @@ -838,7 +838,7 @@ BOOL idle_startup() LLViewerLogin::getInstance()->resetURIs(); } - LLString location; + std::string location; LLPanelLogin::getLocation( location ); LLURLSimString::setString( location ); @@ -894,11 +894,11 @@ BOOL idle_startup() // Display the startup progress bar. gViewerWindow->setShowProgress(TRUE); - gViewerWindow->setProgressCancelButtonVisible(TRUE, "Quit"); + gViewerWindow->setProgressCancelButtonVisible(TRUE, std::string("Quit")); // *TODO: Translate // Poke the VFS, which could potentially block for a while if // Windows XP is acting up - set_startup_status(0.07f, LLTrans::getString("LoginVerifyingCache").c_str(), NULL); + set_startup_status(0.07f, LLTrans::getString("LoginVerifyingCache"), LLStringUtil::null); display_startup(); gVFS->pokeFiles(); @@ -968,16 +968,16 @@ BOOL idle_startup() sAuthUriNum = 0; auth_method = "login_to_simulator"; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[APP_NAME]"] = LLAppViewer::instance()->getSecondLifeTitle(); - auth_desc = LLTrans::getString("LoginInProgress", args).c_str(); + auth_desc = LLTrans::getString("LoginInProgress", args); LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE ); } if (STATE_LOGIN_AUTHENTICATE == LLStartUp::getStartupState()) { LL_DEBUGS("AppInit") << "STATE_LOGIN_AUTHENTICATE" << LL_ENDL; - set_startup_status(progress, auth_desc.c_str(), auth_message.c_str()); + set_startup_status(progress, auth_desc, auth_message); progress += 0.02f; display_startup(); @@ -991,7 +991,7 @@ BOOL idle_startup() << LLURLSimString::sInstance.mX << "&" << LLURLSimString::sInstance.mY << "&" << LLURLSimString::sInstance.mZ; - start << xml_escape_string(unescaped_start.str().c_str()); + start << xml_escape_string(unescaped_start.str()); } else if (gSavedSettings.getBOOL("LoginLastLocation")) @@ -1012,13 +1012,12 @@ BOOL idle_startup() // TODO if statement here to use web_login_key sAuthUriNum = llclamp(sAuthUriNum, 0, (S32)sAuthUris.size()-1); LLUserAuth::getInstance()->authenticate( - sAuthUris[sAuthUriNum].c_str(), - auth_method.c_str(), - firstname.c_str(), - lastname.c_str(), - // web_login_key, - password.c_str(), - start.str().c_str(), + sAuthUris[sAuthUriNum], + auth_method, + firstname, + lastname, + password, // web_login_key, + start.str(), gSkipOptionalUpdate, gAcceptTOS, gAcceptCriticalMessage, @@ -1040,7 +1039,7 @@ BOOL idle_startup() // If we get here we have gotten past the potential stall // in curl, so take "may appear frozen" out of progress bar. JC auth_desc = "Logging in..."; - set_startup_status(progress, auth_desc.c_str(), auth_message.c_str()); + set_startup_status(progress, auth_desc, auth_message); // Process messages to keep from dropping circuit. LLMessageSystem* msg = gMessageSystem; while (msg->checkAllMessages(gFrameCount, gServicePump)) @@ -1055,7 +1054,7 @@ BOOL idle_startup() } LLStartUp::setStartupState( STATE_LOGIN_DOWNLOADING ); progress += 0.01f; - set_startup_status(progress, auth_desc.c_str(), auth_message.c_str()); + set_startup_status(progress, auth_desc, auth_message); return do_normal_idle; } @@ -1076,7 +1075,7 @@ BOOL idle_startup() } LLStartUp::setStartupState( STATE_LOGIN_PROCESS_RESPONSE ); progress += 0.01f; - set_startup_status(progress, LLTrans::getString("LoginProcessingResponse").c_str(), auth_message.c_str()); + set_startup_status(progress, LLTrans::getString("LoginProcessingResponse"), auth_message); return do_normal_idle; } @@ -1085,9 +1084,9 @@ BOOL idle_startup() LL_DEBUGS("AppInit") << "STATE_LOGIN_PROCESS_RESPONSE" << LL_ENDL; std::ostringstream emsg; BOOL quit = FALSE; - const char* login_response = NULL; - const char* reason_response = NULL; - const char* message_response = NULL; + std::string login_response; + std::string reason_response; + std::string message_response; BOOL successful_login = FALSE; LLUserAuth::UserAuthcode error = LLUserAuth::getInstance()->authResponse(); // reset globals @@ -1097,12 +1096,12 @@ BOOL idle_startup() { case LLUserAuth::E_OK: login_response = LLUserAuth::getInstance()->getResponse("login"); - if(login_response && (0 == strcmp(login_response, "true"))) + if(login_response == "true") { // Yay, login! successful_login = TRUE; } - else if(login_response && (0 == strcmp(login_response, "indeterminate"))) + else if(login_response == "indeterminate") { LL_INFOS("AppInit") << "Indeterminate login..." << LL_ENDL; sAuthUris = LLSRV::rewriteURI(LLUserAuth::getInstance()->getResponse("next_url")); @@ -1111,11 +1110,11 @@ BOOL idle_startup() auth_message = LLUserAuth::getInstance()->getResponse("message"); if(auth_method.substr(0, 5) == "login") { - auth_desc.assign(LLTrans::getString("LoginAuthenticating").c_str()); + auth_desc.assign(LLTrans::getString("LoginAuthenticating")); } else { - auth_desc.assign(LLTrans::getString("LoginMaintenance").c_str()); + auth_desc.assign(LLTrans::getString("LoginMaintenance")); } // ignoring the duration & options array for now. // Go back to authenticate. @@ -1128,15 +1127,15 @@ BOOL idle_startup() reason_response = LLUserAuth::getInstance()->getResponse("reason"); message_response = LLUserAuth::getInstance()->getResponse("message"); - if (gHideLinks && reason_response && (0 == strcmp(reason_response, "disabled"))) + if (gHideLinks && reason_response == "disabled") { emsg << gDisabledMessage; } - else if (message_response) + else if (!message_response.empty()) { // XUI: fix translation for strings returned during login // We need a generic table for translations - LLString big_reason = LLAgent::sTeleportErrorMessages[ message_response ]; + std::string big_reason = LLAgent::sTeleportErrorMessages[ message_response ]; if ( big_reason.size() == 0 ) { emsg << message_response; @@ -1147,7 +1146,7 @@ BOOL idle_startup() } } - if(reason_response && (0 == strcmp(reason_response, "tos"))) + if(reason_response == "tos") { if (show_connect_box) { @@ -1164,7 +1163,7 @@ BOOL idle_startup() quit = TRUE; } } - if(reason_response && (0 == strcmp(reason_response, "critical"))) + if(reason_response == "critical") { if (show_connect_box) { @@ -1181,13 +1180,13 @@ BOOL idle_startup() quit = TRUE; } } - if(reason_response && (0 == strcmp(reason_response, "key"))) + if(reason_response == "key") { // Couldn't login because user/password is wrong // Clear the password password = ""; } - if(reason_response && (0 == strcmp(reason_response, "update"))) + if(reason_response == "update") { auth_message = LLUserAuth::getInstance()->getResponse("message"); if (show_connect_box) @@ -1201,7 +1200,7 @@ BOOL idle_startup() quit = TRUE; } } - if(reason_response && (0 == strcmp(reason_response, "optional"))) + if(reason_response == "optional") { LL_DEBUGS("AppInit") << "Login got optional update" << LL_ENDL; auth_message = LLUserAuth::getInstance()->getResponse("message"); @@ -1228,9 +1227,9 @@ BOOL idle_startup() } else { sAuthUriNum++; std::ostringstream s; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NUMBER]"] = llformat("%d", sAuthUriNum + 1); - auth_desc = LLTrans::getString("LoginAttempt", args).c_str(); + auth_desc = LLTrans::getString("LoginAttempt", args); LLStartUp::setStartupState( STATE_LOGIN_AUTHENTICATE ); return do_normal_idle; } @@ -1248,29 +1247,29 @@ BOOL idle_startup() if(successful_login) { // unpack login data needed by the application - const char* text; + std::string text; text = LLUserAuth::getInstance()->getResponse("agent_id"); - if(text) gAgentID.set(text); + if(!text.empty()) gAgentID.set(text); gDebugInfo["AgentID"] = text; text = LLUserAuth::getInstance()->getResponse("session_id"); - if(text) gAgentSessionID.set(text); + if(!text.empty()) gAgentSessionID.set(text); gDebugInfo["SessionID"] = text; text = LLUserAuth::getInstance()->getResponse("secure_session_id"); - if(text) gAgent.mSecureSessionID.set(text); + if(!text.empty()) gAgent.mSecureSessionID.set(text); text = LLUserAuth::getInstance()->getResponse("first_name"); - if(text) + if(!text.empty()) { // Remove quotes from string. Login.cgi sends these to force // names that look like numbers into strings. firstname.assign(text); - LLString::replaceChar(firstname, '"', ' '); - LLString::trim(firstname); + LLStringUtil::replaceChar(firstname, '"', ' '); + LLStringUtil::trim(firstname); } text = LLUserAuth::getInstance()->getResponse("last_name"); - if(text) lastname.assign(text); + if(!text.empty()) lastname.assign(text); gSavedSettings.setString("FirstName", firstname); gSavedSettings.setString("LastName", lastname); @@ -1285,7 +1284,7 @@ BOOL idle_startup() gSavedSettings.setBOOL("RememberPassword", remember_password); text = LLUserAuth::getInstance()->getResponse("agent_access"); - if(text && (text[0] == 'M')) + if(!text.empty() && (text[0] == 'M')) { gAgent.setTeen(false); } @@ -1295,52 +1294,48 @@ BOOL idle_startup() } text = LLUserAuth::getInstance()->getResponse("start_location"); - if(text) agent_start_location.assign(text); + if(!text.empty()) agent_start_location.assign(text); text = LLUserAuth::getInstance()->getResponse("circuit_code"); - if(text) + if(!text.empty()) { - gMessageSystem->mOurCircuitCode = strtoul(text, NULL, 10); + gMessageSystem->mOurCircuitCode = strtoul(text.c_str(), NULL, 10); } - const char* sim_ip_str = LLUserAuth::getInstance()->getResponse("sim_ip"); - const char* sim_port_str = LLUserAuth::getInstance()->getResponse("sim_port"); - if(sim_ip_str && sim_port_str) + std::string sim_ip_str = LLUserAuth::getInstance()->getResponse("sim_ip"); + std::string sim_port_str = LLUserAuth::getInstance()->getResponse("sim_port"); + if(!sim_ip_str.empty() && !sim_port_str.empty()) { - U32 sim_port = strtoul(sim_port_str, NULL, 10); + U32 sim_port = strtoul(sim_port_str.c_str(), NULL, 10); first_sim.set(sim_ip_str, sim_port); if (first_sim.isOk()) { gMessageSystem->enableCircuit(first_sim, TRUE); } } - const char* region_x_str = LLUserAuth::getInstance()->getResponse("region_x"); - const char* region_y_str = LLUserAuth::getInstance()->getResponse("region_y"); - if(region_x_str && region_y_str) + std::string region_x_str = LLUserAuth::getInstance()->getResponse("region_x"); + std::string region_y_str = LLUserAuth::getInstance()->getResponse("region_y"); + if(!region_x_str.empty() && !region_y_str.empty()) { - U32 region_x = strtoul(region_x_str, NULL, 10); - U32 region_y = strtoul(region_y_str, NULL, 10); + U32 region_x = strtoul(region_x_str.c_str(), NULL, 10); + U32 region_y = strtoul(region_y_str.c_str(), NULL, 10); first_sim_handle = to_region_handle(region_x, region_y); } - const char* look_at_str = LLUserAuth::getInstance()->getResponse("look_at"); - if (look_at_str) + const std::string look_at_str = LLUserAuth::getInstance()->getResponse("look_at"); + if (!look_at_str.empty()) { -#if !LL_WINDOWS && !LL_DARWIN - size_t len = strnlen(look_at_str, MAX_STRING); -#else - size_t len = strlen(look_at_str); -#endif - LLMemoryStream mstr((U8*)look_at_str, len); + size_t len = look_at_str.size(); + LLMemoryStream mstr((U8*)look_at_str.c_str(), len); LLSD sd = LLSDSerialize::fromNotation(mstr, len); agent_start_look_at = ll_vector3_from_sd(sd); } text = LLUserAuth::getInstance()->getResponse("seed_capability"); - if (text) first_sim_seed_cap = text; + if (!text.empty()) first_sim_seed_cap = text; text = LLUserAuth::getInstance()->getResponse("seconds_since_epoch"); - if(text) + if(!text.empty()) { - U32 server_utc_time = strtoul(text, NULL, 10); + U32 server_utc_time = strtoul(text.c_str(), NULL, 10); if(server_utc_time) { time_t now = time(NULL); @@ -1348,15 +1343,11 @@ BOOL idle_startup() } } - const char* home_location = LLUserAuth::getInstance()->getResponse("home"); - if(home_location) + std::string home_location = LLUserAuth::getInstance()->getResponse("home"); + if(!home_location.empty()) { -#if !LL_WINDOWS && !LL_DARWIN - size_t len = strnlen(home_location, MAX_STRING); -#else - size_t len = strlen(home_location); -#endif - LLMemoryStream mstr((U8*)home_location, len); + size_t len = home_location.size(); + LLMemoryStream mstr((U8*)home_location.c_str(), len); LLSD sd = LLSDSerialize::fromNotation(mstr, len); S32 region_x = sd["region_handle"][0].asInteger(); S32 region_y = sd["region_handle"][1].asInteger(); @@ -1373,7 +1364,7 @@ BOOL idle_startup() it = options[0].find("folder_id"); if(it != options[0].end()) { - gAgent.mInventoryRootID.set((*it).second.c_str()); + gAgent.mInventoryRootID.set((*it).second); //gInventory.mock(gAgent.getInventoryRootID()); } } @@ -1435,17 +1426,17 @@ BOOL idle_startup() it = options[0].find("sun_texture_id"); if(it != no_texture) { - gSunTextureID.set((*it).second.c_str()); + gSunTextureID.set((*it).second); } it = options[0].find("moon_texture_id"); if(it != no_texture) { - gMoonTextureID.set((*it).second.c_str()); + gMoonTextureID.set((*it).second); } it = options[0].find("cloud_texture_id"); if(it != no_texture) { - gCloudTextureID.set((*it).second.c_str()); + gCloudTextureID.set((*it).second); } } @@ -1470,7 +1461,7 @@ BOOL idle_startup() exit(0); } // Bounce back to the login screen. - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[ERROR_MESSAGE]"] = emsg.str(); gViewerWindow->alertXml("ErrorMessage", args, login_alert_done); reset_login(); @@ -1490,7 +1481,7 @@ BOOL idle_startup() exit(0); } // Bounce back to the login screen. - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[ERROR_MESSAGE]"] = emsg.str(); gViewerWindow->alertXml("ErrorMessage", args, login_alert_done); reset_login(); @@ -1507,7 +1498,7 @@ BOOL idle_startup() //--------------------------------------------------------------------- if (STATE_WORLD_INIT == LLStartUp::getStartupState()) { - set_startup_status(0.40f, LLTrans::getString("LoginInitializingWorld").c_str(), gAgent.mMOTD.c_str()); + set_startup_status(0.40f, LLTrans::getString("LoginInitializingWorld"), gAgent.mMOTD); display_startup(); // We should have an agent id by this point. llassert(!(gAgentID == LLUUID::null)); @@ -1723,7 +1714,7 @@ BOOL idle_startup() for (int i = 0; i < DECODE_TIME_SEC; i++) { F32 frac = (F32)i / (F32)DECODE_TIME_SEC; - set_startup_status(0.45f + frac*0.1f, LLTrans::getString("LoginDecodingImages").c_str(), gAgent.mMOTD.c_str()); + set_startup_status(0.45f + frac*0.1f, LLTrans::getString("LoginDecodingImages"), gAgent.mMOTD); display_startup(); gImageList.decodeAllImages(1.f); } @@ -1761,14 +1752,12 @@ BOOL idle_startup() } //--------------------------------------------------------------------- - - // Agent Send //--------------------------------------------------------------------- if(STATE_WORLD_WAIT == LLStartUp::getStartupState()) { LL_DEBUGS("AppInit") << "Waiting for simulator ack...." << LL_ENDL; - set_startup_status(0.59f, LLTrans::getString("LoginWaitingForRegionHandshake").c_str(), gAgent.mMOTD.c_str()); + set_startup_status(0.59f, LLTrans::getString("LoginWaitingForRegionHandshake"), gAgent.mMOTD); if(gGotUseCircuitCodeAck) { LLStartUp::setStartupState( STATE_AGENT_SEND ); @@ -1787,7 +1776,7 @@ BOOL idle_startup() if (STATE_AGENT_SEND == LLStartUp::getStartupState()) { LL_DEBUGS("AppInit") << "Connecting to region..." << LL_ENDL; - set_startup_status(0.60f, LLTrans::getString("LoginConnectingToRegion").c_str(), gAgent.mMOTD.c_str()); + set_startup_status(0.60f, LLTrans::getString("LoginConnectingToRegion"), gAgent.mMOTD); // register with the message system so it knows we're // expecting this message LLMessageSystem* msg = gMessageSystem; @@ -1870,7 +1859,7 @@ BOOL idle_startup() it = options[0].find("folder_id"); if(it != options[0].end()) { - gInventoryLibraryRoot.set((*it).second.c_str()); + gInventoryLibraryRoot.set((*it).second); } } options.clear(); @@ -1882,7 +1871,7 @@ BOOL idle_startup() it = options[0].find("agent_id"); if(it != options[0].end()) { - gInventoryLibraryOwner.set((*it).second.c_str()); + gInventoryLibraryOwner.set((*it).second); } } options.clear(); @@ -1917,7 +1906,7 @@ BOOL idle_startup() option_it = (*it).find("buddy_id"); if(option_it != (*it).end()) { - agent_id.set((*option_it).second.c_str()); + agent_id.set((*option_it).second); } option_it = (*it).find("buddy_rights_has"); if(option_it != (*it).end()) @@ -1970,7 +1959,7 @@ BOOL idle_startup() { if (option_it->second == "true") { - LLFloaterHUD::show(); + LLFloaterHUD::showHUD(); } } } @@ -1991,19 +1980,27 @@ BOOL idle_startup() LLClassifiedInfo::loadCategories(options); } gInventory.buildParentChildMap(); + + llinfos << "Setting Inventory changed mask and notifying observers" << llendl; gInventory.addChangedMask(LLInventoryObserver::ALL, LLUUID::null); gInventory.notifyObservers(); // set up callbacks + llinfos << "Registering Callbacks" << llendl; LLMessageSystem* msg = gMessageSystem; + llinfos << " Inventory" << llendl; LLInventoryModel::registerCallbacks(msg); + llinfos << " AvatarTracker" << llendl; LLAvatarTracker::instance().registerCallbacks(msg); + llinfos << " Landmark" << llendl; LLLandmark::registerCallbacks(msg); // request mute list + llinfos << "Requesting Mute List" << llendl; LLMuteList::getInstance()->requestFromServer(gAgent.getID()); // Get L$ and ownership credit information + llinfos << "Requesting Money Balance" << llendl; msg->newMessageFast(_PREHASH_MoneyBalanceRequest); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); @@ -2013,11 +2010,13 @@ BOOL idle_startup() gAgent.sendReliableMessage(); // request all group information + llinfos << "Requesting Agent Data" << llendl; gAgent.sendAgentDataUpdateRequest(); BOOL shown_at_exit = gSavedSettings.getBOOL("ShowInventory"); // Create the inventory views + llinfos << "Creating Inventory Views" << llendl; LLInventoryView::showAgentInventory(); // Hide the inventory if it wasn't shown at exit @@ -2072,7 +2071,7 @@ BOOL idle_startup() // based on the comments, we've successfully logged in so we can delete the 'forced' // URL that the updater set in settings.ini (in a mostly paranoid fashion) - LLString nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" ); + std::string nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" ); if ( nextLoginLocation.length() ) { // clear it @@ -2110,13 +2109,13 @@ BOOL idle_startup() if (option_it != response.end()) { const std::string& uuid_string = (*option_it).second; - item_id.set(uuid_string.c_str()); + item_id.set(uuid_string); } option_it = response.find("asset_id"); if (option_it != response.end()) { const std::string& uuid_string = (*option_it).second; - asset_id.set(uuid_string.c_str()); + asset_id.set(uuid_string); } if (item_id.notNull() && asset_id.notNull()) @@ -2180,7 +2179,7 @@ BOOL idle_startup() // location is not your expected location. So, if this is // your first login, then you do not have an expectation, // thus, do not show this alert. - LLString::format_map_t args; + LLStringUtil::format_map_t args; if (url_ok) { args["[TYPE]"] = "desired"; @@ -2237,7 +2236,7 @@ BOOL idle_startup() update_texture_fetch(); set_startup_status(0.60f + 0.40f * timeout_frac, "Loading world...", - gAgent.mMOTD.c_str()); + gAgent.mMOTD); } return do_normal_idle; @@ -2266,15 +2265,15 @@ BOOL idle_startup() { update_texture_fetch(); set_startup_status(0.f + 0.25f * wearables_time / MAX_WEARABLES_TIME, - LLTrans::getString("LoginDownloadingClothing").c_str(), - gAgent.mMOTD.c_str()); + LLTrans::getString("LoginDownloadingClothing"), + gAgent.mMOTD); } return do_normal_idle; } if (STATE_CLEANUP == LLStartUp::getStartupState()) { - set_startup_status(1.0, "", NULL); + set_startup_status(1.0, "", ""); do_normal_idle = TRUE; @@ -2290,7 +2289,7 @@ BOOL idle_startup() gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW); LL_DEBUGS("AppInit") << "Done releasing bitmap" << LL_ENDL; gViewerWindow->setShowProgress(FALSE); - gViewerWindow->setProgressCancelButtonVisible(FALSE, ""); + gViewerWindow->setProgressCancelButtonVisible(FALSE); // We're not away from keyboard, even though login might have taken // a while. JC @@ -2368,12 +2367,12 @@ void login_show() LL_DEBUGS("AppInit") << "Setting Servers" << LL_ENDL; - LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel().c_str(), LLViewerLogin::getInstance()->getGridChoice()); + LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel(), LLViewerLogin::getInstance()->getGridChoice()); LLViewerLogin* vl = LLViewerLogin::getInstance(); for(int grid_index = GRID_INFO_ADITI; grid_index < GRID_INFO_OTHER; ++grid_index) { - LLPanelLogin::addServer(vl->getKnownGridLabel((EGridInfo)grid_index).c_str(), grid_index); + LLPanelLogin::addServer(vl->getKnownGridLabel((EGridInfo)grid_index), grid_index); } } @@ -2391,7 +2390,7 @@ void login_callback(S32 option, void *userdata) else if (QUIT_OPTION == option) { // Make sure we don't save the password if the user is trying to clear it. - LLString first, last, password; + std::string first, last, password; BOOL remember = TRUE; LLPanelLogin::getFields(first, last, password, remember); if (!remember) @@ -2419,9 +2418,9 @@ void login_callback(S32 option, void *userdata) } } -LLString load_password_from_disk() +std::string load_password_from_disk() { - LLString hashed_password(""); + std::string hashed_password(""); // Look for legacy "marker" password from settings.ini hashed_password = gSavedSettings.getString("Marker"); @@ -2436,7 +2435,7 @@ LLString load_password_from_disk() std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "password.dat"); - LLFILE* fp = LLFile::fopen(filepath.c_str(), "rb"); /* Flawfinder: ignore */ + LLFILE* fp = LLFile::fopen(filepath, "rb"); /* Flawfinder: ignore */ if (!fp) { return hashed_password; @@ -2479,11 +2478,11 @@ void save_password_to_disk(const char* hashed_password) if (!hashed_password) { // No password, remove the file. - LLFile::remove(filepath.c_str()); + LLFile::remove(filepath); } else { - LLFILE* fp = LLFile::fopen(filepath.c_str(), "wb"); /* Flawfinder: ignore */ + LLFILE* fp = LLFile::fopen(filepath, "wb"); /* Flawfinder: ignore */ if (!fp) { return; @@ -2493,7 +2492,7 @@ void save_password_to_disk(const char* hashed_password) const S32 HASHED_LENGTH = 32; U8 buffer[HASHED_LENGTH+1]; - LLString::copy((char*)buffer, hashed_password, HASHED_LENGTH+1); + LLStringUtil::copy((char*)buffer, hashed_password, HASHED_LENGTH+1); LLXORCipher cipher(gMACAddress, 6); cipher.encrypt(buffer, HASHED_LENGTH); @@ -2559,7 +2558,7 @@ void first_run_dialog_callback(S32 option, void* userdata) -void set_startup_status(const F32 frac, const char *string, const char* msg) +void set_startup_status(const F32 frac, const std::string& string, const std::string& msg) { gViewerWindow->setProgressPercent(frac*100); gViewerWindow->setProgressString(string); @@ -2602,7 +2601,7 @@ void update_app(BOOL mandatory, const std::string& auth_msg) { msg = "(" + auth_msg + ") \n"; } - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = msg; // represent a bool as a null/non-null pointer @@ -2712,7 +2711,7 @@ void update_dialog_callback(S32 option, void *userdata) updater_source += gDirUtilp->getDirDelimiter(); updater_source += "updater.exe"; - LL_DEBUGS("AppInit") << "Calling CopyFile source: " << updater_source.c_str() + LL_DEBUGS("AppInit") << "Calling CopyFile source: " << updater_source << " dest: " << update_exe_path << LL_ENDL; @@ -2736,9 +2735,9 @@ void update_dialog_callback(S32 option, void *userdata) if (gHideLinks) { // Figure out the program name. - const char* data_dir = gDirUtilp->getAppRODataDir().c_str(); + const std::string& data_dir = gDirUtilp->getAppRODataDir(); // Roll back from the end, stopping at the first '\' - const char* program_name = data_dir + strlen(data_dir); /* Flawfinder: ignore */ + const char* program_name = data_dir.c_str() + data_dir.size(); /* Flawfinder: ignore */ while ( (data_dir != --program_name) && *(program_name) != '\\'); @@ -2790,7 +2789,7 @@ void update_dialog_callback(S32 option, void *userdata) #elif LL_LINUX OSMessageBox("Automatic updating is not yet implemented for Linux.\n" "Please download the latest version from www.secondlife.com.", - NULL, OSMB_OK); + LLStringUtil::null, OSMB_OK); #endif LLAppViewer::instance()->forceQuit(); } @@ -3547,11 +3546,11 @@ void asset_callback_nothing(LLVFS*, const LLUUID&, LLAssetType::EType, void*, S3 } // *HACK: Must match name in Library or agent inventory -const char* COMMON_GESTURES_FOLDER = "Common Gestures"; -const char* MALE_GESTURES_FOLDER = "Male Gestures"; -const char* FEMALE_GESTURES_FOLDER = "Female Gestures"; -const char* MALE_OUTFIT_FOLDER = "Male Shape & Outfit"; -const char* FEMALE_OUTFIT_FOLDER = "Female Shape & Outfit"; +const std::string COMMON_GESTURES_FOLDER = "Common Gestures"; +const std::string MALE_GESTURES_FOLDER = "Male Gestures"; +const std::string FEMALE_GESTURES_FOLDER = "Female Gestures"; +const std::string MALE_OUTFIT_FOLDER = "Male Shape & Outfit"; +const std::string FEMALE_OUTFIT_FOLDER = "Female Shape & Outfit"; const S32 OPT_USE_INITIAL_OUTFIT = -2; const S32 OPT_CLOSED_WINDOW = -1; const S32 OPT_MALE = 0; @@ -3560,12 +3559,11 @@ const S32 OPT_FEMALE = 1; void callback_choose_gender(S32 option, void* userdata) { S32 gender = OPT_FEMALE; - const char* outfit = FEMALE_OUTFIT_FOLDER; - const char* gestures = FEMALE_GESTURES_FOLDER; - const char* common_gestures = COMMON_GESTURES_FOLDER; + std::string outfit; + std::string gestures; if (!gInitialOutfit.empty()) { - outfit = gInitialOutfit.c_str(); + outfit = gInitialOutfit; if (gInitialOutfitGender == "male") { gender = OPT_MALE; @@ -3616,7 +3614,7 @@ void callback_choose_gender(S32 option, void* userdata) wear_outfit_by_name(outfit); } wear_outfit_by_name(gestures); - wear_outfit_by_name(common_gestures); + wear_outfit_by_name(COMMON_GESTURES_FOLDER); typedef std::map<LLUUID, LLMultiGesture*> item_map_t; item_map_t::iterator gestureIterator; @@ -3657,7 +3655,7 @@ void init_start_screen(S32 location_id) LL_DEBUGS("AppInit") << "Loading startup bitmap..." << LL_ENDL; - LLString temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); + std::string temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); if ((S32)START_LOCATION_ID_LAST == location_id) { diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h index 6c832492c0..b5de15d983 100644 --- a/indra/newview/llstartup.h +++ b/indra/newview/llstartup.h @@ -36,13 +36,13 @@ // functions BOOL idle_startup(); -LLString load_password_from_disk(); +std::string load_password_from_disk(); void release_start_screen(); void login_alert_done(S32 option, void* user_data); // constants, variables, & enumerations -extern const char* SCREEN_HOME_FILENAME; -extern const char* SCREEN_LAST_FILENAME; +extern std::string SCREEN_HOME_FILENAME; +extern std::string SCREEN_LAST_FILENAME; enum EStartupState{ STATE_FIRST, // Initial startup diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 0f65510844..a7314548ca 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -179,9 +179,9 @@ mSquareMetersCommitted(0) mSGBandwidth = new LLStatGraph("BandwidthGraph", r); mSGBandwidth->setFollows(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); mSGBandwidth->setStat(&LLViewerStats::getInstance()->mKBitStat); - LLString text = childGetText("bandwidth_tooltip") + " "; + std::string text = childGetText("bandwidth_tooltip") + " "; LLUIString bandwidth_tooltip = text; // get the text from XML until this widget is XML driven - mSGBandwidth->setLabel(bandwidth_tooltip.getString().c_str()); + mSGBandwidth->setLabel(bandwidth_tooltip.getString()); mSGBandwidth->setUnits("Kbps"); mSGBandwidth->setPrecision(0); mSGBandwidth->setMouseOpaque(FALSE); @@ -194,7 +194,7 @@ mSquareMetersCommitted(0) mSGPacketLoss->setStat(&LLViewerStats::getInstance()->mPacketsLostPercentStat); text = childGetText("packet_loss_tooltip") + " "; LLUIString packet_loss_tooltip = text; // get the text from XML until this widget is XML driven - mSGPacketLoss->setLabel(packet_loss_tooltip.getString().c_str()); + mSGPacketLoss->setLabel(packet_loss_tooltip.getString()); mSGPacketLoss->setUnits("%"); mSGPacketLoss->setMin(0.f); mSGPacketLoss->setMax(5.f); @@ -348,7 +348,7 @@ void LLStatusBar::refresh() childSetRect("health", r); x += buttonRect.getWidth(); - const S32 health_width = S32( LLFontGL::sSansSerifSmall->getWidth("100%") ); + const S32 health_width = S32( LLFontGL::sSansSerifSmall->getWidth(std::string("100%")) ); r.set(x, y+TEXT_HEIGHT - 2, x+health_width, y); mTextHealth->setRect(r); x += health_width; @@ -457,7 +457,7 @@ void LLStatusBar::refresh() x += buttonRect.getWidth(); } - LLString location_name; + std::string location_name; if (region) { const LLVector3& agent_pos_region = gAgent.getPositionAgent(); @@ -493,9 +493,9 @@ void LLStatusBar::refresh() { location_name = region->getName() + llformat(" %d, %d, %d (%s) - %s", - pos_x, pos_y, pos_z, - region->getSimAccessString(), - parcel->getName().c_str()); + pos_x, pos_y, pos_z, + region->getSimAccessString().c_str(), + parcel->getName().c_str()); // keep these around for the LCD to use mRegionDetails.mRegionName = region->getName(); @@ -537,7 +537,7 @@ void LLStatusBar::refresh() location_name = region->getName() + llformat(" %d, %d, %d (%s)", pos_x, pos_y, pos_z, - region->getSimAccessString()); + region->getSimAccessString().c_str()); // keep these around for the LCD to use mRegionDetails.mRegionName = region->getName(); mRegionDetails.mParcelName = "Unknown"; @@ -656,8 +656,8 @@ void LLStatusBar::creditBalance(S32 credit) void LLStatusBar::setBalance(S32 balance) { - LLString money_str = LLResMgr::getInstance()->getMonetaryString( balance ); - LLString balance_str = "L$"; + std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance ); + std::string balance_str = "L$"; balance_str += money_str; mTextBalance->setText( balance_str ); @@ -822,14 +822,14 @@ static void onClickBuyLand(void*) void LLStatusBar::setupDate() { // fill the day array with what's in the xui - LLString day_list = getString("StatBarDaysOfWeek"); + std::string day_list = getString("StatBarDaysOfWeek"); size_t length = day_list.size(); // quick input check if(length < MAX_DATE_STRING_LENGTH) { // tokenize it and put it in the array - LLString cur_word; + std::string cur_word; for(size_t i = 0; i < length; ++i) { if(day_list[i] == ':') @@ -839,21 +839,21 @@ void LLStatusBar::setupDate() } else { - cur_word.append(1, day_list.c_str()[i]); + cur_word.append(1, day_list[i]); } } sDays.push_back(cur_word); } // fill the day array with what's in the xui - LLString month_list = getString( "StatBarMonthsOfYear" ); + std::string month_list = getString( "StatBarMonthsOfYear" ); length = month_list.size(); // quick input check if(length < MAX_DATE_STRING_LENGTH) { // tokenize it and put it in the array - LLString cur_word; + std::string cur_word; for(size_t i = 0; i < length; ++i) { if(month_list[i] == ':') @@ -863,7 +863,7 @@ void LLStatusBar::setupDate() } else { - cur_word.append(1, month_list.c_str()[i]); + cur_word.append(1, month_list[i]); } } sMonths.push_back(cur_word); @@ -892,7 +892,7 @@ void LLStatusBar::onCommitSearch(LLUICtrl*, void* data) void LLStatusBar::onClickSearch(void* data) { LLStatusBar* self = (LLStatusBar*)data; - LLString search_text = self->childGetText("search_editor"); + std::string search_text = self->childGetText("search_editor"); LLFloaterDirectory::showFindAll(search_text); } diff --git a/indra/newview/llstylemap.cpp b/indra/newview/llstylemap.cpp index 09578a011a..0f092b31c4 100644 --- a/indra/newview/llstylemap.cpp +++ b/indra/newview/llstylemap.cpp @@ -60,11 +60,11 @@ const LLStyleSP &LLStyleMap::lookup(const LLUUID &source) { LLStyleSP style(new LLStyle); style->setVisible(true); - style->setFontName(LLString::null); + style->setFontName(LLStringUtil::null); if (source != gAgent.getID() && source != LLUUID::null) { style->setColor(gSavedSettings.getColor4("HTMLLinkColor")); - LLString link = llformat("secondlife:///app/agent/%s/about",source.asString().c_str()); + std::string link = llformat("secondlife:///app/agent/%s/about",source.asString().c_str()); style->setLinkHREF(link); } else diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index 6286289d6b..3012625122 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -991,7 +991,7 @@ BOOL LLTexLayerInfo::parseXml(LLXmlTreeNode* node) static LLStdStringHandle write_all_channels_string = LLXmlTree::addAttributeString("write_all_channels"); node->getFastAttributeBOOL( write_all_channels_string, mWriteAllChannels ); - LLString render_pass_name; + std::string render_pass_name; static LLStdStringHandle render_pass_string = LLXmlTree::addAttributeString("render_pass"); if( node->getFastAttributeString( render_pass_string, render_pass_name ) ) { @@ -1019,7 +1019,7 @@ BOOL LLTexLayerInfo::parseXml(LLXmlTreeNode* node) texture_node; texture_node = node->getNextNamedChild()) { - LLString local_texture; + std::string local_texture; static LLStdStringHandle tga_file_string = LLXmlTree::addAttributeString("tga_file"); static LLStdStringHandle local_texture_string = LLXmlTree::addAttributeString("local_texture"); static LLStdStringHandle file_is_mask_string = LLXmlTree::addAttributeString("file_is_mask"); @@ -1105,14 +1105,14 @@ BOOL LLTexLayerInfo::parseXml(LLXmlTreeNode* node) maskNode; maskNode = node->getNextNamedChild()) { - LLString morph_name; + std::string morph_name; static LLStdStringHandle morph_name_string = LLXmlTree::addAttributeString("morph_name"); if (maskNode->getFastAttributeString(morph_name_string, morph_name)) { BOOL invert = FALSE; static LLStdStringHandle invert_string = LLXmlTree::addAttributeString("invert"); maskNode->getFastAttributeBOOL(invert_string, invert); - mMorphNameList.push_back(std::pair<LLString,BOOL>(morph_name,invert)); + mMorphNameList.push_back(std::pair<std::string,BOOL>(morph_name,invert)); } } @@ -1206,7 +1206,7 @@ BOOL LLTexLayer::setInfo(LLTexLayerInfo* info) // morph target, need a better way of actually looking // this up. LLPolyMorphTarget *morph_param; - LLString *name = &(iter->first); + std::string *name = &(iter->first); morph_param = (LLPolyMorphTarget *)(getTexLayerSet()->getAvatar()->getVisualParam(name->c_str())); if (morph_param) { @@ -2244,11 +2244,11 @@ BOOL LLTexParamColorInfo::parseXml(LLXmlTreeNode *node) return FALSE; } - LLString op_string; + std::string op_string; static LLStdStringHandle operation_string = LLXmlTree::addAttributeString("operation"); if( param_color_node->getFastAttributeString( operation_string, op_string ) ) { - LLString::toLower(op_string); + LLStringUtil::toLower(op_string); if ( op_string == "add" ) mOperation = OP_ADD; else if ( op_string == "multiply" ) mOperation = OP_MULTIPLY; else if ( op_string == "blend" ) mOperation = OP_BLEND; @@ -2465,7 +2465,7 @@ void LLTexStaticImageList::deleteCachedImages() // Returns an LLImageTGA that contains the encoded data from a tga file named file_name. // Caches the result to speed identical subsequent requests. -LLImageTGA* LLTexStaticImageList::getImageTGA(const LLString& file_name) +LLImageTGA* LLTexStaticImageList::getImageTGA(const std::string& file_name) { const char *namekey = sImageNames.addString(file_name); image_tga_map_t::iterator iter = mStaticImageListTGA.find(namekey); @@ -2476,7 +2476,7 @@ LLImageTGA* LLTexStaticImageList::getImageTGA(const LLString& file_name) else { std::string path; - path = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,file_name.c_str()); + path = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,file_name); LLPointer<LLImageTGA> image_tga = new LLImageTGA( path ); if( image_tga->getDataSize() > 0 ) { @@ -2495,7 +2495,7 @@ LLImageTGA* LLTexStaticImageList::getImageTGA(const LLString& file_name) // Returns a GL Image (without a backing ImageRaw) that contains the decoded data from a tga file named file_name. // Caches the result to speed identical subsequent requests. -LLImageGL* LLTexStaticImageList::getImageGL(const LLString& file_name, BOOL is_mask ) +LLImageGL* LLTexStaticImageList::getImageGL(const std::string& file_name, BOOL is_mask ) { LLPointer<LLImageGL> image_gl; const char *namekey = sImageNames.addString(file_name); @@ -2536,11 +2536,11 @@ LLImageGL* LLTexStaticImageList::getImageGL(const LLString& file_name, BOOL is_m // Reads a .tga file, decodes it, and puts the decoded data in image_raw. // Returns TRUE if successful. -BOOL LLTexStaticImageList::loadImageRaw( const LLString& file_name, LLImageRaw* image_raw ) +BOOL LLTexStaticImageList::loadImageRaw( const std::string& file_name, LLImageRaw* image_raw ) { BOOL success = FALSE; std::string path; - path = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,file_name.c_str()); + path = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,file_name); LLPointer<LLImageTGA> image_tga = new LLImageTGA( path ); if( image_tga->getDataSize() > 0 ) { diff --git a/indra/newview/lltexlayer.h b/indra/newview/lltexlayer.h index 458db88b8e..59a0660a94 100644 --- a/indra/newview/lltexlayer.h +++ b/indra/newview/lltexlayer.h @@ -87,7 +87,7 @@ public: /*virtual*/ BOOL parseXml(LLXmlTreeNode* node); protected: - LLString mStaticImageFileName; + std::string mStaticImageFileName; BOOL mMultiplyBlend; BOOL mSkipIfZeroWeight; F32 mDomain; @@ -127,7 +127,7 @@ public: protected: typedef std::vector<LLTexParamColorInfo *> color_info_list_t; color_info_list_t mColorInfoList; - LLString mName; + std::string mName; }; //----------------------------------------------------------------------------- @@ -144,10 +144,10 @@ public: BOOL parseXml(LLXmlTreeNode* node); protected: - LLString mBodyRegion; + std::string mBodyRegion; S32 mWidth; S32 mHeight; - LLString mStaticAlphaFileName; + std::string mStaticAlphaFileName; BOOL mClearAlpha; // Set alpha to 1 for this layerset (if there is no mStaticAlphaFileName) typedef std::vector<LLTexLayerInfo*> layer_info_list_t; @@ -174,20 +174,20 @@ public: BOOL parseXml(LLXmlTreeNode* node); protected: - LLString mName; + std::string mName; BOOL mWriteAllChannels; // Don't use masking. Just write RGBA into buffer, ERenderPass mRenderPass; - LLString mGlobalColor; + std::string mGlobalColor; LLColor4 mFixedColor; S32 mLocalTexture; - LLString mStaticImageFileName; + std::string mStaticImageFileName; BOOL mStaticImageIsMask; BOOL mUseLocalTextureAlphaOnly; // Ignore RGB channels from the input texture. Use alpha as a mask - typedef std::vector<std::pair<LLString,BOOL> > morph_name_list_t; + typedef std::vector<std::pair<std::string,BOOL> > morph_name_list_t; morph_name_list_t mMorphNameList; typedef std::vector<LLTexParamColorInfo*> color_info_list_t; @@ -261,7 +261,7 @@ public: BOOL render( S32 x, S32 y, S32 width, S32 height ); BOOL renderBump( S32 x, S32 y, S32 width,S32 height ); - BOOL isBodyRegion( const char* region ) { return mInfo->mBodyRegion == region; } + BOOL isBodyRegion( const std::string& region ) { return mInfo->mBodyRegion == region; } LLTexLayerSetBuffer* getComposite(); void requestUpdate(); void requestUpload(); @@ -277,7 +277,7 @@ public: void deleteCaches(); void gatherAlphaMasks(U8 *data, S32 width, S32 height); void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components); - const LLString& getBodyRegion() { return mInfo->mBodyRegion; } + const std::string getBodyRegion() { return mInfo->mBodyRegion; } BOOL hasComposite() { return (mComposite != NULL); } void setBump( BOOL b ) { mHasBump = b; } BOOL hasBump() { return mHasBump; } @@ -339,7 +339,7 @@ public: void invalidateMorphMasks(); ERenderPass getRenderPass() { return mInfo->mRenderPass; } - const LLString& getGlobalColor() { return mInfo->mGlobalColor; } + const std::string& getGlobalColor() { return mInfo->mGlobalColor; } BOOL findNetColor( LLColor4* color ); BOOL renderImageRaw( U8* in_data, S32 in_width, S32 in_height, S32 in_components, S32 width, S32 height, BOOL is_mask ); BOOL renderAlphaMasks( S32 x, S32 y, S32 width, S32 height, LLColor4* colorp ); @@ -506,15 +506,15 @@ public: LLTexStaticImageList(); ~LLTexStaticImageList(); - LLImageRaw* getImageRaw( const LLString& file_name ); - LLImageGL* getImageGL( const LLString& file_name, BOOL is_mask ); - LLImageTGA* getImageTGA( const LLString& file_name ); + LLImageRaw* getImageRaw( const std::string& file_name ); + LLImageGL* getImageGL( const std::string& file_name, BOOL is_mask ); + LLImageTGA* getImageTGA( const std::string& file_name ); void deleteCachedImages(); void dumpByteCount(); private: - BOOL loadImageRaw( const LLString& file_name, LLImageRaw* image_raw ); + BOOL loadImageRaw( const std::string& file_name, LLImageRaw* image_raw ); private: static LLStringTable sImageNames; diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 10801cfd4f..fad6acc65a 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -155,7 +155,7 @@ protected: class LLTextureCacheLocalFileWorker : public LLTextureCacheWorker { public: - LLTextureCacheLocalFileWorker(LLTextureCache* cache, U32 priority, const LLString& filename, const LLUUID& id, + LLTextureCacheLocalFileWorker(LLTextureCache* cache, U32 priority, const std::string& filename, const LLUUID& id, U8* data, S32 datasize, S32 offset, S32 imagesize, // for writes LLTextureCache::Responder* responder) @@ -169,7 +169,7 @@ public: virtual bool doWrite(); private: - LLString mFileName; + std::string mFileName; }; bool LLTextureCacheLocalFileWorker::doRead() @@ -180,7 +180,7 @@ bool LLTextureCacheLocalFileWorker::doRead() { mDataSize = local_size; // Only a complete file is valid - LLString extension = mFileName.substr(mFileName.size() - 3, 3); + std::string extension = mFileName.substr(mFileName.size() - 3, 3); mImageFormat = LLImageBase::getCodecFromExtension(extension); @@ -1033,12 +1033,12 @@ S64 LLTextureCache::initCache(ELLPath location, S64 max_size, BOOL read_only) if (!mReadOnly) { - LLFile::mkdir(mTexturesDirName.c_str()); + LLFile::mkdir(mTexturesDirName); const char* subdirs = "0123456789abcdef"; for (S32 i=0; i<16; i++) { std::string dirname = mTexturesDirName + gDirUtilp->getDirDelimiter() + subdirs[i]; - LLFile::mkdir(dirname.c_str()); + LLFile::mkdir(dirname); } } readHeaderCache(); @@ -1134,16 +1134,16 @@ void LLTextureCache::purgeAllTextures(bool purge_directories) for (S32 i=0; i<16; i++) { std::string dirname = mTexturesDirName + delem + subdirs[i]; - gDirUtilp->deleteFilesInDir(dirname.c_str(),mask); + gDirUtilp->deleteFilesInDir(dirname,mask); if (purge_directories) { - LLFile::rmdir(dirname.c_str()); + LLFile::rmdir(dirname); } } ll_apr_file_remove(mTexturesDirEntriesFileName, NULL); if (purge_directories) { - LLFile::rmdir(mTexturesDirName.c_str()); + LLFile::rmdir(mTexturesDirName); } } mTexturesSizeMap.clear(); @@ -1392,7 +1392,7 @@ S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, bool touch, S32* image // Calls from texture pipeline thread (i.e. LLTextureFetch) -LLTextureCache::handle_t LLTextureCache::readFromCache(const LLString& filename, const LLUUID& id, U32 priority, +LLTextureCache::handle_t LLTextureCache::readFromCache(const std::string& filename, const LLUUID& id, U32 priority, S32 offset, S32 size, ReadResponder* responder) { // Note: checking to see if an entry exists can cause a stall, diff --git a/indra/newview/lltexturecache.h b/indra/newview/lltexturecache.h index 28b33d5c4e..da7a6c3f12 100644 --- a/indra/newview/lltexturecache.h +++ b/indra/newview/lltexturecache.h @@ -83,7 +83,7 @@ public: void purgeCache(ELLPath location); S64 initCache(ELLPath location, S64 maxsize, BOOL read_only); - handle_t readFromCache(const LLString& local_filename, const LLUUID& id, U32 priority, S32 offset, S32 size, + handle_t readFromCache(const std::string& local_filename, const LLUUID& id, U32 priority, S32 offset, S32 size, ReadResponder* responder); handle_t readFromCache(const LLUUID& id, U32 priority, S32 offset, S32 size, diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index b89e93b9a4..421f0196e3 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -118,7 +118,7 @@ public: virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg); + std::string& tooltip_msg); virtual void draw(); virtual BOOL handleKeyHere(KEY key, MASK mask); @@ -156,7 +156,7 @@ public: static void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data); static void onShowFolders(LLUICtrl* ctrl, void* userdata); static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); - static void onSearchEdit(const LLString& search_string, void* user_data ); + static void onSearchEdit(const std::string& search_string, void* user_data ); static void onTextureSelect( const LLTextureEntry& te, void *data ); protected: @@ -174,7 +174,7 @@ protected: LLTextBox* mTentativeLabel; LLTextBox* mResolutionLabel; - LLString mPendingName; + std::string mPendingName; BOOL mIsDirty; BOOL mActive; @@ -196,9 +196,9 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( PermissionMask non_immediate_filter_perm_mask, BOOL can_apply_immediately) : - LLFloater( "texture picker", + LLFloater( std::string("texture picker"), rect, - LLString( "Pick: " ) + label, + std::string( "Pick: " ) + label, TRUE, TEX_PICKER_MIN_WIDTH, TEX_PICKER_MIN_HEIGHT ), mOwner( owner ), @@ -346,12 +346,12 @@ void LLFloaterTexturePicker::updateImageStats() //RN: have we received header data for this image? if (mTexturep->getWidth(0) > 0 && mTexturep->getHeight(0) > 0) { - LLString formatted_dims = llformat("%d x %d", mTexturep->getWidth(0),mTexturep->getHeight(0)); + std::string formatted_dims = llformat("%d x %d", mTexturep->getWidth(0),mTexturep->getHeight(0)); mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims); } else { - mResolutionLabel->setTextArg("[DIMENSIONS]", LLString("[? x ?]")); + mResolutionLabel->setTextArg("[DIMENSIONS]", std::string("[? x ?]")); } } } @@ -362,7 +362,7 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop( BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL handled = FALSE; @@ -816,12 +816,12 @@ void LLFloaterTexturePicker::updateFilterPermMask() //mInventoryPanel->setFilterPermMask( getFilterPermMask() ); Commented out due to no-copy texture loss. } -void LLFloaterTexturePicker::onSearchEdit(const LLString& search_string, void* user_data ) +void LLFloaterTexturePicker::onSearchEdit(const std::string& search_string, void* user_data ) { LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; std::string upper_case_search_string = search_string; - LLString::toUpper(upper_case_search_string); + LLStringUtil::toUpper(upper_case_search_string); if (upper_case_search_string.empty()) { @@ -924,11 +924,11 @@ LLTextureCtrl::LLTextureCtrl( S32 image_middle = (image_top + image_bottom) / 2; S32 line_height = llround(LLFontGL::sSansSerifSmall->getLineHeight()); - mTentativeLabel = new LLTextBox( "Multiple", + mTentativeLabel = new LLTextBox( std::string("Multiple"), LLRect( 0, image_middle + line_height / 2, getRect().getWidth(), image_middle - line_height / 2 ), - "Multiple", + std::string("Multiple"), LLFontGL::sSansSerifSmall ); mTentativeLabel->setHAlign( LLFontGL::HCENTER ); mTentativeLabel->setFollowsAll(); @@ -936,7 +936,7 @@ LLTextureCtrl::LLTextureCtrl( LLRect border_rect(0, getRect().getHeight(), getRect().getWidth(), 0); border_rect.mBottom += BTN_HEIGHT_SMALL; - mBorder = new LLViewBorder("border", border_rect, LLViewBorder::BEVEL_IN); + mBorder = new LLViewBorder(std::string("border"), border_rect, LLViewBorder::BEVEL_IN); mBorder->setFollowsAll(); addChild(mBorder); @@ -968,22 +968,22 @@ LLXMLNodePtr LLTextureCtrl::getXML(bool save_children) const LLView* LLTextureCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("texture_picker"); + std::string name("texture_picker"); node->getAttributeString("name", name); LLRect rect; createRect(node, rect, parent); - LLString label; + std::string label; node->getAttributeString("label", label); - LLString image_id(""); + std::string image_id(""); node->getAttributeString("image", image_id); - LLString default_image_id(""); + std::string default_image_id(""); node->getAttributeString("default_image", default_image_id); - LLString default_image_name("Default"); + std::string default_image_name("Default"); node->getAttributeString("default_image_name", default_image_name); BOOL allow_no_texture = FALSE; @@ -1017,7 +1017,7 @@ void LLTextureCtrl::setShowLoadingPlaceholder(BOOL showLoadingPlaceholder) mShowLoadingPlaceholder = showLoadingPlaceholder; } -void LLTextureCtrl::setCaption(const LLString& caption) +void LLTextureCtrl::setCaption(const std::string& caption) { mCaption->setText( caption ); } @@ -1046,13 +1046,13 @@ void LLTextureCtrl::setEnabled( BOOL enabled ) LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); if( enabled ) { - LLString tooltip; + std::string tooltip; if (floaterp) tooltip = floaterp->getUIString("choose_picture"); setToolTip( tooltip ); } else { - setToolTip( LLString() ); + setToolTip( std::string() ); // *TODO: would be better to keep floater open and show // disabled state. closeFloater(); @@ -1100,7 +1100,7 @@ void LLTextureCtrl::clear() setImageAssetID(LLUUID::null); } -void LLTextureCtrl::setLabel(const LLString& label) +void LLTextureCtrl::setLabel(const std::string& label) { mLabel = label; mCaption->setText(label); @@ -1251,7 +1251,7 @@ void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id ) BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL handled = FALSE; @@ -1435,7 +1435,7 @@ protected: LLToolTexEyedropper::LLToolTexEyedropper( void (*callback)(const LLUUID& obj_id, const LLUUID& image_id, void* userdata ), void* userdata ) - : LLTool("texeyedropper"), + : LLTool(std::string("texeyedropper")), mCallback( callback ), mCallbackUserData( userdata ) { diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 5dabf07ce5..cf83c628b8 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -81,7 +81,7 @@ public: virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg); + std::string& tooltip_msg); virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleUnicodeCharHere(llwchar uni_char); @@ -103,8 +103,8 @@ public: // LLTextureCtrl interface void showPicker(BOOL take_focus); - void setLabel(const LLString& label); - const LLString& getLabel() const { return mLabel; } + void setLabel(const std::string& label); + const std::string& getLabel() const { return mLabel; } void setAllowNoTexture( BOOL b ) { mAllowNoTexture = b; } bool getAllowNoTexture() const { return mAllowNoTexture; } @@ -116,10 +116,10 @@ public: void setDefaultImageAssetID( const LLUUID& id ) { mDefaultImageAssetID = id; } - const LLString& getDefaultImageName() const { return mDefaultImageName; } + const std::string& getDefaultImageName() const { return mDefaultImageName; } const LLUUID& getDefaultImageAssetID() const { return mDefaultImageAssetID; } - void setCaption(const LLString& caption); + void setCaption(const std::string& caption); void setCanApplyImmediately(BOOL b); void setImmediateFilterPermMask(PermissionMask mask) @@ -163,11 +163,11 @@ private: LLUUID mImageItemID; LLUUID mImageAssetID; LLUUID mDefaultImageAssetID; - LLString mDefaultImageName; + std::string mDefaultImageName; LLHandle<LLFloater> mFloaterHandle; LLTextBox* mTentativeLabel; LLTextBox* mCaption; - LLString mLabel; + std::string mLabel; BOOL mAllowNoTexture; // If true, the user can select "none" as an option LLCoordGL mLastFloaterLeftTop; PermissionMask mImmediateFilterPermMask; @@ -178,7 +178,7 @@ private: BOOL mValid; BOOL mDirty; BOOL mShowLoadingPlaceholder; - LLString mLoadingPlaceholderString; + std::string mLoadingPlaceholderString; }; // XUI HACK: When floaters converted, switch this file to lltexturepicker.h/cpp diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index c5ae50c050..f32e4dd531 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -235,7 +235,7 @@ private: /*virtual*/ void startWork(S32 param); // called from addWork() (MAIN THREAD) /*virtual*/ void endWork(S32 param, bool aborted); // called from doWork() (MAIN THREAD) - virtual LLString getName() { return LLString::null; } + virtual std::string getName() { return LLStringUtil::null; } void resetFormattedData(); void setImagePriority(F32 priority); @@ -345,18 +345,18 @@ class LLTextureFetchLocalFileWorker : public LLTextureFetchWorker friend class LLTextureFetch; protected: - LLTextureFetchLocalFileWorker(LLTextureFetch* fetcher, const LLString& filename, const LLUUID& id, const LLHost& host, + LLTextureFetchLocalFileWorker(LLTextureFetch* fetcher, const std::string& filename, const LLUUID& id, const LLHost& host, F32 priority, S32 discard, S32 size) : LLTextureFetchWorker(fetcher, id, host, priority, discard, size), mFileName(filename) {} private: - /*virtual*/ LLString getName() { return mFileName; } + /*virtual*/ std::string getName() { return mFileName; } private: - LLString mFileName; + std::string mFileName; }; @@ -1313,10 +1313,10 @@ LLTextureFetch::~LLTextureFetch() bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 priority, S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux) { - return createRequest(LLString::null, id, host, priority, w, h, c, desired_discard, needs_aux); + return createRequest(LLStringUtil::null, id, host, priority, w, h, c, desired_discard, needs_aux); } -bool LLTextureFetch::createRequest(const LLString& filename, const LLUUID& id, const LLHost& host, F32 priority, +bool LLTextureFetch::createRequest(const std::string& filename, const LLUUID& id, const LLHost& host, F32 priority, S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux) { if (mDebugPause) diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 9f55a4ee92..e0f444b3cd 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -55,7 +55,7 @@ public: bool createRequest(const LLUUID& id, const LLHost& host, F32 priority, S32 w, S32 h, S32 c, S32 discard, bool needs_aux); - bool createRequest(const LLString& filename, const LLUUID& id, const LLHost& host, F32 priority, + bool createRequest(const std::string& filename, const LLUUID& id, const LLHost& host, F32 priority, S32 w, S32 h, S32 c, S32 discard, bool needs_aux); void deleteRequest(const LLUUID& id, bool cancel); bool getRequestFinished(const LLUUID& id, S32& discard_level, diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index a9005ef71b..43f8391b55 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -61,11 +61,11 @@ std::set<LLViewerImage*> LLTextureView::sDebugImages; //////////////////////////////////////////////////////////////////////////// -static LLString title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download] pk/max"); -static LLString title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max"); -static LLString title_string2("State"); -static LLString title_string3("Pkt Bnd"); -static LLString title_string4(" W x H (Dis) Mem"); +static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch) [download] pk/max"); +static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max"); +static std::string title_string2("State"); +static std::string title_string3("Pkt Bnd"); +static std::string title_string4(" W x H (Dis) Mem"); static S32 title_x1 = 0; static S32 title_x2 = 440; @@ -175,7 +175,7 @@ void LLTextureBar::draw() // The texture UUID or name // The progress bar for the texture, highlighted if it's being download // Various numerical stats. - char tex_str[256]; + std::string tex_str; S32 left, right; S32 top = 0; S32 bottom = top + 6; @@ -184,28 +184,28 @@ void LLTextureBar::draw() LLGLSUIDefault gls_ui; // Name, pixel_area, requested pixel area, decode priority - char uuid_str[255]; + std::string uuid_str; mImagep->mID.toString(uuid_str); - uuid_str[8] = 0; + uuid_str = uuid_str.substr(0,7); if (mTextureView->mOrderFetch) { - sprintf(tex_str, "%s %7.0f %d(%d) 0x%08x(%8.0f)", - uuid_str, - mImagep->mMaxVirtualSize, - mImagep->mDesiredDiscardLevel, - mImagep->mRequestedDiscardLevel, - mImagep->mFetchPriority, - mImagep->getDecodePriority()); + tex_str = llformat("%s %7.0f %d(%d) 0x%08x(%8.0f)", + uuid_str.c_str(), + mImagep->mMaxVirtualSize, + mImagep->mDesiredDiscardLevel, + mImagep->mRequestedDiscardLevel, + mImagep->mFetchPriority, + mImagep->getDecodePriority()); } else { - sprintf(tex_str, "%s %7.0f %d(%d) %8.0f(0x%08x)", - uuid_str, - mImagep->mMaxVirtualSize, - mImagep->mDesiredDiscardLevel, - mImagep->mRequestedDiscardLevel, - mImagep->getDecodePriority(), - mImagep->mFetchPriority); + tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x)", + uuid_str.c_str(), + mImagep->mMaxVirtualSize, + mImagep->mDesiredDiscardLevel, + mImagep->mRequestedDiscardLevel, + mImagep->getDecodePriority(), + mImagep->mFetchPriority); } LLFontGL::sMonospace->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(), @@ -213,7 +213,7 @@ void LLTextureBar::draw() // State // Hack: mirrored from lltexturefetch.cpp - struct { const char* desc; LLColor4 color; } fetch_state_desc[] = { + struct { const std::string desc; LLColor4 color; } fetch_state_desc[] = { { "---", LLColor4::red }, // INVALID { "INI", LLColor4::white }, // INIT { "DSK", LLColor4::cyan }, // LOAD_FROM_TEXTURE_CACHE @@ -325,14 +325,14 @@ void LLTextureBar::draw() LLGLSUIDefault gls_ui; // draw the packet data // { -// LLString num_str = llformat("%3d/%3d", mImagep->mLastPacket+1, mImagep->mPackets); +// std::string num_str = llformat("%3d/%3d", mImagep->mLastPacket+1, mImagep->mPackets); // LLFontGL::sMonospace->renderUTF8(num_str, 0, bar_left + 100, getRect().getHeight(), color, // LLFontGL::LEFT, LLFontGL::TOP); // } // draw the image size at the end { - LLString num_str = llformat("%3dx%3d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(), + std::string num_str = llformat("%3dx%3d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(), mImagep->getDiscardLevel(), mImagep->mTextureMemory); LLFontGL::sMonospace->renderUTF8(num_str, 0, title_x4, getRect().getHeight(), color, LLFontGL::LEFT, LLFontGL::TOP); @@ -474,13 +474,13 @@ void LLGLTexMemBar::draw() S32 dx1 = 0; if (LLAppViewer::getTextureFetch()->mDebugPause) { - LLFontGL::sMonospace->renderUTF8("!", 0, title_x1, line_height, + LLFontGL::sMonospace->renderUTF8(std::string("!"), 0, title_x1, line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } if (mTextureView->mFreezeView) { - LLFontGL::sMonospace->renderUTF8("*", 0, title_x1, line_height, + LLFontGL::sMonospace->renderUTF8(std::string("*"), 0, title_x1, line_height, text_color, LLFontGL::LEFT, LLFontGL::TOP); dx1 += 8; } @@ -713,8 +713,8 @@ void LLTextureView::draw() /* count = gImageList.getNumImages(); - char info_string[512]; - sprintf(info_string, "Global Info:\nTexture Count: %d", count); + std::string info_string; + info_string = llformat("Global Info:\nTexture Count: %d", count); mInfoTextp->setText(info_string); */ diff --git a/indra/newview/lltool.cpp b/indra/newview/lltool.cpp index 0398b7a0c1..22690b550a 100644 --- a/indra/newview/lltool.cpp +++ b/indra/newview/lltool.cpp @@ -46,9 +46,9 @@ extern BOOL gDebugClicks; //static -const LLString LLTool::sNameNull("null"); +const std::string LLTool::sNameNull("null"); -LLTool::LLTool( const LLString& name, LLToolComposite* composite ) : +LLTool::LLTool( const std::string& name, LLToolComposite* composite ) : mComposite( composite ), mName(name) { @@ -124,7 +124,7 @@ BOOL LLTool::handleRightMouseUp(S32 x, S32 y, MASK mask) return FALSE; } -BOOL LLTool::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) +BOOL LLTool::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) { // by default, didn't handle it // llinfos << "LLTool::handleToolTip" << llendl; diff --git a/indra/newview/lltool.h b/indra/newview/lltool.h index 7d565f1574..3cc7f24712 100644 --- a/indra/newview/lltool.h +++ b/indra/newview/lltool.h @@ -47,7 +47,7 @@ class LLTool : public LLMouseHandler { public: - LLTool( const LLString& name, LLToolComposite* composite = NULL ); + LLTool( const std::string& name, LLToolComposite* composite = NULL ); virtual ~LLTool(); // Hack to support LLFocusMgr @@ -61,14 +61,14 @@ public: virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); - virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen); + virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen); // Return FALSE to allow context menu to be shown. virtual void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const { *local_x = screen_x; *local_y = screen_y; } virtual void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const { *screen_x = local_x; *screen_y = local_y; } - virtual const LLString& getName() const { return mName; } + virtual const std::string& getName() const { return mName; } // New virtual functions virtual LLViewerObject* getEditingObject() { return NULL; } @@ -99,10 +99,10 @@ public: protected: LLToolComposite* mComposite; // Composite will handle mouse captures. - LLString mName; + std::string mName; public: - static const LLString sNameNull; + static const std::string sNameNull; }; #endif diff --git a/indra/newview/lltoolbar.cpp b/indra/newview/lltoolbar.cpp index 1ab1b15108..39dc0362b3 100644 --- a/indra/newview/lltoolbar.cpp +++ b/indra/newview/lltoolbar.cpp @@ -75,7 +75,7 @@ class LLFakeResizeHandle : public LLResizeHandle { public: - LLFakeResizeHandle(const LLString& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner = RIGHT_BOTTOM ) + LLFakeResizeHandle(const std::string& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner = RIGHT_BOTTOM ) : LLResizeHandle(name, rect, min_width, min_height, corner ) { @@ -169,7 +169,7 @@ BOOL LLToolBar::postBuild() if(mResizeHandle == NULL) { LLRect rect(0, 0, RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT); - mResizeHandle = new LLFakeResizeHandle(LLString(""), rect, RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT); + mResizeHandle = new LLFakeResizeHandle(std::string(""), rect, RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT); this->addChildAtEnd(mResizeHandle); LLLayoutStack* toolbar_stack = getChild<LLLayoutStack>("toolbar_stack"); toolbar_stack->reshape(toolbar_stack->getRect().getWidth() - RESIZE_HANDLE_WIDTH, toolbar_stack->getRect().getHeight()); @@ -191,7 +191,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { LLButton* inventory_btn = getChild<LLButton>("inventory_btn"); if (!inventory_btn) return FALSE; @@ -356,7 +356,7 @@ void LLToolBar::updateCommunicateList() LLFloaterIMPanel* im_floaterp = (LLFloaterIMPanel*)floater_handle_it->get(); if (im_floaterp) { - LLString floater_title = im_floaterp->getNumUnreadMessages() > 0 ? "*" : ""; + std::string floater_title = im_floaterp->getNumUnreadMessages() > 0 ? "*" : ""; floater_title.append(im_floaterp->getShortTitle()); itemp = communicate_button->add(floater_title, im_floaterp->getSessionID(), ADD_TOP); if (im_floaterp == frontmost_floater) diff --git a/indra/newview/lltoolbar.h b/indra/newview/lltoolbar.h index 28a03aa5d9..19761692c9 100644 --- a/indra/newview/lltoolbar.h +++ b/indra/newview/lltoolbar.h @@ -56,7 +56,7 @@ public: EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, - LLString& tooltip_msg); + std::string& tooltip_msg); /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); diff --git a/indra/newview/lltoolbrush.cpp b/indra/newview/lltoolbrush.cpp index 32b27fb876..1b006822c1 100644 --- a/indra/newview/lltoolbrush.cpp +++ b/indra/newview/lltoolbrush.cpp @@ -89,7 +89,7 @@ const LLColor4 OVERLAY_COLOR(1.0f, 1.0f, 1.0f, 1.0f); // constructor LLToolBrushLand::LLToolBrushLand() -: LLTool("Land"), +: LLTool(std::string("Land")), mStartingZ( 0.0f ), mMouseX( 0 ), mMouseY(0), @@ -589,7 +589,7 @@ void LLToolBrushLand::alertNoTerraform(LLViewerRegion* regionp) { if (!regionp) return; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REGION]"] = regionp->getName(); gViewerWindow->alertXml("RegionNoTerraforming", args); diff --git a/indra/newview/lltoolcomp.cpp b/indra/newview/lltoolcomp.cpp index 8d1faa850f..4efc6f74d4 100644 --- a/indra/newview/lltoolcomp.cpp +++ b/indra/newview/lltoolcomp.cpp @@ -84,7 +84,7 @@ void LLToolComposite::setCurrentTool( LLTool* new_tool ) } } -LLToolComposite::LLToolComposite(const LLString& name) +LLToolComposite::LLToolComposite(const std::string& name) : LLTool(name), mCur(NULL), mDefault(NULL), mSelected(FALSE), mMouseDown(FALSE), mManip(NULL), mSelectRect(NULL) @@ -129,7 +129,7 @@ void LLToolComposite::handleSelect() //---------------------------------------------------------------------------- LLToolCompInspect::LLToolCompInspect() -: LLToolComposite("Inspect") +: LLToolComposite(std::string("Inspect")) { mSelectRect = new LLToolSelectRect(this); mDefault = mSelectRect; @@ -187,7 +187,7 @@ BOOL LLToolCompInspect::handleDoubleClick(S32 x, S32 y, MASK mask) //---------------------------------------------------------------------------- LLToolCompTranslate::LLToolCompTranslate() - : LLToolComposite("Move") + : LLToolComposite(std::string("Move")) { mManip = new LLManipTranslate(this); mSelectRect = new LLToolSelectRect(this); @@ -314,7 +314,7 @@ void LLToolCompTranslate::render() // LLToolCompScale LLToolCompScale::LLToolCompScale() - : LLToolComposite("Stretch") + : LLToolComposite(std::string("Stretch")) { mManip = new LLManipScale(this); mSelectRect = new LLToolSelectRect(this); @@ -434,7 +434,7 @@ void LLToolCompScale::render() // LLToolCompCreate LLToolCompCreate::LLToolCompCreate() - : LLToolComposite("Create") + : LLToolComposite(std::string("Create")) { mPlacer = new LLToolPlacer(); mSelectRect = new LLToolSelectRect(this); @@ -514,7 +514,7 @@ BOOL LLToolCompCreate::handleMouseUp(S32 x, S32 y, MASK mask) // LLToolCompRotate LLToolCompRotate::LLToolCompRotate() - : LLToolComposite("Rotate") + : LLToolComposite(std::string("Rotate")) { mManip = new LLManipRotate(this); mSelectRect = new LLToolSelectRect(this); @@ -633,11 +633,11 @@ void LLToolCompRotate::render() // LLToolCompGun LLToolCompGun::LLToolCompGun() - : LLToolComposite("Mouselook") + : LLToolComposite(std::string("Mouselook")) { mGun = new LLToolGun(this); mGrab = new LLToolGrab(this); - mNull = new LLTool("null", this); + mNull = new LLTool(std::string("null"), this); setCurrentTool(mGun); mDefault = mGun; diff --git a/indra/newview/lltoolcomp.h b/indra/newview/lltoolcomp.h index d6ec6032cd..8926cd34d2 100644 --- a/indra/newview/lltoolcomp.h +++ b/indra/newview/lltoolcomp.h @@ -47,7 +47,7 @@ class LLTextBox; class LLToolComposite : public LLTool { public: - LLToolComposite(const LLString& name); + LLToolComposite(const std::string& name); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) = 0; // Sets the current tool virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); // Returns to the default tool @@ -97,7 +97,7 @@ protected: LLToolSelectRect* mSelectRect; public: - static const LLString sNameComp; + static const std::string sNameComp; }; diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 47ed30a34b..940f5ba62d 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -569,8 +569,7 @@ LLToolDragAndDrop::dragOrDrop3dImpl LLToolDragAndDrop::sDragAndDrop3d[DAD_COUNT] }; LLToolDragAndDrop::LLToolDragAndDrop() - : - LLTool("draganddrop", NULL), +: LLTool(std::string("draganddrop"), NULL), mDragStartX(0), mDragStartY(0), mSource(SOURCE_AGENT), @@ -822,7 +821,7 @@ BOOL LLToolDragAndDrop::handleKey(KEY key, MASK mask) return FALSE; } -BOOL LLToolDragAndDrop::handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen) +BOOL LLToolDragAndDrop::handleToolTip(S32 x, S32 y, std::string& msg, LLRect *sticky_rect_screen) { if (!mToolTipMsg.empty()) { @@ -1169,7 +1168,7 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj, if (hit_obj->isInventoryDirty()) { hit_obj->fetchInventoryFromServer(); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[ERROR_MESSAGE]"] = "Unable to add texture.\nPlease wait a few seconds and try again."; gViewerWindow->alertXml("ErrorMessage", args); return FALSE; @@ -1674,8 +1673,8 @@ void LLToolDragAndDrop::commitGiveInventoryItem(const LLUUID& to_agent, FALSE, gAgent.getSessionID(), to_agent, - name.c_str(), - item->getName().c_str(), + name, + item->getName(), IM_ONLINE, IM_INVENTORY_OFFERED, transaction_id, @@ -1756,7 +1755,7 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent, { LLGiveInventoryInfo* info = NULL; info = new LLGiveInventoryInfo(to_agent, cat->getUUID()); - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[COUNT]"] = llformat("%d",giveable.countNoCopy()); gViewerWindow->alertXml("CannotCopyCountItems", args, &LLToolDragAndDrop::handleCopyProtectedCategory, @@ -1877,8 +1876,8 @@ void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent, FALSE, gAgent.getSessionID(), to_agent, - name.c_str(), - cat->getName().c_str(), + name, + cat->getName(), IM_ONLINE, IM_INVENTORY_OFFERED, transaction_id, @@ -2990,11 +2989,11 @@ LLInventoryObject* LLToolDragAndDrop::locateMultipleInventory(LLViewerInventoryC } */ -void LLToolDragAndDrop::createContainer(LLViewerInventoryItem::item_array_t &items, const char* preferred_name ) -{ - llwarns << "LLToolDragAndDrop::createContainer()" << llendl; - return; -} +// void LLToolDragAndDrop::createContainer(LLViewerInventoryItem::item_array_t &items, const char* preferred_name ) +// { +// llwarns << "LLToolDragAndDrop::createContainer()" << llendl; +// return; +// } // utility functions diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h index b5517c29c1..8f6d1713fa 100644 --- a/indra/newview/lltooldraganddrop.h +++ b/indra/newview/lltooldraganddrop.h @@ -55,7 +55,7 @@ public: virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleKey(KEY key, MASK mask); - virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen); + virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect *sticky_rect_screen); virtual void onMouseCaptureLost(); virtual void handleDeselect(); @@ -127,7 +127,7 @@ protected: EAcceptance mLastAccept; BOOL mDrop; S32 mCurItemIndex; - LLString mToolTipMsg; + std::string mToolTipMsg; // array of pointers to functions that implement the logic to // dragging and dropping into the simulator. @@ -187,7 +187,6 @@ protected: // LLViewerInventoryCategory::cat_array_t& cats, // LLViewerInventoryItem::item_array_t& items); - void createContainer(LLViewerInventoryItem::item_array_t &items, const char* preferred_name); void dropObject(LLViewerObject* raycast_target, BOOL bypass_sim_raycast, BOOL from_task_inventory, diff --git a/indra/newview/lltoolface.cpp b/indra/newview/lltoolface.cpp index 0783cd14b7..3248913182 100644 --- a/indra/newview/lltoolface.cpp +++ b/indra/newview/lltoolface.cpp @@ -52,7 +52,7 @@ // LLToolFace::LLToolFace() -: LLTool("Texture") +: LLTool(std::string("Texture")) { } diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp index 7b1394461a..b46d25583a 100644 --- a/indra/newview/lltoolfocus.cpp +++ b/indra/newview/lltoolfocus.cpp @@ -69,7 +69,7 @@ const F32 FOCUS_OFFSET_FACTOR = 1.f; // LLToolCamera::LLToolCamera() -: LLTool("Camera"), +: LLTool(std::string("Camera")), mAccumX(0), mAccumY(0), mMouseDownX(0), diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp index 5073be3173..a41e9381f6 100644 --- a/indra/newview/lltoolgrab.cpp +++ b/indra/newview/lltoolgrab.cpp @@ -75,7 +75,7 @@ extern BOOL gDebugClicks; // Methods // LLToolGrab::LLToolGrab( LLToolComposite* composite ) -: LLTool( "Grab", composite ), +: LLTool( std::string("Grab"), composite ), mMode( GRAB_INACTIVE ), mVerticalDragging( FALSE ), mHitLand(FALSE), diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp index 134188e2f6..2b6a065a43 100644 --- a/indra/newview/lltoolgun.cpp +++ b/indra/newview/lltoolgun.cpp @@ -48,8 +48,7 @@ #include "lltoolgrab.h" LLToolGun::LLToolGun( LLToolComposite* composite ) - : - LLTool( "gun", composite ) +: LLTool( std::string("gun"), composite ) { } diff --git a/indra/newview/lltoolindividual.cpp b/indra/newview/lltoolindividual.cpp index 0236a5027a..3fa96cd84a 100644 --- a/indra/newview/lltoolindividual.cpp +++ b/indra/newview/lltoolindividual.cpp @@ -61,7 +61,7 @@ // Default constructor LLToolIndividual::LLToolIndividual() - : LLTool("Individual") +: LLTool(std::string("Individual")) { } diff --git a/indra/newview/lltoolmgr.cpp b/indra/newview/lltoolmgr.cpp index a4c7856411..ac2f20895c 100644 --- a/indra/newview/lltoolmgr.cpp +++ b/indra/newview/lltoolmgr.cpp @@ -74,7 +74,7 @@ LLToolMgr::LLToolMgr() mSelectedTool( NULL ), mCurrentToolset( NULL ) { - gToolNull = new LLTool(NULL); // Does nothing + gToolNull = new LLTool(LLStringUtil::null); // Does nothing setCurrentTool(gToolNull); gBasicToolset = new LLToolset(); diff --git a/indra/newview/lltoolobjpicker.cpp b/indra/newview/lltoolobjpicker.cpp index 8354792e31..67e0db962f 100644 --- a/indra/newview/lltoolobjpicker.cpp +++ b/indra/newview/lltoolobjpicker.cpp @@ -50,7 +50,7 @@ LLToolObjPicker::LLToolObjPicker() -: LLTool( "ObjPicker", NULL ), +: LLTool( std::string("ObjPicker"), NULL ), mPicked( FALSE ), mHitObjectID( LLUUID::null ), mExitCallback( NULL ), diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 310b677bff..5954a7f0ff 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -81,7 +81,7 @@ static ECursorType cursor_from_parcel_media(U8 click_action); LLToolPie::LLToolPie() -: LLTool("Select"), +: LLTool(std::string("Select")), mPieMouseButtonDown( FALSE ), mGrabMouseButtonDown( FALSE ), mHitLand( FALSE ), @@ -327,15 +327,15 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show) // Object is an avatar, so check for mute by id. LLVOAvatar* avatar = (LLVOAvatar*)object; - LLString name = avatar->getFullname(); + std::string name = avatar->getFullname(); if (LLMuteList::getInstance()->isMuted(avatar->getID(), name)) { - gMenuHolder->childSetText("Avatar Mute", LLString("Unmute")); // *TODO:Translate + gMenuHolder->childSetText("Avatar Mute", std::string("Unmute")); // *TODO:Translate //gMutePieMenu->setLabel("Unmute"); } else { - gMenuHolder->childSetText("Avatar Mute", LLString("Mute")); // *TODO:Translate + gMenuHolder->childSetText("Avatar Mute", std::string("Mute")); // *TODO:Translate //gMutePieMenu->setLabel("Mute"); } @@ -348,7 +348,7 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show) else { // BUG: What about chatting child objects? - LLString name; + std::string name; LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); if (node) { @@ -356,12 +356,12 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show) } if (LLMuteList::getInstance()->isMuted(object->getID(), name)) { - gMenuHolder->childSetText("Object Mute", LLString("Unmute")); // *TODO:Translate + gMenuHolder->childSetText("Object Mute", std::string("Unmute")); // *TODO:Translate //gMuteObjectPieMenu->setLabel("Unmute"); } else { - gMenuHolder->childSetText("Object Mute", LLString("Mute")); // *TODO:Translate + gMenuHolder->childSetText("Object Mute", std::string("Mute")); // *TODO:Translate //gMuteObjectPieMenu->setLabel("Mute"); } @@ -761,7 +761,7 @@ static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp) std::string media_url = std::string ( parcel->getMediaURL () ); std::string media_type = std::string ( parcel->getMediaType() ); - LLString::trim(media_url); + LLStringUtil::trim(media_url); // Get the scheme, see if that is handled as well. LLURI uri(media_url); @@ -790,7 +790,7 @@ static ECursorType cursor_from_parcel_media(U8 click_action) std::string media_url = std::string ( parcel->getMediaURL () ); std::string media_type = std::string ( parcel->getMediaType() ); - LLString::trim(media_url); + LLStringUtil::trim(media_url); // Get the scheme, see if that is handled as well. LLURI uri(media_url); diff --git a/indra/newview/lltoolpipette.cpp b/indra/newview/lltoolpipette.cpp index aa9500fc0a..a565e4361b 100644 --- a/indra/newview/lltoolpipette.cpp +++ b/indra/newview/lltoolpipette.cpp @@ -51,8 +51,8 @@ // LLToolPipette::LLToolPipette() -: LLTool("Pipette"), -mSuccess(TRUE) +: LLTool(std::string("Pipette")), + mSuccess(TRUE) { mSelectCallback = NULL; mUserData = NULL; @@ -95,7 +95,7 @@ BOOL LLToolPipette::handleHover(S32 x, S32 y, MASK mask) return FALSE; } -BOOL LLToolPipette::handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen) +BOOL LLToolPipette::handleToolTip(S32 x, S32 y, std::string& msg, LLRect *sticky_rect_screen) { if (mTooltipMsg.empty()) { @@ -133,7 +133,7 @@ void LLToolPipette::setSelectCallback(select_callback callback, void* user_data) mUserData = user_data; } -void LLToolPipette::setResult(BOOL success, const LLString& msg) +void LLToolPipette::setResult(BOOL success, const std::string& msg) { mTooltipMsg = msg; mSuccess = success; diff --git a/indra/newview/lltoolpipette.h b/indra/newview/lltoolpipette.h index ef4718bd62..b88a6eebc8 100644 --- a/indra/newview/lltoolpipette.h +++ b/indra/newview/lltoolpipette.h @@ -52,11 +52,11 @@ public: virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleHover(S32 x, S32 y, MASK mask); - virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen); + virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect *sticky_rect_screen); typedef void (*select_callback)(const LLTextureEntry& te, void *data); void setSelectCallback(select_callback callback, void* user_data); - void setResult(BOOL success, const LLString& msg); + void setResult(BOOL success, const std::string& msg); static void pickCallback(S32 x, S32 y, MASK mask); @@ -64,7 +64,7 @@ protected: LLTextureEntry mTextureEntry; select_callback mSelectCallback; BOOL mSuccess; - LLString mTooltipMsg; + std::string mTooltipMsg; void* mUserData; }; diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp index 062d760322..7d4d0397cc 100644 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -70,7 +70,7 @@ const LLVector3 DEFAULT_OBJECT_SCALE(0.5f, 0.5f, 0.5f); LLPCode LLToolPlacer::sObjectType = LL_PCODE_CUBE; LLToolPlacer::LLToolPlacer() -: LLTool( "Create" ) +: LLTool( std::string("Create") ) { } @@ -570,7 +570,7 @@ LLToolPlacerPanel::LLToolPlacerPanel(const std::string& name, const LLRect& rect */ } -void LLToolPlacerPanel::addButton( const LLString& up_state, const LLString& down_state, LLPCode* pcode ) +void LLToolPlacerPanel::addButton( const std::string& up_state, const std::string& down_state, LLPCode* pcode ) { const S32 TOOL_SIZE = 32; const S32 HORIZ_SPACING = TOOL_SIZE + 5; @@ -593,11 +593,11 @@ void LLToolPlacerPanel::addButton( const LLString& up_state, const LLString& dow TOOL_SIZE ); LLButton* btn = new LLButton( - "ToolPlacerOptBtn", + std::string("ToolPlacerOptBtn"), rect, up_state, down_state, - "", &LLToolPlacerPanel::setObjectType, + LLStringUtil::null, &LLToolPlacerPanel::setObjectType, pcode, LLFontGL::sSansSerif); btn->setFollowsBottom(); diff --git a/indra/newview/lltoolplacer.h b/indra/newview/lltoolplacer.h index b016470129..8c3176e0b5 100644 --- a/indra/newview/lltoolplacer.h +++ b/indra/newview/lltoolplacer.h @@ -98,7 +98,7 @@ public: static LLPCode sGrass; private: - void addButton( const LLString& up_state, const LLString& down_state, LLPCode* pcode ); + void addButton( const std::string& up_state, const std::string& down_state, LLPCode* pcode ); private: static S32 sButtonsAdded; diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 1c19de5571..8f84013a26 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -56,7 +56,7 @@ extern BOOL gAllowSelectAvatar; const F32 SELECTION_ROTATION_TRESHOLD = 0.1f; LLToolSelect::LLToolSelect( LLToolComposite* composite ) -: LLTool( "Select", composite ), +: LLTool( std::string("Select"), composite ), mIgnoreGroup( FALSE ) { } diff --git a/indra/newview/lltoolselectland.cpp b/indra/newview/lltoolselectland.cpp index 38e9811b73..8ea8ebfc59 100644 --- a/indra/newview/lltoolselectland.cpp +++ b/indra/newview/lltoolselectland.cpp @@ -51,7 +51,7 @@ // LLToolSelectLand::LLToolSelectLand( ) -: LLTool( "Parcel" ), +: LLTool( std::string("Parcel") ), mDragStartGlobal(), mDragEndGlobal(), mDragEndValid(FALSE), diff --git a/indra/newview/lltoolview.cpp b/indra/newview/lltoolview.cpp index 23012993a3..142cdd65bf 100644 --- a/indra/newview/lltoolview.cpp +++ b/indra/newview/lltoolview.cpp @@ -77,50 +77,50 @@ LLToolView::~LLToolView() } //*TODO:translate? -void LLToolView::addTool(const LLString& icon_off, const LLString& icon_on, LLPanel* panel, LLTool* tool, LLView* hoverView, const char* label) -{ - llassert(tool); - - LLToolContainer* contain = new LLToolContainer(this); - - LLRect btn_rect = getButtonRect(mButtonCount); - - contain->mButton = new LLButton("ToolBtn", - btn_rect, - icon_off, - icon_on, - "", - &LLToolView::onClickToolButton, - contain, - LLFontGL::sSansSerif); - - contain->mPanel = panel; - contain->mTool = tool; - - addChild(contain->mButton); - mButtonCount++; - - const S32 LABEL_TOP_SPACING = 0; - const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); - S32 label_width = font->getWidth( label ); - LLRect label_rect; - label_rect.setLeftTopAndSize( - btn_rect.mLeft + btn_rect.getWidth() / 2 - label_width / 2, - btn_rect.mBottom - LABEL_TOP_SPACING, - label_width, - llfloor(font->getLineHeight())); - addChild( new LLTextBox( "tool label", label_rect, label, font ) ); - - // Can optionally ignore panel - if (contain->mPanel) - { - contain->mPanel->setBackgroundVisible( FALSE ); - contain->mPanel->setBorderVisible( FALSE ); - addChild(contain->mPanel); - } - - mContainList.push_back(contain); -} +// void LLToolView::addTool(const std::string& icon_off, const std::string& icon_on, LLPanel* panel, LLTool* tool, LLView* hoverView, const char* label) +// { +// llassert(tool); + +// LLToolContainer* contain = new LLToolContainer(this); + +// LLRect btn_rect = getButtonRect(mButtonCount); + +// contain->mButton = new LLButton("ToolBtn", +// btn_rect, +// icon_off, +// icon_on, +// "", +// &LLToolView::onClickToolButton, +// contain, +// LLFontGL::sSansSerif); + +// contain->mPanel = panel; +// contain->mTool = tool; + +// addChild(contain->mButton); +// mButtonCount++; + +// const S32 LABEL_TOP_SPACING = 0; +// const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); +// S32 label_width = font->getWidth( label ); +// LLRect label_rect; +// label_rect.setLeftTopAndSize( +// btn_rect.mLeft + btn_rect.getWidth() / 2 - label_width / 2, +// btn_rect.mBottom - LABEL_TOP_SPACING, +// label_width, +// llfloor(font->getLineHeight())); +// addChild( new LLTextBox( "tool label", label_rect, label, font ) ); + +// // Can optionally ignore panel +// if (contain->mPanel) +// { +// contain->mPanel->setBackgroundVisible( FALSE ); +// contain->mPanel->setBorderVisible( FALSE ); +// addChild(contain->mPanel); +// } + +// mContainList.push_back(contain); +// } LLRect LLToolView::getButtonRect(S32 button_index) diff --git a/indra/newview/lltoolview.h b/indra/newview/lltoolview.h index 23f4263602..7faa931532 100644 --- a/indra/newview/lltoolview.h +++ b/indra/newview/lltoolview.h @@ -73,8 +73,6 @@ public: static void onClickToolButton(void* container); - void addTool(const LLString& icon_off, const LLString& icon_on, LLPanel* panel, LLTool* tool, LLView* hoverView, const char* label); - LLView* getCurrentHoverView(); private: diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp index d1b87281f0..85d9504740 100644 --- a/indra/newview/lltracker.cpp +++ b/indra/newview/lltracker.cpp @@ -285,7 +285,7 @@ void LLTracker::render3D() // static -void LLTracker::trackAvatar( const LLUUID& avatar_id, const LLString& name ) +void LLTracker::trackAvatar( const LLUUID& avatar_id, const std::string& name ) { instance()->stopTrackingLandmark(); instance()->stopTrackingLocation(); @@ -297,7 +297,7 @@ void LLTracker::trackAvatar( const LLUUID& avatar_id, const LLString& name ) // static -void LLTracker::trackLandmark( const LLUUID& asset_id, const LLUUID& item_id, const LLString& name) +void LLTracker::trackLandmark( const LLUUID& asset_id, const LLUUID& item_id, const std::string& name) { instance()->stopTrackingAvatar(); instance()->stopTrackingLocation(); @@ -312,7 +312,7 @@ void LLTracker::trackLandmark( const LLUUID& asset_id, const LLUUID& item_id, co // static -void LLTracker::trackLocation(const LLVector3d& pos_global, const LLString& full_name, const LLString& tooltip, ETrackingLocationType location_type) +void LLTracker::trackLocation(const LLVector3d& pos_global, const std::string& full_name, const std::string& tooltip, ETrackingLocationType location_type) { instance()->stopTrackingAvatar(); instance()->stopTrackingLandmark(); @@ -398,7 +398,7 @@ BOOL LLTracker::hasLandmarkPosition() // static -const LLString& LLTracker::getTrackedLocationName() +const std::string& LLTracker::getTrackedLocationName() { return instance()->mTrackedLocationName; } @@ -557,8 +557,8 @@ void LLTracker::renderBeacon(LLVector3d pos_global, //gCylinder.render(1000); glPopMatrix(); - char text[1024]; /* Flawfinder: ignore */ - snprintf(text, sizeof(text), "%.0f m", to_vec.magVec()); /* Flawfinder: ignore */ + std::string text; + text = llformat( "%.0f m", to_vec.magVec()); LLWString wstr; wstr += utf8str_to_wstring(label); diff --git a/indra/newview/lltracker.h b/indra/newview/lltracker.h index 5f7ad98fe5..23d774d9db 100644 --- a/indra/newview/lltracker.h +++ b/indra/newview/lltracker.h @@ -87,15 +87,15 @@ public: static const LLUUID& getTrackedLandmarkAssetID() { return instance()->mTrackedLandmarkAssetID; } static const LLUUID& getTrackedLandmarkItemID() { return instance()->mTrackedLandmarkItemID; } - static void trackAvatar( const LLUUID& avatar_id, const LLString& name ); - static void trackLandmark( const LLUUID& landmark_asset_id, const LLUUID& landmark_item_id , const LLString& name); - static void trackLocation(const LLVector3d& pos, const LLString& full_name, const LLString& tooltip, ETrackingLocationType location_type = LOCATION_NOTHING); + static void trackAvatar( const LLUUID& avatar_id, const std::string& name ); + static void trackLandmark( const LLUUID& landmark_asset_id, const LLUUID& landmark_item_id , const std::string& name); + static void trackLocation(const LLVector3d& pos, const std::string& full_name, const std::string& tooltip, ETrackingLocationType location_type = LOCATION_NOTHING); // returns global pos of tracked thing static LLVector3d getTrackedPositionGlobal(); static BOOL hasLandmarkPosition(); - static const LLString& getTrackedLocationName(); + static const std::string& getTrackedLocationName(); static void drawHUDArrow(); @@ -107,8 +107,8 @@ public: static LLTracker* sTrackerp; static BOOL sCheesyBeacon; - static const LLString& getLabel() { return instance()->mLabel; } - static const LLString& getToolTip() { return instance()->mToolTip; } + static const std::string& getLabel() { return instance()->mLabel; } + static const std::string& getToolTip() { return instance()->mToolTip; } protected: LLTracker(); ~LLTracker(); @@ -137,10 +137,10 @@ protected: LLVector3d mTrackedPositionGlobal; - LLString mLabel; - LLString mToolTip; + std::string mLabel; + std::string mToolTip; - LLString mTrackedLandmarkName; + std::string mTrackedLandmarkName; LLUUID mTrackedLandmarkAssetID; LLUUID mTrackedLandmarkItemID; LLDynamicArray<LLUUID> mLandmarkAssetIDList; @@ -149,7 +149,7 @@ protected: BOOL mHasLandmarkPosition; BOOL mLandmarkHasBeenVisited; - LLString mTrackedLocationName; + std::string mTrackedLocationName; BOOL mIsTrackingLocation; BOOL mHasReachedLocation; }; diff --git a/indra/newview/lluploaddialog.cpp b/indra/newview/lluploaddialog.cpp index 686e386578..e347affa52 100644 --- a/indra/newview/lluploaddialog.cpp +++ b/indra/newview/lluploaddialog.cpp @@ -64,7 +64,7 @@ void LLUploadDialog::modalUploadFinished() LLUploadDialog::LLUploadDialog( const std::string& msg) : - LLPanel( "Uploading...", LLRect(0,100,100,0) ) // dummy rect. Will reshape below. + LLPanel( std::string("Uploading..."), LLRect(0,100,100,0) ) // dummy rect. Will reshape below. { setBackgroundVisible( TRUE ); @@ -78,7 +78,7 @@ LLUploadDialog::LLUploadDialog( const std::string& msg) LLRect msg_rect; for (int line_num=0; line_num<16; ++line_num) { - mLabelBox[line_num] = new LLTextBox( "Filename", msg_rect, "Filename", font ); + mLabelBox[line_num] = new LLTextBox( std::string("Filename"), msg_rect, std::string("Filename"), font ); addChild(mLabelBox[line_num]); } @@ -116,9 +116,10 @@ void LLUploadDialog::setMessage( const std::string& msg) char* token = strtok( temp_msg, "\n" ); while( token ) { - S32 cur_width = S32(font->getWidth(token) + 0.99f) + TEXT_PAD; + std::string tokstr(token); + S32 cur_width = S32(font->getWidth(tokstr) + 0.99f) + TEXT_PAD; max_msg_width = llmax( max_msg_width, cur_width ); - msg_lines.push_back( std::string( token ) ); + msg_lines.push_back( tokstr ); token = strtok( NULL, "\n" ); } delete[] temp_msg; diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp index f103b9b0bf..5f26155bc0 100644 --- a/indra/newview/llurldispatcher.cpp +++ b/indra/newview/llurldispatcher.cpp @@ -326,7 +326,7 @@ void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const std::str bool LLURLDispatcherImpl::matchPrefix(const std::string& url, const std::string& prefix) { std::string test_prefix = url.substr(0, prefix.length()); - LLString::toLower(test_prefix); + LLStringUtil::toLower(test_prefix); return test_prefix == prefix; } diff --git a/indra/newview/llurlhistory.cpp b/indra/newview/llurlhistory.cpp index d5241a4e98..902ab88688 100644 --- a/indra/newview/llurlhistory.cpp +++ b/indra/newview/llurlhistory.cpp @@ -43,13 +43,13 @@ const int MAX_URL_COUNT = 10; ///////////////////////////////////////////////////////////////////////////// // static -bool LLURLHistory::loadFile(const LLString& filename) +bool LLURLHistory::loadFile(const std::string& filename) { LLSD data; { - LLString temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); + std::string temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); - llifstream file((temp_str + filename).c_str()); + llifstream file((temp_str + filename)); if (file.is_open()) { @@ -71,10 +71,10 @@ bool LLURLHistory::loadFile(const LLString& filename) } // static -bool LLURLHistory::saveFile(const LLString& filename) +bool LLURLHistory::saveFile(const std::string& filename) { - LLString temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); - llofstream out((temp_str + filename).c_str()); + std::string temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); + llofstream out((temp_str + filename)); if (!out.good()) { llwarns << "Unable to open " << filename << " for output." << llendl; diff --git a/indra/newview/llurlhistory.h b/indra/newview/llurlhistory.h index 317440f032..7d4dbab382 100644 --- a/indra/newview/llurlhistory.h +++ b/indra/newview/llurlhistory.h @@ -40,10 +40,10 @@ class LLURLHistory { public: // Loads an xml file of URLs. Currently only supports Parcel URL history - static bool loadFile(const LLString& filename); + static bool loadFile(const std::string& filename); // Saves the current history to XML - static bool saveFile(const LLString& filename); + static bool saveFile(const std::string& filename); static LLSD getURLHistory(const std::string& collection); diff --git a/indra/newview/llurlwhitelist.cpp b/indra/newview/llurlwhitelist.cpp index 6acd3c1a45..add997ac34 100644 --- a/indra/newview/llurlwhitelist.cpp +++ b/indra/newview/llurlwhitelist.cpp @@ -89,10 +89,10 @@ bool LLUrlWhiteList::load () clear (); // build filename for each user - LLString resolvedFilename = gDirUtilp->getExpandedFilename ( LL_PATH_PER_SL_ACCOUNT, mFilename.c_str () ); + std::string resolvedFilename = gDirUtilp->getExpandedFilename ( LL_PATH_PER_SL_ACCOUNT, mFilename ); // open a file for reading - llifstream file ( resolvedFilename.c_str () ); + llifstream file ( resolvedFilename ); if ( file.is_open () ) { // add each line in the file to the list @@ -118,10 +118,10 @@ bool LLUrlWhiteList::load () bool LLUrlWhiteList::save () { // build filename for each user - LLString resolvedFilename = gDirUtilp->getExpandedFilename ( LL_PATH_PER_SL_ACCOUNT, mFilename.c_str () ); + std::string resolvedFilename = gDirUtilp->getExpandedFilename ( LL_PATH_PER_SL_ACCOUNT, mFilename ); // open a file for writing - llofstream file ( resolvedFilename.c_str () ); + llofstream file ( resolvedFilename ); if ( file.is_open () ) { // for each entry we have @@ -149,9 +149,9 @@ bool LLUrlWhiteList::clear () return true; } -LLString url_cleanup(LLString pattern) +std::string url_cleanup(std::string pattern) { - LLString::trim(pattern); + LLStringUtil::trim(pattern); S32 length = pattern.length(); S32 position = 0; std::string::reverse_iterator it = pattern.rbegin(); @@ -164,7 +164,7 @@ LLString url_cleanup(LLString pattern) { // found second to last '/' S32 desired_length = length - position; - LLString::truncate(pattern, desired_length); + LLStringUtil::truncate(pattern, desired_length); break; } ++position; @@ -174,9 +174,9 @@ LLString url_cleanup(LLString pattern) /////////////////////////////////////////////////////////////////////////////// // -bool LLUrlWhiteList::addItem ( const LLString& itemIn, bool saveAfterAdd ) +bool LLUrlWhiteList::addItem ( const std::string& itemIn, bool saveAfterAdd ) { - LLString item = url_cleanup(itemIn); + std::string item = url_cleanup(itemIn); mUrlList.push_back ( item ); @@ -189,7 +189,7 @@ bool LLUrlWhiteList::addItem ( const LLString& itemIn, bool saveAfterAdd ) /////////////////////////////////////////////////////////////////////////////// // -bool LLUrlWhiteList::getFirst ( LLString& valueOut ) +bool LLUrlWhiteList::getFirst ( std::string& valueOut ) { if ( mUrlList.size () == 0 ) return false; @@ -202,7 +202,7 @@ bool LLUrlWhiteList::getFirst ( LLString& valueOut ) /////////////////////////////////////////////////////////////////////////////// // -bool LLUrlWhiteList::getNext ( LLString& valueOut ) +bool LLUrlWhiteList::getNext ( std::string& valueOut ) { if ( mCurIndex >= mUrlList.size () ) return false; @@ -214,7 +214,7 @@ bool LLUrlWhiteList::getNext ( LLString& valueOut ) /////////////////////////////////////////////////////////////////////////////// // -bool LLUrlWhiteList::containsMatch ( const LLString& patternIn ) +bool LLUrlWhiteList::containsMatch ( const std::string& patternIn ) { return false; } diff --git a/indra/newview/llurlwhitelist.h b/indra/newview/llurlwhitelist.h index b9901b68c2..eab63cb542 100644 --- a/indra/newview/llurlwhitelist.h +++ b/indra/newview/llurlwhitelist.h @@ -48,21 +48,21 @@ class LLUrlWhiteList bool save (); bool clear (); - bool addItem ( const LLString& itemIn, bool saveAfterAdd ); + bool addItem ( const std::string& itemIn, bool saveAfterAdd ); - bool containsMatch ( const LLString& patternIn ); + bool containsMatch ( const std::string& patternIn ); - bool getFirst ( LLString& valueOut ); - bool getNext ( LLString& valueOut ); + bool getFirst ( std::string& valueOut ); + bool getNext ( std::string& valueOut ); private: LLUrlWhiteList (); static LLUrlWhiteList* sInstance; - typedef std::vector < LLString > string_list_t ; + typedef std::vector < std::string > string_list_t ; bool mLoaded; - const LLString mFilename; + const std::string mFilename; string_list_t mUrlList; U32 mCurIndex; }; diff --git a/indra/newview/llviewchildren.cpp b/indra/newview/llviewchildren.cpp index 11a5384f85..a88e3f67d4 100644 --- a/indra/newview/llviewchildren.cpp +++ b/indra/newview/llviewchildren.cpp @@ -52,18 +52,18 @@ LLViewChildren::LLViewChildren(LLPanel& parent) } -void LLViewChildren::show(const char* id, bool visible) +void LLViewChildren::show(const std::string& id, bool visible) { mParent.childSetVisible(id, visible); } -void LLViewChildren::enable(const char* id, bool enabled) +void LLViewChildren::enable(const std::string& id, bool enabled) { mParent.childSetEnabled(id, enabled); } void LLViewChildren::setText( - const char* id, const std::string& text, bool visible) + const std::string& id, const std::string& text, bool visible) { LLTextBox* child = mParent.getChild<LLTextBox>(id); if (child) @@ -74,7 +74,7 @@ void LLViewChildren::setText( } void LLViewChildren::setWrappedText( - const char* id, const std::string& text, bool visible) + const std::string& id, const std::string& text, bool visible) { LLTextBox* child = mParent.getChild<LLTextBox>(id); if (child) @@ -84,7 +84,7 @@ void LLViewChildren::setWrappedText( } } -void LLViewChildren::setBadge(const char* id, Badge badge, bool visible) +void LLViewChildren::setBadge(const std::string& id, Badge badge, bool visible) { LLIconCtrl* child = mParent.getChild<LLIconCtrl>(id); if (child) @@ -93,15 +93,15 @@ void LLViewChildren::setBadge(const char* id, Badge badge, bool visible) switch (badge) { default: - case BADGE_OK: child->setImage("badge_ok.j2c"); break; - case BADGE_NOTE: child->setImage("badge_note.j2c"); break; - case BADGE_WARN: child->setImage("badge_warn.j2c"); break; - case BADGE_ERROR: child->setImage("badge_error.j2c"); break; + case BADGE_OK: child->setImage(std::string("badge_ok.j2c")); break; + case BADGE_NOTE: child->setImage(std::string("badge_note.j2c")); break; + case BADGE_WARN: child->setImage(std::string("badge_warn.j2c")); break; + case BADGE_ERROR: child->setImage(std::string("badge_error.j2c")); break; } } } -void LLViewChildren::setAction(const char* id, +void LLViewChildren::setAction(const std::string& id, void(*function)(void*), void* value) { LLButton* button = mParent.getChild<LLButton>(id); diff --git a/indra/newview/llviewchildren.h b/indra/newview/llviewchildren.h index d3a09e9b93..633d6f6126 100644 --- a/indra/newview/llviewchildren.h +++ b/indra/newview/llviewchildren.h @@ -42,27 +42,27 @@ public: LLViewChildren(LLPanel& parent); // all views - void show(const char* id, bool visible = true); - void hide(const char* id) { show(id, false); } + void show(const std::string& id, bool visible = true); + void hide(const std::string& id) { show(id, false); } - void enable(const char* id, bool enabled = true); - void disable(const char* id) { enable(id, false); }; + void enable(const std::string& id, bool enabled = true); + void disable(const std::string& id) { enable(id, false); }; // // LLTextBox - void setText(const char* id, + void setText(const std::string& id, const std::string& text, bool visible = true); - void setWrappedText(const char* id, + void setWrappedText(const std::string& id, const std::string& text, bool visible = true); // LLIconCtrl enum Badge { BADGE_OK, BADGE_NOTE, BADGE_WARN, BADGE_ERROR }; - void setBadge(const char* id, Badge b, bool visible = true); + void setBadge(const std::string& id, Badge b, bool visible = true); // LLButton - void setAction(const char* id, void(*function)(void*), void* value); + void setAction(const std::string& id, void(*function)(void*), void* value); private: diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp index 39e0bd8555..0363dba631 100644 --- a/indra/newview/llviewerassetstorage.cpp +++ b/indra/newview/llviewerassetstorage.cpp @@ -88,7 +88,7 @@ void LLViewerAssetStorage::storeAssetData( // This can happen if there's a bug in our code or if the VFS has been corrupted. llwarns << "LLViewerAssetStorage::storeAssetData() Data _should_ already be in the VFS, but it's not! " << asset_id << llendl; // LLAssetStorage metric: Zero size VFS - reportMetric( asset_id, asset_type, NULL, LLUUID::null, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" ); + reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" ); delete req; if (callback) @@ -102,7 +102,7 @@ void LLViewerAssetStorage::storeAssetData( // LLAssetStorage metric: Successful Request S32 size = mVFS->getSize(asset_id, asset_type); const char *message = "Added to upload queue"; - reportMetric( asset_id, asset_type, NULL, LLUUID::null, size, MR_OKAY, __FILE__, __LINE__, message ); + reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, size, MR_OKAY, __FILE__, __LINE__, message ); if(is_priority) { @@ -130,7 +130,7 @@ void LLViewerAssetStorage::storeAssetData( llwarns << "Probable corruption in VFS file, aborting store asset data" << llendl; // LLAssetStorage metric: VFS corrupt - bogus size - reportMetric( asset_id, asset_type, NULL, LLUUID::null, asset_size, MR_VFS_CORRUPTION, __FILE__, __LINE__, "VFS corruption" ); + reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, asset_size, MR_VFS_CORRUPTION, __FILE__, __LINE__, "VFS corruption" ); if (callback) { @@ -158,7 +158,7 @@ void LLViewerAssetStorage::storeAssetData( { llwarns << "AssetStorage: attempt to upload non-existent vfile " << asset_id << ":" << LLAssetType::lookup(asset_type) << llendl; // LLAssetStorage metric: Zero size VFS - reportMetric( asset_id, asset_type, NULL, LLUUID::null, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" ); + reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" ); if (callback) { callback(asset_id, user_data, LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE, LL_EXSTAT_NONEXISTENT_FILE); @@ -169,7 +169,7 @@ void LLViewerAssetStorage::storeAssetData( { llwarns << "Attempt to move asset store request upstream w/o valid upstream provider" << llendl; // LLAssetStorage metric: Upstream provider dead - reportMetric( asset_id, asset_type, NULL, LLUUID::null, 0, MR_NO_UPSTREAM, __FILE__, __LINE__, "No upstream provider" ); + reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_NO_UPSTREAM, __FILE__, __LINE__, "No upstream provider" ); if (callback) { callback(asset_id, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM); @@ -178,7 +178,7 @@ void LLViewerAssetStorage::storeAssetData( } void LLViewerAssetStorage::storeAssetData( - const char* filename, + const std::string& filename, const LLTransactionID& tid, LLAssetType::EType asset_type, LLStoreAssetCallback callback, @@ -188,10 +188,10 @@ void LLViewerAssetStorage::storeAssetData( bool user_waiting, F64 timeout) { -if(!filename) + if(filename.empty()) { // LLAssetStorage metric: no filename - reportMetric( LLUUID::null, asset_type, "", LLUUID::null, 0, MR_VFS_CORRUPTION, __FILE__, __LINE__, "Filename missing" ); + reportMetric( LLUUID::null, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_VFS_CORRUPTION, __FILE__, __LINE__, "Filename missing" ); llerrs << "No filename specified" << llendl; return; } diff --git a/indra/newview/llviewerassetstorage.h b/indra/newview/llviewerassetstorage.h index 39bab687b0..084b273a8f 100644 --- a/indra/newview/llviewerassetstorage.h +++ b/indra/newview/llviewerassetstorage.h @@ -58,7 +58,7 @@ public: F64 timeout=LL_ASSET_STORAGE_TIMEOUT); virtual void storeAssetData( - const char* filename, + const std::string& filename, const LLTransactionID& tid, LLAssetType::EType type, LLStoreAssetCallback callback, diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index cbba73b692..eec1fff942 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -76,14 +76,14 @@ BOOL gHackGodmode = FALSE; #endif -std::map<LLString, LLControlGroup*> gSettings; +std::map<std::string, LLControlGroup*> gSettings; LLControlGroup gSavedSettings; // saved at end of session LLControlGroup gSavedPerAccountSettings; // saved at end of session LLControlGroup gColors; // read-only LLControlGroup gCrashSettings; // saved at end of session -LLString gLastRunVersion; -LLString gCurrentVersion; +std::string gLastRunVersion; +std::string gCurrentVersion; extern BOOL gResizeScreenTexture; extern BOOL gDebugGL; @@ -271,7 +271,7 @@ static bool handleAudioStreamMusicChanged(const LLSD& newvalue) // otherwise music will briefly stop if ( !gAudiop->isInternetStreamPlaying() ) { - gAudiop->startInternetStream(LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL().c_str()); + gAudiop->startInternetStream(LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL()); } } } @@ -385,7 +385,7 @@ static bool handleDebugViewsChanged(const LLSD& newvalue) static bool handleLogFileChanged(const LLSD& newvalue) { std::string log_filename = newvalue.asString(); - LLFile::remove(log_filename.c_str()); + LLFile::remove(log_filename); LLError::logToFile(log_filename); return true; } diff --git a/indra/newview/llviewercontrol.h b/indra/newview/llviewercontrol.h index 4ac544b780..954454fbd1 100644 --- a/indra/newview/llviewercontrol.h +++ b/indra/newview/llviewercontrol.h @@ -46,7 +46,7 @@ extern BOOL gHackGodmode; //setting variables are declared in this function void settings_setup_listeners(); -extern std::map<LLString, LLControlGroup*> gSettings; +extern std::map<std::string, LLControlGroup*> gSettings; // for the graphics settings void create_graphics_group(LLControlGroup& group); @@ -62,7 +62,7 @@ extern LLControlGroup gColors; extern LLControlGroup gCrashSettings; // Set after settings loaded -extern LLString gLastRunVersion; -extern LLString gCurrentVersion; +extern std::string gLastRunVersion; +extern std::string gCurrentVersion; #endif // LL_LLVIEWERCONTROL_H diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index c75bcdc9e8..b7b85105cc 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -331,10 +331,10 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { // Give up. Don't keep the UI locked forever. gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); - gAgent.setTeleportMessage(""); + gAgent.setTeleportMessage(std::string()); } - const LLString& message = gAgent.getTeleportMessage(); + const std::string& message = gAgent.getTeleportMessage(); switch( gAgent.getTeleportState() ) { case LLAgent::TELEPORT_START: @@ -363,7 +363,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) case LLAgent::TELEPORT_START_ARRIVAL: // Transition to ARRIVING. Viewer has received avatar update, etc., from destination simulator gTeleportArrivalTimer.reset(); - gViewerWindow->setProgressCancelButtonVisible(FALSE, "Cancel"); + gViewerWindow->setProgressCancelButtonVisible(FALSE, std::string("Cancel")); //TODO: Translate gViewerWindow->setProgressPercent(75.f); gAgent.setTeleportState( LLAgent::TELEPORT_ARRIVING ); gAgent.setTeleportMessage( @@ -380,7 +380,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) arrival_fraction = 1.f; gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); } - gViewerWindow->setProgressCancelButtonVisible(FALSE, "Cancel"); + gViewerWindow->setProgressCancelButtonVisible(FALSE, std::string("Cancel")); //TODO: Translate gViewerWindow->setProgressPercent( arrival_fraction * 25.f + 75.f); gViewerWindow->setProgressString(message); } @@ -1155,12 +1155,8 @@ void render_disconnected_background() { llinfos << "Loading last bitmap..." << llendl; - char temp_str[MAX_PATH]; /* Flawfinder: ignore */ - strncpy(temp_str, gDirUtilp->getLindenUserDir().c_str(), MAX_PATH -1); /* Flawfinder: ignore */ - temp_str[MAX_PATH -1] = '\0'; - strncat(temp_str, gDirUtilp->getDirDelimiter().c_str(), MAX_PATH - strlen(temp_str) -1); /* Flawfinder: ignore */ - - strcat(temp_str, SCREEN_LAST_FILENAME); /* Flawfinder: ignore */ + std::string temp_str; + temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + SCREEN_LAST_FILENAME; LLPointer<LLImageBMP> image_bmp = new LLImageBMP; if( !image_bmp->load(temp_str) ) diff --git a/indra/newview/llviewergenericmessage.cpp b/indra/newview/llviewergenericmessage.cpp index 81b7594ef8..d7dbeb35d6 100644 --- a/indra/newview/llviewergenericmessage.cpp +++ b/indra/newview/llviewergenericmessage.cpp @@ -44,7 +44,7 @@ LLDispatcher gGenericDispatcher; -void send_generic_message(const char* method, +void send_generic_message(const std::string& method, const std::vector<std::string>& strings, const LLUUID& invoice) { @@ -69,7 +69,7 @@ void send_generic_message(const char* method, for(; it != end; ++it) { msg->nextBlock("ParamList"); - msg->addString("Parameter", (*it).c_str()); + msg->addString("Parameter", *it); } } gAgent.sendReliableMessage(); diff --git a/indra/newview/llviewergenericmessage.h b/indra/newview/llviewergenericmessage.h index 2e12f54320..71099d8367 100644 --- a/indra/newview/llviewergenericmessage.h +++ b/indra/newview/llviewergenericmessage.h @@ -37,7 +37,7 @@ class LLUUID; class LLDispatcher; -void send_generic_message(const char* method, +void send_generic_message(const std::string& method, const std::vector<std::string>& strings, const LLUUID& invoice = LLUUID::null); diff --git a/indra/newview/llviewergesture.cpp b/indra/newview/llviewergesture.cpp index 4434098a42..2d2557f46a 100644 --- a/indra/newview/llviewergesture.cpp +++ b/indra/newview/llviewergesture.cpp @@ -126,7 +126,7 @@ void LLViewerGesture::doTrigger( BOOL send_chat ) } else { - LLUUID anim_id = gAnimLibrary.stringToAnimState(mAnimation.c_str()); + LLUUID anim_id = gAnimLibrary.stringToAnimState(mAnimation); gAgent.sendAnimationRequest(anim_id, ANIM_REQUEST_START); } } @@ -161,8 +161,8 @@ BOOL LLViewerGestureList::matchPrefix(const std::string& in_str, std::string* ou { S32 in_len = in_str.length(); - LLString in_str_lc = in_str; - LLString::toLower(in_str_lc); + std::string in_str_lc = in_str; + LLStringUtil::toLower(in_str_lc); for (S32 i = 0; i < count(); i++) { @@ -176,7 +176,7 @@ BOOL LLViewerGestureList::matchPrefix(const std::string& in_str, std::string* ou } std::string trigger_trunc = utf8str_truncate(trigger, in_len); - LLString::toLower(trigger_trunc); + LLStringUtil::toLower(trigger_trunc); if (in_str_lc == trigger_trunc) { *out_str = trigger; diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index a3929de5f3..7fe076553b 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -64,8 +64,8 @@ LLViewerInventoryItem::LLViewerInventoryItem(const LLUUID& uuid, 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, time_t creation_date_utc) : @@ -77,7 +77,7 @@ LLViewerInventoryItem::LLViewerInventoryItem(const LLUUID& uuid, LLViewerInventoryItem::LLViewerInventoryItem(const LLUUID& item_id, const LLUUID& parent_id, - const char* name, + const std::string& name, LLInventoryType::EType inv_type) : LLInventoryItem(), mIsComplete(FALSE) @@ -85,7 +85,7 @@ LLViewerInventoryItem::LLViewerInventoryItem(const LLUUID& item_id, mUUID = item_id; mParentUUID = parent_id; mInventoryType = inv_type; - mName.assign(name); + mName = name; } LLViewerInventoryItem::LLViewerInventoryItem() : @@ -279,12 +279,12 @@ bool LLViewerInventoryItem::importFileLocal(LLFILE* fp) bool LLViewerInventoryItem::exportFileLocal(LLFILE* fp) 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); fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType)); const char* inv_type_str = LLInventoryType::lookup(mInventoryType); @@ -327,7 +327,7 @@ void LLViewerInventoryItem::updateParentOnServer(BOOL restamp) const LLViewerInventoryCategory::LLViewerInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid, LLAssetType::EType pref, - const LLString& name, + const std::string& name, const LLUUID& owner_id) : LLInventoryCategory(uuid, parent_uuid, pref, name), mOwnerID(owner_id), @@ -518,8 +518,8 @@ bool LLViewerInventoryCategory::importFileLocal(LLFILE* fp) sscanf( /* Flawfinder: ignore */ buffer, " %254s %254[^|]", keyword, valuestr); mName.assign(valuestr); - LLString::replaceNonstandardASCII(mName, ' '); - LLString::replaceChar(mName, '|', ' '); + LLStringUtil::replaceNonstandardASCII(mName, ' '); + LLStringUtil::replaceChar(mName, '|', ' '); } else if(0 == strcmp("owner_id", keyword)) { @@ -540,17 +540,17 @@ bool LLViewerInventoryCategory::importFileLocal(LLFILE* fp) bool LLViewerInventoryCategory::exportFileLocal(LLFILE* fp) 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()); mOwnerID.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()); fprintf(fp, "\t\tversion\t%d\n", mVersion); fprintf(fp,"\t}\n"); return true; @@ -560,17 +560,6 @@ bool LLViewerInventoryCategory::exportFileLocal(LLFILE* fp) const /// Local function definitions ///---------------------------------------------------------------------------- -/* -void inventory_reliable_callback(void**, S32 status) -{ - if(0 != status) - { - char buffer[MAX_STRING]; - sprintf(buffer, "Reliable packet failure: %d", status); - llwarns << buffer << llendl; - } -} -*/ LLInventoryCallbackManager *LLInventoryCallbackManager::sInstance = NULL; LLInventoryCallbackManager::LLInventoryCallbackManager() : @@ -677,7 +666,7 @@ void CreateGestureCallback::fire(const LLUUID& inv_item) if(!LLPreview::show(inv_item,FALSE)) { - LLPreviewGesture* preview = LLPreviewGesture::show(LLString("Gesture: ") + item->getName(), inv_item, LLUUID::null); + LLPreviewGesture* preview = LLPreviewGesture::show(std::string("Gesture: ") + item->getName(), inv_item, LLUUID::null); // Force to be entirely onscreen. gFloaterView->adjustToFitScreen(preview, FALSE); } diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index 102239099f..42dd91f916 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -58,8 +58,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, time_t creation_date_utc); @@ -69,7 +69,7 @@ public: LLViewerInventoryItem( const LLUUID& item_id, const LLUUID& parent_id, - const char* name, + const std::string& name, LLInventoryType::EType inv_type); // construct an invalid and incomplete viewer inventory item. @@ -149,7 +149,7 @@ protected: public: LLViewerInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid, LLAssetType::EType preferred_type, - const LLString& name, + const std::string& name, const LLUUID& owner_id); LLViewerInventoryCategory(const LLUUID& owner_id); // Create a copy of an inventory category from a pointer to another category @@ -161,7 +161,6 @@ public: virtual void removeFromServer(); virtual void updateParentOnServer(BOOL restamp_children) const; virtual void updateServer(BOOL is_new) const; - //virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0); const LLUUID& getOwnerID() const { return mOwnerID; } diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index d6032118c9..8772149a86 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -307,7 +307,7 @@ void LLViewerJointMesh::setMesh( LLPolyMesh *mesh ) U32 jn; for (jn = 0; jn < numJointNames; jn++) { - //llinfos << "Setting up joint " << jointNames[jn].c_str() << llendl; + //llinfos << "Setting up joint " << jointNames[jn] << llendl; LLViewerJoint* joint = (LLViewerJoint*)(getRoot()->findJoint(jointNames[jn]) ); mSkinJoints[jn].setupSkinJoint( joint ); } diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index a5032c5a30..90b3f3502c 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -584,7 +584,7 @@ LLViewerKeyboard::LLViewerKeyboard() : } -void LLViewerKeyboard::bindNamedFunction(const char *name, LLKeyFunc func) +void LLViewerKeyboard::bindNamedFunction(const std::string& name, LLKeyFunc func) { S32 i = mNamedFunctionCount; mNamedFunctions[i].mName = name; @@ -593,29 +593,29 @@ void LLViewerKeyboard::bindNamedFunction(const char *name, LLKeyFunc func) } -BOOL LLViewerKeyboard::modeFromString(const char *string, S32 *mode) +BOOL LLViewerKeyboard::modeFromString(const std::string& string, S32 *mode) { - if (!strcmp(string, "FIRST_PERSON")) + if (string == "FIRST_PERSON") { *mode = MODE_FIRST_PERSON; return TRUE; } - else if (!strcmp(string, "THIRD_PERSON")) + else if (string == "THIRD_PERSON") { *mode = MODE_THIRD_PERSON; return TRUE; } - else if (!strcmp(string, "EDIT")) + else if (string == "EDIT") { *mode = MODE_EDIT; return TRUE; } - else if (!strcmp(string, "EDIT_AVATAR")) + else if (string == "EDIT_AVATAR") { *mode = MODE_EDIT_AVATAR; return TRUE; } - else if (!strcmp(string, "SITTING")) + else if (string == "SITTING") { *mode = MODE_SITTING; return TRUE; @@ -663,11 +663,11 @@ BOOL LLViewerKeyboard::handleKey(KEY translated_key, MASK translated_mask, BOOL -BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, const char *function_name) +BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, const std::string& function_name) { S32 i,index; void (*function)(EKeystate keystate) = NULL; - const char *name = NULL; + std::string name; // Allow remapping of F2-F12 if (function_name[0] == 'F') @@ -691,7 +691,7 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c // Not remapped, look for a function for (i = 0; i < mNamedFunctionCount; i++) { - if (!strcmp(function_name, mNamedFunctions[i].mName)) + if (function_name == mNamedFunctions[i].mName) { function = mNamedFunctions[i].mFunction; name = mNamedFunctions[i].mName; @@ -731,22 +731,20 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c if (index == mBindingCount[mode]) mBindingCount[mode]++; - // printf("Bound key %c to %s\n", key, name); - return TRUE; } -S32 LLViewerKeyboard::loadBindings(const char *filename) +S32 LLViewerKeyboard::loadBindings(const std::string& filename) { LLFILE *fp; const S32 BUFFER_SIZE = 2048; char buffer[BUFFER_SIZE]; /* Flawfinder: ignore */ // *NOTE: This buffer size is hard coded into scanf() below. - char mode_string[MAX_STRING]; /* Flawfinder: ignore */ - char key_string[MAX_STRING]; /* Flawfinder: ignore */ - char mask_string[MAX_STRING]; /* Flawfinder: ignore */ - char function_string[MAX_STRING]; /* Flawfinder: ignore */ + char mode_string[MAX_STRING] = ""; /* Flawfinder: ignore */ + char key_string[MAX_STRING] = ""; /* Flawfinder: ignore */ + char mask_string[MAX_STRING] = ""; /* Flawfinder: ignore */ + char function_string[MAX_STRING] = ""; /* Flawfinder: ignore */ S32 mode = MODE_THIRD_PERSON; KEY key = 0; MASK mask = 0; @@ -754,7 +752,7 @@ S32 LLViewerKeyboard::loadBindings(const char *filename) S32 binding_count = 0; S32 line_count = 0; - if(!filename) + if(filename.empty()) { llerrs << " No filename specified" << llendl; return 0; diff --git a/indra/newview/llviewerkeyboard.h b/indra/newview/llviewerkeyboard.h index df31e17c70..5f1ec18a08 100644 --- a/indra/newview/llviewerkeyboard.h +++ b/indra/newview/llviewerkeyboard.h @@ -40,10 +40,10 @@ const S32 MAX_KEY_BINDINGS = 128; // was 60 class LLNamedFunction { public: - LLNamedFunction() : mName(NULL), mFunction(NULL) { }; + LLNamedFunction() : mFunction(NULL) { }; ~LLNamedFunction() { }; - const char *mName; + std::string mName; LLKeyFunc mFunction; }; @@ -68,16 +68,16 @@ public: BOOL handleKey(KEY key, MASK mask, BOOL repeated); - void bindNamedFunction(const char *name, LLKeyFunc func); + void bindNamedFunction(const std::string& name, LLKeyFunc func); - S32 loadBindings(const char *filename); // returns number bound, 0 on error + S32 loadBindings(const std::string& filename); // returns number bound, 0 on error EKeyboardMode getMode(); - BOOL modeFromString(const char *string, S32 *mode); // False on failure + BOOL modeFromString(const std::string& string, S32 *mode); // False on failure void scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level); protected: - BOOL bindKey(const S32 mode, const KEY key, const MASK mask, const char *function_name); + BOOL bindKey(const S32 mode, const KEY key, const MASK mask, const std::string& function_name); S32 mNamedFunctionCount; LLNamedFunction mNamedFunctions[MAX_NAMED_FUNCTIONS]; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index d53d32ccea..f803ef3a3e 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -474,7 +474,7 @@ void LLViewerMedia::initClass() LLMIMETypes::mime_info_map_t::const_iterator it; for (it = LLMIMETypes::sMap.begin(); it != LLMIMETypes::sMap.end(); ++it) { - const LLString& mime_type = it->first; + const std::string& mime_type = it->first; const LLMIMETypes::LLMIMEInfo& info = it->second; mm->addMimeTypeImplNameMap( mime_type, info.mImpl ); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 645499d943..946167b90e 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -255,24 +255,12 @@ LLPieMenu *gPieAttachment = NULL; LLPieMenu *gPieLand = NULL; // local constants -const LLString LANDMARK_MENU_NAME("Landmarks"); -const LLString CLIENT_MENU_NAME("Advanced"); -const LLString SERVER_MENU_NAME("Admin"); +const std::string LANDMARK_MENU_NAME("Landmarks"); +const std::string CLIENT_MENU_NAME("Advanced"); +const std::string SERVER_MENU_NAME("Admin"); -const LLString SAVE_INTO_INVENTORY("Save Object Back to My Inventory"); -const LLString SAVE_INTO_TASK_INVENTORY("Save Object Back to Object Contents"); - -#if LL_WINDOWS -static const char* SOUND_EXTENSIONS = ".wav"; -static const char* IMAGE_EXTENSIONS = ".tga .bmp .jpg .jpeg .png"; -static const char* ANIM_EXTENSIONS = ".bvh"; -#ifdef _CORY_TESTING -static const char* GEOMETRY_EXTENSIONS = ".slg"; -#endif -static const char* XML_EXTENSIONS = ".xml"; -static const char* SLOBJECT_EXTENSIONS = ".slobject"; -#endif -static const char* ALL_FILE_EXTENSIONS = "*.*"; +const std::string SAVE_INTO_INVENTORY("Save Object Back to My Inventory"); +const std::string SAVE_INTO_TASK_INVENTORY("Save Object Back to Object Contents"); LLMenuGL* gAttachSubMenu = NULL; LLMenuGL* gDetachSubMenu = NULL; @@ -316,7 +304,7 @@ void handle_region_clear_temp_asset_data(void*); BOOL sitting_on_selection(); void near_sit_object(); -void label_sit_or_stand(LLString& label, void*); +void label_sit_or_stand(std::string& label, void*); // buy and take alias into the same UI positions, so these // declarations handle this mess. BOOL is_selection_buy_not_take(); @@ -328,7 +316,7 @@ BOOL enable_buy(void*); void handle_buy(void *); void handle_buy_object(LLSaleInfo sale_info); void handle_buy_contents(LLSaleInfo sale_info); -void label_touch(LLString& label, void*); +void label_touch(std::string& label, void*); // Land pie menu void near_sit_down_point(BOOL success, void *); @@ -339,7 +327,6 @@ void handle_talk_to(void *userdata); // Debug menu void show_permissions_control(void*); -void load_url_local_file(const char* file_name); void toggle_build_options(void* user_data); #if 0 // Unused void handle_audio_status_1(void*); @@ -502,7 +489,7 @@ BOOL enable_selection_you_own_one(void*); BOOL enable_save_into_inventory(void*); BOOL enable_save_into_task_inventory(void*); BOOL enable_not_thirdperson(void*); -BOOL enable_export_selected(void *); +// BOOL enable_export_selected(void *); BOOL enable_have_card(void*); BOOL enable_detach(void*); BOOL enable_region_owner(void*); @@ -725,7 +712,7 @@ void init_menus() LLViewerLogin::getInstance()->isInProductionGrid()); // *TODO:Get the cost info from the server - const LLString upload_cost("10"); + const std::string upload_cost("10"); gMenuHolder->childSetLabelArg("Upload Image", "[COST]", upload_cost); gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost); gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost); @@ -792,6 +779,7 @@ void init_landmark_menu(LLMenuGL* menu) // clear existing menu, as we might be rebuilding as result of inventory update clear_landmark_menu(menu); + // *TODO: Translate menu->append(new LLMenuItemCallGL("Organize Landmarks", &manage_landmarks, NULL)); menu->append(new LLMenuItemCallGL("New Landmark...", @@ -808,7 +796,7 @@ void init_landmark_menu(LLMenuGL* menu) for(S32 i = 0; i < count; ++i) { LLInventoryItem* item = items->get(i); - LLString landmark_name = item->getName(); + std::string landmark_name = item->getName(); LLUUID* landmark_id_ptr = new LLUUID( item->getUUID() ); LLMenuItemCallGL* menu_item = new LLMenuItemCallGL(landmark_name, landmark_menu_action, @@ -847,9 +835,10 @@ void init_client_menu(LLMenuGL* menu) LLMenuGL* sub_menu = NULL; //menu->append(new LLMenuItemCallGL("Permissions Control", &show_permissions_control)); - -// this is now in the view menu so we don't need it here! + // this is now in the view menu so we don't need it here! + { + // *TODO: Translate LLMenuGL* sub = new LLMenuGL("Consoles"); menu->appendMenu(sub); sub->append(new LLMenuItemCheckGL("Frame Console", @@ -871,22 +860,7 @@ void init_client_menu(LLMenuGL* menu) &get_visibility, debugview, '4', MASK_CONTROL|MASK_SHIFT ) ); -#if 0 // Unused - { - LLMenuGL* sub = new LLMenuGL("Audio"); - menu->appendMenu(sub); - sub->append(new LLMenuItemCallGL("Global Pos", - &handle_audio_status_1, NULL, NULL ,'5', MASK_CONTROL|MASK_SHIFT) ); - sub->append(new LLMenuItemCallGL("Cone", - &handle_audio_status_2, NULL, NULL ,'6', MASK_CONTROL|MASK_SHIFT) ); - sub->append(new LLMenuItemCallGL("Local Pos", - &handle_audio_status_3, NULL, NULL ,'7', MASK_CONTROL|MASK_SHIFT) ); - sub->append(new LLMenuItemCallGL("Duration", - &handle_audio_status_4, NULL, NULL ,'8', MASK_CONTROL|MASK_SHIFT) ); - sub->createJumpKeys(); - } -#endif sub->append(new LLMenuItemCheckGL("Fast Timers", &toggle_visibility, NULL, @@ -1168,7 +1142,7 @@ void handle_export_menus_to_xml(void*) llwarns << "No file" << llendl; return; } - const char* filename = picker.getFirstFile(); + std::string filename = picker.getFirstFile(); llofstream out(filename); LLXMLNodePtr node = gMenuBarView->getXML(); @@ -1536,37 +1510,6 @@ void init_debug_baked_texture_menu(LLMenuGL* menu) void init_server_menu(LLMenuGL* menu) { - /* - { - // These messages are now trusted. We can write scripts to do - // this, and the message is unchecked for source. - LLMenuGL* sub_menu = NULL; - sub_menu = new LLMenuGL("Sim Logging"); - - sub_menu->append(new LLMenuItemCallGL("Turn off llinfos Log", - &handle_reduce_llinfo_log, &enable_god_customer_service)); - - sub_menu->append(new LLMenuItemCallGL("Normal Logging", - &handle_normal_llinfo_log, &enable_god_customer_service)); - - sub_menu->appendSeparator(); - sub_menu->append(new LLMenuItemCallGL("Enable Message Log", - &handle_sim_enable_message_log, &enable_god_customer_service)); - sub_menu->append(new LLMenuItemCallGL("Disable Message Log", - &handle_sim_disable_message_log, &enable_god_customer_service)); - - sub_menu->appendSeparator(); - - sub_menu->append(new LLMenuItemCallGL("Fetch Message Log", - &handle_sim_fetch_message_log, &enable_god_customer_service)); - - sub_menu->append(new LLMenuItemCallGL("Fetch Log", - &handle_sim_fetch_log, &enable_god_customer_service)); - - menu->appendMenu( sub_menu ); - } - */ - { LLMenuGL* sub = new LLMenuGL("Object"); menu->appendMenu(sub); @@ -1764,7 +1707,7 @@ class LLObjectEnableTouch : public view_listener_t } }; -void label_touch(LLString& label, void*) +void label_touch(std::string& label, void*) { LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); if (node && node->mValid && !node->mTouchName.empty()) @@ -2128,7 +2071,7 @@ class LLObjectEnableMute : public view_listener_t { // It's an avatar LLNameValue *lastname = avatar->getNVPair("LastName"); - BOOL is_linden = lastname && !LLString::compareStrings(lastname->getString(), "Linden"); + BOOL is_linden = lastname && !LLStringUtil::compareStrings(lastname->getString(), "Linden"); BOOL is_self = avatar->isSelf(); new_value = !is_linden && !is_self; } @@ -2146,7 +2089,7 @@ class LLObjectMute : public view_listener_t if (!object) return true; LLUUID id; - LLString name; + std::string name; LLMute::EType type; LLVOAvatar* avatar = find_avatar_from_object(object); if (avatar) @@ -2275,11 +2218,11 @@ class LLAvatarFreeze : public view_listener_t if( avatar ) { LLUUID* avatar_id = new LLUUID( avatar->getID() ); - LLString fullname = avatar->getFullname(); + std::string fullname = avatar->getFullname(); if (!fullname.empty()) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[AVATAR_NAME]"] = fullname; gViewerWindow->alertXml("FreezeAvatarFullname", args, @@ -2377,11 +2320,11 @@ class LLAvatarEject : public view_listener_t if( avatar ) { LLUUID* avatar_id = new LLUUID( avatar->getID() ); - LLString fullname = avatar->getFullname(); + std::string fullname = avatar->getFullname(); if (!fullname.empty()) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[AVATAR_NAME]"] = fullname; gViewerWindow->alertXml("EjectAvatarFullname", args, @@ -2432,7 +2375,7 @@ class LLAvatarGiveCard : public view_listener_t if(dest && dest->isAvatar()) { bool found_name = false; - LLString::format_map_t args; + LLStringUtil::format_map_t args; LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) @@ -2501,63 +2444,34 @@ void handle_leave_group(void *) { if (gAgent.getGroupID() != LLUUID::null) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[GROUP]"] = gAgent.mGroupName; gViewerWindow->alertXml("GroupLeaveConfirmMember", args, callback_leave_group); } } -void append_aggregate(LLString& string, const LLAggregatePermissions& ag_perm, PermissionBit bit, const char* txt) +void append_aggregate(std::string& string, const LLAggregatePermissions& ag_perm, PermissionBit bit, const char* txt) { LLAggregatePermissions::EValue val = ag_perm.getValue(bit); - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - buffer[0] = '\0'; + std::string buffer; switch(val) { - case LLAggregatePermissions::AP_NONE: - snprintf(buffer, MAX_STRING, "* %s None\n", txt); /* Flawfinder: ignore */ + case LLAggregatePermissions::AP_NONE: + buffer = llformat( "* %s None\n", txt); break; - case LLAggregatePermissions::AP_SOME: - snprintf(buffer, MAX_STRING, "* %s Some\n", txt); /* Flawfinder: ignore */ + case LLAggregatePermissions::AP_SOME: + buffer = llformat( "* %s Some\n", txt); break; - case LLAggregatePermissions::AP_ALL: - snprintf(buffer, MAX_STRING, "* %s All\n", txt); /* Flawfinder: ignore */ + case LLAggregatePermissions::AP_ALL: + buffer = llformat( "* %s All\n", txt); break; - case LLAggregatePermissions::AP_EMPTY: - default: + case LLAggregatePermissions::AP_EMPTY: + default: break; } string.append(buffer); } -const char* build_extensions_string(LLFilePicker::ELoadFilter filter) -{ - switch(filter) - { -#if LL_WINDOWS - case LLFilePicker::FFLOAD_IMAGE: - return IMAGE_EXTENSIONS; - case LLFilePicker::FFLOAD_WAV: - return SOUND_EXTENSIONS; - case LLFilePicker::FFLOAD_ANIM: - return ANIM_EXTENSIONS; - case LLFilePicker::FFLOAD_SLOBJECT: - return SLOBJECT_EXTENSIONS; -#ifdef _CORY_TESTING - case LLFilePicker::FFLOAD_GEOMETRY: - return GEOMETRY_EXTENSIONS; -#endif - case LLFilePicker::FFLOAD_XML: - return XML_EXTENSIONS; - case LLFilePicker::FFLOAD_ALL: - return ALL_FILE_EXTENSIONS; -#endif - default: - return ALL_FILE_EXTENSIONS; - } -} - - BOOL enable_buy(void*) { // In order to buy, there must only be 1 purchaseable object in @@ -2600,7 +2514,7 @@ void handle_buy_object(LLSaleInfo sale_info) } LLUUID owner_id; - LLString owner_name; + std::string owner_name; BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { @@ -2697,8 +2611,8 @@ void handle_dump_region_object_cache(void*) void handle_dump_focus(void *) { LLView *view = gFocusMgr.getKeyboardFocus(); - - llinfos << "Keyboard focus " << (view ? view->getName() : "(none)") << llendl; + std::string name = view ? view->getName() : "(none)"; + llinfos << "Keyboard focus " << name << llendl; } class LLSelfStandUp : public view_listener_t @@ -2766,7 +2680,7 @@ void set_god_level(U8 god_level) LLViewerLogin::getInstance()->isInProductionGrid()); } - LLString::format_map_t args; + LLStringUtil::format_map_t args; if(god_level > GOD_NOT) { args["[LEVEL]"] = llformat("%d",(S32)god_level); @@ -2814,7 +2728,7 @@ void process_grant_godlike_powers(LLMessageSystem* msg, void**) } } -void load_url_local_file(const char* file_name) +void load_url_local_file(const std::string& file_name) { if( gAgent.cameraMouselook() ) { @@ -2838,7 +2752,7 @@ void load_url_local_file(const char* file_name) full_path.append(gDirUtilp->getDirDelimiter()); full_path.append(file_name); - LLWeb::loadURL(full_path.c_str()); + LLWeb::loadURL(full_path); } /* @@ -2926,8 +2840,8 @@ void request_friendship(const LLUUID& dest_id) LLViewerObject* dest = gObjectList.findObject(dest_id); if(dest && dest->isAvatar()) { - LLString fullname; - LLString::format_map_t args; + std::string fullname; + LLStringUtil::format_map_t args; LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) @@ -3636,17 +3550,17 @@ void handle_claim_public_land(void*) msg->nextBlock("MethodData"); msg->addString("Method", "claimpublicland"); msg->addUUID("Invoice", LLUUID::null); - char buffer[32]; /* Flawfinder: ignore */ - snprintf(buffer, sizeof(buffer), "%f", west_south.mV[VX]); /* Flawfinder: ignore */ + std::string buffer; + buffer = llformat( "%f", west_south.mV[VX]); msg->nextBlock("ParamList"); msg->addString("Parameter", buffer); - snprintf(buffer, sizeof(buffer), "%f", west_south.mV[VY]); /* Flawfinder: ignore */ + buffer = llformat( "%f", west_south.mV[VY]); msg->nextBlock("ParamList"); msg->addString("Parameter", buffer); - snprintf(buffer, sizeof(buffer), "%f", east_north.mV[VX]); /* Flawfinder: ignore */ + buffer = llformat( "%f", east_north.mV[VX]); msg->nextBlock("ParamList"); msg->addString("Parameter", buffer); - snprintf(buffer, sizeof(buffer), "%f", east_north.mV[VY]); /* Flawfinder: ignore */ + buffer = llformat( "%f", east_north.mV[VY]); msg->nextBlock("ParamList"); msg->addString("Parameter", buffer); gAgent.sendReliableMessage(); @@ -4157,11 +4071,11 @@ class LLToolsEnableBuyOrTake : public view_listener_t gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); // Update label - LLString label; - LLString buy_text; - LLString take_text; - LLString param = userdata["data"].asString(); - LLString::size_type offset = param.find(","); + std::string label; + std::string buy_text; + std::string take_text; + std::string param = userdata["data"].asString(); + std::string::size_type offset = param.find(","); if (offset != param.npos) { buy_text = param.substr(0, offset); @@ -4255,7 +4169,7 @@ void show_buy_currency(const char* extra) } mesg << "Go to " << BUY_CURRENCY_URL << "\nfor information on purchasing currency?"; - LLString::format_map_t args; + LLStringUtil::format_map_t args; if (extra != NULL) { args["[EXTRA]"] = extra; @@ -4449,7 +4363,7 @@ class LLToolsLink : public view_listener_t S32 object_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); if (object_count > MAX_CHILDREN_PER_TASK + 1) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[COUNT]"] = llformat("%d", object_count); int max = MAX_CHILDREN_PER_TASK+1; args["[MAX]"] = llformat("%d", max); @@ -4468,7 +4382,7 @@ class LLToolsLink : public view_listener_t return true; } LLUUID owner_id; - LLString owner_name; + std::string owner_name; if(!LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name)) { // we don't actually care if you're the owner, but novices are @@ -4847,8 +4761,8 @@ void show_debug_menus() gMenuBarView->setItemVisible(SERVER_MENU_NAME, show_server_menu); gMenuBarView->setItemEnabled(SERVER_MENU_NAME, show_server_menu); - //gMenuBarView->setItemVisible(LLString("DebugOptions"), visible); - //gMenuBarView->setItemVisible(LLString(AVI_TOOLS), visible); + //gMenuBarView->setItemVisible("DebugOptions", visible); + //gMenuBarView->setItemVisible(std::string(AVI_TOOLS), visible); gMenuBarView->arrange(); // clean-up positioning }; @@ -4878,43 +4792,43 @@ void toggle_map( void* user_data ) } -LLUUID gExporterRequestID; -LLString gExportDirectory; +// LLUUID gExporterRequestID; +// std::string gExportDirectory; -LLUploadDialog *gExportDialog = NULL; +// LLUploadDialog *gExportDialog = NULL; -void handle_export_selected( void * ) -{ - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (selection->isEmpty()) - { - return; - } - llinfos << "Exporting selected objects:" << llendl; +// void handle_export_selected( void * ) +// { +// LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); +// if (selection->isEmpty()) +// { +// return; +// } +// llinfos << "Exporting selected objects:" << llendl; - gExporterRequestID.generate(); - gExportDirectory = ""; +// gExporterRequestID.generate(); +// gExportDirectory = ""; - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_ObjectExportSelected); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_RequestID, gExporterRequestID); - msg->addS16Fast(_PREHASH_VolumeDetail, 4); +// LLMessageSystem* msg = gMessageSystem; +// msg->newMessageFast(_PREHASH_ObjectExportSelected); +// msg->nextBlockFast(_PREHASH_AgentData); +// msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); +// msg->addUUIDFast(_PREHASH_RequestID, gExporterRequestID); +// msg->addS16Fast(_PREHASH_VolumeDetail, 4); - for (LLObjectSelection::root_iterator iter = selection->root_begin(); - iter != selection->root_end(); iter++) - { - LLSelectNode* node = *iter; - LLViewerObject* object = node->getObject(); - msg->nextBlockFast(_PREHASH_ObjectData); - msg->addUUIDFast(_PREHASH_ObjectID, object->getID()); - llinfos << "Object: " << object->getID() << llendl; - } - msg->sendReliable(gAgent.getRegion()->getHost()); +// for (LLObjectSelection::root_iterator iter = selection->root_begin(); +// iter != selection->root_end(); iter++) +// { +// LLSelectNode* node = *iter; +// LLViewerObject* object = node->getObject(); +// msg->nextBlockFast(_PREHASH_ObjectData); +// msg->addUUIDFast(_PREHASH_ObjectID, object->getID()); +// llinfos << "Object: " << object->getID() << llendl; +// } +// msg->sendReliable(gAgent.getRegion()->getHost()); - gExportDialog = LLUploadDialog::modalUploadDialog("Exporting selected objects..."); -} +// gExportDialog = LLUploadDialog::modalUploadDialog("Exporting selected objects..."); +// } BOOL menu_check_build_tool( void* user_data ) { @@ -5240,11 +5154,11 @@ class LLObjectEnableSitOrStand : public view_listener_t gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); // Update label - LLString label; - LLString sit_text; - LLString stand_text; - LLString param = userdata["data"].asString(); - LLString::size_type offset = param.find(","); + std::string label; + std::string sit_text; + std::string stand_text; + std::string param = userdata["data"].asString(); + std::string::size_type offset = param.find(","); if (offset != param.npos) { sit_text = param.substr(0, offset); @@ -5331,7 +5245,7 @@ class LLShowFloater : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString floater_name = userdata.asString(); + std::string floater_name = userdata.asString(); if (floater_name == "gestures") { LLFloaterGesture::toggleVisibility(); @@ -5431,7 +5345,7 @@ class LLShowFloater : public view_listener_t } else if (floater_name == "help tutorial") { - LLFloaterHUD::show(); + LLFloaterHUD::showHUD(); } else if (floater_name == "complaint reporter") { @@ -5476,8 +5390,8 @@ class LLFloaterVisible : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString control_name = userdata["control"].asString(); - LLString floater_name = userdata["data"].asString(); + std::string control_name = userdata["control"].asString(); + std::string floater_name = userdata["data"].asString(); bool new_value = false; if (floater_name == "friends") { @@ -5520,12 +5434,12 @@ class LLFloaterVisible : public view_listener_t } }; -void callback_show_url(S32 option, void* url) +void callback_show_url(S32 option, void* data) { - const char* urlp = (const char*)url; + std::string* urlp = (std::string*)data; if (0 == option) { - LLWeb::loadURL(urlp); + LLWeb::loadURL(*urlp); } delete urlp; } @@ -5534,22 +5448,13 @@ class LLPromptShowURL : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString param = userdata.asString(); - LLString::size_type offset = param.find(","); + std::string param = userdata.asString(); + std::string::size_type offset = param.find(","); if (offset != param.npos) { - LLString alert = param.substr(0, offset); - LLString url = param.substr(offset+1); - char *url_copy = new char[url.size()+1]; - if (url_copy != NULL) - { - strcpy(url_copy, url.c_str()); /* Flawfinder: ignore */ - } - else - { - llerrs << "Memory Allocation Failed" << llendl; - return false; - } + std::string alert = param.substr(0, offset); + std::string url = param.substr(offset+1); + std::string* url_copy = new std::string(url); gViewerWindow->alertXml(alert, callback_show_url, url_copy); } else @@ -5560,12 +5465,12 @@ class LLPromptShowURL : public view_listener_t } }; -void callback_show_file(S32 option, void* filename) +void callback_show_file(S32 option, void* data) { - const char* filenamep = (const char*)filename; + std::string* filenamep = (std::string*)data; if (0 == option) { - load_url_local_file(filenamep); + load_url_local_file(*filenamep); } delete filenamep; } @@ -5574,22 +5479,13 @@ class LLPromptShowFile : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString param = userdata.asString(); - LLString::size_type offset = param.find(","); + std::string param = userdata.asString(); + std::string::size_type offset = param.find(","); if (offset != param.npos) { - LLString alert = param.substr(0, offset); - LLString file = param.substr(offset+1); - char *file_copy = new char[file.size()+1]; - if (file_copy != NULL) - { - strcpy(file_copy, file.c_str()); /* Flawfinder: ignore */ - } - else - { - llerrs << "Memory Allocation Failed" << llendl; - return false; - } + std::string alert = param.substr(0, offset); + std::string file = param.substr(offset+1); + std::string* file_copy = new std::string(file); gViewerWindow->alertXml(alert, callback_show_file, file_copy); } else @@ -5887,7 +5783,7 @@ void handle_detach_from_avatar(void* user_data) } } -void attach_label(LLString& label, void* user_data) +void attach_label(std::string& label, void* user_data) { LLViewerJointAttachment* attachmentp = (LLViewerJointAttachment*)user_data; if (attachmentp) @@ -5898,13 +5794,13 @@ void attach_label(LLString& label, void* user_data) LLViewerInventoryItem* itemp = gInventory.getItem(attachmentp->getItemID()); if (itemp) { - label += LLString(" (") + itemp->getName() + LLString(")"); + label += std::string(" (") + itemp->getName() + std::string(")"); } } } } -void detach_label(LLString& label, void* user_data) +void detach_label(std::string& label, void* user_data) { LLViewerJointAttachment* attachmentp = (LLViewerJointAttachment*)user_data; if (attachmentp) @@ -5915,7 +5811,7 @@ void detach_label(LLString& label, void* user_data) LLViewerInventoryItem* itemp = gInventory.getItem(attachmentp->getItemID()); if (itemp) { - label += LLString(" (") + itemp->getName() + LLString(")"); + label += std::string(" (") + itemp->getName() + std::string(")"); } } } @@ -6157,7 +6053,7 @@ class LLAvatarSendIM : public view_listener_t LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() ); if(avatar) { - LLString name("IM"); + std::string name("IM"); LLNameValue *first = avatar->getNVPair("FirstName"); LLNameValue *last = avatar->getNVPair("LastName"); if (first && last) @@ -6248,7 +6144,7 @@ class LLToolsSelectedScriptAction : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString action = userdata.asString(); + std::string action = userdata.asString(); LLFloaterScriptQueue* queue = NULL; if (action == "compile") { @@ -6413,7 +6309,7 @@ BOOL menu_ui_enabled(void *user_data) void menu_toggle_control( void* user_data ) { BOOL checked = gSavedSettings.getBOOL( static_cast<char*>(user_data) ); - if (LLString(static_cast<char*>(user_data)) == "HighResSnapshot" && !checked) + if (std::string(static_cast<char*>(user_data)) == "HighResSnapshot" && !checked) { // High Res Snapshot active, must uncheck RenderUIInSnapshot gSavedSettings.setBOOL( "RenderUIInSnapshot", FALSE ); @@ -6427,7 +6323,7 @@ class LLToggleControl : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString control_name = userdata.asString(); + std::string control_name = userdata.asString(); BOOL checked = gSavedSettings.getBOOL( control_name ); if (control_name == "HighResSnapshot" && !checked) { @@ -6681,22 +6577,22 @@ BOOL enable_not_thirdperson(void*) } -BOOL enable_export_selected(void *) -{ - if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) - { - return FALSE; - } - if (!gExporterRequestID.isNull()) - { - return FALSE; - } - if (!LLUploadDialog::modalUploadIsFinished()) - { - return FALSE; - } - return TRUE; -} +// BOOL enable_export_selected(void *) +// { +// if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) +// { +// return FALSE; +// } +// if (!gExporterRequestID.isNull()) +// { +// return FALSE; +// } +// if (!LLUploadDialog::modalUploadIsFinished()) +// { +// return FALSE; +// } +// return TRUE; +// } class LLViewEnableMouselook : public view_listener_t { @@ -6946,7 +6842,7 @@ void handle_grab_texture(void* data) LLUUID folder_id(gInventory.findCategoryUUIDForType(asset_type)); if(folder_id.notNull()) { - LLString name = "Baked "; + std::string name = "Baked "; switch (index) { case LLVOAvatar::TEX_EYES_BAKED: @@ -6992,7 +6888,7 @@ void handle_grab_texture(void* data) asset_type, inv_type, name, - "", + LLStringUtil::null, LLSaleInfo::DEFAULT, LLInventoryItem::II_FLAGS_NONE, creation_date_now); @@ -7069,12 +6965,7 @@ LLVOAvatar* find_avatar_from_object( const LLUUID& object_id ) void handle_disconnect_viewer(void *) { - char message[2048]; /* Flawfinder: ignore */ - message[0] = '\0'; - - snprintf(message, sizeof(message), "Testing viewer disconnect"); /* Flawfinder: ignore */ - - LLAppViewer::instance()->forceDisconnect(message); + LLAppViewer::instance()->forceDisconnect("Testing viewer disconnect"); } void force_error_breakpoint(void *) @@ -7180,20 +7071,20 @@ void handle_save_to_xml(void*) return; } - LLString default_name = "floater_"; + std::string default_name = "floater_"; default_name += frontmost->getTitle(); default_name += ".xml"; - LLString::toLower(default_name); - LLString::replaceChar(default_name, ' ', '_'); - LLString::replaceChar(default_name, '/', '_'); - LLString::replaceChar(default_name, ':', '_'); - LLString::replaceChar(default_name, '"', '_'); + LLStringUtil::toLower(default_name); + LLStringUtil::replaceChar(default_name, ' ', '_'); + LLStringUtil::replaceChar(default_name, '/', '_'); + LLStringUtil::replaceChar(default_name, ':', '_'); + LLStringUtil::replaceChar(default_name, '"', '_'); LLFilePicker& picker = LLFilePicker::instance(); - if (picker.getSaveFile(LLFilePicker::FFSAVE_XML, default_name.c_str())) + if (picker.getSaveFile(LLFilePicker::FFSAVE_XML, default_name)) { - LLString filename = picker.getFirstFile(); + std::string filename = picker.getFirstFile(); LLUICtrlFactory::getInstance()->saveToXML(frontmost, filename); } } @@ -7203,7 +7094,7 @@ void handle_load_from_xml(void*) LLFilePicker& picker = LLFilePicker::instance(); if (picker.getOpenFile(LLFilePicker::FFLOAD_XML)) { - LLString filename = picker.getFirstFile(); + std::string filename = picker.getFirstFile(); LLFloater* floater = new LLFloater("sample_floater"); LLUICtrlFactory::getInstance()->buildFloater(floater, filename); } @@ -7286,7 +7177,7 @@ class LLViewBeaconWidth : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString width = userdata.asString(); + std::string width = userdata.asString(); if(width == "1") { gSavedSettings.setS32("DebugBeaconLineWidth", 1); @@ -7313,7 +7204,7 @@ class LLViewToggleBeacon : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString beacon = userdata.asString(); + std::string beacon = userdata.asString(); if (beacon == "scriptsbeacon") { LLPipeline::toggleRenderScriptedBeacons(NULL); @@ -7382,7 +7273,7 @@ class LLViewCheckBeaconEnabled : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString beacon = userdata["data"].asString(); + std::string beacon = userdata["data"].asString(); bool new_value = false; if (beacon == "scriptsbeacon") { @@ -7428,7 +7319,7 @@ class LLViewToggleRenderType : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString type = userdata.asString(); + std::string type = userdata.asString(); if (type == "hideparticles") { LLPipeline::toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); @@ -7441,7 +7332,7 @@ class LLViewCheckRenderType : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString type = userdata["data"].asString(); + std::string type = userdata["data"].asString(); bool new_value = false; if (type == "hideparticles") { @@ -7475,8 +7366,8 @@ class LLEditEnableTakeOff : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString control_name = userdata["control"].asString(); - LLString clothing = userdata["data"].asString(); + std::string control_name = userdata["control"].asString(); + std::string clothing = userdata["data"].asString(); bool new_value = false; if (clothing == "shirt") { @@ -7523,7 +7414,7 @@ class LLEditTakeOff : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString clothing = userdata.asString(); + std::string clothing = userdata.asString(); if (clothing == "shirt") { LLAgent::userRemoveWearable((void*)WT_SHIRT); @@ -7581,7 +7472,7 @@ class LLToolsSelectTool : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString tool_name = userdata.asString(); + std::string tool_name = userdata.asString(); if (tool_name == "focus") { LLToolMgr::getInstance()->getCurrentToolset()->selectToolByIndex(1); @@ -7611,7 +7502,7 @@ class LLWorldEnvSettings : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLString tod = userdata.asString(); + std::string tod = userdata.asString(); LLVector3 sun_direction; if (tod == "editor") @@ -7725,7 +7616,7 @@ class LLWorldDayCycle : public view_listener_t -static void addMenu(view_listener_t *menu, const char *name) +static void addMenu(view_listener_t *menu, const std::string& name) { sMenus.push_back(menu); menu->registerListener(gMenuHolder, name); diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h index 98b08c4985..d8a8bba08c 100644 --- a/indra/newview/llviewermenu.h +++ b/indra/newview/llviewermenu.h @@ -50,7 +50,7 @@ void cleanup_menus(); void show_debug_menus(); // checks for if menus should be shown first. void show_context_menu( S32 x, S32 y, MASK mask ); void show_build_mode_context_menu(S32 x, S32 y, MASK mask); -void load_url_local_file(const char *file_name); +void load_url_local_file(const std::string& file_name); BOOL enable_save_into_inventory(void*); void handle_reset_view(); void handle_cut(void*); @@ -83,8 +83,8 @@ void menu_toggle_control( void* user_data ); void check_toggle_control( LLUICtrl *, void* user_data ); void confirm_replace_attachment(S32 option, void* user_data); void handle_detach_from_avatar(void* user_data); -void attach_label(LLString& label, void* user_data); -void detach_label(LLString& label, void* user_data); +void attach_label(std::string& label, void* user_data); +void detach_label(std::string& label, void* user_data); BOOL object_selected_and_point_valid(void* user_data); BOOL object_attached(void* user_data); void handle_detach(void*); @@ -112,9 +112,6 @@ bool handle_go_to(); // Export to XML or Collada void handle_export_selected( void * ); -//Retrieve a list of valid extensions for a given file "type" -const char* build_extensions_string(LLFilePicker::ELoadFilter filter); - // Pass in an empty string and this function will build a string that // describes buyer permissions. class LLSaleInfo; @@ -137,7 +134,7 @@ protected: LLSafeHandle<LLObjectSelection> mObjectSelection; }; -extern const LLString SAVE_INTO_INVENTORY; +extern const std::string SAVE_INTO_INVENTORY; extern LLMenuBarGL* gMenuBarView; //extern LLView* gMenuBarHolder; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 9dc3208adb..00cc94c3d3 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -92,6 +92,47 @@ class LLFileEnableUpload : public view_listener_t } }; +//============================================================================ + +#if LL_WINDOWS +static std::string SOUND_EXTENSIONS = "wav"; +static std::string IMAGE_EXTENSIONS = "tga bmp jpg jpeg png"; +static std::string ANIM_EXTENSIONS = "bvh"; +#ifdef _CORY_TESTING +static std::string GEOMETRY_EXTENSIONS = "slg"; +#endif +static std::string XML_EXTENSIONS = "xml"; +static std::string SLOBJECT_EXTENSIONS = "slobject"; +#endif +static std::string ALL_FILE_EXTENSIONS = "*.*"; + +std::string build_extensions_string(LLFilePicker::ELoadFilter filter) +{ + switch(filter) + { +#if LL_WINDOWS + case LLFilePicker::FFLOAD_IMAGE: + return IMAGE_EXTENSIONS; + case LLFilePicker::FFLOAD_WAV: + return SOUND_EXTENSIONS; + case LLFilePicker::FFLOAD_ANIM: + return ANIM_EXTENSIONS; + case LLFilePicker::FFLOAD_SLOBJECT: + return SLOBJECT_EXTENSIONS; +#ifdef _CORY_TESTING + case LLFilePicker::FFLOAD_GEOMETRY: + return GEOMETRY_EXTENSIONS; +#endif + case LLFilePicker::FFLOAD_XML: + return XML_EXTENSIONS; + case LLFilePicker::FFLOAD_ALL: + return ALL_FILE_EXTENSIONS; +#endif + default: + return ALL_FILE_EXTENSIONS; + } +} + /** char* upload_pick(void* data) @@ -100,7 +141,7 @@ class LLFileEnableUpload : public view_listener_t returns the string to the full path filename, else returns NULL. Data is the load filter for the type of file as defined in LLFilePicker. **/ -const char* upload_pick(void* data) +const std::string upload_pick(void* data) { if( gAgent.cameraMouselook() ) { @@ -123,23 +164,23 @@ const char* upload_pick(void* data) if (!picker.getOpenFile(type)) { llinfos << "Couldn't import objects from file" << llendl; - return NULL; + return std::string(); } - const char* filename = picker.getFirstFile(); - const char* ext = strrchr(filename, '.'); + + const std::string& filename = picker.getFirstFile(); + std::string ext = gDirUtilp->getExtension(filename); //strincmp doesn't like NULL pointers - if (ext == NULL) + if (ext.empty()) { - const char* short_name = strrchr(filename, - *gDirUtilp->getDirDelimiter().c_str()); + std::string short_name = gDirUtilp->getBaseFileName(filename); // No extension - LLStringBase<char>::format_map_t args; - args["[FILE]"] = LLString(short_name + 1); + LLStringUtil::format_map_t args; + args["[FILE]"] = short_name; gViewerWindow->alertXml("NoFileExtension", args); - return NULL; + return std::string(); } else { @@ -148,8 +189,7 @@ const char* upload_pick(void* data) //if the extension is valid //now grab the set of valid file extensions - const char* valids = build_extensions_string(type); - std::string valid_extensions = std::string(valids); + std::string valid_extensions = build_extensions_string(type); BOOL ext_valid = FALSE; @@ -165,10 +205,9 @@ const char* upload_pick(void* data) token_iter != tokens.end() && ext_valid != TRUE; ++token_iter) { - const char* cur_token = token_iter->c_str(); + const std::string& cur_token = *token_iter; - if (0 == strnicmp(cur_token, ext, strlen(cur_token)) || /* Flawfinder: ignore */ - 0 == strnicmp(cur_token, "*.*", strlen(cur_token))) /* Flawfinder: ignore */ + if (cur_token == ext || cur_token == "*.*") { //valid extension //or the acceptable extension is any @@ -180,11 +219,11 @@ const char* upload_pick(void* data) { //should only get here if the extension exists //but is invalid - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[EXTENSION]"] = ext; - args["[VALIDS]"] = valids; + args["[VALIDS]"] = valid_extensions; gViewerWindow->alertXml("InvalidFileExtension", args); - return NULL; + return std::string(); } }//end else (non-null extension) @@ -195,14 +234,14 @@ const char* upload_pick(void* data) if (type == LLFilePicker::FFLOAD_WAV) { // pre-qualify wavs to make sure the format is acceptable - char error_msg[MAX_STRING]; /* Flawfinder: ignore */ + std::string error_msg; if (check_for_invalid_wav_formats(filename,error_msg)) { llinfos << error_msg << ": " << filename << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[FILE]"] = filename; gViewerWindow->alertXml( error_msg, args ); - return NULL; + return std::string(); } }//end if a wave/sound file @@ -214,8 +253,8 @@ class LLFileUploadImage : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - const char* filename = upload_pick((void *)LLFilePicker::FFLOAD_IMAGE); - if (filename) + std::string filename = upload_pick((void *)LLFilePicker::FFLOAD_IMAGE); + if (!filename.empty()) { LLFloaterImagePreview* floaterp = new LLFloaterImagePreview(filename); LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_image_preview.xml"); @@ -228,8 +267,8 @@ class LLFileUploadSound : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - const char* filename = upload_pick((void*)LLFilePicker::FFLOAD_WAV); - if (filename) + std::string filename = upload_pick((void*)LLFilePicker::FFLOAD_WAV); + if (!filename.empty()) { LLFloaterNameDesc* floaterp = new LLFloaterNameDesc(filename); LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_sound_preview.xml"); @@ -242,8 +281,8 @@ class LLFileUploadAnim : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - const char* filename = upload_pick((void*)LLFilePicker::FFLOAD_ANIM); - if (filename) + const std::string filename = upload_pick((void*)LLFilePicker::FFLOAD_ANIM); + if (!filename.empty()) { LLFloaterAnimPreview* floaterp = new LLFloaterAnimPreview(filename); LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_animation_preview.xml"); @@ -274,27 +313,18 @@ class LLFileUploadBulk : public view_listener_t LLFilePicker& picker = LLFilePicker::instance(); if (picker.getMultipleOpenFiles()) { - const char* filename = picker.getFirstFile(); - const char* name = picker.getDirname(); - - LLString asset_name = name; - LLString::replaceNonstandardASCII( asset_name, '?' ); - LLString::replaceChar(asset_name, '|', '?'); - LLString::stripNonprintable(asset_name); - LLString::trim(asset_name); - - char* asset_name_str = (char*)asset_name.c_str(); - char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists - if( !end_p ) - { - end_p = asset_name_str + strlen( asset_name_str ); /* Flawfinder: ignore */ - } - - S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) ); - - asset_name = asset_name.substr( 0, len ); - + const std::string& filename = picker.getFirstFile(); + std::string name = gDirUtilp->getBaseFileName(filename, true); + + std::string asset_name = name; + LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); + LLStringUtil::replaceChar(asset_name, '|', '?'); + LLStringUtil::stripNonprintable(asset_name); + LLStringUtil::trim(asset_name); + upload_new_resource(filename, asset_name, asset_name, 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); // file + // *NOTE: Ew, we don't iterate over the file list here, + // we handle the next files in upload_done_callback() } else { @@ -304,11 +334,11 @@ class LLFileUploadBulk : public view_listener_t } }; -void upload_error(const char* error_message, const char* label, const std::string filename, const LLStringBase<char>::format_map_t args) +void upload_error(const std::string& error_message, const std::string& label, const std::string& filename, const LLStringUtil::format_map_t args) { llwarns << error_message << llendl; gViewerWindow->alertXml(label, args); - if(remove(filename.c_str()) == -1) + if(LLFile::remove(filename) == -1) { lldebugs << "unable to remove temp file" << llendl; } @@ -425,8 +455,8 @@ class LLFileQuit : public view_listener_t void handle_upload(void* data) { - const char* filename = upload_pick(data); - if (filename) + const std::string filename = upload_pick(data); + if (!filename.empty()) { LLFloaterNameDesc* floaterp = new LLFloaterNameDesc(filename); LLUICtrlFactory::getInstance()->buildFloater(floaterp, "floater_name_description.xml"); @@ -438,10 +468,9 @@ void handle_compress_image(void*) LLFilePicker& picker = LLFilePicker::instance(); if (picker.getMultipleOpenFiles(LLFilePicker::FFLOAD_IMAGE)) { - const char* input_file = picker.getFirstFile(); - while (input_file) + std::string infile = picker.getFirstFile(); + while (!infile.empty()) { - std::string infile(input_file); std::string outfile = infile + ".j2c"; llinfos << "Input: " << infile << llendl; @@ -460,59 +489,54 @@ void handle_compress_image(void*) llinfos << "Compression failed: " << LLImageBase::getLastError() << llendl; } - input_file = picker.getNextFile(); + infile = picker.getNextFile(); } } } -void upload_new_resource(const LLString& src_filename, std::string name, +void upload_new_resource(const std::string& src_filename, std::string name, std::string desc, S32 compression_info, LLAssetType::EType destination_folder_type, LLInventoryType::EType inv_type, U32 next_owner_perm, - const LLString& display_name, + const std::string& display_name, LLAssetStorage::LLStoreAssetCallback callback, void *userdata) { // Generate the temporary UUID. - LLString filename = gDirUtilp->getTempFilename(); + std::string filename = gDirUtilp->getTempFilename(); LLTransactionID tid; LLAssetID uuid; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; + + std::string exten = gDirUtilp->getExtension(src_filename); - LLString ext = src_filename.substr(src_filename.find_last_of('.')); LLAssetType::EType asset_type = LLAssetType::AT_NONE; - char error_message[MAX_STRING]; /* Flawfinder: ignore */ - error_message[0] = '\0'; - LLString temp_str; + std::string error_message; BOOL error = FALSE; - if (ext.empty()) + if (exten.empty()) { - LLString::size_type offset = filename.find_last_of(gDirUtilp->getDirDelimiter()); - if (offset != LLString::npos) - offset++; - LLString short_name = filename.substr(offset); + std::string short_name = gDirUtilp->getBaseFileName(filename); // No extension - snprintf(error_message, /* Flawfinder: ignore */ - MAX_STRING, + error_message = llformat( "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", short_name.c_str()); args["[FILE]"] = short_name; upload_error(error_message, "NofileExtension", filename, args); return; } - else if( LLString::compareInsensitive(ext.c_str(),".bmp") == 0 ) + else if( exten == "bmp") { asset_type = LLAssetType::AT_TEXTURE; if (!LLViewerImageList::createUploadFile(src_filename, filename, IMG_CODEC_BMP )) { - snprintf(error_message, MAX_STRING, "Problem with file %s:\n\n%s\n", /* Flawfinder: ignore */ + error_message = llformat( "Problem with file %s:\n\n%s\n", src_filename.c_str(), LLImageBase::getLastError().c_str()); args["[FILE]"] = src_filename; args["[ERROR]"] = LLImageBase::getLastError(); @@ -520,14 +544,14 @@ void upload_new_resource(const LLString& src_filename, std::string name, return; } } - else if( LLString::compareInsensitive(ext.c_str(),".tga") == 0 ) + else if( exten == "tga") { asset_type = LLAssetType::AT_TEXTURE; if (!LLViewerImageList::createUploadFile(src_filename, filename, IMG_CODEC_TGA )) { - snprintf(error_message, MAX_STRING, "Problem with file %s:\n\n%s\n", /* Flawfinder: ignore */ + error_message = llformat("Problem with file %s:\n\n%s\n", src_filename.c_str(), LLImageBase::getLastError().c_str()); args["[FILE]"] = src_filename; args["[ERROR]"] = LLImageBase::getLastError(); @@ -535,14 +559,14 @@ void upload_new_resource(const LLString& src_filename, std::string name, return; } } - else if( LLString::compareInsensitive(ext.c_str(),".jpg") == 0 || LLString::compareInsensitive(ext.c_str(),".jpeg") == 0) + else if( exten == "jpg" || exten == "jpeg") { asset_type = LLAssetType::AT_TEXTURE; if (!LLViewerImageList::createUploadFile(src_filename, filename, IMG_CODEC_JPEG )) { - snprintf(error_message, MAX_STRING, "Problem with file %s:\n\n%s\n", /* Flawfinder: ignore */ + error_message = llformat("Problem with file %s:\n\n%s\n", src_filename.c_str(), LLImageBase::getLastError().c_str()); args["[FILE]"] = src_filename; args["[ERROR]"] = LLImageBase::getLastError(); @@ -550,14 +574,14 @@ void upload_new_resource(const LLString& src_filename, std::string name, return; } } - else if( LLString::compareInsensitive(ext.c_str(),".png") == 0 ) + else if( exten == "png") { asset_type = LLAssetType::AT_TEXTURE; if (!LLViewerImageList::createUploadFile(src_filename, filename, IMG_CODEC_PNG )) { - sprintf(error_message, "Problem with file %s:\n\n%s\n", + error_message = llformat("Problem with file %s:\n\n%s\n", src_filename.c_str(), LLImageBase::getLastError().c_str()); args["[FILE]"] = src_filename; args["[ERROR]"] = LLImageBase::getLastError(); @@ -565,27 +589,27 @@ void upload_new_resource(const LLString& src_filename, std::string name, return; } } - else if(LLString::compareInsensitive(ext.c_str(),".wav") == 0) + else if(exten == "wav") { asset_type = LLAssetType::AT_SOUND; // tag it as audio S32 encode_result = 0; llinfos << "Attempting to encode wav as an ogg file" << llendl; - encode_result = encode_vorbis_file(src_filename.c_str(), filename.c_str()); + encode_result = encode_vorbis_file(src_filename, filename); if (LLVORBISENC_NOERR != encode_result) { switch(encode_result) { case LLVORBISENC_DEST_OPEN_ERR: - snprintf(error_message, MAX_STRING, "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); /* Flawfinder: ignore */ + error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); args["[FILE]"] = filename; upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args); break; default: - snprintf(error_message, MAX_STRING, "Unknown vorbis encode failure on: %s\n", src_filename.c_str()); /* Flawfinder: ignore */ + error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str()); args["[FILE]"] = src_filename; upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args); break; @@ -593,11 +617,11 @@ void upload_new_resource(const LLString& src_filename, std::string name, return; } } - else if(LLString::compareInsensitive(ext.c_str(),".tmp") == 0) + else if(exten == "tmp") { // This is a generic .lin resource file asset_type = LLAssetType::AT_OBJECT; - LLFILE* in = LLFile::fopen(src_filename.c_str(), "rb"); /* Flawfinder: ignore */ + LLFILE* in = LLFile::fopen(src_filename, "rb"); /* Flawfinder: ignore */ if (in) { // read in the file header @@ -627,7 +651,7 @@ void upload_new_resource(const LLString& src_filename, std::string name, if (EOF == tokens_read) { fclose(in); - snprintf(error_message, MAX_STRING, "corrupt resource file: %s", src_filename.c_str()); /* Flawfinder: ignore */ + error_message = llformat("corrupt resource file: %s", src_filename.c_str()); args["[FILE]"] = src_filename; upload_error(error_message, "CorruptResourceFile", filename, args); return; @@ -655,7 +679,7 @@ void upload_new_resource(const LLString& src_filename, std::string name, else { fclose(in); - snprintf(error_message, MAX_STRING, "unknown linden resource file version in file: %s", src_filename.c_str()); /* Flawfinder: ignore */ + error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str()); args["[FILE]"] = src_filename; upload_error(error_message, "UnknownResourceFileVersion", filename, args); return; @@ -682,7 +706,7 @@ void upload_new_resource(const LLString& src_filename, std::string name, } // copy the file's data segment into another file for uploading - LLFILE* out = LLFile::fopen(filename.c_str(), "wb"); /* Flawfinder: ignore */ + LLFILE* out = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ if (out) { while((read = fread(buf, 1, 16384, in))) /* Flawfinder: ignore */ @@ -697,7 +721,7 @@ void upload_new_resource(const LLString& src_filename, std::string name, else { fclose(in); - snprintf(error_message, MAX_STRING, "Unable to create output file: %s", filename.c_str()); /* Flawfinder: ignore */ + error_message = llformat( "Unable to create output file: %s", filename.c_str()); args["[FILE]"] = filename; upload_error(error_message, "UnableToCreateOutputFile", filename, args); return; @@ -710,16 +734,17 @@ void upload_new_resource(const LLString& src_filename, std::string name, llinfos << "Couldn't open .lin file " << src_filename << llendl; } } - else if (LLString::compareInsensitive(ext.c_str(),".bvh") == 0) + else if (exten == "bvh") { - snprintf(error_message, MAX_STRING, "We do not currently support bulk upload of animation files\n"); /* Flawfinder: ignore */ + error_message = llformat("We do not currently support bulk upload of animation files\n"); upload_error(error_message, "DoNotSupportBulkAnimationUpload", filename, args); return; } else { // Unknown extension - snprintf(error_message, MAX_STRING, "Unknown file extension %s\nExpected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh", ext.c_str()); /* Flawfinder: ignore */ + // *TODO: Translate? + error_message = llformat("Unknown file extension .%s\nExpected .wav, .tga, .bmp, .jpg, .jpeg, or .bvh", exten.c_str()); error = TRUE;; } @@ -748,14 +773,14 @@ void upload_new_resource(const LLString& src_filename, std::string name, } else { - snprintf(error_message, MAX_STRING, "Unable to access output file: %s", filename.c_str()); /* Flawfinder: ignore */ + error_message = llformat( "Unable to access output file: %s", filename.c_str()); error = TRUE; } } if (!error) { - LLString t_disp_name = display_name; + std::string t_disp_name = display_name; if (t_disp_name.empty()) { t_disp_name = src_filename; @@ -767,10 +792,10 @@ void upload_new_resource(const LLString& src_filename, std::string name, else { llwarns << error_message << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[ERROR_MESSAGE]"] = error_message; gViewerWindow->alertXml("ErrorMessage", args); - if(LLFile::remove(filename.c_str()) == -1) + if(LLFile::remove(filename) == -1) { lldebugs << "unable to remove temp file" << llendl; } @@ -799,7 +824,7 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt { LLFloaterBuyCurrency::buyCurrency( llformat("Uploading %s costs", - data->mAssetInfo.getName().c_str()), + data->mAssetInfo.getName().c_str()), // *TODO: Translate upload_cost); is_balance_sufficient = FALSE; } @@ -852,9 +877,9 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt } else // if(result >= 0) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[FILE]"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); - args["[REASON]"] = LLString(LLAssetStorage::getErrorString(result)); + args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); gViewerWindow->alertXml("CannotUploadReason", args); } @@ -864,27 +889,14 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt // *NOTE: This is a pretty big hack. What this does is check the // file picker if there are any more pending uploads. If so, // upload that file. - const char* next_file = LLFilePicker::instance().getNextFile(); - if(is_balance_sufficient && next_file) + const std::string& next_file = LLFilePicker::instance().getNextFile(); + if(is_balance_sufficient && !next_file.empty()) { - const char* name = LLFilePicker::instance().getDirname(); - - LLString asset_name = name; - LLString::replaceNonstandardASCII( asset_name, '?' ); - LLString::replaceChar(asset_name, '|', '?'); - LLString::stripNonprintable(asset_name); - LLString::trim(asset_name); - - char* asset_name_str = (char*)asset_name.c_str(); - char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists - if( !end_p ) - { - end_p = asset_name_str + strlen( asset_name_str ); /* Flawfinder: ignore */ - } - - S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) ); - - asset_name = asset_name.substr( 0, len ); + std::string asset_name = gDirUtilp->getBaseFileName(next_file, true); + LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); + LLStringUtil::replaceChar(asset_name, '|', '?'); + LLStringUtil::stripNonprintable(asset_name); + LLStringUtil::trim(asset_name); upload_new_resource(next_file, asset_name, asset_name, // file 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); @@ -897,7 +909,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty LLAssetType::EType destination_folder_type, LLInventoryType::EType inv_type, U32 next_owner_perm, - const LLString& display_name, + const std::string& display_name, LLAssetStorage::LLStoreAssetCallback callback, void *userdata) { @@ -922,8 +934,8 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty { inv_type = LLInventoryType::defaultForAssetType(asset_type); } - LLString::stripNonprintable(name); - LLString::stripNonprintable(desc); + LLStringUtil::stripNonprintable(name); + LLStringUtil::stripNonprintable(desc); if(name.empty()) { name = "(No Name)"; @@ -934,7 +946,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty } // At this point, we're ready for the upload. - LLString upload_message = "Uploading...\n\n"; + std::string upload_message = "Uploading...\n\n"; upload_message.append(display_name); LLUploadDialog::modalUploadDialog(upload_message); diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 46255da022..f43e5bfc92 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -40,12 +40,12 @@ class LLTransactionID; void init_menu_file(); -void upload_new_resource(const LLString& src_filename, std::string name, +void upload_new_resource(const std::string& src_filename, std::string name, std::string desc, S32 compression_info, LLAssetType::EType destination_folder_type, LLInventoryType::EType inv_type, U32 next_owner_perm = 0x0, // PERM_NONE - const LLString& display_name = LLString::null, + const std::string& display_name = LLStringUtil::null, LLAssetStorage::LLStoreAssetCallback callback = NULL, void *userdata = NULL); @@ -55,7 +55,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType type, LLAssetType::EType destination_folder_type, LLInventoryType::EType inv_type, U32 next_owner_perm = 0x0, // PERM_NONE - const LLString& display_name = LLString::null, + const std::string& display_name = LLStringUtil::null, LLAssetStorage::LLStoreAssetCallback callback = NULL, void *userdata = NULL); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 4c8e75016c..114707791b 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -159,6 +159,9 @@ extern BOOL gDebugClicks; void open_offer(const std::vector<LLUUID>& items, const std::string& from_name); void friendship_offer_callback(S32 option, void* user_data); bool check_offer_throttle(const std::string& from_name, bool check_only); +void callbackCacheEstateOwnerName(const LLUUID& id, + const std::string& first, const std::string& last, + BOOL is_group, void*); //inventory offer throttle globals LLFrameTimer gThrottleTimer; @@ -166,7 +169,7 @@ const U32 OFFER_THROTTLE_MAX_COUNT=5; //number of items per time period const F32 OFFER_THROTTLE_TIME=10.f; //time period in seconds //script permissions -const LLString SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] = +const std::string SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] = { "ScriptTakeMoney", "ActOnControlInputs", @@ -198,7 +201,7 @@ struct LLFriendshipOffer // void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_group, - S32 trx_type, const LLString& desc) + S32 trx_type, const std::string& desc) { if(0 == amount) return; amount = abs(amount); @@ -219,7 +222,7 @@ void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_ msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY); msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY); msg->addS32Fast(_PREHASH_TransactionType, trx_type ); - msg->addStringFast(_PREHASH_Description, desc.c_str()); + msg->addStringFast(_PREHASH_Description, desc); msg->sendReliable(region->getHost()); } else @@ -324,194 +327,191 @@ void process_layer_data(LLMessageSystem *mesgsys, void **user_data) } } -S32 exported_object_count = 0; -S32 exported_image_count = 0; -S32 current_object_count = 0; -S32 current_image_count = 0; - -extern LLNotifyBox *gExporterNotify; -extern LLUUID gExporterRequestID; -extern LLString gExportDirectory; - -extern LLUploadDialog *gExportDialog; - -LLString gExportedFile; - -std::map<LLUUID, LLString> gImageChecksums; - -void export_complete() -{ - LLUploadDialog::modalUploadFinished(); - gExporterRequestID.setNull(); - gExportDirectory = ""; - - LLFILE* fXML = LLFile::fopen(gExportedFile.c_str(), "rb"); /* Flawfinder: ignore */ - fseek(fXML, 0, SEEK_END); - long length = ftell(fXML); - fseek(fXML, 0, SEEK_SET); - U8 *buffer = new U8[length + 1]; - size_t nread = fread(buffer, 1, length, fXML); - if (nread < (size_t) length) - { - LL_WARNS("Messaging") << "Short read" << LL_ENDL; - } - buffer[nread] = '\0'; - fclose(fXML); - - char *pos = (char *)buffer; - while ((pos = strstr(pos+1, "<sl:image ")) != 0) - { - char *pos_check = strstr(pos, "checksum=\""); - - if (pos_check) - { - char *pos_uuid = strstr(pos_check, "\">"); - - if (pos_uuid) - { - char image_uuid_str[UUID_STR_SIZE]; /* Flawfinder: ignore */ - memcpy(image_uuid_str, pos_uuid+2, UUID_STR_SIZE-1); /* Flawfinder: ignore */ - image_uuid_str[UUID_STR_SIZE-1] = 0; +// S32 exported_object_count = 0; +// S32 exported_image_count = 0; +// S32 current_object_count = 0; +// S32 current_image_count = 0; + +// extern LLNotifyBox *gExporterNotify; +// extern LLUUID gExporterRequestID; +// extern std::string gExportDirectory; + +// extern LLUploadDialog *gExportDialog; + +// std::string gExportedFile; + +// std::map<LLUUID, std::string> gImageChecksums; + +// void export_complete() +// { +// LLUploadDialog::modalUploadFinished(); +// gExporterRequestID.setNull(); +// gExportDirectory = ""; + +// LLFILE* fXML = LLFile::fopen(gExportedFile, "rb"); /* Flawfinder: ignore */ +// fseek(fXML, 0, SEEK_END); +// long length = ftell(fXML); +// fseek(fXML, 0, SEEK_SET); +// U8 *buffer = new U8[length + 1]; +// size_t nread = fread(buffer, 1, length, fXML); +// if (nread < (size_t) length) +// { +// llwarns << "Short read" << llendl; +// } +// buffer[nread] = '\0'; +// fclose(fXML); + +// char *pos = (char *)buffer; +// while ((pos = strstr(pos+1, "<sl:image ")) != 0) +// { +// char *pos_check = strstr(pos, "checksum=\""); + +// if (pos_check) +// { +// char *pos_uuid = strstr(pos_check, "\">"); + +// if (pos_uuid) +// { +// char image_uuid_str[UUID_STR_SIZE]; /* Flawfinder: ignore */ +// memcpy(image_uuid_str, pos_uuid+2, UUID_STR_SIZE-1); /* Flawfinder: ignore */ +// image_uuid_str[UUID_STR_SIZE-1] = 0; - LLUUID image_uuid(image_uuid_str); - - LL_INFOS("Messaging") << "Found UUID: " << image_uuid << LL_ENDL; - - std::map<LLUUID, LLString>::iterator itor = gImageChecksums.find(image_uuid); - if (itor != gImageChecksums.end()) - { - LL_INFOS("Messaging") << "Replacing with checksum: " << itor->second << LL_ENDL; - if (itor->second.c_str() != NULL) - { - memcpy(&pos_check[10], itor->second.c_str(), 32); /* Flawfinder: ignore */ - } - } - } - } - } - - LLFILE* fXMLOut = LLFile::fopen(gExportedFile.c_str(), "wb"); /* Flawfinder: ignore */ - if (fwrite(buffer, 1, length, fXMLOut) != length) - { - LL_WARNS("Messaging") << "Short write" << LL_ENDL; - } - fclose(fXMLOut); - - delete [] buffer; -} - - -void exported_item_complete(const LLTSCode status, void *user_data) -{ - //LLString *filename = (LLString *)user_data; - - if (status < LLTS_OK) - { - LL_WARNS("Messaging") << "Export failed!" << LL_ENDL; - } - else - { - ++current_object_count; - if (current_image_count == exported_image_count && current_object_count == exported_object_count) - { - LL_INFOS("Messaging") << "*** Export complete ***" << LL_ENDL; - - export_complete(); - } - else - { - gExportDialog->setMessage(llformat("Exported %d/%d object files, %d/%d textures.", current_object_count, exported_object_count, current_image_count, exported_image_count)); - } - } -} - -struct exported_image_info -{ - LLUUID image_id; - LLString filename; - U32 image_num; -}; - -void exported_j2c_complete(const LLTSCode status, void *user_data) -{ - exported_image_info *info = (exported_image_info *)user_data; - LLUUID image_id = info->image_id; - U32 image_num = info->image_num; - LLString filename = info->filename; - delete info; - - if (status < LLTS_OK) - { - LL_WARNS("Messaging") << "Image download failed!" << LL_ENDL; - } - else - { - LLFILE* fIn = LLFile::fopen(filename.c_str(), "rb"); /* Flawfinder: ignore */ - if (fIn) - { - LLPointer<LLImageJ2C> ImageUtility = new LLImageJ2C; - LLPointer<LLImageTGA> TargaUtility = new LLImageTGA; - - fseek(fIn, 0, SEEK_END); - S32 length = ftell(fIn); - fseek(fIn, 0, SEEK_SET); - U8 *buffer = ImageUtility->allocateData(length); - if (fread(buffer, 1, length, fIn) != length) - { - LL_WARNS("Messaging") << "Short read" << LL_ENDL; - } - fclose(fIn); - LLFile::remove(filename.c_str()); - - // Convert to TGA - LLPointer<LLImageRaw> image = new LLImageRaw(); - - ImageUtility->updateData(); - ImageUtility->decode(image, 100000.0f); +// LLUUID image_uuid(image_uuid_str); + +// LL_INFOS("Messaging") << "Found UUID: " << image_uuid << LL_ENDL; + +// std::map<LLUUID, std::string>::iterator itor = gImageChecksums.find(image_uuid); +// if (itor != gImageChecksums.end()) +// { +// LL_INFOS("Messaging") << "Replacing with checksum: " << itor->second << LL_ENDL; +// if (!itor->second.empty()) +// { +// memcpy(&pos_check[10], itor->second.c_str(), 32); /* Flawfinder: ignore */ +// } +// } +// } +// } +// } + +// LLFILE* fXMLOut = LLFile::fopen(gExportedFile, "wb"); /* Flawfinder: ignore */ +// if (fwrite(buffer, 1, length, fXMLOut) != length) +// { +// LL_WARNS("Messaging") << "Short write" << LL_ENDL; +// } +// fclose(fXMLOut); + +// delete [] buffer; +// } + + +// void exported_item_complete(const LLTSCode status, void *user_data) +// { +// //std::string *filename = (std::string *)user_data; + +// if (status < LLTS_OK) +// { +// LL_WARNS("Messaging") << "Export failed!" << LL_ENDL; +// } +// else +// { +// ++current_object_count; +// if (current_image_count == exported_image_count && current_object_count == exported_object_count) +// { +// LL_INFOS("Messaging") << "*** Export complete ***" << LL_ENDL; + +// export_complete(); +// } +// else +// { +// gExportDialog->setMessage(llformat("Exported %d/%d object files, %d/%d textures.", current_object_count, exported_object_count, current_image_count, exported_image_count)); +// } +// } +// } + +// struct exported_image_info +// { +// LLUUID image_id; +// std::string filename; +// U32 image_num; +// }; + +// void exported_j2c_complete(const LLTSCode status, void *user_data) +// { +// exported_image_info *info = (exported_image_info *)user_data; +// LLUUID image_id = info->image_id; +// U32 image_num = info->image_num; +// std::string filename = info->filename; +// delete info; + +// if (status < LLTS_OK) +// { +// LL_WARNS("Messaging") << "Image download failed!" << LL_ENDL; +// } +// else +// { +// LLFILE* fIn = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */ +// if (fIn) +// { +// LLPointer<LLImageJ2C> ImageUtility = new LLImageJ2C; +// LLPointer<LLImageTGA> TargaUtility = new LLImageTGA; + +// fseek(fIn, 0, SEEK_END); +// S32 length = ftell(fIn); +// fseek(fIn, 0, SEEK_SET); +// U8 *buffer = ImageUtility->allocateData(length); +// if (fread(buffer, 1, length, fIn) != length) +// { +// LL_WARNS("Messaging") << "Short read" << LL_ENDL; +// } +// fclose(fIn); +// LLFile::remove(filename); + +// // Convert to TGA +// LLPointer<LLImageRaw> image = new LLImageRaw(); + +// ImageUtility->updateData(); +// ImageUtility->decode(image, 100000.0f); - TargaUtility->encode(image); - U8 *data = TargaUtility->getData(); - S32 data_size = TargaUtility->getDataSize(); - - char *file_path = new char[filename.size()+1]; - strcpy(file_path, filename.c_str()); /* Flawfinder: ignore */ - char *end = strrchr(file_path, gDirUtilp->getDirDelimiter()[0]); - end[0] = 0; - LLString output_file = llformat("%s/image-%03d.tga", file_path, image_num);//filename; - delete [] file_path; - //S32 name_len = output_file.length(); - //strcpy(&output_file[name_len-3], "tga"); - LLFILE* fOut = LLFile::fopen(output_file.c_str(), "wb"); /* Flawfinder: ignore */ - char md5_hash_string[33]; /* Flawfinder: ignore */ - strcpy(md5_hash_string, "00000000000000000000000000000000"); /* Flawfinder: ignore */ - if (fOut) - { - if (fwrite(data, 1, data_size, fOut) != data_size) - { - LL_WARNS("Messaging") << "Short write" << LL_ENDL; - } - fseek(fOut, 0, SEEK_SET); - fclose(fOut); - fOut = LLFile::fopen(output_file.c_str(), "rb"); /* Flawfinder: ignore */ - LLMD5 my_md5_hash(fOut); - my_md5_hash.hex_digest(md5_hash_string); - } - - gImageChecksums.insert(std::pair<LLUUID, LLString>(image_id, md5_hash_string)); - } - } +// TargaUtility->encode(image); +// U8 *data = TargaUtility->getData(); +// S32 data_size = TargaUtility->getDataSize(); - ++current_image_count; - if (current_image_count == exported_image_count && current_object_count == exported_object_count) - { - LL_INFOS("Messaging") << "*** Export textures complete ***" << LL_ENDL; - export_complete(); - } - else - { - gExportDialog->setMessage(llformat("Exported %d/%d object files, %d/%d textures.", current_object_count, exported_object_count, current_image_count, exported_image_count)); - } -} +// std::string file_path = gDirUtilp->getDirName(filename); + +// std::string output_file = llformat("%s/image-%03d.tga", file_path.c_str(), image_num);//filename; +// //S32 name_len = output_file.length(); +// //strcpy(&output_file[name_len-3], "tga"); +// LLFILE* fOut = LLFile::fopen(output_file, "wb"); /* Flawfinder: ignore */ +// char md5_hash_string[33]; /* Flawfinder: ignore */ +// strcpy(md5_hash_string, "00000000000000000000000000000000"); /* Flawfinder: ignore */ +// if (fOut) +// { +// if (fwrite(data, 1, data_size, fOut) != data_size) +// { +// LL_WARNS("Messaging") << "Short write" << LL_ENDL; +// } +// fseek(fOut, 0, SEEK_SET); +// fclose(fOut); +// fOut = LLFile::fopen(output_file, "rb"); /* Flawfinder: ignore */ +// LLMD5 my_md5_hash(fOut); +// my_md5_hash.hex_digest(md5_hash_string); +// } + +// gImageChecksums.insert(std::pair<LLUUID, std::string>(image_id, md5_hash_string)); +// } +// } + +// ++current_image_count; +// if (current_image_count == exported_image_count && current_object_count == exported_object_count) +// { +// LL_INFOS("Messaging") << "*** Export textures complete ***" << LL_ENDL; +// export_complete(); +// } +// else +// { +// gExportDialog->setMessage(llformat("Exported %d/%d object files, %d/%d textures.", current_object_count, exported_object_count, current_image_count, exported_image_count)); +// } +//} void process_derez_ack(LLMessageSystem*, void**) { @@ -581,7 +581,7 @@ void join_group_callback(S32 option, void* user_data) if (option == 2 && data && !data->mGroupID.isNull()) { LLFloaterGroupInfo::showFromUUID(data->mGroupID); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = data->mMessage; LLNotifyBox::showXml("JoinGroup", args, &join_group_callback, data); return; @@ -599,7 +599,7 @@ void join_group_callback(S32 option, void* user_data) else { delete_context_data = FALSE; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = data->mName; args["[INVITE]"] = data->mMessage; LLAlertDialog::showXml("JoinedTooManyGroupsMember", args, join_group_callback, (void*)data); @@ -613,7 +613,7 @@ void join_group_callback(S32 option, void* user_data) if (data->mFee > 0) { delete_context_data = FALSE; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[COST]"] = llformat("%d", data->mFee); // Set the fee to 0, so that we don't keep // asking about a fee. @@ -626,8 +626,8 @@ void join_group_callback(S32 option, void* user_data) else { send_improved_im(data->mGroupID, - "name", - "message", + std::string("name"), + std::string("message"), IM_ONLINE, IM_GROUP_INVITATION_ACCEPT, data->mTransactionID); @@ -636,8 +636,8 @@ void join_group_callback(S32 option, void* user_data) else if (data) { send_improved_im(data->mGroupID, - "name", - "message", + std::string("name"), + std::string("message"), IM_ONLINE, IM_GROUP_INVITATION_DECLINE, data->mTransactionID); @@ -754,7 +754,7 @@ bool check_offer_throttle(const std::string& from_name, bool check_only) static U32 throttle_count; static bool throttle_logged; LLChat chat; - LLString log_message; + std::string log_message; if (!gSavedSettings.getBOOL("ShowNewInventory")) return false; @@ -837,13 +837,13 @@ void open_offer(const std::vector<LLUUID>& items, const std::string& from_name) switch(item->getType()) { case LLAssetType::AT_NOTECARD: - open_notecard((LLViewerInventoryItem*)item, LLString("Note: ") + item->getName(), LLUUID::null, show_keep_discard, LLUUID::null, FALSE); + open_notecard((LLViewerInventoryItem*)item, std::string("Note: ") + item->getName(), LLUUID::null, show_keep_discard, LLUUID::null, FALSE); break; case LLAssetType::AT_LANDMARK: - open_landmark((LLViewerInventoryItem*)item, LLString("Landmark: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); + open_landmark((LLViewerInventoryItem*)item, std::string("Landmark: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); break; case LLAssetType::AT_TEXTURE: - open_texture(*it, LLString("Texture: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); + open_texture(*it, std::string("Texture: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); break; default: break; @@ -890,12 +890,12 @@ void open_offer(const std::vector<LLUUID>& items, const std::string& from_name) } void inventory_offer_mute_callback(const LLUUID& blocked_id, - const char* first_name, - const char* last_name, + const std::string& first_name, + const std::string& last_name, BOOL is_group, void* user_data) { - LLString from_name; + std::string from_name; LLMute::EType type; if (is_group) @@ -906,9 +906,7 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id, else { type = LLMute::AGENT; - from_name += first_name; - from_name += " "; - from_name += last_name; + from_name = first_name + " " + last_name; } LLMute mute(blocked_id, from_name, type); @@ -936,7 +934,7 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id, void inventory_offer_callback(S32 button, void* user_data) { LLChat chat; - LLString log_message; + std::string log_message; LLOfferInfo* info = (LLOfferInfo*)user_data; if(!info) return; @@ -978,8 +976,8 @@ void inventory_offer_callback(S32 button, void* user_data) } // *TODO:translate - LLString from_string; // Used in the pop-up. - LLString chatHistory_string; // Used in chat history. + std::string from_string; // Used in the pop-up. + std::string chatHistory_string; // Used in chat history. if (info->mFromObject == TRUE) { if (info->mFromGroup) @@ -987,12 +985,12 @@ void inventory_offer_callback(S32 button, void* user_data) std::string group_name; if (gCacheName->getGroupName(info->mFromID, group_name)) { - from_string = LLString("An object named '") + info->mFromName + "' owned by the group '" + group_name + "'"; + from_string = std::string("An object named '") + info->mFromName + "' owned by the group '" + group_name + "'"; chatHistory_string = info->mFromName + " owned by the group '" + group_name + "'"; } else { - from_string = LLString("An object named '") + info->mFromName + "' owned by an unknown group"; + from_string = std::string("An object named '") + info->mFromName + "' owned by an unknown group"; chatHistory_string = info->mFromName + " owned by an unknown group"; } } @@ -1001,12 +999,12 @@ void inventory_offer_callback(S32 button, void* user_data) std::string first_name, last_name; if (gCacheName->getName(info->mFromID, first_name, last_name)) { - from_string = LLString("An object named '") + info->mFromName + "' owned by " + first_name + " " + last_name; + from_string = std::string("An object named '") + info->mFromName + "' owned by " + first_name + " " + last_name; chatHistory_string = info->mFromName + " owned by " + first_name + " " + last_name; } else { - from_string = LLString("An object named '") + info->mFromName + "' owned by an unknown user"; + from_string = std::string("An object named '") + info->mFromName + "' owned by an unknown user"; chatHistory_string = info->mFromName + " owned by an unknown user"; } } @@ -1177,7 +1175,7 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) return; } - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[OBJECTNAME]"] = info->mDesc; // must protect against a NULL return from lookupHumanReadable() std::string typestr = ll_safe_string(LLAssetType::lookupHumanReadable(info->mType)); @@ -1285,7 +1283,7 @@ void lure_callback(S32 option, void* user_data) default: // decline send_simple_im(info->mFromID, - "", + LLStringUtil::null, IM_LURE_DECLINED, info->mLureID); break; @@ -1317,16 +1315,16 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) U8 d = 0; LLUUID session_id; U32 t; - char name[DB_FULL_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - char message[DB_IM_MSG_BUF_SIZE]; /* Flawfinder: ignore */ + std::string name; + std::string message; U32 parent_estate_id = 0; LLUUID region_id; LLVector3 position; - char buffer[DB_IM_MSG_BUF_SIZE * 2]; /* Flawfinder: ignore */ U8 binary_bucket[MTUBYTES]; S32 binary_bucket_size; LLChat chat; - + std::string buffer; + // *TODO:translate - need to fix the full name to first/last (maybe) msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, from_id); msg->getBOOLFast(_PREHASH_MessageBlock, _PREHASH_FromGroup, from_group); @@ -1336,8 +1334,8 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ID, session_id); msg->getU32Fast( _PREHASH_MessageBlock, _PREHASH_Timestamp, t); //msg->getData("MessageBlock", "Count", &count); - msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, DB_FULL_NAME_BUF_SIZE, name); - msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, DB_IM_MSG_BUF_SIZE, message); + msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, name); + msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, message); msg->getU32Fast(_PREHASH_MessageBlock, _PREHASH_ParentEstateID, parent_estate_id); msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_RegionID, region_id); msg->getVector3Fast(_PREHASH_MessageBlock, _PREHASH_Position, position); @@ -1354,7 +1352,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) chat.mMuted = is_muted && !is_linden; chat.mFromID = from_id; chat.mFromName = name; - chat.mSourceType = (from_id.isNull() || !strcmp(name, SYSTEM_FROM)) ? CHAT_SOURCE_SYSTEM : CHAT_SOURCE_AGENT; + chat.mSourceType = (from_id.isNull() || (name == std::string(SYSTEM_FROM))) ? CHAT_SOURCE_SYSTEM : CHAT_SOURCE_AGENT; LLViewerObject *source = gObjectList.findObject(session_id); //Session ID is probably the wrong thing. if (source) @@ -1362,17 +1360,18 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) is_owned_by_me = source->permYouOwner(); } - char separator_string[3]=": "; /* Flawfinder: ignore */ - int message_offset=0; + std::string separator_string(": "); + int message_offset = 0; //Handle IRC styled /me messages. - if (!strncmp(message, "/me ", 4) || !strncmp(message, "/me'", 4)) + std::string prefix = message.substr(0, 4); + if (prefix == "/me " || prefix == "/me'") { - strcpy(separator_string,""); /* Flawfinder: ignore */ - message_offset=3; + separator_string = ""; + message_offset = 3; } - LLString::format_map_t args; + LLStringUtil::format_map_t args; switch(dialog) { case IM_CONSOLE_AND_CHAT_HISTORY: @@ -1395,7 +1394,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // do nothing -- don't distract newbies in // Prelude with global IMs } - else if (offline == IM_ONLINE && !is_linden && is_busy && strcmp(name, SYSTEM_FROM)) + else if (offline == IM_ONLINE && !is_linden && is_busy && name != SYSTEM_FROM) { // return a standard "busy" message, but only do it to online IM // (i.e. not other auto responses and not store-and-forward IM) @@ -1405,15 +1404,15 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // initiated by the other party) then... std::string my_name; gAgent.buildFullname(my_name); - LLString response = gSavedPerAccountSettings.getText("BusyModeResponse"); + std::string response = gSavedPerAccountSettings.getText("BusyModeResponse"); pack_instant_message( gMessageSystem, gAgent.getID(), FALSE, gAgent.getSessionID(), from_id, - my_name.c_str(), - response.c_str(), + my_name, + response, IM_ONLINE, IM_BUSY_AUTO_RESPONSE, session_id); @@ -1422,7 +1421,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // now store incoming IM in chat history - snprintf(buffer, sizeof(buffer), "%s%s", separator_string, (message+message_offset)); /* Flawfinder: ignore */ + buffer = name + separator_string + message.substr(message_offset); LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL; @@ -1432,7 +1431,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) from_id, name, buffer, - NULL, + LLStringUtil::null, dialog, parent_estate_id, region_id, @@ -1440,16 +1439,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) true); // pretend this is chat generated by self, so it does not show up on screen - snprintf(buffer, sizeof(buffer), "IM: %s%s%s", name, separator_string, (message+message_offset)); /* Flawfinder: ignore */ - chat.mText = buffer; + chat.mText = std::string("IM: ") + name + separator_string + message.substr(message_offset); LLFloaterChat::addChat( chat, TRUE, TRUE ); } else if (from_id.isNull()) { // Messages from "Second Life" ID don't go to IM history // messages which should be routed to IM window come from a user ID with name=SYSTEM_NAME - snprintf(buffer, sizeof(buffer), "%s: %s", name, message); /* Flawfinder: ignore */ - chat.mText = buffer; + chat.mText = name + ": " + message; LLFloaterChat::addChat(chat, FALSE, FALSE); } else if (to_id.isNull()) @@ -1462,23 +1459,19 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // Treat like a system message and put in chat history. // Claim to be from a local agent so it doesn't go into // console. - snprintf(buffer, sizeof(buffer), "%s%s%s", name, separator_string, (message+message_offset)); /* Flawfinder: ignore */ - chat.mText = buffer; + chat.mText = name + separator_string + message.substr(message_offset); BOOL local_agent = TRUE; LLFloaterChat::addChat(chat, FALSE, local_agent); } else { // standard message, not from system - char saved[MAX_STRING]; /* Flawfinder: ignore */ - saved[0] = '\0'; + std::string saved; if(offline == IM_OFFLINE) { - char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ - snprintf(saved, MAX_STRING, "(Saved %s) ", /* Flawfinder: ignore */ - formatted_time(timestamp, time_buf)); + saved = llformat("(Saved %s) ", formatted_time(timestamp).c_str()); } - snprintf(buffer, sizeof(buffer), "%s%s%s", separator_string, saved,(message+message_offset)); /* Flawfinder: ignore */ + buffer = separator_string + saved + message.substr(message_offset); LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL; @@ -1489,15 +1482,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) from_id, name, buffer, - NULL, + LLStringUtil::null, dialog, parent_estate_id, region_id, position, true); - snprintf(buffer, sizeof(buffer), "IM: %s%s%s%s", name, separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ + chat.mText = std::string("IM: ") + name + separator_string + saved + message.substr(message_offset); - chat.mText = buffer; BOOL local_agent = FALSE; LLFloaterChat::addChat( chat, TRUE, local_agent ); } @@ -1565,7 +1557,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) U8 has_inventory = notice_bin_bucket->header.has_inventory; U8 asset_type = notice_bin_bucket->header.asset_type; LLUUID group_id = notice_bin_bucket->header.group_id; - const char* item_name = (const char*) notice_bin_bucket->item_name; + std::string item_name = ll_safe_string((const char*) notice_bin_bucket->item_name); // If there is inventory, give the user the inventory offer. LLOfferInfo* info = NULL; @@ -1597,18 +1589,18 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) tokenizer tokens(str, sep); tokenizer::iterator iter = tokens.begin(); - LLString subj(*iter++); - LLString mes(*iter++); + std::string subj(*iter++); + std::string mes(*iter++); if (IM_GROUP_NOTICE == dialog) { subj += "\n"; mes = "\n\n" + mes; - LLGroupNotifyBox::show(subj.c_str(),mes.c_str(),name,group_id,t,has_inventory,item_name,info); + LLGroupNotifyBox::show(subj,mes,name,group_id,t,has_inventory,item_name,info); } else if (IM_GROUP_NOTICE_REQUESTED == dialog) { - LLFloaterGroupInfo::showNotice(subj.c_str(),mes.c_str(),group_id,has_inventory,item_name,info); + LLFloaterGroupInfo::showNotice(subj,mes,group_id,has_inventory,item_name,info); } } break; @@ -1648,7 +1640,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) userdata->mMessage.assign(message); userdata->mFee = membership_fee; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = message; LLNotifyBox::showXml("JoinGroup", args, &join_group_callback, @@ -1764,17 +1756,12 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } // standard message, not from system - char saved[MAX_STRING]; /* Flawfinder: ignore */ - saved[0] = '\0'; + std::string saved; if(offline == IM_OFFLINE) { - char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ - snprintf(saved, /* Flawfinder: ignore */ - MAX_STRING, - "(Saved %s) ", - formatted_time(timestamp, time_buf)); + saved = llformat("(Saved %s) ", formatted_time(timestamp).c_str()); } - snprintf(buffer, sizeof(buffer), "%s%s%s", separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ + buffer = separator_string + saved + message.substr(message_offset); BOOL is_this_agent = FALSE; if(from_id == gAgentID) { @@ -1785,15 +1772,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) from_id, name, buffer, - (char*)binary_bucket, + ll_safe_string((char*)binary_bucket), IM_SESSION_INVITE, parent_estate_id, region_id, position, true); - snprintf(buffer, sizeof(buffer), "IM: %s%s%s%s", name, separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ - chat.mText = buffer; + chat.mText = std::string("IM: ") + name + separator_string + saved + message.substr(message_offset); LLFloaterChat::addChat(chat, TRUE, is_this_agent); } break; @@ -1803,10 +1789,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { return; } - snprintf(buffer, sizeof(buffer), "%s%s%s", name, separator_string, (message+message_offset)); /* Flawfinder: ignore */ + chat.mText = name + separator_string + message.substr(message_offset); // Note: lie to LLFloaterChat::addChat(), pretending that this is NOT an IM, because // IMs from objcts don't open IM sessions. - chat.mText = buffer; chat.mSourceType = CHAT_SOURCE_OBJECT; LLFloaterChat::addChat(chat, FALSE, FALSE); break; @@ -1831,7 +1816,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) else { // TODO: after LLTrans hits release, get "busy response" into translatable file - snprintf(buffer, sizeof(buffer), "%s (%s): %s", name, "busy response", (message+message_offset)); /* Flawfinder: ignore */ + buffer = llformat("%s (%s): %s", name.c_str(), "busy response", message.substr(message_offset).c_str()); gIMMgr->addMessage(session_id, from_id, name, buffer); } break; @@ -1961,15 +1946,15 @@ void busy_message (LLMessageSystem* msg, LLUUID from_id) { std::string my_name; gAgent.buildFullname(my_name); - LLString response = gSavedPerAccountSettings.getText("BusyModeResponse"); + std::string response = gSavedPerAccountSettings.getText("BusyModeResponse"); pack_instant_message( gMessageSystem, gAgent.getID(), FALSE, gAgent.getSessionID(), from_id, - my_name.c_str(), - response.c_str(), + my_name, + response, IM_ONLINE, IM_BUSY_AUTO_RESPONSE); gAgent.sendReliableMessage(); @@ -2085,7 +2070,7 @@ void process_offer_callingcard(LLMessageSystem* msg, void**) offerdata->mHost = msg->getSender(); LLViewerObject* source = gObjectList.findObject(source_id); - LLString::format_map_t args; + LLStringUtil::format_map_t args; std::string source_name; if(source && source->isAvatar()) { @@ -2138,8 +2123,8 @@ void process_decline_callingcard(LLMessageSystem* msg, void**) void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) { LLChat chat; - char mesg[DB_CHAT_MSG_BUF_SIZE]; /* Flawfinder: ignore */ - char from_name[DB_FULL_NAME_BUF_SIZE]; /* Flawfinder: ignore */ + std::string mesg; + std::string from_name; U8 source_temp; U8 type_temp; U8 audible_temp; @@ -2149,7 +2134,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) BOOL is_owned_by_me = FALSE; LLViewerObject* chatter; - msg->getString("ChatData", "FromName", DB_FULL_NAME_BUF_SIZE, from_name); + msg->getString("ChatData", "FromName", from_name); chat.mFromName = from_name; msg->getUUID("ChatData", "SourceID", from_id); @@ -2221,15 +2206,16 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) std::string verb; color.setVec(1.f,1.f,1.f,1.f); - msg->getStringFast(_PREHASH_ChatData, _PREHASH_Message, DB_CHAT_MSG_BUF_SIZE, mesg); + msg->getStringFast(_PREHASH_ChatData, _PREHASH_Message, mesg); BOOL ircstyle = FALSE; // Look for IRC-style emotes here so chatbubbles work - if (!strncmp(mesg, "/me ", 4) || !strncmp(mesg, "/me'", 4)) + std::string prefix = mesg.substr(0, 4); + if (prefix == "/me " || prefix == "/me'") { chat.mText = from_name; - chat.mText += (mesg + 3); + chat.mText += mesg.substr(3); ircstyle = TRUE; } else @@ -2320,7 +2306,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) if (is_self) { - chat.mText = "You"; + chat.mText = std::string("You"); } else { @@ -2378,11 +2364,11 @@ void process_teleport_start(LLMessageSystem *msg, void**) if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) { - gViewerWindow->setProgressCancelButtonVisible(FALSE, ""); + gViewerWindow->setProgressCancelButtonVisible(FALSE); } else { - gViewerWindow->setProgressCancelButtonVisible(TRUE, "Cancel"); + gViewerWindow->setProgressCancelButtonVisible(TRUE, std::string("Cancel")); // *TODO: Translate } // Freeze the UI and show progress bar @@ -2413,19 +2399,19 @@ void process_teleport_progress(LLMessageSystem* msg, void**) msg->getU32("Info", "TeleportFlags", teleport_flags); if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) { - gViewerWindow->setProgressCancelButtonVisible(FALSE, ""); + gViewerWindow->setProgressCancelButtonVisible(FALSE); } else { - gViewerWindow->setProgressCancelButtonVisible(TRUE, "Cancel"); + gViewerWindow->setProgressCancelButtonVisible(TRUE, std::string("Cancel")); //TODO: Translate } - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - msg->getString("Info", "Message", MAX_STRING, buffer); + std::string buffer; + msg->getString("Info", "Message", buffer); LL_DEBUGS("Messaging") << "teleport progress: " << buffer << LL_ENDL; //Sorta hacky...default to using simulator raw messages //if we don't find the coresponding mapping in our progress mappings - LLString message = buffer; + std::string message = buffer; if (LLAgent::sTeleportProgressMessages.find(buffer) != LLAgent::sTeleportProgressMessages.end() ) @@ -2467,7 +2453,7 @@ public: LLInventoryModel::EXCLUDE_TRASH, is_card); } - LLString::format_map_t args; + LLStringUtil::format_map_t args; if ( land_items.count() > 0 ) { // Show notification that they can now teleport to landmarks. Use a random landmark from the inventory S32 random_land = ll_rand( land_items.count() - 1 ); @@ -2576,9 +2562,8 @@ void process_teleport_finish(LLMessageSystem* msg, void**) msg->getU32Fast(_PREHASH_Info, _PREHASH_TeleportFlags, teleport_flags); - char seedCap[STD_STRING_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_Info, _PREHASH_SeedCapability, - STD_STRING_BUF_SIZE, seedCap); + std::string seedCap; + msg->getStringFast(_PREHASH_Info, _PREHASH_SeedCapability, seedCap); // update home location if we are teleporting out of prelude - specific to teleporting to welcome area if((teleport_flags & TELEPORT_FLAGS_SET_HOME_TO_TARGET) @@ -2631,7 +2616,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**) gAgent.setTeleportState( LLAgent::TELEPORT_MOVING ); gAgent.setTeleportMessage(LLAgent::sTeleportProgressMessages["contacting"]); - regionp->setSeedCapability(std::string(seedCap)); + regionp->setSeedCapability(seedCap); // Don't send camera updates to the new region until we're // actually there... @@ -2666,7 +2651,7 @@ void process_avatar_init_complete(LLMessageSystem* msg, void**) static void display_release_message(S32, void* data) { std::string* msg = (std::string*)data; - LLFloaterReleaseMsg::displayMessage(msg->c_str()); + LLFloaterReleaseMsg::displayMessage(*msg); delete msg; } @@ -2696,8 +2681,8 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) U64 region_handle; msg->getU64Fast(_PREHASH_Data, _PREHASH_RegionHandle, region_handle); - char version_channel_char[MAX_STRING]; - msg->getString("SimData", "ChannelVersion", MAX_STRING, version_channel_char); + std::string version_channel; + msg->getString("SimData", "ChannelVersion", version_channel); LLVOAvatar* avatarp = gAgent.getAvatarObject(); if (!avatarp) @@ -2832,9 +2817,9 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) // send walk-vs-run status gAgent.sendWalkRun(gAgent.getRunning() || gAgent.getAlwaysRun()); - if (LLFloaterReleaseMsg::checkVersion(version_channel_char)) + if (LLFloaterReleaseMsg::checkVersion(version_channel)) { - LLNotifyBox::showXml("ServerVersionChanged", display_release_message, new std::string(version_channel_char) ); + LLNotifyBox::showXml("ServerVersionChanged", display_release_message, new std::string(version_channel) ); } } @@ -2860,13 +2845,13 @@ void process_crossed_region(LLMessageSystem* msg, void**) U64 region_handle; msg->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle); - char seedCap[STD_STRING_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_RegionData, _PREHASH_SeedCapability, STD_STRING_BUF_SIZE, seedCap); + std::string seedCap; + msg->getStringFast(_PREHASH_RegionData, _PREHASH_SeedCapability, seedCap); send_complete_agent_movement(sim_host); LLViewerRegion* regionp = LLWorld::getInstance()->addRegion(region_handle, sim_host); - regionp->setSeedCapability(std::string(seedCap)); + regionp->setSeedCapability(seedCap); } @@ -3858,7 +3843,7 @@ void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_dat // Culled from newsim lltask.cpp void process_name_value(LLMessageSystem *mesgsys, void **user_data) { - char temp_str[NAME_VALUE_BUF_SIZE]; /* Flawfinder: ignore */ + std::string temp_str; LLUUID id; S32 i, num_blocks; @@ -3871,7 +3856,7 @@ void process_name_value(LLMessageSystem *mesgsys, void **user_data) num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_NameValueData); for (i = 0; i < num_blocks; i++) { - mesgsys->getStringFast(_PREHASH_NameValueData, _PREHASH_NVPair, NAME_VALUE_BUF_SIZE, temp_str, i); + mesgsys->getStringFast(_PREHASH_NameValueData, _PREHASH_NVPair, temp_str, i); LL_INFOS("Messaging") << "Added to object Name Value: " << temp_str << LL_ENDL; object->addNVPair(temp_str); } @@ -3884,7 +3869,7 @@ void process_name_value(LLMessageSystem *mesgsys, void **user_data) void process_remove_name_value(LLMessageSystem *mesgsys, void **user_data) { - char temp_str[NAME_VALUE_BUF_SIZE]; /* Flawfinder: ignore */ + std::string temp_str; LLUUID id; S32 i, num_blocks; @@ -3897,7 +3882,7 @@ void process_remove_name_value(LLMessageSystem *mesgsys, void **user_data) num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_NameValueData); for (i = 0; i < num_blocks; i++) { - mesgsys->getStringFast(_PREHASH_NameValueData, _PREHASH_NVPair, NAME_VALUE_BUF_SIZE, temp_str, i); + mesgsys->getStringFast(_PREHASH_NameValueData, _PREHASH_NVPair, temp_str, i); LL_INFOS("Messaging") << "Removed from object Name Value: " << temp_str << LL_ENDL; object->removeNVPair(temp_str); } @@ -3910,10 +3895,9 @@ void process_remove_name_value(LLMessageSystem *mesgsys, void **user_data) void process_kick_user(LLMessageSystem *msg, void** /*user_data*/) { - char message[2048]; /* Flawfinder: ignore */ - message[0] = '\0'; + std::string message; - msg->getStringFast(_PREHASH_UserInfo, _PREHASH_Reason, 2048, message); + msg->getStringFast(_PREHASH_UserInfo, _PREHASH_Reason, message); LLAppViewer::instance()->forceDisconnect(message); } @@ -3978,12 +3962,12 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) S32 balance = 0; S32 credit = 0; S32 committed = 0; - char desc[STD_STRING_BUF_SIZE] = ""; /* Flawfinder: ignore */ + std::string desc; msg->getS32("MoneyData", "MoneyBalance", balance); msg->getS32("MoneyData", "SquareMetersCredit", credit); msg->getS32("MoneyData", "SquareMetersCommitted", committed); - msg->getStringFast(_PREHASH_MoneyData, _PREHASH_Description, STD_STRING_BUF_SIZE, desc); + msg->getStringFast(_PREHASH_MoneyData, _PREHASH_Description, desc); LL_INFOS("Messaging") << "L$, credit, committed: " << balance << " " << credit << " " << committed << LL_ENDL; @@ -4013,13 +3997,13 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) LLUUID tid; msg->getUUID("MoneyData", "TransactionID", tid); static std::deque<LLUUID> recent; - if(desc[0] && gSavedSettings.getBOOL("NotifyMoneyChange") + if(!desc.empty() && gSavedSettings.getBOOL("NotifyMoneyChange") && (std::find(recent.rbegin(), recent.rend(), tid) == recent.rend())) { // Make the user confirm the transaction, since they might // have missed something during an event. // *TODO:translate - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = desc; LLNotifyBox::showXml("SystemMessage", args); @@ -4039,8 +4023,8 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) void process_agent_alert_message(LLMessageSystem* msgsystem, void** user_data) { - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, MAX_STRING, buffer); + std::string buffer; + msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, buffer); BOOL modal = FALSE; msgsystem->getBOOL("AlertData", "Modal", modal); process_alert_core(buffer, modal); @@ -4048,8 +4032,8 @@ void process_agent_alert_message(LLMessageSystem* msgsystem, void** user_data) void process_alert_message(LLMessageSystem *msgsystem, void **user_data) { - char buffer[MAX_STRING]; /* Flawfinder: ignore */ - msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, MAX_STRING, buffer); + std::string buffer; + msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, buffer); BOOL modal = FALSE; process_alert_core(buffer, modal); } @@ -4068,7 +4052,7 @@ void process_alert_core(const std::string& message, BOOL modal) else if( message == "Home position set." ) { // save the home location image to disk - LLString snap_filename = gDirUtilp->getLindenUserDir(); + std::string snap_filename = gDirUtilp->getLindenUserDir(); snap_filename += gDirUtilp->getDirDelimiter(); snap_filename += SCREEN_HOME_FILENAME; gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight(), FALSE, FALSE); @@ -4093,19 +4077,19 @@ void process_alert_core(const std::string& message, BOOL modal) else if (message[0] == '/') { // System message is important, show in upper-right box not tip - LLString text(message.substr(1)); - LLString::format_map_t args; + std::string text(message.substr(1)); + LLStringUtil::format_map_t args; if (text.substr(0,17) == "RESTART_X_MINUTES") { S32 mins = 0; - LLString::convertToS32(text.substr(18), mins); + LLStringUtil::convertToS32(text.substr(18), mins); args["[MINUTES]"] = llformat("%d",mins); LLNotifyBox::showXml("RegionRestartMinutes", args); } else if (text.substr(0,17) == "RESTART_X_SECONDS") { S32 secs = 0; - LLString::convertToS32(text.substr(18), secs); + LLStringUtil::convertToS32(text.substr(18), secs); args["[SECONDS]"] = llformat("%d",secs); LLNotifyBox::showXml("RegionRestartSeconds", args); } @@ -4119,14 +4103,14 @@ void process_alert_core(const std::string& message, BOOL modal) else if (modal) { // *TODO:translate - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[ERROR_MESSAGE]"] = message; gViewerWindow->alertXml("ErrorMessage", args); } else { // *TODO:translate - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[MESSAGE]"] = message; LLNotifyBox::showXml("SystemMessageTip", args); } @@ -4145,7 +4129,7 @@ void handle_show_mean_events(void *) LLFloaterBump::show(NULL); } -void mean_name_callback(const LLUUID &id, const char *first, const char *last, BOOL always_false, void* data) +void mean_name_callback(const LLUUID &id, const std::string& first, const std::string& last, BOOL always_false, void* data) { if (gNoRender) { @@ -4167,10 +4151,8 @@ void mean_name_callback(const LLUUID &id, const char *first, const char *last, B LLMeanCollisionData *mcd = *iter; if (mcd->mPerp == id) { - strncpy(mcd->mFirstName, first, DB_FIRST_NAME_BUF_SIZE -1); /* Flawfinder: ignore */ - mcd->mFirstName[DB_FIRST_NAME_BUF_SIZE -1] = '\0'; - strncpy(mcd->mLastName, last, DB_LAST_NAME_BUF_SIZE -1); /* Flawfinder: ignore */ - mcd->mLastName[DB_LAST_NAME_BUF_SIZE -1] = '\0'; + mcd->mFirstName = first; + mcd->mLastName = last; } } } @@ -4265,7 +4247,7 @@ void process_economy_data(LLMessageSystem *msg, void** /*user_data*/) class LLScriptQuestionCBData { public: - LLScriptQuestionCBData(const LLUUID &taskid, const LLUUID &itemid, const LLHost &sender, S32 questions, const char *object_name, const char *owner_name) + LLScriptQuestionCBData(const LLUUID &taskid, const LLUUID &itemid, const LLHost &sender, S32 questions, const std::string& object_name, const std::string& owner_name) : mTaskID(taskid), mItemID(itemid), mSender(sender), mQuestions(questions), mObjectName(object_name), mOwnerName(owner_name) { } @@ -4274,8 +4256,8 @@ public: LLUUID mItemID; LLHost mSender; S32 mQuestions; - LLString mObjectName; - LLString mOwnerName; + std::string mObjectName; + std::string mOwnerName; }; void notify_cautioned_script_question(LLScriptQuestionCBData* cbdata, S32 orig_questions, BOOL granted) @@ -4310,7 +4292,7 @@ void notify_cautioned_script_question(LLScriptQuestionCBData* cbdata, S32 orig_q { // got the region, so include the region and 3d coordinates of the object notice.setArg("[REGIONNAME]", viewregion->getName()); - LLString formatpos = llformat("%.1f, %.1f,%.1f", objpos[VX], objpos[VY], objpos[VZ]); + std::string formatpos = llformat("%.1f, %.1f,%.1f", objpos[VX], objpos[VY], objpos[VZ]); notice.setArg("[REGIONPOS]", formatpos); foundpos = TRUE; @@ -4328,7 +4310,7 @@ void notify_cautioned_script_question(LLScriptQuestionCBData* cbdata, S32 orig_q // permission that has been flagged as a caution permission BOOL caution = FALSE; S32 count = 0; - LLString perms; + std::string perms; for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++) { if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && LLNotifyBox::getTemplateIsCaution(SCRIPT_QUESTIONS[i])) @@ -4455,26 +4437,25 @@ void process_script_question(LLMessageSystem *msg, void **user_data) LLUUID taskid; LLUUID itemid; S32 questions; - char object_name[255]; /* Flawfinder: ignore */ - char owner_name[DB_FULL_NAME_BUF_SIZE]; /* Flawfinder: ignore */ + std::string object_name; + std::string owner_name; // taskid -> object key of object requesting permissions msg->getUUIDFast(_PREHASH_Data, _PREHASH_TaskID, taskid ); // itemid -> script asset key of script requesting permissions msg->getUUIDFast(_PREHASH_Data, _PREHASH_ItemID, itemid ); - msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectName, 255, object_name); - msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectOwner, DB_FULL_NAME_BUF_SIZE, owner_name); + msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectName, object_name); + msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectOwner, owner_name); msg->getS32Fast(_PREHASH_Data, _PREHASH_Questions, questions ); // don't display permission requests if this object is muted - JS. if (LLMuteList::getInstance()->isMuted(taskid)) return; // throttle excessive requests from any specific user's scripts - LLString throttle_owner_name = owner_name; - typedef LLKeyThrottle<LLString> LLStringThrottle; + typedef LLKeyThrottle<std::string> LLStringThrottle; static LLStringThrottle question_throttle( LLREQUEST_PERMISSION_THROTTLE_LIMIT, LLREQUEST_PERMISSION_THROTTLE_INTERVAL ); - switch (question_throttle.noteAction(throttle_owner_name)) + switch (question_throttle.noteAction(owner_name)) { case LLStringThrottle::THROTTLE_NEWLY_BLOCKED: LL_INFOS("Messaging") << "process_script_question throttled" @@ -4490,12 +4471,12 @@ void process_script_question(LLMessageSystem *msg, void **user_data) break; } - LLString script_question; + std::string script_question; if (questions) { BOOL caution = FALSE; S32 count = 0; - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[OBJECTNAME]"] = object_name; args["[NAME]"] = owner_name; @@ -4563,7 +4544,7 @@ void container_inventory_arrived(LLViewerObject* object, LLUUID cat_id; cat_id = gInventory.createNewCategory(gAgent.getInventoryRootID(), LLAssetType::AT_NONE, - "Acquired Items"); + std::string("Acquired Items")); //TODO: Translate InventoryObjectList::const_iterator it = inventory->begin(); InventoryObjectList::const_iterator end = inventory->end(); @@ -4654,24 +4635,23 @@ void container_inventory_arrived(LLViewerObject* object, } } -// method to format the time. Buffer should be at least -// TIME_STR_LENGTH long, and the function returns buffer (for use in -// sprintf and the like) -char* formatted_time(const time_t& the_time, char* buffer) +// method to format the time. +std::string formatted_time(const time_t& the_time) { - LLString::copy(buffer, ctime(&the_time), TIME_STR_LENGTH); + char buffer[30]; /* Flawfinder: ignore */ + LLStringUtil::copy(buffer, ctime(&the_time), 30); buffer[24] = '\0'; - return buffer; + return std::string(buffer); } void process_teleport_failed(LLMessageSystem *msg, void**) { - char reason[STD_STRING_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, STD_STRING_BUF_SIZE, reason); + std::string reason; + msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, reason); - LLStringBase<char>::format_map_t args; - LLString big_reason = LLAgent::sTeleportErrorMessages[reason]; + LLStringUtil::format_map_t args; + std::string big_reason = LLAgent::sTeleportErrorMessages[reason]; if ( big_reason.size() > 0 ) { // Substitute verbose reason from the local map args["[REASON]"] = big_reason; @@ -4735,14 +4715,14 @@ void process_teleport_local(LLMessageSystem *msg,void**) } void send_simple_im(const LLUUID& to_id, - const char* message, + const std::string& message, EInstantMessage dialog, const LLUUID& id) { std::string my_name; gAgent.buildFullname(my_name); send_improved_im(to_id, - my_name.c_str(), + my_name, message, IM_ONLINE, dialog, @@ -4753,8 +4733,8 @@ void send_simple_im(const LLUUID& to_id, } void send_group_notice(const LLUUID& group_id, - const char* subject, - const char* message, + const std::string& subject, + const std::string& message, const LLInventoryItem* item) { // Put this notice into an instant message form. @@ -4793,8 +4773,8 @@ void send_group_notice(const LLUUID& group_id, send_improved_im( group_id, - my_name.c_str(), - subject_and_message.str().c_str(), + my_name, + subject_and_message.str(), IM_ONLINE, IM_GROUP_NOTICE, LLUUID::null, @@ -4803,7 +4783,7 @@ void send_group_notice(const LLUUID& group_id, bin_bucket_size); } -void handle_lure_callback(S32 option, const LLString& text, void* userdata) +void handle_lure_callback(S32 option, const std::string& text, void* userdata) { LLDynamicArray<LLUUID>* invitees = (LLDynamicArray<LLUUID>*)userdata; @@ -4816,7 +4796,7 @@ void handle_lure_callback(S32 option, const LLString& text, void* userdata) msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_Info); msg->addU8Fast(_PREHASH_LureType, (U8)0); // sim will fill this in. - msg->addStringFast(_PREHASH_Message, text.c_str()); + msg->addStringFast(_PREHASH_Message, text); for(LLDynamicArray<LLUUID>::iterator itr = invitees->begin(); itr != invitees->end(); ++itr) { msg->nextBlockFast(_PREHASH_TargetData); @@ -4831,7 +4811,7 @@ void handle_lure_callback(S32 option, const LLString& text, void* userdata) void handle_lure_callback_godlike(S32 option, void* userdata) { - handle_lure_callback(option, LLString::null, userdata); + handle_lure_callback(option, LLStringUtil::null, userdata); } void handle_lure(const LLUUID& invitee) @@ -4846,7 +4826,7 @@ void handle_lure(LLDynamicArray<LLUUID>& ids) { LLDynamicArray<LLUUID>* userdata = new LLDynamicArray<LLUUID>(ids); - LLString::format_map_t edit_args; + LLStringUtil::format_map_t edit_args; edit_args["[REGION]"] = gAgent.getRegion()->getName(); if (gAgent.isGodlike()) { @@ -4864,8 +4844,8 @@ void handle_lure(LLDynamicArray<LLUUID>& ids) void send_improved_im(const LLUUID& to_id, - const char* name, - const char* message, + const std::string& name, + const std::string& message, U8 offline, EInstantMessage dialog, const LLUUID& id, @@ -4896,10 +4876,10 @@ void send_improved_im(const LLUUID& to_id, void send_places_query(const LLUUID& query_id, const LLUUID& trans_id, - const char* query_text, + const std::string& query_text, U32 query_flags, S32 category, - const char* sim_name) + const std::string& sim_name) { LLMessageSystem* msg = gMessageSystem; @@ -4931,12 +4911,10 @@ void process_user_info_reply(LLMessageSystem* msg, void**) BOOL im_via_email; msg->getBOOLFast(_PREHASH_UserData, _PREHASH_IMViaEMail, im_via_email); - char email[DB_USER_EMAIL_ADDR_BUF_SIZE]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_UserData, _PREHASH_EMail, DB_USER_EMAIL_ADDR_BUF_SIZE, - email); - char dir_visibility[MAX_STRING]; /* Flawfinder: ignore */ - msg->getString( - "UserData", "DirectoryVisibility", MAX_STRING, dir_visibility); + std::string email; + msg->getStringFast(_PREHASH_UserData, _PREHASH_EMail, email); + std::string dir_visibility; + msg->getString( "UserData", "DirectoryVisibility", dir_visibility); LLFloaterPreference::updateUserInfo(dir_visibility, im_via_email, email); LLFloaterPostcard::updateUserInfo(email); @@ -4957,7 +4935,7 @@ struct ScriptDialogInfo LLHost mSender; LLUUID mObjectID; S32 mChatChannel; - std::vector<LLString> mButtons; + std::vector<std::string> mButtons; }; void callback_script_dialog(S32 option, void* data) @@ -4990,19 +4968,17 @@ void process_script_dialog(LLMessageSystem* msg, void**) ScriptDialogInfo* info = new ScriptDialogInfo; - const S32 messageLength = SCRIPT_DIALOG_MAX_MESSAGE_SIZE + sizeof(SCRIPT_DIALOG_HEADER); - char message[messageLength]; /* Flawfinder: ignore */ // Account for size of "Script Dialog:\n" - - char first_name[DB_FIRST_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - char last_name[DB_GROUP_NAME_BUF_SIZE]; /* Flawfinder: ignore */ - char title[DB_INV_ITEM_NAME_BUF_SIZE]; /* Flawfinder: ignore */ + std::string message; // Account for size of "Script Dialog:\n" + std::string first_name; + std::string last_name; + std::string title; info->mSender = msg->getSender(); msg->getUUID("Data", "ObjectID", info->mObjectID); - msg->getString("Data", "FirstName", DB_FIRST_NAME_BUF_SIZE, first_name); - msg->getString("Data", "LastName", DB_LAST_NAME_BUF_SIZE, last_name); - msg->getString("Data", "ObjectName", DB_INV_ITEM_NAME_BUF_SIZE, title); - msg->getString("Data", "Message", SCRIPT_DIALOG_MAX_MESSAGE_SIZE, message); + msg->getString("Data", "FirstName", first_name); + msg->getString("Data", "LastName", last_name); + msg->getString("Data", "ObjectName", title); + msg->getString("Data", "Message", message); msg->getS32("Data", "ChatChannel", info->mChatChannel); // unused for now @@ -5017,15 +4993,15 @@ void process_script_dialog(LLMessageSystem* msg, void**) for (i = 0; i < button_count; i++) { - char tdesc[SCRIPT_DIALOG_BUTTON_STR_SIZE+1]; /* Flawfinder: ignore */ - msg->getString("Buttons", "ButtonLabel", SCRIPT_DIALOG_BUTTON_STR_SIZE + 1, tdesc, i); - info->mButtons.push_back(LLString(tdesc)); + std::string tdesc; + msg->getString("Buttons", "ButtonLabel", tdesc, i); + info->mButtons.push_back(tdesc); } - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[TITLE]"] = title; args["[MESSAGE]"] = message; - if (strlen(first_name) > 0) /* Flawfinder: ignore */ + if (!first_name.empty()) { args["[FIRST]"] = first_name; args["[LAST]"] = last_name; @@ -5051,9 +5027,9 @@ struct LoadUrlInfo LLUUID mObjectID; LLUUID mOwnerID; BOOL mOwnerIsGroup; - char mObjectName[256]; /* Flawfinder: ignore */ - char mMessage[256]; /* Flawfinder: ignore */ - char mUrl[256]; /* Flawfinder: ignore */ + std::string mObjectName; + std::string mMessage; + std::string mUrl; }; std::vector<LoadUrlInfo*> gLoadUrlList; @@ -5075,7 +5051,7 @@ void callback_load_url(S32 option, void* data) // We've got the name of the person who owns the object hurling the url. // Display confirmation dialog. -void callback_load_url_name(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* data) +void callback_load_url_name(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data) { std::vector<LoadUrlInfo*>::iterator it; for (it = gLoadUrlList.begin(); it != gLoadUrlList.end(); ) @@ -5085,15 +5061,14 @@ void callback_load_url_name(const LLUUID& id, const char* first, const char* las { it = gLoadUrlList.erase(it); - std::string owner_name(first); + std::string owner_name; if (is_group) { - owner_name += " (group)"; + owner_name = first + " (group)"; } else { - owner_name += " "; - owner_name += last; + owner_name = first + " " + last; } // For legacy name-only mutes. @@ -5103,7 +5078,7 @@ void callback_load_url_name(const LLUUID& id, const char* first, const char* las infop = NULL; continue; } - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[URL]"] = infop->mUrl; args["[MESSAGE]"] = infop->mMessage; args["[OBJECTNAME]"] = infop->mObjectName; @@ -5121,12 +5096,12 @@ void process_load_url(LLMessageSystem* msg, void**) { LoadUrlInfo* infop = new LoadUrlInfo; - msg->getString("Data", "ObjectName", 256, infop->mObjectName); + msg->getString("Data", "ObjectName", infop->mObjectName); msg->getUUID( "Data", "ObjectID", infop->mObjectID); msg->getUUID( "Data", "OwnerID", infop->mOwnerID); msg->getBOOL( "Data", "OwnerIsGroup", infop->mOwnerIsGroup); - msg->getString("Data", "Message", 256, infop->mMessage); - msg->getString("Data", "URL", 256, infop->mUrl); + msg->getString("Data", "Message", infop->mMessage); + msg->getString("Data", "URL", infop->mUrl); // URL is safety checked in load_url above @@ -5149,8 +5124,8 @@ void process_load_url(LLMessageSystem* msg, void**) void callback_download_complete(void** data, S32 result, LLExtStat ext_status) { - LLString* filepath = (LLString*)data; - LLString::format_map_t args; + std::string* filepath = (std::string*)data; + LLStringUtil::format_map_t args; args["[DOWNLOAD_PATH]"] = *filepath; gViewerWindow->alertXml("FinishedRawDownload", args); delete filepath; @@ -5167,10 +5142,10 @@ void process_initiate_download(LLMessageSystem* msg, void**) return; } - char sim_filename[MAX_PATH]; /* Flawfinder: ignore */ - char viewer_filename[MAX_PATH]; /* Flawfinder: ignore */ - msg->getString("FileData", "SimFilename", MAX_PATH, sim_filename); - msg->getString("FileData", "ViewerFilename", MAX_PATH, viewer_filename); + std::string sim_filename; + std::string viewer_filename; + msg->getString("FileData", "SimFilename", sim_filename); + msg->getString("FileData", "ViewerFilename", viewer_filename); gXferManager->requestFile(viewer_filename, sim_filename, @@ -5178,19 +5153,19 @@ void process_initiate_download(LLMessageSystem* msg, void**) msg->getSender(), FALSE, // don't delete remote callback_download_complete, - (void**)new LLString(viewer_filename)); + (void**)new std::string(viewer_filename)); } void process_script_teleport_request(LLMessageSystem* msg, void**) { - char object_name[256]; /* Flawfinder: ignore */ - char sim_name[256]; /* Flawfinder: ignore */ + std::string object_name; + std::string sim_name; LLVector3 pos; LLVector3 look_at; - msg->getString("Data", "ObjectName", 255, object_name); - msg->getString( "Data", "SimName", 255, sim_name); + msg->getString("Data", "ObjectName", object_name); + msg->getString("Data", "SimName", sim_name); msg->getVector3("Data", "SimPosition", pos); msg->getVector3("Data", "LookAt", look_at); @@ -5206,11 +5181,11 @@ void process_script_teleport_request(LLMessageSystem* msg, void**) void process_covenant_reply(LLMessageSystem* msg, void**) { LLUUID covenant_id, estate_owner_id; - char estate_name[MAX_STRING]; /* Flawfinder: ignore */ + std::string estate_name; U32 covenant_timestamp; msg->getUUID("Data", "CovenantID", covenant_id); msg->getU32("Data", "CovenantTimestamp", covenant_timestamp); - msg->getString("Data", "EstateName", MAX_STRING, estate_name); + msg->getString("Data", "EstateName", estate_name); msg->getUUID("Data", "EstateOwnerID", estate_owner_id); LLPanelEstateCovenant::updateEstateName(estate_name); @@ -5218,11 +5193,7 @@ void process_covenant_reply(LLMessageSystem* msg, void**) LLFloaterBuyLand::updateEstateName(estate_name); // standard message, not from system - char last_modified[MAX_STRING]; /* Flawfinder: ignore */ - last_modified[0] = '\0'; - char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ - snprintf(last_modified, MAX_STRING, "Last Modified %s", /* Flawfinder: ignore */ - formatted_time((time_t)covenant_timestamp, time_buf)); + std::string last_modified = std::string("Last Modified ") + formatted_time((time_t)covenant_timestamp); LLPanelEstateCovenant::updateLastModified(last_modified); LLPanelLandCovenant::updateLastModified(last_modified); @@ -5262,12 +5233,9 @@ void process_covenant_reply(LLMessageSystem* msg, void**) } } -void callbackCacheEstateOwnerName( - const LLUUID& id, - const char* first, - const char* last, - BOOL is_group, - void*) +void callbackCacheEstateOwnerName(const LLUUID& id, + const std::string& first, const std::string& last, + BOOL is_group, void*) { std::string name; @@ -5277,9 +5245,7 @@ void callbackCacheEstateOwnerName( } else { - name = first; - name += " "; - name += last; + name = first + " " + last; } LLPanelEstateCovenant::updateEstateOwnerName(name); LLPanelLandCovenant::updateEstateOwnerName(name); @@ -5314,10 +5280,10 @@ void onCovenantLoadComplete(LLVFS *vfs, if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) ) { LLViewerTextEditor* editor = - new LLViewerTextEditor("temp", + new LLViewerTextEditor(std::string("temp"), LLRect(0,0,0,0), file_length+1); - if( !editor->importBuffer( buffer ) ) + if( !editor->importBuffer( buffer, file_length+1 ) ) { LL_WARNS("Messaging") << "Problem importing estate covenant." << LL_ENDL; covenant_text = "Problem importing estate covenant."; @@ -5367,12 +5333,12 @@ void process_feature_disabled_message(LLMessageSystem* msg, void**) // Handle Blacklisted feature simulator response... LLUUID agentID; LLUUID transactionID; - char messageText[MAX_STRING]; /* Flawfinder: ignore */ - msg->getStringFast(_PREHASH_FailureInfo,_PREHASH_ErrorMessage,MAX_STRING,&messageText[0],0); + std::string messageText; + msg->getStringFast(_PREHASH_FailureInfo,_PREHASH_ErrorMessage, messageText,0); msg->getUUIDFast(_PREHASH_FailureInfo,_PREHASH_AgentID,agentID); msg->getUUIDFast(_PREHASH_FailureInfo,_PREHASH_TransactionID,transactionID); - LL_WARNS("Messaging") << "Blacklisted Feature Response:" << &messageText[0] << LL_ENDL; + LL_WARNS("Messaging") << "Blacklisted Feature Response:" << messageText << LL_ENDL; } // ------------------------------------------------------------ diff --git a/indra/newview/llviewermessage.h b/indra/newview/llviewermessage.h index 23783058a0..a2ed04d0a7 100644 --- a/indra/newview/llviewermessage.h +++ b/indra/newview/llviewermessage.h @@ -61,7 +61,7 @@ enum InventoryOfferResponse BOOL can_afford_transaction(S32 cost); void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_group = FALSE, - S32 trx_type = TRANS_GIFT, const LLString& desc = LLString::null); + S32 trx_type = TRANS_GIFT, const std::string& desc = LLStringUtil::null); void busy_message (LLMessageSystem* msg, LLUUID from_id); void process_logout_reply(LLMessageSystem* msg, void**); @@ -139,13 +139,13 @@ void process_teleport_local(LLMessageSystem *msg,void**); void process_user_sim_location_reply(LLMessageSystem *msg,void**); void send_simple_im(const LLUUID& to_id, - const char* message, + const std::string& message, EInstantMessage dialog = IM_NOTHING_SPECIAL, const LLUUID& id = LLUUID::null); void send_group_notice(const LLUUID& group_id, - const char* subject, - const char* message, + const std::string& subject, + const std::string& message, const LLInventoryItem* item); void handle_lure(const LLUUID& invitee); @@ -154,8 +154,8 @@ void handle_lure(LLDynamicArray<LLUUID>& ids); // always from gAgent and // routes through the gAgent's current simulator void send_improved_im(const LLUUID& to_id, - const char* name, - const char* message, + const std::string& name, + const std::string& message, U8 offline = IM_ONLINE, EInstantMessage dialog = IM_NOTHING_SPECIAL, const LLUUID& id = LLUUID::null, @@ -165,18 +165,15 @@ void send_improved_im(const LLUUID& to_id, void process_user_info_reply(LLMessageSystem* msg, void**); -// method to format the time. Buffer should be at least -// TIME_STR_LENGTH long, and the function reutnrs buffer (for use in -// sprintf and the like) -const S32 TIME_STR_LENGTH = 30; -char* formatted_time(const time_t& the_time, char* buffer); +// method to format the time. +std::string formatted_time(const time_t& the_time); void send_places_query(const LLUUID& query_id, const LLUUID& trans_id, - const char* query_text, + const std::string& query_text, U32 query_flags, S32 category, - const char* sim_name); + const std::string& sim_name); void process_script_dialog(LLMessageSystem* msg, void**); void process_load_url(LLMessageSystem* msg, void**); void process_script_teleport_request(LLMessageSystem* msg, void**); @@ -185,12 +182,6 @@ void onCovenantLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status); -void callbackCacheEstateOwnerName( - const LLUUID& id, - const char* first, - const char* last, - BOOL is_group, - void*); // calling cards void process_offer_callingcard(LLMessageSystem* msg, void**); @@ -214,8 +205,8 @@ struct LLOfferInfo LLUUID mFolderID; LLUUID mObjectID; LLAssetType::EType mType; - LLString mFromName; - LLString mDesc; + std::string mFromName; + std::string mDesc; LLHost mHost; }; diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index fed98d5daa..d2d8f774a0 100644 --- a/indra/newview/llviewernetwork.cpp +++ b/indra/newview/llviewernetwork.cpp @@ -176,7 +176,7 @@ void LLViewerLogin::setGridChoice(const std::string& grid_name) int grid_index = GRID_INFO_NONE; for(;grid_index < GRID_INFO_OTHER; ++grid_index) { - if(0 == LLString::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name.c_str())) + if(0 == LLStringUtil::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name)) { // Founding a matching label in the list... setGridChoice((EGridInfo)grid_index); @@ -301,7 +301,7 @@ bool LLViewerLogin::isInProductionGrid() // but it seems that loginURI trumps that. std::vector<std::string> uris; getLoginURIs(uris); - LLString::toLower(uris[0]); + LLStringUtil::toLower(uris[0]); if((uris[0].find("agni") != std::string::npos)) { return true; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 3a501a9045..19025b34a4 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -467,7 +467,7 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list) if (end > start) { std::string tok = name_value_list.substr(start, end - start); - addNVPair(tok.c_str()); + addNVPair(tok); } start = end+1; } @@ -955,12 +955,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, S32 nv_size = mesgsys->getSizeFast(_PREHASH_ObjectData, block_num, _PREHASH_NameValue); if (nv_size > 0) { - char* name_value_list = new char[nv_size]; - mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_NameValue, nv_size, name_value_list, block_num); - + std::string name_value_list; + mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_NameValue, name_value_list, block_num); setNameValueList(name_value_list); - - delete [] name_value_list; } // Clear out any existing generic data @@ -996,8 +993,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, mText->setOnHUDAttachment(isHUDAttachment()); } - char temp_string[256]; /* Flawfinder: ignore */ // not MAX_STRING, must hold 255 chars + \0 - mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_Text, 256, temp_string, block_num ); + std::string temp_string; + mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_Text, temp_string, block_num ); LLColor4U coloru; mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextColor, coloru.mV, 4, block_num); @@ -1019,13 +1016,13 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, mText = NULL; } - char media_url[MAX_STRING+1]; /* Flawfinder: ignore */ - mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_MediaURL, MAX_STRING+1, media_url, block_num); - //if (media_url[0]) + std::string media_url; + mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_MediaURL, media_url, block_num); + //if (!media_url.empty()) //{ // llinfos << "WEBONPRIM media_url " << media_url << llendl; //} - if (!mMedia && media_url[0] != '\0') + if (!mMedia && !media_url.empty()) { retval |= MEDIA_URL_ADDED; mMedia = new LLViewerObjectMedia; @@ -1035,7 +1032,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, } else if (mMedia) { - if (media_url[0] == '\0') + if (media_url.empty()) { retval |= MEDIA_URL_REMOVED; delete mMedia; @@ -1514,7 +1511,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, std::string name_value_list; dp->unpackString(name_value_list, "NV"); - setNameValueList(name_value_list.c_str()); + setNameValueList(name_value_list); } mTotalCRC = crc; @@ -2386,7 +2383,7 @@ void LLViewerObject::fetchInventoryFromServer() struct LLFilenameAndTask { LLUUID mTaskID; - char mFilename[MAX_STRING]; /* Flawfinder: ignore */ // Just the filename, not the path + std::string mFilename; #ifdef _DEBUG static S32 sCount; LLFilenameAndTask() @@ -2427,8 +2424,8 @@ void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data) msg->getS16Fast(_PREHASH_InventoryData, _PREHASH_Serial, object->mInventorySerialNum); LLFilenameAndTask* ft = new LLFilenameAndTask; ft->mTaskID = task_id; - msg->getStringFast(_PREHASH_InventoryData, _PREHASH_Filename, MAX_STRING, ft->mFilename); - if(!ft->mFilename[0]) + msg->getStringFast(_PREHASH_InventoryData, _PREHASH_Filename, ft->mFilename); + if(ft->mFilename.empty()) { lldebugs << "Task has no inventory" << llendl; // mock up some inventory to make a drop target. @@ -2443,13 +2440,13 @@ void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data) LLPointer<LLInventoryObject> obj; obj = new LLInventoryObject(object->mID, LLUUID::null, LLAssetType::AT_CATEGORY, - "Contents"); + std::string("Contents")); object->mInventory->push_front(obj); object->doInventoryCallback(); delete ft; return; } - gXferManager->requestFile(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ft->mFilename).c_str(), + gXferManager->requestFile(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ft->mFilename), ft->mFilename, LL_PATH_CACHE, object->mRegionp->getHost(), TRUE, @@ -2477,12 +2474,12 @@ void LLViewerObject::processTaskInvFile(void** user_data, S32 error_code, LLExtS delete ft; } -void LLViewerObject::loadTaskInvFile(const char* filename) +void LLViewerObject::loadTaskInvFile(const std::string& filename) { LLMemType mt(LLMemType::MTYPE_OBJECT); std::string filename_and_local_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, filename); - llifstream ifs(filename_and_local_path.c_str()); + llifstream ifs(filename_and_local_path); if(ifs.good()) { char buffer[MAX_STRING]; /* Flawfinder: ignore */ @@ -2519,7 +2516,7 @@ void LLViewerObject::loadTaskInvFile(const char* filename) } } ifs.close(); - LLFile::remove(filename_and_local_path.c_str()); + LLFile::remove(filename_and_local_path); } else { @@ -2970,7 +2967,7 @@ void LLViewerObject::addNVPair(const std::string& data) mNameValuePairs[nv->mName] = nv; } -BOOL LLViewerObject::removeNVPair(const char *name) +BOOL LLViewerObject::removeNVPair(const std::string& name) { char* canonical_name = gNVNameTable.addString(name); @@ -2989,7 +2986,7 @@ BOOL LLViewerObject::removeNVPair(const char *name) gMessageSystem->addUUIDFast(_PREHASH_ID, mID); gMessageSystem->nextBlockFast(_PREHASH_NameValueData); - gMessageSystem->addStringFast(_PREHASH_NVPair, buffer.c_str()); + gMessageSystem->addStringFast(_PREHASH_NVPair, buffer); gMessageSystem->sendReliable( mRegionp->getHost() ); */ @@ -3007,7 +3004,7 @@ BOOL LLViewerObject::removeNVPair(const char *name) } -LLNameValue *LLViewerObject::getNVPair(const char *name) const +LLNameValue *LLViewerObject::getNVPair(const std::string& name) const { char *canonical_name; @@ -3394,7 +3391,7 @@ void LLViewerObject::setMediaType(U8 media_type) } } -const LLString& LLViewerObject::getMediaURL() const +std::string LLViewerObject::getMediaURL() const { if (mMedia) { @@ -3402,11 +3399,11 @@ const LLString& LLViewerObject::getMediaURL() const } else { - return LLString::null; + return std::string(); } } -void LLViewerObject::setMediaURL(const LLString& media_url) +void LLViewerObject::setMediaURL(const std::string& media_url) { LLMemType mt(LLMemType::MTYPE_OBJECT); diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index ed38911d4e..0f0fa62ea1 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -143,8 +143,8 @@ public: static void cleanupVOClasses(); void addNVPair(const std::string& data); - BOOL removeNVPair(const char *name); - LLNameValue *getNVPair(const char *name) const; // null if no name value pair by that name + BOOL removeNVPair(const std::string& name); + LLNameValue* getNVPair(const std::string& name) const; // null if no name value pair by that name // Object create and update functions virtual BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); @@ -326,8 +326,8 @@ public: U8 getMediaType() const; void setMediaType(U8 media_type); - const LLString& getMediaURL() const; - void setMediaURL(const LLString& media_url); + std::string getMediaURL() const; + void setMediaURL(const std::string& media_url); BOOL getMediaPassedWhitelist() const; void setMediaPassedWhitelist(BOOL passed); @@ -550,7 +550,7 @@ protected: // static void processTaskInvFile(void** user_data, S32 error_code, LLExtStat ext_status); - void loadTaskInvFile(const char* filename); + void loadTaskInvFile(const std::string& filename); void doInventoryCallback(); BOOL isOnMap(); @@ -657,7 +657,7 @@ class LLViewerObjectMedia public: LLViewerObjectMedia() : mMediaURL(), mPassedWhitelist(FALSE), mMediaType(0) { } - LLString mMediaURL; // for web pages on surfaces, one per prim + std::string mMediaURL; // for web pages on surfaces, one per prim BOOL mPassedWhitelist; // user has OK'd display U8 mMediaType; // see LLTextureEntry::WEB_PAGE, etc. }; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 2345b4ea06..1c0aaec29a 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -717,17 +717,17 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) /* // Debugging code for viewing orphans, and orphaned parents LLUUID id; - char id_str[UUID_STR_LENGTH + 20]; for (i = 0; i < mOrphanParents.count(); i++) { id = sIndexAndLocalIDToUUID[mOrphanParents[i]]; LLViewerObject *objectp = findObject(id); if (objectp) { - sprintf(id_str, "Par: "); - objectp->mID.toString(id_str + 5); + std::string id_str; + objectp->mID.toString(id_str); + std::string tmpstr = std::string("Par: ") + id_str; addDebugBeacon(objectp->getPositionAgent(), - id_str, + tmpstr, LLColor4(1.f,0.f,0.f,1.f), LLColor4(1.f,1.f,1.f,1.f)); } @@ -740,20 +740,22 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) LLViewerObject *objectp = findObject(oi.mChildInfo); if (objectp) { + std::string id_str; + objectp->mID.toString(id_str); + std::string tmpstr; if (objectp->getParent()) { - sprintf(id_str, "ChP: "); + tmpstr = std::string("ChP: ") + id_str; text_color = LLColor4(0.f, 1.f, 0.f, 1.f); } else { - sprintf(id_str, "ChNoP: "); + tmpstr = std::string("ChNoP: ") + id_str; text_color = LLColor4(1.f, 0.f, 0.f, 1.f); } id = sIndexAndLocalIDToUUID[oi.mParentInfo]; - objectp->mID.toString(id_str + 8); addDebugBeacon(objectp->getPositionAgent() + LLVector3(0.f, 0.f, -0.25f), - id_str, + tmpstr, LLColor4(0.25f,0.25f,0.25f,1.f), text_color); } @@ -1236,7 +1238,7 @@ LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) } void LLViewerObjectList::addDebugBeacon(const LLVector3 &pos_agent, - const LLString &string, + const std::string &string, const LLColor4 &color, const LLColor4 &text_color, S32 line_width) diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 39603cfd3b..b9b6ff243f 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -95,7 +95,7 @@ public: void renderObjectsForMap(LLNetMap &netmap); void renderObjectBounds(const LLVector3 ¢er); - void addDebugBeacon(const LLVector3 &pos_agent, const LLString &string, + void addDebugBeacon(const LLVector3 &pos_agent, const std::string &string, const LLColor4 &color=LLColor4(1.f, 0.f, 0.f, 0.5f), const LLColor4 &text_color=LLColor4(1.f, 1.f, 1.f, 1.f), S32 line_width = 1); @@ -225,7 +225,7 @@ public: } LLVector3 mPositionAgent; - LLString mString; + std::string mString; LLColor4 mColor; LLColor4 mTextColor; S32 mLineWidth; diff --git a/indra/newview/llviewerparcelmedia.cpp b/indra/newview/llviewerparcelmedia.cpp index ba6a6005bf..272080678f 100644 --- a/indra/newview/llviewerparcelmedia.cpp +++ b/indra/newview/llviewerparcelmedia.cpp @@ -120,7 +120,7 @@ void LLViewerParcelMedia::update(LLParcel* parcel) } std::string mediaUrl = std::string ( parcel->getMediaURL () ); - LLString::trim(mediaUrl); + LLStringUtil::trim(mediaUrl); // has something changed? if ( ( LLViewerMedia::getMediaURL() != mediaUrl ) @@ -370,7 +370,7 @@ void LLViewerParcelMedia::processParcelMediaUpdate( LLMessageSystem *msg, void * { // temporarily store these new values in the parcel parcel->setMediaURL(media_url); - parcel->setMediaType(media_type.c_str()); + parcel->setMediaType(media_type); parcel->setMediaID(media_id); parcel->setMediaWidth(media_width); parcel->setMediaHeight(media_height); diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index f14d206b7f..6e37ec2095 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -83,7 +83,7 @@ LLPointer<LLViewerImage> sBlockedImage; LLPointer<LLViewerImage> sPassImage; // Local functions -void optionally_start_music(const LLString& music_url); +void optionally_start_music(const std::string& music_url); void callback_start_music(S32 option, void* data); void optionally_prepare_video(const LLParcel *parcelp); void callback_prepare_video(S32 option, void* data); @@ -1211,22 +1211,21 @@ void LLViewerParcelMgr::makeLandmarkAtSelection() LLVector3 west_south_bottom_region = region->getPosRegionFromGlobal( mWestSouth ); LLVector3 east_north_top_region = region->getPosRegionFromGlobal( mEastNorth ); - LLString name("My Land"); - char buffer[MAX_STRING]; + std::string name("My Land"); + std::string buffer; S32 pos_x = (S32)floor((west_south_bottom_region.mV[VX] + east_north_top_region.mV[VX]) / 2.0f); S32 pos_y = (S32)floor((west_south_bottom_region.mV[VY] + east_north_top_region.mV[VY]) / 2.0f); - sprintf(buffer, "%s in %s (%d, %d)", + buffer = llformat("%s in %s (%d, %d)", name.c_str(), region->getName().c_str(), pos_x, pos_y); name.assign(buffer); - const char* desc = "Claimed land"; - create_landmark(name.c_str(), desc, global_center); + create_landmark(name, "Claimed land", global_center); } */ -const LLString& LLViewerParcelMgr::getAgentParcelName() const +const std::string& LLViewerParcelMgr::getAgentParcelName() const { return mAgentParcel->getName(); } @@ -1649,16 +1648,16 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use { if (parcel) { - LLString music_url_raw = parcel->getMusicURL(); + std::string music_url_raw = parcel->getMusicURL(); // Trim off whitespace from front and back - LLString music_url = music_url_raw; - LLString::trim(music_url); + std::string music_url = music_url_raw; + LLStringUtil::trim(music_url); // On entering a new parcel, stop the last stream if the // new parcel has a different music url. (Empty URL counts // as different.) - const char* stream_url = gAudiop->getInternetStreamURL(); + const std::string& stream_url = gAudiop->getInternetStreamURL(); if (music_url.empty() || music_url != stream_url) { @@ -1673,10 +1672,10 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use optionally_start_music(music_url); } } - else if (gAudiop->getInternetStreamURL()[0]) + else if (!gAudiop->getInternetStreamURL().empty()) { llinfos << "Stopping parcel music" << llendl; - gAudiop->startInternetStream(NULL); + gAudiop->startInternetStream(LLStringUtil::null); } } } @@ -1692,7 +1691,7 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use }; } -void optionally_start_music(const LLString& music_url) +void optionally_start_music(const std::string& music_url) { if (gSavedSettings.getBOOL("AudioStreamingMusic")) { @@ -1703,7 +1702,7 @@ void optionally_start_music(const LLString& music_url) // changed as part of SL-4878 if ( gOverlayBar && gOverlayBar->musicPlaying()) { - gAudiop->startInternetStream(music_url.c_str()); + gAudiop->startInternetStream(music_url); } } } @@ -1909,7 +1908,7 @@ void LLViewerParcelMgr::deedLandToGroup() { std::string group_name; gCacheName->getGroupName(mCurrentParcel->getGroupID(), group_name); - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[AREA]"] = llformat("%d", mCurrentParcel->getArea()); args["[GROUP_NAME]"] = group_name; if(mCurrentParcel->getContributeWithDeed()) @@ -1980,7 +1979,7 @@ void LLViewerParcelMgr::startReleaseLand() if ((region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL) && !gAgent.isGodlike()) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REGION]"] = region->getName(); gViewerWindow->alertXml("CannotReleaseLandNoTransfer", args); return; @@ -1994,7 +1993,7 @@ void LLViewerParcelMgr::startReleaseLand() } // Compute claim price - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[AREA]"] = llformat("%d",mCurrentParcel->getArea()); gViewerWindow->alertXml("ReleaseLandWarning", args, releaseAlertCB, this); @@ -2193,7 +2192,7 @@ void LLViewerParcelMgr::startDeedLandToGroup() if((region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL) && (mCurrentParcel->getOwnerID() != region->getOwner())) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[REGION]"] = region->getName(); gViewerWindow->alertXml("CannotDeedLandNoTransfer", args); return; diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h index 37499e3751..4326e07e46 100644 --- a/indra/newview/llviewerparcelmgr.h +++ b/indra/newview/llviewerparcelmgr.h @@ -237,7 +237,7 @@ public: void sendParcelRelease(); // accessors for mAgentParcel - const LLString& getAgentParcelName() const; + const std::string& getAgentParcelName() const; // Create a landmark at the "appropriate" location for the // currently selected parcel. diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 41c97818dc..568a4049f0 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -276,12 +276,9 @@ void LLViewerRegion::loadCache() LLVOCacheEntry *entry; - char filename[256]; /* Flawfinder: ignore */ - snprintf(filename, sizeof(filename), "%s%sobjects_%d_%d.slc", /* Flawfinder: ignore */ - gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"").c_str(), - gDirUtilp->getDirDelimiter().c_str(), - U32(mHandle>>32)/REGION_WIDTH_UNITS, - U32(mHandle)/REGION_WIDTH_UNITS ); + std::string filename; + filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"") + gDirUtilp->getDirDelimiter() + + llformat("objects_%d_%d.slc",U32(mHandle>>32)/REGION_WIDTH_UNITS, U32(mHandle)/REGION_WIDTH_UNITS ); LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */ if (!fp) @@ -365,12 +362,9 @@ void LLViewerRegion::saveCache() return; } - char filename[256]; /* Flawfinder: ignore */ - snprintf(filename, sizeof(filename), "%s%sobjects_%d_%d.slc", /* Flawfinder: ignore */ - gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"").c_str(), - gDirUtilp->getDirDelimiter().c_str(), - U32(mHandle>>32)/REGION_WIDTH_UNITS, - U32(mHandle)/REGION_WIDTH_UNITS ); + std::string filename; + filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"") + gDirUtilp->getDirDelimiter() + + llformat("sobjects_%d_%d.slc", U32(mHandle>>32)/REGION_WIDTH_UNITS, U32(mHandle)/REGION_WIDTH_UNITS ); LLFILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ if (!fp) @@ -495,9 +489,8 @@ LLVector3 LLViewerRegion::getCenterAgent() const return gAgent.getPosAgentFromGlobal(mCenterGlobal); } -void LLViewerRegion::setRegionNameAndZone(const char* name_and_zone) +void LLViewerRegion::setRegionNameAndZone (const std::string& name_zone) { - LLString name_zone(name_and_zone); std::string::size_type pipe_pos = name_zone.find('|'); S32 length = name_zone.size(); if (pipe_pos != std::string::npos) @@ -511,8 +504,8 @@ void LLViewerRegion::setRegionNameAndZone(const char* name_and_zone) mZoning = ""; } - LLString::stripNonprintable(mName); - LLString::stripNonprintable(mZoning); + LLStringUtil::stripNonprintable(mName); + LLStringUtil::stripNonprintable(mZoning); } BOOL LLViewerRegion::canManageEstate() const @@ -522,7 +515,7 @@ BOOL LLViewerRegion::canManageEstate() const || gAgent.getID() == getOwner(); } -const char* LLViewerRegion::getSimAccessString() const +const std::string LLViewerRegion::getSimAccessString() const { return accessToString(mSimAccess); } @@ -554,9 +547,9 @@ const char* SIM_ACCESS_STR[] = { "Free Trial", "Unknown" }; // static -const char* LLViewerRegion::accessToString(U8 access) /* Flawfinder: ignore */ +std::string LLViewerRegion::accessToString(U8 sim_access) { - switch(access) /* Flawfinder: ignore */ + switch(sim_access) { case SIM_ACCESS_TRIAL: return SIM_ACCESS_STR[0]; @@ -577,28 +570,28 @@ const char* LLViewerRegion::accessToString(U8 access) /* Flawfinder: ignore */ } // static -U8 LLViewerRegion::stringToAccess(const char* access_str) +U8 LLViewerRegion::stringToAccess(const std::string& access_str) { - U8 access = SIM_ACCESS_MIN; - if (0 == strcmp(access_str, SIM_ACCESS_STR[0])) + U8 sim_access = SIM_ACCESS_MIN; + if (access_str == SIM_ACCESS_STR[0]) { - access = SIM_ACCESS_TRIAL; + sim_access = SIM_ACCESS_TRIAL; } - else if (0 == strcmp(access_str, SIM_ACCESS_STR[1])) + else if (access_str == SIM_ACCESS_STR[1]) { - access = SIM_ACCESS_PG; + sim_access = SIM_ACCESS_PG; } - else if (0 == strcmp(access_str, SIM_ACCESS_STR[2])) + else if (access_str == SIM_ACCESS_STR[2]) { - access = SIM_ACCESS_MATURE; + sim_access = SIM_ACCESS_MATURE; } - return access; /* Flawfinder: ignore */ + return sim_access; } // static -const char* LLViewerRegion::accessToShortString(U8 access) /* Flawfinder: ignore */ +std::string LLViewerRegion::accessToShortString(U8 sim_access) { - switch(access) /* Flawfinder: ignore */ + switch(sim_access) /* Flawfinder: ignore */ { case SIM_ACCESS_PG: return "PG"; @@ -1277,10 +1270,9 @@ void LLViewerRegion::unpackRegionHandshake() { LLMessageSystem *msg = gMessageSystem; - const S32 SIM_NAME_BUF = 256; U32 region_flags; U8 sim_access; - char sim_name[SIM_NAME_BUF]; /* Flawfinder: ignore */ + std::string sim_name; LLUUID sim_owner; BOOL is_estate_manager; F32 water_height; @@ -1289,7 +1281,7 @@ void LLViewerRegion::unpackRegionHandshake() msg->getU32 ("RegionInfo", "RegionFlags", region_flags); msg->getU8 ("RegionInfo", "SimAccess", sim_access); - msg->getString ("RegionInfo", "SimName", SIM_NAME_BUF, sim_name); + msg->getString ("RegionInfo", "SimName", sim_name); msg->getUUID ("RegionInfo", "SimOwner", sim_owner); msg->getBOOL ("RegionInfo", "IsEstateManager", is_estate_manager); msg->getF32 ("RegionInfo", "WaterHeight", water_height); diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index d6e5e8320f..8c3115f78d 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -161,9 +161,9 @@ public: const LLVector3d &getCenterGlobal() const { return mCenterGlobal; } LLVector3 getCenterAgent() const; - void setRegionNameAndZone(const char* name_and_zone); - const LLString& getName() const { return mName; } - const LLString& getZoning() const { return mZoning; } + void setRegionNameAndZone(const std::string& name_and_zone); + const std::string& getName() const { return mName; } + const std::string& getZoning() const { return mZoning; } void setOwner(const LLUUID& owner_id) { mOwnerID = owner_id; } const LLUUID& getOwner() const { return mOwnerID; } @@ -175,18 +175,18 @@ public: void setSimAccess(U8 sim_access) { mSimAccess = sim_access; } U8 getSimAccess() const { return mSimAccess; } - const char* getSimAccessString() const; + const std::string getSimAccessString() const; // Returns "Sandbox", "Expensive", etc. static std::string regionFlagsToString(U32 flags); // Returns "Mature", "PG", etc. - static const char* accessToString(U8 access); + static std::string accessToString(U8 sim_access); - static U8 stringToAccess(const char* access_str); + static U8 stringToAccess(const std::string& access_str); // Returns "M", "PG", etc. - static const char* accessToShortString(U8 access); /* Flawfinder: ignore */ + static std::string accessToShortString(U8 sim_access); // helper function which just makes sure all interested parties // can process the message. @@ -320,8 +320,8 @@ protected: F32 mTimeDilation; // time dilation of physics simulation on simulator // simulator name - LLString mName; - LLString mZoning; + std::string mName; + std::string mZoning; // region/estate owner - usually null. LLUUID mOwnerID; diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index ab0ef9df4a..b90f665abd 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -64,7 +64,7 @@ class StatAttributes { public: - StatAttributes(const char *name, + StatAttributes(const char* name, const BOOL enabled, const BOOL is_timer) : mName(name), @@ -73,9 +73,9 @@ public: { } - const char *mName; - const BOOL mEnabled; - const BOOL mIsTimer; + std::string mName; + BOOL mEnabled; + BOOL mIsTimer; }; const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] = @@ -331,17 +331,17 @@ void LLViewerStats::addToMessage(LLSD &body) const } // static -const char *LLViewerStats::statTypeToText(EStatType type) -{ - if (type >= 0 && type < ST_COUNT) - { - return STAT_INFO[type].mName; - } - else - { - return "Unknown statistic"; - } -} +// const std::string LLViewerStats::statTypeToText(EStatType type) +// { +// if (type >= 0 && type < ST_COUNT) +// { +// return STAT_INFO[type].mName; +// } +// else +// { +// return "Unknown statistic"; +// } +// } // *NOTE:Mani The following methods used to exist in viewer.cpp // Moving them here, but not merging them into LLViewerStats yet. @@ -679,7 +679,7 @@ void send_stats() // send fps only for time app spends in foreground agent["fps"] = (F32)gForegroundFrameCount / gForegroundTime.getElapsedTimeF32(); agent["version"] = gCurrentVersion; - LLString language(gSavedSettings.getString("Language")); + std::string language(gSavedSettings.getString("Language")); if(language == "default") language = gSavedSettings.getString("SystemLanguage"); agent["language"] = language; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index bd16e61149..ccd3110758 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -185,8 +185,6 @@ public: void addToMessage(LLSD &body) const; - static const char *statTypeToText(EStatType type); - private: F64 mStats[ST_COUNT]; diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index aba7d4dac4..0a11f79fd1 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -108,7 +108,7 @@ public: LLPreviewNotecard* preview; preview = new LLPreviewNotecard("preview notecard", rect, - LLString("Embedded Note: ") + item->getName(), + std::string("Embedded Note: ") + item->getName(), item->getUUID(), LLUUID::null, item->getAssetUUID(), @@ -561,10 +561,10 @@ struct LLNotecardCopyInfo // Member functions // -LLViewerTextEditor::LLViewerTextEditor(const LLString& name, +LLViewerTextEditor::LLViewerTextEditor(const std::string& name, const LLRect& rect, S32 max_length, - const LLString& default_text, + const std::string& default_text, const LLFontGL* font, BOOL allow_embedded_items) : LLTextEditor(name, rect, max_length, default_text, font, allow_embedded_items), @@ -581,7 +581,7 @@ LLViewerTextEditor::LLViewerTextEditor(const LLString& name, //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_slurl.xml", this); //if (!menu) //{ - // menu = new LLMenuGL(""); + // menu = new LLMenuGL(LLStringUtil::null); //} //menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); //// menu->setVisible(FALSE); @@ -608,7 +608,7 @@ void LLViewerTextEditor::makePristine() /////////////////////////////////////////////////////////////////// -BOOL LLViewerTextEditor::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) +BOOL LLViewerTextEditor::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen) { for (child_list_const_iter_t child_iter = getChildList()->begin(); child_iter != getChildList()->end(); ++child_iter) @@ -1068,7 +1068,7 @@ BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, - LLString& tooltip_msg) + std::string& tooltip_msg) { BOOL handled = FALSE; @@ -1084,7 +1084,7 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, if (drop) { LLInventoryItem *item = (LLInventoryItem *)cargo_data; - LLString name = item->getName(); + std::string name = item->getName(); appendText(name, true, true); } *accept = ACCEPT_YES_COPY_SINGLE; @@ -1165,7 +1165,7 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, return handled; } -void LLViewerTextEditor::setASCIIEmbeddedText(const LLString& instr) +void LLViewerTextEditor::setASCIIEmbeddedText(const std::string& instr) { LLWString wtext; const U8* buffer = (U8*)(instr.c_str()); @@ -1187,7 +1187,7 @@ void LLViewerTextEditor::setASCIIEmbeddedText(const LLString& instr) setWText(wtext); } -void LLViewerTextEditor::setEmbeddedText(const LLString& instr) +void LLViewerTextEditor::setEmbeddedText(const std::string& instr) { LLWString wtext = utf8str_to_wstring(instr); for (S32 i=0; i<(S32)wtext.size(); i++) @@ -1202,7 +1202,7 @@ void LLViewerTextEditor::setEmbeddedText(const LLString& instr) setWText(wtext); } -LLString LLViewerTextEditor::getEmbeddedText() +std::string LLViewerTextEditor::getEmbeddedText() { #if 1 // New version (Version 2) @@ -1218,12 +1218,12 @@ LLString LLViewerTextEditor::getEmbeddedText() } outtextw.push_back(wch); } - LLString outtext = wstring_to_utf8str(outtextw); + std::string outtext = wstring_to_utf8str(outtextw); return outtext; #else // Old version (Version 1) mEmbeddedItemList->copyUsedCharsToIndexed(); - LLString outtext; + std::string outtext; for (S32 i=0; i<(S32)mWText.size(); i++) { llwchar wch = mWText[i]; @@ -1242,7 +1242,7 @@ LLString LLViewerTextEditor::getEmbeddedText() #endif } -LLString LLViewerTextEditor::appendTime(bool prepend_newline) +std::string LLViewerTextEditor::appendTime(bool prepend_newline) { time_t utc_time; utc_time = time_corrected(); @@ -1254,7 +1254,7 @@ LLString LLViewerTextEditor::appendTime(bool prepend_newline) // it's daylight savings time there. timep = utc_to_pacific_time(utc_time, gPacificDaylightTime); - LLString text = llformat("[%d:%02d] ", timep->tm_hour, timep->tm_min); + std::string text = llformat("[%d:%02d] ", timep->tm_hour, timep->tm_min); appendColoredText(text, false, prepend_newline, LLColor4::grey); return text; @@ -1411,8 +1411,8 @@ void LLViewerTextEditor::openEmbeddedSound( LLInventoryItem* item ) void LLViewerTextEditor::openEmbeddedLandmark( LLInventoryItem* item ) { - LLString title = - LLString(" ") + LLLandmarkBridge::prefix() + item->getName(); + std::string title = + std::string(" ") + LLLandmarkBridge::prefix() + item->getName(); open_landmark((LLViewerInventoryItem*)item, title, FALSE, item->getUUID(), TRUE); } @@ -1519,13 +1519,13 @@ bool LLViewerTextEditor::hasEmbeddedInventory() //////////////////////////////////////////////////////////////////////////// -BOOL LLViewerTextEditor::importBuffer( const LLString& buffer ) +BOOL LLViewerTextEditor::importBuffer( const char* buffer, S32 length ) { - LLMemoryStream str((U8*)buffer.c_str(), buffer.length()); + LLMemoryStream str((U8*)buffer, length); return importStream(str); } -BOOL LLViewerTextEditor::exportBuffer( LLString& buffer ) +BOOL LLViewerTextEditor::exportBuffer( std::string& buffer ) { LLNotecard nc(LLNotecard::MAX_SIZE); @@ -1547,7 +1547,7 @@ BOOL LLViewerTextEditor::exportBuffer( LLString& buffer ) LLView* LLViewerTextEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { - LLString name("text_editor"); + std::string name("text_editor"); node->getAttributeString("name", name); LLRect rect; @@ -1561,8 +1561,8 @@ LLView* LLViewerTextEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlF LLFontGL* font = LLView::selectFont(node); - // LLString text = node->getValue(); - LLString text = node->getTextContents().substr(0, max_text_length - 1); + // std::string text = node->getValue(); + std::string text = node->getTextContents().substr(0, max_text_length - 1); if (text.size() > max_text_length) { @@ -1573,7 +1573,7 @@ LLView* LLViewerTextEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlF LLViewerTextEditor* text_editor = new LLViewerTextEditor(name, rect, max_text_length, - "", + LLStringUtil::null, font, allow_embedded_items); diff --git a/indra/newview/llviewertexteditor.h b/indra/newview/llviewertexteditor.h index 019375b010..7ce28fc60a 100644 --- a/indra/newview/llviewertexteditor.h +++ b/indra/newview/llviewertexteditor.h @@ -42,10 +42,10 @@ class LLViewerTextEditor : public LLTextEditor { public: - LLViewerTextEditor(const LLString& name, + LLViewerTextEditor(const std::string& name, const LLRect& rect, S32 max_length, - const LLString& default_text = LLString(), + const std::string& default_text = std::string(), const LLFontGL* glfont = NULL, BOOL allow_embedded_items = FALSE); @@ -62,28 +62,28 @@ public: virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask ); - virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); + virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, - void *cargo_data, EAcceptance *accept, LLString& tooltip_msg); + void *cargo_data, EAcceptance *accept, std::string& tooltip_msg); const class LLInventoryItem* getDragItem() const { return mDragItem; } - virtual BOOL importBuffer(const LLString& buffer); + virtual BOOL importBuffer(const char* buffer, S32 length); virtual bool importStream(std::istream& str); - virtual BOOL exportBuffer(LLString& buffer); + virtual BOOL exportBuffer(std::string& buffer); void setNotecardInfo(const LLUUID& notecard_item_id, const LLUUID& object_id) { mNotecardInventoryID = notecard_item_id; mObjectID = object_id; } - void setASCIIEmbeddedText(const LLString& instr); - void setEmbeddedText(const LLString& instr); - LLString getEmbeddedText(); + void setASCIIEmbeddedText(const std::string& instr); + void setEmbeddedText(const std::string& instr); + std::string getEmbeddedText(); // Appends Second Life time, small font, grey. // If this starts a line, you need to prepend a newline. - LLString appendTime(bool prepend_newline); + std::string appendTime(bool prepend_newline); void copyInventory(const LLInventoryItem* item, U32 callback_id = 0); diff --git a/indra/newview/llviewerthrottle.cpp b/indra/newview/llviewerthrottle.cpp index c23a74c533..28b3834de4 100644 --- a/indra/newview/llviewerthrottle.cpp +++ b/indra/newview/llviewerthrottle.cpp @@ -58,7 +58,7 @@ const F32 DYNAMIC_UPDATE_DURATION = 5.0f; // seconds LLViewerThrottle gViewerThrottle; // static -const char *LLViewerThrottle::sNames[TC_EOF] = { +const std:: string LLViewerThrottle::sNames[TC_EOF] = { "Resend", "Land", "Wind", diff --git a/indra/newview/llviewerthrottle.h b/indra/newview/llviewerthrottle.h index 4ef58083e5..19e9ce8e7a 100644 --- a/indra/newview/llviewerthrottle.h +++ b/indra/newview/llviewerthrottle.h @@ -77,7 +77,7 @@ public: LLViewerThrottleGroup getThrottleGroup(const F32 bandwidth_kbps); - static const char* sNames[TC_EOF]; /* Flawfinder: ignore */ + static const std::string sNames[TC_EOF]; protected: F32 mMaxBandwidth; F32 mCurrentBandwidth; diff --git a/indra/newview/llviewervisualparam.cpp b/indra/newview/llviewervisualparam.cpp index 3999eb0317..08bacab7c0 100644 --- a/indra/newview/llviewervisualparam.cpp +++ b/indra/newview/llviewervisualparam.cpp @@ -71,7 +71,7 @@ BOOL LLViewerVisualParamInfo::parseXml(LLXmlTreeNode *node) // VIEWER SPECIFIC PARAMS - LLString wearable; + std::string wearable; static LLStdStringHandle wearable_string = LLXmlTree::addAttributeString("wearable"); if( node->getFastAttributeString( wearable_string, wearable) ) { diff --git a/indra/newview/llviewervisualparam.h b/indra/newview/llviewervisualparam.h index b115fecc51..8dc4b16ac2 100644 --- a/indra/newview/llviewervisualparam.h +++ b/indra/newview/llviewervisualparam.h @@ -50,11 +50,11 @@ public: protected: S32 mWearableType; - LLString mEditGroup; + std::string mEditGroup; F32 mCamDist; F32 mCamAngle; // degrees F32 mCamElevation; - LLString mCamTargetName; + std::string mCamTargetName; F32 mEditGroupDisplayOrder; BOOL mShowSimple; // show edit controls when in "simple ui" mode? F32 mSimpleMin; // when in simple UI, apply this minimum, range 0.f to 100.f @@ -91,7 +91,7 @@ public: // interface methods F32 getDisplayOrder() { return getInfo()->mEditGroupDisplayOrder; } S32 getWearableType() const { return getInfo()->mWearableType; } - const LLString& getEditGroup() const { return getInfo()->mEditGroup; } + const std::string& getEditGroup() const { return getInfo()->mEditGroup; } F32 getCameraDistance() const { return getInfo()->mCamDist; } F32 getCameraAngle() const { return getInfo()->mCamAngle; } // degrees diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8f79253cf3..068f4c86e9 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -112,7 +112,6 @@ #include "llframestatview.h" #include "llgesturemgr.h" #include "llglheaders.h" -#include "llhippo.h" #include "llhoverview.h" #include "llhudmanager.h" #include "llhudview.h" @@ -289,10 +288,10 @@ static F32 temp2 = 20.f; LLCoordGL new_gl; #endif //SABINRIG -char LLViewerWindow::sSnapshotBaseName[LL_MAX_PATH]; -char LLViewerWindow::sSnapshotDir[LL_MAX_PATH]; +std::string LLViewerWindow::sSnapshotBaseName; +std::string LLViewerWindow::sSnapshotDir; -char LLViewerWindow::sMovieBaseName[LL_MAX_PATH]; +std::string LLViewerWindow::sMovieBaseName; extern void toggle_debug_menus(void*); @@ -665,7 +664,7 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask x = llround((F32)x / mDisplayScale.mV[VX]); y = llround((F32)y / mDisplayScale.mV[VY]); - LLView::sMouseHandlerMessage = ""; + LLView::sMouseHandlerMessage.clear(); if (gDebugClicks) { @@ -773,7 +772,7 @@ BOOL LLViewerWindow::handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK ma x = llround((F32)x / mDisplayScale.mV[VX]); y = llround((F32)y / mDisplayScale.mV[VY]); - LLView::sMouseHandlerMessage = ""; + LLView::sMouseHandlerMessage.clear(); if (gDebugClicks) { @@ -853,7 +852,7 @@ BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask) x = llround((F32)x / mDisplayScale.mV[VX]); y = llround((F32)y / mDisplayScale.mV[VY]); - LLView::sMouseHandlerMessage = ""; + LLView::sMouseHandlerMessage.clear(); if (gDebugClicks) { @@ -944,7 +943,7 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK x = llround((F32)x / mDisplayScale.mV[VX]); y = llround((F32)y / mDisplayScale.mV[VY]); - LLView::sMouseHandlerMessage = ""; + LLView::sMouseHandlerMessage.clear(); if (gDebugClicks) { @@ -1051,7 +1050,7 @@ BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK m x = llround((F32)x / mDisplayScale.mV[VX]); y = llround((F32)y / mDisplayScale.mV[VY]); - LLView::sMouseHandlerMessage = ""; + LLView::sMouseHandlerMessage.clear(); // Don't care about caps lock for mouse events. if (gDebugClicks) @@ -1406,24 +1405,23 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S //SetBKColor(hdc, RGB(255, 255, 255)); FillRect(hdc, &wnd_rect, CreateSolidBrush(RGB(255, 255, 255))); - LLString name_str; + std::string name_str; gAgent.getName(name_str); - S32 len; - char temp_str[255]; /* Flawfinder: ignore */ - snprintf(temp_str, sizeof(temp_str), "%s FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */ + std::string temp_str; + temp_str = llformat( "%s FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */ name_str.c_str(), LLViewerStats::getInstance()->mFPSStat.getMeanPerSec(), LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0), LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0)); - len = strlen(temp_str); /* Flawfinder: ignore */ - TextOutA(hdc, 0, 0, temp_str, len); + S32 len = temp_str.length(); + TextOutA(hdc, 0, 0, temp_str.c_str(), len); LLVector3d pos_global = gAgent.getPositionGlobal(); - snprintf(temp_str, sizeof(temp_str), "Avatar pos %6.1lf %6.1lf %6.1lf", pos_global.mdV[0], pos_global.mdV[1], pos_global.mdV[2]); /* Flawfinder: ignore */ - len = strlen(temp_str); /* Flawfinder: ignore */ - TextOutA(hdc, 0, 25, temp_str, len); + temp_str = llformat( "Avatar pos %6.1lf %6.1lf %6.1lf", pos_global.mdV[0], pos_global.mdV[1], pos_global.mdV[2]); + len = temp_str.length(); + TextOutA(hdc, 0, 25, temp_str.c_str(), len); TextOutA(hdc, 0, 50, "Set \"DisableRendering FALSE\" in settings.ini file to reenable", 61); EndPaint(window_handle, &ps); @@ -1492,7 +1490,7 @@ BOOL LLViewerWindow::handleDeviceChange(LLWindow *window) // Classes // LLViewerWindow::LLViewerWindow( - const char* title, const char* name, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, BOOL fullscreen, BOOL ignore_pixel_depth) @@ -1515,9 +1513,9 @@ LLViewerWindow::LLViewerWindow( mIgnoreActivate( FALSE ) { // Default to application directory. - strcpy(LLViewerWindow::sSnapshotBaseName, "Snapshot"); /* Flawfinder: ignore */ - strcpy(LLViewerWindow::sMovieBaseName, "SLmovie"); /* Flawfinder: ignore */ - LLViewerWindow::sSnapshotDir[0] = '\0'; + LLViewerWindow::sSnapshotBaseName = "Snapshot"; + LLViewerWindow::sMovieBaseName = "SLmovie"; + LLViewerWindow::sSnapshotDir.clear(); // create window @@ -1626,7 +1624,7 @@ LLViewerWindow::LLViewerWindow( gShowOverlayTitle = gSavedSettings.getBOOL("ShowOverlayTitle"); mOverlayTitle = gSavedSettings.getString("OverlayTitle"); // Can't have spaces in settings.ini strings, so use underscores instead and convert them. - LLString::replaceChar(mOverlayTitle, '_', ' '); + LLStringUtil::replaceChar(mOverlayTitle, '_', ' '); LLAlertDialog::setDisplayCallback(alertCallback); // call this before calling any modal dialogs @@ -1757,7 +1755,7 @@ void LLViewerWindow::initBase() mRootView->addChild(gNotifyBoxView, -2); // Tooltips go above floaters - mToolTip = new LLTextBox( "tool tip", LLRect(0, 1, 1, 0 ) ); + mToolTip = new LLTextBox( std::string("tool tip"), LLRect(0, 1, 1, 0 ) ); mToolTip->setHPad( 4 ); mToolTip->setVPad( 2 ); mToolTip->setColor( gColors.getColor( "ToolTipTextColor" ) ); @@ -1770,14 +1768,14 @@ void LLViewerWindow::initBase() mToolTip->setVisible( FALSE ); // Add the progress bar view (startup view), which overrides everything - mProgressView = new LLProgressView("ProgressView", full_window); + mProgressView = new LLProgressView(std::string("ProgressView"), full_window); mRootView->addChild(mProgressView); setShowProgress(FALSE); - setProgressCancelButtonVisible(FALSE, ""); + setProgressCancelButtonVisible(FALSE); } -void adjust_rect_top_left(const LLString& control, const LLRect& window) +void adjust_rect_top_left(const std::string& control, const LLRect& window) { LLRect r = gSavedSettings.getRect(control); if (r.mLeft == 0 && r.mBottom == 0) @@ -1787,7 +1785,7 @@ void adjust_rect_top_left(const LLString& control, const LLRect& window) } } -void adjust_rect_top_center(const LLString& control, const LLRect& window) +void adjust_rect_top_center(const std::string& control, const LLRect& window) { LLRect r = gSavedSettings.getRect(control); if (r.mLeft == 0 && r.mBottom == 0) @@ -1800,7 +1798,7 @@ void adjust_rect_top_center(const LLString& control, const LLRect& window) } } -void adjust_rect_top_right(const LLString& control, const LLRect& window) +void adjust_rect_top_right(const std::string& control, const LLRect& window) { LLRect r = gSavedSettings.getRect(control); if (r.mLeft == 0 && r.mBottom == 0) @@ -1813,7 +1811,7 @@ void adjust_rect_top_right(const LLString& control, const LLRect& window) } } -void adjust_rect_bottom_center(const LLString& control, const LLRect& window) +void adjust_rect_bottom_center(const std::string& control, const LLRect& window) { LLRect r = gSavedSettings.getRect(control); if (r.mLeft == 0 && r.mBottom == 0) @@ -1829,7 +1827,7 @@ void adjust_rect_bottom_center(const LLString& control, const LLRect& window) } } -void adjust_rect_centered_partial_zoom(const LLString& control, +void adjust_rect_centered_partial_zoom(const std::string& control, const LLRect& window) { LLRect rect = gSavedSettings.getRect(control); @@ -1905,7 +1903,7 @@ void LLViewerWindow::initWorldUI() mRootView->addChild(gBottomPanel); // View for hover information - gHoverView = new LLHoverView("gHoverView", full_window); + gHoverView = new LLHoverView(std::string("gHoverView"), full_window); gHoverView->setVisible(TRUE); mRootView->addChild(gHoverView); @@ -1913,7 +1911,7 @@ void LLViewerWindow::initWorldUI() // Map // // TODO: Move instance management into class - gFloaterMap = new LLFloaterMap("Map"); + gFloaterMap = new LLFloaterMap(std::string("Map")); gFloaterMap->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); // keep onscreen @@ -1929,7 +1927,7 @@ void LLViewerWindow::initWorldUI() LLRect morph_view_rect = full_window; morph_view_rect.stretch( -STATUS_BAR_HEIGHT ); morph_view_rect.mTop = full_window.mTop - 32; - gMorphView = new LLMorphView("gMorphView", morph_view_rect ); + gMorphView = new LLMorphView(std::string("gMorphView"), morph_view_rect ); mRootView->addChild(gMorphView); gMorphView->setVisible(FALSE); @@ -1956,7 +1954,7 @@ void LLViewerWindow::initWorldUI() S32 menu_bar_height = gMenuBarView->getRect().getHeight(); LLRect root_rect = getRootView()->getRect(); LLRect status_rect(0, root_rect.getHeight(), root_rect.getWidth(), root_rect.getHeight() - menu_bar_height); - gStatusBar = new LLStatusBar("status", status_rect); + gStatusBar = new LLStatusBar(std::string("status"), status_rect); gStatusBar->setFollows(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_TOP); gStatusBar->reshape(root_rect.getWidth(), gStatusBar->getRect().getHeight(), TRUE); @@ -2211,7 +2209,7 @@ void LLViewerWindow::setNormalControlsVisible( BOOL visible ) void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; LLColor4 new_bg_color; if(god_mode && LLViewerLogin::getInstance()->isInProductionGrid()) @@ -2283,7 +2281,7 @@ void LLViewerWindow::draw() if (gSavedSettings.getBOOL("DisplayTimecode")) { // draw timecode block - char text[256]; /* Flawfinder: ignore */ + std::string text; glLoadIdentity(); @@ -2457,15 +2455,6 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) } } - // Example "bug" for bug reporter web page - if ((MASK_SHIFT & mask) - && (MASK_ALT & mask) - && (MASK_CONTROL & mask) - && ('H' == key || 'h' == key)) - { - trigger_hippo_bug(NULL); - } - // handle escape key if (key == KEY_ESCAPE && mask == MASK_NONE) { @@ -2663,7 +2652,7 @@ BOOL LLViewerWindow::handleUnicodeChar(llwchar uni_char, MASK mask) void LLViewerWindow::handleScrollWheel(S32 clicks) { - LLView::sMouseHandlerMessage = ""; + LLView::sMouseHandlerMessage.clear(); gMouseIdleTimer.reset(); @@ -2739,7 +2728,7 @@ BOOL LLViewerWindow::handlePerFrameHover() { static std::string last_handle_msg; - LLView::sMouseHandlerMessage = ""; + LLView::sMouseHandlerMessage.clear(); //RN: fix for asynchronous notification of mouse leaving window not working LLCoordWindow mouse_pos; @@ -2880,9 +2869,9 @@ BOOL LLViewerWindow::handlePerFrameHover() } else if (LLView::sDebugMouseHandling) { - if (last_handle_msg != "") + if (last_handle_msg != LLStringUtil::null) { - last_handle_msg = ""; + last_handle_msg.clear(); llinfos << "Hover not handled by view" << llendl; } } @@ -2927,7 +2916,7 @@ BOOL LLViewerWindow::handlePerFrameHover() //llinfos << (mToolTipBlocked ? "BLOCKED" : "NOT BLOCKED") << llendl; // Show a new tool tip (or update one that is alrady shown) BOOL tool_tip_handled = FALSE; - LLString tool_tip_msg; + std::string tool_tip_msg; F32 tooltip_delay = gSavedSettings.getF32( "ToolTipDelay" ); //HACK: hack for tool-based tooltips which need to pop up more quickly //Also for show xui names as tooltips debug mode @@ -4060,14 +4049,14 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d } // Saves an image to the harddrive as "SnapshotX" where X >= 1. -BOOL LLViewerWindow::saveImageNumbered(LLImageRaw *raw, const LLString& extension_in) +BOOL LLViewerWindow::saveImageNumbered(LLImageRaw *raw, const std::string& extension_in) { if (! raw) { return FALSE; } - LLString extension(extension_in); + std::string extension(extension_in); if (extension.empty()) { extension = (gSavedSettings.getBOOL("CompressSnapshotsToDisk")) ? ".j2c" : ".bmp"; @@ -4084,75 +4073,41 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageRaw *raw, const LLString& extensio pick_type = LLFilePicker::FFSAVE_ALL; // ??? // Get a directory if this is the first time. - if (strlen(sSnapshotDir) == 0) /* Flawfinder: ignore */ + if (sSnapshotDir.empty()) { - LLString proposed_name( sSnapshotBaseName ); + std::string proposed_name( sSnapshotBaseName ); proposed_name.append( extension ); // pick a directory in which to save LLFilePicker& picker = LLFilePicker::instance(); - if (!picker.getSaveFile(pick_type, proposed_name.c_str())) + if (!picker.getSaveFile(pick_type, proposed_name)) { // Clicked cancel return FALSE; } // Copy the directory + file name - char directory[LL_MAX_PATH]; /* Flawfinder: ignore */ - strncpy(directory, picker.getFirstFile(), LL_MAX_PATH -1); /* Flawfinder: ignore */ - directory[LL_MAX_PATH -1] = '\0'; - - // Smash the file extension - S32 length = strlen(directory); /* Flawfinder: ignore */ - S32 index = length; + std::string filepath = picker.getFirstFile(); - // Back up over extension - index -= extension.length(); - if (index >= 0 && directory[index] == '.') - { - directory[index] = '\0'; - } - else - { - index = length; - } - - // Find trailing backslash - while (index >= 0 && directory[index] != gDirUtilp->getDirDelimiter()[0]) - { - index--; - } - - // If we found one, truncate the string there - if (index >= 0) - { - if (index + 1 <= length) - { - strncpy(LLViewerWindow::sSnapshotBaseName, directory + index + 1, LL_MAX_PATH -1); /* Flawfinder: ignore */ - LLViewerWindow::sSnapshotBaseName[LL_MAX_PATH -1] = '\0'; - } - - index++; - directory[index] = '\0'; - strncpy(LLViewerWindow::sSnapshotDir, directory, LL_MAX_PATH -1); /* Flawfinder: ignore */ - LLViewerWindow::sSnapshotDir[LL_MAX_PATH -1] = '\0'; - } + LLViewerWindow::sSnapshotBaseName = gDirUtilp->getBaseFileName(filepath, true); + LLViewerWindow::sSnapshotDir = gDirUtilp->getDirName(filepath); } // Look for an unused file name - LLString filepath; + std::string filepath; S32 i = 1; S32 err = 0; do { filepath = sSnapshotDir; + filepath += gDirUtilp->getDirDelimiter(); filepath += sSnapshotBaseName; filepath += llformat("_%.3d",i); filepath += extension; - struct stat stat_info; - err = mWindow->stat( filepath.c_str(), &stat_info ); + llstat stat_info; + err = LLFile::stat( filepath, &stat_info ); i++; } while( -1 != err ); // search until the file is not found (i.e., stat() gives an error). @@ -4207,7 +4162,7 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height) } } -BOOL LLViewerWindow::saveSnapshot( const LLString& filepath, S32 image_width, S32 image_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) +BOOL LLViewerWindow::saveSnapshot( const std::string& filepath, S32 image_width, S32 image_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) { llinfos << "Saving snapshot to: " << filepath << llendl; @@ -4657,7 +4612,7 @@ void LLViewerWindow::destroyWindow() void LLViewerWindow::drawMouselookInstructions() { // Draw instructions for mouselook ("Press ESC to leave Mouselook" in a box at the top of the screen.) - const char* instructions = "Press ESC to leave Mouselook."; + const std::string instructions = "Press ESC to leave Mouselook."; const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ); const S32 INSTRUCTIONS_PAD = 5; @@ -4816,7 +4771,7 @@ void LLViewerWindow::moveProgressViewToFront() } } -void LLViewerWindow::setProgressString(const LLString& string) +void LLViewerWindow::setProgressString(const std::string& string) { if (mProgressView) { @@ -4824,7 +4779,7 @@ void LLViewerWindow::setProgressString(const LLString& string) } } -void LLViewerWindow::setProgressMessage(const LLString& msg) +void LLViewerWindow::setProgressMessage(const std::string& msg) { if(mProgressView) { @@ -4840,7 +4795,7 @@ void LLViewerWindow::setProgressPercent(const F32 percent) } } -void LLViewerWindow::setProgressCancelButtonVisible( BOOL b, const LLString& label ) +void LLViewerWindow::setProgressCancelButtonVisible( BOOL b, const std::string& label ) { if (mProgressView) { @@ -4908,7 +4863,7 @@ void LLViewerWindow::stopGL(BOOL save_state) } } -void LLViewerWindow::restoreGL(const LLString& progress_message) +void LLViewerWindow::restoreGL(const std::string& progress_message) { if (gGLManager.mIsDisabled) { @@ -5146,7 +5101,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, if (!result_first_try) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[RESX]"] = llformat("%d",size.mX); args["[RESY]"] = llformat("%d",size.mY); alertXml("ResolutionSwitchFail", args); @@ -5319,11 +5274,11 @@ bool LLViewerWindow::alertCallback(S32 modal) LLAlertDialog* LLViewerWindow::alertXml(const std::string& xml_filename, LLAlertDialog::alert_callback_t callback, void* user_data) { - LLString::format_map_t args; + LLStringUtil::format_map_t args; return alertXml( xml_filename, args, callback, user_data ); } -LLAlertDialog* LLViewerWindow::alertXml(const std::string& xml_filename, const LLString::format_map_t& args, +LLAlertDialog* LLViewerWindow::alertXml(const std::string& xml_filename, const LLStringUtil::format_map_t& args, LLAlertDialog::alert_callback_t callback, void* user_data) { if (gNoRender) @@ -5347,10 +5302,10 @@ LLAlertDialog* LLViewerWindow::alertXml(const std::string& xml_filename, const L return LLAlertDialog::showXml( xml_filename, args, callback, user_data ); } -LLAlertDialog* LLViewerWindow::alertXmlEditText(const std::string& xml_filename, const LLString::format_map_t& args, +LLAlertDialog* LLViewerWindow::alertXmlEditText(const std::string& xml_filename, const LLStringUtil::format_map_t& args, LLAlertDialog::alert_callback_t callback, void* user_data, LLAlertDialog::alert_text_callback_t text_callback, void *text_data, - const LLString::format_map_t& edit_args, BOOL draw_asterixes) + const LLStringUtil::format_map_t& edit_args, BOOL draw_asterixes) { if (gNoRender) { @@ -5387,7 +5342,7 @@ LLAlertDialog* LLViewerWindow::alertXmlEditText(const std::string& xml_filename, //////////////////////////////////////////////////////////////////////////// LLBottomPanel::LLBottomPanel(const LLRect &rect) : - LLPanel("", rect, FALSE), + LLPanel(LLStringUtil::null, rect, FALSE), mIndicator(NULL) { // bottom panel is focus root, so Tab moves through the toolbar and button bar, and overlay diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 78afaf6cdf..997ac21dfd 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -68,7 +68,7 @@ public: // // CREATORS // - LLViewerWindow(const char* title, const char* name, S32 x, S32 y, S32 width, S32 height, BOOL fullscreen, BOOL ignore_pixel_depth); + LLViewerWindow(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, BOOL fullscreen, BOOL ignore_pixel_depth); virtual ~LLViewerWindow(); void initGLDefaults(); @@ -162,7 +162,7 @@ public: // The 'target' is where the user wants the window to be. It may not be // there yet, because we may be supressing fullscreen prior to login. - const LLString& getInitAlert() { return mInitAlert; } + const std::string& getInitAlert() { return mInitAlert; } // // MANIPULATORS @@ -177,10 +177,10 @@ public: void setShowProgress(const BOOL show); BOOL getShowProgress() const; void moveProgressViewToFront(); - void setProgressString(const LLString& string); + void setProgressString(const std::string& string); void setProgressPercent(const F32 percent); - void setProgressMessage(const LLString& msg); - void setProgressCancelButtonVisible( BOOL b, const LLString& label ); + void setProgressMessage(const std::string& msg); + void setProgressCancelButtonVisible( BOOL b, const std::string& label = LLStringUtil::null ); LLProgressView *getProgressView() const; void updateObjectUnderCursor(); @@ -226,11 +226,11 @@ public: SNAPSHOT_TYPE_OBJECT_ID } ESnapshotType; - BOOL saveSnapshot(const LLString& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR); + BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR); BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR, S32 max_size = MAX_IMAGE_SIZE ); BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) ; - BOOL saveImageNumbered(LLImageRaw *raw, const LLString& extension = LLString()); + BOOL saveImageNumbered(LLImageRaw *raw, const std::string& extension = std::string()); void playSnapshotAnimAndSound(); @@ -278,12 +278,12 @@ public: LLAlertDialog* alertXml(const std::string& xml_filename, LLAlertDialog::alert_callback_t callback = NULL, void* user_data = NULL); - LLAlertDialog* alertXml(const std::string& xml_filename, const LLString::format_map_t& args, + LLAlertDialog* alertXml(const std::string& xml_filename, const LLStringUtil::format_map_t& args, LLAlertDialog::alert_callback_t callback = NULL, void* user_data = NULL); - LLAlertDialog* alertXmlEditText(const std::string& xml_filename, const LLString::format_map_t& args, + LLAlertDialog* alertXmlEditText(const std::string& xml_filename, const LLStringUtil::format_map_t& args, LLAlertDialog::alert_callback_t callback, void* user_data, LLAlertDialog::alert_text_callback_t text_callback, void *text_data, - const LLString::format_map_t& edit_args = LLString::format_map_t(), + const LLStringUtil::format_map_t& edit_args = LLStringUtil::format_map_t(), BOOL draw_asterixes = FALSE); static bool alertCallback(S32 modal); @@ -298,7 +298,7 @@ private: void destroyWindow(); void drawMouselookInstructions(); void stopGL(BOOL save_state = TRUE); - void restoreGL(const LLString& progress_message = LLString::null); + void restoreGL(const std::string& progress_message = LLStringUtil::null); void initFonts(F32 zoom_factor = 1.f); void analyzeHit( @@ -354,20 +354,20 @@ protected: BOOL mPickPending; void (*mPickCallback)(S32 x, S32 y, MASK mask); - LLString mOverlayTitle; // Used for special titles such as "Second Life - Special E3 2003 Beta" + std::string mOverlayTitle; // Used for special titles such as "Second Life - Special E3 2003 Beta" BOOL mIgnoreActivate; U8* mPickBuffer; - LLString mInitAlert; // Window / GL initialization requires an alert + std::string mInitAlert; // Window / GL initialization requires an alert class LLDebugText* mDebugText; // Internal class for debug text protected: - static char sSnapshotBaseName[LL_MAX_PATH]; /* Flawfinder: ignore */ - static char sSnapshotDir[LL_MAX_PATH]; /* Flawfinder: ignore */ + static std::string sSnapshotBaseName; + static std::string sSnapshotDir; - static char sMovieBaseName[LL_MAX_PATH]; /* Flawfinder: ignore */ + static std::string sMovieBaseName; }; class LLBottomPanel : public LLPanel @@ -391,7 +391,7 @@ void toggle_flying(void*); void toggle_first_person(); void toggle_build(void*); void reset_viewer_state_on_sim(void); -void update_saved_window_size(const LLString& control,S32 delta_width, S32 delta_height); +void update_saved_window_size(const std::string& control,S32 delta_width, S32 delta_height); // // Constants // diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 2e001a50c7..4b7ad71e80 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -718,8 +718,6 @@ LLVOAvatar::LLVOAvatar( mSpeed = 0.f; setAnimationData("Speed", &mSpeed); - strcpy(mAvatarDefinition, AVATAR_DEFAULT_CHAR); /* Flawfinder: ignore */ - if (id == gAgentID) { mIsSelf = TRUE; @@ -1358,9 +1356,9 @@ void LLVOAvatar::initClass() { LLVOAvatar::sMaxOtherAvatarsToComposite = gSavedSettings.getS32("AvatarCompositeLimit"); - char xmlFile[MAX_PATH]; /* Flawfinder: ignore */ + std::string xmlFile; - snprintf(xmlFile, MAX_PATH, "%s_lad.xml", gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,AVATAR_DEFAULT_CHAR).c_str()); /* Flawfinder: ignore */ + xmlFile = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,AVATAR_DEFAULT_CHAR) + "_lad.xml"; BOOL success = sXMLTree.parseFile( xmlFile, FALSE ); if (!success) { @@ -1383,7 +1381,7 @@ void LLVOAvatar::initClass() llerrs << "Invalid avatar file header: " << xmlFile << llendl; } - LLString version; + std::string version; static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version"); if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") ) { @@ -1395,7 +1393,7 @@ void LLVOAvatar::initClass() root->getFastAttributeS32( wearable_definition_version_string, wearable_def_version ); LLWearable::setCurrentDefinitionVersion( wearable_def_version ); - LLString mesh_file_name; + std::string mesh_file_name; LLXmlTreeNode* skeleton_node = root->getChildByName( "skeleton" ); if (!skeleton_node) @@ -1404,7 +1402,7 @@ void LLVOAvatar::initClass() return; } - LLString skeleton_file_name; + std::string skeleton_file_name; static LLStdStringHandle file_name_string = LLXmlTree::addAttributeString("file_name"); if (!skeleton_node->getFastAttributeString(file_name_string, skeleton_file_name)) { @@ -1569,7 +1567,7 @@ void LLVOAvatar::getSpatialExtents(LLVector3& newMin, LLVector3& newMax) //----------------------------------------------------------------------------- // parseSkeletonFile() //----------------------------------------------------------------------------- -BOOL LLVOAvatar::parseSkeletonFile(const LLString& filename) +BOOL LLVOAvatar::parseSkeletonFile(const std::string& filename) { LLMemType mt(LLMemType::MTYPE_AVATAR); @@ -1596,7 +1594,7 @@ BOOL LLVOAvatar::parseSkeletonFile(const LLString& filename) llerrs << "Invalid avatar skeleton file header: " << filename << llendl; } - LLString version; + std::string version; static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version"); if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") ) { @@ -1815,7 +1813,6 @@ void LLVOAvatar::buildCharacter() if ( mIsSelf ) { llerrs << "Unable to load user's avatar" << llendl; - //set_avatar_character( &LLString(AVATAR_DEFAULT_CHAR)); } else { @@ -1925,23 +1922,24 @@ void LLVOAvatar::buildCharacter() //------------------------------------------------------------------------- if (mIsSelf) { + // *TODO: Translate gAttachBodyPartPieMenus[0] = NULL; - gAttachBodyPartPieMenus[1] = new LLPieMenu("Right Arm >"); - gAttachBodyPartPieMenus[2] = new LLPieMenu("Head >"); - gAttachBodyPartPieMenus[3] = new LLPieMenu("Left Arm >"); + gAttachBodyPartPieMenus[1] = new LLPieMenu(std::string("Right Arm >")); + gAttachBodyPartPieMenus[2] = new LLPieMenu(std::string("Head >")); + gAttachBodyPartPieMenus[3] = new LLPieMenu(std::string("Left Arm >")); gAttachBodyPartPieMenus[4] = NULL; - gAttachBodyPartPieMenus[5] = new LLPieMenu("Left Leg >"); - gAttachBodyPartPieMenus[6] = new LLPieMenu("Torso >"); - gAttachBodyPartPieMenus[7] = new LLPieMenu("Right Leg >"); + gAttachBodyPartPieMenus[5] = new LLPieMenu(std::string("Left Leg >")); + gAttachBodyPartPieMenus[6] = new LLPieMenu(std::string("Torso >")); + gAttachBodyPartPieMenus[7] = new LLPieMenu(std::string("Right Leg >")); gDetachBodyPartPieMenus[0] = NULL; - gDetachBodyPartPieMenus[1] = new LLPieMenu("Right Arm >"); - gDetachBodyPartPieMenus[2] = new LLPieMenu("Head >"); - gDetachBodyPartPieMenus[3] = new LLPieMenu("Left Arm >"); + gDetachBodyPartPieMenus[1] = new LLPieMenu(std::string("Right Arm >")); + gDetachBodyPartPieMenus[2] = new LLPieMenu(std::string("Head >")); + gDetachBodyPartPieMenus[3] = new LLPieMenu(std::string("Left Arm >")); gDetachBodyPartPieMenus[4] = NULL; - gDetachBodyPartPieMenus[5] = new LLPieMenu("Left Leg >"); - gDetachBodyPartPieMenus[6] = new LLPieMenu("Torso >"); - gDetachBodyPartPieMenus[7] = new LLPieMenu("Right Leg >"); + gDetachBodyPartPieMenus[5] = new LLPieMenu(std::string("Left Leg >")); + gDetachBodyPartPieMenus[6] = new LLPieMenu(std::string("Torso >")); + gDetachBodyPartPieMenus[7] = new LLPieMenu(std::string("Right Leg >")); for (S32 i = 0; i < 8; i++) { @@ -2510,7 +2508,7 @@ void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled) { if ( mCurrentGesticulationLevel != VOICE_GESTICULATION_LEVEL_OFF ) { - LLString gestureString = "unInitialized"; + std::string gestureString = "unInitialized"; if ( mCurrentGesticulationLevel == 0 ) { gestureString = "/voicelevel1"; } else if ( mCurrentGesticulationLevel == 1 ) { gestureString = "/voicelevel2"; } else if ( mCurrentGesticulationLevel == 2 ) { gestureString = "/voicelevel3"; } @@ -4405,7 +4403,7 @@ void LLVOAvatar::updateTextures(LLAgent &agent) { llwarns << "LLVOAvatar::updateTextures No host for texture " << imagep->getID() << " for avatar " - << (mIsSelf ? "<myself>" : getID().asString().c_str()) + << (mIsSelf ? "<myself>" : getID().asString()) << " on host " << getRegion()->getHost() << llendl; } @@ -5487,7 +5485,7 @@ BOOL LLVOAvatar::loadMeshNodes() iter != sAvatarInfo->mMeshInfoList.end(); iter++) { LLVOAvatarInfo::LLVOAvatarMeshInfo *info = *iter; - LLString &type = info->mType; + std::string &type = info->mType; S32 lod = info->mLOD; LLViewerJointMesh* mesh = NULL; @@ -5687,7 +5685,7 @@ BOOL LLVOAvatar::loadMeshNodes() } // Multimap insert - mMeshes.insert(std::pair<LLString, LLPolyMesh*>(info->mMeshFileName, poly_mesh)); + mMeshes.insert(std::make_pair(info->mMeshFileName, poly_mesh)); mesh->setMesh( poly_mesh ); @@ -6402,7 +6400,7 @@ LLViewerObject* LLVOAvatar::getWornAttachment( const LLUUID& inv_item_id ) return NULL; } -const LLString LLVOAvatar::getAttachedPointName(const LLUUID& inv_item_id) +const std::string LLVOAvatar::getAttachedPointName(const LLUUID& inv_item_id) { for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ) @@ -6411,11 +6409,11 @@ const LLString LLVOAvatar::getAttachedPointName(const LLUUID& inv_item_id) LLViewerJointAttachment* attachment = curiter->second; if( attachment->getItemID() == inv_item_id ) { - return (LLString)attachment->getName(); + return attachment->getName(); } } - return LLString::null; + return LLStringUtil::null; } @@ -6499,7 +6497,7 @@ void LLVOAvatar::updateComposites() } } -LLColor4 LLVOAvatar::getGlobalColor( const LLString& color_name ) +LLColor4 LLVOAvatar::getGlobalColor( const std::string& color_name ) { if( color_name=="skin_color" && mTexSkinColor ) { @@ -8008,7 +8006,7 @@ LLColor4 LLVOAvatar::getClothesColor( ETextureIndex te ) -void LLVOAvatar::dumpAvatarTEs( const char* context ) +void LLVOAvatar::dumpAvatarTEs( const std::string& context ) { llinfos << (mIsSelf ? "Self: " : "Other: ") << context << llendl; for( S32 i=0; i<TEX_NUM_ENTRIES; i++ ) @@ -8826,8 +8824,8 @@ void LLVOAvatar::dumpArchetypeXML( void* ) // only body parts, not clothing. for( S32 type = WT_SHAPE; type <= WT_EYES; type++ ) { - const char* wearable_name = LLWearable::typeToTypeName( (EWearableType) type ); - apr_file_printf( file, "\n\t\t<!-- wearable: %s -->\n", wearable_name ); + const std::string& wearable_name = LLWearable::typeToTypeName( (EWearableType) type ); + apr_file_printf( file, "\n\t\t<!-- wearable: %s -->\n", wearable_name.c_str() ); for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) { @@ -8847,9 +8845,9 @@ void LLVOAvatar::dumpArchetypeXML( void* ) LLViewerImage* te_image = avatar->getTEImage( te ); if( te_image ) { - char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string uuid_str; te_image->getID().toString( uuid_str ); - apr_file_printf( file, "\t\t<texture te=\"%i\" uuid=\"%s\"/>\n", te, uuid_str); + apr_file_printf( file, "\t\t<texture te=\"%i\" uuid=\"%s\"/>\n", te, uuid_str.c_str()); } } } @@ -9480,7 +9478,7 @@ BOOL LLVOAvatarInfo::parseXmlColorNodes(LLXmlTreeNode* root) color_node; color_node = root->getNextNamedChild()) { - LLString global_color_name; + std::string global_color_name; static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); if (color_node->getFastAttributeString( name_string, global_color_name ) ) { @@ -9620,9 +9618,9 @@ void LLVOAvatar::updateRegion(LLViewerRegion *regionp) } } -LLString LLVOAvatar::getFullname() const +std::string LLVOAvatar::getFullname() const { - LLString name; + std::string name; LLNameValue* first = getNVPair("FirstName"); LLNameValue* last = getNVPair("LastName"); diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index d958c40eb2..b991ae305e 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -128,7 +128,7 @@ public: BOOL parseXml(LLXmlTreeNode* node); protected: - LLString mName; + std::string mName; BOOL mIsJoint; LLVector3 mPos; LLVector3 mRot; @@ -194,10 +194,10 @@ protected: mPolyMorphTargetInfoList.clear(); } - LLString mType; + std::string mType; S32 mLOD; - LLString mMeshFileName; - LLString mReferenceMeshName; + std::string mMeshFileName; + std::string mReferenceMeshName; F32 mMinPixelArea; morph_info_list_t mPolyMorphTargetInfoList; }; @@ -212,8 +212,8 @@ protected: LLVOAvatarAttachmentInfo() : mGroup(-1), mAttachmentID(-1), mPieMenuSlice(-1), mVisibleFirstPerson(FALSE), mIsHUDAttachment(FALSE), mHasPosition(FALSE), mHasRotation(FALSE) {} - LLString mName; - LLString mJointName; + std::string mName; + std::string mJointName; LLVector3 mPosition; LLVector3 mRotationEuler; S32 mGroup; @@ -277,7 +277,7 @@ public: //-------------------------------------------------------------------- static void initClass(); // Initialize data that's only inited once per class. static void cleanupClass(); // Cleanup data that's only inited once per class. - static BOOL parseSkeletonFile(const LLString& filename); + static BOOL parseSkeletonFile(const std::string& filename); virtual U32 processUpdateMessage( LLMessageSystem *mesgsys, void **user_data, U32 block_num, @@ -454,7 +454,7 @@ public: void stopTyping() { mTyping = FALSE; } // Returns "FirstName LastName" - LLString getFullname() const; + std::string getFullname() const; //-------------------------------------------------------------------- // internal (pseudo-private) functions @@ -510,7 +510,7 @@ public: BOOL isWearingAttachment( const LLUUID& inv_item_id ); LLViewerObject* getWornAttachment( const LLUUID& inv_item_id ); - const LLString getAttachedPointName(const LLUUID& inv_item_id); + const std::string getAttachedPointName(const LLUUID& inv_item_id); static LLVOAvatar* findAvatarFromAttachment( LLViewerObject* obj ); @@ -541,7 +541,7 @@ public: //-------------------------------------------------------------------- // texture compositing (used only by the LLTexLayer series of classes) //-------------------------------------------------------------------- - LLColor4 getGlobalColor( const LLString& color_name ); + LLColor4 getGlobalColor( const std::string& color_name ); BOOL isLocalTextureDataAvailable( LLTexLayerSet* layerset ); BOOL isLocalTextureDataFinal( LLTexLayerSet* layerset ); ETextureIndex getBakedTE( LLTexLayerSet* layerset ); @@ -602,11 +602,6 @@ public: BOOL mIsBuilt; //-------------------------------------------------------------------- - // avatar definition name - //-------------------------------------------------------------------- - char mAvatarDefinition[64]; /* Flawfinder: ignore */ - - //-------------------------------------------------------------------- // skeleton for skinned avatar //-------------------------------------------------------------------- S32 mNumJoints; @@ -694,7 +689,7 @@ public: LLViewerJointMesh mSkirtMesh3; LLViewerJointMesh mSkirtMesh4; - typedef std::multimap<LLString, LLPolyMesh*> mesh_map_t; + typedef std::multimap<std::string, LLPolyMesh*> mesh_map_t; mesh_map_t mMeshes; //-------------------------------------------------------------------- @@ -924,7 +919,7 @@ protected: F32 mAdjustedPixelArea; LLWString mNameString; - LLString mTitle; + std::string mTitle; BOOL mNameAway; BOOL mNameBusy; BOOL mNameMute; @@ -932,8 +927,7 @@ protected: BOOL mVisibleChat; BOOL mRenderGroupTitles; - - LLString mDebugText; + std::string mDebugText; U64 mLastRegionHandle; LLFrameTimer mRegionCrossingTimer; S32 mRegionCrossingCount; @@ -1013,7 +1007,7 @@ protected: static void onInitialBakedTextureLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ); static void onBakedTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata); void useBakedTexture(const LLUUID& id); - void dumpAvatarTEs(const char* context); + void dumpAvatarTEs(const std::string& context); void removeMissingBakedTextures(); LLTexLayerSet* getLayerSet(ETextureIndex index) const; LLHost getObjectHost() const; diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 54dabe5615..cc7d73e37a 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -172,7 +172,7 @@ void LLVOGrass::initClass() if (newGrass->mTextureID.isNull()) { - LLString textureName; + std::string textureName; static LLStdStringHandle texture_name_string = LLXmlTree::addAttributeString("texture_name"); success &= grass_def->getFastAttributeString(texture_name_string, textureName); @@ -203,7 +203,7 @@ void LLVOGrass::initClass() if (!success) { - LLString name; + std::string name; static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); grass_def->getFastAttributeString(name_string, name); llwarns << "Incomplete definition of grass " << name << llendl; @@ -211,22 +211,20 @@ void LLVOGrass::initClass() } BOOL have_all_grass = TRUE; - LLString err; - char buffer[10]; /* Flawfinder: ignore */ + std::string err; for (S32 i=0;i<sMaxGrassSpecies;++i) { if (!sSpeciesTable.count(i)) { - snprintf(buffer,10," %d",i); /* Flawfinder: ignore */ - err.append(buffer); + err.append(llformat(" %d",i)); have_all_grass = FALSE; } } if (!have_all_grass) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[SPECIES]"] = err; gViewerWindow->alertXml("ErrorUndefinedGrasses", args, alert_done ); } diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index b3b82d9c79..222ce45d9d 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -1,4 +1,4 @@ -/** + /** * @file llvoiceclient.cpp * @brief Implementation of LLVoiceClient class which is the interface to the voice client process. * @@ -421,7 +421,7 @@ void LLVivoxProtocolParser::StartTag(const char *tag, const char **attr) void LLVivoxProtocolParser::EndTag(const char *tag) { - const char *string = textBuffer.c_str(); + const std::string& string = textBuffer; bool clearbuffer = true; responseDepth--; @@ -445,9 +445,9 @@ void LLVivoxProtocolParser::EndTag(const char *tag) // Closing a tag. Finalize the text we've accumulated and reset if (strcmp("ReturnCode", tag) == 0) - returnCode = strtol(string, NULL, 10); + returnCode = strtol(string.c_str(), NULL, 10); else if (strcmp("StatusCode", tag) == 0) - statusCode = strtol(string, NULL, 10); + statusCode = strtol(string.c_str(), NULL, 10); else if (strcmp("ConnectorHandle", tag) == 0) connectorHandle = string; else if (strcmp("AccountHandle", tag) == 0) @@ -462,11 +462,11 @@ void LLVivoxProtocolParser::EndTag(const char *tag) else if (strcmp("StatusString", tag) == 0) statusString = string; else if (strcmp("State", tag) == 0) - state = strtol(string, NULL, 10); + state = strtol(string.c_str(), NULL, 10); else if (strcmp("URI", tag) == 0) uriString = string; else if (strcmp("IsChannel", tag) == 0) - isChannel = strcmp(string, "true") == 0; + isChannel = string == "true" ? true : false; else if (strcmp("Name", tag) == 0) nameString = string; else if (strcmp("AudioMedia", tag) == 0) @@ -480,19 +480,19 @@ void LLVivoxProtocolParser::EndTag(const char *tag) else if (strcmp("AccountName", tag) == 0) nameString = string; else if (strcmp("ParticipantTyppe", tag) == 0) - participantType = strtol(string, NULL, 10); + participantType = strtol(string.c_str(), NULL, 10); else if (strcmp("IsLocallyMuted", tag) == 0) - isLocallyMuted = strcmp(string, "true") == 0; + isLocallyMuted = string == "true" ? true : false; else if (strcmp("IsModeratorMuted", tag) == 0) - isModeratorMuted = strcmp(string, "true") == 0; + isModeratorMuted = string == "true" ? true : false; else if (strcmp("IsSpeaking", tag) == 0) - isSpeaking = strcmp(string, "true") == 0; + isSpeaking = string == "true" ? true : false; else if (strcmp("Volume", tag) == 0) - volume = strtol(string, NULL, 10); + volume = strtol(string.c_str(), NULL, 10); else if (strcmp("Energy", tag) == 0) - energy = (F32)strtod(string, NULL); + energy = (F32)strtod(string.c_str(), NULL); else if (strcmp("MicEnergy", tag) == 0) - energy = (F32)strtod(string, NULL); + energy = (F32)strtod(string.c_str(), NULL); else if (strcmp("ChannelName", tag) == 0) nameString = string; else if (strcmp("ChannelURI", tag) == 0) @@ -1096,9 +1096,9 @@ void LLVoiceClient::idle(void* user_data) self->stateMachine(); } -const char *LLVoiceClient::state2string(LLVoiceClient::state inState) +std::string LLVoiceClient::state2string(LLVoiceClient::state inState) { - const char *result = "UNKNOWN"; + std::string result = "UNKNOWN"; // Prevent copy-paste errors when updating this list... #define CASE(x) case x: result = #x; break @@ -1148,9 +1148,9 @@ const char *LLVoiceClient::state2string(LLVoiceClient::state inState) return result; } -const char *LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserver::EStatusType inStatus) +std::string LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserver::EStatusType inStatus) { - const char *result = "UNKNOWN"; + std::string result = "UNKNOWN"; // Prevent copy-paste errors when updating this list... #define CASE(x) case x: result = #x; break @@ -1279,7 +1279,7 @@ void LLVoiceClient::stateMachine() #endif // See if the vivox executable exists llstat s; - if(!LLFile::stat(exe_path.c_str(), &s)) + if(!LLFile::stat(exe_path, &s)) { // vivox executable exists. Build the command line and launch the daemon. std::string args = " -p tcp -h -c"; @@ -1325,7 +1325,7 @@ void LLVoiceClient::stateMachine() // This should be the same for mac and linux { std::vector<std::string> arglist; - arglist.push_back(exe_path.c_str()); + arglist.push_back(exe_path); // Split the argument string into separate strings for each argument typedef boost::tokenizer<boost::char_separator<char> > tokenizer; @@ -1376,7 +1376,7 @@ void LLVoiceClient::stateMachine() // To do this, launch the gateway on a nearby host like this: // vivox-gw.exe -p tcp -i 0.0.0.0:44124 // and put that host's IP address here. - mDaemonHost = LLHost(gSavedSettings.getString("VoiceHost").c_str(), gSavedSettings.getU32("VoicePort")); + mDaemonHost = LLHost(gSavedSettings.getString("VoiceHost"), gSavedSettings.getU32("VoicePort")); } mUpdateTimer.start(); @@ -2927,9 +2927,9 @@ void LLVoiceClient::sessionNewEvent( LLIMMgr::computeSessionID( IM_SESSION_P2P_INVITE, caller_id), - LLString::null, + LLStringUtil::null, caller_id, - LLString::null, + LLStringUtil::null, IM_SESSION_P2P_INVITE, LLIMMgr::INVITATION_TYPE_VOICE, eventSessionHandle); @@ -3426,8 +3426,8 @@ std::string LLVoiceClient::nameFromAvatar(LLVOAvatar *avatar) std::string LLVoiceClient::nameFromID(const LLUUID &uuid) { std::string result; - U8 rawuuid[UUID_BYTES + 1]; - uuid.toCompressedString((char*)rawuuid); + std::string rawuuid; + uuid.toCompressedString(rawuuid); // Prepending this apparently prevents conflicts with reserved names inside the vivox and diamondware code. result = "x"; @@ -3435,9 +3435,9 @@ std::string LLVoiceClient::nameFromID(const LLUUID &uuid) // Base64 encode and replace the pieces of base64 that are less compatible // with e-mail local-parts. // See RFC-4648 "Base 64 Encoding with URL and Filename Safe Alphabet" - result += LLBase64::encode(rawuuid, UUID_BYTES); - LLString::replaceChar(result, '+', '-'); - LLString::replaceChar(result, '/', '_'); + result += LLBase64::encode((const U8*)rawuuid.c_str(), UUID_BYTES); + LLStringUtil::replaceChar(result, '+', '-'); + LLStringUtil::replaceChar(result, '/', '_'); // If you need to transform a GUID to this form on the Mac OS X command line, this will do so: // echo -n x && (echo e669132a-6c43-4ee1-a78d-6c82fff59f32 |xxd -r -p |openssl base64|tr '/+' '_-') @@ -3459,8 +3459,8 @@ bool LLVoiceClient::IDFromName(const std::string name, LLUUID &uuid) // Reverse the transforms done by nameFromID std::string temp = name; - LLString::replaceChar(temp, '-', '+'); - LLString::replaceChar(temp, '_', '/'); + LLStringUtil::replaceChar(temp, '-', '+'); + LLStringUtil::replaceChar(temp, '_', '/'); U8 rawuuid[UUID_BYTES + 1]; int len = apr_base64_decode_binary(rawuuid, temp.c_str() + 1); @@ -3490,7 +3490,7 @@ std::string LLVoiceClient::sipURIFromName(std::string &name) result += "@"; result += mAccountServerName; -// LLString::toLower(result); +// LLStringUtil::toLower(result); return result; } @@ -3855,9 +3855,9 @@ F32 LLVoiceClient::getCurrentPower(const LLUUID& id) } -LLString LLVoiceClient::getDisplayName(const LLUUID& id) +std::string LLVoiceClient::getDisplayName(const LLUUID& id) { - LLString result; + std::string result; participantState *participant = findParticipantByID(id); if(participant) { @@ -4054,17 +4054,17 @@ void LLVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::EStatusTy } //static -void LLVoiceClient::onAvatarNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* user_data) -{ - participantState* statep = gVoiceClient->findParticipantByID(id); - - if (statep) - { - statep->mDisplayName = llformat("%s %s", first, last); - } +// void LLVoiceClient::onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* user_data) +// { +// participantState* statep = gVoiceClient->findParticipantByID(id); + +// if (statep) +// { +// statep->mDisplayName = first + " " + last; +// } - gVoiceClient->notifyObservers(); -} +// gVoiceClient->notifyObservers(); +// } class LLViewerParcelVoiceInfo : public LLHTTPNode { diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index 8c3637830d..85a1674d98 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -74,7 +74,7 @@ public: virtual ~LLVoiceClientStatusObserver() { } virtual void onChange(EStatusType status, const std::string &channelURI, bool proximal) = 0; - static const char *status2string(EStatusType inStatus); + static std::string status2string(EStatusType inStatus); }; class LLVoiceClient: public LLSingleton<LLVoiceClient> @@ -227,7 +227,7 @@ class LLVoiceClient: public LLSingleton<LLVoiceClient> BOOL getPTTPressed(const LLUUID& id); // This is the inverse of the "locally muted" property. BOOL getOnMuteList(const LLUUID& id); F32 getUserVolume(const LLUUID& id); - LLString getDisplayName(const LLUUID& id); + std::string getDisplayName(const LLUUID& id); // MBW -- XXX -- Not sure how to get this data out of the TVC BOOL getUsingPTT(const LLUUID& id); @@ -274,7 +274,7 @@ class LLVoiceClient: public LLSingleton<LLVoiceClient> void addStatusObserver(LLVoiceClientStatusObserver* observer); void removeStatusObserver(LLVoiceClientStatusObserver* observer); - static void onAvatarNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* user_data); +// static void onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* user_data); typedef std::vector<std::string> deviceList; deviceList *getCaptureDevices(); @@ -357,7 +357,7 @@ class LLVoiceClient: public LLSingleton<LLVoiceClient> void setState(state inState); state getState(void) { return mState; }; - static const char *state2string(state inState); + static std::string state2string(state inState); void stateMachine(); static void idle(void *user_data); diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 5f83dd4b06..97a1ed162d 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -232,7 +232,7 @@ void LLVOTree::initClass() if (!success) { - LLString name; + std::string name; static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name"); tree_def->getFastAttributeString(name_string, name); llwarns << "Incomplete definition of tree " << name << llendl; @@ -240,22 +240,20 @@ void LLVOTree::initClass() } BOOL have_all_trees = TRUE; - LLString err; - char buffer[10]; /* Flawfinder: ignore */ + std::string err; for (S32 i=0;i<sMaxTreeSpecies;++i) { if (!sSpeciesTable.count(i)) { - snprintf(buffer,10," %d",i); /* Flawfinder: ignore */ - err.append(buffer); + err.append(llformat(" %d",i)); have_all_trees = FALSE; } } if (!have_all_trees) { - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[SPECIES]"] = err; gViewerWindow->alertXml("ErrorUndefinedTrees", args ); } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 0117737225..16c6bcdd5f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -212,9 +212,9 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, // Well, crap, there's something bogus in the data that we're unpacking. dp->dumpBufferToLog(); llwarns << "Flushing cache files" << llendl; - char mask[LL_MAX_PATH]; /* Flawfinder: ignore */ - snprintf(mask, LL_MAX_PATH, "%s*.slc", gDirUtilp->getDirDelimiter().c_str()); /* Flawfinder: ignore */ - gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"").c_str(),mask); + std::string mask; + mask = gDirUtilp->getDirDelimiter() + "*.slc"; + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask); // llerrs << "Bogus TE data in " << getID() << ", crashing!" << llendl; llwarns << "Bogus TE data in " << getID() << llendl; } diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 2853860802..4f2dd663ed 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -84,9 +84,9 @@ LLWaterParamManager::~LLWaterParamManager() { } -void LLWaterParamManager::loadAllPresets(const LLString& file_name) +void LLWaterParamManager::loadAllPresets(const std::string& file_name) { - LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); + std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); LL_INFOS2("AppInit", "Shaders") << "Loading water settings from " << path_name << LL_ENDL; //mParamList.clear(); @@ -111,10 +111,10 @@ void LLWaterParamManager::loadAllPresets(const LLString& file_name) // not much error checking here since we're getting rid of this std::string water_name = unescaped_name.substr(0, unescaped_name.size() - 4); - LLString cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", name)); + std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", name)); LL_DEBUGS2("AppInit", "Shaders") << "Loading water from " << cur_path << LL_ENDL; - std::ifstream water_xml(cur_path.c_str()); + llifstream water_xml(cur_path); if (water_xml) { LLSD water_data(LLSD::emptyMap()); @@ -122,12 +122,13 @@ void LLWaterParamManager::loadAllPresets(const LLString& file_name) parser->parse(water_xml, water_data, LLSDSerialize::SIZE_UNLIMITED); addParamSet(water_name, water_data); + water_xml.close(); } } } } -void LLWaterParamManager::loadPreset(const LLString & name) +void LLWaterParamManager::loadPreset(const std::string & name) { // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_escape(name.c_str(), name.size()); @@ -140,7 +141,7 @@ void LLWaterParamManager::loadPreset(const LLString & name) std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); llinfos << "Loading water settings from " << pathName << llendl; - std::ifstream presetsXML(pathName.c_str()); + llifstream presetsXML(pathName); if (presetsXML) { @@ -159,6 +160,7 @@ void LLWaterParamManager::loadPreset(const LLString & name) { setParamSet(name, paramsData); } + presetsXML.close(); } else { @@ -171,7 +173,7 @@ void LLWaterParamManager::loadPreset(const LLString & name) propagateParameters(); } -void LLWaterParamManager::savePreset(const LLString & name) +void LLWaterParamManager::savePreset(const std::string & name) { // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_escape(name.c_str(), name.size()); @@ -189,7 +191,7 @@ void LLWaterParamManager::savePreset(const LLString & name) paramsData = mParamList[name].getAll(); // write to file - std::ofstream presetsXML(pathName.c_str()); + llofstream presetsXML(pathName); LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); presetsXML.close(); @@ -386,7 +388,7 @@ bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_fr if(delete_from_disk) { - LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); + std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); // use full curl escaped name char * curl_str = curl_escape(name.c_str(), name.size()); @@ -425,7 +427,7 @@ LLWaterParamManager * LLWaterParamManager::instance() { sInstance = new LLWaterParamManager(); - sInstance->loadAllPresets(""); + sInstance->loadAllPresets(LLStringUtil::null); sInstance->getParamSet("Default", sInstance->mCurParams); } diff --git a/indra/newview/llwaterparammanager.h b/indra/newview/llwaterparammanager.h index 937dd9e388..6f31ebce5c 100644 --- a/indra/newview/llwaterparammanager.h +++ b/indra/newview/llwaterparammanager.h @@ -44,12 +44,12 @@ const F32 WATER_FOG_LIGHT_CLAMP = 0.3f; struct WaterColorControl { F32 mR, mG, mB, mA, mI; /// the values - char const * mName; /// name to use to dereference params + std::string mName; /// name to use to dereference params std::string mSliderName; /// name of the slider in menu bool mHasSliderName; /// only set slider name for true color types inline WaterColorControl(F32 red, F32 green, F32 blue, F32 alpha, - F32 intensity, char const * n, char const * sliderName = "") + F32 intensity, const std::string& n, const std::string& sliderName = LLStringUtil::null) : mR(red), mG(green), mB(blue), mA(alpha), mI(intensity), mName(n), mSliderName(sliderName) { // if there's a slider name, say we have one @@ -104,10 +104,10 @@ struct WaterVector3Control F32 mY; F32 mZ; - char const * mName; + std::string mName; // basic constructor - inline WaterVector3Control(F32 valX, F32 valY, F32 valZ, char const * n) + inline WaterVector3Control(F32 valX, F32 valY, F32 valZ, const std::string& n) : mX(valX), mY(valY), mZ(valZ), mName(n) { } @@ -133,10 +133,10 @@ struct WaterVector2Control F32 mX; F32 mY; - char const * mName; + std::string mName; // basic constructor - inline WaterVector2Control(F32 valX, F32 valY, char const * n) + inline WaterVector2Control(F32 valX, F32 valY, const std::string& n) : mX(valX), mY(valY), mName(n) { } @@ -159,10 +159,10 @@ struct WaterVector2Control struct WaterFloatControl { F32 mX; - char const * mName; + std::string mName; F32 mMult; - inline WaterFloatControl(F32 val, char const * n, F32 m=1.0f) + inline WaterFloatControl(F32 val, const std::string& n, F32 m=1.0f) : mX(val), mName(n), mMult(m) { } @@ -189,10 +189,10 @@ struct WaterFloatControl struct WaterExpFloatControl { F32 mExp; - char const * mName; + std::string mName; F32 mBase; - inline WaterExpFloatControl(F32 val, char const * n, F32 b) + inline WaterExpFloatControl(F32 val, const std::string& n, F32 b) : mExp(val), mName(n), mBase(b) { } @@ -225,13 +225,13 @@ public: ~LLWaterParamManager(); /// load a preset file - void loadAllPresets(const LLString & fileName); + void loadAllPresets(const std::string & fileName); /// load an individual preset into the sky - void loadPreset(const LLString & name); + void loadPreset(const std::string & name); /// save the parameter presets to file - void savePreset(const LLString & name); + void savePreset(const std::string & name); /// send the parameters to the shaders void propagateParameters(void); diff --git a/indra/newview/llwaterparamset.cpp b/indra/newview/llwaterparamset.cpp index 78797eecce..ab3b6a820f 100644 --- a/indra/newview/llwaterparamset.cpp +++ b/indra/newview/llwaterparamset.cpp @@ -87,7 +87,7 @@ LLWaterParamSet::LLWaterParamSet(void) : } -void LLWaterParamSet::set(const char * paramName, float x) +void LLWaterParamSet::set(const std::string& paramName, float x) { // handle case where no array if(mParamValues[paramName].isReal()) @@ -103,19 +103,19 @@ void LLWaterParamSet::set(const char * paramName, float x) } } -void LLWaterParamSet::set(const char * paramName, float x, float y) { +void LLWaterParamSet::set(const std::string& paramName, float x, float y) { mParamValues[paramName][0] = x; mParamValues[paramName][1] = y; } -void LLWaterParamSet::set(const char * paramName, float x, float y, float z) +void LLWaterParamSet::set(const std::string& paramName, float x, float y, float z) { mParamValues[paramName][0] = x; mParamValues[paramName][1] = y; mParamValues[paramName][2] = z; } -void LLWaterParamSet::set(const char * paramName, float x, float y, float z, float w) +void LLWaterParamSet::set(const std::string& paramName, float x, float y, float z, float w) { mParamValues[paramName][0] = x; mParamValues[paramName][1] = y; @@ -123,7 +123,7 @@ void LLWaterParamSet::set(const char * paramName, float x, float y, float z, flo mParamValues[paramName][3] = w; } -void LLWaterParamSet::set(const char * paramName, const float * val) +void LLWaterParamSet::set(const std::string& paramName, const float * val) { mParamValues[paramName][0] = val[0]; mParamValues[paramName][1] = val[1]; @@ -131,7 +131,7 @@ void LLWaterParamSet::set(const char * paramName, const float * val) mParamValues[paramName][3] = val[3]; } -void LLWaterParamSet::set(const char * paramName, const LLVector4 & val) +void LLWaterParamSet::set(const std::string& paramName, const LLVector4 & val) { mParamValues[paramName][0] = val.mV[0]; mParamValues[paramName][1] = val.mV[1]; @@ -139,7 +139,7 @@ void LLWaterParamSet::set(const char * paramName, const LLVector4 & val) mParamValues[paramName][3] = val.mV[3]; } -void LLWaterParamSet::set(const char * paramName, const LLColor4 & val) +void LLWaterParamSet::set(const std::string& paramName, const LLColor4 & val) { mParamValues[paramName][0] = val.mV[0]; mParamValues[paramName][1] = val.mV[1]; @@ -147,7 +147,7 @@ void LLWaterParamSet::set(const char * paramName, const LLColor4 & val) mParamValues[paramName][3] = val.mV[3]; } -LLVector4 LLWaterParamSet::getVector4(const char * paramName, bool& error) +LLVector4 LLWaterParamSet::getVector4(const std::string& paramName, bool& error) { // test to see if right type @@ -168,7 +168,7 @@ LLVector4 LLWaterParamSet::getVector4(const char * paramName, bool& error) return val; } -LLVector3 LLWaterParamSet::getVector3(const char * paramName, bool& error) +LLVector3 LLWaterParamSet::getVector3(const std::string& paramName, bool& error) { // test to see if right type @@ -188,7 +188,7 @@ LLVector3 LLWaterParamSet::getVector3(const char * paramName, bool& error) return val; } -LLVector2 LLWaterParamSet::getVector2(const char * paramName, bool& error) +LLVector2 LLWaterParamSet::getVector2(const std::string& paramName, bool& error) { // test to see if right type int ttest; @@ -208,7 +208,7 @@ LLVector2 LLWaterParamSet::getVector2(const char * paramName, bool& error) return val; } -F32 LLWaterParamSet::getFloat(const char * paramName, bool& error) +F32 LLWaterParamSet::getFloat(const std::string& paramName, bool& error) { // test to see if right type diff --git a/indra/newview/llwaterparamset.h b/indra/newview/llwaterparamset.h index f853140733..b733160dff 100644 --- a/indra/newview/llwaterparamset.h +++ b/indra/newview/llwaterparamset.h @@ -48,7 +48,7 @@ class LLWaterParamSet friend class LLWaterParamManager; public: - LLString mName; + std::string mName; private: @@ -70,20 +70,20 @@ public: /// Set a float parameter. /// \param paramName The name of the parameter to set. /// \param x The float value to set. - void set(const char * paramName, float x); + void set(const std::string& paramName, float x); /// Set a float2 parameter. /// \param paramName The name of the parameter to set. /// \param x The x component's value to set. /// \param y The y component's value to set. - void set(const char * paramName, float x, float y); + void set(const std::string& paramName, float x, float y); /// Set a float3 parameter. /// \param paramName The name of the parameter to set. /// \param x The x component's value to set. /// \param y The y component's value to set. /// \param z The z component's value to set. - void set(const char * paramName, float x, float y, float z); + void set(const std::string& paramName, float x, float y, float z); /// Set a float4 parameter. /// \param paramName The name of the parameter to set. @@ -91,42 +91,42 @@ public: /// \param y The y component's value to set. /// \param z The z component's value to set. /// \param w The w component's value to set. - void set(const char * paramName, float x, float y, float z, float w); + void set(const std::string& paramName, float x, float y, float z, float w); /// Set a float4 parameter. /// \param paramName The name of the parameter to set. /// \param val An array of the 4 float values to set the parameter to. - void set(const char * paramName, const float * val); + void set(const std::string& paramName, const float * val); /// Set a float4 parameter. /// \param paramName The name of the parameter to set. /// \param val A struct of the 4 float values to set the parameter to. - void set(const char * paramName, const LLVector4 & val); + void set(const std::string& paramName, const LLVector4 & val); /// Set a float4 parameter. /// \param paramName The name of the parameter to set. /// \param val A struct of the 4 float values to set the parameter to. - void set(const char * paramName, const LLColor4 & val); + void set(const std::string& paramName, const LLColor4 & val); /// Get a float4 parameter. /// \param paramName The name of the parameter to set. /// \param error A flag to set if it's not the proper return type - LLVector4 getVector4(const char * paramName, bool& error); + LLVector4 getVector4(const std::string& paramName, bool& error); /// Get a float3 parameter. /// \param paramName The name of the parameter to set. /// \param error A flag to set if it's not the proper return type - LLVector3 getVector3(const char * paramName, bool& error); + LLVector3 getVector3(const std::string& paramName, bool& error); /// Get a float2 parameter. /// \param paramName The name of the parameter to set. /// \param error A flag to set if it's not the proper return type - LLVector2 getVector2(const char * paramName, bool& error); + LLVector2 getVector2(const std::string& paramName, bool& error); /// Get an integer parameter /// \param paramName The name of the parameter to set. /// \param error A flag to set if it's not the proper return type - F32 getFloat(const char * paramName, bool& error); + F32 getFloat(const std::string& paramName, bool& error); /// interpolate two parameter sets /// \param src The parameter set to start with diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp index f084088478..ef077101e9 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llwearable.cpp @@ -52,7 +52,7 @@ S32 LLWearable::sCurrentDefinitionVersion = 1; // static -const char* LLWearable::sTypeName[ WT_COUNT ] = +const std::string LLWearable::sTypeName[ WT_COUNT+1 ] = { "shape", "skin", @@ -66,11 +66,12 @@ const char* LLWearable::sTypeName[ WT_COUNT ] = "gloves", "undershirt", "underpants", - "skirt" + "skirt", + "invalid" }; // static -const char* LLWearable::sTypeLabel[ WT_COUNT ] = +const std::string LLWearable::sTypeLabel[ WT_COUNT+1 ] = { "Shape", "Skin", @@ -84,7 +85,8 @@ const char* LLWearable::sTypeLabel[ WT_COUNT ] = "Gloves", "Undershirt", "Underpants", - "Skirt" + "Skirt", + "invalid" }; @@ -136,7 +138,7 @@ LLWearable::~LLWearable() // static -EWearableType LLWearable::typeNameToType( const LLString& type_name ) +EWearableType LLWearable::typeNameToType( const std::string& type_name ) { for( S32 i = 0; i < WT_COUNT; i++ ) { @@ -149,37 +151,35 @@ EWearableType LLWearable::typeNameToType( const LLString& type_name ) } -const char* terse_F32_to_string( F32 f, char s[MAX_STRING] ) /* Flawfinder: ignore */ +std::string terse_F32_to_string( F32 f ) { - char* r = s; - S32 len = snprintf( s, MAX_STRING, "%.2f", f ); /* Flawfinder: ignore */ + std::string r = llformat( "%.2f", f ); // "1.20" -> "1.2" // "24.00" -> "24." - while( '0' == r[len - 1] ) + S32 len = r.length(); + while( len > 0 && '0' == r[len - 1] ) { - len--; - r[len] = '\0'; + r.erase(len-1, 1); + len--; } if( '.' == r[len - 1] ) { // "24." -> "24" - len--; - r[len] = '\0'; + r.erase(len-1, 1); } else if( ('-' == r[0]) && ('0' == r[1]) ) { // "-0.59" -> "-.59" - r++; - r[0] = '-'; + r.erase(1, 1); } else if( '0' == r[0] ) { // "0.59" -> ".59" - r++; + r.erase(0, 1); } return r; @@ -231,13 +231,12 @@ BOOL LLWearable::exportFile( LLFILE* file ) return FALSE; } - char s[ MAX_STRING ]; /* Flawfinder: ignore */ for (param_map_t::iterator iter = mVisualParamMap.begin(); iter != mVisualParamMap.end(); ++iter) { S32 param_id = iter->first; F32 param_weight = iter->second; - if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight, s ) ) < 0 ) + if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight ).c_str() ) < 0 ) { return FALSE; } @@ -311,7 +310,7 @@ BOOL LLWearable::importFile( LLFILE* file ) return FALSE; } mName = text_buffer; - LLString::truncate(mName, DB_INV_ITEM_NAME_STR_LEN ); + LLStringUtil::truncate(mName, DB_INV_ITEM_NAME_STR_LEN ); } // description @@ -334,7 +333,7 @@ BOOL LLWearable::importFile( LLFILE* file ) return FALSE; } mDescription = text_buffer; - LLString::truncate(mDescription, DB_INV_ITEM_DESC_STR_LEN ); + LLStringUtil::truncate(mDescription, DB_INV_ITEM_DESC_STR_LEN ); } // permissions @@ -848,10 +847,10 @@ void LLWearable::saveNewAsset() // llinfos << "LLWearable::saveNewAsset() type: " << getTypeName() << llendl; //llinfos << *this << llendl; - char new_asset_id_string[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string new_asset_id_string; mAssetID.toString(new_asset_id_string); - char filename[LL_MAX_PATH]; /* Flawfinder: ignore */ - snprintf(filename, LL_MAX_PATH, "%s.wbl", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,new_asset_id_string).c_str()); /* Flawfinder: ignore */ + std::string filename; + filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,new_asset_id_string) + ".wbl"; LLFILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ BOOL successful_save = FALSE; if(fp && exportFile(fp)) @@ -865,14 +864,10 @@ void LLWearable::saveNewAsset() } if(!successful_save) { - char buffer[2*MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buffer, /* Flawfinder: ignore */ - sizeof(buffer), - "Unable to save '%s' to wearable file.", - mName.c_str()); + std::string buffer = llformat("Unable to save '%s' to wearable file.", mName.c_str()); llwarns << buffer << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = mName; gViewerWindow->alertXml("CannotSaveWearableOutOfSpace", args); return; @@ -910,7 +905,7 @@ void LLWearable::saveNewAsset() void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userdata, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed) { LLWearableSaveData* data = (LLWearableSaveData*)userdata; - const char* type_name = LLWearable::typeToTypeName(data->mType); + const std::string& type_name = LLWearable::typeToTypeName(data->mType); if(0 == status) { // Success @@ -918,22 +913,18 @@ void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userda } else { - char buffer[2*MAX_STRING]; /* Flawfinder: ignore */ - snprintf(buffer, /* Flawfinder: ignore */ - sizeof(buffer), - "Unable to save %s to central asset store.", - type_name); + std::string buffer = llformat("Unable to save %s to central asset store.", type_name.c_str()); llwarns << buffer << " Status: " << status << llendl; - LLStringBase<char>::format_map_t args; + LLStringUtil::format_map_t args; args["[NAME]"] = type_name; gViewerWindow->alertXml("CannotSaveToAssetStore", args); } // Delete temp file - char new_asset_id_string[UUID_STR_LENGTH]; /* Flawfinder: ignore */ + std::string new_asset_id_string; new_asset_id.toString(new_asset_id_string); - char src_filename[LL_MAX_PATH]; /* Flawfinder: ignore */ - snprintf(src_filename, LL_MAX_PATH, "%s.wbl", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,new_asset_id_string).c_str()); /* Flawfinder: ignore */ + std::string src_filename; + src_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,new_asset_id_string) + ".wbl"; LLFile::remove(src_filename); // delete the context data diff --git a/indra/newview/llwearable.h b/indra/newview/llwearable.h index 059444d941..ab9a00c785 100644 --- a/indra/newview/llwearable.h +++ b/indra/newview/llwearable.h @@ -69,7 +69,6 @@ public: const LLAssetID& getID() { return mAssetID; } const LLTransactionID& getTransactionID() { return mTransactionID; } - BOOL readData( const char *buffer ); BOOL isDirty(); BOOL isOldVersion(); @@ -84,11 +83,11 @@ public: EWearableType getType() const { return mType; } void setType( EWearableType type ) { mType = type; } - void setName( const LLString& name ) { mName = name; } - const LLString& getName() { return mName; } + void setName( const std::string& name ) { mName = name; } + const std::string& getName() { return mName; } - void setDescription( const LLString& desc ) { mDescription = desc; } - const LLString& getDescription() { return mDescription; } + void setDescription( const std::string& desc ) { mDescription = desc; } + const std::string& getDescription() { return mDescription; } void setPermissions( const LLPermissions& p ) { mPermissions = p; } const LLPermissions& getPermissions() { return mPermissions; } @@ -96,17 +95,17 @@ public: void setSaleInfo( const LLSaleInfo& info ) { mSaleInfo = info; } const LLSaleInfo& getSaleInfo() { return mSaleInfo; } - const char* getTypeLabel() const { return LLWearable::sTypeLabel[ mType ]; } - const char* getTypeName() const { return LLWearable::sTypeName[ mType ]; } + const std::string& getTypeLabel() const { return LLWearable::sTypeLabel[ mType ]; } + const std::string& getTypeName() const { return LLWearable::sTypeName[ mType ]; } void setParamsToDefaults(); void setTexturesToDefaults(); LLAssetType::EType getAssetType() const { return LLWearable::typeToAssetType( mType ); } - static EWearableType typeNameToType( const LLString& type_name ); - static const char* typeToTypeName( EWearableType type ) { return (type<WT_COUNT) ? LLWearable::sTypeName[type] : "invalid"; } - static const char* typeToTypeLabel( EWearableType type ) { return (type<WT_COUNT) ? LLWearable::sTypeLabel[type] : "invalid"; } + static EWearableType typeNameToType( const std::string& type_name ); + static const std::string& typeToTypeName( EWearableType type ) { return LLWearable::sTypeName[llmin(type,WT_COUNT)]; } + static const std::string& typeToTypeLabel( EWearableType type ) { return LLWearable::sTypeLabel[llmin(type,WT_COUNT)]; } static LLAssetType::EType typeToAssetType( EWearableType wearable_type ); void saveNewAsset(); @@ -123,8 +122,8 @@ public: private: static S32 sCurrentDefinitionVersion; // Depends on the current state of the avatar_lad.xml. S32 mDefinitionVersion; // Depends on the state of the avatar_lad.xml when this asset was created. - LLString mName; - LLString mDescription; + std::string mName; + std::string mDescription; LLPermissions mPermissions; LLSaleInfo mSaleInfo; LLAssetID mAssetID; @@ -136,8 +135,8 @@ private: typedef std::map<S32, LLUUID> te_map_t; te_map_t mTEMap; // maps TE to Image ID - static const char* sTypeName[ WT_COUNT ]; - static const char* sTypeLabel[ WT_COUNT ]; + static const std::string sTypeName[ WT_COUNT+1 ]; + static const std::string sTypeLabel[ WT_COUNT+1 ]; }; #endif // LL_LLWEARABLE_H diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 7fca271d3d..7678727e58 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -50,7 +50,7 @@ struct LLWearableArrivedData { LLWearableArrivedData( LLAssetType::EType asset_type, - const LLString& wearable_name, + const std::string& wearable_name, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata ) : @@ -64,7 +64,7 @@ struct LLWearableArrivedData LLAssetType::EType mAssetType; void (*mCallback)(LLWearable*, void* userdata); void* mUserdata; - LLString mName; + std::string mName; S32 mRetries; }; @@ -79,7 +79,7 @@ LLWearableList::~LLWearableList() mList.clear(); } -void LLWearableList::getAsset( const LLAssetID& assetID, const LLString& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata ) +void LLWearableList::getAsset( const LLAssetID& assetID, const std::string& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata ) { llassert( (asset_type == LLAssetType::AT_CLOTHING) || (asset_type == LLAssetType::AT_BODYPART) ); LLWearable* instance = get_if_there(mList, assetID, (LLWearable*)NULL ); @@ -112,7 +112,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID if( status >= 0 ) { // read the file - LLFILE* fp = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ + LLFILE* fp = LLFile::fopen(std::string(filename), "rb"); /*Flawfinder: ignore*/ if( !fp ) { LL_WARNS("Wearable") << "Bad Wearable Asset: unable to open file: '" << filename << "'" << LL_ENDL; @@ -130,7 +130,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID fclose( fp ); if(filename) { - LLFile::remove(filename); + LLFile::remove(std::string(filename)); } } } @@ -138,7 +138,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID { if(filename) { - LLFile::remove(filename); + LLFile::remove(std::string(filename)); } LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); @@ -180,7 +180,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID } else { - LLString::format_map_t args; + LLStringUtil::format_map_t args; // *TODO:translate args["[TYPE]"] = LLAssetType::lookupHumanReadable(data->mAssetType); if (data->mName.empty()) @@ -290,7 +290,7 @@ LLWearable* LLWearableList::createNewWearable( EWearableType type ) LLWearable* wearable = new LLWearable( tid ); wearable->setType( type ); - LLString name = "New "; + std::string name = "New "; name.append( wearable->getTypeLabel() ); wearable->setName( name ); diff --git a/indra/newview/llwearablelist.h b/indra/newview/llwearablelist.h index 88434842b4..1b7bb2fff2 100644 --- a/indra/newview/llwearablelist.h +++ b/indra/newview/llwearablelist.h @@ -46,7 +46,7 @@ public: void getAsset( const LLAssetID& assetID, - const LLString& wearable_name, + const std::string& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata ); @@ -56,7 +56,7 @@ public: LLWearable* createCopy( LLWearable* old_wearable ); LLWearable* createNewWearable( EWearableType type ); - // Pseudo-private + // Callback static void processGetAssetReply(const char* filename, const LLAssetID& assetID, void* user_data, S32 status, LLExtStat ext_status); protected: diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp index 21be936960..77c98d0569 100644 --- a/indra/newview/llweb.cpp +++ b/indra/newview/llweb.cpp @@ -34,7 +34,7 @@ #include "llweb.h" -#include "llwindow.h" +#include "llviewerwindow.h" #include "llviewercontrol.h" #include "llfloaterhtmlhelp.h" @@ -63,7 +63,7 @@ void LLWeb::loadURL(const std::string& url) void LLWeb::loadURLExternal(const std::string& url) { std::string escaped_url = escapeURL(url); - spawn_web_browser(escaped_url.c_str()); + gViewerWindow->getWindow()->spawnWebBrowser(escaped_url); } diff --git a/indra/newview/llweb.h b/indra/newview/llweb.h index 318410bb3b..b294bd8fe2 100644 --- a/indra/newview/llweb.h +++ b/indra/newview/llweb.h @@ -45,7 +45,7 @@ public: // browser, depending on user settings. static void loadURL(const std::string& url); - static void loadURL(const char* url) { loadURL( std::string(url) ); } + static void loadURL(const char* url) { loadURL( ll_safe_string(url) ); } // Loads unescaped url in external browser. static void loadURLExternal(const std::string& url); diff --git a/indra/newview/llwindebug.cpp b/indra/newview/llwindebug.cpp index bf6fcd6ccc..b13ef98bec 100644 --- a/indra/newview/llwindebug.cpp +++ b/indra/newview/llwindebug.cpp @@ -486,7 +486,7 @@ LLSD WINAPI Get_Exception_Info(PEXCEPTION_POINTERS pException) // Save instruction that caused exception. /* - LLString str; + std::string str; for (i = 0; i < 16; i++) str += llformat(" %02X", PBYTE(E.ExceptionAddress)[i]); info["Instruction"] = str; @@ -639,7 +639,7 @@ bool LLWinDebug::checkExceptionHandler() return ok; } -void LLWinDebug::writeDumpToFile(MINIDUMP_TYPE type, MINIDUMP_EXCEPTION_INFORMATION *ExInfop, const char *filename) +void LLWinDebug::writeDumpToFile(MINIDUMP_TYPE type, MINIDUMP_EXCEPTION_INFORMATION *ExInfop, const std::string& filename) { if(f_mdwp == NULL || gDirUtilp == NULL) { @@ -648,8 +648,7 @@ void LLWinDebug::writeDumpToFile(MINIDUMP_TYPE type, MINIDUMP_EXCEPTION_INFORMAT } else { - std::string dump_path = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, - filename); + std::string dump_path = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename); HANDLE hFile = CreateFileA(dump_path.c_str(), GENERIC_WRITE, @@ -734,7 +733,7 @@ void LLWinDebug::generateCrashStacks(struct _EXCEPTION_POINTERS *exception_infop info["Threads"] = threads; - std::ofstream out_file(log_path.c_str()); + llofstream out_file(log_path); LLSDSerialize::toPrettyXML(info, out_file); out_file.close(); } diff --git a/indra/newview/llwindebug.h b/indra/newview/llwindebug.h index f7543597cc..6875b943ae 100644 --- a/indra/newview/llwindebug.h +++ b/indra/newview/llwindebug.h @@ -66,7 +66,7 @@ public: static bool checkExceptionHandler(); static void generateCrashStacks(struct _EXCEPTION_POINTERS *pExceptionInfo = NULL); - static void writeDumpToFile(MINIDUMP_TYPE type, MINIDUMP_EXCEPTION_INFORMATION *ExInfop, const char *filename); + static void writeDumpToFile(MINIDUMP_TYPE type, MINIDUMP_EXCEPTION_INFORMATION *ExInfop, const std::string& filename); private: }; diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index b8b2a85ee4..1abf760580 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -48,17 +48,17 @@ LLWLDayCycle::~LLWLDayCycle() { } -void LLWLDayCycle::loadDayCycle(const LLString & fileName) +void LLWLDayCycle::loadDayCycle(const std::string & fileName) { // clear the first few things mTimeMap.clear(); // now load the file - LLString pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); llinfos << "Loading DayCycle settings from " << pathName << llendl; - llifstream day_cycle_xml(pathName.c_str()); + llifstream day_cycle_xml(pathName); if (day_cycle_xml.is_open()) { // load and parse it @@ -82,7 +82,7 @@ void LLWLDayCycle::loadDayCycle(const LLString & fileName) if(!success) { // alert the user - LLString::format_map_t args; + LLStringUtil::format_map_t args; args["[SKY]"] = day_data[i][1].asString(); gViewerWindow->alertXml("WLMissingSky", args); continue; @@ -96,11 +96,11 @@ void LLWLDayCycle::loadDayCycle(const LLString & fileName) } } -void LLWLDayCycle::saveDayCycle(const LLString & fileName) +void LLWLDayCycle::saveDayCycle(const std::string & fileName) { LLSD day_data(LLSD::emptyArray()); - LLString pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); //llinfos << "Saving WindLight settings to " << pathName << llendl; for(std::map<F32, std::string>::const_iterator mIt = mTimeMap.begin(); @@ -113,11 +113,10 @@ void LLWLDayCycle::saveDayCycle(const LLString & fileName) day_data.append(key); } - std::ofstream day_cycle_xml(pathName.c_str()); + llofstream day_cycle_xml(pathName); LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); formatter->format(day_data, day_cycle_xml, LLSDFormatter::OPTIONS_PRETTY); - - //day_cycle_xml.close(); + day_cycle_xml.close(); } @@ -127,7 +126,7 @@ void LLWLDayCycle::clearKeys() } -bool LLWLDayCycle::addKey(F32 newTime, const LLString & paramName) +bool LLWLDayCycle::addKey(F32 newTime, const std::string & paramName) { // no adding negative time if(newTime < 0) @@ -160,7 +159,7 @@ bool LLWLDayCycle::changeKeyTime(F32 oldTime, F32 newTime) return addKey(newTime, name); } -bool LLWLDayCycle::changeKeyParam(F32 time, const LLString & name) +bool LLWLDayCycle::changeKeyParam(F32 time, const std::string & name) { // just remove and add back // make sure param exists @@ -189,7 +188,7 @@ bool LLWLDayCycle::removeKey(F32 time) return false; } -bool LLWLDayCycle::getKey(const LLString & name, F32& key) +bool LLWLDayCycle::getKey(const std::string & name, F32& key) { // scroll through till we find the std::map<F32, std::string>::iterator mIt = mTimeMap.begin(); @@ -218,7 +217,7 @@ bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param) return false; } -bool LLWLDayCycle::getKeyedParamName(F32 time, LLString & name) +bool LLWLDayCycle::getKeyedParamName(F32 time, std::string & name) { // just scroll on through till you find it std::map<F32, std::string>::iterator mIt = mTimeMap.find(time); diff --git a/indra/newview/llwldaycycle.h b/indra/newview/llwldaycycle.h index b554c915fc..018774cf2b 100644 --- a/indra/newview/llwldaycycle.h +++ b/indra/newview/llwldaycycle.h @@ -61,10 +61,10 @@ public: ~LLWLDayCycle(); /// load a day cycle - void loadDayCycle(const LLString & fileName); + void loadDayCycle(const std::string & fileName); /// load a day cycle - void saveDayCycle(const LLString & fileName); + void saveDayCycle(const std::string & fileName); /// clear keys void clearKeys(); @@ -73,7 +73,7 @@ public: /// add a new key frame to the day cycle /// returns true if successful /// no negative time - bool addKey(F32 newTime, const LLString & paramName); + bool addKey(F32 newTime, const std::string & paramName); /// adjust a key's placement in the day cycle /// returns true if successful @@ -81,7 +81,7 @@ public: /// adjust a key's parameter used /// returns true if successful - bool changeKeyParam(F32 time, const LLString & paramName); + bool changeKeyParam(F32 time, const std::string & paramName); /// remove a key from the day cycle /// returns true if successful @@ -89,7 +89,7 @@ public: /// get the first key time for a parameter /// returns false if not there - bool getKey(const LLString & name, F32& key); + bool getKey(const std::string & name, F32& key); /// get the param set at a given time /// returns true if found one @@ -97,7 +97,7 @@ public: /// get the name /// returns true if it found one - bool getKeyedParamName(F32 time, LLString & name); + bool getKeyedParamName(F32 time, std::string & name); }; diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index 5fb8990774..24ddb6fc08 100644 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -104,16 +104,16 @@ LLWLParamManager::~LLWLParamManager() { } -void LLWLParamManager::loadPresets(const LLString& file_name) +void LLWLParamManager::loadPresets(const std::string& file_name) { // if fileName exists, use legacy loading form the big file, otherwise, search the sky // directory, and add the list if(file_name != "") { - LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name)); + std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name)); LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; - llifstream presetsXML(path_name.c_str()); + llifstream presetsXML(path_name); if (presetsXML) { @@ -136,7 +136,7 @@ void LLWLParamManager::loadPresets(const LLString& file_name) // otherwise, search the sky directory and find things there else { - LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); + std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; //mParamList.clear(); @@ -161,10 +161,10 @@ void LLWLParamManager::loadPresets(const LLString& file_name) // not much error checking here since we're getting rid of this std::string sky_name = unescaped_name.substr(0, unescaped_name.size() - 4); - LLString cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name)); + std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name)); LL_DEBUGS2("AppInit", "Shaders") << "Loading sky from " << cur_path << LL_ENDL; - std::ifstream sky_xml(cur_path.c_str()); + llifstream sky_xml(cur_path); if (sky_xml) { LLSD sky_data(LLSD::emptyMap()); @@ -172,17 +172,18 @@ void LLWLParamManager::loadPresets(const LLString& file_name) parser->parse(sky_xml, sky_data, LLSDSerialize::SIZE_UNLIMITED); addParamSet(sky_name, sky_data); + sky_xml.close(); } } } } } -void LLWLParamManager::savePresets(const LLString & fileName) +void LLWLParamManager::savePresets(const std::string & fileName) { LLSD paramsData(LLSD::emptyMap()); - LLString pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", fileName)); + std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", fileName)); for(std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.begin(); mIt != mParamList.end(); @@ -191,7 +192,7 @@ void LLWLParamManager::savePresets(const LLString & fileName) paramsData[mIt->first] = mIt->second.getAll(); } - std::ofstream presetsXML(pathName.c_str()); + llofstream presetsXML(pathName); LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); @@ -200,7 +201,7 @@ void LLWLParamManager::savePresets(const LLString & fileName) presetsXML.close(); } -void LLWLParamManager::loadPreset(const LLString & name) +void LLWLParamManager::loadPreset(const std::string & name) { // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_escape(name.c_str(), name.size()); @@ -213,7 +214,7 @@ void LLWLParamManager::loadPreset(const LLString & name) std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); llinfos << "Loading WindLight sky setting from " << pathName << llendl; - std::ifstream presetsXML(pathName.c_str()); + llifstream presetsXML(pathName); if (presetsXML) { @@ -232,6 +233,7 @@ void LLWLParamManager::loadPreset(const LLString & name) { setParamSet(name, paramsData); } + presetsXML.close(); } else { @@ -244,7 +246,7 @@ void LLWLParamManager::loadPreset(const LLString & name) propagateParameters(); } -void LLWLParamManager::savePreset(const LLString & name) +void LLWLParamManager::savePreset(const std::string & name) { // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_escape(name.c_str(), name.size()); @@ -262,7 +264,7 @@ void LLWLParamManager::savePreset(const LLString & name) paramsData = mParamList[name].getAll(); // write to file - std::ofstream presetsXML(pathName.c_str()); + llofstream presetsXML(pathName); LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); presetsXML.close(); @@ -531,7 +533,7 @@ bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_ if(delete_from_disk) { - LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); + std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); // use full curl escaped name char * curl_str = curl_escape(name.c_str(), name.size()); @@ -553,10 +555,10 @@ LLWLParamManager * LLWLParamManager::instance() { sInstance = new LLWLParamManager(); - sInstance->loadPresets(""); + sInstance->loadPresets(LLStringUtil::null); // load the day - sInstance->mDay.loadDayCycle("Default.xml"); + sInstance->mDay.loadDayCycle(std::string("Default.xml")); // *HACK - sets cloud scrolling to what we want... fix this better in the future sInstance->getParamSet("Default", sInstance->mCurParams); diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index 474db19cfa..1a2b2a3903 100644 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -45,15 +45,15 @@ class LLGLSLShader; struct WLColorControl { F32 r, g, b, i; /// the values - char const * name; /// name to use to dereference params + std::string mName; /// name to use to dereference params std::string mSliderName; /// name of the slider in menu bool hasSliderName; /// only set slider name for true color types bool isSunOrAmbientColor; /// flag for if it's the sun or ambient color controller bool isBlueHorizonOrDensity; /// flag for if it's the Blue Horizon or Density color controller - inline WLColorControl(F32 red, F32 green, F32 blue, F32 intensity, char const * n, - char const * sliderName = "") - : r(red), g(green), b(blue), i(intensity), name(n), mSliderName(sliderName) + inline WLColorControl(F32 red, F32 green, F32 blue, F32 intensity, + const std::string& n, const std::string& sliderName = LLStringUtil::null) + : r(red), g(green), b(blue), i(intensity), mName(n), mSliderName(sliderName) { // if there's a slider name, say we have one hasSliderName = false; @@ -90,18 +90,18 @@ struct WLColorControl { } inline void update(LLWLParamSet & params) const { - params.set(name, r, g, b, i); + params.set(mName, r, g, b, i); } }; // float slider control struct WLFloatControl { F32 x; - char const * name; + std::string mName; F32 mult; - inline WLFloatControl(F32 val, char const * n, F32 m=1.0f) - : x(val), name(n), mult(m) + inline WLFloatControl(F32 val, const std::string& n, F32 m=1.0f) + : x(val), mName(n), mult(m) { } @@ -116,7 +116,7 @@ struct WLFloatControl { } inline void update(LLWLParamSet & params) const { - params.set(name, x); + params.set(mName, x); } }; @@ -129,16 +129,16 @@ public: ~LLWLParamManager(); /// load a preset file - void loadPresets(const LLString & fileName); + void loadPresets(const std::string & fileName); /// save the preset file - void savePresets(const LLString & fileName); + void savePresets(const std::string & fileName); /// load an individual preset into the sky - void loadPreset(const LLString & name); + void loadPreset(const std::string & name); /// save the parameter presets to file - void savePreset(const LLString & name); + void savePreset(const std::string & name); /// Set shader uniforms dirty, so they'll update automatically. void propagateParameters(void); diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index 6e1a3972ea..7a109c42de 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -80,7 +80,7 @@ void LLWLParamSet::update(LLGLSLShader * shader) const i != mParamValues.endMap(); ++i) { - const LLString& param = i->first; + const std::string& param = i->first; if( param == "star_brightness" || param == "preset_num" || param == "sun_angle" || param == "east_angle" || param == "enable_cloud_scroll" || @@ -130,7 +130,7 @@ void LLWLParamSet::update(LLGLSLShader * shader) const } } -void LLWLParamSet::set(const char * paramName, float x) +void LLWLParamSet::set(const std::string& paramName, float x) { // handle case where no array if(mParamValues[paramName].isReal()) @@ -146,19 +146,19 @@ void LLWLParamSet::set(const char * paramName, float x) } } -void LLWLParamSet::set(const char * paramName, float x, float y) { +void LLWLParamSet::set(const std::string& paramName, float x, float y) { mParamValues[paramName][0] = x; mParamValues[paramName][1] = y; } -void LLWLParamSet::set(const char * paramName, float x, float y, float z) +void LLWLParamSet::set(const std::string& paramName, float x, float y, float z) { mParamValues[paramName][0] = x; mParamValues[paramName][1] = y; mParamValues[paramName][2] = z; } -void LLWLParamSet::set(const char * paramName, float x, float y, float z, float w) +void LLWLParamSet::set(const std::string& paramName, float x, float y, float z, float w) { mParamValues[paramName][0] = x; mParamValues[paramName][1] = y; @@ -166,7 +166,7 @@ void LLWLParamSet::set(const char * paramName, float x, float y, float z, float mParamValues[paramName][3] = w; } -void LLWLParamSet::set(const char * paramName, const float * val) +void LLWLParamSet::set(const std::string& paramName, const float * val) { mParamValues[paramName][0] = val[0]; mParamValues[paramName][1] = val[1]; @@ -174,7 +174,7 @@ void LLWLParamSet::set(const char * paramName, const float * val) mParamValues[paramName][3] = val[3]; } -void LLWLParamSet::set(const char * paramName, const LLVector4 & val) +void LLWLParamSet::set(const std::string& paramName, const LLVector4 & val) { mParamValues[paramName][0] = val.mV[0]; mParamValues[paramName][1] = val.mV[1]; @@ -182,7 +182,7 @@ void LLWLParamSet::set(const char * paramName, const LLVector4 & val) mParamValues[paramName][3] = val.mV[3]; } -void LLWLParamSet::set(const char * paramName, const LLColor4 & val) +void LLWLParamSet::set(const std::string& paramName, const LLColor4 & val) { mParamValues[paramName][0] = val.mV[0]; mParamValues[paramName][1] = val.mV[1]; @@ -190,7 +190,7 @@ void LLWLParamSet::set(const char * paramName, const LLColor4 & val) mParamValues[paramName][3] = val.mV[3]; } -LLVector4 LLWLParamSet::getVector(const char * paramName, bool& error) +LLVector4 LLWLParamSet::getVector(const std::string& paramName, bool& error) { // test to see if right type @@ -211,7 +211,7 @@ LLVector4 LLWLParamSet::getVector(const char * paramName, bool& error) return val; } -F32 LLWLParamSet::getFloat(const char * paramName, bool& error) +F32 LLWLParamSet::getFloat(const std::string& paramName, bool& error) { // test to see if right type diff --git a/indra/newview/llwlparamset.h b/indra/newview/llwlparamset.h index fe075ece9a..15afeaf364 100644 --- a/indra/newview/llwlparamset.h +++ b/indra/newview/llwlparamset.h @@ -48,7 +48,7 @@ class LLWLParamSet { friend class LLWLParamManager; public: - LLString mName; + std::string mName; private: @@ -73,20 +73,20 @@ public: /// Set a float parameter. /// \param paramName The name of the parameter to set. /// \param x The float value to set. - void set(const char * paramName, float x); + void set(const std::string& paramName, float x); /// Set a float2 parameter. /// \param paramName The name of the parameter to set. /// \param x The x component's value to set. /// \param y The y component's value to set. - void set(const char * paramName, float x, float y); + void set(const std::string& paramName, float x, float y); /// Set a float3 parameter. /// \param paramName The name of the parameter to set. /// \param x The x component's value to set. /// \param y The y component's value to set. /// \param z The z component's value to set. - void set(const char * paramName, float x, float y, float z); + void set(const std::string& paramName, float x, float y, float z); /// Set a float4 parameter. /// \param paramName The name of the parameter to set. @@ -94,32 +94,32 @@ public: /// \param y The y component's value to set. /// \param z The z component's value to set. /// \param w The w component's value to set. - void set(const char * paramName, float x, float y, float z, float w); + void set(const std::string& paramName, float x, float y, float z, float w); /// Set a float4 parameter. /// \param paramName The name of the parameter to set. /// \param val An array of the 4 float values to set the parameter to. - void set(const char * paramName, const float * val); + void set(const std::string& paramName, const float * val); /// Set a float4 parameter. /// \param paramName The name of the parameter to set. /// \param val A struct of the 4 float values to set the parameter to. - void set(const char * paramName, const LLVector4 & val); + void set(const std::string& paramName, const LLVector4 & val); /// Set a float4 parameter. /// \param paramName The name of the parameter to set. /// \param val A struct of the 4 float values to set the parameter to. - void set(const char * paramName, const LLColor4 & val); + void set(const std::string& paramName, const LLColor4 & val); /// Get a float4 parameter. /// \param paramName The name of the parameter to set. /// \param error A flag to set if it's not the proper return type - LLVector4 getVector(const char * paramName, bool& error); + LLVector4 getVector(const std::string& paramName, bool& error); /// Get an integer parameter /// \param paramName The name of the parameter to set. /// \param error A flag to set if it's not the proper return type - F32 getFloat(const char * paramName, bool& error); + F32 getFloat(const std::string& paramName, bool& error); // specific getters and setters diff --git a/indra/newview/llworldmap.cpp b/indra/newview/llworldmap.cpp index 1dd08604cd..2afeb4a1e4 100644 --- a/indra/newview/llworldmap.cpp +++ b/indra/newview/llworldmap.cpp @@ -237,7 +237,7 @@ LLSimInfo* LLWorldMap::simInfoFromHandle(const U64 handle) } -LLSimInfo* LLWorldMap::simInfoFromName(const LLString& sim_name) +LLSimInfo* LLWorldMap::simInfoFromName(const std::string& sim_name) { LLSimInfo* sim_info = NULL; if (!sim_name.empty()) @@ -246,7 +246,7 @@ LLSimInfo* LLWorldMap::simInfoFromName(const LLString& sim_name) { sim_info = (*it).second; if (sim_info - && (0 == LLString::compareInsensitive(sim_name.c_str(), sim_info->mName.c_str())) ) + && (0 == LLStringUtil::compareInsensitive(sim_name, sim_info->mName)) ) { break; } @@ -256,7 +256,7 @@ LLSimInfo* LLWorldMap::simInfoFromName(const LLString& sim_name) return sim_info; } -bool LLWorldMap::simNameFromPosGlobal(const LLVector3d& pos_global, LLString & outSimName ) +bool LLWorldMap::simNameFromPosGlobal(const LLVector3d& pos_global, std::string & outSimName ) { bool gotSimName = true; @@ -266,7 +266,7 @@ bool LLWorldMap::simNameFromPosGlobal(const LLVector3d& pos_global, LLString & o if (it != mSimInfoMap.end()) { LLSimInfo* info = (*it).second; - outSimName = info->mName.c_str(); + outSimName = info->mName; } else { @@ -552,16 +552,16 @@ void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) { U16 x_regions; U16 y_regions; - char name[MAX_STRING]; /* Flawfinder: ignore */ - U8 access; /* Flawfinder: ignore */ + std::string name; + U8 accesscode; U32 region_flags; U8 water_height; U8 agents; LLUUID image_id; msg->getU16Fast(_PREHASH_Data, _PREHASH_X, x_regions, block); msg->getU16Fast(_PREHASH_Data, _PREHASH_Y, y_regions, block); - msg->getStringFast(_PREHASH_Data, _PREHASH_Name, MAX_STRING, name, block); - msg->getU8Fast(_PREHASH_Data, _PREHASH_Access, access, block); /* Flawfinder: ignore */ + msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block); + msg->getU8Fast(_PREHASH_Data, _PREHASH_Access, accesscode, block); msg->getU32Fast(_PREHASH_Data, _PREHASH_RegionFlags, region_flags, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_WaterHeight, water_height, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Agents, agents, block); @@ -572,7 +572,7 @@ void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) U64 handle = to_region_handle(x_meters, y_meters); - if (access == 255) + if (accesscode == 255) { // This region doesn't exist if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && @@ -611,7 +611,7 @@ void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) siminfo->mHandle = handle; siminfo->mName.assign( name ); - siminfo->mAccess = access; /* Flawfinder: ignore */ + siminfo->mAccess = accesscode; siminfo->mRegionFlags = region_flags; siminfo->mWaterHeight = (F32) water_height; siminfo->mMapImageID[agent_flags] = image_id; @@ -655,9 +655,9 @@ void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) if(LLWorldMap::getInstance()->mSLURLCallback != NULL) { - // Server returns definitive capitalization, SLURL might - // not have that. - if (!stricmp(LLWorldMap::getInstance()->mSLURLRegionName.c_str(), name) || (LLWorldMap::getInstance()->mSLURLRegionHandle == handle)) + // Server returns definitive capitalization, SLURL might not have that. + if ((LLStringUtil::compareInsensitive(LLWorldMap::getInstance()->mSLURLRegionName, name)==0) + || (LLWorldMap::getInstance()->mSLURLRegionHandle == handle)) { url_callback_t callback = LLWorldMap::getInstance()->mSLURLCallback; @@ -685,12 +685,12 @@ void LLWorldMap::processMapItemReply(LLMessageSystem* msg, void**) for (S32 block=0; block<num_blocks; ++block) { U32 X, Y; - char name[MAX_STRING]; /* Flawfinder: ignore */ + std::string name; S32 extra, extra2; LLUUID uuid; msg->getU32Fast(_PREHASH_Data, _PREHASH_X, X, block); msg->getU32Fast(_PREHASH_Data, _PREHASH_Y, Y, block); - msg->getStringFast(_PREHASH_Data, _PREHASH_Name, MAX_STRING, name, block); + msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block); msg->getUUIDFast(_PREHASH_Data, _PREHASH_ID, uuid, block); msg->getS32Fast(_PREHASH_Data, _PREHASH_Extra, extra, block); msg->getS32Fast(_PREHASH_Data, _PREHASH_Extra2, extra2, block); @@ -735,7 +735,6 @@ void LLWorldMap::processMapItemReply(LLMessageSystem* msg, void**) case MAP_ITEM_PG_EVENT: // events case MAP_ITEM_MATURE_EVENT: { - char buffer[32]; /* Flawfinder: ignore */ struct tm* timep; // Convert to Pacific, based on server's opinion of whether // it's daylight savings time there. @@ -744,11 +743,10 @@ void LLWorldMap::processMapItemReply(LLMessageSystem* msg, void**) S32 display_hour = timep->tm_hour % 12; if (display_hour == 0) display_hour = 12; - snprintf(buffer, sizeof(buffer), "%d:%02d %s", /* Flawfinder: ignore */ - display_hour, - timep->tm_min, - (timep->tm_hour < 12 ? "AM" : "PM") ); - new_item.mToolTip.assign( buffer ); + new_item.mToolTip = llformat( "%d:%02d %s", + display_hour, + timep->tm_min, + (timep->tm_hour < 12 ? "AM" : "PM") ); // HACK: store Z in extra2 new_item.mPosGlobal.mdV[VZ] = (F64)extra2; @@ -824,7 +822,7 @@ void LLWorldMap::dump() from_region_handle(handle, &x_pos, &y_pos); llinfos << x_pos << "," << y_pos - << " " << info->mName.c_str() + << " " << info->mName << " " << (S32)info->mAccess << " " << std::hex << info->mRegionFlags << std::dec << " " << info->mWaterHeight diff --git a/indra/newview/llworldmap.h b/indra/newview/llworldmap.h index 3c22159cc8..5d9e1972ae 100644 --- a/indra/newview/llworldmap.h +++ b/indra/newview/llworldmap.h @@ -138,10 +138,10 @@ public: LLSimInfo* simInfoFromPosGlobal(const LLVector3d& pos_global); // Returns simulator information for named sim, or NULL if non-existent - LLSimInfo* simInfoFromName(const LLString& sim_name); + LLSimInfo* simInfoFromName(const std::string& sim_name); // Gets simulator name for a global position, returns true if it was found - bool simNameFromPosGlobal(const LLVector3d& pos_global, LLString & outSimName ); + bool simNameFromPosGlobal(const LLVector3d& pos_global, std::string& outSimName ); // Sets the current layer void setCurrentLayer(S32 layer, bool request_layer = false); diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 04a09490ea..b5e23550b9 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -99,7 +99,7 @@ S32 LLWorldMapView::sTrackingArrowY = 0; F32 LLWorldMapView::sPixelsPerMeter = 1.f; F32 CONE_SIZE = 0.6f; -std::map<std::string,LLString> LLWorldMapView::sStringsMap; +std::map<std::string,std::string> LLWorldMapView::sStringsMap; #define SIM_NULL_MAP_SCALE 1 // width in pixels, where we start drawing "null" sims #define SIM_MAP_AGENT_SCALE 2 // width in pixels, where we start drawing agents @@ -172,40 +172,40 @@ LLWorldMapView::LLWorldMapView(const std::string& name, const LLRect& rect ) const S32 DIR_HEIGHT = 10; LLRect major_dir_rect( 0, DIR_HEIGHT, DIR_WIDTH, 0 ); - mTextBoxNorth = new LLTextBox( "N", major_dir_rect ); + mTextBoxNorth = new LLTextBox( std::string("N"), major_dir_rect ); addChild( mTextBoxNorth ); LLColor4 minor_color( 1.f, 1.f, 1.f, .7f ); - mTextBoxEast = new LLTextBox( "E", major_dir_rect ); + mTextBoxEast = new LLTextBox( std::string("E"), major_dir_rect ); mTextBoxEast->setColor( minor_color ); addChild( mTextBoxEast ); major_dir_rect.mRight += 1 ; - mTextBoxWest = new LLTextBox( "W", major_dir_rect ); + mTextBoxWest = new LLTextBox( std::string("W"), major_dir_rect ); mTextBoxWest->setColor( minor_color ); addChild( mTextBoxWest ); major_dir_rect.mRight -= 1 ; - mTextBoxSouth = new LLTextBox( "S", major_dir_rect ); + mTextBoxSouth = new LLTextBox( std::string("S"), major_dir_rect ); mTextBoxSouth->setColor( minor_color ); addChild( mTextBoxSouth ); LLRect minor_dir_rect( 0, DIR_HEIGHT, DIR_WIDTH * 2, 0 ); - mTextBoxSouthEast = new LLTextBox( "SE", minor_dir_rect ); + mTextBoxSouthEast = new LLTextBox( std::string("SE"), minor_dir_rect ); mTextBoxSouthEast->setColor( minor_color ); addChild( mTextBoxSouthEast ); - mTextBoxNorthEast = new LLTextBox( "NE", minor_dir_rect ); + mTextBoxNorthEast = new LLTextBox( std::string("NE"), minor_dir_rect ); mTextBoxNorthEast->setColor( minor_color ); addChild( mTextBoxNorthEast ); - mTextBoxSouthWest = new LLTextBox( "SW", minor_dir_rect ); + mTextBoxSouthWest = new LLTextBox( std::string("SW"), minor_dir_rect ); mTextBoxSouthWest->setColor( minor_color ); addChild( mTextBoxSouthWest ); - mTextBoxNorthWest = new LLTextBox( "NW", minor_dir_rect ); + mTextBoxNorthWest = new LLTextBox( std::string("NW"), minor_dir_rect ); mTextBoxNorthWest->setColor( minor_color ); addChild( mTextBoxNorthWest ); } @@ -625,33 +625,31 @@ void LLWorldMapView::draw() // Draw the region name in the lower left corner LLFontGL* font = LLFontGL::sSansSerifSmall; - char mesg[MAX_STRING]; /* Flawfinder: ignore */ + std::string mesg; if (gMapScale < sThresholdA) { - mesg[0] = '\0'; } else if (gMapScale < sThresholdB) { - //sprintf(mesg, "%d", info->mAgents); - mesg[0] = '\0'; + // mesg = llformat( info->mAgents); } else { - //sprintf(mesg, "%d / %s (%s)", + //mesg = llformat("%d / %s (%s)", // info->mAgents, // info->mName.c_str(), - // LLViewerRegion::accessToShortString(info->mAccess) ); + // LLViewerRegion::accessToShortString(info->mAccess).c_str() ); if (info->mAccess == SIM_ACCESS_DOWN) { - snprintf(mesg, MAX_STRING, "%s (%s)", info->mName.c_str(), sStringsMap["offline"].c_str()); /* Flawfinder: ignore */ + mesg = llformat( "%s (%s)", info->mName.c_str(), sStringsMap["offline"].c_str()); } else { - snprintf(mesg, MAX_STRING, "%s", info->mName.c_str()); /* Flawfinder: ignore */ + mesg = info->mName; } } - if (mesg[0] != '\0') + if (!mesg.empty()) { font->renderUTF8( mesg, 0, @@ -668,7 +666,7 @@ void LLWorldMapView::draw() simimage->getDiscardLevel() != 0) { font->renderUTF8( - sStringsMap["loading"].c_str(), 0, + sStringsMap["loading"], 0, llfloor(left + 18), llfloor(top - 25), LLColor4::white, @@ -1017,8 +1015,8 @@ LLVector3 LLWorldMapView::globalPosToView( const LLVector3d& global_pos ) } -void LLWorldMapView::drawTracking(const LLVector3d& pos_global, const LLColor4& color, - BOOL draw_arrow, LLString label, LLString tooltip, S32 vert_offset ) +void LLWorldMapView::drawTracking(const LLVector3d& pos_global, const LLColor4& color, BOOL draw_arrow, + const std::string& label, const std::string& tooltip, S32 vert_offset ) { LLVector3 pos_local = globalPosToView( pos_global ); S32 x = llround( pos_local.mV[VX] ); @@ -1108,7 +1106,7 @@ LLVector3d LLWorldMapView::viewPosToGlobal( S32 x, S32 y ) } -BOOL LLWorldMapView::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen ) +BOOL LLWorldMapView::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen ) { LLVector3d pos_global = viewPosToGlobal(x, y); @@ -1120,7 +1118,7 @@ BOOL LLWorldMapView::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_ std::string message = llformat("%s (%s)", info->mName.c_str(), - LLViewerRegion::accessToString(info->mAccess)); + LLViewerRegion::accessToString(info->mAccess).c_str()); if (info->mAccess != SIM_ACCESS_DOWN) { @@ -1784,10 +1782,11 @@ BOOL LLWorldMapView::handleDoubleClick( S32 x, S32 y, MASK mask ) { gFloaterWorldMap->close(); // This is an ungainly hack - char uuid_str[38]; /* Flawfinder: ignore */ + std::string uuid_str; S32 event_id; id.toString(uuid_str); - sscanf(&uuid_str[28], "%X", &event_id); + uuid_str = uuid_str.substr(28); + sscanf(uuid_str.c_str(), "%X", &event_id); LLFloaterDirectory::showEvents(event_id); break; } diff --git a/indra/newview/llworldmapview.h b/indra/newview/llworldmapview.h index 8f70b79f2e..7fce2a03cc 100644 --- a/indra/newview/llworldmapview.h +++ b/indra/newview/llworldmapview.h @@ -69,7 +69,7 @@ public: virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask ); virtual BOOL handleHover( S32 x, S32 y, MASK mask ); - virtual BOOL handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen ); + virtual BOOL handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen ); bool checkItemHit(S32 x, S32 y, LLItemInfo& item, LLUUID* id, bool track); void handleClick(S32 x, S32 y, MASK mask, S32* hit_type, LLUUID* id); @@ -95,9 +95,9 @@ public: // Draw the tracking indicator, doing the right thing if it's outside // the view area. - void drawTracking( const LLVector3d& pos_global, - const LLColor4& color, - BOOL draw_arrow = TRUE, LLString label = LLString(), LLString tooltip = "", S32 vert_offset = 0); + void drawTracking( const LLVector3d& pos_global, const LLColor4& color, BOOL draw_arrow = TRUE, + const std::string& label = std::string(), const std::string& tooltip = std::string(), + S32 vert_offset = 0); static void drawTrackingArrow(const LLRect& view_rect, S32 x, S32 y, const LLColor4& color, S32 arrow_size = DEFAULT_TRACKING_ARROW_SIZE); @@ -188,7 +188,7 @@ public: typedef std::vector<U64> handle_list_t; handle_list_t mVisibleRegions; // set every frame - static std::map<std::string,LLString> sStringsMap; + static std::map<std::string,std::string> sStringsMap; }; #endif diff --git a/indra/test/llblowfish_tut.cpp b/indra/test/llblowfish_tut.cpp index 3081ac3855..8fe8b7a720 100644 --- a/indra/test/llblowfish_tut.cpp +++ b/indra/test/llblowfish_tut.cpp @@ -57,8 +57,8 @@ namespace tut mInputSize = 36; } - bool matchFile(const char* filename, - const std::string& data) + bool matchFile(const std::string& filename, + const std::string& data) { LLFILE* fp = LLFile::fopen(filename, "rb"); if (!fp) @@ -66,7 +66,7 @@ namespace tut // sometimes test is run inside the indra directory std::string path = "test/"; path += filename; - fp = LLFile::fopen(path.c_str(), "rb"); + fp = LLFile::fopen(path, "rb"); } if (!fp) { diff --git a/indra/test/llmessageconfig_tut.cpp b/indra/test/llmessageconfig_tut.cpp index c2329220e5..3dcf251fc0 100644 --- a/indra/test/llmessageconfig_tut.cpp +++ b/indra/test/llmessageconfig_tut.cpp @@ -56,7 +56,7 @@ namespace tut oStr << "/tmp/llmessage-config-test-" << random; #endif mTestConfigDir = oStr.str(); - LLFile::mkdir(mTestConfigDir.c_str()); + LLFile::mkdir(mTestConfigDir); writeConfigFile(LLSD()); LLMessageConfig::initClass("simulator", mTestConfigDir); } @@ -64,16 +64,16 @@ namespace tut ~LLMessageConfigTestData() { // rm contents of temp dir - int rmfile = LLFile::remove((mTestConfigDir + "/message.xml").c_str()); + int rmfile = LLFile::remove((mTestConfigDir + "/message.xml")); ensure_equals("rmfile value", rmfile, 0); // rm temp dir - int rmdir = LLFile::rmdir(mTestConfigDir.c_str()); + int rmdir = LLFile::rmdir(mTestConfigDir); ensure_equals("rmdir value", rmdir, 0); } void writeConfigFile(const LLSD& config) { - llofstream file((mTestConfigDir + "/message.xml").c_str()); + llofstream file((mTestConfigDir + "/message.xml")); if (file.is_open()) { LLSDSerialize::toPrettyXML(config, file); diff --git a/indra/test/llsd_new_tut.cpp b/indra/test/llsd_new_tut.cpp index b40d4fa348..529e0df20f 100644 --- a/indra/test/llsd_new_tut.cpp +++ b/indra/test/llsd_new_tut.cpp @@ -132,13 +132,11 @@ namespace tut v = newUUID; ensureTypeAndValue("set to new UUID", v, newUUID); v = nullUUID; ensureTypeAndValue("set to null again", v, nullUUID); - // strings must be tested with three (!) types of string objects + // strings must be tested with two types of string objects std::string s = "now is the time"; - LLString ls = "for all good zorks"; - const char* cs = "to come to the air of their planet"; + const char* cs = "for all good zorks"; v = s; ensureTypeAndValue("set to std::string", v, s); - v = ls; ensureTypeAndValue("set to LLString", v, ls); v = cs; ensureTypeAndValue("set to const char*", v, cs); LLDate epoch; @@ -186,10 +184,10 @@ namespace tut ensureTypeAndValue("construct std::string", ss1, "abc"); LLSD ss2 = std::string("abc"); ensureTypeAndValue("initialize std::string",ss2, "abc"); - LLSD sl1(LLString("def")); - ensureTypeAndValue("construct LLString", sl1, "def"); - LLSD sl2 = LLString("def"); - ensureTypeAndValue("initialize LLString", sl2, "def"); + LLSD sl1(std::string("def")); + ensureTypeAndValue("construct std::string", sl1, "def"); + LLSD sl2 = std::string("def"); + ensureTypeAndValue("initialize std::string", sl2, "def"); LLSD sc1("ghi"); ensureTypeAndValue("construct const char*", sc1, "ghi"); LLSD sc2 = "ghi"; @@ -432,10 +430,6 @@ namespace tut // SAD s = v; ensure_equals("assign to string", s, " 42.375"); s = (std::string)v; ensure_equals("cast to string", s, " 42.375"); - LLString t = "yo"; -// SAD t = v; ensure_equals("assign to LLString", t, " 42.375"); - t = (LLString)v; ensure_equals("cast to LLString", t, " 42.375"); - std::string uuidStr = "b1e50c2b-b627-4d23-8a86-a65d97b6319b"; v = uuidStr; LLUUID u; @@ -486,10 +480,10 @@ namespace tut ensure_equals("contruct string", s1, " 42.375"); ensure_equals("initialize string", s2, " 42.375"); - LLString t1(v); - LLString t2 = v.asString(); // SAD - ensure_equals("contruct LLString", t1, " 42.375"); - ensure_equals("initialize LLString", t2, " 42.375"); + std::string t1(v); + std::string t2 = v.asString(); // SAD + ensure_equals("contruct std::string", t1, " 42.375"); + ensure_equals("initialize std::string", t2, " 42.375"); std::string uuidStr = "b1e50c2b-b627-4d23-8a86-a65d97b6319b"; v = uuidStr; diff --git a/indra/test/llsdtraits.h b/indra/test/llsdtraits.h index 97eece6ff0..e140be2a7d 100644 --- a/indra/test/llsdtraits.h +++ b/indra/test/llsdtraits.h @@ -84,10 +84,6 @@ LLSDTraits<LLSD::String>::LLSDTraits() { } template<> -class LLSDTraits<LLString> : public LLSDTraits<LLSD::String> -{ }; - -template<> class LLSDTraits<const char*> : public LLSDTraits<LLSD::String> { }; diff --git a/indra/test/message_tut.cpp b/indra/test/message_tut.cpp index 57db6dd97a..d426511d24 100644 --- a/indra/test/message_tut.cpp +++ b/indra/test/message_tut.cpp @@ -93,7 +93,7 @@ namespace tut random.generate(); ostr << "message-test-" << random; mTestConfigDir = ostr.str(); - LLFile::mkdir(mTestConfigDir.c_str()); + LLFile::mkdir(mTestConfigDir); writeConfigFile(LLSD()); LLMessageConfig::initClass("simulator", ostr.str()); } @@ -107,11 +107,11 @@ namespace tut // rm contents of temp dir std::ostringstream ostr; ostr << mTestConfigDir << mSep << "message.xml"; - int rmfile = LLFile::remove(ostr.str().c_str()); + int rmfile = LLFile::remove(ostr.str()); ensure_equals("rmfile value", rmfile, 0); // rm temp dir - int rmdir = LLFile::rmdir(mTestConfigDir.c_str()); + int rmdir = LLFile::rmdir(mTestConfigDir); ensure_equals("rmdir value", rmdir, 0); } @@ -119,7 +119,7 @@ namespace tut { std::ostringstream ostr; ostr << mTestConfigDir << mSep << "message.xml"; - llofstream file(ostr.str().c_str()); + llofstream file(ostr.str()); if (file.is_open()) { LLSDSerialize::toPrettyXML(config, file); diff --git a/indra/win_crash_logger/llcrashloggerwindows.cpp b/indra/win_crash_logger/llcrashloggerwindows.cpp index b09821977d..40dbc3bbd0 100644 --- a/indra/win_crash_logger/llcrashloggerwindows.cpp +++ b/indra/win_crash_logger/llcrashloggerwindows.cpp @@ -59,7 +59,7 @@ HINSTANCE hInst= NULL; // current instance TCHAR szTitle[MAX_LOADSTRING]; /* Flawfinder: ignore */ // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; /* Flawfinder: ignore */ // The title bar text -LLString gProductName; +std::string gProductName; HWND gHwndReport = NULL; // Send/Don't Send dialog HWND gHwndProgress = NULL; // Progress window HCURSOR gCursorArrow = NULL; @@ -97,7 +97,7 @@ void write_debug(std::string& str) write_debug(str.c_str()); } -void show_progress(const char* message) +void show_progress(const std::string& message) { std::wstring msg = wstring_to_utf16str(utf8str_to_wstring(message)); if (gHwndProgress) @@ -198,7 +198,7 @@ bool handle_button_click(WORD button_id) wbuffer, // pointer to buffer for text 20000 // maximum size of string ); - LLString user_text(ll_convert_wide_to_string(wbuffer)); + std::string user_text(ll_convert_wide_to_string(wbuffer)); // Activate and show the window. ShowWindow(gHwndProgress, SW_SHOW); // Try doing this second to make the progress window go frontmost. @@ -357,10 +357,10 @@ bool LLCrashLoggerWindows::mainLoop() return 0; } -void LLCrashLoggerWindows::updateApplication(LLString message) +void LLCrashLoggerWindows::updateApplication(const std::string& message) { LLCrashLogger::updateApplication(); - if(message != "") show_progress(message.c_str()); + if(!message.empty()) show_progress(message); update_messages(); } diff --git a/indra/win_crash_logger/llcrashloggerwindows.h b/indra/win_crash_logger/llcrashloggerwindows.h index 1f5a216947..45c3b4772b 100644 --- a/indra/win_crash_logger/llcrashloggerwindows.h +++ b/indra/win_crash_logger/llcrashloggerwindows.h @@ -44,7 +44,7 @@ public: ~LLCrashLoggerWindows(void); virtual bool init(); virtual bool mainLoop(); - virtual void updateApplication(LLString message = ""); + virtual void updateApplication(const std::string& message = LLStringUtil::null); virtual bool cleanup(); virtual void gatherPlatformSpecificFiles(); //void annotateCallStack(); |