diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-06-26 00:39:00 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-06-26 00:39:00 +0000 |
commit | 25c10ed028da5c547b11f1f461916897272b0e6d (patch) | |
tree | 350a5858f8970b6e28b2dc395625d74d8bd597b2 /indra/llimage | |
parent | 6dd125d375b38455997a0c4b8747659f4c2351aa (diff) |
QAR-628 merge string-cleanup-5 -r 90476:90508 -> release
dataserver-is-deprecated
Diffstat (limited to 'indra/llimage')
-rw-r--r-- | indra/llimage/llimage.cpp | 48 | ||||
-rw-r--r-- | indra/llimage/llimage.h | 20 | ||||
-rw-r--r-- | indra/llimage/llimagej2c.cpp | 2 | ||||
-rw-r--r-- | indra/llimage/llimagej2c.h | 2 | ||||
-rw-r--r-- | indra/llimage/llimagetga.cpp | 12 | ||||
-rw-r--r-- | indra/llimage/llimagetga.h | 4 | ||||
-rw-r--r-- | indra/llimage/llpngwrapper.cpp | 2 | ||||
-rw-r--r-- | indra/llimage/llpngwrapper.h | 4 |
8 files changed, 47 insertions, 47 deletions
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 |